Bug 1417781: Consider style structs as not equal if visited styles on them are changed. r?heycam
This change should be also fine for the Gecko callers, but please double-check.
MozReview-Commit-ID: 5ZntHeBt5wC
--- 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) {