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

[api-minor] Fixes behaviour of DOMCanvasFactory to return {canvas, context}. #8036

Merged
merged 1 commit into from
Feb 7, 2017

Conversation

mukulmishra18
Copy link
Contributor

Fixes the behaviour of DOMCanvasFactory to return {canvas, context} pair instead to make it work for node's canvas.

canvasEntry = this.canvasFactory.create(width, height);
this.cache[id] = canvasEntry;
}
if (trackTransform) {
Copy link
Contributor

@timvandermeij timvandermeij Feb 6, 2017

Choose a reason for hiding this comment

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

Previously, this was inside the else branch. Shouldn't it be there now as well instead of outside of it?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

For node-canvas, the canvas and context must be re-created. It will fine to that after the if.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good, let's keep it like this then. Thanks for clearing up the confusion!

return canvas;
return {
canvas: canvas,
context: context
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: add a trailing comma here, i.e., context: context,. This is to avoid unnecessarily line changes in the diff later on if new items are added to this object.

canvas.height = 0;
canvasAndContextPair.canvas.width = 0;
canvasAndContextPair.canvas.height = 0;
canvasAndContextPair.canvas = null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this? I think zeroing the width and height should be enough, just like in the previous version.

Copy link
Contributor

Choose a reason for hiding this comment

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

loosing DOM object reference is always a plus

Copy link
Contributor

Choose a reason for hiding this comment

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

Good point. Let's keep this then.

Copy link
Collaborator

Choose a reason for hiding this comment

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

loosing DOM object reference is always a plus

Then we probably ought to get rid of the context in a similar way, or am I missing something?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, context must be nulled as well

Copy link
Contributor

@timvandermeij timvandermeij 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 with passing tests.

@Snuffleupagus
Copy link
Collaborator

/botio test

@pdfjsbot
Copy link

pdfjsbot commented Feb 7, 2017

From: Bot.io (Linux)


Received

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

Live output at: http://107.21.233.14:8877/f7967e323e6ced6/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Feb 7, 2017

From: Bot.io (Windows)


Received

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

Live output at: http://54.215.176.217:8877/b69e35d4250f76f/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Feb 7, 2017

From: Bot.io (Windows)


Success

Full output at http://54.215.176.217:8877/b69e35d4250f76f/output.txt

Total script time: 22.11 mins

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

@pdfjsbot
Copy link

pdfjsbot commented Feb 7, 2017

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/f7967e323e6ced6/output.txt

Total script time: 25.27 mins

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

@yurydelendik yurydelendik changed the title Fixes behaviour of DOMCanvasFactory to return {canvas, context}. [api-minor] Fixes behaviour of DOMCanvasFactory to return {canvas, context}. Feb 7, 2017
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.

Thank you for the patch.

@yurydelendik yurydelendik merged commit 9b0e095 into mozilla:master Feb 7, 2017
@mukulmishra18 mukulmishra18 deleted the node-canvas branch September 19, 2017 08:22
movsb pushed a commit to movsb/pdf.js that referenced this pull request Jul 14, 2018
[api-minor] Fixes behaviour of DOMCanvasFactory to return {canvas, context}.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants