Commit d3f486b8 authored by Ryan VanderMeulen's avatar Ryan VanderMeulen
Browse files

Bug 1632644 - Allow PDF attachments to, once again, be opened directly in the...

Bug 1632644 - Allow PDF attachments to, once again, be opened directly in the browser. r=bdahl, a=RyanVM

Backport of upstream commit https://github.com/mozilla/pdf.js/commit/0960e6c0b5f2bdb45b8f4d280a3353ed230f448a

Differential Revision: https://phabricator.services.mozilla.com/D76200
parent 6c7fc982
...@@ -1783,7 +1783,7 @@ function loadAndEnablePDFBug(enabledTabs) { ...@@ -1783,7 +1783,7 @@ function loadAndEnablePDFBug(enabledTabs) {
function webViewerInitialized() { function webViewerInitialized() {
const appConfig = PDFViewerApplication.appConfig; const appConfig = PDFViewerApplication.appConfig;
let file; let file;
file = window.location.href.split("#")[0]; file = window.location.href;
appConfig.toolbar.openFile.setAttribute("hidden", "true"); appConfig.toolbar.openFile.setAttribute("hidden", "true");
appConfig.secondaryToolbar.openFileButton.setAttribute("hidden", "true"); appConfig.secondaryToolbar.openFileButton.setAttribute("hidden", "true");
...@@ -4693,7 +4693,7 @@ class PDFAttachmentViewer { ...@@ -4693,7 +4693,7 @@ class PDFAttachmentViewer {
} }
let viewerUrl; let viewerUrl;
viewerUrl = blobUrl + "?" + encodeURIComponent(filename); viewerUrl = blobUrl + "#filename=" + encodeURIComponent(filename);
window.open(viewerUrl); window.open(viewerUrl);
return false; return false;
}; };
...@@ -4873,7 +4873,7 @@ class PDFDocumentProperties { ...@@ -4873,7 +4873,7 @@ class PDFDocumentProperties {
metadata, metadata,
contentDispositionFilename contentDispositionFilename
}) => { }) => {
return Promise.all([info, metadata, contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(this.url || ""), this._parseFileSize(this.maybeFileSize), this._parseDate(info.CreationDate), this._parseDate(info.ModDate), this.pdfDocument.getPage(currentPageNumber).then(pdfPage => { return Promise.all([info, metadata, contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(this.url), this._parseFileSize(this.maybeFileSize), this._parseDate(info.CreationDate), this._parseDate(info.ModDate), this.pdfDocument.getPage(currentPageNumber).then(pdfPage => {
return this._parsePageSize((0, _ui_utils.getPageSizeInches)(pdfPage), pagesRotation); return this._parsePageSize((0, _ui_utils.getPageSizeInches)(pdfPage), pagesRotation);
}), this._parseLinearization(info.IsLinearized)]); }), this._parseLinearization(info.IsLinearized)]);
}).then(([info, metadata, fileName, fileSize, creationDate, modDate, pageSize, isLinearized]) => { }).then(([info, metadata, fileName, fileSize, creationDate, modDate, pageSize, isLinearized]) => {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment