Title: [104452] trunk/Source/WebCore
Revision
104452
Author
alexis.men...@openbossa.org
Date
2012-01-09 05:48:36 -0800 (Mon, 09 Jan 2012)

Log Message

Extend CSSValueList to allow slash separated lists.
https://bugs.webkit.org/show_bug.cgi?id=75841

Reviewed by Andreas Kling.

Multiple CSS properties are using slash to separate
various parts (e.g. border-radius) so having this
feature available in CSSValueList will make it easier
in the future to support these properties.

No new tests : existing ones should cover the refactor.

* css/CSSInitialValue.h:
(WebCore::CSSInitialValue::isImplicit):
(WebCore::CSSInitialValue::CSSInitialValue):
* css/CSSValue.cpp:
(WebCore::CSSValue::isImplicitInitialValue):
* css/CSSValue.h:
In order for CSSValue to not grow I moved m_isImplicitInitialValue
back to CSSInitialValue as this object is used only in CSSValuePool
and is allocated only twice.
(WebCore::CSSValue::CSSValue):
* css/CSSValueList.cpp:
(WebCore::CSSValueList::CSSValueList):
(WebCore::CSSValueList::copy):
Fix also usage of PassRefPtr.
(WebCore::CSSValueList::customCssText):
Refactor to use StringBuilder.
* css/CSSValueList.h:
(WebCore::CSSValueList::createCommaSeparated):
(WebCore::CSSValueList::createSpaceSeparated):
(WebCore::CSSValueList::createSlashSeparated):
* css/WebKitCSSFilterValue.cpp:
(WebCore::WebKitCSSFilterValue::WebKitCSSFilterValue):
* css/WebKitCSSTransformValue.cpp:
(WebCore::WebKitCSSTransformValue::WebKitCSSTransformValue):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (104451 => 104452)


--- trunk/Source/WebCore/ChangeLog	2012-01-09 13:22:38 UTC (rev 104451)
+++ trunk/Source/WebCore/ChangeLog	2012-01-09 13:48:36 UTC (rev 104452)
@@ -1,3 +1,42 @@
+2012-01-09  Alexis Menard  <alexis.men...@openbossa.org>
+
+        Extend CSSValueList to allow slash separated lists.
+        https://bugs.webkit.org/show_bug.cgi?id=75841
+
+        Reviewed by Andreas Kling.
+
+        Multiple CSS properties are using slash to separate
+        various parts (e.g. border-radius) so having this
+        feature available in CSSValueList will make it easier
+        in the future to support these properties.
+
+        No new tests : existing ones should cover the refactor.
+
+        * css/CSSInitialValue.h:
+        (WebCore::CSSInitialValue::isImplicit):
+        (WebCore::CSSInitialValue::CSSInitialValue):
+        * css/CSSValue.cpp:
+        (WebCore::CSSValue::isImplicitInitialValue):
+        * css/CSSValue.h:
+        In order for CSSValue to not grow I moved m_isImplicitInitialValue
+        back to CSSInitialValue as this object is used only in CSSValuePool
+        and is allocated only twice.
+        (WebCore::CSSValue::CSSValue):
+        * css/CSSValueList.cpp:
+        (WebCore::CSSValueList::CSSValueList):
+        (WebCore::CSSValueList::copy):
+        Fix also usage of PassRefPtr.
+        (WebCore::CSSValueList::customCssText):
+        Refactor to use StringBuilder.
+        * css/CSSValueList.h:
+        (WebCore::CSSValueList::createCommaSeparated):
+        (WebCore::CSSValueList::createSpaceSeparated):
+        (WebCore::CSSValueList::createSlashSeparated):
+        * css/WebKitCSSFilterValue.cpp:
+        (WebCore::WebKitCSSFilterValue::WebKitCSSFilterValue):
+        * css/WebKitCSSTransformValue.cpp:
+        (WebCore::WebKitCSSTransformValue::WebKitCSSTransformValue):
+
 2012-01-09  No'am Rosenthal  <noam.rosent...@nokia.com>
 
         [Texmap] Move surface management from TextureMapperNode to TextureMapper

Modified: trunk/Source/WebCore/css/CSSInitialValue.h (104451 => 104452)


--- trunk/Source/WebCore/css/CSSInitialValue.h	2012-01-09 13:22:38 UTC (rev 104451)
+++ trunk/Source/WebCore/css/CSSInitialValue.h	2012-01-09 13:48:36 UTC (rev 104452)
@@ -39,12 +39,16 @@
 
     String customCssText() const;
 
+    bool isImplicit() const { return m_isImplicit; }
+
 private:
     CSSInitialValue(bool implicit)
         : CSSValue(InitialClass)
+        , m_isImplicit(implicit)
     {
-        m_isImplicitInitialValue = implicit;
     }
+
+    bool m_isImplicit;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/css/CSSValue.cpp (104451 => 104452)


--- trunk/Source/WebCore/css/CSSValue.cpp	2012-01-09 13:22:38 UTC (rev 104451)
+++ trunk/Source/WebCore/css/CSSValue.cpp	2012-01-09 13:48:36 UTC (rev 104452)
@@ -65,6 +65,11 @@
 
 COMPILE_ASSERT(sizeof(CSSValue) == sizeof(SameSizeAsCSSValue), CSS_value_should_stay_small);
 
+bool CSSValue::isImplicitInitialValue() const
+{
+    return m_classType == InitialClass && static_cast<const CSSInitialValue*>(this)->isImplicit();
+}
+
 CSSValue::Type CSSValue::cssValueType() const
 {
     if (isInheritedValue())

Modified: trunk/Source/WebCore/css/CSSValue.h (104451 => 104452)


--- trunk/Source/WebCore/css/CSSValue.h	2012-01-09 13:22:38 UTC (rev 104451)
+++ trunk/Source/WebCore/css/CSSValue.h	2012-01-09 13:48:36 UTC (rev 104452)
@@ -68,7 +68,7 @@
     bool isFontValue() const { return m_classType == FontClass; }
     bool isImageGeneratorValue() const { return m_classType >= CanvasClass && m_classType <= RadialGradientClass; }
     bool isImageValue() const { return m_classType == ImageClass || m_classType == CursorImageClass; }
-    bool isImplicitInitialValue() const { return m_classType == InitialClass && m_isImplicitInitialValue; }
+    bool isImplicitInitialValue() const;
     bool isInheritedValue() const { return m_classType == InheritedClass; }
     bool isInitialValue() const { return m_classType == InitialClass; }
     bool isReflectValue() const { return m_classType == ReflectClass; }
@@ -145,14 +145,20 @@
         // Do not append non-list class types here.
     };
 
+    static const size_t ValueListSeparatorBits = 2;
+    enum ValueListSeparator {
+        SpaceSeparator,
+        CommaSeparator,
+        SlashSeparator
+    };
+
     ClassType classType() const { return static_cast<ClassType>(m_classType); }
 
     explicit CSSValue(ClassType classType)
         : m_primitiveUnitType(0)
         , m_hasCachedCSSText(false)
         , m_isQuirkValue(false)
-        , m_isImplicitInitialValue(false)
-        , m_isSpaceSeparatedValueList(false)
+        , m_valueListSeparator(SpaceSeparator)
         , m_classType(classType)
     {
     }
@@ -174,12 +180,8 @@
     mutable bool m_hasCachedCSSText : 1;
     bool m_isQuirkValue : 1;
 
-    // CSSInitialValue bits:
-    bool m_isImplicitInitialValue : 1;
+    unsigned char m_valueListSeparator : ValueListSeparatorBits;
 
-    // CSSValueList bits:
-    bool m_isSpaceSeparatedValueList : 1;
-
 private:
     unsigned char m_classType : ClassTypeBits; // ClassType
 };

Modified: trunk/Source/WebCore/css/CSSValueList.cpp (104451 => 104452)


--- trunk/Source/WebCore/css/CSSValueList.cpp	2012-01-09 13:22:38 UTC (rev 104451)
+++ trunk/Source/WebCore/css/CSSValueList.cpp	2012-01-09 13:48:36 UTC (rev 104452)
@@ -24,25 +24,26 @@
 #include "CSSParserValues.h"
 #include "PlatformString.h"
 #include <wtf/PassOwnPtr.h>
+#include <wtf/text/StringBuilder.h>
 
 namespace WebCore {
 
-CSSValueList::CSSValueList(ClassType classType, bool isSpaceSeparated)
+CSSValueList::CSSValueList(ClassType classType, ValueListSeparator listSeparator)
     : CSSValue(classType)
 {
-    m_isSpaceSeparatedValueList = isSpaceSeparated;
+    m_valueListSeparator = listSeparator;
 }
 
-CSSValueList::CSSValueList(bool isSpaceSeparated)
+CSSValueList::CSSValueList(ValueListSeparator listSeparator)
     : CSSValue(ValueListClass)
 {
-    m_isSpaceSeparatedValueList = isSpaceSeparated;
+    m_valueListSeparator = listSeparator;
 }
 
 CSSValueList::CSSValueList(CSSParserValueList* list)
     : CSSValue(ValueListClass)
 {
-    m_isSpaceSeparatedValueList = true;
+    m_valueListSeparator = SpaceSeparator;
     if (list) {
         size_t size = list->size();
         for (unsigned i = 0; i < size; ++i)
@@ -88,28 +89,51 @@
 
 PassRefPtr<CSSValueList> CSSValueList::copy()
 {
-    PassRefPtr<CSSValueList> newList = isSpaceSeparated() ? createSpaceSeparated() : createCommaSeparated();
+    RefPtr<CSSValueList> newList;
+    switch (m_valueListSeparator) {
+    case SpaceSeparator:
+        newList = createSpaceSeparated();
+        break;
+    case CommaSeparator:
+        newList = createCommaSeparated();
+        break;
+    case SlashSeparator:
+        newList = createSlashSeparated();
+        break;
+    default:
+        ASSERT_NOT_REACHED();
+    }
     for (size_t index = 0; index < m_values.size(); index++)
         newList->append(m_values[index]);
-    return newList;
+    return newList.release();
 }
 
 String CSSValueList::customCssText() const
 {
-    String result = "";
+    StringBuilder result;
+    String separator;
+    switch (m_valueListSeparator) {
+    case SpaceSeparator:
+        separator = " ";
+        break;
+    case CommaSeparator:
+        separator = ", ";
+        break;
+    case SlashSeparator:
+        separator = " / ";
+        break;
+    default:
+        ASSERT_NOT_REACHED();
+    }
 
     unsigned size = m_values.size();
     for (unsigned i = 0; i < size; i++) {
-        if (!result.isEmpty()) {
-            if (isSpaceSeparated())
-                result += " ";
-            else
-                result += ", ";
-        }
-        result += m_values[i]->cssText();
+        if (!result.isEmpty())
+            result.append(separator);
+        result.append(m_values[i]->cssText());
     }
 
-    return result;
+    return result.toString();
 }
 
 void CSSValueList::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const CSSStyleSheet* styleSheet)

Modified: trunk/Source/WebCore/css/CSSValueList.h (104451 => 104452)


--- trunk/Source/WebCore/css/CSSValueList.h	2012-01-09 13:22:38 UTC (rev 104451)
+++ trunk/Source/WebCore/css/CSSValueList.h	2012-01-09 13:48:36 UTC (rev 104452)
@@ -33,12 +33,16 @@
 public:
     static PassRefPtr<CSSValueList> createCommaSeparated()
     {
-        return adoptRef(new CSSValueList(false));
+        return adoptRef(new CSSValueList(CommaSeparator));
     }
     static PassRefPtr<CSSValueList> createSpaceSeparated()
     {
-        return adoptRef(new CSSValueList(true));
+        return adoptRef(new CSSValueList(SpaceSeparator));
     }
+    static PassRefPtr<CSSValueList> createSlashSeparated()
+    {
+        return adoptRef(new CSSValueList(SlashSeparator));
+    }
     static PassRefPtr<CSSValueList> createFromParserValueList(CSSParserValueList* list)
     {
         return adoptRef(new CSSValueList(list));
@@ -59,14 +63,12 @@
     void addSubresourceStyleURLs(ListHashSet<KURL>&, const CSSStyleSheet*);
 
 protected:
-    CSSValueList(ClassType, bool isSpaceSeparated);
+    CSSValueList(ClassType, ValueListSeparator);
 
 private:
-    explicit CSSValueList(bool isSpaceSeparated);
+    explicit CSSValueList(ValueListSeparator);
     explicit CSSValueList(CSSParserValueList*);
 
-    bool isSpaceSeparated() const { return m_isSpaceSeparatedValueList; }
-
     Vector<RefPtr<CSSValue> > m_values;
 };
 

Modified: trunk/Source/WebCore/css/WebKitCSSFilterValue.cpp (104451 => 104452)


--- trunk/Source/WebCore/css/WebKitCSSFilterValue.cpp	2012-01-09 13:22:38 UTC (rev 104451)
+++ trunk/Source/WebCore/css/WebKitCSSFilterValue.cpp	2012-01-09 13:48:36 UTC (rev 104452)
@@ -35,7 +35,7 @@
 namespace WebCore {
 
 WebKitCSSFilterValue::WebKitCSSFilterValue(FilterOperationType operationType)
-    : CSSValueList(WebKitCSSFilterClass, typeUsesSpaceSeparator(operationType))
+    : CSSValueList(WebKitCSSFilterClass, typeUsesSpaceSeparator(operationType) ? SpaceSeparator : CommaSeparator)
     , m_type(operationType)
 {
 }

Modified: trunk/Source/WebCore/css/WebKitCSSTransformValue.cpp (104451 => 104452)


--- trunk/Source/WebCore/css/WebKitCSSTransformValue.cpp	2012-01-09 13:22:38 UTC (rev 104451)
+++ trunk/Source/WebCore/css/WebKitCSSTransformValue.cpp	2012-01-09 13:48:36 UTC (rev 104452)
@@ -33,7 +33,7 @@
 namespace WebCore {
 
 WebKitCSSTransformValue::WebKitCSSTransformValue(TransformOperationType op)
-    : CSSValueList(WebKitCSSTransformClass, false)
+    : CSSValueList(WebKitCSSTransformClass, CommaSeparator)
     , m_type(op)
 {
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to