Issue #2045 - Part 8: Remap revert keyword values to a higher cascade level

This commit is contained in:
Francis Dominic Fajardo 2025-07-03 17:51:18 +08:00 committed by roytam1
commit a47f44e93d
3 changed files with 45 additions and 24 deletions

View file

@ -174,7 +174,8 @@ MapSinglePropertyInto(nsCSSPropertyID aTargetProp,
// then records any resulting ImageValue objects in the
// CSSVariableImageTable, to give them the appropriate lifetime.
MOZ_ASSERT(aTargetValue->GetUnit() == eCSSUnit_TokenStream ||
aTargetValue->GetUnit() == eCSSUnit_Null,
aTargetValue->GetUnit() == eCSSUnit_Null ||
aTargetValue->GetUnit() == eCSSUnit_Revert,
"aTargetValue must only be a token stream (when re-parsing "
"properties with variable references) or null");
@ -316,19 +317,26 @@ nsCSSCompressedDataBlock::MapRuleInfoInto(nsRuleData *aRuleData) const
EnsurePhysicalProperty(iProp, aRuleData);
}
nsCSSValue* target = aRuleData->ValueFor(iProp);
if (target->GetUnit() == eCSSUnit_Null) {
const nsCSSValue *val = ValueAtIndex(i);
// In order for variable resolution to have the right information
// about the stylesheet level of a value, that level needs to be
// stored on the token stream. We can't do that at creation time
// because the CSS parser (which creates the object) has no idea
// about the stylesheet level, so we do it here instead, where
// the rule walking will have just updated aRuleData.
if (val->GetUnit() == eCSSUnit_TokenStream) {
val->GetTokenStreamValue()->mLevel = aRuleData->mLevel;
if (target->GetUnit() == eCSSUnit_Revert) {
if (aRuleData->mLevel >= target->GetCascadeOriginValue()) {
continue;
}
MapSinglePropertyInto(iProp, val, target, aRuleData);
} else if (target->GetUnit() != eCSSUnit_Null) {
continue;
}
const nsCSSValue* val = ValueAtIndex(i);
// In order for variable resolution to have the right information
// about the stylesheet level of a value, that level needs to be
// stored on the token stream. We can't do that at creation time
// because the CSS parser (which creates the object) has no idea
// about the stylesheet level, so we do it here instead, where
// the rule walking will have just updated aRuleData.
if (val->GetUnit() == eCSSUnit_TokenStream) {
val->GetTokenStreamValue()->mLevel = aRuleData->mLevel;
} else if (val->GetUnit() == eCSSUnit_Revert) {
aRuleData->mConditions.SetUncacheable();
}
MapSinglePropertyInto(iProp, val, target, aRuleData);
}
}
}