- Revision
- 126491
- Author
- [email protected]
- Date
- 2012-08-23 15:52:30 -0700 (Thu, 23 Aug 2012)
Log Message
CSSParser: Move enumeration to a common place (StylePropertyShorthand)
https://bugs.webkit.org/show_bug.cgi?id=93210
Patch by Adenilson Cavalcanti <[email protected]> on 2012-08-23
Reviewed by Dean Jackson.
CSSParser::parseAnimationShorthand() uses an enumeration with the same
elements as another enumeration present in StylePropertyShorthand, but
with different ordering of values. This patch puts both enums in the same place.
No new tests. No change in behavior.
* css/CSSParser.cpp:
(WebCore::CSSParser::parseAnimationShorthand):
* css/StylePropertyShorthand.cpp:
(WebCore::webkitAnimationShorthandForParsing):
(WebCore):
* css/StylePropertyShorthand.h:
(WebCore):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (126490 => 126491)
--- trunk/Source/WebCore/ChangeLog 2012-08-23 22:50:26 UTC (rev 126490)
+++ trunk/Source/WebCore/ChangeLog 2012-08-23 22:52:30 UTC (rev 126491)
@@ -1,3 +1,24 @@
+2012-08-23 Adenilson Cavalcanti <[email protected]>
+
+ CSSParser: Move enumeration to a common place (StylePropertyShorthand)
+ https://bugs.webkit.org/show_bug.cgi?id=93210
+
+ Reviewed by Dean Jackson.
+
+ CSSParser::parseAnimationShorthand() uses an enumeration with the same
+ elements as another enumeration present in StylePropertyShorthand, but
+ with different ordering of values. This patch puts both enums in the same place.
+
+ No new tests. No change in behavior.
+
+ * css/CSSParser.cpp:
+ (WebCore::CSSParser::parseAnimationShorthand):
+ * css/StylePropertyShorthand.cpp:
+ (WebCore::webkitAnimationShorthandForParsing):
+ (WebCore):
+ * css/StylePropertyShorthand.h:
+ (WebCore):
+
2012-08-23 Mike West <[email protected]>
Trailing spaces in CSP source lists should not generate console warnings.
Modified: trunk/Source/WebCore/css/CSSParser.cpp (126490 => 126491)
--- trunk/Source/WebCore/css/CSSParser.cpp 2012-08-23 22:50:26 UTC (rev 126490)
+++ trunk/Source/WebCore/css/CSSParser.cpp 2012-08-23 22:52:30 UTC (rev 126491)
@@ -51,6 +51,7 @@
#include "CSSValueKeywords.h"
#include "CSSValueList.h"
#include "CSSValuePool.h"
+#include "StylePropertyShorthand.h"
#if ENABLE(CSS_VARIABLES)
#include "CSSVariableValue.h"
#endif
@@ -3074,30 +3075,13 @@
bool CSSParser::parseAnimationShorthand(bool important)
{
- // When we parse the animation shorthand we need to look for animation-name
- // last because otherwise it might match against the keywords for fill mode,
- // timing functions and infinite iteration. This means that animation names
- // that are the same as keywords (e.g. 'forwards') won't always match in the
- // shorthand. In that case they should be using longhands (or reconsidering
- // their approach). This is covered by the animations spec bug:
- // https://www.w3.org/Bugs/Public/show_bug.cgi?id=14790
- // And in the spec (editor's draft) at:
- // http://dev.w3.org/csswg/css3-animations/#animation-shorthand-property
-
- static const CSSPropertyID animationProperties[] = {
- CSSPropertyWebkitAnimationDuration,
- CSSPropertyWebkitAnimationTimingFunction,
- CSSPropertyWebkitAnimationDelay,
- CSSPropertyWebkitAnimationIterationCount,
- CSSPropertyWebkitAnimationDirection,
- CSSPropertyWebkitAnimationFillMode,
- CSSPropertyWebkitAnimationName
- };
+ const StylePropertyShorthand& animationProperties = webkitAnimationShorthandForParsing();
const unsigned numProperties = 7;
// The list of properties in the shorthand should be the same
- // length as the list we have here, even though they are
- // a different order.
+ // length as the list with animation name in last position, even though they are
+ // in a different order.
+ ASSERT(numProperties == webkitAnimationShorthandForParsing().length());
ASSERT(numProperties == webkitAnimationShorthand().length());
ShorthandScope scope(this, CSSPropertyWebkitAnimation);
@@ -3124,7 +3108,7 @@
for (i = 0; i < numProperties; ++i) {
if (!parsedProperty[i]) {
RefPtr<CSSValue> val;
- if (parseAnimationProperty(animationProperties[i], val)) {
+ if (parseAnimationProperty(animationProperties.properties()[i], val)) {
parsedProperty[i] = found = true;
addAnimationValue(values[i], val.release());
break;
@@ -3143,7 +3127,7 @@
if (!parsedProperty[i])
addAnimationValue(values[i], cssValuePool().createImplicitInitialValue());
- addProperty(animationProperties[i], values[i].release(), important);
+ addProperty(animationProperties.properties()[i], values[i].release(), important);
}
return true;
Modified: trunk/Source/WebCore/css/StylePropertyShorthand.cpp (126490 => 126491)
--- trunk/Source/WebCore/css/StylePropertyShorthand.cpp 2012-08-23 22:50:26 UTC (rev 126490)
+++ trunk/Source/WebCore/css/StylePropertyShorthand.cpp 2012-08-23 22:52:30 UTC (rev 126491)
@@ -261,6 +261,31 @@
return webkitAnimationLonghands;
}
+const StylePropertyShorthand& webkitAnimationShorthandForParsing()
+{
+ // When we parse the animation shorthand we need to look for animation-name
+ // last because otherwise it might match against the keywords for fill mode,
+ // timing functions and infinite iteration. This means that animation names
+ // that are the same as keywords (e.g. 'forwards') won't always match in the
+ // shorthand. In that case the authors should be using longhands (or
+ // reconsidering their approach). This is covered by the animations spec
+ // bug: https://www.w3.org/Bugs/Public/show_bug.cgi?id=14790
+ // And in the spec (editor's draft) at:
+ // http://dev.w3.org/csswg/css3-animations/#animation-shorthand-property
+ static const CSSPropertyID animationPropertiesForParsing[] = {
+ CSSPropertyWebkitAnimationDuration,
+ CSSPropertyWebkitAnimationTimingFunction,
+ CSSPropertyWebkitAnimationDelay,
+ CSSPropertyWebkitAnimationIterationCount,
+ CSSPropertyWebkitAnimationDirection,
+ CSSPropertyWebkitAnimationFillMode,
+ CSSPropertyWebkitAnimationName
+ };
+
+ DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitAnimationLonghandsForParsing, (animationPropertiesForParsing, WTF_ARRAY_LENGTH(animationPropertiesForParsing)));
+ return webkitAnimationLonghandsForParsing;
+}
+
const StylePropertyShorthand& webkitBorderAfterShorthand()
{
static const CSSPropertyID borderAfterProperties[] = { CSSPropertyWebkitBorderAfterWidth, CSSPropertyWebkitBorderAfterStyle, CSSPropertyWebkitBorderAfterColor };
Modified: trunk/Source/WebCore/css/StylePropertyShorthand.h (126490 => 126491)
--- trunk/Source/WebCore/css/StylePropertyShorthand.h 2012-08-23 22:50:26 UTC (rev 126490)
+++ trunk/Source/WebCore/css/StylePropertyShorthand.h 2012-08-23 22:52:30 UTC (rev 126491)
@@ -80,6 +80,7 @@
const StylePropertyShorthand& overflowShorthand();
const StylePropertyShorthand& paddingShorthand();
const StylePropertyShorthand& webkitAnimationShorthand();
+const StylePropertyShorthand& webkitAnimationShorthandForParsing();
const StylePropertyShorthand& webkitBorderAfterShorthand();
const StylePropertyShorthand& webkitBorderBeforeShorthand();
const StylePropertyShorthand& webkitBorderEndShorthand();