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

Use the native URL.createObjectURL method in web/debugger.js #11545

Merged

Conversation

Snuffleupagus
Copy link
Collaborator

There's no particular reason for using the PDF.js helper function createObjectURL[1] in the debugger, instead of the native URL.createObjectURL directly, for a couple of reasons:

  • The relevant code-path only applies to fonts loaded with the Font Loading API, and this isn't supported in IE anyway.
  • The debugger can, since quite some time, not even be loaded in IE any more.
  • General support for IE is now limited, and there's no guaratee that everything actually works.

[1] It provides a fallback for browsers with broken Blob support, which as usual means Internet Explorer :-P

There's no particular reason for using the PDF.js helper function `createObjectURL`[1] in the debugger, instead of the native `URL.createObjectURL` directly, for a couple of reasons:
 - The relevant code-path only applies to fonts loaded with the Font Loading API, and this isn't supported in IE anyway.
 - The debugger can, since quite some time, not even be loaded in IE any more.
 - General support for IE is now limited, and there's no guaratee that everything actually works.

---
[1] It provides a fallback for browsers with broken `Blob` support, which as usual means Internet Explorer :-P
@Snuffleupagus
Copy link
Collaborator Author

/botio-linux preview

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.67.70.0:8877/b709a4f6c8a0b33/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/b709a4f6c8a0b33/output.txt

Total script time: 1.74 mins

Published

@timvandermeij timvandermeij merged commit 6d5de7e into mozilla:master Jan 28, 2020
@timvandermeij
Copy link
Contributor

Always good to start using native methods; thanks!

@Snuffleupagus Snuffleupagus deleted the debugger-createObjectURL branch January 28, 2020 22:16
@@ -121,7 +119,9 @@ var FontInspector = (function FontInspectorClosure() {
url = /url\(['"]?([^\)"']+)/.exec(url);
download.href = url[1];
} else if (fontObj.data) {
download.href = createObjectURL(fontObj.data, fontObj.mimeType);
download.href = URL.createObjectURL(
new Blob([fontObj.data], { type: fontObj.mimeType })
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be

new Blob([fontObj.data], { type: fontObj.mimetype })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants