Title: [122501] trunk
Revision
122501
Author
commit-qu...@webkit.org
Date
2012-07-12 13:48:39 -0700 (Thu, 12 Jul 2012)

Log Message

Percentage width replaced element in zero percent/fixed width container block incorrectly rendered.
https://bugs.webkit.org/show_bug.cgi?id=9493

Patch by Pravin D <pravind....@gmail.com> on 2012-07-12
Reviewed by Andy Estes.

Source/WebCore:

When the width of the container is zero percent/fixed value then the width of the replaced element must also be zero.

Test: fast/css/percent-width-img-inside-zero-percent-and-fixed-container.html

* rendering/RenderBox.cpp:
(WebCore::RenderBox::computeReplacedLogicalWidthUsing):
  When the containing block's available width is zero there can be two cases.
  The containing block is floated/positioned in which case the width of the replaced child element must be its instrinsic width.
  On the other hand if the width of the container is specified to be either zero percent or fixed value then the width of the
  replaced elment must be zero.

LayoutTests:

* fast/css/percent-width-img-inside-zero-percent-and-fixed-container-expected.html: Added.
* fast/css/percent-width-img-inside-zero-percent-and-fixed-container.html: Added.
* fast/css/resources/red-box.png: Added.
  Image resource file for the test case.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (122500 => 122501)


--- trunk/LayoutTests/ChangeLog	2012-07-12 20:44:45 UTC (rev 122500)
+++ trunk/LayoutTests/ChangeLog	2012-07-12 20:48:39 UTC (rev 122501)
@@ -1,3 +1,15 @@
+2012-07-12  Pravin D  <pravind....@gmail.com>
+
+        Percentage width replaced element in zero percent/fixed width container block incorrectly rendered.
+        https://bugs.webkit.org/show_bug.cgi?id=9493
+
+        Reviewed by Andy Estes.
+
+        * fast/css/percent-width-img-inside-zero-percent-and-fixed-container-expected.html: Added.
+        * fast/css/percent-width-img-inside-zero-percent-and-fixed-container.html: Added.
+        * fast/css/resources/red-box.png: Added.
+          Image resource file for the test case.
+
 2012-07-12  Dirk Pranke  <dpra...@chromium.org>
 
         Remove chromium-mac-leopard baselines.

Added: trunk/LayoutTests/fast/css/percent-width-img-inside-zero-percent-and-fixed-container-expected.html (0 => 122501)


--- trunk/LayoutTests/fast/css/percent-width-img-inside-zero-percent-and-fixed-container-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/percent-width-img-inside-zero-percent-and-fixed-container-expected.html	2012-07-12 20:48:39 UTC (rev 122501)
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>Test case for https://bugs.webkit.org/show_bug.cgi?id=9493</title>
+<style type="text/css">
+  #fixedContainer { width: 0px }
+  #percentContainer { width: 0% }
+</style>
+</head>
+<body>
+ <h4> There should be no red squares visible below. </h4>
+ <div style="background-color:green;position:absolute;width:64px;height:64px">
+   <div id="fixedContainer"></div>
+ </div>
+  <div style="background-color:green;position:absolute;width:64px;height:64px;top:130px">
+   <div id="percentContainer"></div>
+  </div>
+ </div>
+</body>
+</html>

Added: trunk/LayoutTests/fast/css/percent-width-img-inside-zero-percent-and-fixed-container.html (0 => 122501)


--- trunk/LayoutTests/fast/css/percent-width-img-inside-zero-percent-and-fixed-container.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/percent-width-img-inside-zero-percent-and-fixed-container.html	2012-07-12 20:48:39 UTC (rev 122501)
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>Test case for https://bugs.webkit.org/show_bug.cgi?id=9493</title>
+<style type="text/css">
+  #fixedContainer { width: 0px }
+  #percentContainer { width: 0% }
+  .test { width: 100%; }
+</style>
+</head>
+<body>
+ <h4> There should be no red squares visible below. </h4>
+ <div style="background-color:green;position:absolute;width:64px;height:64px">
+   <div id="fixedContainer">
+     <img class="test" src=""
+   </div>
+ </div>
+  <div style="background-color:green;position:absolute;width:64px;height:64px;top:130px">
+   <div id="percentContainer">
+     <img class="test" src=""
+   </div>
+  </div>
+ </div>
+</body>
+</html>

Added: trunk/LayoutTests/fast/css/resources/red-box.png (0 => 122501)


--- trunk/LayoutTests/fast/css/resources/red-box.png	                        (rev 0)
+++ trunk/LayoutTests/fast/css/resources/red-box.png	2012-07-12 20:48:39 UTC (rev 122501)
@@ -0,0 +1,6 @@
+\x89PNG
+
+
+IHDR@@\xAAiq\xDEsRGB\xAE\xCE\xE9gAMA\xB1\x8F\xFCa	pHYs\xC4\xC4\x95+\x8FIDATx^\xED\xD7\xC1
+\xC00İ\xDB\xE8$\xC8\xE2\xA3\xB4.,sg\xBB\xE5g\xE5\x97\xFF\xEF\xEE\xF8\xECKP\xCA{@\xCA\xD3w8\x84\\x82NaP`(\xEF(O\x9FX\x80X@T\x80X\x80\xCA{@\xCA\xD3g`P``\x81\xF2P\x81\xF2\xF4Y\x80X\x80T@X\x80X\xA0\xBCT\xA0<}``\xA8W\xE0
+j\xD1ҲFRIEND\xAEB`\x82
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (122500 => 122501)


--- trunk/Source/WebCore/ChangeLog	2012-07-12 20:44:45 UTC (rev 122500)
+++ trunk/Source/WebCore/ChangeLog	2012-07-12 20:48:39 UTC (rev 122501)
@@ -1,3 +1,21 @@
+2012-07-12  Pravin D  <pravind....@gmail.com>
+
+        Percentage width replaced element in zero percent/fixed width container block incorrectly rendered.
+        https://bugs.webkit.org/show_bug.cgi?id=9493
+
+        Reviewed by Andy Estes.
+
+        When the width of the container is zero percent/fixed value then the width of the replaced element must also be zero.
+
+        Test: fast/css/percent-width-img-inside-zero-percent-and-fixed-container.html
+
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::computeReplacedLogicalWidthUsing):
+          When the containing block's available width is zero there can be two cases.
+          The containing block is floated/positioned in which case the width of the replaced child element must be its instrinsic width.
+          On the other hand if the width of the container is specified to be either zero percent or fixed value then the width of the
+          replaced elment must be zero.
+
 2012-07-11  Ryosuke Niwa  <rn...@webkit.org>
 
         invalidateNodeListsCacheAfterAttributeChanged should dynamically figure out which attribute needs invalidation

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (122500 => 122501)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2012-07-12 20:44:45 UTC (rev 122500)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2012-07-12 20:48:39 UTC (rev 122501)
@@ -2205,7 +2205,10 @@
             // containing block's block-flow.
             // https://bugs.webkit.org/show_bug.cgi?id=46496
             const LayoutUnit cw = isOutOfFlowPositioned() ? containingBlockLogicalWidthForPositioned(toRenderBoxModelObject(container())) : containingBlockLogicalWidthForContent();
-            if (cw > 0)
+            Length containerLogicalWidth = containingBlock()->style()->logicalWidth();
+            // FIXME: Handle cases when containing block width is calculated or viewport percent.
+            // https://bugs.webkit.org/show_bug.cgi?id=91071
+            if (cw > 0 || (!cw && (containerLogicalWidth.isFixed() || containerLogicalWidth.isPercent())))
                 return computeContentBoxLogicalWidth(minimumValueForLength(logicalWidth, cw));
         }
         // fall through
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to