Bug 1383367: Part 3 - Defer getComputedStyle call if a reflow is currently pending. r=mconley

MozReview-Commit-ID: 33IRfOlaBxP

--HG--
extra : source : 1f9ec38274940ff20a1bfc0a6b8c76ea5ae16cff
This commit is contained in:
Kris Maglione 2017-07-26 14:30:00 -07:00
Родитель bb44d3f3da
Коммит 89980ca107
2 изменённых файлов: 27 добавлений и 19 удалений

Просмотреть файл

@ -8717,7 +8717,7 @@ var ToolbarIconColor = {
// to avoid unnecessary calls to getComputedStyle // to avoid unnecessary calls to getComputedStyle
_toolbarLuminanceCache: new Map(), _toolbarLuminanceCache: new Map(),
inferFromText(reason, reasonValue) { async inferFromText(reason, reasonValue) {
if (!this._initialized) if (!this._initialized)
return; return;
function parseRGB(aColorString) { function parseRGB(aColorString) {
@ -8754,6 +8754,7 @@ var ToolbarIconColor = {
// two loops to avoid flushing layout and making it dirty repeatedly. // two loops to avoid flushing layout and making it dirty repeatedly.
let cachedLuminances = this._toolbarLuminanceCache; let cachedLuminances = this._toolbarLuminanceCache;
let luminances = new Map(); let luminances = new Map();
await BrowserUtils.promiseLayoutFlushed(document, "style", () => {
for (let toolbar of document.querySelectorAll(toolbarSelector)) { for (let toolbar of document.querySelectorAll(toolbarSelector)) {
// toolbars *should* all have ids, but guard anyway to avoid blowing up // toolbars *should* all have ids, but guard anyway to avoid blowing up
let cacheKey = toolbar.id && toolbar.id + JSON.stringify(this._windowState); let cacheKey = toolbar.id && toolbar.id + JSON.stringify(this._windowState);
@ -8768,6 +8769,7 @@ var ToolbarIconColor = {
} }
luminances.set(toolbar, luminance); luminances.set(toolbar, luminance);
} }
});
for (let [toolbar, luminance] of luminances) { for (let [toolbar, luminance] of luminances) {
if (luminance <= 110) if (luminance <= 110)

Просмотреть файл

@ -32,8 +32,10 @@ if (Services.appinfo.OS == "Linux") {
EXPECTED_REFLOWS.push( EXPECTED_REFLOWS.push(
[ [
"handleEvent@chrome://browser/content/tabbrowser.xml", "handleEvent@chrome://browser/content/tabbrowser.xml",
"inferFromText@chrome://browser/content/browser.js", "inferFromText/<@chrome://browser/content/browser.js",
"handleEvent@chrome://browser/content/browser.js", "promiseReflowed/</<@resource://gre/modules/BrowserUtils.jsm",
"_onReflow@resource://gre/modules/BrowserUtils.jsm",
"reflowInterruptible@resource://gre/modules/BrowserUtils.jsm",
], ],
); );
} }
@ -43,8 +45,10 @@ if (Services.appinfo.OS == "Darwin") {
EXPECTED_REFLOWS.push( EXPECTED_REFLOWS.push(
[ [
"handleEvent@chrome://browser/content/tabbrowser.xml", "handleEvent@chrome://browser/content/tabbrowser.xml",
"inferFromText@chrome://browser/content/browser.js", "inferFromText/<@chrome://browser/content/browser.js",
"handleEvent@chrome://browser/content/browser.js", "promiseReflowed/</<@resource://gre/modules/BrowserUtils.jsm",
"_onReflow@resource://gre/modules/BrowserUtils.jsm",
"reflowInterruptible@resource://gre/modules/BrowserUtils.jsm",
], ],
); );
} }
@ -67,8 +71,10 @@ if (Services.appinfo.OS == "WINNT") {
[ [
"handleEvent@chrome://browser/content/tabbrowser.xml", "handleEvent@chrome://browser/content/tabbrowser.xml",
"inferFromText@chrome://browser/content/browser.js", "inferFromText/<@chrome://browser/content/browser.js",
"handleEvent@chrome://browser/content/browser.js", "promiseReflowed/</<@resource://gre/modules/BrowserUtils.jsm",
"_onReflow@resource://gre/modules/BrowserUtils.jsm",
"reflowInterruptible@resource://gre/modules/BrowserUtils.jsm",
], ],
[ [