Prepare the MOZCENTRAL viewer for receiving zoom events from the browser UI (bug 786674, bug 1177385)

This lays the necessary foundation for handling zoom events originating within the browser itself, rather than in the viewer. Please note that this will also require a follow-up patch to `mozilla-central`, such that the viewer is actually notified when zooming occurs.
This commit is contained in:
Jonas Jenwald 2019-03-19 10:45:27 +01:00
parent 844aecf9e3
commit 2e044bf646
2 changed files with 42 additions and 4 deletions

View file

@ -171,7 +171,7 @@ class MozL10n {
'findentirewordchange',
'findbarclose',
];
let handleEvent = function({ type, detail, }) {
const handleEvent = function({ type, detail, }) {
if (!PDFViewerApplication.initialized) {
return;
}
@ -193,7 +193,28 @@ class MozL10n {
});
};
for (let event of events) {
for (const event of events) {
window.addEventListener(event, handleEvent);
}
})();
(function listenZoomEvents() {
const events = [
'zoomin',
'zoomout',
'zoomreset',
];
const handleEvent = function({ type, detail, }) {
if (!PDFViewerApplication.initialized) {
return;
}
PDFViewerApplication.eventBus.dispatch(type, {
source: window,
ignoreDuplicate: (type === 'zoomreset' ? true : undefined),
});
};
for (const event of events) {
window.addEventListener(event, handleEvent);
}
})();