Merge remote-tracking branch 'origin/tracking' into custom

This commit is contained in:
roytam1 2025-07-07 11:59:17 +08:00
commit bd335d6284
36 changed files with 1149 additions and 306 deletions

View file

@ -953,10 +953,11 @@ inDOMUtils::GetCSSValuesForProperty(const nsAString& aProperty,
GetOtherValuesForProperty(propertyParserVariant, array);
}
}
// All CSS properties take initial, inherit and unset.
// All CSS properties take initial, inherit, unset, and revert.
InsertNoDuplicates(array, NS_LITERAL_STRING("initial"));
InsertNoDuplicates(array, NS_LITERAL_STRING("inherit"));
InsertNoDuplicates(array, NS_LITERAL_STRING("unset"));
InsertNoDuplicates(array, NS_LITERAL_STRING("revert"));
*aLength = array.Length();
char16_t** ret =

View file

@ -11,12 +11,13 @@
#include "nsCSSScanner.h"
#include "nsRuleData.h"
// These three special string values are used to represent specified values of
// 'initial', 'inherit' and 'unset'. (Note that none of these are valid
// variable values.)
// These four special string values are used to represent specified values of
// 'initial', 'inherit', 'unset', and 'revert'. (Note that none of these are
// valid variable values.)
#define INITIAL_VALUE "!"
#define INHERIT_VALUE ";"
#define UNSET_VALUE ")"
#define REVERT_VALUE ">"
namespace mozilla {
@ -83,6 +84,9 @@ CSSVariableDeclarations::Get(const nsAString& aName,
} else if (value.EqualsLiteral(UNSET_VALUE)) {
aType = eUnset;
aTokenStream.Truncate();
} else if (value.EqualsLiteral(REVERT_VALUE)) {
aType = eRevert;
aTokenStream.Truncate();
} else {
aType = eTokenStream;
aTokenStream = value;
@ -96,7 +100,8 @@ CSSVariableDeclarations::PutTokenStream(const nsAString& aName,
{
MOZ_ASSERT(!aTokenStream.EqualsLiteral(INITIAL_VALUE) &&
!aTokenStream.EqualsLiteral(INHERIT_VALUE) &&
!aTokenStream.EqualsLiteral(UNSET_VALUE));
!aTokenStream.EqualsLiteral(UNSET_VALUE) &&
!aTokenStream.EqualsLiteral(REVERT_VALUE));
mVariables.Put(aName, aTokenStream);
}
@ -118,6 +123,12 @@ CSSVariableDeclarations::PutUnset(const nsAString& aName)
mVariables.Put(aName, NS_LITERAL_STRING(UNSET_VALUE));
}
void
CSSVariableDeclarations::PutRevert(const nsAString& aName)
{
mVariables.Put(aName, NS_LITERAL_STRING(REVERT_VALUE));
}
void
CSSVariableDeclarations::Remove(const nsAString& aName)
{
@ -160,12 +171,13 @@ CSSVariableDeclarations::AddVariablesToResolver(
eCSSTokenSerialization_Nothing,
false);
} else if (value.EqualsLiteral(INHERIT_VALUE) ||
value.EqualsLiteral(UNSET_VALUE)) {
// Values of 'inherit' and 'unset' don't need any handling, since it means
// we just need to keep whatever value is currently in the resolver. This
// is because the specified variable declarations already have only the
// winning declaration for the variable and no longer have any of the
// others.
value.EqualsLiteral(UNSET_VALUE) ||
value.EqualsLiteral(REVERT_VALUE)) {
// Values of 'inherit', 'unset', and 'revert' don't need any handling,
// since it means we just need to keep whatever value is currently in
// the resolver. This is because the specified variable declarations
// already have only the winning declaration for the variable and no
// longer have any of the others.
} else {
// At this point, we don't know what token types are at the start and end
// of the specified variable value. These will be determined later during

View file

@ -42,7 +42,8 @@ public:
eTokenStream, // a stream of CSS tokens (the usual type for variables)
eInitial, // 'initial'
eInherit, // 'inherit'
eUnset // 'unset'
eUnset, // 'unset'
eRevert // 'revert'
};
/**
@ -53,8 +54,8 @@ public:
* @param aType Out parameter into which the type of the variable value will
* be stored.
* @param aValue Out parameter into which the value of the variable will
* be stored. If the variable is 'initial', 'inherit' or 'unset', this will
* be the empty string.
* be stored. If the variable is 'initial', 'inherit', 'unset', or
* 'revert', this will be the empty string.
* @return Whether a variable with the given name was found. When false
* is returned, aType and aValue will not be modified.
*/
@ -87,6 +88,15 @@ public:
*/
void PutUnset(const nsAString& aName);
/**
* Adds or modifies an existing entry in this set of variable declarations
* to have the value 'revert'.
*
* @param aName The variable name (not including any "--" prefix that would
* be part of the custom property name) whose value is to be set.
*/
void PutRevert(const nsAString& aName);
/**
* Adds or modifies an existing entry in this set of variable declarations
* to have a token stream value.

View file

@ -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) {
@ -794,18 +802,63 @@ Declaration::GetPropertyValueInternal(
MOZ_ASSERT(StringEndsWith(nsCSSProps::GetStringValue(subprops[2]),
NS_LITERAL_CSTRING("-color")),
"third subprop must be the color property");
const nsCSSValue *widthValue = data->ValueFor(subprops[0]);
const nsCSSValue *styleValue = data->ValueFor(subprops[1]);
const nsCSSValue *colorValue = data->ValueFor(subprops[2]);
bool isCurrentColor =
bool isNoneStyle =
styleValue->GetUnit() == eCSSUnit_Enumerated &&
styleValue->GetIntValue() == NS_STYLE_BORDER_STYLE_NONE;
bool isMediumWidth =
widthValue->GetUnit() == eCSSUnit_Enumerated &&
widthValue->GetIntValue() == NS_STYLE_BORDER_WIDTH_MEDIUM;
bool isCurrentColor = colorValue->GetUnit() == eCSSUnit_EnumColor &&
colorValue->GetIntValue() == NS_COLOR_CURRENTCOLOR;
if (isNoneStyle && isCurrentColor) {
// Case (1) above: some subproperties not specified.
return;
}
isCurrentColor =
colorValue->GetUnit() == eCSSUnit_EnumColor &&
colorValue->GetIntValue() == NS_COLOR_CURRENTCOLOR;
if (!AppendValueToString(subprops[0], aValue, aSerialization) ||
!(aValue.Append(char16_t(' ')),
AppendValueToString(subprops[1], aValue, aSerialization)) ||
// Don't output a third value when it's currentcolor.
!(isCurrentColor ||
(aValue.Append(char16_t(' ')),
AppendValueToString(subprops[2], aValue, aSerialization)))) {
aValue.Truncate();
// special case: if we have just color and all other values are default,
// output: color
if (!isCurrentColor && isNoneStyle && isMediumWidth) {
if (!AppendValueToString(subprops[2], aValue, aSerialization)) {
aValue.Truncate();
}
break;
}
// normal case: output width unless medium and only have color
if (!(isMediumWidth && isNoneStyle && !isCurrentColor)) {
if (!AppendValueToString(subprops[0], aValue, aSerialization)) {
aValue.Truncate();
break;
}
}
// if style is not none, append style
if (!isNoneStyle) {
aValue.Append(char16_t(' '));
if (!AppendValueToString(subprops[1], aValue, aSerialization)) {
aValue.Truncate();
break;
}
}
if (!isCurrentColor) {
aValue.Append(char16_t(' '));
if (!AppendValueToString(subprops[2], aValue, aSerialization)) {
aValue.Truncate();
break;
}
}
break;
}
@ -1022,12 +1075,21 @@ Declaration::GetPropertyValueInternal(
aSerialization);
break;
case eCSSProperty_overflow: {
const nsCSSValue &xValue =
*data->ValueFor(eCSSProperty_overflow_x);
const nsCSSValue &yValue =
*data->ValueFor(eCSSProperty_overflow_y);
if (xValue == yValue)
xValue.AppendToString(eCSSProperty_overflow_x, aValue, aSerialization);
const nsCSSValue* xValue = data->ValueFor(eCSSProperty_overflow_x);
const nsCSSValue* yValue = data->ValueFor(eCSSProperty_overflow_y);
if (!xValue || !yValue ||
xValue->GetUnit() != eCSSUnit_Enumerated ||
yValue->GetUnit() != eCSSUnit_Enumerated) {
aValue.Truncate(); // don't serialize shorthand if not both present/enumerated
break;
}
if (*xValue == *yValue) {
xValue->AppendToString(eCSSProperty_overflow_x, aValue, aSerialization);
} else {
xValue->AppendToString(eCSSProperty_overflow_x, aValue, aSerialization);
aValue.Append(char16_t(' '));
yValue->AppendToString(eCSSProperty_overflow_y, aValue, aSerialization);
}
break;
}
case eCSSProperty_text_decoration: {
@ -1455,6 +1517,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 +1626,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 +1726,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 +1966,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 +2035,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");
}

View file

@ -201,7 +201,7 @@ FontFaceSet::ParseFontShorthandForMatching(
const nsCSSValue* family = data->ValueFor(eCSSProperty_font_family);
if (family->GetUnit() != eCSSUnit_FontFamilyList) {
// We got inherit, initial, unset, a system font, or a token stream.
// We got inherit, initial, unset, revert, a system font, or a token stream.
aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
return;
}

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);
}
}
}

View file

@ -474,6 +474,7 @@ CSS_KEY(repeat, repeat)
CSS_KEY(repeat-x, repeat_x)
CSS_KEY(repeat-y, repeat_y)
CSS_KEY(reverse, reverse)
CSS_KEY(revert, revert)
CSS_KEY(ridge, ridge)
CSS_KEY(right, right)
CSS_KEY(rl, rl)

View file

@ -1170,8 +1170,9 @@ protected:
nsString& aValue);
/**
* Parses a CSS variable value. This could be 'initial', 'inherit', 'unset'
* or a token stream, which may or may not include variable references.
* Parses a CSS variable value. This could be 'initial', 'inherit', 'unset',
* 'revert', or a token stream, which may or may not include variable
* references.
*
* @param aType Out parameter into which the type of the variable value
* will be stored.
@ -1525,6 +1526,9 @@ protected:
// enum type be signed.
css::SheetParsingMode mParsingMode : 3;
// Indicates the cascade origin of the sheet.
mozilla::SheetType mLevel;
// True if we are in parsing rules for the chrome.
bool mIsChrome : 1;
@ -1656,6 +1660,7 @@ CSSParserImpl::CSSParserImpl()
mHashlessColorQuirk(false),
mUnitlessLengthQuirk(false),
mParsingMode(css::eAuthorSheetFeatures),
mLevel(mozilla::SheetType::Doc),
mIsChrome(false),
mViewportUnitsEnabled(true),
mHTMLMediaMode(false),
@ -1799,6 +1804,22 @@ CSSParserImpl::ParseSheet(const nsAString& aInput,
}
mParsingMode = mSheet->ParsingMode();
switch (mParsingMode) {
case css::eAgentSheetFeatures:
mLevel = mozilla::SheetType::Agent;
break;
case css::eUserSheetFeatures:
mLevel = mozilla::SheetType::User;
break;
case css::eAuthorSheetFeatures:
mLevel = mozilla::SheetType::Doc;
break;
default:
MOZ_CRASH("impossible value for aType");
}
mIsChrome = dom::IsChromeURI(aSheetURI);
mReusableSheets = aReusableSheets;
@ -1824,6 +1845,7 @@ CSSParserImpl::ParseSheet(const nsAString& aInput,
ReleaseScanner();
mParsingMode = css::eAuthorSheetFeatures;
mLevel = mozilla::SheetType::Doc;
mIsChrome = false;
mReusableSheets = nullptr;
@ -8185,6 +8207,10 @@ CSSParserImpl::ParseVariant(nsCSSValue& aValue,
aValue.SetUnsetValue();
return CSSParseResult::Ok;
}
else if (eCSSKeyword_revert == keyword) {
aValue.SetRevertValue(mLevel);
return CSSParseResult::Ok;
}
}
if ((aVariantMask & VARIANT_NONE) != 0) {
if (eCSSKeyword_none == keyword) {
@ -8384,7 +8410,8 @@ CSSParserImpl::ParseVariant(nsCSSValue& aValue,
!(tk->mIdent.LowerCaseEqualsLiteral("inherit") ||
tk->mIdent.LowerCaseEqualsLiteral("initial") ||
(tk->mIdent.LowerCaseEqualsLiteral("unset") &&
nsLayoutUtils::UnsetValueEnabled())))) {
nsLayoutUtils::UnsetValueEnabled()) ||
tk->mIdent.LowerCaseEqualsLiteral("revert")))) {
aValue.SetStringValue(tk->mIdent, eCSSUnit_Ident);
return CSSParseResult::Ok;
}
@ -8454,6 +8481,7 @@ CSSParserImpl::ParseCustomIdent(nsCSSValue& aValue,
if (keyword == eCSSKeyword_inherit ||
keyword == eCSSKeyword_initial ||
keyword == eCSSKeyword_unset ||
keyword == eCSSKeyword_revert ||
keyword == eCSSKeyword_default ||
(aPropertyKTable &&
nsCSSProps::FindIndexOfKeyword(keyword, aPropertyKTable) >= 0)) {
@ -8675,7 +8703,7 @@ bool
CSSParserImpl::ParseImageOrientation(nsCSSValue& aValue)
{
if (ParseSingleTokenVariant(aValue, VARIANT_INHERIT, nullptr)) {
// 'inherit', 'initial' and 'unset' must be alone
// 'inherit', 'initial', 'unset', and 'revert' must be alone
return true;
}
@ -8789,7 +8817,7 @@ CSSParserImpl::ParseElement(nsCSSValue& aValue)
bool
CSSParserImpl::ParseFlex()
{
// First check for inherit / initial / unset
// First check for inherit / initial / unset / revert
nsCSSValue tmpVal;
if (ParseSingleTokenVariant(tmpVal, VARIANT_INHERIT, nullptr)) {
AppendValue(eCSSProperty_flex_grow, tmpVal);
@ -10297,7 +10325,8 @@ bool
CSSParserImpl::ParseInitialLetter()
{
nsCSSValue value;
// 'inherit', 'initial', 'unset', 'none', and 'normal' must be alone
// 'inherit', 'initial', 'unset', 'revert', 'none', and 'normal'
// must be alone
if (!ParseSingleTokenVariant(value, VARIANT_INHERIT | VARIANT_NORMAL,
nullptr)) {
nsCSSValue first, second;
@ -11551,8 +11580,14 @@ CSSParserImpl::ParseChoice(nsCSSValue aValues[],
}
found = ((1 << aNumIDs) - 1);
}
else if (eCSSUnit_Revert == aValues[0].GetUnit()) { // one revert, all revert
for (loop = 1; loop < aNumIDs; loop++) {
aValues[loop].SetRevertValue(mLevel);
}
found = ((1 << aNumIDs) - 1);
}
}
else { // more than one value, verify no inherits, initials or unsets
else { // more than one value, verify no inherits, initials, unsets, or reverts
for (loop = 0; loop < aNumIDs; loop++) {
if (eCSSUnit_Inherit == aValues[loop].GetUnit()) {
found = -1;
@ -11566,6 +11601,10 @@ CSSParserImpl::ParseChoice(nsCSSValue aValues[],
found = -1;
break;
}
else if (eCSSUnit_Revert == aValues[loop].GetUnit()) {
found = -1;
break;
}
}
}
}
@ -11604,12 +11643,13 @@ CSSParserImpl::ParseBoxProperties(const nsCSSPropertyID aPropIDs[])
return false;
}
if (1 < count) { // verify no more than single inherit, initial or unset
if (1 < count) { // verify no more than single inherit, initial, unset, or revert
NS_FOR_CSS_SIDES (index) {
nsCSSUnit unit = (result.*(nsCSSRect::sides[index])).GetUnit();
if (eCSSUnit_Inherit == unit ||
eCSSUnit_Initial == unit ||
eCSSUnit_Unset == unit) {
eCSSUnit_Unset == unit ||
eCSSUnit_Revert == unit) {
return false;
}
}
@ -11713,10 +11753,11 @@ CSSParserImpl::ParseBoxCornerRadius(nsCSSPropertyID aPropID)
return false;
}
// optional second value (forbidden if first value is inherit/initial/unset)
// optional second value (forbidden if first value is inherit/initial/unset/revert)
if (dimenX.GetUnit() != eCSSUnit_Inherit &&
dimenX.GetUnit() != eCSSUnit_Initial &&
dimenX.GetUnit() != eCSSUnit_Unset) {
dimenX.GetUnit() != eCSSUnit_Unset &&
dimenX.GetUnit() != eCSSUnit_Revert) {
if (ParseNonNegativeVariant(dimenY, VARIANT_LP | VARIANT_CALC, nullptr) ==
CSSParseResult::Error) {
return false;
@ -11774,12 +11815,14 @@ CSSParserImpl::ParseBoxCornerRadiiInternals(nsCSSValue array[])
return false;
}
// if 'initial', 'inherit' or 'unset' was used, it must be the only value
// if 'initial', 'inherit', 'unset', or 'revert' was used, it
// must be the only value
if (countX > 1 || countY > 0) {
nsCSSUnit unit = dimenX.mTop.GetUnit();
if (eCSSUnit_Inherit == unit ||
eCSSUnit_Initial == unit ||
eCSSUnit_Unset == unit)
eCSSUnit_Unset == unit ||
eCSSUnit_Revert == unit)
return false;
}
@ -12526,6 +12569,7 @@ CSSParserImpl::ParseFontDescriptorValue(nsCSSFontDesc aDescID,
aValue.GetUnit() != eCSSUnit_Inherit &&
aValue.GetUnit() != eCSSUnit_Initial &&
aValue.GetUnit() != eCSSUnit_Unset &&
aValue.GetUnit() != eCSSUnit_Revert &&
(aValue.GetUnit() != eCSSUnit_Enumerated ||
(aValue.GetIntValue() != NS_STYLE_FONT_WEIGHT_BOLDER &&
aValue.GetIntValue() != NS_STYLE_FONT_WEIGHT_LIGHTER)));
@ -12590,7 +12634,7 @@ CSSParserImpl::ParseImageLayers(const nsCSSPropertyID aTable[])
// background-color can only be set once, so it's not a list.
nsCSSValue color;
// Check first for inherit/initial/unset.
// Check first for inherit/initial/unset/revert.
if (ParseSingleTokenVariant(color, VARIANT_INHERIT, nullptr)) {
// must be alone
for (const nsCSSPropertyID* subprops =
@ -12787,7 +12831,8 @@ CSSParserImpl::ParseImageLayersItem(
int32_t dummy;
if (keyword == eCSSKeyword_inherit ||
keyword == eCSSKeyword_initial ||
keyword == eCSSKeyword_unset) {
keyword == eCSSKeyword_unset ||
keyword == eCSSKeyword_revert) {
return false;
} else if (keyword == eCSSKeyword_none) {
if (haveImage)
@ -12950,7 +12995,7 @@ CSSParserImpl::ParseImageLayersItem(
if (haveColor)
return false;
haveColor = true;
// Note: This parses 'inherit', 'initial' and 'unset', but
// Note: This parses 'inherit', 'initial', 'unset', and 'revert', but
// we've already checked for them, so it's ok.
if (ParseSingleValueProperty(aState.mColor,
aTable[nsStyleImageLayers::color]) !=
@ -12974,7 +13019,7 @@ CSSParserImpl::ParseValueList(nsCSSPropertyID aPropID)
{
// aPropID is a single value prop-id
nsCSSValue value;
// 'initial', 'inherit' and 'unset' stand alone, no list permitted.
// 'initial', 'inherit', 'unset', and 'revert' stand alone, no list permitted.
if (!ParseSingleTokenVariant(value, VARIANT_INHERIT, nullptr)) {
nsCSSValueList* item = value.SetListValue();
for (;;) {
@ -12997,7 +13042,7 @@ bool
CSSParserImpl::ParseImageLayerRepeat(nsCSSPropertyID aPropID)
{
nsCSSValue value;
// 'initial', 'inherit' and 'unset' stand alone, no list permitted.
// 'initial', 'inherit', 'unset', and 'revert' stand alone, no list permitted.
if (!ParseSingleTokenVariant(value, VARIANT_INHERIT, nullptr)) {
nsCSSValuePair valuePair;
if (!ParseImageLayerRepeatValues(valuePair)) {
@ -13047,7 +13092,7 @@ CSSParserImpl::ParseImageLayerRepeatValues(nsCSSValuePair& aValue)
bool
CSSParserImpl::ParseImageLayerPosition(const nsCSSPropertyID aTable[])
{
// 'initial', 'inherit' and 'unset' stand alone, no list permitted.
// 'initial', 'inherit', 'unset', and 'revert' stand alone, no list permitted.
nsCSSValue position;
if (ParseSingleTokenVariant(position, VARIANT_INHERIT, nullptr)) {
AppendValue(aTable[nsStyleImageLayers::positionX], position);
@ -13088,7 +13133,7 @@ bool
CSSParserImpl::ParseImageLayerPositionCoord(nsCSSPropertyID aPropID, bool aIsHorizontal)
{
nsCSSValue value;
// 'initial', 'inherit' and 'unset' stand alone, no list permitted.
// 'initial', 'inherit', 'unset', and 'revert' stand alone, no list permitted.
if (!ParseSingleTokenVariant(value, VARIANT_INHERIT, nullptr)) {
nsCSSValue itemValue;
if (!ParseImageLayerPositionCoordItem(itemValue, aIsHorizontal)) {
@ -13123,8 +13168,8 @@ CSSParserImpl::ParseImageLayerPositionCoord(nsCSSPropertyID aPropID, bool aIsHor
* like "top," "left center," etc.
*
* @param aOut The nsCSSValuePair in which to place the result.
* @param aAcceptsInherit If true, 'inherit', 'initial' and 'unset' are
* legal values
* @param aAcceptsInherit If true, 'inherit', 'initial', 'unset', and 'revert'
* are legal values
* @param aAllowExplicitCenter If true, 'center' is a legal value
* @return Whether or not the operation succeeded.
*/
@ -13143,7 +13188,8 @@ bool CSSParserImpl::ParseBoxPositionValues(nsCSSValuePair &aOut,
} else if (result == CSSParseResult::Ok) {
if (eCSSUnit_Inherit == xValue.GetUnit() ||
eCSSUnit_Initial == xValue.GetUnit() ||
eCSSUnit_Unset == xValue.GetUnit()) { // both are inherit, initial or unset
eCSSUnit_Unset == xValue.GetUnit() ||
eCSSUnit_Revert == xValue.GetUnit()) { // both are inherit, initial, unset, or revert
yValue = xValue;
return true;
}
@ -13557,7 +13603,7 @@ bool
CSSParserImpl::ParseImageLayerSize(nsCSSPropertyID aPropID)
{
nsCSSValue value;
// 'initial', 'inherit' and 'unset' stand alone, no list permitted.
// 'initial', 'inherit', 'unset', and 'revert' stand alone, no list permitted.
if (!ParseSingleTokenVariant(value, VARIANT_INHERIT, nullptr)) {
nsCSSValuePair valuePair;
if (!ParseImageLayerSizeValues(valuePair)) {
@ -13585,8 +13631,8 @@ CSSParserImpl::ParseImageLayerSize(nsCSSPropertyID aPropID)
* Parses two values that correspond to lengths for the background-size
* property. These can be one or two lengths (or the 'auto' keyword) or
* percentages corresponding to the element's dimensions or the single keywords
* 'contain' or 'cover'. 'initial', 'inherit' and 'unset' must be handled by
* the caller if desired.
* 'contain' or 'cover'. 'initial', 'inherit', 'unset', and 'revert' must be
* handled by the caller if desired.
*
* @param aOut The nsCSSValuePair in which to place the result.
* @return Whether or not the operation succeeded.
@ -13684,8 +13730,8 @@ CSSParserImpl::ParseBorderImageSlice(bool aAcceptsInherit,
if (aAcceptsInherit &&
ParseSingleTokenVariant(value, VARIANT_INHERIT, nullptr)) {
// Keywords "inherit", "initial" and "unset" can not be mixed, so we
// are done.
// Keywords "inherit", "initial", "unset", and "revert" can not be
// mixed, so we are done.
AppendValue(eCSSProperty_border_image_slice, value);
return true;
}
@ -13735,8 +13781,8 @@ CSSParserImpl::ParseBorderImageWidth(bool aAcceptsInherit)
if (aAcceptsInherit &&
ParseSingleTokenVariant(value, VARIANT_INHERIT, nullptr)) {
// Keywords "inherit", "initial" and "unset" can not be mixed, so we
// are done.
// Keywords "inherit", "initial", "unset", and "revert" can not be
// mixed, so we are done.
AppendValue(eCSSProperty_border_image_width, value);
return true;
}
@ -13758,8 +13804,8 @@ CSSParserImpl::ParseBorderImageOutset(bool aAcceptsInherit)
if (aAcceptsInherit &&
ParseSingleTokenVariant(value, VARIANT_INHERIT, nullptr)) {
// Keywords "inherit", "initial" and "unset" can not be mixed, so we
// are done.
// Keywords "inherit", "initial", "unset", and "revert" can not be
// mixed, so we are done.
AppendValue(eCSSProperty_border_image_outset, value);
return true;
}
@ -13779,8 +13825,8 @@ CSSParserImpl::ParseBorderImageRepeat(bool aAcceptsInherit)
nsCSSValue value;
if (aAcceptsInherit &&
ParseSingleTokenVariant(value, VARIANT_INHERIT, nullptr)) {
// Keywords "inherit", "initial" and "unset" can not be mixed, so we
// are done.
// Keywords "inherit", "initial", "unset", and "revert" can not be
// mixed, so we are done.
AppendValue(eCSSProperty_border_image_repeat, value);
return true;
}
@ -13819,7 +13865,8 @@ CSSParserImpl::ParseBorderImage()
AppendValue(eCSSProperty_border_image_width, value);
AppendValue(eCSSProperty_border_image_outset, value);
AppendValue(eCSSProperty_border_image_repeat, value);
// Keywords "inherit", "initial" and "unset" can't be mixed, so we are done.
// Keywords "inherit", "initial", "unset", and "revert" can not be
// mixed, so we are done.
return true;
}
@ -13973,8 +14020,9 @@ CSSParserImpl::ParseBorderSide(const nsCSSPropertyID aPropIDs[],
case eCSSUnit_Inherit:
case eCSSUnit_Initial:
case eCSSUnit_Unset:
case eCSSUnit_Revert:
extraValue = values[0];
// Set value of border-image properties to initial/inherit/unset
// Set value of border-image properties to initial/inherit/unset/revert
AppendValue(eCSSProperty_border_image_source, extraValue);
AppendValue(eCSSProperty_border_image_slice, extraValue);
AppendValue(eCSSProperty_border_image_width, extraValue);
@ -14015,7 +14063,8 @@ bool
CSSParserImpl::ParseBorderColors(nsCSSPropertyID aProperty)
{
nsCSSValue value;
// 'inherit', 'initial', 'unset' and 'none' are only allowed on their own
// 'inherit', 'initial', 'unset', 'revert', and 'none' are only allowed
// on their own
if (!ParseSingleTokenVariant(value, VARIANT_INHERIT | VARIANT_NONE,
nullptr)) {
nsCSSValueList *cur = value.SetListValue();
@ -14402,8 +14451,8 @@ CSSParserImpl::ParseContent()
"content keyword tables out of sync");
nsCSSValue value;
// 'inherit', 'initial', 'unset', 'normal', 'none', and 'alt-content' must
// be alone
// 'inherit', 'initial', 'unset', 'revert', 'normal', 'none', and
// 'alt-content' must be alone
if (!ParseSingleTokenVariant(value, VARIANT_HMK | VARIANT_NONE,
kContentSolitaryKWs)) {
nsCSSValueList* cur = value.SetListValue();
@ -14473,7 +14522,7 @@ bool
CSSParserImpl::ParseCursor()
{
nsCSSValue value;
// 'inherit', 'initial' and 'unset' must be alone
// 'inherit', 'initial', 'unset', and 'revert' must be alone
if (!ParseSingleTokenVariant(value, VARIANT_INHERIT, nullptr)) {
nsCSSValueList* cur = value.SetListValue();
for (;;) {
@ -14517,7 +14566,8 @@ CSSParserImpl::ParseFont()
if (ParseSingleTokenVariant(family, VARIANT_HK, nsCSSProps::kFontKTable)) {
if (eCSSUnit_Inherit == family.GetUnit() ||
eCSSUnit_Initial == family.GetUnit() ||
eCSSUnit_Unset == family.GetUnit()) {
eCSSUnit_Unset == family.GetUnit() ||
eCSSUnit_Revert == family.GetUnit()) {
AppendValue(eCSSProperty__x_system_font, nsCSSValue(eCSSUnit_None));
AppendValue(eCSSProperty_font_family, family);
AppendValue(eCSSProperty_font_style, family);
@ -14585,7 +14635,8 @@ CSSParserImpl::ParseFont()
if (found < 0 ||
eCSSUnit_Inherit == values[kFontStyleIndex].GetUnit() ||
eCSSUnit_Initial == values[kFontStyleIndex].GetUnit() ||
eCSSUnit_Unset == values[kFontStyleIndex].GetUnit()) { // illegal data
eCSSUnit_Unset == values[kFontStyleIndex].GetUnit() ||
eCSSUnit_Revert == values[kFontStyleIndex].GetUnit() ) { // illegal data
return false;
}
if ((found & (1 << kFontStyleIndex)) == 0) {
@ -14643,7 +14694,8 @@ CSSParserImpl::ParseFont()
if (ParseFamily(family)) {
if (eCSSUnit_Inherit != family.GetUnit() &&
eCSSUnit_Initial != family.GetUnit() &&
eCSSUnit_Unset != family.GetUnit()) {
eCSSUnit_Unset != family.GetUnit() &&
eCSSUnit_Revert != family.GetUnit()) {
AppendValue(eCSSProperty__x_system_font, nsCSSValue(eCSSUnit_None));
AppendValue(eCSSProperty_font_family, family);
AppendValue(eCSSProperty_font_style, values[kFontStyleIndex]);
@ -14688,7 +14740,8 @@ CSSParserImpl::ParseFontSynthesis(nsCSSValue& aValue)
if (eCSSUnit_None == aValue.GetUnit() ||
eCSSUnit_Initial == aValue.GetUnit() ||
eCSSUnit_Inherit == aValue.GetUnit() ||
eCSSUnit_Unset == aValue.GetUnit())
eCSSUnit_Unset == aValue.GetUnit() ||
eCSSUnit_Revert == aValue.GetUnit() )
{
return true;
}
@ -15308,6 +15361,9 @@ CSSParserImpl::ParseFamily(nsCSSValue& aValue)
return true;
}
break;
case eCSSKeyword_revert:
aValue.SetRevertValue(mLevel);
return true;
case eCSSKeyword__moz_use_system_font:
if (!IsParsingCompoundProperty()) {
aValue.SetSystemFontValue();
@ -15341,6 +15397,7 @@ CSSParserImpl::ParseFamily(nsCSSValue& aValue)
case eCSSKeyword_inherit:
case eCSSKeyword_initial:
case eCSSKeyword_default:
case eCSSKeyword_revert:
case eCSSKeyword__moz_use_system_font:
return false;
case eCSSKeyword_unset:
@ -15790,25 +15847,41 @@ CSSParserImpl::ParseOutline()
bool
CSSParserImpl::ParseOverflow()
{
nsCSSValue overflow;
if (!ParseSingleTokenVariant(overflow, VARIANT_HK,
nsCSSProps::kOverflowKTable)) {
nsCSSValue overflowX, overflowY;
// Parse the first value
if (!ParseSingleTokenVariant(overflowX, VARIANT_HK, nsCSSProps::kOverflowKTable)) {
return false;
}
nsCSSValue overflowX(overflow);
nsCSSValue overflowY(overflow);
if (eCSSUnit_Enumerated == overflow.GetUnit())
switch(overflow.GetIntValue()) {
case NS_STYLE_OVERFLOW_SCROLLBARS_HORIZONTAL:
overflowX.SetIntValue(NS_STYLE_OVERFLOW_SCROLL, eCSSUnit_Enumerated);
overflowY.SetIntValue(NS_STYLE_OVERFLOW_HIDDEN, eCSSUnit_Enumerated);
break;
case NS_STYLE_OVERFLOW_SCROLLBARS_VERTICAL:
overflowX.SetIntValue(NS_STYLE_OVERFLOW_HIDDEN, eCSSUnit_Enumerated);
overflowY.SetIntValue(NS_STYLE_OVERFLOW_SCROLL, eCSSUnit_Enumerated);
break;
// Try to parse a second value (optional)
bool haveSecond = ParseSingleTokenVariant(overflowY, VARIANT_HK, nsCSSProps::kOverflowKTable);
if (!haveSecond) {
overflowY = overflowX;
}
// Handle legacy scrollbars keywords for each axis
auto fix_legacy = [](nsCSSValue& v, bool isX) {
if (v.GetUnit() == eCSSUnit_Enumerated) {
switch (v.GetIntValue()) {
case NS_STYLE_OVERFLOW_SCROLLBARS_HORIZONTAL:
if (isX) {
v.SetIntValue(NS_STYLE_OVERFLOW_SCROLL, eCSSUnit_Enumerated);
} else {
v.SetIntValue(NS_STYLE_OVERFLOW_HIDDEN, eCSSUnit_Enumerated);
}
break;
case NS_STYLE_OVERFLOW_SCROLLBARS_VERTICAL:
if (isX) {
v.SetIntValue(NS_STYLE_OVERFLOW_HIDDEN, eCSSUnit_Enumerated);
} else {
v.SetIntValue(NS_STYLE_OVERFLOW_SCROLL, eCSSUnit_Enumerated);
}
break;
}
}
};
fix_legacy(overflowX, true);
fix_legacy(overflowY, false);
AppendValue(eCSSProperty_overflow_x, overflowX);
AppendValue(eCSSProperty_overflow_y, overflowY);
return true;
@ -16013,7 +16086,7 @@ bool
CSSParserImpl::ParseTextAlign(nsCSSValue& aValue, const KTableEntry aTable[])
{
if (ParseSingleTokenVariant(aValue, VARIANT_INHERIT, nullptr)) {
// 'inherit', 'initial' and 'unset' must be alone
// 'inherit', 'initial', 'unset', and 'revert' must be alone
return true;
}
@ -16108,7 +16181,7 @@ bool
CSSParserImpl::ParseTextOverflow(nsCSSValue& aValue)
{
if (ParseSingleTokenVariant(aValue, VARIANT_INHERIT, nullptr)) {
// 'inherit', 'initial' and 'unset' must be alone
// 'inherit', 'initial', 'unset', and 'revert' must be alone
return true;
}
@ -16139,7 +16212,7 @@ CSSParserImpl::ParseTouchAction(nsCSSValue& aValue)
}
// Auto and None keywords aren't allowed in conjunction with others.
// Also inherit, initial and unset values are available.
// Also inherit, initial, unset, and revert values are available.
if (eCSSUnit_Enumerated != aValue.GetUnit()) {
return true;
}
@ -16644,7 +16717,7 @@ bool
CSSParserImpl::ParseTransform(bool aIsPrefixed, bool aDisallowRelativeValues)
{
nsCSSValue value;
// 'inherit', 'initial', 'unset' and 'none' must be alone
// 'inherit', 'initial', 'unset', 'revert', and 'none' must be alone
if (!ParseSingleTokenVariant(value, VARIANT_INHERIT | VARIANT_NONE,
nullptr)) {
nsCSSValueSharedList* list = new nsCSSValueSharedList;
@ -16930,7 +17003,8 @@ bool
CSSParserImpl::ParseShapeOutside(nsCSSValue& aValue)
{
if (ParseSingleTokenVariant(aValue, VARIANT_HUO, nullptr)) {
// 'inherit', 'initial', 'unset', 'none', and <image> url must be alone.
// 'inherit', 'initial', 'unset', 'revert', 'none', and
// <image> url must be alone.
return true;
}
@ -16954,9 +17028,10 @@ bool CSSParserImpl::ParseTransformOrigin(bool aPerspective)
// a pair, and to keep the computation code simple.
if (position.mXValue.GetUnit() == eCSSUnit_Inherit ||
position.mXValue.GetUnit() == eCSSUnit_Initial ||
position.mXValue.GetUnit() == eCSSUnit_Unset) {
position.mXValue.GetUnit() == eCSSUnit_Unset ||
position.mXValue.GetUnit() == eCSSUnit_Revert) {
MOZ_ASSERT(position.mXValue == position.mYValue,
"inherit/initial/unset only half?");
"inherit/initial/unset/revert only half?");
AppendValue(prop, position.mXValue);
} else {
nsCSSValue value;
@ -17133,7 +17208,7 @@ bool
CSSParserImpl::ParseFilter()
{
nsCSSValue value;
// 'inherit', 'initial', 'unset' and 'none' must be alone
// 'inherit', 'initial', 'unset', 'revert', and 'none' must be alone
if (!ParseSingleTokenVariant(value, VARIANT_INHERIT | VARIANT_NONE,
nullptr)) {
nsCSSValueList* cur = value.SetListValue();
@ -17162,7 +17237,7 @@ bool
CSSParserImpl::ParseTransitionProperty()
{
nsCSSValue value;
// 'inherit', 'initial', 'unset' and 'none' must be alone
// 'inherit', 'initial', 'unset', 'revert', and 'none' must be alone
if (!ParseSingleTokenVariant(value, VARIANT_INHERIT | VARIANT_NONE,
nullptr)) {
// Accept a list of arbitrary identifiers. They should be
@ -17178,13 +17253,14 @@ CSSParserImpl::ParseTransitionProperty()
}
if (cur->mValue.GetUnit() == eCSSUnit_Ident) {
nsDependentString str(cur->mValue.GetStringBufferValue());
// Exclude 'none', 'inherit', 'initial' and 'unset' according to the
// same rules as for 'counter-reset' in CSS 2.1.
// Exclude 'none', 'inherit', 'initial', 'unset', and 'revert'
// according to the same rules as for 'counter-reset' in CSS 2.1.
if (str.LowerCaseEqualsLiteral("none") ||
str.LowerCaseEqualsLiteral("inherit") ||
str.LowerCaseEqualsLiteral("initial") ||
(str.LowerCaseEqualsLiteral("unset") &&
nsLayoutUtils::UnsetValueEnabled())) {
nsLayoutUtils::UnsetValueEnabled()) ||
str.LowerCaseEqualsLiteral("revert")) {
return false;
}
}
@ -17325,9 +17401,9 @@ CSSParserImpl::ParseAnimationOrTransitionShorthand(
size_t aNumProperties)
{
nsCSSValue tempValue;
// first see if 'inherit', 'initial' or 'unset' is specified. If one is,
// it can be the only thing specified, so don't attempt to parse any
// additional properties
// first see if 'inherit', 'initial', 'unset', or 'revert' is specified.
// If one is, it can be the only thing specified, so don't attempt to
// parse any additional properties
if (ParseSingleTokenVariant(tempValue, VARIANT_INHERIT, nullptr)) {
for (uint32_t i = 0; i < aNumProperties; ++i) {
AppendValue(aProperties[i], tempValue);
@ -17452,7 +17528,7 @@ CSSParserImpl::ParseTransition()
// Make two checks on the list for 'transition-property':
// + If there is more than one item, then none of the items can be
// 'none'.
// + None of the items can be 'inherit', 'initial' or 'unset'.
// + None of the items can be 'inherit', 'initial', 'unset', or 'revert'.
{
MOZ_ASSERT(kTransitionProperties[3] == eCSSProperty_transition_property,
"array index mismatch");
@ -17475,7 +17551,8 @@ CSSParserImpl::ParseTransition()
if (str.EqualsLiteral("inherit") ||
str.EqualsLiteral("initial") ||
(str.EqualsLiteral("unset") &&
nsLayoutUtils::UnsetValueEnabled())) {
nsLayoutUtils::UnsetValueEnabled()) ||
str.EqualsLiteral("revert")) {
return false;
}
}
@ -17644,7 +17721,7 @@ CSSParserImpl::ParseShadowList(nsCSSPropertyID aProperty)
bool isBoxShadow = aProperty == eCSSProperty_box_shadow;
nsCSSValue value;
// 'inherit', 'initial', 'unset' and 'none' must be alone
// 'inherit', 'initial', 'unset', 'revert', and 'none' must be alone
if (!ParseSingleTokenVariant(value, VARIANT_INHERIT | VARIANT_NONE,
nullptr)) {
nsCSSValueList* cur = value.SetListValue();
@ -17731,7 +17808,8 @@ CSSParserImpl::ParseDasharray()
{
nsCSSValue value;
// 'inherit', 'initial', 'unset' and 'none' are only allowed on their own
// 'inherit', 'initial', 'unset', 'revert' and 'none' are only allowed
// on their own
if (!ParseSingleTokenVariant(value, VARIANT_INHERIT | VARIANT_NONE |
VARIANT_OPENTYPE_SVG_KEYWORD,
nsCSSProps::kStrokeContextValueKTable)) {
@ -18095,8 +18173,8 @@ CSSParserImpl::ParseValueWithVariables(CSSVariableDeclarations::Type* aType,
}
}
// Look for 'initial', 'inherit' or 'unset' as the first non-white space
// token.
// Look for 'initial', 'inherit', 'unset', or 'revert' as the first
// non-white space token.
CSSVariableDeclarations::Type type = CSSVariableDeclarations::eTokenStream;
if (mToken.mType == eCSSToken_Ident) {
if (mToken.mIdent.LowerCaseEqualsLiteral("initial")) {
@ -18105,6 +18183,8 @@ CSSParserImpl::ParseValueWithVariables(CSSVariableDeclarations::Type* aType,
type = CSSVariableDeclarations::eInherit;
} else if (mToken.mIdent.LowerCaseEqualsLiteral("unset")) {
type = CSSVariableDeclarations::eUnset;
} else if (mToken.mIdent.LowerCaseEqualsLiteral("revert")) {
type = CSSVariableDeclarations::eRevert;
}
}

View file

@ -4391,9 +4391,9 @@ CSS_PROP_USERINTERFACE(
CSS_PROP_NO_OFFSET,
eStyleAnimType_Discrete) // XXX bug 3935
CSS_PROP_UIRESET(
-moz-user-select,
user-select,
user_select,
CSS_PROP_DOMPROP_PREFIXED(UserSelect),
UserSelect,
CSS_PROPERTY_PARSE_VALUE,
"",
VARIANT_HK,

View file

@ -54,3 +54,4 @@ CSS_PROP_LOGICAL_GROUP_BOX(Offset)
CSS_PROP_LOGICAL_GROUP_SHORTHAND(Padding)
CSS_PROP_LOGICAL_GROUP_AXIS(MinSize)
CSS_PROP_LOGICAL_GROUP_AXIS(Size)
CSS_PROP_LOGICAL_GROUP_AXIS(Overflow)

View file

@ -2216,6 +2216,7 @@ const KTableEntry nsCSSProps::kUserSelectKTable[] = {
{ eCSSKeyword_auto, StyleUserSelect::Auto },
{ eCSSKeyword_text, StyleUserSelect::Text },
{ eCSSKeyword_element, StyleUserSelect::Element },
{ eCSSKeyword_contain, StyleUserSelect::Contain },
{ eCSSKeyword_elements, StyleUserSelect::Elements },
{ eCSSKeyword_all, StyleUserSelect::All },
{ eCSSKeyword_toggle, StyleUserSelect::Toggle },
@ -3180,6 +3181,13 @@ static const nsCSSPropertyID gSizeLogicalGroupTable[] = {
eCSSProperty_UNKNOWN
};
static const nsCSSPropertyID gOverflowLogicalGroupTable[] = {
eCSSProperty_overflow_y,
eCSSProperty_overflow_x,
eCSSProperty_UNKNOWN
};
const nsCSSPropertyID* const
nsCSSProps::kLogicalGroupTable[eCSSPropertyLogicalGroup_COUNT] = {
#define CSS_PROP_LOGICAL_GROUP_SHORTHAND(id_) g##id_##SubpropTable,

View file

@ -44,7 +44,7 @@
// 'inherit' and 'initial'
#define VARIANT_OPACITY 0x008000 // Take floats and percents as input, output float.
#define VARIANT_AUTO 0x010000 // A
#define VARIANT_INHERIT 0x020000 // H eCSSUnit_Initial, eCSSUnit_Inherit, eCSSUnit_Unset
#define VARIANT_INHERIT 0x020000 // H eCSSUnit_Initial, eCSSUnit_Inherit, eCSSUnit_Unset, eCSSUnit_Revert
#define VARIANT_NONE 0x040000 // O
#define VARIANT_NORMAL 0x080000 // M
#define VARIANT_SYSFONT 0x100000 // eCSSUnit_System_Font

View file

@ -166,6 +166,9 @@ nsCSSValue::nsCSSValue(const nsCSSValue& aCopy)
mValue.mComplexColor = aCopy.mValue.mComplexColor;
mValue.mComplexColor->AddRef();
}
else if (eCSSUnit_Revert == mUnit) {
mValue.mCascadeOrigin = aCopy.mValue.mCascadeOrigin;
}
else if (UnitHasArrayValue()) {
mValue.mArray = aCopy.mValue.mArray;
mValue.mArray->AddRef();
@ -279,6 +282,9 @@ bool nsCSSValue::operator==(const nsCSSValue& aOther) const
else if (eCSSUnit_ComplexColor == mUnit) {
return *mValue.mComplexColor == *aOther.mValue.mComplexColor;
}
else if (eCSSUnit_Revert == mUnit) {
return mValue.mCascadeOrigin == aOther.mValue.mCascadeOrigin;
}
else if (UnitHasArrayValue()) {
return *mValue.mArray == *aOther.mValue.mArray;
}
@ -539,6 +545,15 @@ nsCSSValue::SetComplexColorValue(already_AddRefed<ComplexColorValue> aValue)
mValue.mComplexColor = aValue.take();
}
void
nsCSSValue::SetCascadeOriginValue(mozilla::SheetType aValue, nsCSSUnit aUnit)
{
MOZ_ASSERT(aUnit == eCSSUnit_Revert, "bad unit");
Reset();
mUnit = aUnit;
mValue.mCascadeOrigin = aValue;
}
void nsCSSValue::SetArrayValue(nsCSSValue::Array* aValue, nsCSSUnit aUnit)
{
Reset();
@ -598,7 +613,7 @@ void nsCSSValue::SetFontFamilyListValue(css::FontFamilyListRefCnt* aValue)
void nsCSSValue::SetPairValue(const nsCSSValuePair* aValue)
{
// pairs should not be used for null/inherit/initial values
// pairs should not be used for null/inherit/initial/unset/revert values
MOZ_ASSERT(aValue &&
aValue->mXValue.GetUnit() != eCSSUnit_Null &&
aValue->mYValue.GetUnit() != eCSSUnit_Null &&
@ -607,7 +622,9 @@ void nsCSSValue::SetPairValue(const nsCSSValuePair* aValue)
aValue->mXValue.GetUnit() != eCSSUnit_Initial &&
aValue->mYValue.GetUnit() != eCSSUnit_Initial &&
aValue->mXValue.GetUnit() != eCSSUnit_Unset &&
aValue->mYValue.GetUnit() != eCSSUnit_Unset,
aValue->mYValue.GetUnit() != eCSSUnit_Unset &&
aValue->mXValue.GetUnit() != eCSSUnit_Revert &&
aValue->mYValue.GetUnit() != eCSSUnit_Revert,
"missing or inappropriate pair value");
Reset();
mUnit = eCSSUnit_Pair;
@ -625,7 +642,9 @@ void nsCSSValue::SetPairValue(const nsCSSValue& xValue,
xValue.GetUnit() != eCSSUnit_Initial &&
yValue.GetUnit() != eCSSUnit_Initial &&
xValue.GetUnit() != eCSSUnit_Unset &&
yValue.GetUnit() != eCSSUnit_Unset,
yValue.GetUnit() != eCSSUnit_Unset &&
xValue.GetUnit() != eCSSUnit_Revert &&
yValue.GetUnit() != eCSSUnit_Revert,
"inappropriate pair value");
Reset();
mUnit = eCSSUnit_Pair;
@ -635,7 +654,7 @@ void nsCSSValue::SetPairValue(const nsCSSValue& xValue,
void nsCSSValue::SetTripletValue(const nsCSSValueTriplet* aValue)
{
// triplet should not be used for null/inherit/initial values
// triplet should not be used for null/inherit/initial/unset/revert values
MOZ_ASSERT(aValue &&
aValue->mXValue.GetUnit() != eCSSUnit_Null &&
aValue->mYValue.GetUnit() != eCSSUnit_Null &&
@ -648,7 +667,10 @@ void nsCSSValue::SetTripletValue(const nsCSSValueTriplet* aValue)
aValue->mZValue.GetUnit() != eCSSUnit_Initial &&
aValue->mXValue.GetUnit() != eCSSUnit_Unset &&
aValue->mYValue.GetUnit() != eCSSUnit_Unset &&
aValue->mZValue.GetUnit() != eCSSUnit_Unset,
aValue->mZValue.GetUnit() != eCSSUnit_Unset &&
aValue->mXValue.GetUnit() != eCSSUnit_Revert &&
aValue->mYValue.GetUnit() != eCSSUnit_Revert &&
aValue->mZValue.GetUnit() != eCSSUnit_Revert,
"missing or inappropriate triplet value");
Reset();
mUnit = eCSSUnit_Triplet;
@ -671,7 +693,10 @@ void nsCSSValue::SetTripletValue(const nsCSSValue& xValue,
zValue.GetUnit() != eCSSUnit_Initial &&
xValue.GetUnit() != eCSSUnit_Unset &&
yValue.GetUnit() != eCSSUnit_Unset &&
zValue.GetUnit() != eCSSUnit_Unset,
zValue.GetUnit() != eCSSUnit_Unset &&
xValue.GetUnit() != eCSSUnit_Revert &&
yValue.GetUnit() != eCSSUnit_Revert &&
zValue.GetUnit() != eCSSUnit_Revert,
"inappropriate triplet value");
Reset();
mUnit = eCSSUnit_Triplet;
@ -781,6 +806,12 @@ void nsCSSValue::SetUnsetValue()
mUnit = eCSSUnit_Unset;
}
void
nsCSSValue::SetRevertValue(mozilla::SheetType aValue)
{
SetCascadeOriginValue(aValue, eCSSUnit_Revert);
}
void nsCSSValue::SetNoneValue()
{
Reset();
@ -1930,6 +1961,7 @@ nsCSSValue::AppendToString(nsCSSPropertyID aProperty, nsAString& aResult,
case eCSSUnit_Inherit: aResult.AppendLiteral("inherit"); break;
case eCSSUnit_Initial: aResult.AppendLiteral("initial"); break;
case eCSSUnit_Unset: aResult.AppendLiteral("unset"); break;
case eCSSUnit_Revert: aResult.AppendLiteral("revert"); break;
case eCSSUnit_None: aResult.AppendLiteral("none"); break;
case eCSSUnit_Normal: aResult.AppendLiteral("normal"); break;
case eCSSUnit_System_Font: aResult.AppendLiteral("-moz-use-system-font"); break;
@ -2189,6 +2221,10 @@ nsCSSValue::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
n += mValue.mComplexColor->SizeOfIncludingThis(aMallocSizeOf);
break;
// Cascade Origin: nothing extra to measure.
case eCSSUnit_Revert:
break;
// Float: nothing extra to measure.
case eCSSUnit_Percent:
case eCSSUnit_Number:
@ -2511,7 +2547,8 @@ nsCSSRect::AppendToString(nsCSSPropertyID aProperty, nsAString& aResult,
MOZ_ASSERT(mTop.GetUnit() != eCSSUnit_Null &&
mTop.GetUnit() != eCSSUnit_Inherit &&
mTop.GetUnit() != eCSSUnit_Initial &&
mTop.GetUnit() != eCSSUnit_Unset,
mTop.GetUnit() != eCSSUnit_Unset &&
mTop.GetUnit() != eCSSUnit_Revert,
"parser should have used a bare value");
if (eCSSProperty_border_image_slice == aProperty ||
@ -2681,6 +2718,7 @@ nsCSSValuePairList::AppendToString(nsCSSPropertyID aProperty,
if (item->mXValue.GetUnit() != eCSSUnit_Inherit &&
item->mXValue.GetUnit() != eCSSUnit_Initial &&
item->mXValue.GetUnit() != eCSSUnit_Unset &&
item->mXValue.GetUnit() != eCSSUnit_Revert &&
item->mYValue.GetUnit() != eCSSUnit_Null) {
aResult.Append(char16_t(' '));
item->mYValue.AppendToString(aProperty, aResult, aSerialization);

View file

@ -484,6 +484,7 @@ enum nsCSSUnit {
eCSSUnit_TokenStream = 43, // (nsCSSValueTokenStream*) value
eCSSUnit_GridTemplateAreas = 44, // (GridTemplateAreasValue*)
// for grid-template-areas
eCSSUnit_Revert = 45, // (SheetType) value is the current cascade origin
eCSSUnit_Pair = 50, // (nsCSSValuePair*) pair of values
eCSSUnit_Triplet = 51, // (nsCSSValueTriplet*) triplet of values
@ -911,6 +912,12 @@ public:
return mValue.mFloatColor;
}
mozilla::SheetType GetCascadeOriginValue() const
{
MOZ_ASSERT(mUnit == eCSSUnit_Revert, "not a cascade origin value");
return mValue.mCascadeOrigin;
}
void Reset() // sets to null
{
if (mUnit != eCSSUnit_Null)
@ -943,6 +950,7 @@ public:
void SetRGBAColorValue(const mozilla::css::RGBAColorData& aValue);
void SetComplexColorValue(
already_AddRefed<mozilla::css::ComplexColorValue> aValue);
void SetCascadeOriginValue(mozilla::SheetType aValue, nsCSSUnit aUnit);
void SetArrayValue(nsCSSValue::Array* aArray, nsCSSUnit aUnit);
void SetURLValue(mozilla::css::URLValue* aURI);
void SetImageValue(mozilla::css::ImageValue* aImage);
@ -961,6 +969,7 @@ public:
void SetInheritValue();
void SetInitialValue();
void SetUnsetValue();
void SetRevertValue(mozilla::SheetType aValue);
void SetNoneValue();
void SetAllValue();
void SetNormalValue();
@ -1054,6 +1063,7 @@ protected:
nsCSSValueFloatColor* MOZ_OWNING_REF mFloatColor;
mozilla::css::FontFamilyListRefCnt* MOZ_OWNING_REF mFontFamilyList;
mozilla::css::ComplexColorValue* MOZ_OWNING_REF mComplexColor;
mozilla::SheetType mCascadeOrigin;
} mValue;
};

View file

@ -4750,15 +4750,26 @@ nsComputedDOMStyle::DoGetOverflow()
{
const nsStyleDisplay* display = StyleDisplay();
if (display->mOverflowX != display->mOverflowY) {
// No value to return. We can't express this combination of
// values as a shorthand.
return nullptr;
if (display->mOverflowX == display->mOverflowY) {
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
val->SetIdent(nsCSSProps::ValueToKeywordEnum(display->mOverflowX,
nsCSSProps::kOverflowKTable));
return val.forget();
}
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
val->SetIdent(nsCSSProps::ValueToKeywordEnum(display->mOverflowX,
nsCSSProps::kOverflowKTable));
nsAutoString result;
nsCSSKeyword xKeyword = nsCSSProps::ValueToKeywordEnum(display->mOverflowX,
nsCSSProps::kOverflowKTable);
nsCSSKeyword yKeyword = nsCSSProps::ValueToKeywordEnum(display->mOverflowY,
nsCSSProps::kOverflowKTable);
result.AppendASCII(nsCSSKeywords::GetStringValue(xKeyword).get());
result.Append(char16_t(' '));
result.AppendASCII(nsCSSKeywords::GetStringValue(yKeyword).get());
val->SetString(result);
return val.forget();
}

View file

@ -46,9 +46,11 @@ nsHTMLStyleSheet::HTMLColorRule::MapRuleInfoInto(nsRuleData* aRuleData)
{
if (aRuleData->mSIDs & NS_STYLE_INHERIT_BIT(Color)) {
nsCSSValue* color = aRuleData->ValueForColor();
if (color->GetUnit() == eCSSUnit_Null &&
aRuleData->mPresContext->UseDocumentColors())
if ((color->GetUnit() == eCSSUnit_Null ||
color->GetUnit() == eCSSUnit_Revert) &&
aRuleData->mPresContext->UseDocumentColors()) {
color->SetColorValue(mColor);
}
}
}
@ -98,7 +100,8 @@ nsHTMLStyleSheet::TableTHRule::MapRuleInfoInto(nsRuleData* aRuleData)
{
if (aRuleData->mSIDs & NS_STYLE_INHERIT_BIT(Text)) {
nsCSSValue* textAlign = aRuleData->ValueForTextAlign();
if (textAlign->GetUnit() == eCSSUnit_Null) {
if (textAlign->GetUnit() == eCSSUnit_Null ||
textAlign->GetUnit() == eCSSUnit_Revert) {
textAlign->SetIntValue(NS_STYLE_TEXT_ALIGN_MOZ_CENTER_OR_INHERIT,
eCSSUnit_Enumerated);
}
@ -126,9 +129,11 @@ nsHTMLStyleSheet::TableQuirkColorRule::MapRuleInfoInto(nsRuleData* aRuleData)
nsCSSValue* color = aRuleData->ValueForColor();
// We do not check UseDocumentColors() here, because we want to
// use the body color no matter what.
if (color->GetUnit() == eCSSUnit_Null)
if (color->GetUnit() == eCSSUnit_Null ||
color->GetUnit() == eCSSUnit_Revert) {
color->SetIntValue(NS_STYLE_COLOR_INHERIT_FROM_BODY,
eCSSUnit_Enumerated);
}
}
}
@ -153,7 +158,8 @@ nsHTMLStyleSheet::LangRule::MapRuleInfoInto(nsRuleData* aRuleData)
{
if (aRuleData->mSIDs & NS_STYLE_INHERIT_BIT(Font)) {
nsCSSValue* lang = aRuleData->ValueForLang();
if (lang->GetUnit() == eCSSUnit_Null) {
if (lang->GetUnit() == eCSSUnit_Null ||
lang->GetUnit() == eCSSUnit_Revert) {
lang->SetStringValue(mLang, eCSSUnit_Ident);
}
}

File diff suppressed because it is too large Load diff

View file

@ -787,7 +787,8 @@ protected:
nsStyleFont* aFont);
inline RuleDetail CheckSpecifiedProperties(const nsStyleStructID aSID,
const nsRuleData* aRuleData);
const nsRuleData* aRuleData,
bool& ignoreRuleCache);
private:
nsRuleNode(nsPresContext* aPresContext, nsRuleNode* aParent,

View file

@ -186,6 +186,7 @@ enum class StyleUserSelect : uint8_t {
None,
Text,
Element,
Contain,
Elements,
All,
Toggle,

View file

@ -720,12 +720,12 @@ canvas {
/* hidden elements */
base, basefont, datalist, head, meta, script, style, title,
noembed, param, template {
display: none !important;
display: none;
}
area {
/* Don't give it frames other than its imageframe */
display: none !important;
display: none ! important;
}
iframe:fullscreen {