Add support for auto values in flex transitions. Add support for mapping the back...
authorhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Jun 2004 23:27:38 +0000 (23:27 +0000)
committerhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Jun 2004 23:27:38 +0000 (23:27 +0000)
front end values.  Next it's time to actually try to use this stuff in render_flexbox.

        Reviewed by darin

        * khtml/css/css_valueimpl.cpp:
        (length):
        * khtml/css/css_valueimpl.h:
        (DOM::FlexGroupTransitionValueImpl::isAuto):
        * khtml/css/cssparser.cpp:
        (FlexGroupTransitionParseContext::length):
        (FlexGroupTransitionParseContext::commitAutoValue):
        (FlexGroupTransitionParseContext::commitValue):
        (CSSParser::parseFlexGroupTransition):
        * khtml/css/cssstyleselector.cpp:
        (khtml::CSSStyleSelector::applyProperty):
        * khtml/rendering/render_style.cpp:
        (FlexGroupTransitionData::operator==):
        * khtml/rendering/render_style.h:
        (khtml::FlexGroupTransitionData::next):
        (khtml::FlexGroupTransitionData::isAuto):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@6778 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog-2005-08-23
WebCore/khtml/css/css_valueimpl.cpp
WebCore/khtml/css/css_valueimpl.h
WebCore/khtml/css/cssparser.cpp
WebCore/khtml/css/cssstyleselector.cpp
WebCore/khtml/rendering/render_style.cpp
WebCore/khtml/rendering/render_style.h

index 8bba597..8681242 100644 (file)
@@ -1,3 +1,27 @@
+2004-06-04  David Hyatt  <hyatt@apple.com>
+
+       Add support for auto values in flex transitions.  Add support for mapping the back end values to
+       front end values.  Next it's time to actually try to use this stuff in render_flexbox.
+       
+        Reviewed by darin
+
+        * khtml/css/css_valueimpl.cpp:
+        (length):
+        * khtml/css/css_valueimpl.h:
+        (DOM::FlexGroupTransitionValueImpl::isAuto):
+        * khtml/css/cssparser.cpp:
+        (FlexGroupTransitionParseContext::length):
+        (FlexGroupTransitionParseContext::commitAutoValue):
+        (FlexGroupTransitionParseContext::commitValue):
+        (CSSParser::parseFlexGroupTransition):
+        * khtml/css/cssstyleselector.cpp:
+        (khtml::CSSStyleSelector::applyProperty):
+        * khtml/rendering/render_style.cpp:
+        (FlexGroupTransitionData::operator==):
+        * khtml/rendering/render_style.h:
+        (khtml::FlexGroupTransitionData::next):
+        (khtml::FlexGroupTransitionData::isAuto):
+
 === Safari-143 ===
 
 2004-06-04  Kevin Decker  <kdecker@apple.com>
index 6954430..a8ca4a2 100644 (file)
@@ -1032,10 +1032,14 @@ DOMString ShadowValueImpl::cssText() const
 }
 
 // Used for box-flex-transition-group
+FlexGroupTransitionValueImpl::FlexGroupTransitionValueImpl()
+:autoValue(true), group1(0), group2(0), length(0)
+{}
+
 FlexGroupTransitionValueImpl::FlexGroupTransitionValueImpl(unsigned int _group1, 
                                                            unsigned int _group2,
                                                            CSSPrimitiveValueImpl* _length)
-:group1(_group1), group2(_group2), length(_length)
+:autoValue(false), group1(_group1), group2(_group2), length(_length)
 {}
 
 FlexGroupTransitionValueImpl::~FlexGroupTransitionValueImpl()
index 6b9453e..129fa49 100644 (file)
@@ -356,6 +356,7 @@ public:
 class FlexGroupTransitionValueImpl : public CSSValueImpl
 {
 public:
+    FlexGroupTransitionValueImpl();
     FlexGroupTransitionValueImpl(unsigned int _group1, 
                                  unsigned int _group2,
                                  CSSPrimitiveValueImpl* _length);
@@ -365,6 +366,9 @@ public:
     
     virtual DOM::DOMString cssText() const;
     
+    bool isAuto() const { return autoValue; }
+
+    bool autoValue;
     unsigned int group1;
     unsigned int group2;
     CSSPrimitiveValueImpl* length;
index 08967ae..570030c 100644 (file)
@@ -1935,7 +1935,7 @@ bool CSSParser::parseShadow(int propId, bool important)
 struct FlexGroupTransitionParseContext {
     FlexGroupTransitionParseContext()
     :values(0), allowGroup1(true), allowSlash(false), allowGroup2(false), allowLength(false),
-     allowBreak(true), group1(0), group2(0), length(0)
+     allowBreak(true),  autoValue(false), group1(0), group2(0), length(0)
     {}
     
     ~FlexGroupTransitionParseContext() {
@@ -1976,21 +1976,29 @@ struct FlexGroupTransitionParseContext {
         allowBreak = true;
     }
 
+    void commitAutoValue() {
+        autoValue = true;
+        allowSlash = allowGroup1 = allowGroup2 = allowLength = false;
+        allowBreak = true;
+    }
+
     void commitValue() {
         // Handle the ,, case gracefully by doing nothing.
-        if ((group1 || group2) && length) {
+        if (autoValue || ((group1 || group2) && length)) {
             if (!values)
                 values = new CSSValueListImpl();
             
             // Construct the current shadow value and add it to the list.
-            values->append(new FlexGroupTransitionValueImpl(group1, group2, length));
+            values->append(autoValue ? 
+                           new FlexGroupTransitionValueImpl() :
+                           new FlexGroupTransitionValueImpl(group1, group2, length));
         }
         
         // Now reset for the next shadow value.
         group1 = group2 = 0;
         length = 0;
         allowGroup1 = allowBreak = true;
-        allowSlash = allowGroup2 = allowLength = false;
+        allowSlash = allowGroup2 = allowLength = autoValue = false;
     }
     
     CSSValueListImpl* values;
@@ -1999,6 +2007,9 @@ struct FlexGroupTransitionParseContext {
     bool allowGroup2;
     bool allowLength;
     bool allowBreak;
+
+    // The current value data
+    bool autoValue;
     unsigned int group1;
     unsigned int group2;
     CSSPrimitiveValueImpl* length;
@@ -2025,6 +2036,13 @@ bool CSSParser::parseFlexGroupTransition(int propId, bool important)
             // The value is good.  Commit it.
             context.commitValue();
         }
+        // See if an auto value was specified
+        else if (val->id == CSS_VAL_AUTO) {
+            if (context.allowGroup1)
+                context.commitAutoValue();
+            else
+                return context.failed();
+        }
         // Check to see if we're a non-negative number.
         else if (validUnit(val, FInteger|FNonNeg, true)) {
             if (context.allowGroup())
index 16248fa..4c59e8c 100644 (file)
@@ -3421,6 +3421,39 @@ void CSSStyleSelector::applyProperty( int id, DOM::CSSValueImpl *value )
             return; // Error case.
         style->setBoxOrdinalGroup((unsigned int)(primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER)));
         return;
+    case CSS_PROP__KHTML_BOX_FLEX_GROUP_TRANSITION: {
+        if (isInherit) {
+            style->setBoxFlexGroupTransition(parentStyle->boxFlexGroupTransition() ? 
+                                             new FlexGroupTransitionData(*parentStyle->boxFlexGroupTransition()) : 0);
+            return;
+        }
+        else if (isInitial) {
+            style->setBoxFlexGroupTransition(0);
+            return;
+        }
+
+        if (!value->isValueList()) return;
+        CSSValueListImpl *list = static_cast<CSSValueListImpl *>(value);
+        int len = list->length();
+        for (int i = 0; i < len; i++) {
+            FlexGroupTransitionValueImpl *item = static_cast<FlexGroupTransitionValueImpl*>(list->item(i));
+            FlexGroupTransitionData* transitionData;
+            if (item->isAuto())
+                transitionData = new FlexGroupTransitionData();
+            else {
+                int type = item->length->primitiveType();
+                Length l;
+                if (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
+                    l = Length(primitiveValue->computeLength(style, paintDeviceMetrics), Fixed, false);
+                else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
+                    l = Length((int)primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
+                transitionData = new FlexGroupTransitionData(item->group1, item->group2, l);
+            }
+            style->setBoxFlexGroupTransition(transitionData, i != 0);
+        }
+            
+        return;
+    }
     case CSS_PROP__KHTML_MARQUEE:
         if (value->cssValueType() != CSSValue::CSS_INHERIT || !parentNode) return;
         style->setMarqueeDirection(parentStyle->marqueeDirection());
index 467a0f5..deb2e6e 100644 (file)
@@ -924,5 +924,5 @@ bool FlexGroupTransitionData::operator==(const FlexGroupTransitionData& o) const
         (next && o.next && *next != *o.next))
         return false;
     
-    return group1 == o.group1 && group2 == o.group2 && length == o.length;
+    return autoValue == o.autoValue && group1 == o.group1 && group2 == o.group2 && length == o.length;
 }
index c38676d..94a2dce 100644 (file)
@@ -453,8 +453,9 @@ public:
 
 // This struct holds information about flex group transitions for the box-flex-group-transition property.
 struct FlexGroupTransitionData {
+    FlexGroupTransitionData() :autoValue(true), group1(0), group2(0), next(0) {}
     FlexGroupTransitionData(unsigned int _group1, unsigned int _group2, Length _l)
-    :group1(_group1), group2(_group2), length(_l), next(0) {}
+    :autoValue(false), group1(_group1), group2(_group2), length(_l), next(0) {}
     FlexGroupTransitionData(const FlexGroupTransitionData& o);
     
     ~FlexGroupTransitionData() { delete next; }
@@ -464,6 +465,9 @@ struct FlexGroupTransitionData {
         return !(*this == o);
     }
     
+    bool isAuto() const { return autoValue; }
+    
+    bool autoValue;
     unsigned int group1;
     unsigned int group2;
     Length length;