Title: [103209] trunk/Source/WebCore
Revision
103209
Author
macpher...@chromium.org
Date
2011-12-18 19:07:55 -0800 (Sun, 18 Dec 2011)

Log Message

Separate box alignment and box pack values into separate enums.
https://bugs.webkit.org/show_bug.cgi?id=74580

Reviewed by Andreas Kling.

No new tests / refactoring only.

Separating these types cleans up the code by removing several assertions that
values are in the correct ranges, as this is ensured by the type system.

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
* css/CSSPrimitiveValueMappings.h:
(WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
(WebCore::CSSPrimitiveValue::operator EBoxPack):
(WebCore::CSSPrimitiveValue::operator EBoxAlignment):
* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::applyProperty):
* rendering/RenderDeprecatedFlexibleBox.cpp:
(WebCore::RenderDeprecatedFlexibleBox::layoutHorizontalBox):
(WebCore::RenderDeprecatedFlexibleBox::layoutVerticalBox):
* rendering/RenderFullScreen.cpp:
(createFullScreenStyle):
* rendering/style/RenderStyle.h:
(WebCore::InheritedFlags::boxPack):
(WebCore::InheritedFlags::setBoxAlign):
(WebCore::InheritedFlags::setBoxPack):
(WebCore::InheritedFlags::initialBoxPack):
* rendering/style/RenderStyleConstants.h:
* rendering/style/StyleDeprecatedFlexibleBoxData.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (103208 => 103209)


--- trunk/Source/WebCore/ChangeLog	2011-12-19 03:01:29 UTC (rev 103208)
+++ trunk/Source/WebCore/ChangeLog	2011-12-19 03:07:55 UTC (rev 103209)
@@ -1,5 +1,38 @@
 2011-12-18  Luke Macpherson   <macpher...@chromium.org>
 
+        Separate box alignment and box pack values into separate enums.
+        https://bugs.webkit.org/show_bug.cgi?id=74580
+
+        Reviewed by Andreas Kling.
+
+        No new tests / refactoring only.
+
+        Separating these types cleans up the code by removing several assertions that
+        values are in the correct ranges, as this is ensured by the type system.
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
+        * css/CSSPrimitiveValueMappings.h:
+        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
+        (WebCore::CSSPrimitiveValue::operator EBoxPack):
+        (WebCore::CSSPrimitiveValue::operator EBoxAlignment):
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::applyProperty):
+        * rendering/RenderDeprecatedFlexibleBox.cpp:
+        (WebCore::RenderDeprecatedFlexibleBox::layoutHorizontalBox):
+        (WebCore::RenderDeprecatedFlexibleBox::layoutVerticalBox):
+        * rendering/RenderFullScreen.cpp:
+        (createFullScreenStyle):
+        * rendering/style/RenderStyle.h:
+        (WebCore::InheritedFlags::boxPack):
+        (WebCore::InheritedFlags::setBoxAlign):
+        (WebCore::InheritedFlags::setBoxPack):
+        (WebCore::InheritedFlags::initialBoxPack):
+        * rendering/style/RenderStyleConstants.h:
+        * rendering/style/StyleDeprecatedFlexibleBoxData.h:
+
+2011-12-18  Luke Macpherson   <macpher...@chromium.org>
+
         Implement CSS font-size property in CSSStyleApplyProperty.
         https://bugs.webkit.org/show_bug.cgi?id=74368
 

Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (103208 => 103209)


--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2011-12-19 03:01:29 UTC (rev 103208)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2011-12-19 03:07:55 UTC (rev 103209)
@@ -1396,14 +1396,8 @@
             return cssValuePool->createValue(style->boxOrdinalGroup(), CSSPrimitiveValue::CSS_NUMBER);
         case CSSPropertyWebkitBoxOrient:
             return cssValuePool->createValue(style->boxOrient());
-        case CSSPropertyWebkitBoxPack: {
-            EBoxAlignment boxPack = style->boxPack();
-            ASSERT(boxPack != BSTRETCH);
-            ASSERT(boxPack != BBASELINE);
-            if (boxPack == BJUSTIFY || boxPack== BBASELINE)
-                return 0;
-            return cssValuePool->createValue(boxPack);
-        }
+        case CSSPropertyWebkitBoxPack:
+            return cssValuePool->createValue(style->boxPack());
         case CSSPropertyWebkitBoxReflect:
             return valueForReflection(style->boxReflect(), style.get(), cssValuePool);
         case CSSPropertyBoxShadow:

Modified: trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h (103208 => 103209)


--- trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h	2011-12-19 03:01:29 UTC (rev 103208)
+++ trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h	2011-12-19 03:07:55 UTC (rev 103209)
@@ -649,6 +649,43 @@
     }
 }
 
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EBoxPack e)
+    : CSSValue(PrimitiveClass)
+{
+    m_primitiveUnitType = CSS_IDENT;
+    switch (e) {
+    case Start:
+        m_value.ident = CSSValueStart;
+        break;
+    case Center:
+        m_value.ident = CSSValueCenter;
+        break;
+    case End:
+        m_value.ident = CSSValueEnd;
+        break;
+    case Justify:
+        m_value.ident = CSSValueJustify;
+        break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EBoxPack() const
+{
+    switch (m_value.ident) {
+    case CSSValueStart:
+        return Start;
+    case CSSValueEnd:
+        return End;
+    case CSSValueCenter:
+        return Center;
+    case CSSValueJustify:
+        return Justify;
+    default:
+        ASSERT_NOT_REACHED();
+        return Justify;
+    }
+}
+
 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EBoxAlignment e)
     : CSSValue(PrimitiveClass)
 {
@@ -669,9 +706,6 @@
         case BBASELINE:
             m_value.ident = CSSValueBaseline;
             break;
-        case BJUSTIFY:
-            m_value.ident = CSSValueJustify;
-            break;
     }
 }
 
@@ -688,8 +722,6 @@
             return BCENTER;
         case CSSValueBaseline:
             return BBASELINE;
-        case CSSValueJustify:
-            return BJUSTIFY;
         default:
             ASSERT_NOT_REACHED();
             return BSTRETCH;

Modified: trunk/Source/WebCore/css/CSSStyleSelector.cpp (103208 => 103209)


--- trunk/Source/WebCore/css/CSSStyleSelector.cpp	2011-12-19 03:01:29 UTC (rev 103208)
+++ trunk/Source/WebCore/css/CSSStyleSelector.cpp	2011-12-19 03:07:55 UTC (rev 103209)
@@ -3170,15 +3170,8 @@
         HANDLE_INHERIT_AND_INITIAL_AND_PRIMITIVE(boxOrient, BoxOrient)
         return;
     case CSSPropertyWebkitBoxPack:
-    {
-        HANDLE_INHERIT_AND_INITIAL(boxPack, BoxPack)
-        if (!primitiveValue)
-            return;
-        EBoxAlignment boxPack = *primitiveValue;
-        if (boxPack != BSTRETCH && boxPack != BBASELINE)
-            m_style->setBoxPack(boxPack);
+        HANDLE_INHERIT_AND_INITIAL_AND_PRIMITIVE(boxPack, BoxPack)
         return;
-    }
     case CSSPropertyWebkitBoxFlex:
         HANDLE_INHERIT_AND_INITIAL_AND_PRIMITIVE(boxFlex, BoxFlex)
         return;

Modified: trunk/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp (103208 => 103209)


--- trunk/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp	2011-12-19 03:01:29 UTC (rev 103208)
+++ trunk/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp	2011-12-19 03:07:55 UTC (rev 103209)
@@ -567,11 +567,11 @@
 
     RenderBlock::finishDelayUpdateScrollInfo();
 
-    if (remainingSpace > 0 && ((style()->isLeftToRightDirection() && style()->boxPack() != BSTART)
-        || (!style()->isLeftToRightDirection() && style()->boxPack() != BEND))) {
+    if (remainingSpace > 0 && ((style()->isLeftToRightDirection() && style()->boxPack() != Start)
+        || (!style()->isLeftToRightDirection() && style()->boxPack() != End))) {
         // Children must be repositioned.
         LayoutUnit offset = 0;
-        if (style()->boxPack() == BJUSTIFY) {
+        if (style()->boxPack() == Justify) {
             // Determine the total number of children.
             int totalChildren = 0;
             for (RenderBox* child = iterator.first(); child; child = iterator.next()) {
@@ -602,7 +602,7 @@
                 }
             }
         } else {
-            if (style()->boxPack() == BCENTER)
+            if (style()->boxPack() == Center)
                 offset += remainingSpace / 2;
             else // END for LTR, START for RTL
                 offset += remainingSpace;
@@ -816,10 +816,10 @@
 
     RenderBlock::finishDelayUpdateScrollInfo();
 
-    if (style()->boxPack() != BSTART && remainingSpace > 0) {
+    if (style()->boxPack() != Start && remainingSpace > 0) {
         // Children must be repositioned.
         LayoutUnit offset = 0;
-        if (style()->boxPack() == BJUSTIFY) {
+        if (style()->boxPack() == Justify) {
             // Determine the total number of children.
             int totalChildren = 0;
             for (RenderBox* child = iterator.first(); child; child = iterator.next()) {
@@ -850,7 +850,7 @@
                 }
             }
         } else {
-            if (style()->boxPack() == BCENTER)
+            if (style()->boxPack() == Center)
                 offset += remainingSpace / 2;
             else // END
                 offset += remainingSpace;

Modified: trunk/Source/WebCore/rendering/RenderFullScreen.cpp (103208 => 103209)


--- trunk/Source/WebCore/rendering/RenderFullScreen.cpp	2011-12-19 03:01:29 UTC (rev 103208)
+++ trunk/Source/WebCore/rendering/RenderFullScreen.cpp	2011-12-19 03:07:55 UTC (rev 103209)
@@ -90,7 +90,7 @@
     fullscreenStyle->font().update(0);
 
     fullscreenStyle->setDisplay(BOX);
-    fullscreenStyle->setBoxPack(BCENTER);
+    fullscreenStyle->setBoxPack(Center);
     fullscreenStyle->setBoxAlign(BCENTER);
     fullscreenStyle->setBoxOrient(VERTICAL);
     

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (103208 => 103209)


--- trunk/Source/WebCore/rendering/style/RenderStyle.h	2011-12-19 03:01:29 UTC (rev 103208)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h	2011-12-19 03:07:55 UTC (rev 103209)
@@ -733,7 +733,7 @@
     EBoxLines boxLines() { return static_cast<EBoxLines>(rareNonInheritedData->m_deprecatedFlexibleBox->lines); }
     unsigned int boxOrdinalGroup() const { return rareNonInheritedData->m_deprecatedFlexibleBox->ordinal_group; }
     EBoxOrient boxOrient() const { return static_cast<EBoxOrient>(rareNonInheritedData->m_deprecatedFlexibleBox->orient); }
-    EBoxAlignment boxPack() const { return static_cast<EBoxAlignment>(rareNonInheritedData->m_deprecatedFlexibleBox->pack); }
+    EBoxPack boxPack() const { return static_cast<EBoxPack>(rareNonInheritedData->m_deprecatedFlexibleBox->pack); }
 
     float flexboxWidthPositiveFlex() const { return rareNonInheritedData->m_flexibleBox->m_widthPositiveFlex; }
     float flexboxWidthNegativeFlex() const { return rareNonInheritedData->m_flexibleBox->m_widthNegativeFlex; }
@@ -1146,14 +1146,14 @@
     void setOpacity(float f) { SET_VAR(rareNonInheritedData, opacity, f); }
     void setAppearance(ControlPart a) { SET_VAR(rareNonInheritedData, m_appearance, a); }
     // For valid values of box-align see http://www.w3.org/TR/2009/WD-css3-flexbox-20090723/#alignment
-    void setBoxAlign(EBoxAlignment a) { ASSERT(a == BSTRETCH || a == BSTART || a == BCENTER || a == BEND || a == BBASELINE); SET_VAR(rareNonInheritedData.access()->m_deprecatedFlexibleBox, align, a); }
+    void setBoxAlign(EBoxAlignment a) { SET_VAR(rareNonInheritedData.access()->m_deprecatedFlexibleBox, align, a); }
     void setBoxDirection(EBoxDirection d) { inherited_flags._box_direction = d; }
     void setBoxFlex(float f) { SET_VAR(rareNonInheritedData.access()->m_deprecatedFlexibleBox, flex, f); }
     void setBoxFlexGroup(unsigned int fg) { SET_VAR(rareNonInheritedData.access()->m_deprecatedFlexibleBox, flex_group, fg); }
     void setBoxLines(EBoxLines l) { SET_VAR(rareNonInheritedData.access()->m_deprecatedFlexibleBox, lines, l); }
     void setBoxOrdinalGroup(unsigned int og) { SET_VAR(rareNonInheritedData.access()->m_deprecatedFlexibleBox, ordinal_group, og); }
     void setBoxOrient(EBoxOrient o) { SET_VAR(rareNonInheritedData.access()->m_deprecatedFlexibleBox, orient, o); }
-    void setBoxPack(EBoxAlignment p) { SET_VAR(rareNonInheritedData.access()->m_deprecatedFlexibleBox, pack, p); }
+    void setBoxPack(EBoxPack p) { SET_VAR(rareNonInheritedData.access()->m_deprecatedFlexibleBox, pack, p); }
     void setBoxShadow(PassOwnPtr<ShadowData>, bool add = false);
     void setBoxReflect(PassRefPtr<StyleReflection> reflect) { if (rareNonInheritedData->m_boxReflect != reflect) rareNonInheritedData.access()->m_boxReflect = reflect; }
     void setBoxSizing(EBoxSizing s) { SET_VAR(m_box, m_boxSizing, s); }
@@ -1475,7 +1475,7 @@
     static EBoxDirection initialBoxDirection() { return BNORMAL; }
     static EBoxLines initialBoxLines() { return SINGLE; }
     static EBoxOrient initialBoxOrient() { return HORIZONTAL; }
-    static EBoxAlignment initialBoxPack() { return BSTART; }
+    static EBoxPack initialBoxPack() { return Start; }
     static float initialBoxFlex() { return 0.0f; }
     static int initialBoxFlexGroup() { return 1; }
     static int initialBoxOrdinalGroup() { return 1; }

Modified: trunk/Source/WebCore/rendering/style/RenderStyleConstants.h (103208 => 103209)


--- trunk/Source/WebCore/rendering/style/RenderStyleConstants.h	2011-12-19 03:01:29 UTC (rev 103208)
+++ trunk/Source/WebCore/rendering/style/RenderStyleConstants.h	2011-12-19 03:07:55 UTC (rev 103209)
@@ -168,7 +168,8 @@
 
 // Deprecated Flexible Box Properties
 
-enum EBoxAlignment { BSTRETCH, BSTART, BCENTER, BEND, BJUSTIFY, BBASELINE };
+enum EBoxPack { Start, Center, End, Justify };
+enum EBoxAlignment { BSTRETCH, BSTART, BCENTER, BEND, BBASELINE };
 enum EBoxOrient { HORIZONTAL, VERTICAL };
 enum EBoxLines { SINGLE, MULTIPLE };
 enum EBoxDirection { BNORMAL, BREVERSE };

Modified: trunk/Source/WebCore/rendering/style/StyleDeprecatedFlexibleBoxData.h (103208 => 103209)


--- trunk/Source/WebCore/rendering/style/StyleDeprecatedFlexibleBoxData.h	2011-12-19 03:01:29 UTC (rev 103208)
+++ trunk/Source/WebCore/rendering/style/StyleDeprecatedFlexibleBoxData.h	2011-12-19 03:07:55 UTC (rev 103209)
@@ -46,7 +46,7 @@
     unsigned int ordinal_group;
 
     unsigned align : 3; // EBoxAlignment
-    unsigned pack: 3; // EBoxAlignment
+    unsigned pack: 2; // EBoxPack
     unsigned orient: 1; // EBoxOrient
     unsigned lines : 1; // EBoxLines
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to