Title: [101225] trunk/Source/WebCore
Revision
101225
Author
[email protected]
Date
2011-11-27 23:08:34 -0800 (Sun, 27 Nov 2011)

Log Message

Implement vertical-align property in CSSStyleApplyProperty.
https://bugs.webkit.org/show_bug.cgi?id=72926

Reviewed by Andreas Kling.

Part of the ongoing refactoring of CSSStyleSelector::applyProperty.

Covered by several tests under fast/css.

* css/CSSPrimitiveValue.h:
(WebCore::CSSPrimitiveValue::isPercent):
* css/CSSStyleApplyProperty.cpp:
(WebCore::ApplyPropertyVerticalAlign::applyValue):
(WebCore::ApplyPropertyVerticalAlign::createHandler):
(WebCore::CSSStyleApplyProperty::CSSStyleApplyProperty):
* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::applyProperty):
* rendering/style/RenderStyle.h:
(WebCore::InheritedFlags::setVerticalAlignLength):
Calling setVerticalAlignLength now automatically sets verticalAlign to LENGTH.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (101224 => 101225)


--- trunk/Source/WebCore/ChangeLog	2011-11-28 06:59:25 UTC (rev 101224)
+++ trunk/Source/WebCore/ChangeLog	2011-11-28 07:08:34 UTC (rev 101225)
@@ -1,5 +1,28 @@
 2011-11-27  Luke Macpherson   <[email protected]>
 
+        Implement vertical-align property in CSSStyleApplyProperty.
+        https://bugs.webkit.org/show_bug.cgi?id=72926
+
+        Reviewed by Andreas Kling.
+
+        Part of the ongoing refactoring of CSSStyleSelector::applyProperty.
+
+        Covered by several tests under fast/css.
+
+        * css/CSSPrimitiveValue.h:
+        (WebCore::CSSPrimitiveValue::isPercent):
+        * css/CSSStyleApplyProperty.cpp:
+        (WebCore::ApplyPropertyVerticalAlign::applyValue):
+        (WebCore::ApplyPropertyVerticalAlign::createHandler):
+        (WebCore::CSSStyleApplyProperty::CSSStyleApplyProperty):
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::applyProperty):
+        * rendering/style/RenderStyle.h:
+        (WebCore::InheritedFlags::setVerticalAlignLength):
+        Calling setVerticalAlignLength now automatically sets verticalAlign to LENGTH.
+
+2011-11-27  Luke Macpherson   <[email protected]>
+
         Implement CSSPropertyTextAlign in CSSStyleApplyProperty.
         https://bugs.webkit.org/show_bug.cgi?id=73102
 

Modified: trunk/Source/WebCore/css/CSSPrimitiveValue.h (101224 => 101225)


--- trunk/Source/WebCore/css/CSSPrimitiveValue.h	2011-11-28 06:59:25 UTC (rev 101224)
+++ trunk/Source/WebCore/css/CSSPrimitiveValue.h	2011-11-28 07:08:34 UTC (rev 101225)
@@ -120,6 +120,7 @@
                                                     type == CSSPrimitiveValue::CSS_REMS; }
 
     bool isLength() const { return isUnitTypeLength(m_primitiveUnitType); }
+    bool isPercentage() const { return m_primitiveUnitType == CSSPrimitiveValue::CSS_PERCENTAGE; }
 
     static PassRefPtr<CSSPrimitiveValue> createIdentifier(int identifier) { return adoptRef(new CSSPrimitiveValue(identifier)); }
     static PassRefPtr<CSSPrimitiveValue> createColor(unsigned rgbValue) { return adoptRef(new CSSPrimitiveValue(rgbValue)); }

Modified: trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp (101224 => 101225)


--- trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp	2011-11-28 06:59:25 UTC (rev 101224)
+++ trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp	2011-11-28 07:08:34 UTC (rev 101225)
@@ -869,6 +869,34 @@
     static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
 };
 
+class ApplyPropertyVerticalAlign {
+public:
+    static void applyValue(CSSStyleSelector* selector, CSSValue* value)
+    {
+        if (!value->isPrimitiveValue())
+            return;
+
+        CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
+
+        if (primitiveValue->getIdent())
+            return selector->style()->setVerticalAlign(*primitiveValue);
+
+        Length length;
+        if (primitiveValue->isLength())
+            length = primitiveValue->computeLength<Length>(selector->style(), selector->rootElementStyle(), selector->style()->effectiveZoom());
+        else if (primitiveValue->isPercentage())
+            length = Length(primitiveValue->getDoubleValue(), Percent);
+
+        selector->style()->setVerticalAlignLength(length);
+    }
+
+    static PropertyHandler createHandler()
+    {
+        PropertyHandler handler = ApplyPropertyDefaultBase<EVerticalAlign, &RenderStyle::verticalAlign, EVerticalAlign, &RenderStyle::setVerticalAlign, EVerticalAlign, &RenderStyle::initialVerticalAlign>::createHandler();
+        return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
+    }
+};
+
 class ApplyPropertyAspectRatio {
 public:
     static void applyInheritValue(CSSStyleSelector* selector)
@@ -1090,6 +1118,8 @@
     setPropertyHandler(CSSPropertyPaddingLeft, ApplyPropertyLength<&RenderStyle::paddingLeft, &RenderStyle::setPaddingLeft, &RenderStyle::initialPadding>::createHandler());
     setPropertyHandler(CSSPropertyPadding, ApplyPropertyExpanding<SuppressValue, CSSPropertyPaddingTop, CSSPropertyPaddingRight, CSSPropertyPaddingBottom, CSSPropertyPaddingLeft>::createHandler());
 
+    setPropertyHandler(CSSPropertyVerticalAlign, ApplyPropertyVerticalAlign::createHandler());
+
     setPropertyHandler(CSSPropertyWebkitPerspectiveOriginX, ApplyPropertyLength<&RenderStyle::perspectiveOriginX, &RenderStyle::setPerspectiveOriginX, &RenderStyle::initialPerspectiveOriginX>::createHandler());
     setPropertyHandler(CSSPropertyWebkitPerspectiveOriginY, ApplyPropertyLength<&RenderStyle::perspectiveOriginY, &RenderStyle::setPerspectiveOriginY, &RenderStyle::initialPerspectiveOriginY>::createHandler());
     setPropertyHandler(CSSPropertyWebkitPerspectiveOrigin, ApplyPropertyExpanding<SuppressValue, CSSPropertyWebkitPerspectiveOriginX, CSSPropertyWebkitPerspectiveOriginY>::createHandler());

Modified: trunk/Source/WebCore/css/CSSStyleSelector.cpp (101224 => 101225)


--- trunk/Source/WebCore/css/CSSStyleSelector.cpp	2011-11-28 06:59:25 UTC (rev 101224)
+++ trunk/Source/WebCore/css/CSSStyleSelector.cpp	2011-11-28 07:08:34 UTC (rev 101225)
@@ -2656,28 +2656,6 @@
         m_style->setResize(r);
         return;
     }
-    case CSSPropertyVerticalAlign:
-    {
-        HANDLE_INHERIT_AND_INITIAL(verticalAlign, VerticalAlign)
-        if (!primitiveValue)
-            return;
-
-        if (primitiveValue->getIdent()) {
-          m_style->setVerticalAlign(*primitiveValue);
-          return;
-        }
-
-        int type = primitiveValue->primitiveType();
-        Length length;
-        if (CSSPrimitiveValue::isUnitTypeLength(type))
-            length = primitiveValue->computeLength<Length>(style(), m_rootElementStyle, zoomFactor);
-        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();
@@ -4010,6 +3988,7 @@
     case CSSPropertyMaxHeight:
     case CSSPropertyHeight:
     case CSSPropertyMinHeight:
+    case CSSPropertyVerticalAlign:
     case CSSPropertyWebkitTransformOriginX:
     case CSSPropertyWebkitTransformOriginY:
     case CSSPropertyWebkitTransformOriginZ:

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (101224 => 101225)


--- trunk/Source/WebCore/rendering/style/RenderStyle.h	2011-11-28 06:59:25 UTC (rev 101224)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h	2011-11-28 07:08:34 UTC (rev 101225)
@@ -979,7 +979,7 @@
     void setOverflowY(EOverflow v) { noninherited_flags._overflowY = v; }
     void setVisibility(EVisibility v) { inherited_flags._visibility = v; }
     void setVerticalAlign(EVerticalAlign v) { noninherited_flags._vertical_align = v; }
-    void setVerticalAlignLength(Length l) { SET_VAR(m_box, m_verticalAlign, l) }
+    void setVerticalAlignLength(Length length) { setVerticalAlign(LENGTH); SET_VAR(m_box, m_verticalAlign, length) }
 
     void setHasClip(bool b = true) { SET_VAR(visual, hasClip, b) }
     void setClipLeft(Length v) { SET_VAR(visual, clip.m_left, v) }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to