mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 773296 - Part 19: Compare style structs even for the same rule node when variables have changed. r=dbaron
This makes updates work correctly when variable values change. Rather than handling nsStyleVariables with a DO_STRUCT_DIFFERENCE, we explicitly compare the two nsStyleVariables objects in nsStyleContext::CalcStyleDifference before looking at the other style structs. This is because we need to force those other style structs to be compared if variable values are changing. nsStyleVariables::CalcDifference still returns 0, since the change in variable values themselves doesn't require any updates.
This commit is contained in:
parent
ba08f38dc0
commit
3fdf3d9eee
@ -42,6 +42,28 @@ CSSVariableValues::operator=(const CSSVariableValues& aOther)
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool
|
||||
CSSVariableValues::operator==(const CSSVariableValues& aOther) const
|
||||
{
|
||||
if (mVariables.Length() != aOther.mVariables.Length()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (size_t thisIndex = 0; thisIndex < mVariables.Length(); ++thisIndex) {
|
||||
size_t otherIndex;
|
||||
if (!aOther.mVariableIDs.Get(mVariables[thisIndex].mVariableName,
|
||||
&otherIndex)) {
|
||||
return false;
|
||||
}
|
||||
const nsString& otherValue = aOther.mVariables[otherIndex].mValue;
|
||||
if (!mVariables[thisIndex].mValue.Equals(otherValue)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
CSSVariableValues::Get(const nsAString& aName, nsString& aValue) const
|
||||
{
|
||||
|
@ -26,6 +26,10 @@ public:
|
||||
#endif
|
||||
CSSVariableValues& operator=(const CSSVariableValues& aOther);
|
||||
|
||||
bool operator==(const CSSVariableValues& aOther) const;
|
||||
bool operator!=(const CSSVariableValues& aOther) const
|
||||
{ return !(*this == aOther); }
|
||||
|
||||
/**
|
||||
* Gets the value of a variable in this set of computed variables.
|
||||
*
|
||||
|
@ -440,7 +440,19 @@ nsStyleContext::CalcStyleDifference(nsStyleContext* aOther,
|
||||
// by font-size changing, so we don't need to worry about them like
|
||||
// we worry about 'inherit' values.)
|
||||
bool compare = mRuleNode != aOther->mRuleNode;
|
||||
DebugOnly<int> styleStructCount = 0;
|
||||
|
||||
// If we had any change in variable values, then we'll need to examine
|
||||
// all of the other style structs too, even if the new style context has
|
||||
// the same rule node as the old one.
|
||||
const nsStyleVariables* thisVariables = PeekStyleVariables();
|
||||
if (thisVariables) {
|
||||
const nsStyleVariables* otherVariables = aOther->StyleVariables();
|
||||
if (thisVariables->mVariables != otherVariables->mVariables) {
|
||||
compare = true;
|
||||
}
|
||||
}
|
||||
|
||||
DebugOnly<int> styleStructCount = 1; // count Variables already
|
||||
|
||||
#define DO_STRUCT_DIFFERENCE(struct_) \
|
||||
PR_BEGIN_MACRO \
|
||||
@ -490,7 +502,6 @@ nsStyleContext::CalcStyleDifference(nsStyleContext* aOther,
|
||||
DO_STRUCT_DIFFERENCE(TextReset);
|
||||
DO_STRUCT_DIFFERENCE(Background);
|
||||
DO_STRUCT_DIFFERENCE(Color);
|
||||
DO_STRUCT_DIFFERENCE(Variables);
|
||||
|
||||
#undef DO_STRUCT_DIFFERENCE
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user