зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1685801: Part 8 - Remove BrowserUtils toolbar tracking code. r=mccr8
It's only used by the finder code, and can be much simpler. Differential Revision: https://phabricator.services.mozilla.com/D101488
This commit is contained in:
Родитель
7f0df139d5
Коммит
56bb7266d8
|
@ -344,7 +344,7 @@ var PageThumbUtils = {
|
|||
},
|
||||
|
||||
shouldStoreContentThumbnail(aDocument, aDocShell) {
|
||||
if (BrowserUtils.isToolbarVisible(aDocShell, "findbar")) {
|
||||
if (BrowserUtils.isFindbarVisible(aDocShell)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -266,60 +266,12 @@ var BrowserUtils = {
|
|||
);
|
||||
},
|
||||
|
||||
_visibleToolbarsMap: new WeakMap(),
|
||||
|
||||
/**
|
||||
* Return true if any or a specific toolbar that interacts with the content
|
||||
* document is visible.
|
||||
*
|
||||
* @param {nsIDocShell} docShell The docShell instance that a toolbar should
|
||||
* be interacting with
|
||||
* @param {String} which Identifier of a specific toolbar
|
||||
* @return {Boolean}
|
||||
*/
|
||||
isToolbarVisible(docShell, which) {
|
||||
let window = this.getRootWindow(docShell);
|
||||
if (!this._visibleToolbarsMap.has(window)) {
|
||||
return false;
|
||||
}
|
||||
let toolbars = this._visibleToolbarsMap.get(window);
|
||||
return !!toolbars && toolbars.has(which);
|
||||
},
|
||||
|
||||
/**
|
||||
* Track whether a toolbar is visible for a given a docShell.
|
||||
*
|
||||
* @param {nsIDocShell} docShell The docShell instance that a toolbar should
|
||||
* be interacting with
|
||||
* @param {String} which Identifier of a specific toolbar
|
||||
* @param {Boolean} [visible] Whether the toolbar is visible. Optional,
|
||||
* defaults to `true`.
|
||||
*/
|
||||
trackToolbarVisibility(docShell, which, visible = true) {
|
||||
// We have to get the root window object, because XPConnect WrappedNatives
|
||||
// can't be used as WeakMap keys.
|
||||
let window = this.getRootWindow(docShell);
|
||||
let toolbars = this._visibleToolbarsMap.get(window);
|
||||
if (!toolbars) {
|
||||
toolbars = new Set();
|
||||
this._visibleToolbarsMap.set(window, toolbars);
|
||||
}
|
||||
if (!visible) {
|
||||
toolbars.delete(which);
|
||||
} else {
|
||||
toolbars.add(which);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Retrieve the root window object (i.e. the top-most content global) for a
|
||||
* specific docShell object.
|
||||
*
|
||||
* @param {nsIDocShell} docShell
|
||||
* @return {nsIDOMWindow}
|
||||
*/
|
||||
getRootWindow(docShell) {
|
||||
return docShell.browsingContext.top.window;
|
||||
isFindbarVisible(docShell) {
|
||||
const FINDER_JSM = "resource://gre/modules/Finder.jsm";
|
||||
return (
|
||||
Cu.isModuleLoaded(FINDER_JSM) &&
|
||||
ChromeUtils.import(FINDER_JSM).Finder.isFindbarVisible(docShell)
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -15,11 +15,6 @@ const { XPCOMUtils } = ChromeUtils.import(
|
|||
const { Rect } = ChromeUtils.import("resource://gre/modules/Geometry.jsm");
|
||||
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
ChromeUtils.defineModuleGetter(
|
||||
this,
|
||||
"BrowserUtils",
|
||||
"resource://gre/modules/BrowserUtils.jsm"
|
||||
);
|
||||
ChromeUtils.defineModuleGetter(
|
||||
this,
|
||||
"FinderIterator",
|
||||
|
@ -42,6 +37,8 @@ XPCOMUtils.defineLazyServiceGetter(
|
|||
const kSelectionMaxLen = 150;
|
||||
const kMatchesCountLimitPref = "accessibility.typeaheadfind.matchesCountLimit";
|
||||
|
||||
const activeFinderRoots = new WeakSet();
|
||||
|
||||
function Finder(docShell) {
|
||||
this._fastFind = Cc["@mozilla.org/typeaheadfind;1"].createInstance(
|
||||
Ci.nsITypeAheadFind
|
||||
|
@ -492,11 +489,15 @@ Finder.prototype = {
|
|||
this.enableSelection();
|
||||
this.highlighter.highlight(false);
|
||||
this.iterator.reset();
|
||||
BrowserUtils.trackToolbarVisibility(this._docShell, "findbar", false);
|
||||
activeFinderRoots.delete(this._docShell.browsingContext.top);
|
||||
},
|
||||
|
||||
onFindbarOpen() {
|
||||
BrowserUtils.trackToolbarVisibility(this._docShell, "findbar", true);
|
||||
activeFinderRoots.add(this._docShell.browsingContext.top);
|
||||
},
|
||||
|
||||
isFindbarVisible(docShell) {
|
||||
return activeFinderRoots.has(docShell.browsingContext.top);
|
||||
},
|
||||
|
||||
onModalHighlightChange(useModalHighlight) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче