Bug 1380224 - Part 1: Check custom properties for differences in Servo-backed style contexts. r=emilio draft
authorCameron McCormack <cam@mcc.id.au>
Thu, 13 Jul 2017 16:49:14 +0800
changeset 608806 a507dd0c752a6a89edcb38d37540f863ada87806
parent 608805 2dfe2fa4ff9a375042b1410cc8830f8794909af8
child 608807 3f085b29629031338310da0b858b6472584faf97
push id68407
push userbmo:cam@mcc.id.au
push dateFri, 14 Jul 2017 06:25:25 +0000
reviewersemilio
bugs1380224
milestone56.0a1
Bug 1380224 - Part 1: Check custom properties for differences in Servo-backed style contexts. r=emilio MozReview-Commit-ID: IVyiTNxPDT9
layout/style/ServoBindingList.h
layout/style/nsStyleContext.cpp
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -467,16 +467,19 @@ SERVO_BINDING_FUNC(Servo_ComputedValues_
                    RawServoStyleSetBorrowed set,
                    ServoComputedValuesBorrowedOrNull parent_style,
                    mozilla::InheritTarget target)
 SERVO_BINDING_FUNC(Servo_ComputedValues_GetVisitedStyle,
                    ServoComputedValuesStrong,
                    ServoComputedValuesBorrowed values)
 SERVO_BINDING_FUNC(Servo_ComputedValues_GetStyleBits, uint64_t,
                    ServoComputedValuesBorrowed values)
+SERVO_BINDING_FUNC(Servo_ComputedValues_EqualCustomProperties, bool,
+                   ServoComputedValuesBorrowed first,
+                   ServoComputedValuesBorrowed second)
 // Gets the source style rules for the computed values. This returns
 // the result via rules, which would include a list of unowned pointers
 // to RawServoStyleRule.
 SERVO_BINDING_FUNC(Servo_ComputedValues_GetStyleRuleList, void,
                    ServoComputedValuesBorrowed values,
                    RawGeckoServoStyleRuleListBorrowedMut rules)
 
 // Initialize Servo components. Should be called exactly once at startup.
--- a/layout/style/nsStyleContext.cpp
+++ b/layout/style/nsStyleContext.cpp
@@ -255,28 +255,36 @@ nsStyleContext::CalcStyleDifferenceInter
   // style change, the PeekStyleData doesn't return null (implying that
   // nobody ever looked at that struct's data).  In other words, we
   // can't skip later structs if we get a big change up front, because
   // we could later get a small change in one of those structs that we
   // don't want to miss.
 
   DebugOnly<uint32_t> structsFound = 0;
 
-  // FIXME(heycam): We should just do the comparison in
-  // nsStyleVariables::CalcDifference, returning NeutralChange if there are
-  // any Variables differences.
-  const nsStyleVariables* thisVariables = PeekStyleVariables();
-  if (thisVariables) {
-    structsFound |= NS_STYLE_INHERIT_BIT(Variables);
-    const nsStyleVariables* otherVariables = aNewContext->StyleVariables();
-    if (thisVariables->mVariables == otherVariables->mVariables) {
+  if (IsGecko()) {
+    // FIXME(heycam): We should just do the comparison in
+    // nsStyleVariables::CalcDifference, returning NeutralChange if there are
+    // any Variables differences.
+    const nsStyleVariables* thisVariables = PeekStyleVariables();
+    if (thisVariables) {
+      structsFound |= NS_STYLE_INHERIT_BIT(Variables);
+      const nsStyleVariables* otherVariables = aNewContext->StyleVariables();
+      if (thisVariables->mVariables == otherVariables->mVariables) {
+        *aEqualStructs |= NS_STYLE_INHERIT_BIT(Variables);
+      }
+    } else {
       *aEqualStructs |= NS_STYLE_INHERIT_BIT(Variables);
     }
   } else {
-    *aEqualStructs |= NS_STYLE_INHERIT_BIT(Variables);
+    if (Servo_ComputedValues_EqualCustomProperties(
+          ComputedValues(),
+          aNewContext->ComputedValues())) {
+      *aEqualStructs |= NS_STYLE_INHERIT_BIT(Variables);
+    }
   }
 
   DebugOnly<int> styleStructCount = 1;  // count Variables already
 
   // Servo's optimization to stop the cascade when there are no style changes
   // that children need to be recascade for relies on comparing all of the
   // structs, not just those that are returned from PeekStyleData, although
   // if PeekStyleData does return null we still don't want to accumulate
@@ -504,16 +512,18 @@ public:
     return Servo_GetStyle##name_(mComputedValues);                            \
   }                                                                           \
   const nsStyle##name_ * ThreadsafeStyle##name_() {                           \
     return Servo_GetStyle##name_(mComputedValues);                            \
   }
   #include "nsStyleStructList.h"
   #undef STYLE_STRUCT
 
+  const ServoComputedValues* ComputedValues() { return mComputedValues; }
+
 private:
   const ServoComputedValues* MOZ_NON_OWNING_REF mComputedValues;
 };
 
 nsChangeHint
 nsStyleContext::CalcStyleDifference(const ServoComputedValues* aNewComputedValues,
                                     uint32_t* aEqualStructs,
                                     uint32_t* aSamePointerStructs)