Title: [88431] trunk/Source/WebCore
Revision
88431
Author
[email protected]
Date
2011-06-08 23:55:33 -0700 (Wed, 08 Jun 2011)

Log Message

2011-06-08  Luke Macpherson   <[email protected]>

        Reviewed by Eric Seidel.

        Make CSSPrimitiveValue support cast to EVerticalAlign.
        https://bugs.webkit.org/show_bug.cgi?id=62356

        No new tests / refactoring only.

        * css/CSSPrimitiveValueMappings.h:
        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
        (WebCore::CSSPrimitiveValue::operator EVerticalAlign):
        * css/CSSStyleSelector.cpp:
        (WebCore::CSSStyleSelector::applyProperty):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (88430 => 88431)


--- trunk/Source/WebCore/ChangeLog	2011-06-09 06:47:15 UTC (rev 88430)
+++ trunk/Source/WebCore/ChangeLog	2011-06-09 06:55:33 UTC (rev 88431)
@@ -1,3 +1,18 @@
+2011-06-08  Luke Macpherson   <[email protected]>
+
+        Reviewed by Eric Seidel.
+
+        Make CSSPrimitiveValue support cast to EVerticalAlign.
+        https://bugs.webkit.org/show_bug.cgi?id=62356
+
+        No new tests / refactoring only.
+
+        * css/CSSPrimitiveValueMappings.h:
+        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
+        (WebCore::CSSPrimitiveValue::operator EVerticalAlign):
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::applyProperty):
+
 2011-06-08  Justin Novosad  <[email protected]>
 
         Reviewed by James Robinson.

Modified: trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h (88430 => 88431)


--- trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h	2011-06-09 06:47:15 UTC (rev 88430)
+++ trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h	2011-06-09 06:55:33 UTC (rev 88431)
@@ -1849,6 +1849,70 @@
     }
 }
 
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EVerticalAlign a)
+    : m_type(CSS_IDENT)
+    , m_hasCachedCSSText(false)
+{
+    switch (a) {
+    case TOP:
+        m_value.ident = CSSValueTop;
+        break;
+    case BOTTOM:
+        m_value.ident = CSSValueBottom;
+        break;
+    case MIDDLE:
+        m_value.ident = CSSValueMiddle;
+        break;
+    case BASELINE:
+        m_value.ident = CSSValueBaseline;
+        break;
+    case TEXT_BOTTOM:
+        m_value.ident = CSSValueTextBottom;
+        break;
+    case TEXT_TOP:
+        m_value.ident = CSSValueTextTop;
+        break;
+    case SUB:
+        m_value.ident = CSSValueSub;
+        break;
+    case SUPER:
+        m_value.ident = CSSValueSuper;
+        break;
+    case BASELINE_MIDDLE:
+        m_value.ident = CSSValueWebkitBaselineMiddle;
+        break;
+    case LENGTH:
+        m_value.ident = CSSValueInvalid;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EVerticalAlign() const
+{
+    switch (m_value.ident) {
+    case CSSValueTop:
+        return TOP;
+    case CSSValueBottom:
+        return BOTTOM;
+    case CSSValueMiddle:
+        return MIDDLE;
+    case CSSValueBaseline:
+        return BASELINE;
+    case CSSValueTextBottom:
+        return TEXT_BOTTOM;
+    case CSSValueTextTop:
+        return TEXT_TOP;
+    case CSSValueSub:
+        return SUB;
+    case CSSValueSuper:
+        return SUPER;
+    case CSSValueWebkitBaselineMiddle:
+        return BASELINE_MIDDLE;
+    default:
+        ASSERT_NOT_REACHED();
+        return TOP;
+    }
+}
+
 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EVisibility e)
     : m_type(CSS_IDENT)
     , m_hasCachedCSSText(false)

Modified: trunk/Source/WebCore/css/CSSStyleSelector.cpp (88430 => 88431)


--- trunk/Source/WebCore/css/CSSStyleSelector.cpp	2011-06-09 06:47:15 UTC (rev 88430)
+++ trunk/Source/WebCore/css/CSSStyleSelector.cpp	2011-06-09 06:55:33 UTC (rev 88431)
@@ -3872,49 +3872,27 @@
         return;
     }
     case CSSPropertyVerticalAlign:
+    {
         HANDLE_INHERIT_AND_INITIAL(verticalAlign, VerticalAlign)
         if (!primitiveValue)
             return;
-        if (primitiveValue->getIdent()) {
-          EVerticalAlign align;
 
-          switch (primitiveValue->getIdent()) {
-                case CSSValueTop:
-                    align = TOP; break;
-                case CSSValueBottom:
-                    align = BOTTOM; break;
-                case CSSValueMiddle:
-                    align = MIDDLE; break;
-                case CSSValueBaseline:
-                    align = BASELINE; break;
-                case CSSValueTextBottom:
-                    align = TEXT_BOTTOM; break;
-                case CSSValueTextTop:
-                    align = TEXT_TOP; break;
-                case CSSValueSub:
-                    align = SUB; break;
-                case CSSValueSuper:
-                    align = SUPER; break;
-                case CSSValueWebkitBaselineMiddle:
-                    align = BASELINE_MIDDLE; break;
-                default:
-                    return;
-            }
-          m_style->setVerticalAlign(align);
+        if (primitiveValue->getIdent()) {
+          m_style->setVerticalAlign(*primitiveValue);
           return;
-        } else {
-          int type = primitiveValue->primitiveType();
-          Length l;
-          if (CSSPrimitiveValue::isUnitTypeLength(type))
-            l = Length(primitiveValue->computeLengthIntForLength(style(), m_rootElementStyle, zoomFactor), Fixed);
-          else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
-            l = Length(primitiveValue->getDoubleValue(), Percent);
-
-          m_style->setVerticalAlign(LENGTH);
-          m_style->setVerticalAlignLength(l);
         }
-        return;
 
+        int type = primitiveValue->primitiveType();
+        Length length;
+        if (CSSPrimitiveValue::isUnitTypeLength(type))
+            length = Length(primitiveValue->computeLengthIntForLength(style(), m_rootElementStyle, zoomFactor), Fixed);
+        else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
+            length = Length(primitiveValue->getDoubleValue(), Percent);
+
+        m_style->setVerticalAlign(LENGTH);
+        m_style->setVerticalAlignLength(length);
+        return;
+    }
     case CSSPropertyFontSize:
     {
         FontDescription fontDescription = m_style->fontDescription();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to