зеркало из https://github.com/mozilla/gecko-dev.git
merge mozilla-central to autoland. r=merge a=merge
This commit is contained in:
Коммит
1e24731891
|
@ -8717,7 +8717,7 @@ var ToolbarIconColor = {
|
|||
// to avoid unnecessary calls to getComputedStyle
|
||||
_toolbarLuminanceCache: new Map(),
|
||||
|
||||
async inferFromText(reason, reasonValue) {
|
||||
inferFromText(reason, reasonValue) {
|
||||
if (!this._initialized)
|
||||
return;
|
||||
function parseRGB(aColorString) {
|
||||
|
@ -8754,7 +8754,6 @@ var ToolbarIconColor = {
|
|||
// two loops to avoid flushing layout and making it dirty repeatedly.
|
||||
let cachedLuminances = this._toolbarLuminanceCache;
|
||||
let luminances = new Map();
|
||||
await BrowserUtils.promiseLayoutFlushed(document, "style", () => {
|
||||
for (let toolbar of document.querySelectorAll(toolbarSelector)) {
|
||||
// toolbars *should* all have ids, but guard anyway to avoid blowing up
|
||||
let cacheKey = toolbar.id && toolbar.id + JSON.stringify(this._windowState);
|
||||
|
@ -8769,7 +8768,6 @@ var ToolbarIconColor = {
|
|||
}
|
||||
luminances.set(toolbar, luminance);
|
||||
}
|
||||
});
|
||||
|
||||
for (let [toolbar, luminance] of luminances) {
|
||||
if (luminance <= 110)
|
||||
|
|
|
@ -32,10 +32,8 @@ if (Services.appinfo.OS == "Linux") {
|
|||
EXPECTED_REFLOWS.push(
|
||||
[
|
||||
"handleEvent@chrome://browser/content/tabbrowser.xml",
|
||||
"inferFromText/<@chrome://browser/content/browser.js",
|
||||
"promiseReflowed/</<@resource://gre/modules/BrowserUtils.jsm",
|
||||
"_onReflow@resource://gre/modules/BrowserUtils.jsm",
|
||||
"reflowInterruptible@resource://gre/modules/BrowserUtils.jsm",
|
||||
"inferFromText@chrome://browser/content/browser.js",
|
||||
"handleEvent@chrome://browser/content/browser.js",
|
||||
],
|
||||
);
|
||||
}
|
||||
|
@ -45,10 +43,8 @@ if (Services.appinfo.OS == "Darwin") {
|
|||
EXPECTED_REFLOWS.push(
|
||||
[
|
||||
"handleEvent@chrome://browser/content/tabbrowser.xml",
|
||||
"inferFromText/<@chrome://browser/content/browser.js",
|
||||
"promiseReflowed/</<@resource://gre/modules/BrowserUtils.jsm",
|
||||
"_onReflow@resource://gre/modules/BrowserUtils.jsm",
|
||||
"reflowInterruptible@resource://gre/modules/BrowserUtils.jsm",
|
||||
"inferFromText@chrome://browser/content/browser.js",
|
||||
"handleEvent@chrome://browser/content/browser.js",
|
||||
],
|
||||
);
|
||||
}
|
||||
|
@ -71,10 +67,8 @@ if (Services.appinfo.OS == "WINNT") {
|
|||
|
||||
[
|
||||
"handleEvent@chrome://browser/content/tabbrowser.xml",
|
||||
"inferFromText/<@chrome://browser/content/browser.js",
|
||||
"promiseReflowed/</<@resource://gre/modules/BrowserUtils.jsm",
|
||||
"_onReflow@resource://gre/modules/BrowserUtils.jsm",
|
||||
"reflowInterruptible@resource://gre/modules/BrowserUtils.jsm",
|
||||
"inferFromText@chrome://browser/content/browser.js",
|
||||
"handleEvent@chrome://browser/content/browser.js",
|
||||
],
|
||||
|
||||
[
|
||||
|
|
|
@ -1825,39 +1825,6 @@ nsDOMWindowUtils::GetBoundsWithoutFlushing(nsIDOMElement *aElement,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMWindowUtils::NeedsFlush(int32_t aFlushType, bool* aResult)
|
||||
{
|
||||
MOZ_ASSERT(aResult);
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = GetDocument();
|
||||
NS_ENSURE_STATE(doc);
|
||||
|
||||
nsIPresShell* presShell = doc->GetShell();
|
||||
NS_ENSURE_STATE(presShell);
|
||||
|
||||
FlushType flushType;
|
||||
switch (aFlushType) {
|
||||
case FLUSH_STYLE:
|
||||
flushType = FlushType::Style;
|
||||
break;
|
||||
|
||||
case FLUSH_LAYOUT:
|
||||
flushType = FlushType::Layout;
|
||||
break;
|
||||
|
||||
case FLUSH_DISPLAY:
|
||||
flushType = FlushType::Display;
|
||||
break;
|
||||
|
||||
default:
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
*aResult = presShell->NeedFlush(flushType);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMWindowUtils::GetRootBounds(nsIDOMClientRect** aResult)
|
||||
{
|
||||
|
|
|
@ -995,15 +995,6 @@ interface nsIDOMWindowUtils : nsISupports {
|
|||
*/
|
||||
nsIDOMClientRect getBoundsWithoutFlushing(in nsIDOMElement aElement);
|
||||
|
||||
const long FLUSH_STYLE = 0;
|
||||
const long FLUSH_LAYOUT = 1;
|
||||
const long FLUSH_DISPLAY = 2;
|
||||
|
||||
/**
|
||||
* Returns true if a flush of the given type is needed.
|
||||
*/
|
||||
bool needsFlush(in long aFlushtype);
|
||||
|
||||
/**
|
||||
* Returns the bounds of the window's currently loaded document. This will
|
||||
* generally be (0, 0, pageWidth, pageHeight) but in some cases (e.g. RTL
|
||||
|
|
|
@ -16,48 +16,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
|
|||
|
||||
Cu.importGlobalProperties(["URL"]);
|
||||
|
||||
let reflowObservers = new WeakMap();
|
||||
|
||||
function ReflowObserver(doc) {
|
||||
this._doc = doc;
|
||||
|
||||
doc.docShell.addWeakReflowObserver(this);
|
||||
reflowObservers.set(this._doc, this);
|
||||
|
||||
this.callbacks = [];
|
||||
}
|
||||
|
||||
ReflowObserver.prototype = {
|
||||
QueryInterface: XPCOMUtils.generateQI(["nsIReflowObserver", "nsISupportsWeakReference"]),
|
||||
|
||||
_onReflow() {
|
||||
reflowObservers.delete(this._doc);
|
||||
this._doc.docShell.removeWeakReflowObserver(this);
|
||||
|
||||
for (let callback of this.callbacks) {
|
||||
try {
|
||||
callback();
|
||||
} catch (e) {
|
||||
Cu.reportError(e);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
reflow() {
|
||||
this._onReflow();
|
||||
},
|
||||
|
||||
reflowInterruptible() {
|
||||
this._onReflow();
|
||||
},
|
||||
};
|
||||
|
||||
const FLUSH_TYPES = {
|
||||
"style": Ci.nsIDOMWindowUtils.FLUSH_STYLE,
|
||||
"layout": Ci.nsIDOMWindowUtils.FLUSH_LAYOUT,
|
||||
"display": Ci.nsIDOMWindowUtils.FLUSH_DISPLAY,
|
||||
};
|
||||
|
||||
this.BrowserUtils = {
|
||||
|
||||
/**
|
||||
|
@ -668,63 +626,4 @@ this.BrowserUtils = {
|
|||
}
|
||||
return [url, postData];
|
||||
},
|
||||
|
||||
/**
|
||||
* Calls the given function when the given document has just reflowed,
|
||||
* and returns a promise which resolves to its return value after it
|
||||
* has been called.
|
||||
*
|
||||
* The function *must not trigger any reflows*, or make any changes
|
||||
* which would require a layout flush.
|
||||
*
|
||||
* @param {Document} doc
|
||||
* @param {function} callback
|
||||
* @returns {Promise}
|
||||
*/
|
||||
promiseReflowed(doc, callback) {
|
||||
let observer = reflowObservers.get(doc);
|
||||
if (!observer) {
|
||||
observer = new ReflowObserver(doc);
|
||||
reflowObservers.set(doc, observer);
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
observer.callbacks.push(() => {
|
||||
try {
|
||||
resolve(callback());
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Calls the given function as soon as a layout flush of the given
|
||||
* type is not necessary, and returns a promise which resolves to the
|
||||
* callback's return value after it executes.
|
||||
*
|
||||
* The function *must not trigger any reflows*, or make any changes
|
||||
* which would require a layout flush.
|
||||
*
|
||||
* @param {Document} doc
|
||||
* @param {string} flushType
|
||||
* The flush type required. Must be one of:
|
||||
*
|
||||
* - "style"
|
||||
* - "layout"
|
||||
* - "display"
|
||||
* @param {function} callback
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async promiseLayoutFlushed(doc, flushType, callback) {
|
||||
let utils = doc.defaultView.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIDOMWindowUtils);
|
||||
|
||||
if (!utils.needsFlush(FLUSH_TYPES[flushType])) {
|
||||
return callback();
|
||||
}
|
||||
|
||||
return this.promiseReflowed(doc, callback);
|
||||
},
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче