-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
Implement support for square and circle annotations #8691
Conversation
fd74034
to
ac226b9
Compare
/botio-linux preview |
/botio test |
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! |
ac226b9
to
0a16908
Compare
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. |
There was a problem hiding this 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.
src/display/annotation_layer.js
Outdated
// 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'); |
There was a problem hiding this comment.
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.
src/display/annotation_layer.js
Outdated
// 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); |
There was a problem hiding this comment.
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?
src/display/dom_utils.js
Outdated
@@ -109,6 +110,23 @@ class DOMCMapReaderFactory { | |||
} | |||
} | |||
|
|||
class DOMSVGFactory { | |||
static create(width, height) { | |||
if (width <= 0 || height <= 0) { |
There was a problem hiding this comment.
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.
0a16908
to
c04f9d6
Compare
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 |
/botio-linux preview |
From: Bot.io (Linux m4)ReceivedCommand cmd_preview from @timvandermeij received. Current queue size: 0 Live output at: http://54.67.70.0:8877/45058e3caa45d22/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.67.70.0:8877/45058e3caa45d22/output.txt Total script time: 2.30 mins Published |
/botio test |
From: Bot.io (Linux m4)ReceivedCommand cmd_test from @timvandermeij received. Current queue size: 0 Live output at: http://54.67.70.0:8877/c4624884bdc2cab/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_test from @timvandermeij received. Current queue size: 0 Live output at: http://54.215.176.217:8877/1fbafd100330961/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.67.70.0:8877/c4624884bdc2cab/output.txt Total script time: 16.58 mins
|
From: Bot.io (Windows)SuccessFull output at http://54.215.176.217:8877/1fbafd100330961/output.txt Total script time: 29.59 mins
|
/botio makeref |
From: Bot.io (Linux m4)ReceivedCommand cmd_makeref from @timvandermeij received. Current queue size: 0 Live output at: http://54.67.70.0:8877/5b15fef1f84edf0/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_makeref from @timvandermeij received. Current queue size: 0 Live output at: http://54.215.176.217:8877/6ede4e8756048f5/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.67.70.0:8877/5b15fef1f84edf0/output.txt Total script time: 15.63 mins
|
From: Bot.io (Windows)SuccessFull output at http://54.215.176.217:8877/6ede4e8756048f5/output.txt Total script time: 27.81 mins
|
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.
…tations Implement support for square and circle annotations
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.
The commit descriptions provide more information about the individual changes.