Title: [130774] trunk
Revision
130774
Author
[email protected]
Date
2012-10-09 09:55:46 -0700 (Tue, 09 Oct 2012)

Log Message

max-width property is does not overriding the width properties for css tables(display:table)
https://bugs.webkit.org/show_bug.cgi?id=98455

Patch by Pravin D <[email protected]> on 2012-10-09
Reviewed by Tony Chang.

Source/WebCore:

The max-width property determines the maximum computed width an element can have. In case of css tables(display:table),
the computed was not being limited by the max-width property. The current patch fixes this issue.

Test: fast/table/css-table-max-width.html

* rendering/RenderTable.cpp:
(WebCore::RenderTable::updateLogicalWidth):
 Logic to compute the logical width of an element such that it does not exceed the max-width value.
 Also when both min-width and max-width are present, the following contraint is used to compute the logical width:
   1) min-width < Computed LogicalWidth < max-width, when min-width < max-width.
   2) Computed LogicalWidth = min-width, when min-width > max-width.

LayoutTests:

* fast/table/css-table-max-width-expected.txt: Added.
* fast/table/css-table-max-width.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (130773 => 130774)


--- trunk/LayoutTests/ChangeLog	2012-10-09 16:50:26 UTC (rev 130773)
+++ trunk/LayoutTests/ChangeLog	2012-10-09 16:55:46 UTC (rev 130774)
@@ -1,3 +1,13 @@
+2012-10-09  Pravin D  <[email protected]>
+
+        max-width property is does not overriding the width properties for css tables(display:table)
+        https://bugs.webkit.org/show_bug.cgi?id=98455
+
+        Reviewed by Tony Chang.
+
+        * fast/table/css-table-max-width-expected.txt: Added.
+        * fast/table/css-table-max-width.html: Added.
+
 2012-10-09  Zan Dobersek  <[email protected]>
 
         Unreviewed GTK gardening.

Added: trunk/LayoutTests/fast/table/css-table-max-width-expected.txt (0 => 130774)


--- trunk/LayoutTests/fast/table/css-table-max-width-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/table/css-table-max-width-expected.txt	2012-10-09 16:55:46 UTC (rev 130774)
@@ -0,0 +1,21 @@
+Test case for bug http://webkit.org/b/98455. The testcase checks if the max-width property overrides the computed width of a html container with display:table.
+A html container with display:table should not exceed the max-width even if its calculated width is greater than the max-width value.
+However when min-width property is set and its value is greated than the max-width value, the width of the container must be equal to the min-width value.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Note:The width of the css tables inclusive of its border width.
+
+PASS maxGreatThanMinWidthAutoLayout.getBoundingClientRect().width is 202
+PASS minGreatThanMaxWidthAutoLayout.getBoundingClientRect().width is 202
+PASS onlyMaxWidthAutoLayout.getBoundingClientRect().width is 202
+PASS maxWidthZeroAutoLayout.getBoundingClientRect().width is 0
+PASS maxGreatThanMinWidthFixedLayout.getBoundingClientRect().width is 202
+PASS minGreatThanMaxWidthFixedLayout.getBoundingClientRect().width is 202
+PASS onlyMaxWidthFixedLayout.getBoundingClientRect().width is 202
+PASS maxWidthZeroFixedLayout.getBoundingClientRect().width is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/table/css-table-max-width.html (0 => 130774)


--- trunk/LayoutTests/fast/table/css-table-max-width.html	                        (rev 0)
+++ trunk/LayoutTests/fast/table/css-table-max-width.html	2012-10-09 16:55:46 UTC (rev 130774)
@@ -0,0 +1,114 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style type="text/css">
+.parent
+{
+    width:300px;
+    border:1px solid green;
+}
+
+.parent .child
+{
+    background-color:#999999;
+    border:1px solid yellow;
+}
+</style>
+<script src=""
+</head>
+<body>
+<div id="container" class="parent">
+    <div id="maxGreatThanMinWidthAutoLayout" class="child" style="display:table; min-width:100px; max-width:200px; width:100%;">
+        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod 
+        tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, 
+        quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. 
+        Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu 
+        fugiat nulla pariatur.Excepteur sint occaecat cupidatat non proident, sunt in culpa 
+        qui officia deserunt mollit anim id est laborum.
+    </div>
+    <div id="minGreatThanMaxWidthAutoLayout" class="child" style="display:table; min-width:200px; max-width:100px; width:100%;">
+        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod 
+        tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, 
+        quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. 
+        Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu 
+        fugiat nulla pariatur.Excepteur sint occaecat cupidatat non proident, sunt in culpa 
+        qui officia deserunt mollit anim id est laborum.
+    </div>
+    <div id="onlyMaxWidthAutoLayout" class="child" style="display:table; max-width:200px; width:100%;">
+        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod 
+        tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, 
+        quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. 
+        Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu 
+        fugiat nulla pariatur.Excepteur sint occaecat cupidatat non proident, sunt in culpa 
+        qui officia deserunt mollit anim id est laborum.
+    </div>
+    <div id="maxWidthZeroAutoLayout" class="child" style="display:table; max-width:0; width:100%;">
+        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod 
+        tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, 
+        quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. 
+        Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu 
+        fugiat nulla pariatur.Excepteur sint occaecat cupidatat non proident, sunt in culpa 
+        qui officia deserunt mollit anim id est laborum.
+    </div>
+        <div id="maxGreatThanMinWidthFixedLayout" class="child" style="display:table; table-layout:fixed; min-width:100px; max-width:200px; width:100%;">
+        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod 
+        tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, 
+        quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. 
+        Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu 
+        fugiat nulla pariatur.Excepteur sint occaecat cupidatat non proident, sunt in culpa 
+        qui officia deserunt mollit anim id est laborum.
+    </div>
+    <div id="minGreatThanMaxWidthFixedLayout" class="child" style="display:table; table-layout:fixed; min-width:200px; max-width:100px; width:100%;">
+        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod 
+        tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, 
+        quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. 
+        Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu 
+        fugiat nulla pariatur.Excepteur sint occaecat cupidatat non proident, sunt in culpa 
+        qui officia deserunt mollit anim id est laborum.
+    </div>
+    <div id="onlyMaxWidthFixedLayout" class="child" style="display:table; table-layout:fixed; max-width:200px; width:100%;">
+        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod 
+        tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, 
+        quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. 
+        Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu 
+        fugiat nulla pariatur.Excepteur sint occaecat cupidatat non proident, sunt in culpa 
+        qui officia deserunt mollit anim id est laborum.
+    </div>
+    <div id="maxWidthZeroFixedLayout" class="child" style="display:table; table-layout:fixed; max-width:0; width:100%;">
+        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod 
+        tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, 
+        quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. 
+        Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu 
+        fugiat nulla pariatur.Excepteur sint occaecat cupidatat non proident, sunt in culpa 
+        qui officia deserunt mollit anim id est laborum.
+    </div>
+</div>
+<script>
+description('Test case for bug <a href="" The testcase checks \
+if the max-width property overrides the computed width of a html container with display:table.<br> \
+A html container with display:table should not exceed the max-width even if its calculated \
+width is greater than the max-width value.<br>However when min-width property is set and its value is greated than \
+the max-width value, the width of the container must be equal to the min-width value.');
+debug('Note:The width of the css tables inclusive of its border width.<br>');
+maxGreatThanMinWidthAutoLayout = document.getElementById("maxGreatThanMinWidthAutoLayout");
+shouldBe("maxGreatThanMinWidthAutoLayout.getBoundingClientRect().width","202");
+minGreatThanMaxWidthAutoLayout = document.getElementById("minGreatThanMaxWidthAutoLayout");
+shouldBe("minGreatThanMaxWidthAutoLayout.getBoundingClientRect().width","202");
+_onlyMaxWidthAutoLayout_ = document.getElementById("onlyMaxWidthAutoLayout");
+shouldBe("onlyMaxWidthAutoLayout.getBoundingClientRect().width","202");
+maxWidthZeroAutoLayout = document.getElementById("maxWidthZeroAutoLayout");
+shouldBe("maxWidthZeroAutoLayout.getBoundingClientRect().width","0");
+maxGreatThanMinWidthFixedLayout = document.getElementById("maxGreatThanMinWidthFixedLayout");
+shouldBe("maxGreatThanMinWidthFixedLayout.getBoundingClientRect().width","202");
+minGreatThanMaxWidthFixedLayout = document.getElementById("minGreatThanMaxWidthFixedLayout");
+shouldBe("minGreatThanMaxWidthFixedLayout.getBoundingClientRect().width","202");
+_onlyMaxWidthFixedLayout_ = document.getElementById("onlyMaxWidthFixedLayout");
+shouldBe("onlyMaxWidthFixedLayout.getBoundingClientRect().width","202");
+maxWidthZeroFixedLayout = document.getElementById("maxWidthZeroFixedLayout");
+shouldBe("maxWidthZeroFixedLayout.getBoundingClientRect().width","0");
+
+document.body.removeChild(document.getElementById('container'));
+</script>
+<script src=""
+<body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (130773 => 130774)


--- trunk/Source/WebCore/ChangeLog	2012-10-09 16:50:26 UTC (rev 130773)
+++ trunk/Source/WebCore/ChangeLog	2012-10-09 16:55:46 UTC (rev 130774)
@@ -1,3 +1,22 @@
+2012-10-09  Pravin D  <[email protected]>
+
+        max-width property is does not overriding the width properties for css tables(display:table)
+        https://bugs.webkit.org/show_bug.cgi?id=98455
+
+        Reviewed by Tony Chang.
+
+        The max-width property determines the maximum computed width an element can have. In case of css tables(display:table),
+        the computed was not being limited by the max-width property. The current patch fixes this issue.
+
+        Test: fast/table/css-table-max-width.html
+
+        * rendering/RenderTable.cpp:
+        (WebCore::RenderTable::updateLogicalWidth):
+         Logic to compute the logical width of an element such that it does not exceed the max-width value.
+         Also when both min-width and max-width are present, the following contraint is used to compute the logical width:
+           1) min-width < Computed LogicalWidth < max-width, when min-width < max-width.
+           2) Computed LogicalWidth = min-width, when min-width > max-width.
+
 2012-10-09  Harald Alvestrand  <[email protected]>
 
         Change PeerConnection getStats function to single value local / remote

Modified: trunk/Source/WebCore/rendering/RenderTable.cpp (130773 => 130774)


--- trunk/Source/WebCore/rendering/RenderTable.cpp	2012-10-09 16:50:26 UTC (rev 130773)
+++ trunk/Source/WebCore/rendering/RenderTable.cpp	2012-10-09 16:55:46 UTC (rev 130774)
@@ -255,10 +255,20 @@
     // Ensure we aren't smaller than our min preferred width.
     setLogicalWidth(max<int>(logicalWidth(), minPreferredLogicalWidth()));
 
+    
+    // Ensure we aren't bigger than our max-width style.
+    Length styleMaxLogicalWidth = style()->logicalMaxWidth();
+    if (styleMaxLogicalWidth.isSpecified() && !styleMaxLogicalWidth.isNegative()) {
+        LayoutUnit computedMaxLogicalWidth = convertStyleLogicalWidthToComputedWidth(styleMaxLogicalWidth, availableLogicalWidth);
+        setLogicalWidth(min<int>(logicalWidth(), computedMaxLogicalWidth));
+    }
+
     // Ensure we aren't smaller than our min-width style.
     Length styleMinLogicalWidth = style()->logicalMinWidth();
-    if (styleMinLogicalWidth.isSpecified() && styleMinLogicalWidth.isPositive())
-        setLogicalWidth(max<int>(logicalWidth(), convertStyleLogicalWidthToComputedWidth(styleMinLogicalWidth, availableLogicalWidth)));
+    if (styleMinLogicalWidth.isSpecified() && !styleMinLogicalWidth.isNegative()) {
+        LayoutUnit computedMinLogicalWidth = convertStyleLogicalWidthToComputedWidth(styleMinLogicalWidth, availableLogicalWidth);
+        setLogicalWidth(max<int>(logicalWidth(), computedMinLogicalWidth));
+    }
 
     // Finally, with our true width determined, compute our margins for real.
     setMarginStart(0);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to