[Pkg-javascript-commits] [pdf.js] 97/210: Add getFindBar for Fx extension

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 bc66c8119e1f0dd7373ff003e7288032486b0c2b
Author: Adam Dane [:hobophobe] <unusualtears at gmail.com>
Date:   Wed May 7 18:45:24 2014 -0500

    Add getFindBar for Fx extension
---
 extensions/firefox/content/PdfStreamConverter.jsm | 30 +++++++++++++++--------
 test/mozcentral/browser_pdfjs_main.js             |  5 ++++
 2 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/extensions/firefox/content/PdfStreamConverter.jsm b/extensions/firefox/content/PdfStreamConverter.jsm
index cbbb121..52359ea 100644
--- a/extensions/firefox/content/PdfStreamConverter.jsm
+++ b/extensions/firefox/content/PdfStreamConverter.jsm
@@ -53,12 +53,22 @@ XPCOMUtils.defineLazyServiceGetter(Svc, 'mime',
                                    '@mozilla.org/mime;1',
                                    'nsIMIMEService');
 
+function getContainingBrowser(domWindow) {
+  return domWindow.QueryInterface(Ci.nsIInterfaceRequestor)
+                  .getInterface(Ci.nsIWebNavigation)
+                  .QueryInterface(Ci.nsIDocShell)
+                  .chromeEventHandler;
+}
+
 function getChromeWindow(domWindow) {
-  var containingBrowser = domWindow.QueryInterface(Ci.nsIInterfaceRequestor)
-                                   .getInterface(Ci.nsIWebNavigation)
-                                   .QueryInterface(Ci.nsIDocShell)
-                                   .chromeEventHandler;
-  return containingBrowser.ownerDocument.defaultView;
+  return getContainingBrowser(domWindow).ownerDocument.defaultView;
+}
+
+function getFindBar(domWindow) {
+  var browser = getContainingBrowser(domWindow);
+  var tabbrowser = browser.getTabBrowser();
+  var tab = tabbrowser._getTabForBrowser(browser);
+  return tabbrowser.getFindBar(tab);
 }
 
 function setBoolPref(pref, value) {
@@ -320,8 +330,8 @@ ChromeActions.prototype = {
     // 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 &&
-           getChromeWindow(this.domWindow).gFindBar &&
-           'updateControlState' in getChromeWindow(this.domWindow).gFindBar;
+           getFindBar(this.domWindow) &&
+           'updateControlState' in getFindBar(this.domWindow);
   },
   supportsDocumentFonts: function() {
     var prefBrowser = getIntPref('browser.display.use_document_fonts', 1);
@@ -438,8 +448,7 @@ ChromeActions.prototype = {
         (findPreviousType !== 'undefined' && findPreviousType !== 'boolean')) {
       return;
     }
-    getChromeWindow(this.domWindow).gFindBar
-                                   .updateControlState(result, findPrevious);
+    getFindBar(this.domWindow).updateControlState(result, findPrevious);
   },
   setPreferences: function(prefs, sendResponse) {
     var defaultBranch = Services.prefs.getDefaultBranch(PREF_PREFIX + '.');
@@ -917,7 +926,8 @@ PdfStreamConverter.prototype = {
         }, false, true);
         if (actions.supportsIntegratedFind()) {
           var chromeWindow = getChromeWindow(domWindow);
-          var findEventManager = new FindEventManager(chromeWindow.gFindBar,
+          var findBar = getFindBar(domWindow);
+          var findEventManager = new FindEventManager(findBar,
                                                       domWindow,
                                                       chromeWindow);
           findEventManager.bind();
diff --git a/test/mozcentral/browser_pdfjs_main.js b/test/mozcentral/browser_pdfjs_main.js
index ba0c251..7a8e206 100644
--- a/test/mozcentral/browser_pdfjs_main.js
+++ b/test/mozcentral/browser_pdfjs_main.js
@@ -47,6 +47,11 @@ function runTests(document, window, callback) {
   ok('PDFJS' in window.wrappedJSObject, "window content has PDFJS object");
 
   //
+  // Browser Find
+  //
+  ok(gBrowser.isFindBarInitialized(tab), "Browser FindBar initialized!");
+
+  //
   // Sidebar: open
   //
   var sidebar = document.querySelector('button#sidebarToggle'),

-- 
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