зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1280876 - don't take screenshots of pages that have the findbar open. r=jaws,mconley
MozReview-Commit-ID: Dmz0MaukNVq --HG-- extra : rebase_source : dc359e5bc31d86fa01caf6c8d9d4fc359251d9f3
This commit is contained in:
Родитель
5ed26abff3
Коммит
7c49e1e69b
|
@ -16,6 +16,9 @@ Cu.import("resource://gre/modules/Services.jsm");
|
|||
Cu.import("resource://gre/modules/Promise.jsm", this);
|
||||
Cu.import("resource://gre/modules/AppConstants.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "BrowserUtils",
|
||||
"resource://gre/modules/BrowserUtils.jsm");
|
||||
|
||||
this.PageThumbUtils = {
|
||||
// The default background color for page thumbnails.
|
||||
THUMBNAIL_BG_COLOR: "#fff",
|
||||
|
@ -263,6 +266,10 @@ this.PageThumbUtils = {
|
|||
},
|
||||
|
||||
shouldStoreContentThumbnail: function (aDocument, aDocShell) {
|
||||
if (BrowserUtils.isToolbarVisible(aDocShell, "findbar")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// FIXME Bug 720575 - Don't capture thumbnails for SVG or XML documents as
|
||||
// that currently regresses Talos SVG tests.
|
||||
if (aDocument instanceof Ci.nsIDOMXMLDocument) {
|
||||
|
|
|
@ -760,6 +760,8 @@
|
|||
event.initEvent("findbaropen", true, false);
|
||||
this.dispatchEvent(event);
|
||||
|
||||
this.browser.finder.onFindbarOpen();
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -303,6 +303,62 @@ this.BrowserUtils = {
|
|||
return true;
|
||||
},
|
||||
|
||||
_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.QueryInterface(Ci.nsIDocShellTreeItem)
|
||||
.sameTypeRootTreeItem.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIDOMWindow);
|
||||
},
|
||||
|
||||
getSelectionDetails: function(topWindow, aCharLen) {
|
||||
// selections of more than 150 characters aren't useful
|
||||
const kMaxSelectionLen = 150;
|
||||
|
|
|
@ -12,6 +12,9 @@ Cu.import("resource://gre/modules/Geometry.jsm");
|
|||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/Task.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "BrowserUtils",
|
||||
"resource://gre/modules/BrowserUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "TextToSubURIService",
|
||||
"@mozilla.org/intl/texttosuburi;1",
|
||||
"nsITextToSubURI");
|
||||
|
@ -316,6 +319,11 @@ Finder.prototype = {
|
|||
onFindbarClose: function() {
|
||||
this.enableSelection();
|
||||
this.highlighter.highlight(false);
|
||||
BrowserUtils.trackToolbarVisibility(this._docShell, "findbar", false);
|
||||
},
|
||||
|
||||
onFindbarOpen: function() {
|
||||
BrowserUtils.trackToolbarVisibility(this._docShell, "findbar", true);
|
||||
},
|
||||
|
||||
onModalHighlightChange(useModalHighlight) {
|
||||
|
|
|
@ -185,6 +185,10 @@ RemoteFinder.prototype = {
|
|||
this._browser.messageManager.sendAsyncMessage("Finder:FindbarClose");
|
||||
},
|
||||
|
||||
onFindbarOpen: function () {
|
||||
this._browser.messageManager.sendAsyncMessage("Finder:FindbarOpen");
|
||||
},
|
||||
|
||||
onModalHighlightChange: function(aUseModalHighlight) {
|
||||
this._browser.messageManager.sendAsyncMessage("Finder:ModalHighlightChange", {
|
||||
useModalHighlight: aUseModalHighlight
|
||||
|
@ -240,6 +244,7 @@ RemoteFinderListener.prototype = {
|
|||
"Finder:RemoveSelection",
|
||||
"Finder:FocusContent",
|
||||
"Finder:FindbarClose",
|
||||
"Finder:FindbarOpen",
|
||||
"Finder:KeyPress",
|
||||
"Finder:MatchesCount",
|
||||
"Finder:ModalHighlightChange"
|
||||
|
@ -323,6 +328,10 @@ RemoteFinderListener.prototype = {
|
|||
this._finder.onFindbarClose();
|
||||
break;
|
||||
|
||||
case "Finder:FindbarOpen":
|
||||
this._finder.onFindbarOpen();
|
||||
break;
|
||||
|
||||
case "Finder:KeyPress":
|
||||
this._finder.keyPress(data);
|
||||
break;
|
||||
|
|
Загрузка…
Ссылка в новой задаче