2011-05-11 Emil A Eklund <eae@chromium.org>
authoreae@chromium.org <eae@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 May 2011 07:11:18 +0000 (07:11 +0000)
committereae@chromium.org <eae@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 May 2011 07:11:18 +0000 (07:11 +0000)
        Reviewed by Eric Seidel.

        Convert RenderFlexibleBox to use IntPoint/IntSize instead of x,y/w,h pairs
        https://bugs.webkit.org/show_bug.cgi?id=60592

        Refactoring, covered by existing tests.

        * rendering/RenderFlexibleBox.cpp:
        (WebCore::RenderFlexibleBox::layoutBlock):
        (WebCore::RenderFlexibleBox::layoutHorizontalBox):
        (WebCore::RenderFlexibleBox::layoutVerticalBox):
        (WebCore::RenderFlexibleBox::placeChild):
        * rendering/RenderFlexibleBox.h:

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

Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderFlexibleBox.cpp
Source/WebCore/rendering/RenderFlexibleBox.h

index 18cb1f8..7f7170e 100644 (file)
@@ -1,3 +1,19 @@
+2011-05-11  Emil A Eklund  <eae@chromium.org>
+
+        Reviewed by Eric Seidel.
+
+        Convert RenderFlexibleBox to use IntPoint/IntSize instead of x,y/w,h pairs
+        https://bugs.webkit.org/show_bug.cgi?id=60592
+
+        Refactoring, covered by existing tests.
+
+        * rendering/RenderFlexibleBox.cpp:
+        (WebCore::RenderFlexibleBox::layoutBlock):
+        (WebCore::RenderFlexibleBox::layoutHorizontalBox):
+        (WebCore::RenderFlexibleBox::layoutVerticalBox):
+        (WebCore::RenderFlexibleBox::placeChild):
+        * rendering/RenderFlexibleBox.h:
+
 2011-05-10  Ilya Tikhonovsky  <loislo@chromium.org>
 
         Unreviewed buildfix for strict OwnPtr.
index 667f3f0..900a130 100644 (file)
@@ -209,17 +209,16 @@ void RenderFlexibleBox::layoutBlock(bool relayoutChildren, int /*pageHeight FIXM
     LayoutRepainter repainter(*this, checkForRepaintDuringLayout());
     LayoutStateMaintainer statePusher(view(), this, IntSize(x(), y()), hasTransform() || hasReflection() || style()->isFlippedBlocksWritingMode());
 
-    int previousWidth = width();
-    int previousHeight = height();
+    IntSize previousSize = size();
 
     computeLogicalWidth();
     computeLogicalHeight();
 
     m_overflow.clear();
 
-    if (previousWidth != width() || previousHeight != height() ||
-        (parent()->isFlexibleBox() && parent()->style()->boxOrient() == HORIZONTAL &&
-         parent()->style()->boxAlign() == BSTRETCH))
+    if (previousSize != size()
+        || (parent()->isFlexibleBox() && parent()->style()->boxOrient() == HORIZONTAL
+        && parent()->style()->boxAlign() == BSTRETCH))
         relayoutChildren = true;
 
     setHeight(0);
@@ -244,7 +243,7 @@ void RenderFlexibleBox::layoutBlock(bool relayoutChildren, int /*pageHeight FIXM
     int oldClientAfterEdge = clientLogicalBottom();
     computeLogicalHeight();
 
-    if (previousHeight != height())
+    if (previousSize.height() != height())
         relayoutChildren = true;
 
     layoutPositionedObjects(relayoutChildren || isRoot());
@@ -442,7 +441,7 @@ void RenderFlexibleBox::layoutHorizontalBox(bool relayoutChildren)
                     break;
             }
 
-            placeChild(child, xPos, childY);
+            placeChild(child, IntPoint(xPos, childY));
 
             xPos += child->width() + child->marginRight();
         }
@@ -567,7 +566,7 @@ void RenderFlexibleBox::layoutHorizontalBox(bool relayoutChildren)
                     remainingSpace -= (remainingSpace/totalChildren);
                     --totalChildren;
 
-                    placeChild(child, child->x() + offset, child->y());
+                    placeChild(child, child->location() + IntSize(offset, 0));
                 }
             }
         } else {
@@ -579,7 +578,7 @@ void RenderFlexibleBox::layoutHorizontalBox(bool relayoutChildren)
                 if (child->isPositioned())
                     continue;
 
-                placeChild(child, child->x() + offset, child->y());
+                placeChild(child, child->location() + IntSize(offset, 0));
             }
         }
     }
@@ -672,7 +671,7 @@ void RenderFlexibleBox::layoutVerticalBox(bool relayoutChildren)
             }
 
             // Place the child.
-            placeChild(child, childX, height());
+            placeChild(child, IntPoint(childX, height()));
             setHeight(height() + child->height() + child->marginBottom());
         }
 
@@ -810,7 +809,7 @@ void RenderFlexibleBox::layoutVerticalBox(bool relayoutChildren)
                     offset += remainingSpace/totalChildren;
                     remainingSpace -= (remainingSpace/totalChildren);
                     --totalChildren;
-                    placeChild(child, child->x(), child->y() + offset);
+                    placeChild(child, child->location() + IntSize(0, offset));
                 }
             }
         } else {
@@ -821,7 +820,7 @@ void RenderFlexibleBox::layoutVerticalBox(bool relayoutChildren)
             for (RenderBox* child = iterator.first(); child; child = iterator.next()) {
                 if (child->isPositioned())
                     continue;
-                placeChild(child, child->x(), child->y() + offset);
+                placeChild(child, child->location() + IntSize(0, offset));
             }
         }
     }
@@ -934,12 +933,12 @@ void RenderFlexibleBox::applyLineClamp(FlexBoxIterator& iterator, bool relayoutC
     }
 }
 
-void RenderFlexibleBox::placeChild(RenderBox* child, int x, int y)
+void RenderFlexibleBox::placeChild(RenderBox* child, IntPoint location)
 {
-    IntRect oldRect(child->x(), child->y() , child->width(), child->height());
+    IntRect oldRect = child->frameRect();
 
     // Place the child.
-    child->setLocation(x, y);
+    child->setLocation(location);
 
     // If the child moved, we have to repaint it as well as any floating/positioned
     // descendants.  An exception is if we need a layout.  In this case, we know we're going to
index 8525c29..f4f57d2 100644 (file)
@@ -50,7 +50,7 @@ public:
     virtual bool isFlexingChildren() const { return m_flexingChildren; }
     virtual bool isStretchingChildren() const { return m_stretchingChildren; }
 
-    void placeChild(RenderBox* child, int x, int y);
+    void placeChild(RenderBox* child, IntPoint location);
 
 protected:
     int allowedChildFlex(RenderBox* child, bool expanding, unsigned group);