Title: [98997] trunk
Revision
98997
Author
domin...@chromium.org
Date
2011-11-01 13:55:57 -0700 (Tue, 01 Nov 2011)

Log Message

display: table-cell and box-sizing: border-box calculates content-box height
https://bugs.webkit.org/show_bug.cgi?id=69425

Reviewed by Dan Bernstein.

Source/WebCore:

Test: fast/box-sizing/table-cell.html

* rendering/RenderTableSection.cpp:
(WebCore::RenderTableSection::calcRowLogicalHeight):

LayoutTests:

* fast/box-sizing/table-cell-expected.txt: Added.
* fast/box-sizing/table-cell.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (98996 => 98997)


--- trunk/LayoutTests/ChangeLog	2011-11-01 20:52:11 UTC (rev 98996)
+++ trunk/LayoutTests/ChangeLog	2011-11-01 20:55:57 UTC (rev 98997)
@@ -1,3 +1,13 @@
+2011-11-01  Dominic Cooney  <domin...@chromium.org>
+
+        display: table-cell and box-sizing: border-box calculates content-box height
+        https://bugs.webkit.org/show_bug.cgi?id=69425
+
+        Reviewed by Dan Bernstein.
+
+        * fast/box-sizing/table-cell-expected.txt: Added.
+        * fast/box-sizing/table-cell.html: Added.
+
 2011-11-01  Kenji Imasaki  <imas...@chromium.org>
 
         [Chromium] Unreviewed. Remove media/audio-repaint.html from test expectaion.

Added: trunk/LayoutTests/fast/box-sizing/table-cell-expected.txt (0 => 98997)


--- trunk/LayoutTests/fast/box-sizing/table-cell-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/box-sizing/table-cell-expected.txt	2011-11-01 20:55:57 UTC (rev 98997)
@@ -0,0 +1,15 @@
+Tests that display: table-cell and box-sizing: border-box work when used together.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+div-display-table-cell
+PASS element.offsetWidth is 80
+PASS element.offsetHeight is 30
+td
+PASS element.offsetWidth is 80
+PASS element.offsetHeight is 30
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/box-sizing/table-cell.html (0 => 98997)


--- trunk/LayoutTests/fast/box-sizing/table-cell.html	                        (rev 0)
+++ trunk/LayoutTests/fast/box-sizing/table-cell.html	2011-11-01 20:55:57 UTC (rev 98997)
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<link rel="stylesheet" href=""
+
+<style>
+.styledForTest {
+  -moz-box-sizing: border-box;
+  box-sizing: border-box;
+  background-color: orange;
+  color: white;
+  border: 7px solid black;
+  padding: 5px;
+  width: 80px;
+  height: 30px;
+  margin: 2px;
+}
+</style>
+
+<p id="description">All of the boxes should be 80x30 and look identical.</p>
+<div id="console"></div>
+
+<div id="expected" class="styledForTest"></div>
+
+<div id="div-display-table-cell" class="styledForTest" style="display: table-cell;"></div>
+
+<table>
+<tr>
+<td id="td" class="styledForTest"></td>
+</tr>
+</table>
+
+<script src=""
+<script>
+description('Tests that display: table-cell and box-sizing: border-box work when used together.');
+
+['div-display-table-cell', 'td'].forEach(function (id) {
+  debug(id);
+  element = document.querySelector('#' + id);
+  shouldBe('element.offsetWidth', '80');
+  shouldBe('element.offsetHeight', '30');
+});
+
+successfullyParsed = true;
+</script>
+<script src=""

Modified: trunk/Source/WebCore/ChangeLog (98996 => 98997)


--- trunk/Source/WebCore/ChangeLog	2011-11-01 20:52:11 UTC (rev 98996)
+++ trunk/Source/WebCore/ChangeLog	2011-11-01 20:55:57 UTC (rev 98997)
@@ -1,3 +1,15 @@
+2011-11-01  Dominic Cooney  <domin...@chromium.org>
+
+        display: table-cell and box-sizing: border-box calculates content-box height
+        https://bugs.webkit.org/show_bug.cgi?id=69425
+
+        Reviewed by Dan Bernstein.
+
+        Test: fast/box-sizing/table-cell.html
+
+        * rendering/RenderTableSection.cpp:
+        (WebCore::RenderTableSection::calcRowLogicalHeight):
+
 2011-11-01  Alok Priyadarshi  <al...@chromium.org>
 
         [chromium] Add testing for --enable-accelerated-drawing

Modified: trunk/Source/WebCore/rendering/RenderTableSection.cpp (98996 => 98997)


--- trunk/Source/WebCore/rendering/RenderTableSection.cpp	2011-11-01 20:52:11 UTC (rev 98996)
+++ trunk/Source/WebCore/rendering/RenderTableSection.cpp	2011-11-01 20:55:57 UTC (rev 98997)
@@ -363,15 +363,19 @@
                 cell->layoutIfNeeded();
             }
 
-            LayoutUnit adjustedPaddingBefore = cell->paddingBefore() - cell->intrinsicPaddingBefore();
-            LayoutUnit adjustedPaddingAfter = cell->paddingAfter() - cell->intrinsicPaddingAfter();
             LayoutUnit adjustedLogicalHeight = cell->logicalHeight() - (cell->intrinsicPaddingBefore() + cell->intrinsicPaddingAfter());
 
-            // Explicit heights use the border box in quirks mode.  In strict mode do the right
-            // thing and actually add in the border and padding.
-            ch = cell->style()->logicalHeight().calcValue(0) + 
-                (document()->inQuirksMode() ? 0 : (adjustedPaddingBefore + adjustedPaddingAfter +
-                                                   cell->borderBefore() + cell->borderAfter()));
+            ch = cell->style()->logicalHeight().calcValue(0);
+            if (document()->inQuirksMode() || cell->style()->boxSizing() == BORDER_BOX) {
+                // Explicit heights use the border box in quirks mode.
+                // Don't adjust height.
+            } else {
+                // In strict mode, box-sizing: content-box do the right
+                // thing and actually add in the border and padding.
+                LayoutUnit adjustedPaddingBefore = cell->paddingBefore() - cell->intrinsicPaddingBefore();
+                LayoutUnit adjustedPaddingAfter = cell->paddingAfter() - cell->intrinsicPaddingAfter();
+                ch += adjustedPaddingBefore + adjustedPaddingAfter + cell->borderBefore() + cell->borderAfter();
+            }
             ch = max(ch, adjustedLogicalHeight);
 
             pos = m_rowPos[indx] + ch + (m_grid[r].rowRenderer ? spacing : 0);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to