<rdar://problem/7972529> Images with percentage based height/max-height are missing...
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 May 2011 18:50:41 +0000 (18:50 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 May 2011 18:50:41 +0000 (18:50 +0000)
https://bugs.webkit.org/show_bug.cgi?id=58006

Reviewed by Simon Fraser.

Source/WebCore:

* rendering/RenderBox.cpp:
(WebCore::RenderBox::computeReplacedLogicalHeightUsing): Expanded the scope of the fix for
<http://webkit.org/b/15359> from r29039 to cover not just the case of a auto-or-percent-height
table cell as the immediate containing block, but any case where all containing block ancestors
up to and including a table cell are auto-or-percent height.

LayoutTests:

* fast/replaced/table-percent-height-expected.txt: Updated.
* fast/replaced/table-percent-height.html: Added a test case with a replaced object nested in an
auto-height block inside a table cell.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@85499 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/replaced/table-percent-height-expected.txt
LayoutTests/fast/replaced/table-percent-height.html
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBox.cpp

index c198281..547bc1c 100644 (file)
@@ -1,3 +1,14 @@
+2011-05-02  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Simon Fraser.
+
+        <rdar://problem/7972529> Images with percentage based height/max-height are missing when they are inside blocks inside tables
+        https://bugs.webkit.org/show_bug.cgi?id=58006
+
+        * fast/replaced/table-percent-height-expected.txt: Updated.
+        * fast/replaced/table-percent-height.html: Added a test case with a replaced object nested in an
+        auto-height block inside a table cell.
+
 2011-05-02  Daniel Bates  <dbates@webkit.org>
 
         Reviewed by Sam Weinig.
index 11929be..730e191 100644 (file)
@@ -4,6 +4,8 @@
 
 
 
+
+
 Button
 Button
 
@@ -40,6 +42,10 @@ PASS getWidth('img-75') is '75px'
 PASS getHeight('img-75') is '75px'
 PASS getWidth('img-100') is '100px'
 PASS getHeight('img-100') is '100px'
+PASS getWidth('img-75-nested') is '75px'
+PASS getHeight('img-75-nested') is '75px'
+PASS getWidth('img-100-nested') is '100px'
+PASS getHeight('img-100-nested') is '100px'
 PASS getWidth('object-75') is '300px'
 PASS getHeight('object-75') is '112px'
 PASS getWidth('object-100') is '300px'
index 1b6f058..30b5d23 100644 (file)
@@ -76,6 +76,11 @@ function test()
     shouldBe("getWidth('img-100')", "'100px'");
     shouldBe("getHeight('img-100')", "'100px'");
 
+    shouldBe("getWidth('img-75-nested')", "'75px'");
+    shouldBe("getHeight('img-75-nested')", "'75px'");
+    shouldBe("getWidth('img-100-nested')", "'100px'");
+    shouldBe("getHeight('img-100-nested')", "'100px'");
+
     shouldBe("getWidth('object-75')", "'300px'");
     shouldBe("getHeight('object-75')", "'112px'");
     shouldBe("getWidth('object-100')", "'300px'");
@@ -143,6 +148,9 @@ var successfullyParsed = true;
 <table><tr><td><img id="img-75" src="resources/square-blue-100x100.png" style="height: 75%;"></td></tr></table>
 <table><tr><td><img id="img-100" src="resources/square-blue-100x100.png" style="height: 100%;"></td></tr></table>
 
+<table><tr><td><div><img id="img-75-nested" src="resources/square-blue-100x100.png" style="height: 75%;"></div></td></tr></table>
+<table><tr><td><div><img id="img-100-nested" src="resources/square-blue-100x100.png" style="height: 100%;"></div></td></tr></table>
+
 <table><tr><td><object id="object-75" style="background-color: #00ff00; height: 75%;"></object></td></tr></table>
 <table><tr><td><object id="object-100" style="background-color: #00ff00; height: 100%;"></object></td></tr></table>
 
index 2b97fcb..cc9cbc9 100644 (file)
@@ -1,3 +1,16 @@
+2011-05-02  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Simon Fraser.
+
+        <rdar://problem/7972529> Images with percentage based height/max-height are missing when they are inside blocks inside tables
+        https://bugs.webkit.org/show_bug.cgi?id=58006
+
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::computeReplacedLogicalHeightUsing): Expanded the scope of the fix for
+        <http://webkit.org/b/15359> from r29039 to cover not just the case of a auto-or-percent-height
+        table cell as the immediate containing block, but any case where all containing block ancestors
+        up to and including a table cell are auto-or-percent height.
+
 2011-05-02  Daniel Bates  <dbates@webkit.org>
 
         Reviewed by Sam Weinig.
index d9670d5..ede20dd 100644 (file)
@@ -2017,11 +2017,14 @@ int RenderBox::computeReplacedLogicalHeightUsing(Length logicalHeight) const
             // table cells using percentage heights.
             // FIXME: This needs to be made block-flow-aware.  If the cell and image are perpendicular block-flows, this isn't right.
             // https://bugs.webkit.org/show_bug.cgi?id=46997
-            if (cb->isTableCell() && (cb->style()->logicalHeight().isAuto() || cb->style()->logicalHeight().isPercent())) {
-                // Don't let table cells squeeze percent-height replaced elements
-                // <http://bugs.webkit.org/show_bug.cgi?id=15359>
-                availableHeight = max(availableHeight, intrinsicLogicalHeight());
-                return logicalHeight.calcValue(availableHeight - borderAndPaddingLogicalHeight());
+            while (cb && !cb->isRenderView() && (cb->style()->logicalHeight().isAuto() || cb->style()->logicalHeight().isPercent())) {
+                if (cb->isTableCell()) {
+                    // Don't let table cells squeeze percent-height replaced elements
+                    // <http://bugs.webkit.org/show_bug.cgi?id=15359>
+                    availableHeight = max(availableHeight, intrinsicLogicalHeight());
+                    return logicalHeight.calcValue(availableHeight - borderAndPaddingLogicalHeight());
+                }
+                cb = cb->containingBlock();
             }
 
             return computeContentBoxLogicalHeight(logicalHeight.calcValue(availableHeight));