Title: [87281] trunk/Source/WebCore
Revision
87281
Author
[email protected]
Date
2011-05-25 02:35:43 -0700 (Wed, 25 May 2011)

Log Message

2011-05-16  Alexander Pavlov  <[email protected]>

        Reviewed by David Levin.

        CSSParser: m_implicitShorthand should probably be RAII
        https://bugs.webkit.org/show_bug.cgi?id=51586

        It was impossible to entirely eliminate the m_implicitShorthand manual changes
        due to the parseFill*() method stateful call chains.

        No new tests, as this is a refactoring.

        * css/CSSParser.cpp:
        (ImplicitScope::ImplicitScope):
        (ImplicitScope::~ImplicitScope):
        (WebCore::CSSParser::parseShorthand):
        (WebCore::CSSParser::parse4Values):
        (WebCore::CSSParser::parseBorderRadius):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (87280 => 87281)


--- trunk/Source/WebCore/ChangeLog	2011-05-25 09:03:11 UTC (rev 87280)
+++ trunk/Source/WebCore/ChangeLog	2011-05-25 09:35:43 UTC (rev 87281)
@@ -1,3 +1,22 @@
+2011-05-16  Alexander Pavlov  <[email protected]>
+
+        Reviewed by David Levin.
+
+        CSSParser: m_implicitShorthand should probably be RAII
+        https://bugs.webkit.org/show_bug.cgi?id=51586
+
+        It was impossible to entirely eliminate the m_implicitShorthand manual changes
+        due to the parseFill*() method stateful call chains.
+
+        No new tests, as this is a refactoring.
+
+        * css/CSSParser.cpp:
+        (ImplicitScope::ImplicitScope):
+        (ImplicitScope::~ImplicitScope):
+        (WebCore::CSSParser::parseShorthand):
+        (WebCore::CSSParser::parse4Values):
+        (WebCore::CSSParser::parseBorderRadius):
+
 2011-05-24  Pavel Podivilov  <[email protected]>
 
         Reviewed by Yury Semikhatsky.

Modified: trunk/Source/WebCore/css/CSSParser.cpp (87280 => 87281)


--- trunk/Source/WebCore/css/CSSParser.cpp	2011-05-25 09:03:11 UTC (rev 87280)
+++ trunk/Source/WebCore/css/CSSParser.cpp	2011-05-25 09:35:43 UTC (rev 87281)
@@ -92,6 +92,33 @@
 using namespace std;
 using namespace WTF;
 
+namespace {
+
+enum PropertyType {
+    PropertyExplicit,
+    PropertyImplicit
+};
+
+class ImplicitScope {
+    WTF_MAKE_NONCOPYABLE(ImplicitScope);
+public:
+    ImplicitScope(WebCore::CSSParser* parser, PropertyType propertyType)
+        : m_parser(parser)
+    {
+        m_parser->m_implicitShorthand = propertyType == PropertyImplicit;
+    }
+
+    ~ImplicitScope()
+    {
+        m_parser->m_implicitShorthand = false;
+    }
+
+private:
+    WebCore::CSSParser* m_parser;
+};
+
+} // namespace
+
 namespace WebCore {
 
 static const unsigned INVALID_NUM_PARSED_PROPERTIES = UINT_MAX;
@@ -2382,12 +2409,11 @@
     }
 
     // Fill in any remaining properties with the initial value.
-    m_implicitShorthand = true;
+    ImplicitScope implicitScope(this, PropertyImplicit);
     for (int i = 0; i < numProperties; ++i) {
         if (!fnd[i])
             addProperty(properties[i], CSSInitialValue::createImplicit(), important);
     }
-    m_implicitShorthand = false;
 
     return true;
 }
@@ -2412,31 +2438,28 @@
             if (!parseValue(properties[0], important))
                 return false;
             CSSValue *value = m_parsedProperties[m_numParsedProperties-1]->value();
-            m_implicitShorthand = true;
+            ImplicitScope implicitScope(this, PropertyImplicit);
             addProperty(properties[1], value, important);
             addProperty(properties[2], value, important);
             addProperty(properties[3], value, important);
-            m_implicitShorthand = false;
             break;
         }
         case 2: {
             if (!parseValue(properties[0], important) || !parseValue(properties[1], important))
                 return false;
             CSSValue *value = m_parsedProperties[m_numParsedProperties-2]->value();
-            m_implicitShorthand = true;
+            ImplicitScope implicitScope(this, PropertyImplicit);
             addProperty(properties[2], value, important);
             value = m_parsedProperties[m_numParsedProperties-2]->value();
             addProperty(properties[3], value, important);
-            m_implicitShorthand = false;
             break;
         }
         case 3: {
             if (!parseValue(properties[0], important) || !parseValue(properties[1], important) || !parseValue(properties[2], important))
                 return false;
             CSSValue *value = m_parsedProperties[m_numParsedProperties-2]->value();
-            m_implicitShorthand = true;
+            ImplicitScope implicitScope(this, PropertyImplicit);
             addProperty(properties[3], value, important);
-            m_implicitShorthand = false;
             break;
         }
         case 4: {
@@ -4995,12 +5018,11 @@
     } else
         completeBorderRadii(radii[1]);
 
-    m_implicitShorthand = true;
+    ImplicitScope implicitScope(this, PropertyImplicit);
     addProperty(CSSPropertyBorderTopLeftRadius, primitiveValueCache()->createValue(Pair::create(radii[0][0].release(), radii[1][0].release())), important);
     addProperty(CSSPropertyBorderTopRightRadius, primitiveValueCache()->createValue(Pair::create(radii[0][1].release(), radii[1][1].release())), important);
     addProperty(CSSPropertyBorderBottomRightRadius, primitiveValueCache()->createValue(Pair::create(radii[0][2].release(), radii[1][2].release())), important);
     addProperty(CSSPropertyBorderBottomLeftRadius, primitiveValueCache()->createValue(Pair::create(radii[0][3].release(), radii[1][3].release())), important);
-    m_implicitShorthand = false;
     return true;
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to