Title: [113264] trunk
Revision
113264
Author
[email protected]
Date
2012-04-04 16:57:33 -0700 (Wed, 04 Apr 2012)

Log Message

CSS transitions should work on the flex property
https://bugs.webkit.org/show_bug.cgi?id=75915

Reviewed by Dean Jackson.

Source/WebCore:

Test: transitions/flex-transitions.html

* page/animation/AnimationBase.cpp:
(WebCore::PropertyWrapperGetter::equals): Fix indention.
(PropertyWrapperFlex): Add a wrapper for -webkit-flex which has 3 values (two floats and
a length), but is not a shorthand.
(WebCore::PropertyWrapperFlex::PropertyWrapperFlex):
(WebCore::PropertyWrapperFlex::equals):
(WebCore::PropertyWrapperFlex::blend):
(WebCore):
(WebCore::AnimationBase::ensurePropertyMap):

LayoutTests:

* transitions/flex-transitions-expected.txt: Added.
* transitions/flex-transitions.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (113263 => 113264)


--- trunk/LayoutTests/ChangeLog	2012-04-04 23:54:28 UTC (rev 113263)
+++ trunk/LayoutTests/ChangeLog	2012-04-04 23:57:33 UTC (rev 113264)
@@ -1,3 +1,13 @@
+2012-04-04  Tony Chang  <[email protected]>
+
+        CSS transitions should work on the flex property
+        https://bugs.webkit.org/show_bug.cgi?id=75915
+
+        Reviewed by Dean Jackson.
+
+        * transitions/flex-transitions-expected.txt: Added.
+        * transitions/flex-transitions.html: Added.
+
 2012-04-04  Tom Sepez  <[email protected]>
 
         XSSAuditor bypass through HTTP Parameter Pollution.

Added: trunk/LayoutTests/transitions/flex-transitions-expected.txt (0 => 113264)


--- trunk/LayoutTests/transitions/flex-transitions-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/transitions/flex-transitions-expected.txt	2012-04-04 23:57:33 UTC (rev 113264)
@@ -0,0 +1,5 @@
+PASS - "-webkit-flex" property for "row1" element at 0.5s saw something close to: 2,0,0
+PASS - "-webkit-flex" property for "column1" element at 0.5s saw something close to: 0.5,0,10
+PASS - "-webkit-flex" property for "negative1" element at 0.5s saw something close to: 1,0.5,75
+PASS - "-webkit-flex" property for "no-flex1" element at 0.5s saw something close to: 0.5,0,0
+

Added: trunk/LayoutTests/transitions/flex-transitions.html (0 => 113264)


--- trunk/LayoutTests/transitions/flex-transitions.html	                        (rev 0)
+++ trunk/LayoutTests/transitions/flex-transitions.html	2012-04-04 23:57:33 UTC (rev 113264)
@@ -0,0 +1,97 @@
+<!DOCTYPE>
+<html>
+<head>
+<style>
+.flexbox {
+    display: -webkit-flexbox;
+    width: 100px;
+    height: 100px;
+}
+.flexbox :nth-child(1) {
+    background-color: blue;
+}
+.flexbox :nth-child(2) {
+    background-color: green;
+}
+.flexbox div {
+    -webkit-transition-property: -webkit-flex;
+    -webkit-transition-duration: 1s;
+    -webkit-transition-timing-function: linear;
+}
+
+#flex-row div {
+    -webkit-flex: 1;
+}
+.final #row1 {
+    -webkit-flex: 3;
+}
+
+#flex-column {
+    -webkit-flex-direction: column;
+}
+#flex-column div {
+    -webkit-flex: 1;
+}
+.final #column1 {
+    -webkit-flex: 20px;
+}
+
+#flex-negative div {
+    -webkit-flex: 1 1 50px;
+}
+.final #negative1 {
+    -webkit-flex: 1 100px;
+}
+
+#flex-no-flex div {
+    -webkit-flex: 1;
+}
+.final #no-flex1 {
+    -webkit-flex: 0;
+}
+
+</style>
+  <script src=""
+  <script type="text/_javascript_">
+
+    const expectedValues = [
+      // [time, element-id, property, expected-value, tolerance]
+      [0.5, 'row1', '-webkit-flex', [2, 0, 0], .5],
+      [0.5, 'column1', '-webkit-flex', [.5, 0, 10], 3],
+      [0.5, 'negative1', '-webkit-flex', [1, .5, 75], 3],
+      [0.5, 'no-flex1', '-webkit-flex', [.5, 0, 0], .4],
+    ];
+
+    function setupTest()
+    {
+      document.body.className = 'final';
+    }
+  
+    runTransitionTest(expectedValues, setupTest, usePauseAPI);
+  </script>
+</head>
+<body>
+
+  <div id="flex-row" class='flexbox'>
+    <div id="row1"></div>
+    <div id="row2"></div>
+  </div>
+
+  <div id="flex-column" class='flexbox'>
+    <div id="column1"></div>
+    <div id="column2"></div>
+  </div>
+
+  <div id="flex-negative" class='flexbox'>
+    <div id="negative1"></div>
+    <div id="negative2"></div>
+  </div>
+
+  <div id="flex-no-flex" class='flexbox'>
+    <div id="no-flex1"></div>
+    <div id="no-flex2"></div>
+  </div>
+
+  <div id="result"></div>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (113263 => 113264)


--- trunk/Source/WebCore/ChangeLog	2012-04-04 23:54:28 UTC (rev 113263)
+++ trunk/Source/WebCore/ChangeLog	2012-04-04 23:57:33 UTC (rev 113264)
@@ -1,3 +1,22 @@
+2012-04-04  Tony Chang  <[email protected]>
+
+        CSS transitions should work on the flex property
+        https://bugs.webkit.org/show_bug.cgi?id=75915
+
+        Reviewed by Dean Jackson.
+
+        Test: transitions/flex-transitions.html
+
+        * page/animation/AnimationBase.cpp:
+        (WebCore::PropertyWrapperGetter::equals): Fix indention.
+        (PropertyWrapperFlex): Add a wrapper for -webkit-flex which has 3 values (two floats and
+        a length), but is not a shorthand.
+        (WebCore::PropertyWrapperFlex::PropertyWrapperFlex):
+        (WebCore::PropertyWrapperFlex::equals):
+        (WebCore::PropertyWrapperFlex::blend):
+        (WebCore):
+        (WebCore::AnimationBase::ensurePropertyMap):
+
 2012-04-04  Tom Sepez  <[email protected]>
 
         XSSAuditor bypass through HTTP Parameter Pollution.

Modified: trunk/Source/WebCore/page/animation/AnimationBase.cpp (113263 => 113264)


--- trunk/Source/WebCore/page/animation/AnimationBase.cpp	2012-04-04 23:54:28 UTC (rev 113263)
+++ trunk/Source/WebCore/page/animation/AnimationBase.cpp	2012-04-04 23:57:33 UTC (rev 113264)
@@ -346,11 +346,11 @@
 
     virtual bool equals(const RenderStyle* a, const RenderStyle* b) const
     {
-       // If the style pointers are the same, don't bother doing the test.
-       // If either is null, return false. If both are null, return true.
-       if ((!a && !b) || a == b)
-           return true;
-       if (!a || !b)
+        // If the style pointers are the same, don't bother doing the test.
+        // If either is null, return false. If both are null, return true.
+        if ((!a && !b) || a == b)
+            return true;
+        if (!a || !b)
             return false;
         return (a->*m_getter)() == (b->*m_getter)();
     }
@@ -865,6 +865,32 @@
     LayersAccessor m_layersAccessor;
 };
 
+class PropertyWrapperFlex : public PropertyWrapperBase {
+public:
+    PropertyWrapperFlex() : PropertyWrapperBase(CSSPropertyWebkitFlex)
+    {
+    }
+
+    virtual bool equals(const RenderStyle* a, const RenderStyle* b) const
+    {
+        // If the style pointers are the same, don't bother doing the test.
+        // If either is null, return false. If both are null, return true.
+        if ((!a && !b) || a == b)
+            return true;
+        if (!a || !b)
+            return false;
+
+        return a->flexPreferredSize() == b->flexPreferredSize() && a->positiveFlex() == b->positiveFlex() && a->negativeFlex() == b->negativeFlex();
+    }
+
+    virtual void blend(const AnimationBase* anim, RenderStyle* dst, const RenderStyle* a, const RenderStyle* b, double progress) const
+    {
+        dst->setFlexPreferredSize(blendFunc(anim, a->flexPreferredSize(), b->flexPreferredSize(), progress));
+        dst->setPositiveFlex(blendFunc(anim, a->positiveFlex(), b->positiveFlex(), progress));
+        dst->setNegativeFlex(blendFunc(anim, a->negativeFlex(), b->negativeFlex(), progress));
+    }
+};
+
 class ShorthandPropertyWrapper : public PropertyWrapperBase {
 public:
     ShorthandPropertyWrapper(CSSPropertyID property, const StylePropertyShorthand& shorthand)
@@ -990,6 +1016,8 @@
         gPropertyWrappers->append(new PropertyWrapper<Length>(CSSPropertyMinHeight, &RenderStyle::minHeight, &RenderStyle::setMinHeight));
         gPropertyWrappers->append(new PropertyWrapper<Length>(CSSPropertyMaxHeight, &RenderStyle::maxHeight, &RenderStyle::setMaxHeight));
 
+        gPropertyWrappers->append(new PropertyWrapperFlex());
+
         gPropertyWrappers->append(new PropertyWrapper<unsigned>(CSSPropertyBorderLeftWidth, &RenderStyle::borderLeftWidth, &RenderStyle::setBorderLeftWidth));
         gPropertyWrappers->append(new PropertyWrapper<unsigned>(CSSPropertyBorderRightWidth, &RenderStyle::borderRightWidth, &RenderStyle::setBorderRightWidth));
         gPropertyWrappers->append(new PropertyWrapper<unsigned>(CSSPropertyBorderTopWidth, &RenderStyle::borderTopWidth, &RenderStyle::setBorderTopWidth));
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to