Skip to content

Commit

Permalink
Bug 1827374 - Update PDF.js to new version a43151103efbc96c98a9cda62b…
Browse files Browse the repository at this point in the history
…f9a51e8d9f0337 r=pdfjs-reviewers,marco

Differential Revision: https://phabricator.services.mozilla.com/D175109
  • Loading branch information
calixteman committed Apr 11, 2023
1 parent aa6fd08 commit 43ae5b9
Show file tree
Hide file tree
Showing 9 changed files with 225 additions and 57 deletions.
10 changes: 5 additions & 5 deletions toolkit/components/pdfjs/content/build/pdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ function getDocument(src) {
}
const fetchDocParams = {
docId,
apiVersion: '3.6.9',
apiVersion: '3.6.25',
data,
password,
disableAutoFetch,
Expand Down Expand Up @@ -2607,9 +2607,9 @@ class InternalRenderTask {
}
}
}
const version = '3.6.9';
const version = '3.6.25';
exports.version = version;
const build = '184076fe7';
const build = 'a43151103';
exports.build = build;

/***/ }),
Expand Down Expand Up @@ -13233,8 +13233,8 @@ var _annotation_layer = __w_pdfjs_require__(26);
var _worker_options = __w_pdfjs_require__(14);
var _svg = __w_pdfjs_require__(29);
var _xfa_layer = __w_pdfjs_require__(28);
const pdfjsVersion = '3.6.9';
const pdfjsBuild = '184076fe7';
const pdfjsVersion = '3.6.25';
const pdfjsBuild = 'a43151103';
})();

/******/ return __webpack_exports__;
Expand Down
4 changes: 2 additions & 2 deletions toolkit/components/pdfjs/content/build/pdf.scripting.js
Original file line number Diff line number Diff line change
Expand Up @@ -4258,8 +4258,8 @@ Object.defineProperty(exports, "initSandbox", ({
}
}));
var _initialization = __w_pdfjs_require__(1);
const pdfjsVersion = '3.6.9';
const pdfjsBuild = '184076fe7';
const pdfjsVersion = '3.6.25';
const pdfjsBuild = 'a43151103';
})();

/******/ return __webpack_exports__;
Expand Down
6 changes: 3 additions & 3 deletions toolkit/components/pdfjs/content/build/pdf.worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class WorkerMessageHandler {
docId,
apiVersion
} = docParams;
const workerVersion = '3.6.9';
const workerVersion = '3.6.25';
if (apiVersion !== workerVersion) {
throw new Error(`The API version "${apiVersion}" does not match ` + `the Worker version "${workerVersion}".`);
}
Expand Down Expand Up @@ -53029,8 +53029,8 @@ Object.defineProperty(exports, "WorkerMessageHandler", ({
}
}));
var _worker = __w_pdfjs_require__(1);
const pdfjsVersion = '3.6.9';
const pdfjsBuild = '184076fe7';
const pdfjsVersion = '3.6.25';
const pdfjsBuild = 'a43151103';
})();

/******/ return __webpack_exports__;
Expand Down
76 changes: 76 additions & 0 deletions toolkit/components/pdfjs/content/web/viewer-geckoview.css
Original file line number Diff line number Diff line change
Expand Up @@ -1090,6 +1090,8 @@
--dialog-button-border: none;
--dialog-button-bg-color: rgba(12, 12, 13, 0.1);
--dialog-button-hover-bg-color: rgba(12, 12, 13, 0.3);

--toolbarButton-download-icon: url(images/toolbarButton-download.svg);
}

:root:dir(rtl) {
Expand Down Expand Up @@ -1210,6 +1212,80 @@ body {
border-color: #0a84ff;
}

#floatingToolbar {
position: absolute;
width: 40px;
height: auto;
bottom: 5%;
right: 5%;
background-color: transparent;
z-index: 100000;
}

#floatingToolbar.show {
display: block;
}

#floatingToolbar:not(show) {
display: none;
}

.toolbarButton {
margin: 2px;
padding: 8px;
border-style: solid;
border-width: 1px;
border-color: transparent;
border-radius: 19px;
user-select: none;
box-sizing: border-box;
background-color: transparent;
backdrop-filter: blur(20px) contrast(100%) invert(100%);
width: 38px;
height: 38px;
outline: none;
position: relative;
}

.toolbarButton > span {
display: inline-block;
width: 0;
height: 0;
overflow: hidden;
}

.toolbarButton[disabled],
.dialogButton[disabled] {
opacity: 0.5;
}

.toolbarButton:hover,
.toolbarButton:focus-visible {
backdrop-filter: blur(20px) contrast(200%) invert(100%);
}

.toolbarButton::before {
display: inline-block;
width: 100%;
height: 100%;
content: "";
background-color: transparent;
backdrop-filter: invert(100%);
mask-size: cover;
}

.toolbarButton::before {
opacity: var(--toolbar-icon-opacity);
}

.toolbarButton:hover::before {
backdrop-filter: invert(60%);
}

#download::before {
mask-image: var(--toolbarButton-download-icon);
}

.dialogButton {
width: auto;
margin: 3px 4px 2px !important;
Expand Down
6 changes: 6 additions & 0 deletions toolkit/components/pdfjs/content/web/viewer-geckoview.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,11 @@

</div> <!-- outerContainer -->

<div id="floatingToolbar">
<button id="download" class="toolbarButton" title="Save" tabindex="31" data-l10n-id="save">
<span data-l10n-id="save_label">Save</span>
</button>
</div>

</body>
</html>
104 changes: 87 additions & 17 deletions toolkit/components/pdfjs/content/web/viewer-geckoview.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ exports.FirefoxCom = exports.DownloadManager = void 0;
__webpack_require__(2);
var _app = __webpack_require__(3);
var _pdfjsLib = __webpack_require__(5);
var _preferences = __webpack_require__(28);
var _preferences = __webpack_require__(29);
var _ui_utils = __webpack_require__(4);
var _l10n_utils = __webpack_require__(18);
;
Expand Down Expand Up @@ -507,8 +507,8 @@ var _webPdf_sidebar_resizer = __webpack_require__(9);
var _webPdf_thumbnail_viewer = __webpack_require__(9);
var _pdf_viewer = __webpack_require__(17);
var _webSecondary_toolbar = __webpack_require__(9);
var _webToolbar = __webpack_require__(9);
var _view_history = __webpack_require__(27);
var _webToolbar = __webpack_require__(27);
var _view_history = __webpack_require__(28);
const FORCE_PAGES_LOADED_TIMEOUT = 10000;
const WHEEL_ZOOM_DISABLED_TIMEOUT = 1000;
const ViewOnLoad = {
Expand Down Expand Up @@ -1856,14 +1856,14 @@ function webViewerInitialized() {
});
}
if (!PDFViewerApplication.supportsPrinting) {
appConfig.toolbar?.print.classList.add("hidden");
appConfig.toolbar?.print?.classList.add("hidden");
appConfig.secondaryToolbar?.printButton.classList.add("hidden");
}
if (!PDFViewerApplication.supportsFullscreen) {
appConfig.secondaryToolbar?.presentationModeButton.classList.add("hidden");
}
if (PDFViewerApplication.supportsIntegratedFind) {
appConfig.toolbar?.viewFind.classList.add("hidden");
appConfig.toolbar?.viewFind?.classList.add("hidden");
}
appConfig.mainContainer.addEventListener("transitionend", function (evt) {
if (evt.target === this) {
Expand Down Expand Up @@ -2338,6 +2338,9 @@ function webViewerTouchEnd(evt) {
PDFViewerApplication._touchUnusedFactor = 1;
}
function webViewerClick(evt) {
if (document.activeElement === PDFViewerApplication.appConfig.mainContainer) {
PDFViewerApplication.toolbar?.toggle();
}
if (!PDFViewerApplication.secondaryToolbar?.isOpen) {
return;
}
Expand Down Expand Up @@ -6021,7 +6024,7 @@ class PDFViewer {
#onVisibilityChange = null;
#scaleTimeoutId = null;
constructor(options) {
const viewerVersion = '3.6.9';
const viewerVersion = '3.6.25';
if (_pdfjsLib.version !== viewerVersion) {
throw new Error(`The API version "${_pdfjsLib.version}" does not match the Viewer version "${viewerVersion}".`);
}
Expand Down Expand Up @@ -6984,21 +6987,25 @@ class PDFViewer {
return true;
}
getPagesOverview() {
let initialOrientation;
return this._pages.map(pageView => {
const viewport = pageView.pdfPage.getViewport({
scale: 1
});
if (!this.enablePrintAutoRotate || (0, _ui_utils.isPortraitOrientation)(viewport)) {
const orientation = (0, _ui_utils.isPortraitOrientation)(viewport);
if (initialOrientation === undefined) {
initialOrientation = orientation;
} else if (this.enablePrintAutoRotate && orientation !== initialOrientation) {
return {
width: viewport.width,
height: viewport.height,
rotation: viewport.rotation
width: viewport.height,
height: viewport.width,
rotation: (viewport.rotation - 90) % 360
};
}
return {
width: viewport.height,
height: viewport.width,
rotation: (viewport.rotation - 90) % 360
width: viewport.width,
height: viewport.height,
rotation: viewport.rotation
};
});
}
Expand Down Expand Up @@ -9150,6 +9157,63 @@ exports.XfaLayerBuilder = XfaLayerBuilder;



Object.defineProperty(exports, "__esModule", ({
value: true
}));
exports.Toolbar = void 0;
class Toolbar {
#buttons;
#eventBus;
#toolbar;
#mainContainer;
#toggleBound = this.toggle.bind(this);
constructor(options, eventBus, _l10n) {
this.#toolbar = options.container;
this.#mainContainer = options.mainContainer;
this.#eventBus = eventBus;
this.#buttons = [{
element: options.download,
eventName: "download"
}];
this.#bindListeners(options);
}
setPageNumber(pageNumber, pageLabel) {}
setPagesCount(pagesCount, hasPageLabels) {}
setPageScale(pageScaleValue, pageScale) {}
reset() {}
#bindListeners(options) {
for (const {
element,
eventName,
eventDetails
} of this.#buttons) {
element.addEventListener("click", evt => {
if (eventName !== null) {
this.#eventBus.dispatch(eventName, {
source: this,
...eventDetails
});
}
});
}
}
updateLoadingIndicatorState(loading = false) {}
toggle() {
if (this.#toolbar.classList.toggle("show")) {
this.#mainContainer.addEventListener("scroll", this.#toggleBound);
} else {
this.#mainContainer.removeEventListener("scroll", this.#toggleBound);
}
}
}
exports.Toolbar = Toolbar;

/***/ }),
/* 28 */
/***/ ((__unused_webpack_module, exports) => {



Object.defineProperty(exports, "__esModule", ({
value: true
}));
Expand Down Expand Up @@ -9222,7 +9286,7 @@ class ViewHistory {
exports.ViewHistory = ViewHistory;

/***/ }),
/* 28 */
/* 29 */
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {


Expand Down Expand Up @@ -9395,18 +9459,24 @@ var _ui_utils = __webpack_require__(4);
var _app_options = __webpack_require__(6);
var _pdf_link_service = __webpack_require__(8);
var _app = __webpack_require__(3);
const pdfjsVersion = '3.6.9';
const pdfjsBuild = '184076fe7';
const pdfjsVersion = '3.6.25';
const pdfjsBuild = 'a43151103';
const AppConstants = null;
exports.PDFViewerApplicationConstants = AppConstants;
window.PDFViewerApplication = _app.PDFViewerApplication;
window.PDFViewerApplicationConstants = AppConstants;
window.PDFViewerApplicationOptions = _app_options.AppOptions;
function getViewerConfiguration() {
const mainContainer = document.getElementById("viewerContainer");
return {
appContainer: document.body,
mainContainer: document.getElementById("viewerContainer"),
mainContainer,
viewerContainer: document.getElementById("viewer"),
toolbar: {
mainContainer,
container: document.getElementById("floatingToolbar"),
download: document.getElementById("download")
},
passwordOverlay: {
dialog: document.getElementById("passwordDialog"),
label: document.getElementById("passwordText"),
Expand Down
Loading

0 comments on commit 43ae5b9

Please sign in to comment.