Title: [115667] branches/chromium/1084
Revision
115667
Author
[email protected]
Date
2012-04-30 14:15:36 -0700 (Mon, 30 Apr 2012)

Log Message

Merge 114574 - REGRESSION(102040): Auto-table layout with percent width doesn't shrink-to-fit content a cell with colspan
https://bugs.webkit.org/show_bug.cgi?id=84260

Reviewed by Ojan Vafai.

Source/WebCore:

Tests: fast/table/td-width-fifty-percent-regression-expected.html
       fast/table/td-width-fifty-percent-regression.html

* rendering/AutoTableLayout.cpp:
(WebCore::AutoTableLayout::calcEffectiveLogicalWidth):
As we are spreading the cell's min / max logical width, we should be updating them.
This prevents the following logic getting confused and allocating more than needed.

LayoutTests:

* fast/table/td-width-fifty-percent-regression-expected.html: Added.
* fast/table/td-width-fifty-percent-regression.html: Added.


[email protected]
Review URL: https://chromiumcodereview.appspot.com/10274014

Modified Paths

Added Paths

Diff

Copied: branches/chromium/1084/LayoutTests/fast/table/td-width-fifty-percent-regression-expected.html (from rev 114574, trunk/LayoutTests/fast/table/td-width-fifty-percent-regression-expected.html) (0 => 115667)


--- branches/chromium/1084/LayoutTests/fast/table/td-width-fifty-percent-regression-expected.html	                        (rev 0)
+++ branches/chromium/1084/LayoutTests/fast/table/td-width-fifty-percent-regression-expected.html	2012-04-30 21:15:36 UTC (rev 115667)
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+    table
+    {
+        border:solid black 1px;
+    }
+</style> 
+</head>
+<body>
+<p>Test for bug <a href="" REGRESSION(102040): Auto-table layout with percent width doesn't shrink-to-fit content a cell with colspan</p>
+<p>For this test to pass, the table below should fit its content.</p>
+<table>
+    <tr>
+        <td></td><td></td>
+    </tr>
+    <tr>
+        <td colspan="2">Lorem</td>
+    </tr>
+</table>
+</body>
+</html>

Copied: branches/chromium/1084/LayoutTests/fast/table/td-width-fifty-percent-regression.html (from rev 114574, trunk/LayoutTests/fast/table/td-width-fifty-percent-regression.html) (0 => 115667)


--- branches/chromium/1084/LayoutTests/fast/table/td-width-fifty-percent-regression.html	                        (rev 0)
+++ branches/chromium/1084/LayoutTests/fast/table/td-width-fifty-percent-regression.html	2012-04-30 21:15:36 UTC (rev 115667)
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+    table
+    {
+        border:solid black 1px;
+    }
+    td.fiftyPercent
+    {
+        width: 50%;
+    }
+</style> 
+</head>
+<body>
+<p>Test for bug <a href="" REGRESSION(102040): Auto-table layout with percent width doesn't shrink-to-fit content a cell with colspan</p>
+<p>For this test to pass, the table below should fit its content.</p>
+<table>
+    <tr>
+        <td class="fiftyPercent"></td><td class="fiftyPercent"></td>
+    </tr>
+    <tr>
+        <td colspan="2">Lorem</td>
+    </tr>
+</table>
+</body>
+</html>

Modified: branches/chromium/1084/Source/WebCore/rendering/AutoTableLayout.cpp (115666 => 115667)


--- branches/chromium/1084/Source/WebCore/rendering/AutoTableLayout.cpp	2012-04-30 21:11:45 UTC (rev 115666)
+++ branches/chromium/1084/Source/WebCore/rendering/AutoTableLayout.cpp	2012-04-30 21:15:36 UTC (rev 115667)
@@ -402,13 +402,23 @@
                 }
             } else if (allColsArePercent) {
                 // In this case, we just split the colspan's min amd max widths following the percentage.
+                int allocatedMinLogicalWidth = 0;
+                float allocatedMaxLogicalWidth = 0;
                 for (unsigned pos = effCol; pos < lastCol; ++pos) {
                     ASSERT(m_layoutStruct[pos].logicalWidth.isPercent() || m_layoutStruct[pos].effectiveLogicalWidth.isPercent());
                     // |allColsArePercent| means that either the logicalWidth *or* the effectiveLogicalWidth are percents, handle both of them here.
                     float percent = m_layoutStruct[pos].logicalWidth.isPercent() ? m_layoutStruct[pos].logicalWidth.percent() : m_layoutStruct[pos].effectiveLogicalWidth.percent();
-                    m_layoutStruct[pos].effectiveMinLogicalWidth = max(m_layoutStruct[pos].effectiveMinLogicalWidth, static_cast<int>(percent * cellMinLogicalWidth / totalPercent));
-                    m_layoutStruct[pos].effectiveMaxLogicalWidth = percent * cellMaxLogicalWidth / totalPercent;
+                    int columnMinLogicalWidth = static_cast<int>(percent * cellMinLogicalWidth / totalPercent);
+                    float columnMaxLogicalWidth = percent * cellMaxLogicalWidth / totalPercent;
+                    m_layoutStruct[pos].effectiveMinLogicalWidth = max(m_layoutStruct[pos].effectiveMinLogicalWidth, columnMinLogicalWidth);
+                    m_layoutStruct[pos].effectiveMaxLogicalWidth = columnMaxLogicalWidth;
+                    allocatedMinLogicalWidth += columnMinLogicalWidth;
+                    allocatedMaxLogicalWidth += columnMaxLogicalWidth;
                 }
+                ASSERT(allocatedMinLogicalWidth <= cellMinLogicalWidth);
+                ASSERT(allocatedMaxLogicalWidth <= cellMaxLogicalWidth);
+                cellMinLogicalWidth -= allocatedMinLogicalWidth;
+                cellMaxLogicalWidth -= allocatedMaxLogicalWidth;
             } else {
                 float remainingMaxLogicalWidth = spanMaxLogicalWidth;
                 int remainingMinLogicalWidth = spanMinLogicalWidth;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to