Bug 1380224 - Part 1: Check custom properties for differences in Servo-backed style contexts. r=emilio
MozReview-Commit-ID: IVyiTNxPDT9
--- 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)