Skip to content

Handle non-integer Annotation border widths correctly (issue 14203) #14391

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
Dec 28, 2021

Conversation

KouWakai
Copy link
Contributor

The border width is expected to be 3 but tracing Class Annotation, I found the width actually comes as float 2.99998 so when the width passed to Number.Isinteger in Class AnnotationBorderStyle:setWidth() the width gets lost.

Number.Isinteger makes sure that the value should be integer.Taking it into account,adding Math.round can solve this issue I think.

@KouWakai
Copy link
Contributor Author

KouWakai commented Dec 22, 2021

This is my first time Pull request in my life.I apologize if there are any mistakes in this PR.

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.

In addition to the comment, please write a better commit message (and PR title/description) since as-is it's really quite difficult to understand this patch without looking at both the code and the relevant issue. (The first line of the commit message should be a short summary of the changes, and then you should also include additional information such as e.g. links to the specification and a good description of what you're changing and why.)

Furthermore, please add an eq test for these changes such that we avoid future regressions.

Also, please make sure that you follow all of https://github.com/mozilla/pdf.js/wiki/Contributing#4-run-lint-and-testing locally to ensure that the patch passes all existing tests.

@Snuffleupagus
Copy link
Collaborator

For the commit message, I'd suggest the following wording:

Handle non-integer Annotation border widths correctly (issue 14203)

The existing code appears to be wrong, since according to the PDF specification the border width of an Annotation only has to be a number and not specifically an integer. Please see:
 - https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf#page=392
 - https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf#G11.2096210
 - https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf#G6.1965562

@KouWakai KouWakai force-pushed the annot-border-correct branch from dd6ad7b to f5a8dd8 Compare December 23, 2021 17:43
@KouWakai KouWakai force-pushed the annot-border-correct branch from f5a8dd8 to d9e0160 Compare December 23, 2021 17:56
@Snuffleupagus Snuffleupagus changed the title Add Math.round to get border width comes in float for issue 14203 Handle non-integer Annotation border widths correctly (issue 14203) Dec 23, 2021
@Snuffleupagus
Copy link
Collaborator

/botio test

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.241.84.105:8877/672384e03d797eb/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://54.193.163.58:8877/8adcceb2f041632/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/672384e03d797eb/output.txt

Total script time: 22.82 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Integration Tests: Passed
  • Regression tests: FAILED
  different ref/snapshot: 8

Image differences available at: http://54.241.84.105:8877/672384e03d797eb/reftest-analyzer.html#web=eq.log

@pdfjsbot
Copy link

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/8adcceb2f041632/output.txt

Total script time: 42.46 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Integration Tests: Passed
  • Regression tests: FAILED
  different ref/snapshot: 9
  different first/second rendering: 1

Image differences available at: http://54.193.163.58:8877/8adcceb2f041632/reftest-analyzer.html#web=eq.log

@Snuffleupagus
Copy link
Collaborator

Note that the test results above look good, despite the failures (those tests unfortunately fail intermittently).

#14391 (comment) also asked for a new unit-test as well (since you're new to the code-base I'll make a suggestion to help speed this up), and I'd thus suggest changing

const borderStyle = new AnnotationBorderStyle();
borderStyle.setWidth(3);
expect(borderStyle.width).toEqual(3);

to the following instead:

const borderStyleInt = new AnnotationBorderStyle();
borderStyleInt.setWidth(3);
const borderStyleNum = new AnnotationBorderStyle();
borderStyleNum.setWidth(2.5);

expect(borderStyleInt.width).toEqual(3);
expect(borderStyleNum.width).toEqual(2.5);

@KouWakai KouWakai force-pushed the annot-border-correct branch from d9e0160 to 702d2d7 Compare December 24, 2021 12:52
@KouWakai
Copy link
Contributor Author

Thank you for the suggestion and approved my commit.
I understand where to add unit tests and learned great example of commit message.

@timvandermeij
Copy link
Contributor

/botio-linux preview

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.241.84.105:8877/a53d125d4ec684d/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.241.84.105:8877/a53d125d4ec684d/output.txt

Total script time: 4.50 mins

Published

@timvandermeij timvandermeij merged commit 01b25b2 into mozilla:master Dec 28, 2021
@timvandermeij
Copy link
Contributor

Thank you for fixing this!

@timvandermeij
Copy link
Contributor

/botio makeref

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://54.193.163.58:8877/b137b96a71a8f09/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.241.84.105:8877/07c5b21596a63de/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.241.84.105:8877/07c5b21596a63de/output.txt

Total script time: 20.14 mins

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

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://54.193.163.58:8877/b137b96a71a8f09/output.txt

Total script time: 38.75 mins

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

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.

4 participants