Bug 1289868 - Part 2: stylo: Compare all structs in CalcStyleDifference so that Servo can accurately determine whether to stop traversal. r=emilio
authorCameron McCormack <cam@mcc.id.au>
Fri, 19 May 2017 17:39:14 +0800
changeset 359804 da166dedd42e0cbef6515c7b5f51dbacc85f0ba1
parent 359803 008cb503f35e0576d22e63b9aa3186ee064f6020
child 359805 36678242b5a67613e665050b8f0413a167c8ae15
push id90515
push userphilringnalda@gmail.com
push dateSun, 21 May 2017 20:18:32 +0000
treeherdermozilla-inbound@76cbe80e7e87 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1289868
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 1289868 - Part 2: stylo: Compare all structs in CalcStyleDifference so that Servo can accurately determine whether to stop traversal. r=emilio MozReview-Commit-ID: I0WK2gDsMMu
layout/style/nsStyleContext.cpp
--- a/layout/style/nsStyleContext.cpp
+++ b/layout/style/nsStyleContext.cpp
@@ -1027,30 +1027,49 @@ nsStyleContext::CalcStyleDifferenceInter
       *aEqualStructs |= NS_STYLE_INHERIT_BIT(Variables);
     }
   } else {
     *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
+  // any change hints for those structs.
+  bool checkUnrequestedServoStructs = mSource.IsServoComputedValues();
+
 #define DO_STRUCT_DIFFERENCE(struct_)                                         \
   PR_BEGIN_MACRO                                                              \
     const nsStyle##struct_* this##struct_ = PeekStyle##struct_();             \
+    bool unrequestedStruct;                                                   \
     if (this##struct_) {                                                      \
+      unrequestedStruct = false;                                              \
       structsFound |= NS_STYLE_INHERIT_BIT(struct_);                          \
+    } else if (checkUnrequestedServoStructs) {                                \
+      this##struct_ =                                                         \
+        Servo_GetStyle##struct_(mSource.AsServoComputedValues());             \
+      unrequestedStruct = true;                                               \
+    } else {                                                                  \
+      unrequestedStruct = false;                                              \
+    }                                                                         \
+    if (this##struct_) {                                                      \
       const nsStyle##struct_* other##struct_ = aNewContext->Style##struct_(); \
       if (this##struct_ == other##struct_) {                                  \
         /* The very same struct, so we know that there will be no */          \
         /* differences.                                           */          \
         *aEqualStructs |= NS_STYLE_INHERIT_BIT(struct_);                      \
       } else {                                                                \
         nsChangeHint difference =                                             \
           this##struct_->CalcDifference(*other##struct_ EXTRA_DIFF_ARGS);     \
-        hint |= difference;                                                   \
+        if (!unrequestedStruct) {                                             \
+          hint |= difference;                                                 \
+        }                                                                     \
         if (!difference) {                                                    \
           *aEqualStructs |= NS_STYLE_INHERIT_BIT(struct_);                    \
         }                                                                     \
       }                                                                       \
     } else {                                                                  \
       *aEqualStructs |= NS_STYLE_INHERIT_BIT(struct_);                        \
     }                                                                         \
     styleStructCount++;                                                       \