Title: [113273] trunk/Source/WebCore
Revision
113273
Author
[email protected]
Date
2012-04-04 18:42:05 -0700 (Wed, 04 Apr 2012)

Log Message

Replace further usage of int with CSSPropertyID.
https://bugs.webkit.org/show_bug.cgi?id=83119

Reviewed by Simon Fraser.

No new tests / no functionality changed.

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::logUnimplementedPropertyID):
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
* css/CSSGrammar.y:
* css/CSSParser.cpp:
(WebCore::CSSParser::CSSParser):
* css/CSSParser.h:
(CSSParser):
(WebCore::ShorthandScope::~ShorthandScope):
* css/CSSProperty.h:
(WebCore::CSSProperty::CSSProperty):
* css/SVGCSSComputedStyleDeclaration.cpp:
(WebCore::CSSComputedStyleDeclaration::getSVGPropertyCSSValue):
* css/StylePropertySet.h:
(StylePropertySet):
* css/makeprop.pl:
* dom/StyledElement.h:
(StyledElement):
* editing/EditingStyle.h:
(EditingStyle):
* html/HTMLElement.h:
(HTMLElement):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (113272 => 113273)


--- trunk/Source/WebCore/ChangeLog	2012-04-05 01:38:28 UTC (rev 113272)
+++ trunk/Source/WebCore/ChangeLog	2012-04-05 01:42:05 UTC (rev 113273)
@@ -1,3 +1,35 @@
+2012-04-04  Luke Macpherson  <[email protected]>
+
+        Replace further usage of int with CSSPropertyID.
+        https://bugs.webkit.org/show_bug.cgi?id=83119
+
+        Reviewed by Simon Fraser.
+
+        No new tests / no functionality changed.
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::logUnimplementedPropertyID):
+        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
+        * css/CSSGrammar.y:
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::CSSParser):
+        * css/CSSParser.h:
+        (CSSParser):
+        (WebCore::ShorthandScope::~ShorthandScope):
+        * css/CSSProperty.h:
+        (WebCore::CSSProperty::CSSProperty):
+        * css/SVGCSSComputedStyleDeclaration.cpp:
+        (WebCore::CSSComputedStyleDeclaration::getSVGPropertyCSSValue):
+        * css/StylePropertySet.h:
+        (StylePropertySet):
+        * css/makeprop.pl:
+        * dom/StyledElement.h:
+        (StyledElement):
+        * editing/EditingStyle.h:
+        (EditingStyle):
+        * html/HTMLElement.h:
+        (HTMLElement):
+
 2012-04-04  Adam Klein  <[email protected]>
 
         Use PassRefPtr in V8DOMWrapper interface to avoid explicit ref() calls

Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (113272 => 113273)


--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2012-04-05 01:38:28 UTC (rev 113272)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2012-04-05 01:42:05 UTC (rev 113273)
@@ -1247,7 +1247,7 @@
 
 static void logUnimplementedPropertyID(CSSPropertyID propertyID)
 {
-    DEFINE_STATIC_LOCAL(HashSet<int>, propertyIDSet, ());
+    DEFINE_STATIC_LOCAL(HashSet<CSSPropertyID>, propertyIDSet, ());
     if (!propertyIDSet.add(propertyID).isNewEntry)
         return;
 

Modified: trunk/Source/WebCore/css/CSSGrammar.y (113272 => 113273)


--- trunk/Source/WebCore/css/CSSGrammar.y	2012-04-05 01:38:28 UTC (rev 113272)
+++ trunk/Source/WebCore/css/CSSGrammar.y	2012-04-05 01:42:05 UTC (rev 113273)
@@ -84,6 +84,7 @@
     StyleKeyframe* keyframe;
     StyleRuleKeyframes* keyframesRule;
     float val;
+    CSSPropertyID id;
 }
 
 %{
@@ -250,7 +251,7 @@
 %type <valueList> key_list
 %type <value> key
 
-%type <integer> property
+%type <id> property
 
 %type <selector> specifier
 %type <selector> specifier_list

Modified: trunk/Source/WebCore/css/CSSParser.cpp (113272 => 113273)


--- trunk/Source/WebCore/css/CSSParser.cpp	2012-04-05 01:38:28 UTC (rev 113272)
+++ trunk/Source/WebCore/css/CSSParser.cpp	2012-04-05 01:42:05 UTC (rev 113273)
@@ -185,7 +185,7 @@
     , m_id(CSSPropertyInvalid)
     , m_styleSheet(0)
     , m_inParseShorthand(0)
-    , m_currentShorthand(0)
+    , m_currentShorthand(CSSPropertyInvalid)
     , m_implicitShorthand(false)
     , m_hasFontFaceOnlyValues(false)
     , m_hadSyntacticallyValidCSSRule(false)

Modified: trunk/Source/WebCore/css/CSSParser.h (113272 => 113273)


--- trunk/Source/WebCore/css/CSSParser.h	2012-04-05 01:38:28 UTC (rev 113272)
+++ trunk/Source/WebCore/css/CSSParser.h	2012-04-05 01:42:05 UTC (rev 113273)
@@ -109,7 +109,7 @@
     void parseFillPosition(CSSParserValueList*, RefPtr<CSSValue>&, RefPtr<CSSValue>&);
 
     void parseFillRepeat(RefPtr<CSSValue>&, RefPtr<CSSValue>&);
-    PassRefPtr<CSSValue> parseFillSize(CSSPropertyID propId, bool &allowComma);
+    PassRefPtr<CSSValue> parseFillSize(CSSPropertyID, bool &allowComma);
 
     bool parseFillProperty(CSSPropertyID propId, CSSPropertyID& propId1, CSSPropertyID& propId2, RefPtr<CSSValue>&, RefPtr<CSSValue>&);
     bool parseFillShorthand(CSSPropertyID, const CSSPropertyID* properties, int numProperties, bool important);
@@ -130,7 +130,7 @@
 
     bool parseTransformOriginShorthand(RefPtr<CSSValue>&, RefPtr<CSSValue>&, RefPtr<CSSValue>&);
     bool parseCubicBezierTimingFunctionValue(CSSParserValueList*& args, double& result);
-    bool parseAnimationProperty(CSSPropertyID propId, RefPtr<CSSValue>&);
+    bool parseAnimationProperty(CSSPropertyID, RefPtr<CSSValue>&);
     bool parseTransitionShorthand(bool important);
     bool parseAnimationShorthand(bool important);
 
@@ -181,7 +181,7 @@
     bool parseBorderImageSlice(CSSPropertyID, RefPtr<CSSBorderImageSliceValue>&);
     bool parseBorderImageWidth(RefPtr<CSSPrimitiveValue>&);
     bool parseBorderImageOutset(RefPtr<CSSPrimitiveValue>&);
-    bool parseBorderRadius(CSSPropertyID, bool);
+    bool parseBorderRadius(CSSPropertyID, bool important);
 
     bool parseAspectRatio(bool important);
 
@@ -301,7 +301,7 @@
     unsigned m_numParsedPropertiesBeforeMarginBox;
 
     int m_inParseShorthand;
-    int m_currentShorthand;
+    CSSPropertyID m_currentShorthand;
     bool m_implicitShorthand;
 
     bool m_hasFontFaceOnlyValues;
@@ -482,7 +482,7 @@
     ~ShorthandScope()
     {
         if (!(--m_parser->m_inParseShorthand))
-            m_parser->m_currentShorthand = 0;
+            m_parser->m_currentShorthand = CSSPropertyInvalid;
     }
 
 private:

Modified: trunk/Source/WebCore/css/CSSProperty.h (113272 => 113273)


--- trunk/Source/WebCore/css/CSSProperty.h	2012-04-05 01:38:28 UTC (rev 113272)
+++ trunk/Source/WebCore/css/CSSProperty.h	2012-04-05 01:42:05 UTC (rev 113273)
@@ -32,7 +32,7 @@
 
 class CSSProperty {
 public:
-    CSSProperty(CSSPropertyID propID, PassRefPtr<CSSValue> value, bool important = false, int shorthandID = 0, bool implicit = false)
+    CSSProperty(CSSPropertyID propID, PassRefPtr<CSSValue> value, bool important = false, CSSPropertyID shorthandID = CSSPropertyInvalid, bool implicit = false)
         : m_id(propID)
         , m_shorthandID(shorthandID)
         , m_important(important)

Modified: trunk/Source/WebCore/css/SVGCSSComputedStyleDeclaration.cpp (113272 => 113273)


--- trunk/Source/WebCore/css/SVGCSSComputedStyleDeclaration.cpp	2012-04-05 01:38:28 UTC (rev 113272)
+++ trunk/Source/WebCore/css/SVGCSSComputedStyleDeclaration.cpp	2012-04-05 01:42:05 UTC (rev 113273)
@@ -86,7 +86,7 @@
     if (!svgStyle)
         return 0;
 
-    switch (static_cast<CSSPropertyID>(propertyID)) {
+    switch (propertyID) {
         case CSSPropertyClipRule:
             return CSSPrimitiveValue::create(svgStyle->clipRule());
         case CSSPropertyFloodOpacity:

Modified: trunk/Source/WebCore/css/StylePropertySet.h (113272 => 113273)


--- trunk/Source/WebCore/css/StylePropertySet.h	2012-04-05 01:38:28 UTC (rev 113272)
+++ trunk/Source/WebCore/css/StylePropertySet.h	2012-04-05 01:42:05 UTC (rev 113273)
@@ -68,11 +68,11 @@
     bool isPropertyImplicit(CSSPropertyID) const;
 
     // These expand shorthand properties into multiple properties.
-    bool setProperty(CSSPropertyID, const String&, bool important = false, CSSStyleSheet* contextStyleSheet = 0);
+    bool setProperty(CSSPropertyID, const String& value, bool important = false, CSSStyleSheet* contextStyleSheet = 0);
     void setProperty(CSSPropertyID, PassRefPtr<CSSValue>, bool important = false);
 
     // These do not. FIXME: This is too messy, we can do better.
-    bool setProperty(CSSPropertyID, int, bool important = false, CSSStyleSheet* contextStyleSheet = 0);
+    bool setProperty(CSSPropertyID, int value, bool important = false, CSSStyleSheet* contextStyleSheet = 0);
     void setProperty(const CSSProperty&, CSSProperty* slot = 0);
     
     bool removeProperty(CSSPropertyID, String* returnText = 0);

Modified: trunk/Source/WebCore/css/makeprop.pl (113272 => 113273)


--- trunk/Source/WebCore/css/makeprop.pl	2012-04-05 01:38:28 UTC (rev 113272)
+++ trunk/Source/WebCore/css/makeprop.pl	2012-04-05 01:42:05 UTC (rev 113273)
@@ -153,6 +153,8 @@
 #define CSSPropertyNames_h
 
 #include <string.h>
+#include <wtf/HashFunctions.h>
+#include <wtf/HashTraits.h>
 
 namespace WTF {
 class String;
@@ -177,10 +179,12 @@
   }
 }
 my $num = $i - $first;
+my $last = $i - 1;
 
 print HEADER "};\n\n";
 print HEADER "const int firstCSSProperty = $first;\n";
 print HEADER "const int numCSSProperties = $num;\n";
+print HEADER "const int lastCSSProperty = $last;\n";
 print HEADER "const size_t maxCSSPropertyNameLength = $maxLen;\n";
 
 print HEADER "const char* const propertyNameStrings[$num] = {\n";
@@ -194,8 +198,24 @@
 const char* getPropertyName(CSSPropertyID);
 WTF::String getJSPropertyName(CSSPropertyID);
 
+inline CSSPropertyID convertToCSSPropertyID(int value)
+{
+    ASSERT((value >= firstCSSProperty && value <= lastCSSProperty) || value == CSSPropertyInvalid);
+    return static_cast<CSSPropertyID>(value);
+}
+
 } // namespace WebCore
 
+namespace WTF {
+template<> struct DefaultHash<WebCore::CSSPropertyID> { typedef IntHash<unsigned> Hash; };
+template<> struct HashTraits<WebCore::CSSPropertyID> : GenericHashTraits<WebCore::CSSPropertyID> {
+    static const bool emptyValueIsZero = true;
+    static const bool needsDestruction = false;
+    static void constructDeletedValue(WebCore::CSSPropertyID& slot) { slot = static_cast<WebCore::CSSPropertyID>(WebCore::lastCSSProperty + 1); }
+    static bool isDeletedValue(WebCore::CSSPropertyID value) { return value == (WebCore::lastCSSProperty + 1); }
+};
+}
+
 #endif // CSSPropertyNames_h
 
 EOF
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to