Bug 1448017 - Initialize ToolbarIconColor before the initial layout to spare a potential restyle after the initial layout. r=bgrins
authorDão Gottwald <dao@mozilla.com>
Thu, 22 Mar 2018 16:18:20 +0100
changeset 409518 bcd284a1f312f79c4d3866975a6fcaaf17006664
parent 409517 e39a944f310fdc7dfc35b45792ee99f0265c47de
child 409519 82e4db446286ad1a387bc7ee3feeeadbaa9d0887
push id61539
push userdgottwald@mozilla.com
push dateThu, 22 Mar 2018 15:52:15 +0000
treeherderautoland@bcd284a1f312 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgrins
bugs1448017
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1448017 - Initialize ToolbarIconColor before the initial layout to spare a potential restyle after the initial layout. r=bgrins MozReview-Commit-ID: LLJ2EftdXZn
browser/base/content/browser.js
browser/base/content/test/performance/browser_toolbariconcolor_restyles.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -1227,16 +1227,27 @@ var gBrowserInit = {
 
       if (width < TARGET_WIDTH && height < TARGET_HEIGHT) {
         document.documentElement.setAttribute("sizemode", "maximized");
       }
     }
 
     new LightweightThemeConsumer(document);
     TabsInTitlebar.init();
+
+    if (window.matchMedia("(-moz-os-version: windows-win8)").matches &&
+        window.matchMedia("(-moz-windows-default-theme)").matches) {
+      let windowFrameColor = new Color(...ChromeUtils.import("resource:///modules/Windows8WindowFrameColor.jsm", {})
+                                            .Windows8WindowFrameColor.get());
+      // Default to black for foreground text.
+      if (!windowFrameColor.isContrastRatioAcceptable(new Color(0, 0, 0))) {
+        document.documentElement.setAttribute("darkwindowframe", "true");
+      }
+    }
+    ToolbarIconColor.init();
   },
 
   onDOMContentLoaded() {
     gBrowser = window._gBrowser;
     delete window._gBrowser;
     gBrowser.init();
 
     window.QueryInterface(Ci.nsIInterfaceRequestor)
@@ -1363,28 +1374,16 @@ var gBrowserInit = {
 
     // Misc. inits.
     TabletModeUpdater.init();
     CombinedStopReload.ensureInitialized();
     gPrivateBrowsingUI.init();
     BrowserPageActions.init();
     gAccessibilityServiceIndicator.init();
 
-    if (window.matchMedia("(-moz-os-version: windows-win8)").matches &&
-        window.matchMedia("(-moz-windows-default-theme)").matches) {
-      let windowFrameColor = new Color(...ChromeUtils.import("resource:///modules/Windows8WindowFrameColor.jsm", {})
-                                            .Windows8WindowFrameColor.get());
-      // Default to black for foreground text.
-      if (!windowFrameColor.isContrastRatioAcceptable(new Color(0, 0, 0))) {
-        document.documentElement.setAttribute("darkwindowframe", "true");
-      }
-    }
-
-    ToolbarIconColor.init();
-
     gRemoteControl.updateVisualCue(Marionette.running);
 
     // If we are given a tab to swap in, take care of it before first paint to
     // avoid an about:blank flash.
     let tabToOpen = window.arguments && window.arguments[0];
     if (tabToOpen instanceof XULElement) {
       // Clear the reference to the tab from the arguments array.
       window.arguments[0] = null;
--- a/browser/base/content/test/performance/browser_toolbariconcolor_restyles.js
+++ b/browser/base/content/test/performance/browser_toolbariconcolor_restyles.js
@@ -12,16 +12,22 @@ add_task(async function test_toolbar_ele
   // create a window and snapshot the elementsStyled
   let win1 = await BrowserTestUtils.openNewBrowserWindow();
   await new Promise(resolve => waitForFocus(resolve, win1));
 
   // create a 2nd window and snapshot the elementsStyled
   let win2 = await BrowserTestUtils.openNewBrowserWindow();
   await new Promise(resolve => waitForFocus(resolve, win2));
 
+  // (De)-activate both windows once before we take a measurement. The first
+  // (de-)activation may flush styles, after that the style data should be
+  // cached.
+  Services.focus.activeWindow = win1;
+  Services.focus.activeWindow = win2;
+
   // Flush any pending styles before we take a measurement.
   win1.getComputedStyle(win1.document.firstElementChild);
   win2.getComputedStyle(win2.document.firstElementChild);
 
   // Clear the focused element from each window so that when
   // we raise them, the focus of the element doesn't cause an
   // unrelated style flush.
   Services.focus.clearFocus(win1);