From 591a3c291f55e4bda9cb61fdcec2e6bcf702ccd8 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Fri, 19 Jun 2015 14:36:44 +0200 Subject: [PATCH 1/2] Make FirefoxCom.requestSync able to return objects from PdfStreamConverter.jsm, by utilizing makeContentReadable --- extensions/firefox/content/PdfStreamConverter.jsm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/firefox/content/PdfStreamConverter.jsm b/extensions/firefox/content/PdfStreamConverter.jsm index 61e0c16c3..14b12becd 100644 --- a/extensions/firefox/content/PdfStreamConverter.jsm +++ b/extensions/firefox/content/PdfStreamConverter.jsm @@ -794,7 +794,7 @@ RequestListener.prototype.receive = function(event) { var response; if (sync) { response = actions[action].call(this.actions, data); - event.detail.response = response; + event.detail.response = makeContentReadable(response, doc.defaultView); } else { if (!event.detail.responseExpected) { doc.documentElement.removeChild(message); From 633d51fc222f40bd9da8271b2c346dac1d936f93 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Tue, 2 Jun 2015 13:17:02 +0200 Subject: [PATCH 2/2] [Firefox] Handle the user modifying the "mousewheel.with_meta.action" and "mousewheel.with_control.action" prefs (bug 1170063) Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1170063. The bug only mentions the Meta key, but given that a similar situation can occur for Ctrl, it seemed reasonable to also handle that case in the same patch. The only possible caveat with the patch is that because of the use of `shadow`, things won't work perfectly if either of the prefs are changed *while* the viewer is active. In this case a reload is required in order for it to work correctly, but given that the issue this patch fixes should be quite rare anyway, that seems OK. --- .../firefox/content/PdfStreamConverter.jsm | 6 ++++++ web/viewer.js | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/extensions/firefox/content/PdfStreamConverter.jsm b/extensions/firefox/content/PdfStreamConverter.jsm index 14b12becd..0e917162a 100644 --- a/extensions/firefox/content/PdfStreamConverter.jsm +++ b/extensions/firefox/content/PdfStreamConverter.jsm @@ -423,6 +423,12 @@ ChromeActions.prototype = { } return true; }, + supportedMouseWheelZoomModifierKeys: function() { + return { + ctrlKey: getIntPref('mousewheel.with_control.action', 3) === 3, + metaKey: getIntPref('mousewheel.with_meta.action', 1) === 3, + }; + }, reportTelemetry: function (data) { var probeInfo = JSON.parse(data); switch (probeInfo.type) { diff --git a/web/viewer.js b/web/viewer.js index 32ed42843..53d298427 100644 --- a/web/viewer.js +++ b/web/viewer.js @@ -394,6 +394,18 @@ var PDFViewerApplication = { return PDFJS.shadow(this, 'loadingBar', bar); }, + get supportedMouseWheelZoomModifierKeys() { + var support = { + ctrlKey: true, + metaKey: true, + }; +//#if (FIREFOX || MOZCENTRAL) +// support = FirefoxCom.requestSync('supportedMouseWheelZoomModifierKeys'); +//#endif + + return PDFJS.shadow(this, 'supportedMouseWheelZoomModifierKeys', support); + }, + //#if (FIREFOX || MOZCENTRAL) initPassiveLoading: function pdfViewInitPassiveLoading() { function FirefoxComDataRangeTransport(length, initialData) { @@ -1845,6 +1857,11 @@ function handleMouseWheel(evt) { PDFViewerApplication.scrollPresentationMode(ticks * MOUSE_WHEEL_DELTA_FACTOR); } else if (evt.ctrlKey || evt.metaKey) { + var support = PDFViewerApplication.supportedMouseWheelZoomModifierKeys; + if ((evt.ctrlKey && !support.ctrlKey) || + (evt.metaKey && !support.metaKey)) { + return; + } // Only zoom the pages, not the entire viewer. evt.preventDefault(); PDFViewerApplication[direction](Math.abs(ticks));