Title: [95591] trunk/Source/WebCore
Revision
95591
Author
o...@chromium.org
Date
2011-09-20 18:30:06 -0700 (Tue, 20 Sep 2011)

Log Message

[css3-flexbox] cleanup padding width calculations
https://bugs.webkit.org/show_bug.cgi?id=68490

Reviewed by Tony Chang.

No new tests. Existing tests cover the refactor.

* rendering/RenderFlexibleBox.cpp:
(WebCore::RenderFlexibleBox::logicalBorderAndPaddingWidthForChild):
(WebCore::RenderFlexibleBox::logicalScrollbarHeightForChild):
(WebCore::RenderFlexibleBox::preferredLogicalContentWidthForFlexItem):
(WebCore::RenderFlexibleBox::computePreferredLogicalWidth):
(WebCore::RenderFlexibleBox::layoutAndPlaceChildrenInlineDirection):
* rendering/RenderFlexibleBox.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (95590 => 95591)


--- trunk/Source/WebCore/ChangeLog	2011-09-21 01:07:43 UTC (rev 95590)
+++ trunk/Source/WebCore/ChangeLog	2011-09-21 01:30:06 UTC (rev 95591)
@@ -1,3 +1,20 @@
+2011-09-20  Ojan Vafai  <o...@chromium.org>
+
+        [css3-flexbox] cleanup padding width calculations
+        https://bugs.webkit.org/show_bug.cgi?id=68490
+
+        Reviewed by Tony Chang.
+
+        No new tests. Existing tests cover the refactor.
+
+        * rendering/RenderFlexibleBox.cpp:
+        (WebCore::RenderFlexibleBox::logicalBorderAndPaddingWidthForChild):
+        (WebCore::RenderFlexibleBox::logicalScrollbarHeightForChild):
+        (WebCore::RenderFlexibleBox::preferredLogicalContentWidthForFlexItem):
+        (WebCore::RenderFlexibleBox::computePreferredLogicalWidth):
+        (WebCore::RenderFlexibleBox::layoutAndPlaceChildrenInlineDirection):
+        * rendering/RenderFlexibleBox.h:
+
 2011-09-19  Jer Noble  <jer.no...@apple.com>
 
         Fix clang compile errors in Web Audio

Modified: trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp (95590 => 95591)


--- trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp	2011-09-21 01:07:43 UTC (rev 95590)
+++ trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp	2011-09-21 01:30:06 UTC (rev 95591)
@@ -113,25 +113,14 @@
     setNeedsLayout(false);
 }
 
-LayoutUnit RenderFlexibleBox::logicalBorderWidthForChild(RenderBox* child)
+LayoutUnit RenderFlexibleBox::logicalBorderAndPaddingWidthForChild(RenderBox* child)
 {
-    if (isHorizontalWritingMode())
-        return child->borderLeft() + child->borderRight();
-    return child->borderTop() + child->borderBottom();
+    return isHorizontalWritingMode() ? child->borderAndPaddingWidth() : child->borderAndPaddingHeight();
 }
 
-LayoutUnit RenderFlexibleBox::logicalPaddingWidthForChild(RenderBox* child)
-{
-    if (isHorizontalWritingMode())
-        return child->paddingLeft() + child->paddingRight();
-    return child->paddingTop() + child->paddingBottom();
-}
-
 LayoutUnit RenderFlexibleBox::logicalScrollbarHeightForChild(RenderBox* child)
 {
-    if (isHorizontalWritingMode())
-        return child->horizontalScrollbarHeight();
-    return child->verticalScrollbarWidth();
+    return isHorizontalWritingMode() ? child->verticalScrollbarWidth() : child->horizontalScrollbarHeight();
 }
 
 Length RenderFlexibleBox::marginStartStyleForChild(RenderBox* child)
@@ -153,7 +142,7 @@
     Length width = isHorizontalWritingMode() ? child->style()->width() : child->style()->height();
     if (width.isAuto()) {
         LayoutUnit logicalWidth = isHorizontalWritingMode() == child->isHorizontalWritingMode() ? child->maxPreferredLogicalWidth() : child->logicalHeight();
-        return logicalWidth - logicalBorderWidthForChild(child) - logicalScrollbarHeightForChild(child) - logicalPaddingWidthForChild(child);
+        return logicalWidth - logicalBorderAndPaddingWidthForChild(child) - logicalScrollbarHeightForChild(child);
     }
     return isHorizontalWritingMode() ? child->contentWidth() : child->contentHeight();
 }
@@ -204,16 +193,13 @@
             child->setChildNeedsLayout(true);
         child->layoutIfNeeded();
 
+        // We can't just use marginStartForChild, et. al. because "auto" needs to be treated as 0.
         if (isHorizontalWritingMode()) {
             preferredLogicalWidth += child->style()->marginLeft().calcMinValue(flexboxAvailableLogicalWidth);
             preferredLogicalWidth += child->style()->marginRight().calcMinValue(flexboxAvailableLogicalWidth);
-            preferredLogicalWidth += child->style()->paddingLeft().calcMinValue(flexboxAvailableLogicalWidth);
-            preferredLogicalWidth += child->style()->paddingRight().calcMinValue(flexboxAvailableLogicalWidth);
         } else {
             preferredLogicalWidth += child->style()->marginTop().calcMinValue(flexboxAvailableLogicalWidth);
             preferredLogicalWidth += child->style()->marginBottom().calcMinValue(flexboxAvailableLogicalWidth);
-            preferredLogicalWidth += child->style()->paddingTop().calcMinValue(flexboxAvailableLogicalWidth);
-            preferredLogicalWidth += child->style()->paddingBottom().calcMinValue(flexboxAvailableLogicalWidth);
         }
 
         if (marginStartStyleForChild(child).isAuto())
@@ -221,7 +207,7 @@
         if (marginEndStyleForChild(child).isAuto())
             totalPositiveFlexibility += 1;
 
-        preferredLogicalWidth += logicalBorderWidthForChild(child);
+        preferredLogicalWidth += logicalBorderAndPaddingWidthForChild(child);
         preferredLogicalWidth += preferredLogicalContentWidthForFlexItem(child);
 
         totalPositiveFlexibility += logicalPositiveFlexForChild(child);
@@ -305,7 +291,7 @@
     size_t i = 0;
     for (RenderBox* child = iterator.first(); child; child = iterator.next(), ++i) {
         // FIXME: Does this need to take the scrollbar width into account?
-        LayoutUnit childPreferredSize = childSizes[i] + logicalBorderWidthForChild(child) + logicalPaddingWidthForChild(child);
+        LayoutUnit childPreferredSize = childSizes[i] + logicalBorderAndPaddingWidthForChild(child);
         setLogicalOverrideSize(child, childPreferredSize);
         child->setChildNeedsLayout(true);
         child->layoutIfNeeded();

Modified: trunk/Source/WebCore/rendering/RenderFlexibleBox.h (95590 => 95591)


--- trunk/Source/WebCore/rendering/RenderFlexibleBox.h	2011-09-21 01:07:43 UTC (rev 95590)
+++ trunk/Source/WebCore/rendering/RenderFlexibleBox.h	2011-09-21 01:30:06 UTC (rev 95591)
@@ -52,8 +52,7 @@
     class FlexibleBoxIterator;
     typedef WTF::HashMap<const RenderBox*, LayoutUnit> InflexibleFlexItemSize;
 
-    LayoutUnit logicalBorderWidthForChild(RenderBox* child);
-    LayoutUnit logicalPaddingWidthForChild(RenderBox* child);
+    LayoutUnit logicalBorderAndPaddingWidthForChild(RenderBox* child);
     LayoutUnit logicalScrollbarHeightForChild(RenderBox* child);
     Length marginStartStyleForChild(RenderBox* child);
     Length marginEndStyleForChild(RenderBox* child);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to