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

Refactor annotation color handling and add unit tests #6214

Merged
merged 1 commit into from Jul 16, 2015

Conversation

timvandermeij
Copy link
Contributor

This PR has the following goals:

  • Add unit tests for annotation colors. These tests describe the exact behavior that the annotation's setColor method should have according to the specification at https://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_reference_1-7.pdf#page=607&zoom=auto,-246,289.
  • Implement the setColor method on an annotation as described by the unit tests. Note that this also adds support for grayscale and CMYK color spaces (previously a TODO) practically for free.
  • Remove old color handling code and switch that to calling setColor.
  • Adjust and simplify the annotation display code. setColor takes care of color space conversion and color array preparation (as RGB), so we do not need to convert anything in the display layer anymore.

This rewrite automatically fixes an issue in the old code where transparency (here with color = null) would not be interpreted correctly and it would draw as black instead.

@Snuffleupagus Could you review this? It is a fairly easy patch and half of it are unit tests. http://tug.ctan.org/tex-archive/macros/latex/contrib/pdfcomment/doc/pdfcomment.pdf is a good document to verify that the colors are still the same before and after the patch (see page 6).


'use strict';

var DEFAULT_COLOR = [0, 0, 0]; // Black in RGB color space
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: How about using new UintArray(3) here 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.

This has been changed in the new commit so we do not even need this anymore.

@timvandermeij
Copy link
Contributor Author

/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/29488461e439a6a/output.txt

@timvandermeij
Copy link
Contributor Author

/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/63f2826b437d469/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/5a9d5b59cd9e010/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

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

Total script time: 18.30 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/63f2826b437d469/output.txt

Total script time: 19.54 mins

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

Snuffleupagus added a commit that referenced this pull request Jul 16, 2015
Refactor annotation color handling and add unit tests
@Snuffleupagus Snuffleupagus merged commit cf6d40f into mozilla:master Jul 16, 2015
@Snuffleupagus
Copy link
Collaborator

Looks good, thanks!

@timvandermeij timvandermeij deleted the annotation-color branch July 16, 2015 19:46
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.

None yet

3 participants