Title: [138668] trunk
Revision
138668
Author
commit-qu...@webkit.org
Date
2013-01-02 15:54:21 -0800 (Wed, 02 Jan 2013)

Log Message

When a block's height is determined by min-height/max-height, children with percentage heights are sized incorrectly
https://bugs.webkit.org/show_bug.cgi?id=26559

Patch by Bem Jones-Bey <bjone...@adobe.com> on 2013-01-02
Reviewed by Tony Chang.

Source/WebCore:

Percentage logical height computation now takes into account the min and max height of the container.

Test: fast/block/min-max-height-percent-height-child.html

* rendering/RenderBox.cpp:
(WebCore::RenderBox::constrainContentBoxLogicalHeightByMinMax): Added. Like constrainLogicalHeightByMinMax,
    but constrains the content box instead of the border box.
(WebCore):
(WebCore::RenderBox::computeContentLogicalHeight): Make const so it can be called from the const method
    constrainContentBoxLogicalHeightByMinMax.
(WebCore::RenderBox::computePercentageLogicalHeight): Use constrainContentBoxLogicalHeightByMinMax to properly
    respect min and max height on the containing box when computing the percentage height.
* rendering/RenderBox.h:
(RenderBox):

LayoutTests:

Add tests to ensure percent heights are correctly determined.

* fast/block/min-max-height-percent-height-child-expected.txt: Added.
* fast/block/min-max-height-percent-height-child.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (138667 => 138668)


--- trunk/LayoutTests/ChangeLog	2013-01-02 23:51:20 UTC (rev 138667)
+++ trunk/LayoutTests/ChangeLog	2013-01-02 23:54:21 UTC (rev 138668)
@@ -1,3 +1,15 @@
+2013-01-02  Bem Jones-Bey  <bjone...@adobe.com>
+
+        When a block's height is determined by min-height/max-height, children with percentage heights are sized incorrectly
+        https://bugs.webkit.org/show_bug.cgi?id=26559
+
+        Reviewed by Tony Chang.
+
+        Add tests to ensure percent heights are correctly determined.
+
+        * fast/block/min-max-height-percent-height-child-expected.txt: Added.
+        * fast/block/min-max-height-percent-height-child.html: Added.
+
 2013-01-02  Ryosuke Niwa  <rn...@webkit.org>
 
         Add a failing test expectation to a test added by r136697.

Added: trunk/LayoutTests/fast/block/min-max-height-percent-height-child-expected.txt (0 => 138668)


--- trunk/LayoutTests/fast/block/min-max-height-percent-height-child-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/block/min-max-height-percent-height-child-expected.txt	2013-01-02 23:54:21 UTC (rev 138668)
@@ -0,0 +1,57 @@
+Bug 26559: When a block's height is determined by min-height/max-height, children with percentage heights are sized incorrectly
+
+Tests to make sure a child with percentage height is computed properly when the parent has a max or min height set.
+
+Each of the following tests should display a green rectangle with a 1 pixel red border on all sides.
+
+Parent with fixed height and min set
+
+PASS
+Parent with fixed height and max set
+
+PASS
+Parent with fixed height and min greater than max
+
+PASS
+Vertical parent with fixed width and max set
+
+PASS
+Vertical parent with fixed width and min set
+
+PASS
+Parent with percent height and a max set
+
+PASS
+Parent with percent height and a min set
+
+PASS
+Parent with fixed height and percentage max
+
+PASS
+Parent with fixed height and percentage min
+
+PASS
+Parent with auto height and a max set. This test will not have the border all around, it will only be on the top portion.
+
+XXXXX XXXXX XXXXX XXXXX XXXXX XXXXX XXXXX XXXXX
+PASS
+Parent with auto height and a min set
+
+XXXXX XXXXX XXXXX XXXXX XXXXX XXXXX XXXXX XXXXX
+PASS
+The following two tests will have a 6 pixel red border.
+
+Parent with fixed height and padding and max set
+
+PASS
+Parent with fixed height and padding and min set
+
+PASS
+Fixed height parent with scroll bar
+
+XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX
+PASS
+Parent with percent height and scroll bar
+
+XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX
+PASS

Added: trunk/LayoutTests/fast/block/min-max-height-percent-height-child.html (0 => 138668)


--- trunk/LayoutTests/fast/block/min-max-height-percent-height-child.html	                        (rev 0)
+++ trunk/LayoutTests/fast/block/min-max-height-percent-height-child.html	2013-01-02 23:54:21 UTC (rev 138668)
@@ -0,0 +1,136 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <style id="stylesheet">
+            .container {
+                width: 50px;
+                height: 50px;
+            }
+            .bottom-margin {
+                margin-bottom: 50px;
+            }
+            .ahem {
+                font: 10px/1 Ahem, sans-serif;
+                color: green;
+            }
+            .parent {
+                background-color: red;
+                border: 1px solid red;
+            }
+            .child {
+                background-color: green;
+            }
+            .vertical { -webkit-writing-mode: vertical-lr; }
+        </style>
+        <script src=""
+        <script>
+            window._onload_ = function () {
+                checkLayout(".parent");
+            }
+        </script>
+    </head>
+    <body>
+        <h1><a href="" 26559</a>: When a block's height is determined by min-height/max-height, children with percentage heights are sized incorrectly</h1>
+        <h1>Tests to make sure a child with percentage height is computed properly when the parent has a max or min height set.</h1>
+        <h2>Each of the following tests should display a green rectangle with a 1 pixel red border on all sides.</h2>
+        <h3>Parent with fixed height and min set</h2>
+        <div id="simple-min" class="parent" style="width: 50px; height: 50px; min-height: 75px">
+            <div class="child" style="width: 100%; height: 100%" data-expected-width="50px" data-expected-height="75px"></div>
+        </div>
+        <h3>Parent with fixed height and max set</h2>
+        <div id="simple-max" class="parent" style="max-height: 25px; width: 50px; height: 50px">
+            <div class="child" style="width: 100%; height: 100%" data-expected-width="50px" data-expected-height="25px"></div>
+        </div>
+        <h3>Parent with fixed height and min greater than max</h2>
+        <div id="min-greater-max" class="parent" style="width: 50px; height: 50px; min-height: 75px; max-height: 25px">
+            <div class="child" style="width: 100%; height: 100%" data-expected-width="50px" data-expected-height="75px"></div>
+        </div>
+        <h3>Vertical parent with fixed width and max set</h2>
+        <div id="vertical-max" class="parent" style="width: 50px; max-width: 25px; height: 50px">
+            <div class="child" style="width: 100%; height: 100%" data-expected-width="25px" data-expected-height="50px"></div>
+        </div>
+        <h3>Vertical parent with fixed width and min set</h2>
+        <div id="vertical-min" class="parent" style="width: 50px; min-width: 75px; height: 50px">
+            <div class="child" style="width: 100%; height: 100%" data-expected-width="75px" data-expected-height="50px"></div>
+        </div>
+        <h3>Parent with percent height and a max set</h3>
+        <div class="container bottom-margin">
+            <div id="parent-percent-max" class="parent" style="max-height: 25px; width: 50px; height: 100%">
+                <div class="child" style="width: 100%; height: 100%" data-expected-width="50px" data-expected-height="25px"></div>
+            </div>
+        </div>
+        <h3>Parent with percent height and a min set</h3>
+        <div class="container bottom-margin">
+            <div id="parent-percent-min" class="parent" style="width: 50px; height: 100%; min-height: 75px">
+                <div class="child" style="width: 100%; height: 100%" data-expected-width="50px" data-expected-height="75px"></div>
+            </div>
+        </div>
+        <h3>Parent with fixed height and percentage max</h3>
+        <div class="container">
+            <div id="percent-max" class="parent" style="max-height: 50%; width: 50px; height: 50px">
+                <div class="child" style="width: 100%; height: 100%" data-expected-width="50px" data-expected-height="25px"></div>
+            </div>
+        </div>
+        <h3>Parent with fixed height and percentage min</h3>
+        <div class="container bottom-margin">
+            <div id="percent-min" class="parent" style="width: 50px; height: 50px; min-height: 150%">
+                <div class="child" style="width: 100%; height: 100%" data-expected-width="50px" data-expected-height="75px"></div>
+            </div>
+        </div>
+        <h3>Parent with auto height and a max set. This test will not have the border all around, it will only be on the top portion.</h3>
+        <div id="auto-max" class="parent ahem bottom-margin" style="max-height: 25px; width: 50px">
+            <div class="child" style="width: 100%; height: 100%" data-expected-width="50px" data-expected-height="0px"></div>
+            XXXXX
+            XXXXX
+            XXXXX
+            XXXXX
+            XXXXX
+            XXXXX
+            XXXXX
+            XXXXX
+        </div>
+        <h3>Parent with auto height and a min set</h3>
+        <div id="auto-min" class="parent ahem" style="width: 50px; min-height: 75px">
+            <div class="child" style="width: 100%; height: 100%" data-expected-width="50px" data-expected-height="0px"></div>
+            XXXXX
+            XXXXX
+            XXXXX
+            XXXXX
+            XXXXX
+            XXXXX
+            XXXXX
+            XXXXX
+        </div>
+        <h2>The following two tests will have a 6 pixel red border.</h2>
+        <h3>Parent with fixed height and padding and max set</h2>
+        <div id="parent-padding-max" class="parent" style="max-height: 25px; width: 50px; padding: 5px; height: 50px">
+            <div class="child" style="width: 100%; height: 100%" data-expected-width="50px" data-expected-height="25px"></div>
+        </div>
+        <h3>Parent with fixed height and padding and min set</h2>
+        <div id="parent-padding-min" class="parent" style="width: 50px; padding: 5px; height: 50px; min-height: 75px">
+            <div class="child" style="width: 100%; height: 100%" data-expected-width="50px" data-expected-height="75px"></div>
+        </div>
+        <h3>Fixed height parent with scroll bar</h3>
+        <div id="overflow" class="parent ahem" style="overflow: scroll; min-height: 75px; width: 50px; height: 50px">
+            <div class="child" style="width: 100%; height: 100%" data-expected-width="35px" data-expected-height="60px"></div>
+            XXXXXXXXXX
+            XXXXXXXXXX
+            XXXXXXXXXX
+            XXXXXXXXXX
+            XXXXXXXXXX
+            XXXXXXXXXX
+        </div>
+        <h3>Parent with percent height and scroll bar</h3>
+        <div class="container bottom-margin">
+            <div id="overflow-percent" class="parent ahem" style="overflow: scroll; min-height: 75px; width: 50px; height: 100%">
+                <div class="child" style="width: 100%; height: 100%" data-expected-width="35px" data-expected-height="60px"></div>
+                XXXXXXXXXX
+                XXXXXXXXXX
+                XXXXXXXXXX
+                XXXXXXXXXX
+                XXXXXXXXXX
+                XXXXXXXXXX
+            </div>
+        </div>
+    </body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (138667 => 138668)


--- trunk/Source/WebCore/ChangeLog	2013-01-02 23:51:20 UTC (rev 138667)
+++ trunk/Source/WebCore/ChangeLog	2013-01-02 23:54:21 UTC (rev 138668)
@@ -1,3 +1,25 @@
+2013-01-02  Bem Jones-Bey  <bjone...@adobe.com>
+
+        When a block's height is determined by min-height/max-height, children with percentage heights are sized incorrectly
+        https://bugs.webkit.org/show_bug.cgi?id=26559
+
+        Reviewed by Tony Chang.
+
+        Percentage logical height computation now takes into account the min and max height of the container.
+
+        Test: fast/block/min-max-height-percent-height-child.html
+
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::constrainContentBoxLogicalHeightByMinMax): Added. Like constrainLogicalHeightByMinMax,
+            but constrains the content box instead of the border box.
+        (WebCore):
+        (WebCore::RenderBox::computeContentLogicalHeight): Make const so it can be called from the const method
+            constrainContentBoxLogicalHeightByMinMax.
+        (WebCore::RenderBox::computePercentageLogicalHeight): Use constrainContentBoxLogicalHeightByMinMax to properly
+            respect min and max height on the containing box when computing the percentage height.
+        * rendering/RenderBox.h:
+        (RenderBox):
+
 2013-01-02  Tony Chang  <t...@chromium.org>
 
         Unreviewed, force InternalSettings.cpp to rebuild to try and fix the Apple Win build.

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (138667 => 138668)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2013-01-02 23:51:20 UTC (rev 138667)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2013-01-02 23:54:21 UTC (rev 138668)
@@ -470,6 +470,17 @@
     return max(logicalHeight, computeLogicalHeightUsing(MinSize, styleToUse->logicalMinHeight()));
 }
 
+LayoutUnit RenderBox::constrainContentBoxLogicalHeightByMinMax(LayoutUnit logicalHeight) const
+{
+    RenderStyle* styleToUse = style();
+    if (!styleToUse->logicalMaxHeight().isUndefined()) {
+        LayoutUnit maxH = computeContentLogicalHeight(MaxSize, styleToUse->logicalMaxHeight());
+        if (maxH != -1)
+            logicalHeight = min(logicalHeight, maxH);
+    }
+    return max(logicalHeight, computeContentLogicalHeight(MinSize, styleToUse->logicalMinHeight()));
+}
+
 IntRect RenderBox::absoluteContentBox() const
 {
     // This is wrong with transforms and flipped writing modes.
@@ -2298,7 +2309,7 @@
     return logicalHeight;
 }
 
-LayoutUnit RenderBox::computeContentLogicalHeight(SizeType heightType, const Length& height)
+LayoutUnit RenderBox::computeContentLogicalHeight(SizeType heightType, const Length& height) const
 {
     LayoutUnit heightIncludingScrollbar = computeContentAndScrollbarLogicalHeightUsing(heightType, height);
     if (heightIncludingScrollbar == -1)
@@ -2381,14 +2392,19 @@
             includeBorderPadding = true;
         }
     } else if (cbstyle->logicalHeight().isFixed()) {
-        LayoutUnit contentBoxHeightWithScrollbar = cb->adjustContentBoxLogicalHeightForBoxSizing(cbstyle->logicalHeight().value());
-        availableHeight = max<LayoutUnit>(0, contentBoxHeightWithScrollbar - cb->scrollbarLogicalHeight());
+        LayoutUnit contentBoxHeight = cb->adjustContentBoxLogicalHeightForBoxSizing(cbstyle->logicalHeight().value());
+        availableHeight = max<LayoutUnit>(0, cb->constrainContentBoxLogicalHeightByMinMax(contentBoxHeight - cb->scrollbarLogicalHeight()));
     } else if (cbstyle->logicalHeight().isPercent() && !isOutOfFlowPositionedWithSpecifiedHeight) {
         // We need to recur and compute the percentage height for our containing block.
         LayoutUnit heightWithScrollbar = cb->computePercentageLogicalHeight(cbstyle->logicalHeight());
         if (heightWithScrollbar != -1) {
             LayoutUnit contentBoxHeightWithScrollbar = cb->adjustContentBoxLogicalHeightForBoxSizing(heightWithScrollbar);
-            availableHeight = max<LayoutUnit>(0, contentBoxHeightWithScrollbar - cb->scrollbarLogicalHeight());
+            // We need to adjust for min/max height because this method does not
+            // handle the min/max of the current block, its caller does. So the
+            // return value from the recursive call will not have been adjusted
+            // yet.
+            LayoutUnit contentBoxHeight = cb->constrainContentBoxLogicalHeightByMinMax(contentBoxHeightWithScrollbar - cb->scrollbarLogicalHeight());
+            availableHeight = max<LayoutUnit>(0, contentBoxHeight);
         }
     } else if (cb->isRenderView() || isOutOfFlowPositionedWithSpecifiedHeight) {
         // Don't allow this to affect the block' height() member variable, since this

Modified: trunk/Source/WebCore/rendering/RenderBox.h (138667 => 138668)


--- trunk/Source/WebCore/rendering/RenderBox.h	2013-01-02 23:51:20 UTC (rev 138667)
+++ trunk/Source/WebCore/rendering/RenderBox.h	2013-01-02 23:54:21 UTC (rev 138668)
@@ -82,6 +82,7 @@
 
     LayoutUnit constrainLogicalWidthInRegionByMinMax(LayoutUnit, LayoutUnit, RenderBlock*, RenderRegion* = 0, LayoutUnit offsetFromLogicalTopOfFirstPage = 0) const;
     LayoutUnit constrainLogicalHeightByMinMax(LayoutUnit) const;
+    LayoutUnit constrainContentBoxLogicalHeightByMinMax(LayoutUnit) const;
 
     int pixelSnappedLogicalHeight() const { return style()->isHorizontalWritingMode() ? pixelSnappedHeight() : pixelSnappedWidth(); }
     int pixelSnappedLogicalWidth() const { return style()->isHorizontalWritingMode() ? pixelSnappedWidth() : pixelSnappedHeight(); }
@@ -413,7 +414,7 @@
 
     LayoutUnit computeLogicalWidthInRegionUsing(SizeType, LayoutUnit availableLogicalWidth, const RenderBlock* containingBlock, RenderRegion*, LayoutUnit offsetFromLogicalTopOfFirstPage) const;
     LayoutUnit computeLogicalHeightUsing(SizeType, const Length& height) const;
-    LayoutUnit computeContentLogicalHeight(SizeType, const Length& height);
+    LayoutUnit computeContentLogicalHeight(SizeType, const Length& height) const;
     LayoutUnit computeContentAndScrollbarLogicalHeightUsing(SizeType, const Length& height) const;
     LayoutUnit computeReplacedLogicalWidthUsing(SizeType, Length width) const;
     LayoutUnit computeReplacedLogicalWidthRespectingMinMaxWidth(LayoutUnit logicalWidth, ShouldComputePreferred  = ComputeActual) const;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to