Title: [171480] trunk
Revision
171480
Author
[email protected]
Date
2014-07-23 10:56:18 -0700 (Wed, 23 Jul 2014)

Log Message

Ensure we compute the min and max height of replaced elements to 'none' or 0 when appropriate.
https://bugs.webkit.org/show_bug.cgi?id=135181

Reviewed by David Hyatt.

Source/WebCore:
If a replaced element has a percentage min or max height specified then that height value should
compute to 'none' for max-height and 0 for min-height when its containing block
does not have a height 'specified explicitly'.

This is based on a Blink patch by Robert Hogan.

Tests: css2.1/20110323/max-height-percentage-003.html
       fast/replaced/max-height-percentage-quirks.html
       fast/replaced/min-height-percentage-quirks.html
       fast/replaced/min-height-percentage.html

* rendering/RenderBox.cpp:
(WebCore::RenderBox::logicalHeightComputesAsNone):
(WebCore::RenderBox::computeReplacedLogicalHeightRespectingMinMaxHeight):
* rendering/RenderBox.h:

LayoutTests:
* css2.1/20110323/max-height-percentage-003-expected.html: Added.
* css2.1/20110323/max-height-percentage-003.html: Added.
* fast/replaced/max-height-percentage-quirks-expected.html: Added.
* fast/replaced/max-height-percentage-quirks.html: Added.
* fast/replaced/min-height-percentage-expected.html: Added.
* fast/replaced/min-height-percentage-quirks-expected.html: Added.
* fast/replaced/min-height-percentage-quirks.html: Added.
* fast/replaced/min-height-percentage.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (171479 => 171480)


--- trunk/LayoutTests/ChangeLog	2014-07-23 17:35:29 UTC (rev 171479)
+++ trunk/LayoutTests/ChangeLog	2014-07-23 17:56:18 UTC (rev 171480)
@@ -1,3 +1,19 @@
+2014-07-23  Bem Jones-Bey  <[email protected]>
+
+        Ensure we compute the min and max height of replaced elements to 'none' or 0 when appropriate.
+        https://bugs.webkit.org/show_bug.cgi?id=135181
+
+        Reviewed by David Hyatt.
+
+        * css2.1/20110323/max-height-percentage-003-expected.html: Added.
+        * css2.1/20110323/max-height-percentage-003.html: Added.
+        * fast/replaced/max-height-percentage-quirks-expected.html: Added.
+        * fast/replaced/max-height-percentage-quirks.html: Added.
+        * fast/replaced/min-height-percentage-expected.html: Added.
+        * fast/replaced/min-height-percentage-quirks-expected.html: Added.
+        * fast/replaced/min-height-percentage-quirks.html: Added.
+        * fast/replaced/min-height-percentage.html: Added.
+
 2014-07-23  Mihnea Ovidenie  <[email protected]>
 
         ASSERTION FAILED: generatingElement() in WebCore::RenderNamedFlowFragment::regionOversetState

Added: trunk/LayoutTests/css2.1/20110323/max-height-percentage-003-expected.html (0 => 171480)


--- trunk/LayoutTests/css2.1/20110323/max-height-percentage-003-expected.html	                        (rev 0)
+++ trunk/LayoutTests/css2.1/20110323/max-height-percentage-003-expected.html	2014-07-23 17:56:18 UTC (rev 171480)
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+  <p>Test passes if there is a filled black square.</p>
+
+  <div id="parent">
+    <img src="" alt="Image download support must be enabled">
+  </div>

Added: trunk/LayoutTests/css2.1/20110323/max-height-percentage-003.html (0 => 171480)


--- trunk/LayoutTests/css2.1/20110323/max-height-percentage-003.html	                        (rev 0)
+++ trunk/LayoutTests/css2.1/20110323/max-height-percentage-003.html	2014-07-23 17:56:18 UTC (rev 171480)
@@ -0,0 +1,43 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+
+ <head>
+
+  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+
+  <title>CSS Test: max-height percentage - inline replaced element inside an auto-height container</title>
+
+  <link rel="author" title="Gérard Talbot" href=""
+
+  <!--
+  Original post:
+  Image % sizing interoperability
+  from Bogdan Brinza who deserves credit for reporting this
+  http://lists.w3.org/Archives/Public/www-style/2014Jun/0079.html
+  -->
+
+  <link rel="help" href="" title="10.7 Minimum and maximum heights: 'min-height' and 'max-height'">
+  <link rel="bookmark" href="" title="Image % sizing interoperability">
+  <link rel="match" href=""
+
+  <meta content="image" name="flags">
+  <meta content="This test checks that a max-height percentage is calculated with respect to the height of the generated box's containing block only if and only when such containing block's height is specified explicitly (i.e., it depends on content height; its specified height is not 'auto'). In this test, the div#child has an 'auto' height; therefore the max-height percentage is treated as 'none' and so the image should be rendered (entirely visible) inside that div#child. Note that div#parent's initial overflow value is 'visible'." name="assert">
+
+  <style type="text/css">
+  div#parent {height: 0px;}
+
+  img {max-height: 100%;}
+  </style>
+
+ </head>
+
+ <body>
+
+  <p>Test passes if there is a filled black square.</p>
+
+  <div id="parent">
+    <div id="child"><img src="" alt="Image download support must be enabled"></div>
+  </div>
+
+ </body>
+</html>
\ No newline at end of file

Added: trunk/LayoutTests/fast/replaced/max-height-percentage-quirks-expected.html (0 => 171480)


--- trunk/LayoutTests/fast/replaced/max-height-percentage-quirks-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/replaced/max-height-percentage-quirks-expected.html	2014-07-23 17:56:18 UTC (rev 171480)
@@ -0,0 +1,4 @@
+<p>Test passes if there is a filled blue square.</p>
+<div id="parent">
+    <div id="child"><img src=""
+</div>

Added: trunk/LayoutTests/fast/replaced/max-height-percentage-quirks.html (0 => 171480)


--- trunk/LayoutTests/fast/replaced/max-height-percentage-quirks.html	                        (rev 0)
+++ trunk/LayoutTests/fast/replaced/max-height-percentage-quirks.html	2014-07-23 17:56:18 UTC (rev 171480)
@@ -0,0 +1,8 @@
+<style>
+    div#parent {height: 0px;}
+    img {max-height: 100%;}
+</style>
+<p>Test passes if there is a filled blue square.</p>
+<div id="parent">
+    <div id="child"><img src=""
+</div>

Added: trunk/LayoutTests/fast/replaced/min-height-percentage-expected.html (0 => 171480)


--- trunk/LayoutTests/fast/replaced/min-height-percentage-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/replaced/min-height-percentage-expected.html	2014-07-23 17:56:18 UTC (rev 171480)
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+    <style>
+        img { height: 50px;}
+    </style>
+    <p> The blue square should be 50px by 50px. This is because http://www.w3.org/TR/CSS21/visudet.html#min-max-heights says: "If the height of the containing block is not specified explicitly 
+          (i.e., it depends on content height), and this element is not absolutely positioned, the percentage value is treated as '0' (for 'min-height')." </p>
+    <div>
+        <img id="image" src=""
+    </div>

Added: trunk/LayoutTests/fast/replaced/min-height-percentage-quirks-expected.html (0 => 171480)


--- trunk/LayoutTests/fast/replaced/min-height-percentage-quirks-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/replaced/min-height-percentage-quirks-expected.html	2014-07-23 17:56:18 UTC (rev 171480)
@@ -0,0 +1,8 @@
+<style>
+    img {height: 50px;}
+</style>
+<p> The blue square should be 50px by 50px. This is because http://www.w3.org/TR/CSS21/visudet.html#min-max-heights says: "If the height of the containing block is not specified explicitly 
+(i.e., it depends on content height), and this element is not absolutely positioned, the percentage value is treated as '0' (for 'min-height')." </p>
+<div>
+    <div id="child"><img id="image" src=""
+</div>

Added: trunk/LayoutTests/fast/replaced/min-height-percentage-quirks.html (0 => 171480)


--- trunk/LayoutTests/fast/replaced/min-height-percentage-quirks.html	                        (rev 0)
+++ trunk/LayoutTests/fast/replaced/min-height-percentage-quirks.html	2014-07-23 17:56:18 UTC (rev 171480)
@@ -0,0 +1,8 @@
+<style>
+    img {min-height: 100%; max-height: 50px;}
+</style>
+<p> The blue square should be 50px by 50px. This is because http://www.w3.org/TR/CSS21/visudet.html#min-max-heights says: "If the height of the containing block is not specified explicitly 
+(i.e., it depends on content height), and this element is not absolutely positioned, the percentage value is treated as '0' (for 'min-height')." </p>
+<div>
+    <div id="child"><img id="image" src=""
+</div>

Added: trunk/LayoutTests/fast/replaced/min-height-percentage.html (0 => 171480)


--- trunk/LayoutTests/fast/replaced/min-height-percentage.html	                        (rev 0)
+++ trunk/LayoutTests/fast/replaced/min-height-percentage.html	2014-07-23 17:56:18 UTC (rev 171480)
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+    <style>
+        img {min-height: 100%; max-height: 50px;}
+    </style>
+    <p> The blue square should be 50px by 50px. This is because http://www.w3.org/TR/CSS21/visudet.html#min-max-heights says: "If the height of the containing block is not specified explicitly 
+          (i.e., it depends on content height), and this element is not absolutely positioned, the percentage value is treated as '0' (for 'min-height')." </p>
+    <div>
+        <div id="child"><img id="image" src=""
+    </div>

Modified: trunk/Source/WebCore/ChangeLog (171479 => 171480)


--- trunk/Source/WebCore/ChangeLog	2014-07-23 17:35:29 UTC (rev 171479)
+++ trunk/Source/WebCore/ChangeLog	2014-07-23 17:56:18 UTC (rev 171480)
@@ -1,5 +1,28 @@
 2014-07-23  Bem Jones-Bey  <[email protected]>
 
+        Ensure we compute the min and max height of replaced elements to 'none' or 0 when appropriate.
+        https://bugs.webkit.org/show_bug.cgi?id=135181
+
+        Reviewed by David Hyatt.
+
+        If a replaced element has a percentage min or max height specified then that height value should
+        compute to 'none' for max-height and 0 for min-height when its containing block
+        does not have a height 'specified explicitly'.
+
+        This is based on a Blink patch by Robert Hogan.
+
+        Tests: css2.1/20110323/max-height-percentage-003.html
+               fast/replaced/max-height-percentage-quirks.html
+               fast/replaced/min-height-percentage-quirks.html
+               fast/replaced/min-height-percentage.html
+
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::logicalHeightComputesAsNone):
+        (WebCore::RenderBox::computeReplacedLogicalHeightRespectingMinMaxHeight):
+        * rendering/RenderBox.h:
+
+2014-07-23  Bem Jones-Bey  <[email protected]>
+
         Remove CSS_EXCLUSIONS compile flag and leftover code
         https://bugs.webkit.org/show_bug.cgi?id=135175
 

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (171479 => 171480)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2014-07-23 17:35:29 UTC (rev 171479)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2014-07-23 17:56:18 UTC (rev 171480)
@@ -2929,10 +2929,37 @@
     return computeReplacedLogicalHeightRespectingMinMaxHeight(computeReplacedLogicalHeightUsing(style().logicalHeight()));
 }
 
+bool RenderBox::logicalHeightComputesAsNone(SizeType sizeType) const
+{
+    ASSERT(sizeType == MinSize || sizeType == MaxSize);
+    Length logicalHeight = sizeType == MinSize ? style().logicalMinHeight() : style().logicalMaxHeight();
+    Length initialLogicalHeight = sizeType == MinSize ? RenderStyle::initialMinSize() : RenderStyle::initialMaxSize();
+
+    if (logicalHeight == initialLogicalHeight)
+        return true;
+
+    if (!logicalHeight.isPercent() || isOutOfFlowPositioned())
+        return false;
+
+    // Anonymous block boxes are ignored when resolving percentage values that would refer to it:
+    // the closest non-anonymous ancestor box is used instead.
+    RenderBlock* containingBlock = this->containingBlock();
+    while (containingBlock->isAnonymous())
+        containingBlock = containingBlock->containingBlock();
+
+    return containingBlock->hasAutoHeightOrContainingBlockWithAutoHeight();
+}
+
 LayoutUnit RenderBox::computeReplacedLogicalHeightRespectingMinMaxHeight(LayoutUnit logicalHeight) const
 {
-    LayoutUnit minLogicalHeight = computeReplacedLogicalHeightUsing(style().logicalMinHeight());
-    LayoutUnit maxLogicalHeight = style().logicalMaxHeight().isUndefined() ? logicalHeight : computeReplacedLogicalHeightUsing(style().logicalMaxHeight());
+    // If the height of the containing block is not specified explicitly (i.e., it depends on content height), and this element is not absolutely positioned,
+    // the percentage value is treated as '0' (for 'min-height') or 'none' (for 'max-height').
+    LayoutUnit minLogicalHeight;
+    if (!logicalHeightComputesAsNone(MinSize))
+        minLogicalHeight = computeReplacedLogicalHeightUsing(style().logicalMinHeight());
+    LayoutUnit maxLogicalHeight = logicalHeight;
+    if (!logicalHeightComputesAsNone(MaxSize))
+        maxLogicalHeight =  computeReplacedLogicalHeightUsing(style().logicalMaxHeight());
     return std::max(minLogicalHeight, std::min(logicalHeight, maxLogicalHeight));
 }
 

Modified: trunk/Source/WebCore/rendering/RenderBox.h (171479 => 171480)


--- trunk/Source/WebCore/rendering/RenderBox.h	2014-07-23 17:35:29 UTC (rev 171479)
+++ trunk/Source/WebCore/rendering/RenderBox.h	2014-07-23 17:56:18 UTC (rev 171480)
@@ -702,6 +702,8 @@
 
     virtual LayoutRect frameRectForStickyPositioning() const override final { return frameRect(); }
 
+    bool logicalHeightComputesAsNone(SizeType) const;
+
 private:
     // The width/height of the contents + borders + padding.  The x/y location is relative to our container (which is not always our parent).
     LayoutRect m_frameRect;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to