Bug 1417781: Consider style structs as not equal if visited styles on them are changed. r=heycam a=gchang
authorEmilio Cobos Álvarez <emilio@crisal.io>
Tue, 21 Nov 2017 00:53:51 +0100
changeset 444897 f9ad55279ee6acff969cfff813836d61bfa1cb92
parent 444896 3039d8099e943afeb74d056101599b74633b5caf
child 444898 54fa8f9eabe7b96ee82ce4bfd157fcc8f0a5ad36
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam, gchang
bugs1417781
milestone58.0
Bug 1417781: Consider style structs as not equal if visited styles on them are changed. r=heycam a=gchang This change should be also fine for the Gecko callers, but please double-check. MozReview-Commit-ID: 5ZntHeBt5wC
layout/style/nsStyleContext.cpp
--- a/layout/style/nsStyleContext.cpp
+++ b/layout/style/nsStyleContext.cpp
@@ -98,16 +98,17 @@ nsStyleContext::nsStyleContext(nsAtom* a
 
 #ifdef DEBUG
   static_assert(MOZ_ARRAY_LENGTH(nsStyleContext::sDependencyTable)
                   == nsStyleStructID_Length,
                 "Number of items in dependency table doesn't match IDs");
 #endif
 }
 
+// TODO(stylo-everywhere): Remove aSamePointerStructs.
 nsChangeHint
 nsStyleContext::CalcStyleDifference(nsStyleContext* aNewContext,
                                     uint32_t* aEqualStructs,
                                     uint32_t* aSamePointerStructs,
                                     bool aIgnoreVariables)
 {
   AUTO_PROFILER_LABEL("nsStyleContext::CalcStyleDifference", CSS);
 
@@ -297,34 +298,41 @@ nsStyleContext::CalcStyleDifference(nsSt
   // here, we add nsChangeHint_RepaintFrame hints (the maximum for
   // things that can depend on :visited) for the properties on which we
   // call GetVisitedDependentColor.
   nsStyleContext* thisVis = GetStyleIfVisited();
   nsStyleContext* otherVis = aNewContext->GetStyleIfVisited();
   if (!thisVis != !otherVis) {
     // One style context has a style-if-visited and the other doesn't.
     // Presume a difference.
+#define STYLE_STRUCT(name_, fields_)                                \
+    *aSamePointerStructs &= ~NS_STYLE_INHERIT_BIT(name_);           \
+    *aEqualStructs &= ~NS_STYLE_INHERIT_BIT(name_);
+#include "nsCSSVisitedDependentPropList.h"
+#undef STYLE_STRUCT
     hint |= nsChangeHint_RepaintFrame;
-  } else if (thisVis && !NS_IsHintSubset(nsChangeHint_RepaintFrame, hint)) {
+  } else if (thisVis) {
     // Both style contexts have a style-if-visited.
     bool change = false;
 
     // NB: Calling Peek on |this|, not |thisVis|, since callers may look
     // at a struct on |this| without looking at the same struct on
     // |thisVis| (including this function if we skip one of these checks
     // due to change being true already or due to the old style context
     // not having a style-if-visited), but not the other way around.
 #define STYLE_FIELD(name_) thisVisStruct->name_ != otherVisStruct->name_
 #define STYLE_STRUCT(name_, fields_)                                    \
-    if (!change && (PEEK(name_) != nullptr)) {                          \
+    if (PEEK(name_)) {                                                  \
       const nsStyle##name_* thisVisStruct =                             \
         thisVis->ThreadsafeStyle##name_();                              \
       const nsStyle##name_* otherVisStruct =                            \
         otherVis->ThreadsafeStyle##name_();                             \
       if (MOZ_FOR_EACH_SEPARATED(STYLE_FIELD, (||), (), fields_)) {     \
+        *aSamePointerStructs &= ~NS_STYLE_INHERIT_BIT(name_);           \
+        *aEqualStructs &= ~NS_STYLE_INHERIT_BIT(name_);                 \
         change = true;                                                  \
       }                                                                 \
     }
 #include "nsCSSVisitedDependentPropList.h"
 #undef STYLE_STRUCT
 #undef STYLE_FIELD
 
     if (change) {