Skip to content

Slightly re-factor how we pre-load fonts and images in XFA documents #19889

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 3 commits into from
May 4, 2025

Conversation

Snuffleupagus
Copy link
Collaborator

  • Ensure that XFAFactory.prototype.isValid returns a boolean value

    Considering the name of the method, and how it's actually being used, you'd expect it to return a boolean value.
    Given how it's currently being used this inconsistency doesn't cause any issues, however we should still fix this.

  • Reduce duplication when parsing fonts in loadXfaFonts

    Currently we repeat virtually the same code when calling the PartialEvaluator.prototype.handleSetFont method, which we can avoid by introducing an inline helper function.

  • Slightly re-factor how we pre-load fonts and images in XFA documents

    Rather than "manually" invoking the methods from the src/core/worker.js file we introduce a single PDFDocument-method that handles this for us, and make the current methods private.
    Since this code is only invoked at most once per document, and only for XFA documents, we can use BasePdfManager.prototype.ensureDoc directly rather than needing a stand-alone method.

@Snuffleupagus
Copy link
Collaborator Author

/botio xfatest

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.241.84.105:8877/29d2f25555032ec/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Received

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

Live output at: http://54.193.163.58:8877/10a0e1fd07f99df/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/29d2f25555032ec/output.txt

Total script time: 17.14 mins

  • Unit tests: Passed
  • Integration Tests: FAILED
  • Regression tests: Passed

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/10a0e1fd07f99df/output.txt

Total script time: 40.75 mins

  • Unit tests: Passed
  • Integration Tests: FAILED
  • Regression tests: Passed

Considering the name of the method, and how it's actually being used, you'd expect it to return a boolean value.
Given how it's currently being used this inconsistency doesn't cause any issues, however we should still fix this.
Currently we repeat virtually the same code when calling the `PartialEvaluator.prototype.handleSetFont` method, which we can avoid by introducing an inline helper function.
Rather than "manually" invoking the methods from the `src/core/worker.js` file we introduce a single `PDFDocument`-method that handles this for us, and make the current methods private.
Since this code is only invoked at most *once* per document, and only for XFA documents, we can use `BasePdfManager.prototype.ensureDoc` directly rather than needing a stand-alone method.
@Snuffleupagus Snuffleupagus marked this pull request as ready for review May 4, 2025 11:47
@Snuffleupagus
Copy link
Collaborator Author

/botio xfatest

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

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

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

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Received

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

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

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Failed

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

Total script time: 17.23 mins

  • Unit tests: Passed
  • Integration Tests: FAILED
  • Regression tests: Passed

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Failed

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

Total script time: 40.00 mins

  • Unit tests: Passed
  • Integration Tests: FAILED
  • Regression tests: Passed

@timvandermeij timvandermeij merged commit 06f4491 into mozilla:master May 4, 2025
9 checks passed
@timvandermeij
Copy link
Contributor

Nice simplification!

@Snuffleupagus Snuffleupagus deleted the loadXfaResources branch May 5, 2025 15:01
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