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

Improved annotations' display/behavior. #4318

Merged
merged 1 commit into from Mar 7, 2014
Merged

Improved annotations' display/behavior. #4318

merged 1 commit into from Mar 7, 2014

Conversation

ghost
Copy link

@ghost ghost commented Feb 22, 2014

Added an "InteractiveAnnotation" class to homogenize appearance (highlighting) and user interactions (for now, used for text and link annotations).

Text annotations:
The appearance (AP) has priority over the icon (Name).
The popup extends horizontally (up to a limit) as well as vertically.
Reduced the title's font size.
The annotation's color (C) is used to color the popup's background.
On top of the mouseover show/hide behavior, a click on the icon will lock the annotation open (for mobile purposes). It can be closed with another click on either the icon or the popup.

@yurydelendik
Copy link
Contributor

could you provide couple of test documents with steps to replicate?

/botio-windows preview

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://107.22.172.223:8877/70b9ed8a784bb31/output.txt

@Snuffleupagus
Copy link
Collaborator

This seems to break the display of normal links in PDFs, since they are no longer standard hyperlinks. For example, the mouse cursor doesn't change to indicating that links are clickable.

Also, with these changes, the HTML code for standard links have become unnecessarily complex, which I guess might explain some of the issues.

Btw, I tested with: http://mirrors.ctan.org/info/lshort/english/lshort.pdf.

Edit: Note that the links that are not working corresponds to internal destinations, which is a common way to link to other parts of the PDF file.

@ghost
Copy link
Author

ghost commented Feb 22, 2014

Here is a test file with different sorts of text annotations and a link: https://dl.dropboxusercontent.com/u/1910542/interactiveAnnotations.pdf

This is what it looks like with all annotations open:
screen shot 2014-02-21 at 8 44 42 pm

And in Adobe Reader:
screen shot 2014-02-21 at 8 45 53 pm

The link annotations' behavior is now the same as in Adobe Reader. The only difference is the highlighting effect on mouseover that is common to all interactive annotation so they can programmatically be highlighted through a common interface. If this is not desirable, I can change it back.

@ghost
Copy link
Author

ghost commented Feb 22, 2014

In my tests the cursor does change on links. Let me look what would be the difference with your test file.

@ghost
Copy link
Author

ghost commented Feb 22, 2014

I had missed the particular case of internal links. It is now fixed and the sample PDF is updated. Thanks for your test.
I removed the highlighting effects (unnecessary as the pointer already indicates that something is clickable) but I did leave the highlighting code because a global "highlight annotations" feature is something I would like to have available if possible.

Edit: just squashed the commits

@timvandermeij
Copy link
Contributor

Really nice patch! Especially https://dl.dropboxusercontent.com/u/1910542/interactiveAnnotations.pdf has improved a lot. This patch also seems to fix #3654.

@timvandermeij
Copy link
Contributor

@dferer I have added some comments about your code. The comments mainly address minor style issues as outlined in https://github.com/mozilla/pdf.js/wiki/Style-Guide. If you have addressed these comments, please squash your commits again to make review easier. Thanks! :)

@ghost
Copy link
Author

ghost commented Feb 22, 2014

@timvandermeij Done (I answered one of your comments). Thanks for the review!

@timvandermeij
Copy link
Contributor

/botio test

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

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

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

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://107.22.172.223:8877/33dd9dd94b01582/output.txt

@ghost
Copy link
Author

ghost commented Feb 22, 2014

FYI: some tests are expected to fail due to some text annotations' appearances (AP) that were previously ignored.

@pdfjsbot
Copy link

From: Bot.io (Linux)


Failed

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

Total script time: 23.58 mins

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

Image differences available at: http://107.21.233.14:8877/c12f9e4084fafea/reftest-analyzer.xhtml#web=eq.log

@pdfjsbot
Copy link

From: Bot.io (Windows)


Failed

Full output at http://107.22.172.223:8877/33dd9dd94b01582/output.txt

Total script time: 35.27 mins

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

Image differences available at: http://107.22.172.223:8877/33dd9dd94b01582/reftest-analyzer.xhtml#web=eq.log

@yurydelendik
Copy link
Contributor

(ff/linux might fail for some other tests)

@ghost
Copy link
Author

ghost commented Feb 22, 2014

Is there a way for me to see the image differences? The link in bot.io's output only shows an empty text area.

@timvandermeij
Copy link
Contributor

The link http://107.22.172.223:8877/33dd9dd94b01582/reftest-analyzer.xhtml#web=eq.log starts with an empty text area, but should show the image differences after a second (or whenever the images are loaded). What browser are you using?

@ghost
Copy link
Author

ghost commented Feb 22, 2014

I am using Safari 7.0.1 (OSX) and nothing happens even after a couple minutes.

I guess that would explain it ;):
screen shot 2014-02-22 at 12 48 31 pm

It does work with Firefox, and I confirm, the errors are the ones I expected.

@timvandermeij
Copy link
Contributor

@dferer I have just added some last review comments. It looks good to me when those are addressed.

@yurydelendik Could you also review this? And can you reproduce the issue with the reftest analyzer in Safari?

item.colorCssRgb = Util.makeCssRgb(rgb);

var highlight = document.createElement('div');
var highlightOffset = 4; // px
Copy link
Collaborator

Choose a reason for hiding this comment

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

You might want to consider adding this as a constant (i.e. var HIGHLIGHT_OFFSET = 4; // px placed just below use strict;) at the top of the file instead, to make it easier to find and change this value in the future.

@timvandermeij
Copy link
Contributor

@dferer Could you squash the commits again?

@ghost
Copy link
Author

ghost commented Feb 24, 2014

Done

@ghost ghost closed this Feb 24, 2014
@ghost ghost reopened this Feb 24, 2014
@ghost
Copy link
Author

ghost commented Feb 24, 2014

Oops wrong button

@timvandermeij
Copy link
Contributor

/botio test

@ghost
Copy link
Author

ghost commented Mar 7, 2014

Done

@yurydelendik
Copy link
Contributor

Awesome

/botio-linux preview

@pdfjsbot
Copy link

pdfjsbot commented Mar 7, 2014

From: Bot.io (Linux)


Received

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

Live output at: http://107.21.233.14:8877/2a1c0b987850c6a/output.txt

@yurydelendik
Copy link
Contributor

/botio test

Probably not a big deal. I'm kinda missing yellow box shadow for links, but that's probably because I used to see it for long time. If other people will miss it too, we will add something.

@pdfjsbot
Copy link

pdfjsbot commented Mar 7, 2014

From: Bot.io (Linux)


Received

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

Live output at: http://107.21.233.14:8877/482ee73a283a329/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Mar 7, 2014

From: Bot.io (Windows)


Received

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

Live output at: http://107.22.172.223:8877/5b6b8867cc1050d/output.txt

@ghost ghost closed this Mar 7, 2014
@ghost ghost reopened this Mar 7, 2014
@Snuffleupagus
Copy link
Collaborator

Probably not a big deal. I'm kinda missing yellow box shadow for links, but that's probably because I used to see it for long time. If other people will miss it too, we will add something.

That can easily be added back, just change this line: https://github.com/mozilla/pdf.js/blob/master/web/viewer.css#L1257 to .annotationLayer a:hover { instead.

Also with this patch, can we remove the following lines: https://github.com/mozilla/pdf.js/blob/master/web/viewer.css#L1250-L1256?

Edit: Removing the yellow box, as is done (inadvertently) by this PR, would fix: https://bugzilla.mozilla.org/show_bug.cgi?id=960580.

@ghost
Copy link
Author

ghost commented Mar 7, 2014

Done

Added an "InteractiveAnnotation" class to homogenize the annotations' structure (highlighting) and user interactions (for now, used for text and link annotations).

Text annotations:
The appearance (AP) has priority over the icon (Name).
The popup extends horizontally (up to a limit) as well as vertically.
Reduced the title's font size.
The annotation's color (C) is used to color the popup's background.
On top of the mouseover show/hide behavior, a click on the icon will lock the annotation open (for mobile purposes). It can be closed with another click on either the icon or the popup.

An annotation printing is conditioned by its "print" bit
Unsupported annotations are not displayed at all.
@ghost
Copy link
Author

ghost commented Mar 7, 2014

I put them back for now, although I would advocate removing them as it the default behavior in most other PDF readers.
I'll be waiting for your final decision.

@pdfjsbot
Copy link

pdfjsbot commented Mar 7, 2014

From: Bot.io (Windows)


Failed

Full output at http://107.22.172.223:8877/5b6b8867cc1050d/output.txt

Total script time: 35.83 mins

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

Image differences available at: http://107.22.172.223:8877/5b6b8867cc1050d/reftest-analyzer.html#web=eq.log

@yurydelendik
Copy link
Contributor

/botio-linux preview

@pdfjsbot
Copy link

pdfjsbot commented Mar 7, 2014

From: Bot.io (Linux)


Received

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

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

yurydelendik added a commit that referenced this pull request Mar 7, 2014
Improved annotations' display/behavior.
@yurydelendik yurydelendik merged commit 01b2343 into mozilla:master Mar 7, 2014
@yurydelendik
Copy link
Contributor

Thank you for the patch

@ghost ghost deleted the improveAnnotationsDisplay branch March 7, 2014 15:45
@yurydelendik
Copy link
Contributor

/botio makeref

@pdfjsbot
Copy link

pdfjsbot commented Mar 8, 2014

From: Bot.io (Linux)


Received

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

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

@pdfjsbot
Copy link

pdfjsbot commented Mar 8, 2014

From: Bot.io (Windows)


Received

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

Live output at: http://107.22.172.223:8877/dbd3de9151b9cbc/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Mar 8, 2014

From: Bot.io (Linux)


Failed

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

Total script time: 0.09 mins

@pdfjsbot
Copy link

pdfjsbot commented Mar 8, 2014

From: Bot.io (Windows)


Failed

Full output at http://107.22.172.223:8877/dbd3de9151b9cbc/output.txt

Total script time: 0.12 mins

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants