[Firefox] Re-factor the 'zoomreset' message handling in the viewer (PR 10652 follow-up)

Given that this special-case only matters for the Firefox PDF viewer, it's probably better to just move it into `firefoxcom.js` instead to reduce unnecessary confusion.
This commit is contained in:
Jonas Jenwald 2019-07-17 11:59:56 +02:00
parent 6e96a158f4
commit 8e5aa484fb
2 changed files with 11 additions and 12 deletions

View File

@ -437,14 +437,9 @@ let PDFViewerApplication = {
this.pdfViewer.currentScaleValue = newScale; this.pdfViewer.currentScaleValue = newScale;
}, },
zoomReset(ignoreDuplicate = false) { zoomReset() {
if (this.pdfViewer.isInPresentationMode) { if (this.pdfViewer.isInPresentationMode) {
return; return;
} else if (ignoreDuplicate &&
this.pdfViewer.currentScaleValue === DEFAULT_SCALE_VALUE) {
// Avoid attempting to needlessly reset the zoom level *twice* in a row,
// when using the `Ctrl + 0` keyboard shortcut in `MOZCENTRAL` builds.
return;
} }
this.pdfViewer.currentScaleValue = DEFAULT_SCALE_VALUE; this.pdfViewer.currentScaleValue = DEFAULT_SCALE_VALUE;
}, },
@ -1965,8 +1960,8 @@ function webViewerZoomIn() {
function webViewerZoomOut() { function webViewerZoomOut() {
PDFViewerApplication.zoomOut(); PDFViewerApplication.zoomOut();
} }
function webViewerZoomReset(evt) { function webViewerZoomReset() {
PDFViewerApplication.zoomReset(evt && evt.ignoreDuplicate); PDFViewerApplication.zoomReset();
} }
function webViewerPageNumberChanged(evt) { function webViewerPageNumberChanged(evt) {
let pdfViewer = PDFViewerApplication.pdfViewer; let pdfViewer = PDFViewerApplication.pdfViewer;

View File

@ -16,6 +16,7 @@
import '../extensions/firefox/tools/l10n'; import '../extensions/firefox/tools/l10n';
import { createObjectURL, PDFDataRangeTransport, shadow, URL } from 'pdfjs-lib'; import { createObjectURL, PDFDataRangeTransport, shadow, URL } from 'pdfjs-lib';
import { BasePreferences } from './preferences'; import { BasePreferences } from './preferences';
import { DEFAULT_SCALE_VALUE } from './ui_utils';
import { PDFViewerApplication } from './app'; import { PDFViewerApplication } from './app';
if (typeof PDFJSDev === 'undefined' || if (typeof PDFJSDev === 'undefined' ||
@ -208,10 +209,13 @@ class MozL10n {
if (!PDFViewerApplication.initialized) { if (!PDFViewerApplication.initialized) {
return; return;
} }
PDFViewerApplication.eventBus.dispatch(type, { // Avoid attempting to needlessly reset the zoom level *twice* in a row,
source: window, // when using the `Ctrl + 0` keyboard shortcut.
ignoreDuplicate: (type === 'zoomreset' ? true : undefined), if (type === 'zoomreset' && // eslint-disable-next-line max-len
}); PDFViewerApplication.pdfViewer.currentScaleValue === DEFAULT_SCALE_VALUE) {
return;
}
PDFViewerApplication.eventBus.dispatch(type, { source: window, });
}; };
for (const event of events) { for (const event of events) {