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

Document: handle indirect objects in MediaBox and CropBox entries #7873

Merged

Conversation

timvandermeij
Copy link
Contributor

@timvandermeij timvandermeij commented Dec 5, 2016

Fixes #7872.

@timvandermeij timvandermeij force-pushed the mediabox-cropbox-indirect branch 2 times, most recently from bca1768 to ade0700 Compare December 6, 2016 00:04
Copy link
Collaborator

@Snuffleupagus Snuffleupagus left a comment

Choose a reason for hiding this comment

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

To be totally honest, I'm imagining a much simpler and more general solution here. (Since this issue may happen again in the future if support for other "array" parameters are added).
My thinking is something like master...Snuffleupagus:issue-7872 instead, and a reduced test-case should be is easy to create here.
Should I submit a PR with that change, and a test-case included?

@timvandermeij
Copy link
Contributor Author

timvandermeij commented Dec 6, 2016

I think that's a nice solution as well. Good point! The only thing I think makes sense is to create the CropBox getter as in this PR because it brings it more in line with the other page properties (most notably the MediaBox getter that we already have, and the recently added UserUnit). It will also make it easier to expose via e.g., the API later on, and it makes the view getter less cluttered with crop box sanitizing code it shouldn't really need to worry about.

That being said, I do like your solution of not including the for loops in each getter and amending the getInteritedPageProp method instead (and of course the reduced test case!). How about updating this PR with two commits, the first one being your commit (that fixes the issue) and the second one being my commit without the for loops and length variables (for additional clean-up)? My commit will then be much shorter, but we would still have the getter/name improvements.

@Snuffleupagus
Copy link
Collaborator

The only thing I think makes sense is to create the CropBox getter as in this PR because it brings it more in line with the other page properties (most notably the MediaBox getter that we already have, and the recently added UserUnit). It will also make it easier to expose via e.g., the API later on, and it makes the view getter less cluttered with crop box sanitizing code it shouldn't really need to worry about.

That's a fair point, but I've got one small reservation: This would require us to always compute the intersection, since then get cropBox() will always be defined. Could we skip doing that if cropBox === mediaBox to avoid what will often be a useless Util.intersect call? If so, I'm OK with it :-)

@timvandermeij
Copy link
Contributor Author

Yes, I think that should be possible. I'll update the PR soon.

… fetch (and dereference) Arrays, and use that for the `MediaBox`/`CropBox` getters (issue 7872)
@timvandermeij timvandermeij force-pushed the mediabox-cropbox-indirect branch from ade0700 to e99e225 Compare December 8, 2016 21:28
Copy link
Collaborator

@Snuffleupagus Snuffleupagus 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!
r=me, with nits, assuming that the tests pass of course!

Edit: Obviously I cannot review my own patch, but yours look good :-)

return shadow(this, 'view', cropBox);

var intersection = Util.intersect(cropBox, mediaBox);
return shadow(this, 'view', !intersection ? mediaBox : intersection);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: It would probably suffice to just check intersection || mediaBox here, instead of the ternary condition.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in the new commit.

return shadow(this, 'view', mediaBox);
}
return shadow(this, 'view', cropBox);

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: I'm not sure if we need this newline for readability, let's make the diff smaller instead :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in the new commit.

This patch refactors the `CropBox` code to combine fetching and
validation code in a getter, like we already did for the `MediaBox`
property. Combined with variable name changes, this improves readability
of the code and makes the `view` getter simpler as well.
@timvandermeij timvandermeij force-pushed the mediabox-cropbox-indirect branch from e99e225 to 3800b5e Compare December 8, 2016 21:46
@timvandermeij
Copy link
Contributor Author

/botio-linux preview

@pdfjsbot
Copy link

pdfjsbot commented Dec 8, 2016

From: Bot.io (Linux)


Received

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

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

@pdfjsbot
Copy link

pdfjsbot commented Dec 8, 2016

From: Bot.io (Linux)


Success

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

Total script time: 2.06 mins

Published

@timvandermeij
Copy link
Contributor Author

/botio test

@pdfjsbot
Copy link

pdfjsbot commented Dec 8, 2016

From: Bot.io (Linux)


Received

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

Live output at: http://107.21.233.14:8877/970733f8e65554e/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Dec 8, 2016

From: Bot.io (Windows)


Received

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

Live output at: http://107.22.172.223:8877/9c80ac6c851058d/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Dec 8, 2016

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/970733f8e65554e/output.txt

Total script time: 26.47 mins

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

@pdfjsbot
Copy link

pdfjsbot commented Dec 8, 2016

From: Bot.io (Windows)


Success

Full output at http://107.22.172.223:8877/9c80ac6c851058d/output.txt

Total script time: 26.55 mins

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

@timvandermeij
Copy link
Contributor Author

/botio makeref

@pdfjsbot
Copy link

pdfjsbot commented Dec 8, 2016

From: Bot.io (Linux)


Received

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

Live output at: http://107.21.233.14:8877/599d47f295aedb8/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Dec 8, 2016

From: Bot.io (Windows)


Received

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

Live output at: http://107.22.172.223:8877/2bcf17ccfb2af69/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Dec 8, 2016

From: Bot.io (Windows)


Success

Full output at http://107.22.172.223:8877/2bcf17ccfb2af69/output.txt

Total script time: 26.10 mins

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

@timvandermeij
Copy link
Contributor Author

timvandermeij commented Dec 8, 2016

Even though the message has not been posted, the Linux bot finished successfully. Merging with r=me for @Snuffleupagus' commit. Thanks!

@timvandermeij timvandermeij merged commit 47f03b6 into mozilla:master Dec 8, 2016
@timvandermeij timvandermeij deleted the mediabox-cropbox-indirect branch December 8, 2016 22:59
movsb pushed a commit to movsb/pdf.js that referenced this pull request Jul 14, 2018
…ndirect

Document: handle indirect objects in `MediaBox` and `CropBox` entries
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.

3 participants