[Pkg-javascript-commits] [pdf.js] 98/210: Refactors new extension find bar code to support old FF versions
David Prévot
taffit at moszumanska.debian.org
Thu Jun 5 14:21:06 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch upstream
in repository pdf.js.
commit 9f9454d2aeb194c9a9c41b3bf8e26ad4ebd33db5
Author: Yury Delendik <ydelendik at mozilla.com>
Date: Thu May 8 09:05:28 2014 -0500
Refactors new extension find bar code to support old FF versions
---
extensions/firefox/content/PdfStreamConverter.jsm | 24 +++++++++++++++--------
test/mozcentral/browser_pdfjs_main.js | 4 ++--
2 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/extensions/firefox/content/PdfStreamConverter.jsm b/extensions/firefox/content/PdfStreamConverter.jsm
index 52359ea..691d22e 100644
--- a/extensions/firefox/content/PdfStreamConverter.jsm
+++ b/extensions/firefox/content/PdfStreamConverter.jsm
@@ -66,9 +66,15 @@ function getChromeWindow(domWindow) {
function getFindBar(domWindow) {
var browser = getContainingBrowser(domWindow);
- var tabbrowser = browser.getTabBrowser();
- var tab = tabbrowser._getTabForBrowser(browser);
- return tabbrowser.getFindBar(tab);
+ try {
+ var tabbrowser = browser.getTabBrowser();
+ var tab = tabbrowser._getTabForBrowser(browser);
+ return tabbrowser.getFindBar(tab);
+ } catch (e) {
+ // FF22 has no _getTabForBrowser, and FF24 has no getFindBar
+ var chromeWindow = browser.ownerDocument.defaultView;
+ return chromeWindow.gFindBar;
+ }
}
function setBoolPref(pref, value) {
@@ -327,11 +333,13 @@ ChromeActions.prototype = {
return getBoolPref(PREF_PREFIX + '.pdfBugEnabled', false);
},
supportsIntegratedFind: function() {
- // Integrated find is only supported when we're not in a frame and when the
- // new find events code exists.
- return this.domWindow.frameElement === null &&
- getFindBar(this.domWindow) &&
- 'updateControlState' in getFindBar(this.domWindow);
+ // Integrated find is only supported when we're not in a frame
+ if (this.domWindow.frameElement !== null) {
+ return false;
+ }
+ // ... and when the new find events code exists.
+ var findBar = getFindBar(this.domWindow);
+ return findBar && ('updateControlState' in findBar);
},
supportsDocumentFonts: function() {
var prefBrowser = getIntPref('browser.display.use_document_fonts', 1);
diff --git a/test/mozcentral/browser_pdfjs_main.js b/test/mozcentral/browser_pdfjs_main.js
index 7a8e206..9dd1e7a 100644
--- a/test/mozcentral/browser_pdfjs_main.js
+++ b/test/mozcentral/browser_pdfjs_main.js
@@ -32,13 +32,13 @@ function test() {
// Runs tests after all 'load' event handlers have fired off
window.addEventListener("documentload", function() {
- runTests(document, window, finish);
+ runTests(document, window, tab, finish);
}, false, true);
}, true);
}
-function runTests(document, window, callback) {
+function runTests(document, window, tab, callback) {
//
// Overall sanity tests
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git
More information about the Pkg-javascript-commits
mailing list