Skip to content

Let non-viewable Popup Annotations inherit the parent's Annotation Flags if the parent is viewable #7352

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

Merged
merged 1 commit into from
May 25, 2016
Merged

Let non-viewable Popup Annotations inherit the parent's Annotation Flags if the parent is viewable #7352

merged 1 commit into from
May 25, 2016

Conversation

Snuffleupagus
Copy link
Collaborator

@Snuffleupagus Snuffleupagus commented May 24, 2016

Fixes http://www.pdf-archive.com/2013/09/30/file2/file2.pdf.

Note how it's not possible to show the various Popup Annotations in the above document.
To fix that, this patch lets the Popup inherit the flags of the parent, in the special case where the parent is viewable and the Popup is not.
In general, I don't think that a Popup must have the same flags set as the parent. However, it seems very strange to have a viewable parent annotation, and then not being able to view the Popup.

Annoyingly the PDF specification doesn't, as far as I can find, mention anything about how this case should be handled, but this patch seem consistent with the actual behaviour in Adobe Reader.

@timvandermeij How do you feel about this patch? Should we consider fixing this edge-case, or are we more worried about breakage elsewhere.
Please note: I've not attached a test-case, nor run the tests, since I wanted feedback on the general idea of the patch before spending a lot of time on this.

@timvandermeij
Copy link
Contributor

timvandermeij commented May 25, 2016

I think the general idea here is fine. Okular is also able to properly view this file, so I think it makes sense to fix this since other viewers can work with this PDF, even though (luckily) it's very much an edge case. The situation where the parent is visible but the popup is not is sufficiently rare that I'm not worried about breakage in other areas.

I followed the specification closely when I implemented this initially, so I'm also pretty sure that this case is not outlined in the specification, unfortunately.

@@ -55,6 +55,22 @@ var ObjectLoader = coreObj.ObjectLoader;
var FileSpec = coreObj.FileSpec;
var OperatorList = coreEvaluator.OperatorList;

function hasFlag(flags, bit) {
Copy link
Contributor

@timvandermeij timvandermeij May 25, 2016

Choose a reason for hiding this comment

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

Can we keep these functions inside the class, but instead access them via private methods? So, get viewable() would use return this._isViewable(this.flags) and _isViewable is a private method of the Annotation class. It seems to make sense to me to keep this inside the Annotation class as that is where they operate on. All other classes inherit from Annotation, so they will also have these private methods.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Can we keep these functions inside the class, but instead access them via private methods?

Of course we can, thanks for suggesting this!
I wasn't entirely happy about moving that code out of the Annotation class, so nice idea :-)

@Snuffleupagus Snuffleupagus changed the title [WIP] Let non-viewable Popup Annotations inherit the parent's Annotation Flags if the parent is viewable Let non-viewable Popup Annotations inherit the parent's Annotation Flags if the parent is viewable May 25, 2016
@Snuffleupagus
Copy link
Collaborator Author

/botio test

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://107.22.172.223:8877/30f4ff2591541c6/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

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

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

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://107.22.172.223:8877/30f4ff2591541c6/output.txt

Total script time: 21.26 mins

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

@pdfjsbot
Copy link

From: Bot.io (Linux)


Success

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

Total script time: 27.48 mins

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

@timvandermeij
Copy link
Contributor

/botio-linux preview

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

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

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

@@ -191,27 +191,48 @@ var Annotation = (function AnnotationClosure() {

Annotation.prototype = {
/**
* @private
*/
_hasFlag: function Annotation_isViewable(flags, flag) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be Annotation_hasFlag.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Whoops, fixed now.

…ags if the parent is viewable

Fixes http://www.pdf-archive.com/2013/09/30/file2/file2.pdf.

Note how it's not possible to show the various Popup Annotations in the above document.
To fix that, this patch lets the Popup inherit the flags of the parent, in the special case where the parent is `viewable` *and* the Popup is not.
In general, I don't think that a Popup must have the same flags set as the parent. However, it seems very strange to have a `viewable` parent annotation, and then not being able to view the Popup.

Annoyingly the PDF specification doesn't, as far as I can find, mention anything about how this case should be handled, but this patch seem consistent with the actual behaviour in Adobe Reader.
@timvandermeij
Copy link
Contributor

/botio makeref

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://107.22.172.223:8877/354c2e12d53a6b0/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

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

Live output at: http://107.21.233.14:8877/8773c81b7651ae1/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://107.22.172.223:8877/354c2e12d53a6b0/output.txt

Total script time: 21.14 mins

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

@pdfjsbot
Copy link

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/8773c81b7651ae1/output.txt

Total script time: 26.47 mins

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

@timvandermeij timvandermeij merged commit c55541f into mozilla:master May 25, 2016
@timvandermeij
Copy link
Contributor

Thank you for working on this!

@Snuffleupagus Snuffleupagus deleted the popup-annotation-inherit-parent-flags branch May 26, 2016 08:03
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