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

Annotations: refactor setting the normal appearance stream #8065

Merged
merged 1 commit into from
Feb 15, 2017

Conversation

timvandermeij
Copy link
Contributor

@timvandermeij timvandermeij commented Feb 12, 2017

Previously, we had a function called getDefaultAppearance. This name, however, is misleading as the method gets the normal appearance (in the N entry) and not the default appearance (in the DA entry). Moreover, it was not entirely clear how it works just from reading the code. It primarily lacks comments and explicit error case handling.

This patch improves the situation by fixing the issues mentioned above and making this function a proper method of the Annotation class, just like e.g., setColor and setBorderStyle.

@timvandermeij
Copy link
Contributor Author

/botio-linux preview

@timvandermeij
Copy link
Contributor Author

/botio test

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.

As can be seen from the test results, this causes "double" rendering in some of the annotation tests.

I'd assume that the source of the problems is that you're now attempting to send a Stream (compared to just a boolean previously) from the worker to the main thread, which most likely is not going to work since its data structure is too complicated for that.

Edit: Basically, you need to revert the second commit, since it first of all doesn't work to send a Stream to the display layer and second of all there's nothing you can use it for there (even if sending it would work).

@timvandermeij timvandermeij changed the title [api-minor] Refactor setting the normal appearance stream and remove hasAppearance Annotations: refactor setting the normal appearance stream Feb 13, 2017
@timvandermeij
Copy link
Contributor Author

timvandermeij commented Feb 13, 2017

Thank you for pointing this out! I removed the second commit and improved the first commit with a comment above the method (which I initially forgot). Hopefully all is fine now. Without that second commit, there are no more API changes in this patch.

@timvandermeij
Copy link
Contributor Author

/botio-linux preview

@timvandermeij
Copy link
Contributor Author

/botio test

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.

Seems fine, with the comment addressed. Thank you!

if (isStream(normalAppearanceState)) {
this.appearance = normalAppearanceState;
return;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm thinking that you may be able to simplify the conditions above slightly.
Wouldn't the following code work just as well?

// In case the normal appearance is a stream, then it is used directly.
if (isStream(normalAppearanceState)) {
  this.appearance = normalAppearanceState;
  return;
}
if (!isDict(normalAppearanceState)) {
  return;
}
// In case the normal appearance is a dictionary, the `AS` entry provides
// the key of the stream in this dictionary.
...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. This reduced the length of the method by two lines.

Previously, we had a function called `getDefaultAppearance`. This name,
however, is misleading as the method gets the normal appearance (in the
`N` entry) and not the default appearance (in the `DA` entry). Moreover,
it was not entirely clear how it works just from reading the code. It
primarily lacks comments and explicit error case handling.

This patch improves the situation by fixing the issues mentioned above
and making this function a proper method of the `Annotation` class, just
like e.g., `setColor` and `setBorderStyle`.
@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/22bcb7ed291afbc/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/22bcb7ed291afbc/output.txt

Total script time: 2.18 mins

Published

@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/48d06f15c39e582/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://54.215.176.217:8877/6fe154a92c1271c/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://54.215.176.217:8877/6fe154a92c1271c/output.txt

Total script time: 21.49 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/48d06f15c39e582/output.txt

Total script time: 25.62 mins

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

@timvandermeij timvandermeij merged commit 8aad33e into mozilla:master Feb 15, 2017
@timvandermeij timvandermeij deleted the annotation-appearances branch February 15, 2017 22:27
movsb pushed a commit to movsb/pdf.js that referenced this pull request Jul 14, 2018
…nces

Annotations: refactor setting the normal appearance stream
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