Title: [121309] trunk
Revision
121309
Author
commit-qu...@webkit.org
Date
2012-06-26 18:41:06 -0700 (Tue, 26 Jun 2012)

Log Message

Unexpected element sizes when mixing inline-table with box-sizing
https://bugs.webkit.org/show_bug.cgi?id=89819

Patch by Kulanthaivel Palanichamy <kulanthai...@codeaurora.org> on 2012-06-26
Reviewed by Julien Chaffraix.

Source/WebCore:

This change handles box-sizing: border-box property for CSS tables properly.

Test: fast/box-sizing/css-table-with-box-sizing.html

* rendering/RenderTable.cpp:
(WebCore::RenderTable::convertStyleLogicalWidthToComputedWidth):
(WebCore::RenderTable::layout):

LayoutTests:

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

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (121308 => 121309)


--- trunk/LayoutTests/ChangeLog	2012-06-27 01:38:41 UTC (rev 121308)
+++ trunk/LayoutTests/ChangeLog	2012-06-27 01:41:06 UTC (rev 121309)
@@ -1,3 +1,13 @@
+2012-06-26  Kulanthaivel Palanichamy  <kulanthai...@codeaurora.org>
+
+        Unexpected element sizes when mixing inline-table with box-sizing
+        https://bugs.webkit.org/show_bug.cgi?id=89819
+
+        Reviewed by Julien Chaffraix.
+
+        * fast/box-sizing/css-table-with-box-sizing-expected.txt: Added.
+        * fast/box-sizing/css-table-with-box-sizing.html: Added.
+
 2012-06-26  Filip Pizlo  <fpi...@apple.com>
 
         DFG PutByValAlias is too aggressive

Added: trunk/LayoutTests/fast/box-sizing/css-table-with-box-sizing-expected.txt (0 => 121309)


--- trunk/LayoutTests/fast/box-sizing/css-table-with-box-sizing-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/box-sizing/css-table-with-box-sizing-expected.txt	2012-06-27 01:41:06 UTC (rev 121309)
@@ -0,0 +1,17 @@
+Test case for bug 89819. This tests CSS 'table' and 'inline-table' with box-sizing.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.getElementById("t1").offsetWidth is 120
+PASS document.getElementById("t1").offsetHeight is 120
+PASS document.getElementById("t2").offsetWidth is 120
+PASS document.getElementById("t2").offsetHeight is 120
+PASS document.getElementById("t3").offsetWidth is 140
+PASS document.getElementById("t3").offsetHeight is 140
+PASS document.getElementById("t4").offsetWidth is 140
+PASS document.getElementById("t4").offsetHeight is 140
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/box-sizing/css-table-with-box-sizing.html (0 => 121309)


--- trunk/LayoutTests/fast/box-sizing/css-table-with-box-sizing.html	                        (rev 0)
+++ trunk/LayoutTests/fast/box-sizing/css-table-with-box-sizing.html	2012-06-27 01:41:06 UTC (rev 121309)
@@ -0,0 +1,53 @@
+<html>
+<head>
+  <style>
+    .test {
+      width:120px;
+      height:120px;
+      border:10px solid black;
+    }
+
+    .border-box {
+      box-sizing:border-box;
+      -moz-box-sizing:border-box;
+    }
+
+	.content-box {
+      box-sizing:content-box;
+      -moz-box-sizing:content-box;
+    }                     	
+
+    .css-inline-table {
+      display:inline-table;
+    }
+
+    .css-table {
+      display:table;
+    }
+  </style>
+</head>
+<body>
+<div id="testContent">
+  <p id="t1" class="test css-inline-table border-box">120x120<br>css-inline-table<br>border-box</p>
+  <p id="t2" class="test css-table border-box">120x120<br>css-table<br>border-box</p>
+  <p id="t3" class="test css-inline-table content-box">120x120<br>css-inline-table<br>content-box</p>
+  <p id="t4" class="test css-table content-box">120x120<br>css-table<br>content-box</p>
+</div>
+  <script src=""
+  <script>
+    description("Test case for bug 89819. This tests CSS 'table' and 'inline-table' with box-sizing.");
+
+    shouldBe('document.getElementById("t1").offsetWidth', '120');
+    shouldBe('document.getElementById("t1").offsetHeight', '120');
+    shouldBe('document.getElementById("t2").offsetWidth', '120');
+    shouldBe('document.getElementById("t2").offsetHeight', '120');
+    shouldBe('document.getElementById("t3").offsetWidth', '140');
+    shouldBe('document.getElementById("t3").offsetHeight', '140');
+    shouldBe('document.getElementById("t4").offsetWidth', '140');
+    shouldBe('document.getElementById("t4").offsetHeight', '140');
+
+    document.getElementById("testContent").style.display = 'none';
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (121308 => 121309)


--- trunk/Source/WebCore/ChangeLog	2012-06-27 01:38:41 UTC (rev 121308)
+++ trunk/Source/WebCore/ChangeLog	2012-06-27 01:41:06 UTC (rev 121309)
@@ -1,3 +1,18 @@
+2012-06-26  Kulanthaivel Palanichamy  <kulanthai...@codeaurora.org>
+
+        Unexpected element sizes when mixing inline-table with box-sizing
+        https://bugs.webkit.org/show_bug.cgi?id=89819
+
+        Reviewed by Julien Chaffraix.
+
+        This change handles box-sizing: border-box property for CSS tables properly.
+
+        Test: fast/box-sizing/css-table-with-box-sizing.html
+
+        * rendering/RenderTable.cpp:
+        (WebCore::RenderTable::convertStyleLogicalWidthToComputedWidth):
+        (WebCore::RenderTable::layout):
+
 2012-06-26  Simon Fraser  <simon.fra...@apple.com>
 
         Optimize mappings of simple transforms in RenderGeometryMap

Modified: trunk/Source/WebCore/rendering/RenderTable.cpp (121308 => 121309)


--- trunk/Source/WebCore/rendering/RenderTable.cpp	2012-06-27 01:38:41 UTC (rev 121308)
+++ trunk/Source/WebCore/rendering/RenderTable.cpp	2012-06-27 01:41:06 UTC (rev 121309)
@@ -273,7 +273,8 @@
     bool isCSSTable = !node() || !node()->hasTagName(tableTag);
     if (isCSSTable && styleLogicalWidth.isFixed() && styleLogicalWidth.isPositive()) {
         recalcBordersInRowDirection();
-        borders = borderStart() + borderEnd() + (collapseBorders() ? ZERO_LAYOUT_UNIT : paddingStart() + paddingEnd());
+        if (style()->boxSizing() == CONTENT_BOX)
+            borders = borderStart() + borderEnd() + (collapseBorders() ? ZERO_LAYOUT_UNIT : paddingStart() + paddingEnd());
     }
     return minimumValueForLength(styleLogicalWidth, availableWidth, view()) + borders;
 }
@@ -397,7 +398,10 @@
     LayoutUnit computedLogicalHeight = 0;
     if (logicalHeightLength.isFixed()) {
         // HTML tables size as though CSS height includes border/padding, CSS tables do not.
-        LayoutUnit borders = node() && node()->hasTagName(tableTag) ? (borderAndPaddingBefore + borderAndPaddingAfter) : ZERO_LAYOUT_UNIT;
+        LayoutUnit borders = ZERO_LAYOUT_UNIT;
+        // FIXME: We cannot apply box-sizing: content-box on <table> which other browsers allow.
+        if ((node() && node()->hasTagName(tableTag)) || style()->boxSizing() == BORDER_BOX)
+            borders = borderAndPaddingBefore + borderAndPaddingAfter;
         computedLogicalHeight = logicalHeightLength.value() - borders;
     } else if (logicalHeightLength.isPercent())
         computedLogicalHeight = computePercentageLogicalHeight(logicalHeightLength);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to