Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement support for square and circle annotations #8691

Merged

Conversation

timvandermeij
Copy link
Contributor

The commit descriptions provide more information about the individual changes.

@timvandermeij timvandermeij force-pushed the square-circle-annotations branch from fd74034 to ac226b9 Compare July 23, 2017 22:51
@mozilla mozilla deleted a comment from pdfjsbot Jul 23, 2017
@mozilla mozilla deleted a comment from pdfjsbot Jul 23, 2017
@timvandermeij
Copy link
Contributor Author

/botio-linux preview

@timvandermeij
Copy link
Contributor Author

/botio test

@timvandermeij
Copy link
Contributor Author

timvandermeij commented Jul 31, 2017

Would somebody perhaps have time to review this patch? It will make it easier to implement more annotation types and it is the first step towards supporting annotations without appearance streams (since the invisible annotations that we draw over the canvas can also be made visible and styled in case of missing appearance streams more easily with this approach). Thank you!

@timvandermeij timvandermeij changed the title Implement square and circle annotations Implement support for square and circle annotations Jul 31, 2017
@yurydelendik yurydelendik self-requested a review July 31, 2017 21:14
@timvandermeij timvandermeij force-pushed the square-circle-annotations branch from ac226b9 to 0a16908 Compare August 31, 2017 22:00
@timvandermeij
Copy link
Contributor Author

timvandermeij commented Aug 31, 2017

I have updated the patches to resolve conflicts and to convert the code to ES6 syntax after the recent introduction of this for the annotation layer.

Copy link
Contributor

@yurydelendik yurydelendik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

I'm thinking DOMSVGFactory must be created Abstract factory. This means that it will not have static member and be an object that we can pass around. It will have a nice effect: we can replace node polyfill with NodeSVGFactory and have it in the library.

// the borders outside the square by default. This behavior cannot be
// changed programmatically, so correct for that here.
let borderWidth = data.borderStyle.width;
let square = document.createElementNS(SVG_NS, 'svg:rect');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add createElement to the DOMSVGFactory.

// changed programmatically, so correct for that here.
let borderWidth = data.borderStyle.width;
let square = document.createElementNS(SVG_NS, 'svg:rect');
square.setAttributeNS(null, 'x', borderWidth / 2);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if just setAttribute('x', boderWidth / 2); will work?

@@ -109,6 +110,23 @@ class DOMCMapReaderFactory {
}
}

class DOMSVGFactory {
static create(width, height) {
if (width <= 0 || height <= 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we will keep DOMSVGFactory internal to the library, assert() is preferred.

This patch provides a new unit tested factory for creating SVG
containers and elements. This code is duplicated twice in the
codebase, but with upcoming changes this would need to be duplicated
even more. Moreover, consolidating this code in one factory allows
us to replace it easily for e.g., supporting Node.js. Therefore, move
this to a central place and update/ES6-ify the related code.

Finally, we replace `setAttributeNS` with `setAttribute` because no
namespace is provided.
@timvandermeij timvandermeij force-pushed the square-circle-annotations branch from 0a16908 to c04f9d6 Compare September 9, 2017 19:42
@timvandermeij
Copy link
Contributor Author

timvandermeij commented Sep 9, 2017

Thank you for the review! I incorporated all the improvements you mentioned and verified that everything still works. I like how the SVG factory now also handles element creation so we don't need to export the SVG_NS constant anymore and there is no more explicit document usage; it's all encapsulated in the factory now.

@timvandermeij
Copy link
Contributor Author

/botio-linux preview

@pdfjsbot
Copy link

pdfjsbot commented Sep 9, 2017

From: Bot.io (Linux m4)


Received

Command cmd_preview from @timvandermeij received. Current queue size: 0

Live output at: http://54.67.70.0:8877/45058e3caa45d22/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Sep 9, 2017

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/45058e3caa45d22/output.txt

Total script time: 2.30 mins

Published

@mozilla mozilla deleted a comment from pdfjsbot Sep 9, 2017
@mozilla mozilla deleted a comment from pdfjsbot Sep 9, 2017
@mozilla mozilla deleted a comment from pdfjsbot Sep 9, 2017
@mozilla mozilla deleted a comment from pdfjsbot Sep 9, 2017
@mozilla mozilla deleted a comment from pdfjsbot Sep 9, 2017
@mozilla mozilla deleted a comment from pdfjsbot Sep 9, 2017
@timvandermeij
Copy link
Contributor Author

/botio test

@pdfjsbot
Copy link

pdfjsbot commented Sep 9, 2017

From: Bot.io (Linux m4)


Received

Command cmd_test from @timvandermeij received. Current queue size: 0

Live output at: http://54.67.70.0:8877/c4624884bdc2cab/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Sep 9, 2017

From: Bot.io (Windows)


Received

Command cmd_test from @timvandermeij received. Current queue size: 0

Live output at: http://54.215.176.217:8877/1fbafd100330961/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Sep 9, 2017

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/c4624884bdc2cab/output.txt

Total script time: 16.58 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: Passed

@pdfjsbot
Copy link

pdfjsbot commented Sep 9, 2017

From: Bot.io (Windows)


Success

Full output at http://54.215.176.217:8877/1fbafd100330961/output.txt

Total script time: 29.59 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: Passed

@timvandermeij
Copy link
Contributor Author

/botio makeref

@pdfjsbot
Copy link

pdfjsbot commented Sep 9, 2017

From: Bot.io (Linux m4)


Received

Command cmd_makeref from @timvandermeij received. Current queue size: 0

Live output at: http://54.67.70.0:8877/5b15fef1f84edf0/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Sep 9, 2017

From: Bot.io (Windows)


Received

Command cmd_makeref from @timvandermeij received. Current queue size: 0

Live output at: http://54.215.176.217:8877/6ede4e8756048f5/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Sep 9, 2017

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/5b15fef1f84edf0/output.txt

Total script time: 15.63 mins

  • Lint: Passed
  • Make references: Passed
  • Check references: Passed

@pdfjsbot
Copy link

pdfjsbot commented Sep 9, 2017

From: Bot.io (Windows)


Success

Full output at http://54.215.176.217:8877/6ede4e8756048f5/output.txt

Total script time: 27.81 mins

  • Lint: Passed
  • Make references: Passed
  • Check references: Passed

@timvandermeij timvandermeij merged commit 320779e into mozilla:master Sep 9, 2017
@timvandermeij timvandermeij deleted the square-circle-annotations branch September 9, 2017 20:56
timvandermeij added a commit to timvandermeij/pdf.js that referenced this pull request Sep 12, 2017
Node.js

This patch fixes a regression from PR mozilla#8691 where we switched to using
`setAttribute` instead of `setAttributeNS` if no namespace is provided.
movsb pushed a commit to movsb/pdf.js that referenced this pull request Jul 14, 2018
…tations

Implement support for square and circle annotations
movsb pushed a commit to movsb/pdf.js that referenced this pull request Jul 14, 2018
Node.js

This patch fixes a regression from PR mozilla#8691 where we switched to using
`setAttribute` instead of `setAttributeNS` if no namespace is provided.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants