Make generic mechanism for parsing lists of single values with ParseVariant. (Bug 636029) r=bzbarsky

This commit is contained in:
L. David Baron 2011-03-05 09:58:33 -08:00
Родитель 246f9e9c3c
Коммит 94b5a8b599
3 изменённых файлов: 22 добавлений и 90 удалений

Просмотреть файл

@ -463,7 +463,7 @@ protected:
PRBool ParseBackgroundItem(BackgroundParseState& aState);
PRBool ParseBackgroundList(nsCSSProperty aPropID); // a single value prop-id
PRBool ParseValueList(nsCSSProperty aPropID); // a single value prop-id
PRBool ParseBackgroundPosition();
PRBool ParseBoxPositionValues(nsCSSValuePair& aOut, PRBool aAcceptsInherit);
PRBool ParseBackgroundSize();
@ -515,10 +515,8 @@ protected:
PRBool ParseShadowItem(nsCSSValue& aValue, PRBool aIsBoxShadow);
PRBool ParseShadowList(nsCSSProperty aProperty);
PRBool ParseTransitionTime(nsCSSProperty aPropID);
PRBool ParseTransitionProperty();
PRBool ParseTransition();
PRBool ParseTransitionTimingFunction();
PRBool ParseTransitionTimingFunctionValues(nsCSSValue& aValue);
PRBool ParseTransitionTimingFunctionValueComponent(float& aComponent,
char aStop,
@ -5270,6 +5268,9 @@ CSSParserImpl::ParseProperty(nsCSSProperty aPropID)
// XXX Report errors?
return PR_FALSE;
}
case CSS_PROPERTY_PARSE_VALUE_LIST: {
return ParseValueList(aPropID);
}
}
NS_ABORT_IF_FALSE(PR_FALSE,
"Property's flags field in nsCSSPropList.h is missing "
@ -5285,12 +5286,6 @@ CSSParserImpl::ParsePropertyByFunction(nsCSSProperty aPropID)
return ParseBackground();
case eCSSProperty_background_position:
return ParseBackgroundPosition();
case eCSSProperty_background_attachment:
case eCSSProperty_background_clip:
case eCSSProperty_background_image:
case eCSSProperty_background_origin:
case eCSSProperty_background_repeat:
return ParseBackgroundList(aPropID);
case eCSSProperty_background_size:
return ParseBackgroundSize();
case eCSSProperty_border:
@ -5446,11 +5441,6 @@ CSSParserImpl::ParsePropertyByFunction(nsCSSProperty aPropID)
return ParseTransition();
case eCSSProperty_transition_property:
return ParseTransitionProperty();
case eCSSProperty_transition_timing_function:
return ParseTransitionTimingFunction();
case eCSSProperty_transition_duration:
case eCSSProperty_transition_delay:
return ParseTransitionTime(aPropID);
#ifdef MOZ_SVG
case eCSSProperty_fill:
@ -5934,7 +5924,7 @@ CSSParserImpl::ParseBackgroundItem(CSSParserImpl::BackgroundParseState& aState)
// This function is very similar to ParseBackgroundPosition and
// ParseBackgroundSize.
PRBool
CSSParserImpl::ParseBackgroundList(nsCSSProperty aPropID)
CSSParserImpl::ParseValueList(nsCSSProperty aPropID)
{
// aPropID is a single value prop-id
nsCSSValue value;
@ -7936,35 +7926,6 @@ CSSParserImpl::ParseTextDecoration(nsCSSValue& aValue)
}
PRBool
CSSParserImpl::ParseTransitionTime(nsCSSProperty aPropID)
{
nsCSSValue value;
if (ParseVariant(value, VARIANT_INHERIT, nsnull)) {
// 'inherit' and 'initial' must be alone
if (!ExpectEndProperty()) {
return PR_FALSE;
}
} else {
nsCSSValueList* cur = value.SetListValue();
for (;;) {
if (!ParseVariant(cur->mValue, VARIANT_TIME, nsnull)) {
return PR_FALSE;
}
if (CheckEndProperty()) {
break;
}
if (!ExpectSymbol(',', PR_TRUE)) {
return PR_FALSE;
}
cur->mNext = new nsCSSValueList;
cur = cur->mNext;
}
}
AppendValue(aPropID, value);
return PR_TRUE;
}
PRBool
CSSParserImpl::ParseTransitionProperty()
{
@ -8011,36 +7972,6 @@ CSSParserImpl::ParseTransitionProperty()
return PR_TRUE;
}
PRBool
CSSParserImpl::ParseTransitionTimingFunction()
{
nsCSSValue value;
if (ParseVariant(value, VARIANT_INHERIT, nsnull)) {
// 'inherit' and 'initial' must be alone
if (!ExpectEndProperty()) {
return PR_FALSE;
}
} else {
nsCSSValueList* cur = value.SetListValue();
for (;;) {
if (!ParseVariant(cur->mValue, VARIANT_TIMING_FUNCTION,
nsCSSProps::kTransitionTimingFunctionKTable)) {
return PR_FALSE;
}
if (CheckEndProperty()) {
break;
}
if (!ExpectSymbol(',', PR_TRUE)) {
return PR_FALSE;
}
cur->mNext = new nsCSSValueList;
cur = cur->mNext;
}
}
AppendValue(eCSSProperty_transition_timing_function, value);
return PR_TRUE;
}
PRBool
CSSParserImpl::ParseTransitionTimingFunctionValues(nsCSSValue& aValue)
{

Просмотреть файл

@ -398,12 +398,12 @@ CSS_PROP_BACKGROUND(
background-attachment,
background_attachment,
BackgroundAttachment,
CSS_PROPERTY_PARSE_FUNCTION |
CSS_PROPERTY_PARSE_VALUE_LIST |
CSS_PROPERTY_APPLIES_TO_FIRST_LETTER_AND_FIRST_LINE |
CSS_PROPERTY_VALUE_LIST_USES_COMMAS,
Color,
mBackAttachment,
VARIANT_KEYWORD, // used only internally
VARIANT_KEYWORD, // used by list parsing
kBackgroundAttachmentKTable,
CSS_PROP_NO_OFFSET,
eStyleAnimType_None)
@ -411,12 +411,12 @@ CSS_PROP_BACKGROUND(
background-clip,
background_clip,
BackgroundClip,
CSS_PROPERTY_PARSE_FUNCTION |
CSS_PROPERTY_PARSE_VALUE_LIST |
CSS_PROPERTY_APPLIES_TO_FIRST_LETTER_AND_FIRST_LINE |
CSS_PROPERTY_VALUE_LIST_USES_COMMAS,
Color,
mBackClip,
VARIANT_KEYWORD, // used only internally
VARIANT_KEYWORD, // used by list parsing
kBackgroundOriginKTable,
CSS_PROP_NO_OFFSET,
eStyleAnimType_None)
@ -437,14 +437,14 @@ CSS_PROP_BACKGROUND(
background-image,
background_image,
BackgroundImage,
CSS_PROPERTY_PARSE_FUNCTION |
CSS_PROPERTY_PARSE_VALUE_LIST |
CSS_PROPERTY_APPLIES_TO_FIRST_LETTER_AND_FIRST_LINE |
CSS_PROPERTY_VALUE_LIST_USES_COMMAS |
CSS_PROPERTY_IGNORED_WHEN_COLORS_DISABLED |
CSS_PROPERTY_START_IMAGE_LOADS,
Color,
mBackImage,
VARIANT_IMAGE, // used only internally
VARIANT_IMAGE, // used by list parsing
nsnull,
CSS_PROP_NO_OFFSET,
eStyleAnimType_None)
@ -464,12 +464,12 @@ CSS_PROP_BACKGROUND(
background-origin,
background_origin,
BackgroundOrigin,
CSS_PROPERTY_PARSE_FUNCTION |
CSS_PROPERTY_PARSE_VALUE_LIST |
CSS_PROPERTY_APPLIES_TO_FIRST_LETTER_AND_FIRST_LINE |
CSS_PROPERTY_VALUE_LIST_USES_COMMAS,
Color,
mBackOrigin,
VARIANT_KEYWORD, // used only internally
VARIANT_KEYWORD, // used by list parsing
kBackgroundOriginKTable,
CSS_PROP_NO_OFFSET,
eStyleAnimType_None)
@ -491,12 +491,12 @@ CSS_PROP_BACKGROUND(
background-repeat,
background_repeat,
BackgroundRepeat,
CSS_PROPERTY_PARSE_FUNCTION |
CSS_PROPERTY_PARSE_VALUE_LIST |
CSS_PROPERTY_APPLIES_TO_FIRST_LETTER_AND_FIRST_LINE |
CSS_PROPERTY_VALUE_LIST_USES_COMMAS,
Color,
mBackRepeat,
VARIANT_KEYWORD, // used only internally
VARIANT_KEYWORD, // used by list parsing
kBackgroundRepeatKTable,
CSS_PROP_NO_OFFSET,
eStyleAnimType_None)
@ -2570,11 +2570,11 @@ CSS_PROP_DISPLAY(
-moz-transition-delay,
transition_delay,
MozTransitionDelay,
CSS_PROPERTY_PARSE_FUNCTION |
CSS_PROPERTY_PARSE_VALUE_LIST |
CSS_PROPERTY_VALUE_LIST_USES_COMMAS,
Display,
mTransitionDelay,
0,
VARIANT_TIME, // used by list parsing
nsnull,
CSS_PROP_NO_OFFSET,
eStyleAnimType_None)
@ -2582,11 +2582,11 @@ CSS_PROP_DISPLAY(
-moz-transition-duration,
transition_duration,
MozTransitionDuration,
CSS_PROPERTY_PARSE_FUNCTION |
CSS_PROPERTY_PARSE_VALUE_LIST |
CSS_PROPERTY_VALUE_LIST_USES_COMMAS,
Display,
mTransitionDuration,
0,
VARIANT_TIME, // used by list parsing
nsnull,
CSS_PROP_NO_OFFSET,
eStyleAnimType_None)
@ -2606,11 +2606,11 @@ CSS_PROP_DISPLAY(
-moz-transition-timing-function,
transition_timing_function,
MozTransitionTimingFunction,
CSS_PROPERTY_PARSE_FUNCTION |
CSS_PROPERTY_PARSE_VALUE_LIST |
CSS_PROPERTY_VALUE_LIST_USES_COMMAS,
Display,
mTransitionTimingFunction,
0,
VARIANT_TIMING_FUNCTION, // used by list parsing
kTransitionTimingFunctionKTable,
CSS_PROP_NO_OFFSET,
eStyleAnimType_None)

Просмотреть файл

@ -101,6 +101,7 @@
#define CSS_PROPERTY_PARSE_INACCESSIBLE (1<<9)
#define CSS_PROPERTY_PARSE_FUNCTION (2<<9)
#define CSS_PROPERTY_PARSE_VALUE (3<<9)
#define CSS_PROPERTY_PARSE_VALUE_LIST (4<<9)
// See CSSParserImpl::ParseSingleValueProperty
#define CSS_PROPERTY_VALUE_PARSER_FUNCTION (1<<12)