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 8bba597f3dacfa109c976fc2eece24b74b96d59d..8681242a14c01a0829888c150ec63aaeed908f6d 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 695443073aaa7da161f5b54f5b12c6165a491a0d..a8ca4a29eb133a253e11096c787f4f3123de865b 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 6b9453e66fdec52f3027992a38db1127255fcc00..129fa4943ffef0b93627f1b520bc78a678ef29db 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 08967ae84c0f1dfa6f6133b84c9971204bb638cf..570030c14a0123dfed7664bf0a4b35d5b9219f85 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 16248fa4ae95f813b7037025bb84f070d701f5b2..4c59e8c3addda20f6319b993ec3ac5b7a3f54b94 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 467a0f5b2d92db22200acb228eda5fca66086f8d..deb2e6e0d78d10fa5fa0827c18e4540e4c7cfb10 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 c38676daa07eb729406dede38c393ea9c00580cb..94a2dcec6593cf674705bad0a748dbce32e724b2 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;