Skip to content

Fix XFA links (bug 1735738) #14153

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
Oct 29, 2021
Merged

Fix XFA links (bug 1735738) #14153

merged 1 commit into from
Oct 29, 2021

Conversation

cathydev
Copy link

@cathydev cathydev commented Oct 16, 2021

At the end the anchor tag inside the button wasn't the problem here, after comparing the reference file and this one

https://bug1716758.bmoattachments.org/attachment.cgi?id=9240360

I realized that in the reference file the anchor tag has an inline display and couldn't receive any height. After changing the display to inline-block it started working but since it receives a 100% height the text wasn't showing properly so I added an absolute position and now the reference file it's working in both Firefox nightly and Chrome.

It also solves a bug in this file

https://bug1716758.bmoattachments.org/attachment.cgi?id=9240360

Where the second link in schedule II wasn't working at all, now all links in both files are working just fine.

Thank you @calixteman for explaining me with so much patience!

closes #14139

@Snuffleupagus
Copy link
Collaborator

Can you please provide a bit more detail in the commit message as well (since it's currently a single sentence), and not just in the PR description?
Generally it's always a very good idea if it's possible to understand what a patch does and why from the commit message too, since that's often most helpful when looking at a patch on the Git command line (e.g. during bisecting).

@cathydev
Copy link
Author

Can you please provide a bit more detail in the commit message as well (since it's currently a single sentence), and not just in the PR description? Generally it's always a very good idea if it's possible to understand what a patch does and why from the commit message too, since that's often most helpful when looking at a patch on the Git command line (e.g. during bisecting).

Yes, it's no problem. Sorry for that, I'll make sure to be more specific in my commits from now on

@Snuffleupagus
Copy link
Collaborator

The commit message is still just a single sentence, and doesn't really contain all that much more information. Please imagine that you're looking at this commit locally, without using GitHub, in e.g. one month's time. Will it still help you understand what you changed and (importantly) why the implementation looks the way it does?

In #14153 (comment) you've got the following paragraph, which definitely seems like a good thing to also add to the commit message:

I realized that in the reference file the anchor tag has an inline display and couldn't receive any height. After changing the display to inline-block it started working but since it receives a 100% height the text wasn't showing properly so I added an absolute position and now the reference file it's working in both Firefox nightly and Chrome.

@@ -221,6 +221,8 @@
}

.xfaLink {
display: inline-block;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think display: inline-block is useless here.
Could you elaborate on why you added it ?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, as I mentioned I added it because the inline display can't receive any height. When changing the display the link start working and the absolute position it's for the text in the links to show properly.

Copy link
Author

Choose a reason for hiding this comment

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

Ok, I see it's still working with just the absolute position. Do you want me to remove the display?

@calixteman
Copy link
Contributor

I think we should add a reftest for that to avoid future regressions.
Maybe we could do something similar to what we have for annotations, see:
https://github.com/mozilla/pdf.js/blob/master/test/annotation_layer_builder_overrides.css

@catherinemds, would you mind to do that ?

@cathydev
Copy link
Author

I think we should add a reftest for that to avoid future regressions. Maybe we could do something similar to what we have for annotations, see: https://github.com/mozilla/pdf.js/blob/master/test/annotation_layer_builder_overrides.css

@catherinemds, would you mind to do that ?

Sure, no problem.

"file": "pdfs/xfa_bug1735738.pdf",
"md5": "7aa91f6681798c48e0c9d9836ed30742",
"rounds": 1,
"type": "eq"
Copy link
Contributor

Choose a reason for hiding this comment

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

You should add "enableXfa": true else the pdf won't rendered correctly.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, are we allowed to include the file or should it be a link test-case instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh yes, correct.
@catherinemds, please add a file named xfa_bug1735738.pdf.link which contains only the url to the pdf which is in the bugzilla bug and remove from this PR `xfa_bug1735738.pdf`` you added.

@calixteman
Copy link
Contributor

@catherinemds, you added a test: nice.
You should run a gulp makeref locally and check the output for this test.
You'll notice that we can't "see" the link on the generated image: it's why you should add a css file for xfa tests (similarly to what it have been done for annotations with https://github.com/mozilla/pdf.js/blob/master/test/annotation_layer_builder_overrides.css) and modify the style for xfaLink in order to be able to "see" it.
If you're a bit impatient, you can remove all the tests from test_manifest.json but the one you added: it should help you to go faster.

@cathydev
Copy link
Author

Hey @calixteman I submitted the changes even though I could still see the yellow box from the override file after commenting my modifications, I'm struggling to understand what when wrong here, also I wonder if the changes made to the driver.js file are okay

@calixteman
Copy link
Contributor

calixteman commented Oct 26, 2021

Could you try to see if there is any difference in removing the display:block in th overriden css ?

@cathydev
Copy link
Author

Could you try to see if there is any difference in removing the display:block in th overriden css ?

Yes, I tried that. The yellow box is almost gone but you can still see a bit of it in a little corner of the button

@calixteman
Copy link
Contributor

calixteman commented Oct 26, 2021

It's likely due to the box-shadow.
Could you fix the test_manifest file please ? There are a way too much change here ?

@cathydev cathydev force-pushed the xfa-link branch 4 times, most recently from 1fdf6b0 to 0ce9a0e Compare October 26, 2021 22:58
@cathydev
Copy link
Author

@calixteman I noticed something here, the litle corner where the yellow box it's still showing it's not the same xfalink that contains that "www.assuredynamics.com" link.
What I mean it's... The specific xfaLink that wasn't working where I applied my modification has this id "linkbutton12", the one with the yellow box it's "linkbutton48"...I think we could say that my patch has an effect?

Sorry for pushing so many times, I made a mistake and the .gitignore file updated and somehow I pushed it and had to fix it

@@ -0,0 +1 @@
https://bugzilla.mozilla.org/attachment.cgi?id=9227382
Copy link
Collaborator

Choose a reason for hiding this comment

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

Missing a line-break at the end here.


Your code-editor should be able to help you enforce this, thanks to this file; please see https://editorconfig.org/#pre-installed or https://editorconfig.org/#download

@@ -0,0 +1,5 @@
.xfaLink {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This file is missing a license header, please copy the one found e.g. in https://github.com/mozilla/pdf.js/blob/master/test/annotation_layer_builder_overrides.css (obviously with the year adjusted).

test/driver.js Outdated
.then(async ([cssRules]) => {
style.textContent = fontRules + "\n" + cssRules;
.then(async ([common, overrides]) => {
style.textContent = common + "\n" + overrides;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you remove fontRules ?

Copy link
Author

Choose a reason for hiding this comment

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

Yeah sorry, I was following the example of rasterizeAnnotationLayer and I removed to make it work at first but I fixed it now, I ran gulp makeref again to make sure it still working and everything seems fine

test/driver.js Outdated
Comment on lines 333 to 335
.then(async ([cssRules, common, overrides]) => {
style.textContent =
fontRules + "\n" + cssRules + "\n" + common + "\n" + overrides;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Have you successfully tested this, since I don't believe that the style promise will return an Array with three elements?
Based on the styles definition above, I'd expect that the correct thing here would be:

        .then(async ([common, overrides]) => {
          style.textContent = fontRules + "\n" + common + "\n" + overrides;

@calixteman
Copy link
Contributor

/botio xfatest

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_xfatest from @calixteman received. Current queue size: 0

Live output at: http://54.193.163.58:8877/3ccf85e57f0f0ce/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_xfatest from @calixteman received. Current queue size: 0

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

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

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

Total script time: 9.21 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Integration Tests: Passed
  • Regression tests: FAILED
  errors: 30
  different ref/snapshot: 28

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

@pdfjsbot
Copy link

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/3ccf85e57f0f0ce/output.txt

Total script time: 15.87 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Integration Tests: FAILED
  • Regression tests: FAILED
  errors: 30
  different ref/snapshot: 29

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

@calixteman
Copy link
Contributor

The reftests are showing links at incorrect positions.
I guess it's fine from a user point of view but it's a bit strange when we look at the images.
I think setting top and left to 0px should fix this small issue. Could you make a try and see if it improves things ?

There were some links not working in some XFA files,I realized that the anchor tag that contains the link has an inline display and couldn't receive any height, solved this by adding a "position: absolute". Tested with two different files in Firefox Nightly and Chrome and now all links are working perfectly fine. Added reftest to avoid future regressions
@calixteman
Copy link
Contributor

/botio test

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.241.84.105:8877/93de029e54a7f12/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://54.193.163.58:8877/114d54c44ff3527/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/93de029e54a7f12/output.txt

Total script time: 22.84 mins

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

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

@pdfjsbot
Copy link

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/114d54c44ff3527/output.txt

Total script time: 43.28 mins

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

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

Copy link
Contributor

@calixteman calixteman left a comment

Choose a reason for hiding this comment

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

LGTM, thank you for doing this.

@calixteman calixteman merged commit 2c0bbaf into mozilla:master Oct 29, 2021
@mozilla mozilla deleted a comment from pdfjsbot Oct 29, 2021
@mozilla mozilla deleted a comment from pdfjsbot Oct 29, 2021
@mozilla mozilla deleted a comment from pdfjsbot Oct 29, 2021
@mozilla mozilla deleted a comment from pdfjsbot Oct 29, 2021
@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

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

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

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://54.193.163.58:8877/6f396e8be2c881d/output.txt

@cathydev cathydev deleted the xfa-link branch October 29, 2021 18:43
@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

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

Total script time: 20.61 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/6f396e8be2c881d/output.txt

Total script time: 39.03 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.

Clicking on some links doesn't work sometimes in some XFA
5 participants