Merge pull request #10979 from Snuffleupagus/firefox-zoomreset

[Firefox] Re-factor the 'zoomreset' message handling in the viewer (PR 10652 follow-up)
This commit is contained in:
Tim van der Meij 2019-07-19 22:42:07 +02:00 committed by GitHub
commit acef5bfd16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 15 deletions

View File

@ -437,14 +437,9 @@ let PDFViewerApplication = {
this.pdfViewer.currentScaleValue = newScale;
},
zoomReset(ignoreDuplicate = false) {
zoomReset() {
if (this.pdfViewer.isInPresentationMode) {
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;
},
@ -1965,8 +1960,8 @@ function webViewerZoomIn() {
function webViewerZoomOut() {
PDFViewerApplication.zoomOut();
}
function webViewerZoomReset(evt) {
PDFViewerApplication.zoomReset(evt && evt.ignoreDuplicate);
function webViewerZoomReset() {
PDFViewerApplication.zoomReset();
}
function webViewerPageNumberChanged(evt) {
let pdfViewer = PDFViewerApplication.pdfViewer;

View File

@ -16,6 +16,7 @@
import '../extensions/firefox/tools/l10n';
import { createObjectURL, PDFDataRangeTransport, shadow, URL } from 'pdfjs-lib';
import { BasePreferences } from './preferences';
import { DEFAULT_SCALE_VALUE } from './ui_utils';
import { PDFViewerApplication } from './app';
if (typeof PDFJSDev === 'undefined' ||
@ -176,9 +177,7 @@ class MozL10n {
return;
}
if (type === 'findbarclose') {
PDFViewerApplication.eventBus.dispatch('findbarclose', {
source: window,
});
PDFViewerApplication.eventBus.dispatch(type, { source: window, });
return;
}
PDFViewerApplication.eventBus.dispatch('find', {
@ -208,10 +207,13 @@ class MozL10n {
if (!PDFViewerApplication.initialized) {
return;
}
PDFViewerApplication.eventBus.dispatch(type, {
source: window,
ignoreDuplicate: (type === 'zoomreset' ? true : undefined),
});
// Avoid attempting to needlessly reset the zoom level *twice* in a row,
// when using the `Ctrl + 0` keyboard shortcut.
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) {