mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-05 07:18:39 +09:00
Issue #2045 - Part 5: Serialize shorthands using "revert" like those containing "unset"
This commit is contained in:
parent
9105c58a30
commit
801d4a2db8
3 changed files with 68 additions and 24 deletions
|
|
@ -558,9 +558,9 @@ Declaration::GetPropertyValueInternal(
|
|||
// (1) Since a shorthand sets all sub-properties, if some of its
|
||||
// subproperties were not specified, we must return the empty
|
||||
// string.
|
||||
// (2) Since 'inherit', 'initial' and 'unset' can only be specified
|
||||
// as the values for entire properties, we need to return the
|
||||
// empty string if some but not all of the subproperties have one
|
||||
// (2) Since 'inherit', 'initial', 'unset', and 'revert' can only be
|
||||
// specified as the values for entire properties, we need to return
|
||||
// the empty string if some but not all of the subproperties have one
|
||||
// of those values.
|
||||
// (3) Since a single value only makes sense with or without
|
||||
// !important, we return the empty string if some values are
|
||||
|
|
@ -575,7 +575,7 @@ Declaration::GetPropertyValueInternal(
|
|||
// assigned to the shorthand.
|
||||
const nsCSSValue* tokenStream = nullptr;
|
||||
uint32_t totalCount = 0, importantCount = 0,
|
||||
initialCount = 0, inheritCount = 0, unsetCount = 0,
|
||||
initialCount = 0, inheritCount = 0, unsetCount = 0, revertCount = 0,
|
||||
matchingTokenStreamCount = 0, nonMatchingTokenStreamCount = 0;
|
||||
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(p, aProperty,
|
||||
CSSEnabledState::eForAllContent) {
|
||||
|
|
@ -601,6 +601,8 @@ Declaration::GetPropertyValueInternal(
|
|||
++initialCount;
|
||||
} else if (val->GetUnit() == eCSSUnit_Unset) {
|
||||
++unsetCount;
|
||||
} else if (val->GetUnit() == eCSSUnit_Revert) {
|
||||
++revertCount;
|
||||
} else if (val->GetUnit() == eCSSUnit_TokenStream) {
|
||||
if (val->GetTokenStreamValue()->mShorthandPropertyID == aProperty) {
|
||||
tokenStream = val;
|
||||
|
|
@ -632,9 +634,15 @@ Declaration::GetPropertyValueInternal(
|
|||
nsCSSValue::eNormalized);
|
||||
return;
|
||||
}
|
||||
if (initialCount != 0 || inheritCount != 0 ||
|
||||
unsetCount != 0 || nonMatchingTokenStreamCount != 0) {
|
||||
// Case (2): partially initial, inherit, unset or token stream.
|
||||
if (revertCount == totalCount) {
|
||||
// Simplify serialization below by serializing revert up-front.
|
||||
nsCSSValue(eCSSUnit_Revert).AppendToString(eCSSProperty_UNKNOWN, aValue,
|
||||
nsCSSValue::eNormalized);
|
||||
return;
|
||||
}
|
||||
if (initialCount != 0 || inheritCount != 0 || unsetCount != 0 ||
|
||||
revertCount != 0 || nonMatchingTokenStreamCount != 0) {
|
||||
// Case (2): partially initial, inherit, unset, revert, or token stream.
|
||||
return;
|
||||
}
|
||||
if (tokenStream) {
|
||||
|
|
@ -1455,6 +1463,7 @@ Declaration::GetPropertyValueInternal(
|
|||
case eCSSUnit_Inherit:
|
||||
case eCSSUnit_Initial:
|
||||
case eCSSUnit_Unset:
|
||||
case eCSSUnit_Revert:
|
||||
return true;
|
||||
case eCSSUnit_Enumerated:
|
||||
// return false if there is a fallback value or <overflow-position>
|
||||
|
|
@ -1563,10 +1572,10 @@ Declaration::GetPropertyValueInternal(
|
|||
break;
|
||||
}
|
||||
case eCSSProperty_all:
|
||||
// If we got here, then we didn't have all "inherit" or "initial" or
|
||||
// "unset" values for all of the longhand property components of 'all'.
|
||||
// There is no other possible value that is valid for all properties,
|
||||
// so serialize as the empty string.
|
||||
// If we got here, then we didn't have all "inherit", "initial", "unset",
|
||||
// or "revert" values for all of the longhand property components of
|
||||
// 'all'. There is no other possible value that is valid for all
|
||||
// properties, so serialize as the empty string.
|
||||
break;
|
||||
default:
|
||||
MOZ_ASSERT(false, "no other shorthands");
|
||||
|
|
@ -1663,6 +1672,10 @@ Declaration::AppendVariableAndValueToString(const nsAString& aName,
|
|||
aResult.AppendLiteral("unset");
|
||||
break;
|
||||
|
||||
case CSSVariableDeclarations::eRevert:
|
||||
aResult.AppendLiteral("revert");
|
||||
break;
|
||||
|
||||
default:
|
||||
MOZ_ASSERT(false, "unexpected variable value type");
|
||||
}
|
||||
|
|
@ -1899,6 +1912,10 @@ Declaration::GetVariableValue(const nsAString& aName, nsAString& aValue) const
|
|||
aValue.AppendLiteral("unset");
|
||||
break;
|
||||
|
||||
case CSSVariableDeclarations::eRevert:
|
||||
aValue.AppendLiteral("revert");
|
||||
break;
|
||||
|
||||
default:
|
||||
MOZ_ASSERT(false, "unexpected variable value type");
|
||||
}
|
||||
|
|
@ -1964,6 +1981,11 @@ Declaration::AddVariable(const nsAString& aName,
|
|||
variables->PutUnset(aName);
|
||||
break;
|
||||
|
||||
case CSSVariableDeclarations::eRevert:
|
||||
MOZ_ASSERT(aValue.IsEmpty());
|
||||
variables->PutRevert(aName);
|
||||
break;
|
||||
|
||||
default:
|
||||
MOZ_ASSERT(false, "unexpected aType value");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue