changing -webkit-order should change the paint order of flex items
authortony@chromium.org <tony@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Jul 2012 07:27:44 +0000 (07:27 +0000)
committertony@chromium.org <tony@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Jul 2012 07:27:44 +0000 (07:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=92041

Reviewed by Ojan Vafai.

Source/WebCore:

Override paintChildren and use the flex order iterator to determine the order to paint the children.

Test: css3/flexbox/order-painting.html

* rendering/RenderFlexibleBox.cpp:
(WebCore::RenderFlexibleBox::layoutBlock): Save a reference to the order iterator.
(WebCore::RenderFlexibleBox::paintChildren):
* rendering/RenderFlexibleBox.h:
(RenderFlexibleBox): Hold a reference to the order iterator so we don't have to recreate it at paint time.
    Also mark all the virtual methods with OVERRIDE.

LayoutTests:

Use a ref test since this is testing paint behavior.

* css3/flexbox/order-painting-expected.html: Added.
* css3/flexbox/order-painting.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/css3/flexbox/order-painting-expected.html [new file with mode: 0644]
LayoutTests/css3/flexbox/order-painting.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderFlexibleBox.cpp
Source/WebCore/rendering/RenderFlexibleBox.h

index 0b8137e..422d07e 100644 (file)
@@ -1,3 +1,15 @@
+2012-07-27  Tony Chang  <tony@chromium.org>
+
+        changing -webkit-order should change the paint order of flex items
+        https://bugs.webkit.org/show_bug.cgi?id=92041
+
+        Reviewed by Ojan Vafai.
+
+        Use a ref test since this is testing paint behavior.
+
+        * css3/flexbox/order-painting-expected.html: Added.
+        * css3/flexbox/order-painting.html: Added.
+
 2012-07-27  Csaba Osztrogon√°c  <ossy@webkit.org>
 
         [Qt][WK2] REGRESSION(r119127): resetting window.internals settings between tests doesn't work properly
 2012-07-27  Csaba Osztrogon√°c  <ossy@webkit.org>
 
         [Qt][WK2] REGRESSION(r119127): resetting window.internals settings between tests doesn't work properly
diff --git a/LayoutTests/css3/flexbox/order-painting-expected.html b/LayoutTests/css3/flexbox/order-painting-expected.html
new file mode 100644 (file)
index 0000000..bf7bc30
--- /dev/null
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>This test passes if there is no red showing.</p>
+
+<div style="width: 100px; height: 100px; background-color: green"></div>
+</body>
+</html>
diff --git a/LayoutTests/css3/flexbox/order-painting.html b/LayoutTests/css3/flexbox/order-painting.html
new file mode 100644 (file)
index 0000000..f0c6756
--- /dev/null
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>This test passes if there is no red showing.</p>
+
+<div style="display: -webkit-flex; width: 100px;">
+    <div style="-webkit-order: 2; background-color: green; width: 100px; height: 100px; margin-left: -50px;"></div>
+    <div style="-webkit-order: 1; background-color: red;   width: 50px;  height: 100px;"></div>
+</div>
+</body>
+</html>
index 37fea8c..8a84e0b 100644 (file)
@@ -1,3 +1,21 @@
+2012-07-27  Tony Chang  <tony@chromium.org>
+
+        changing -webkit-order should change the paint order of flex items
+        https://bugs.webkit.org/show_bug.cgi?id=92041
+
+        Reviewed by Ojan Vafai.
+
+        Override paintChildren and use the flex order iterator to determine the order to paint the children.
+
+        Test: css3/flexbox/order-painting.html
+
+        * rendering/RenderFlexibleBox.cpp:
+        (WebCore::RenderFlexibleBox::layoutBlock): Save a reference to the order iterator.
+        (WebCore::RenderFlexibleBox::paintChildren):
+        * rendering/RenderFlexibleBox.h:
+        (RenderFlexibleBox): Hold a reference to the order iterator so we don't have to recreate it at paint time.
+            Also mark all the virtual methods with OVERRIDE.
+
 2012-07-26  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r123820.
 2012-07-26  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r123820.
index 87fb25f..f59906b 100644 (file)
@@ -259,12 +259,12 @@ void RenderFlexibleBox::layoutBlock(bool relayoutChildren, LayoutUnit)
     WTF::Vector<LineContext> lineContexts;
     OrderHashSet orderValues;
     computeMainAxisPreferredSizes(relayoutChildren, orderValues);
     WTF::Vector<LineContext> lineContexts;
     OrderHashSet orderValues;
     computeMainAxisPreferredSizes(relayoutChildren, orderValues);
-    OrderIterator flexIterator(this, orderValues);
-    layoutFlexItems(flexIterator, lineContexts);
+    m_orderIterator = adoptPtr(new OrderIterator(this, orderValues));
+    layoutFlexItems(*m_orderIterator, lineContexts);
 
     LayoutUnit oldClientAfterEdge = clientLogicalBottom();
     computeLogicalHeight();
 
     LayoutUnit oldClientAfterEdge = clientLogicalBottom();
     computeLogicalHeight();
-    repositionLogicalHeightDependentFlexItems(flexIterator, lineContexts, oldClientAfterEdge);
+    repositionLogicalHeightDependentFlexItems(*m_orderIterator, lineContexts, oldClientAfterEdge);
 
     if (size() != previousSize)
         relayoutChildren = true;
 
     if (size() != previousSize)
         relayoutChildren = true;
@@ -289,6 +289,16 @@ void RenderFlexibleBox::layoutBlock(bool relayoutChildren, LayoutUnit)
     setNeedsLayout(false);
 }
 
     setNeedsLayout(false);
 }
 
+void RenderFlexibleBox::paintChildren(PaintInfo& paintInfo, const LayoutPoint& paintOffset, PaintInfo& paintInfoForChild, bool usePrintRect)
+{
+    ASSERT(m_orderIterator);
+
+    for (RenderBox* child = m_orderIterator->first(); child; child = m_orderIterator->next()) {
+        if (!paintChild(child, paintInfo, paintOffset, paintInfoForChild, usePrintRect))
+            return;
+    }
+}
+
 void RenderFlexibleBox::repositionLogicalHeightDependentFlexItems(OrderIterator& iterator, WTF::Vector<LineContext>& lineContexts, LayoutUnit& oldClientAfterEdge)
 {
     LayoutUnit crossAxisStartEdge = lineContexts.isEmpty() ? ZERO_LAYOUT_UNIT : lineContexts[0].crossAxisOffset;
 void RenderFlexibleBox::repositionLogicalHeightDependentFlexItems(OrderIterator& iterator, WTF::Vector<LineContext>& lineContexts, LayoutUnit& oldClientAfterEdge)
 {
     LayoutUnit crossAxisStartEdge = lineContexts.isEmpty() ? ZERO_LAYOUT_UNIT : lineContexts[0].crossAxisOffset;
index 64b1adb..916bcae 100644 (file)
@@ -32,6 +32,7 @@
 #define RenderFlexibleBox_h
 
 #include "RenderBlock.h"
 #define RenderFlexibleBox_h
 
 #include "RenderBlock.h"
+#include <wtf/OwnPtr.h>
 
 namespace WebCore {
 
 
 namespace WebCore {
 
@@ -40,11 +41,13 @@ public:
     RenderFlexibleBox(Node*);
     virtual ~RenderFlexibleBox();
 
     RenderFlexibleBox(Node*);
     virtual ~RenderFlexibleBox();
 
-    virtual const char* renderName() const;
+    virtual const char* renderName() const OVERRIDE;
 
 
-    virtual bool isFlexibleBox() const { return true; }
-    virtual void computePreferredLogicalWidths();
-    virtual void layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight = 0);
+    virtual bool isFlexibleBox() const OVERRIDE { return true; }
+    virtual void computePreferredLogicalWidths() OVERRIDE;
+    virtual void layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight = 0) OVERRIDE;
+
+    virtual void paintChildren(PaintInfo& forSelf, const LayoutPoint&, PaintInfo& forChild, bool usePrintRect) OVERRIDE;
 
     bool isHorizontalFlow() const;
 
 
     bool isHorizontalFlow() const;
 
@@ -132,6 +135,8 @@ private:
     void applyStretchAlignmentToChild(RenderBox*, LayoutUnit lineCrossAxisExtent);
     void flipForRightToLeftColumn(OrderIterator&);
     void flipForWrapReverse(OrderIterator&, const WTF::Vector<LineContext>&, LayoutUnit crossAxisStartEdge);
     void applyStretchAlignmentToChild(RenderBox*, LayoutUnit lineCrossAxisExtent);
     void flipForRightToLeftColumn(OrderIterator&);
     void flipForWrapReverse(OrderIterator&, const WTF::Vector<LineContext>&, LayoutUnit crossAxisStartEdge);
+
+    OwnPtr<OrderIterator> m_orderIterator;
 };
 
 } // namespace WebCore
 };
 
 } // namespace WebCore