Bug 1376655 - Move EnsureSameStructsCached to GeckoStyleContext. r=emilio
authorBobby Holley <bobbyholley@gmail.com>
Tue, 27 Jun 2017 18:47:04 -0700
changeset 366450 f3e0f0a4ab7b48483dcb6c6283220282b7aec651
parent 366449 0eb7e3863c5f3750c05497fbff10fbdd7d5ebf97
child 366451 ecf7e90cecf61941db73659203ea09c28ef7a417
push id45589
push userbholley@mozilla.com
push dateWed, 28 Jun 2017 17:08:46 +0000
treeherderautoland@f3e0f0a4ab7b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1376655
milestone56.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 1376655 - Move EnsureSameStructsCached to GeckoStyleContext. r=emilio
layout/base/GeckoRestyleManager.cpp
layout/style/GeckoStyleContext.h
layout/style/nsStyleContext.cpp
layout/style/nsStyleContext.h
--- a/layout/base/GeckoRestyleManager.cpp
+++ b/layout/base/GeckoRestyleManager.cpp
@@ -969,17 +969,17 @@ GeckoRestyleManager::ReparentStyleContex
         TryInitiatingTransition(mPresContext, aFrame->GetContent(),
                                 oldContext, &newContext);
       }
 #endif
 
       // Ensure the new context ends up resolving all the structs the old
       // context resolved.
       if (!copyFromContinuation) {
-        newContext->EnsureSameStructsCached(oldContext);
+        newContext->AsGecko()->EnsureSameStructsCached(oldContext);
       }
 
       aFrame->SetStyleContext(newContext);
 
       nsIFrame::ChildListIterator lists(aFrame);
       for (; !lists.IsDone(); lists.Next()) {
         for (nsIFrame* child : lists.CurrentList()) {
           // only do frames that are in flow
@@ -1022,17 +1022,17 @@ GeckoRestyleManager::ReparentStyleContex
         RefPtr<nsStyleContext> newExtraContext;
         newExtraContext = StyleSet()->
                             ReparentStyleContext(oldExtraContext,
                                                  newContext, nullptr);
         if (newExtraContext) {
           if (newExtraContext != oldExtraContext) {
             // Ensure the new context ends up resolving all the structs the old
             // context resolved.
-            newContext->EnsureSameStructsCached(oldContext);
+            newContext->AsGecko()->EnsureSameStructsCached(oldContext);
           }
 
           aFrame->SetAdditionalStyleContext(contextIndex, newExtraContext);
         }
       }
 #ifdef DEBUG
       DebugVerifyStyleTree(aFrame);
 #endif
--- a/layout/style/GeckoStyleContext.h
+++ b/layout/style/GeckoStyleContext.h
@@ -26,16 +26,21 @@ public:
   }
 
   void AddChild(GeckoStyleContext* aChild);
   void RemoveChild(GeckoStyleContext* aChild);
 
   void* GetUniqueStyleData(const nsStyleStructID& aSID);
   void* CreateEmptyStyleData(const nsStyleStructID& aSID);
 
+  /**
+   * Ensures the same structs are cached on this style context as would be
+   * done if we called aOther->CalcDifference(this).
+   */
+  void EnsureSameStructsCached(nsStyleContext* aOldContext);
 
   /**
    * Sets the NS_STYLE_INELIGIBLE_FOR_SHARING bit on this style context
    * and its descendants.  If it finds a descendant that has the bit
    * already set, assumes that it can skip that subtree.
    */
   void SetIneligibleForSharing();
   /**
--- a/layout/style/nsStyleContext.cpp
+++ b/layout/style/nsStyleContext.cpp
@@ -520,43 +520,37 @@ nsStyleContext::CalcStyleDifference(cons
                                     uint32_t* aSamePointerStructs)
 {
   FakeStyleContext newContext(aNewComputedValues);
   return CalcStyleDifferenceInternal(&newContext,
                                      aEqualStructs,
                                      aSamePointerStructs);
 }
 
+namespace mozilla {
+
 void
-nsStyleContext::EnsureSameStructsCached(nsStyleContext* aOldContext)
+GeckoStyleContext::EnsureSameStructsCached(nsStyleContext* aOldContext)
 {
   // NOTE(emilio): We could do better here for stylo, where we only call
   // Style##name_() because we need to run FinishStyle, but otherwise this
   // is only a bitwise or.
   //
   // We could reduce the FFI traffic we do only doing it for structs that have
   // non-trivial FinishStyle.
 
 #define STYLE_STRUCT(name_, checkdata_cb_)                                    \
   if (aOldContext->PeekStyle##name_()) {                                      \
     Style##name_();                                                           \
   }
 #include "nsStyleStructList.h"
 #undef STYLE_STRUCT
+}
 
-#ifdef DEBUG
-  if (IsServo()) {
-    auto oldMask = aOldContext->mBits & NS_STYLE_INHERIT_MASK;
-    auto newMask = mBits & NS_STYLE_INHERIT_MASK;
-    MOZ_ASSERT((oldMask & newMask) == oldMask,
-               "Should have at least as many structs computed as the "
-               "old context!");
-  }
-#endif
-}
+} // namespace mozilla
 
 #ifdef DEBUG
 void nsStyleContext::List(FILE* out, int32_t aIndent, bool aListDescendants)
 {
   nsAutoCString str;
   // Indent
   int32_t ix;
   for (ix = aIndent; --ix >= 0; ) {
--- a/layout/style/nsStyleContext.h
+++ b/layout/style/nsStyleContext.h
@@ -339,22 +339,16 @@ public:
 private:
   template<class StyleContextLike>
   nsChangeHint CalcStyleDifferenceInternal(StyleContextLike* aNewContext,
                                            uint32_t* aEqualStructs,
                                            uint32_t* aSamePointerStructs);
 
 public:
   /**
-   * Ensures the same structs are cached on this style context as would be
-   * done if we called aOther->CalcDifference(this).
-   */
-  void EnsureSameStructsCached(nsStyleContext* aOldContext);
-
-  /**
    * Get a color that depends on link-visitedness using this and
    * this->GetStyleIfVisited().
    *
    * @param aField A pointer to a member variable in a style struct.
    *               The member variable and its style struct must have
    *               been listed in nsCSSVisitedDependentPropList.h.
    */
   template<typename T, typename S>