Bug 1349815 - Avoid setting the static cache during the servo traversal. r=heycam
authorBobby Holley <bobbyholley@gmail.com>
Wed, 22 Mar 2017 19:52:53 -0700
changeset 348994 45e1d59b5dffcb5ffefb2fc057cde91bb8b8d321
parent 348993 f366ad4623fd760b48d2838c165f63a78ca0d48b
child 348995 9476c9a5f4c960a62ab066c6ff1f976c80b592e2
push id39373
push userbholley@mozilla.com
push dateThu, 23 Mar 2017 04:20:37 +0000
treeherderautoland@45e1d59b5dff [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1349815
milestone55.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 1349815 - Avoid setting the static cache during the servo traversal. r=heycam MozReview-Commit-ID: E9XC4kaCVd2
widget/nsXPLookAndFeel.cpp
--- a/widget/nsXPLookAndFeel.cpp
+++ b/widget/nsXPLookAndFeel.cpp
@@ -8,16 +8,17 @@
 #include "nscore.h"
 
 #include "nsXPLookAndFeel.h"
 #include "nsLookAndFeel.h"
 #include "nsCRT.h"
 #include "nsFont.h"
 #include "mozilla/dom/ContentChild.h"
 #include "mozilla/Preferences.h"
+#include "mozilla/ServoStyleSet.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/widget/WidgetMessageUtils.h"
 
 #include "gfxPlatform.h"
 #include "qcms.h"
 
 #ifdef DEBUG
 #include "nsSize.h"
@@ -432,16 +433,18 @@ nsXPLookAndFeel::OnPrefChanged(const cha
 // Read values from the user's preferences.
 // This is done once at startup, but since the user's preferences
 // haven't actually been read yet at that time, we also have to
 // set a callback to inform us of changes to each pref.
 //
 void
 nsXPLookAndFeel::Init()
 {
+  MOZ_RELEASE_ASSERT(NS_IsMainThread());
+
   // Say we're already initialized, and take the chance that it might fail;
   // protects against some other process writing to our static variables.
   sInitialized = true;
 
   // XXX If we could reorganize the pref names, we should separate the branch
   //     for each types.  Then, we could reduce the unnecessary loop from
   //     nsXPLookAndFeel::OnPrefChanged().
   Preferences::RegisterPrefixCallback(OnPrefChanged, "ui.");
@@ -820,17 +823,20 @@ nsXPLookAndFeel::GetColorImpl(ColorID aI
         color[0] = NS_GET_R(aResult);
         color[1] = NS_GET_G(aResult);
         color[2] = NS_GET_B(aResult);
         qcms_transform_data(transform, color, color, 1);
         aResult = NS_RGB(color[0], color[1], color[2]);
       }
     }
 
-    CACHE_COLOR(aID, aResult);
+    if (!mozilla::ServoStyleSet::IsInServoTraversal()) {
+      MOZ_ASSERT(NS_IsMainThread());
+      CACHE_COLOR(aID, aResult);
+    }
     return NS_OK;
   }
 
   return NS_ERROR_NOT_AVAILABLE;
 }
 
 nsresult
 nsXPLookAndFeel::GetIntImpl(IntID aID, int32_t &aResult)