Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add getFindBar for Fx extension #4753

Merged
merged 1 commit into from
May 8, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions extensions/firefox/content/PdfStreamConverter.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 + '.');
Expand Down Expand Up @@ -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();
Expand Down
5 changes: 5 additions & 0 deletions test/mozcentral/browser_pdfjs_main.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ function runTests(document, window, callback) {
ok(document.querySelector('div#viewer'), "document content has viewer UI");
ok('PDFJS' in window.wrappedJSObject, "window content has PDFJS object");

//
// Browser Find
//
ok(gBrowser.isFindBarInitialized(tab), "Browser FindBar initialized!");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chrome-browser test timeout due to this line

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Console message: [JavaScript Error: "tab is not defined" {file: "chrome://mochitests/content/browser/browser/extensions/pdfjs/test/browser_pdfjs_main.js" line: 52}]


//
// Sidebar: open
//
Expand Down