Title: [130951] branches/chromium/1271
Revision
130951
Author
o...@chromium.org
Date
2012-10-10 13:38:55 -0700 (Wed, 10 Oct 2012)

Log Message

Merge 130549 - Deprecated flexboxes subtract scrollbar width/height twice
https://bugs.webkit.org/show_bug.cgi?id=98552

Reviewed by Tony Chang.

Source/WebCore:

This is a regression from http://trac.webkit.org/changeset/119507.
The problem is that contentHeight subtracts the scrollbar and
RenderDeprecatedFlexbox subtracts the scrollbar.

-Make it so that we only access override sizes if one has been set.
I think this makes the calling code more clear.
-If we don't have one set, grab the height/width - borderAndPadding.
-Add a FIXME to change this all back to being borderbox sizes.
There's something trick with making table padding/border work right for that
though (noted in the original patch).

Test: fast/flexbox/flexing-overflow-scroll-item.html

* rendering/RenderBox.cpp:
(WebCore::RenderBox::overrideLogicalContentWidth):
(WebCore::RenderBox::overrideLogicalContentHeight):
(WebCore::RenderBox::availableLogicalHeightUsing):
* rendering/RenderBox.h:
(RenderBox):
* rendering/RenderDeprecatedFlexibleBox.cpp:
(WebCore::contentWidthForChild):
(WebCore):
(WebCore::contentHeightForChild):
(WebCore::RenderDeprecatedFlexibleBox::layoutHorizontalBox):
(WebCore::RenderDeprecatedFlexibleBox::layoutVerticalBox):
(WebCore::RenderDeprecatedFlexibleBox::allowedChildFlex):

LayoutTests:

* fast/flexbox/flexing-overflow-scroll-item-expected.txt: Added.
* fast/flexbox/flexing-overflow-scroll-item.html: Added.

TBR=o...@chromium.org
Review URL: https://codereview.chromium.org/11017062

Modified Paths

Added Paths

Diff

Copied: branches/chromium/1271/LayoutTests/fast/flexbox/flexing-overflow-scroll-item-expected.txt (from rev 130549, trunk/LayoutTests/fast/flexbox/flexing-overflow-scroll-item-expected.txt) (0 => 130951)


--- branches/chromium/1271/LayoutTests/fast/flexbox/flexing-overflow-scroll-item-expected.txt	                        (rev 0)
+++ branches/chromium/1271/LayoutTests/fast/flexbox/flexing-overflow-scroll-item-expected.txt	2012-10-10 20:38:55 UTC (rev 130951)
@@ -0,0 +1,2 @@
+PASS
+PASS

Copied: branches/chromium/1271/LayoutTests/fast/flexbox/flexing-overflow-scroll-item.html (from rev 130549, trunk/LayoutTests/fast/flexbox/flexing-overflow-scroll-item.html) (0 => 130951)


--- branches/chromium/1271/LayoutTests/fast/flexbox/flexing-overflow-scroll-item.html	                        (rev 0)
+++ branches/chromium/1271/LayoutTests/fast/flexbox/flexing-overflow-scroll-item.html	2012-10-10 20:38:55 UTC (rev 130951)
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<div id="flexbox" style="display: -webkit-box; height: 100px; width: 200px;">
+    <div style="overflow: scroll; -webkit-box-flex: 1;" data-expected-width=200 data-expected-height=100></div>
+</div>
+
+<div id="flexbox" style="display: -webkit-box; height: 100px; width: 200px; -webkit-box-orient: vertical;">
+    <div style="overflow: scroll; -webkit-box-flex: 1;" data-expected-width=200 data-expected-height=100></div>
+</div>
+
+<script src=""
+<script>
+if (window.testRunner)
+    testRunner.dumpAsText();
+checkLayout('#flexbox');
+</script>
\ No newline at end of file

Modified: branches/chromium/1271/Source/WebCore/rendering/RenderBox.cpp (130950 => 130951)


--- branches/chromium/1271/Source/WebCore/rendering/RenderBox.cpp	2012-10-10 20:33:44 UTC (rev 130950)
+++ branches/chromium/1271/Source/WebCore/rendering/RenderBox.cpp	2012-10-10 20:38:55 UTC (rev 130951)
@@ -708,14 +708,14 @@
 
 LayoutUnit RenderBox::overrideLogicalContentWidth() const
 {
-    // FIXME: This should probably be returning contentLogicalWidth instead of contentWidth.
-    return hasOverrideWidth() ? gOverrideWidthMap->get(this) : contentWidth();
+    ASSERT(hasOverrideWidth());
+    return gOverrideWidthMap->get(this);
 }
 
 LayoutUnit RenderBox::overrideLogicalContentHeight() const
 {
-    // FIXME: This should probably be returning contentLogicalHeight instead of contentHeight.
-    return hasOverrideHeight() ? gOverrideHeightMap->get(this) : contentHeight();
+    ASSERT(hasOverrideHeight());
+    return gOverrideHeightMap->get(this);
 }
 
 LayoutUnit RenderBox::adjustBorderBoxLogicalWidthForBoxSizing(LayoutUnit width) const
@@ -2341,8 +2341,11 @@
     // We need to stop here, since we don't want to increase the height of the table
     // artificially.  We're going to rely on this cell getting expanded to some new
     // height, and then when we lay out again we'll use the calculation below.
-    if (isTableCell() && (h.isAuto() || h.isPercent()))
-        return overrideLogicalContentHeight();
+    if (isTableCell() && (h.isAuto() || h.isPercent())) {
+        if (hasOverrideHeight())
+            return overrideLogicalContentHeight();
+        return logicalHeight() - borderAndPaddingLogicalHeight();
+    }
 
     if (h.isPercent() && isOutOfFlowPositioned()) {
         // FIXME: This is wrong if the containingBlock has a perpendicular writing mode.

Modified: branches/chromium/1271/Source/WebCore/rendering/RenderBox.h (130950 => 130951)


--- branches/chromium/1271/Source/WebCore/rendering/RenderBox.h	2012-10-10 20:33:44 UTC (rev 130950)
+++ branches/chromium/1271/Source/WebCore/rendering/RenderBox.h	2012-10-10 20:38:55 UTC (rev 130951)
@@ -289,6 +289,10 @@
     virtual LayoutUnit minPreferredLogicalWidth() const;
     virtual LayoutUnit maxPreferredLogicalWidth() const;
 
+    // FIXME: We should rename these back to overrideLogicalHeight/Width and have them store
+    // the border-box height/width like the regular height/width accessors on RenderBox.
+    // Right now, these are different than contentHeight/contentWidth because they still
+    // include the scrollbar height/width.
     LayoutUnit overrideLogicalContentWidth() const;
     LayoutUnit overrideLogicalContentHeight() const;
     bool hasOverrideHeight() const;

Modified: branches/chromium/1271/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp (130950 => 130951)


--- branches/chromium/1271/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp	2012-10-10 20:33:44 UTC (rev 130950)
+++ branches/chromium/1271/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp	2012-10-10 20:38:55 UTC (rev 130951)
@@ -151,6 +151,20 @@
     return child->isOutOfFlowPositioned() || child->style()->visibility() == COLLAPSE;
 }
 
+static LayoutUnit contentWidthForChild(RenderBox* child)
+{
+    if (child->hasOverrideWidth())
+        return child->overrideLogicalContentWidth();
+    return child->logicalWidth() - child->borderAndPaddingLogicalWidth();
+}
+
+static LayoutUnit contentHeightForChild(RenderBox* child)
+{
+    if (child->hasOverrideHeight())
+        return child->overrideLogicalContentHeight();
+    return child->logicalHeight() - child->borderAndPaddingLogicalHeight();
+}
+
 void RenderDeprecatedFlexibleBox::styleWillChange(StyleDifference diff, const RenderStyle* newStyle)
 {
     RenderStyle* oldStyle = style();
@@ -538,7 +552,7 @@
                         if (allowedChildFlex(child, expanding, i)) {
                             LayoutUnit spaceAdd = LayoutUnit(spaceAvailableThisPass * (child->style()->boxFlex() / totalFlex));
                             if (spaceAdd) {
-                                child->setOverrideLogicalContentWidth(child->overrideLogicalContentWidth() + spaceAdd);
+                                child->setOverrideLogicalContentWidth(contentWidthForChild(child) + spaceAdd);
                                 flexingChildren = true;
                                 relayoutChildren = true;
                             }
@@ -555,7 +569,7 @@
                         LayoutUnit spaceAdd = groupRemainingSpace > 0 ? 1 : -1;
                         for (RenderBox* child = iterator.first(); child && groupRemainingSpace; child = iterator.next()) {
                             if (allowedChildFlex(child, expanding, i)) {
-                                child->setOverrideLogicalContentWidth(child->overrideLogicalContentWidth() + spaceAdd);
+                                child->setOverrideLogicalContentWidth(contentWidthForChild(child) + spaceAdd);
                                 flexingChildren = true;
                                 relayoutChildren = true;
                                 remainingSpace -= spaceAdd;
@@ -789,7 +803,7 @@
                         if (allowedChildFlex(child, expanding, i)) {
                             LayoutUnit spaceAdd = static_cast<LayoutUnit>(spaceAvailableThisPass * (child->style()->boxFlex() / totalFlex));
                             if (spaceAdd) {
-                                child->setOverrideLogicalContentHeight(child->overrideLogicalContentHeight() + spaceAdd);
+                                child->setOverrideLogicalContentHeight(contentHeightForChild(child) + spaceAdd);
                                 flexingChildren = true;
                                 relayoutChildren = true;
                             }
@@ -806,7 +820,7 @@
                         LayoutUnit spaceAdd = groupRemainingSpace > 0 ? 1 : -1;
                         for (RenderBox* child = iterator.first(); child && groupRemainingSpace; child = iterator.next()) {
                             if (allowedChildFlex(child, expanding, i)) {
-                                child->setOverrideLogicalContentHeight(child->overrideLogicalContentHeight() + spaceAdd);
+                                child->setOverrideLogicalContentHeight(contentHeightForChild(child) + spaceAdd);
                                 flexingChildren = true;
                                 relayoutChildren = true;
                                 remainingSpace -= spaceAdd;
@@ -1019,7 +1033,7 @@
         if (isHorizontal()) {
             // FIXME: For now just handle fixed values.
             LayoutUnit maxWidth = MAX_LAYOUT_UNIT;
-            LayoutUnit width = child->overrideLogicalContentWidth();
+            LayoutUnit width = contentWidthForChild(child);
             if (!child->style()->maxWidth().isUndefined() && child->style()->maxWidth().isFixed())
                 maxWidth = child->style()->maxWidth().value();
             else if (child->style()->maxWidth().type() == Intrinsic)
@@ -1032,7 +1046,7 @@
         } else {
             // FIXME: For now just handle fixed values.
             LayoutUnit maxHeight = MAX_LAYOUT_UNIT;
-            LayoutUnit height = child->overrideLogicalContentHeight();
+            LayoutUnit height = contentHeightForChild(child);
             if (!child->style()->maxHeight().isUndefined() && child->style()->maxHeight().isFixed())
                 maxHeight = child->style()->maxHeight().value();
             if (maxHeight == MAX_LAYOUT_UNIT)
@@ -1044,7 +1058,7 @@
     // FIXME: For now just handle fixed values.
     if (isHorizontal()) {
         LayoutUnit minWidth = child->minPreferredLogicalWidth();
-        LayoutUnit width = child->overrideLogicalContentWidth();
+        LayoutUnit width = contentWidthForChild(child);
         if (child->style()->minWidth().isFixed())
             minWidth = child->style()->minWidth().value();
         else if (child->style()->minWidth().type() == Intrinsic)
@@ -1060,7 +1074,7 @@
         Length minHeight = child->style()->minHeight();
         if (minHeight.isFixed() || minHeight.isAuto()) {
             LayoutUnit minHeight = child->style()->minHeight().value();
-            LayoutUnit height = child->overrideLogicalContentHeight();
+            LayoutUnit height = contentHeightForChild(child);
             LayoutUnit allowedShrinkage = min<LayoutUnit>(0, minHeight - height);
             return allowedShrinkage;
         }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to