Title: [121274] branches/chromium/1180
Revision
121274
Author
[email protected]
Date
2012-06-26 11:58:44 -0700 (Tue, 26 Jun 2012)

Log Message

Merge 120934 - Non-fixed length margins don't work with align=center
https://bugs.webkit.org/show_bug.cgi?id=89626

Reviewed by Levi Weintraub.

Source/WebCore:

Tests: fast/block/negative-start-margin-align-center-percent.html
       fast/block/positive-margin-block-child-align-center-calc.html

Calling Length::value() is a bad idea as it returns the *raw* value of
the length. For percent and calculated length this is a bad idea as they
bear not relation to the actual computed length.

* rendering/RenderBox.cpp:
(WebCore::RenderBox::computeInlineDirectionMargins):
Fixed the code to use minimumValueForLength as this nicely takes care of the 'auto' case.

LayoutTests:

* fast/block/negative-start-margin-align-center-percent-expected.html: Added.
* fast/block/negative-start-margin-align-center-percent.html: Added.
* fast/block/positive-margin-block-child-align-center-calc-expected.html: Added.
* fast/block/positive-margin-block-child-align-center-calc.html: Added.


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

Modified Paths

Added Paths

Diff

Copied: branches/chromium/1180/LayoutTests/fast/block/negative-start-margin-align-center-percent-expected.html (from rev 120934, trunk/LayoutTests/fast/block/negative-start-margin-align-center-percent-expected.html) (0 => 121274)


--- branches/chromium/1180/LayoutTests/fast/block/negative-start-margin-align-center-percent-expected.html	                        (rev 0)
+++ branches/chromium/1180/LayoutTests/fast/block/negative-start-margin-align-center-percent-expected.html	2012-06-26 18:58:44 UTC (rev 121274)
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+body
+{
+    margin: 0px;
+}
+
+.hidTarget
+{
+    height: 100px;
+    width: 250px;
+    position: absolute;
+    left: 50px;
+    background-color: green;
+}
+
+p
+{
+    position: absolute;
+    top: 300px;
+}
+</style>
+</head>
+<body>
+    <div class="hidTarget"></div>
+    <p>
+        <a href="" Non-fixed length margins don't work with align=center<br>
+        There should be a green rectangle above with no red.
+    </p>
+</body>
+</html>

Copied: branches/chromium/1180/LayoutTests/fast/block/negative-start-margin-align-center-percent.html (from rev 120934, trunk/LayoutTests/fast/block/negative-start-margin-align-center-percent.html) (0 => 121274)


--- branches/chromium/1180/LayoutTests/fast/block/negative-start-margin-align-center-percent.html	                        (rev 0)
+++ branches/chromium/1180/LayoutTests/fast/block/negative-start-margin-align-center-percent.html	2012-06-26 18:58:44 UTC (rev 121274)
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+body {
+    margin: 0px;
+}
+
+.hidTarget
+{
+    height: 100px;
+    width: 250px;
+    position: absolute;
+    left: 50px;
+    background-color: green;
+}
+
+.sized
+{
+    margin-left: 100px;
+    width: 200px;
+}
+
+.marginLeft
+{
+    font: Ahem 10px;
+    height: 100px;
+    margin-left: -25%;
+    background-color: red;
+}
+
+p
+{
+    position: absolute;
+    top: 300px;
+}
+</style>
+</head>
+<body>
+    <div class="hidTarget"></div>
+    <div align="center" class="sized">
+        <div class="marginLeft">xxxxx xxxxx xxxxx xxxxx</div>
+    </div>
+    <p>
+        <a href="" Non-fixed length margins don't work with align=center<br>
+        There should be a green rectangle above with no red.
+    </p>
+</body>
+</html>

Copied: branches/chromium/1180/LayoutTests/fast/block/positive-margin-block-child-align-center-calc-expected.html (from rev 120934, trunk/LayoutTests/fast/block/positive-margin-block-child-align-center-calc-expected.html) (0 => 121274)


--- branches/chromium/1180/LayoutTests/fast/block/positive-margin-block-child-align-center-calc-expected.html	                        (rev 0)
+++ branches/chromium/1180/LayoutTests/fast/block/positive-margin-block-child-align-center-calc-expected.html	2012-06-26 18:58:44 UTC (rev 121274)
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+body
+{
+    margin: 0px;
+}
+
+.hidTarget {
+    position: absolute;
+    left: 100px;
+    width: 100px;
+    height: 100px;
+    background-color: green;
+}
+
+p
+{
+    position: absolute;
+    top: 300px;
+}
+</style>
+</head>
+<body>
+    <div class="hidTarget"></div>
+    <p>
+        <a href="" Non-fixed length margins don't work with align=center<br>
+        There should be a green rectangle above with no red.
+    </p>
+</body>
+</html>

Copied: branches/chromium/1180/LayoutTests/fast/block/positive-margin-block-child-align-center-calc.html (from rev 120934, trunk/LayoutTests/fast/block/positive-margin-block-child-align-center-calc.html) (0 => 121274)


--- branches/chromium/1180/LayoutTests/fast/block/positive-margin-block-child-align-center-calc.html	                        (rev 0)
+++ branches/chromium/1180/LayoutTests/fast/block/positive-margin-block-child-align-center-calc.html	2012-06-26 18:58:44 UTC (rev 121274)
@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+body {
+    margin: 0px;
+}
+
+div {
+    height: 100px;
+}
+
+.hidTarget {
+    position: absolute;
+    left: 100px;
+    width: 100px;
+    background-color: green;
+}
+
+.sized
+{
+    width: 200px;
+}
+
+.marginLeft
+{
+    margin-left: -webkit-calc(20% + 60px);
+    background-color: red;
+}
+
+p
+{
+    position: absolute;
+    top: 300px;
+}
+</style>
+</head>
+<body>
+    <div class="hidTarget"></div>
+    <div align="center" class="sized">
+        <div class="marginLeft"></div>
+    </div>
+    <p>
+        <a href="" Non-fixed length margins don't work with align=center<br>
+        There should be a green rectangle above with no red.
+    </p>
+</body>
+</html>

Modified: branches/chromium/1180/Source/WebCore/rendering/RenderBox.cpp (121273 => 121274)


--- branches/chromium/1180/Source/WebCore/rendering/RenderBox.cpp	2012-06-26 18:42:29 UTC (rev 121273)
+++ branches/chromium/1180/Source/WebCore/rendering/RenderBox.cpp	2012-06-26 18:58:44 UTC (rev 121274)
@@ -1833,8 +1833,8 @@
     if ((marginStartLength.isAuto() && marginEndLength.isAuto() && childWidth < containerWidth)
         || (!marginStartLength.isAuto() && !marginEndLength.isAuto() && containingBlock->style()->textAlign() == WEBKIT_CENTER)) {
         // Other browsers center the margin box for align=center elements so we match them here.
-        LayoutUnit marginStartWidth = marginStartLength.value();
-        LayoutUnit marginEndWidth = marginEndLength.value();
+        LayoutUnit marginStartWidth = minimumValueForLength(marginStartLength, containerWidth, renderView);
+        LayoutUnit marginEndWidth = minimumValueForLength(marginEndLength, containerWidth, renderView);
         LayoutUnit centeredMarginBoxStart = max<LayoutUnit>(0, (containerWidth - childWidth - marginStartWidth - marginEndWidth) / 2);
         containingBlock->setMarginStartForChild(this, centeredMarginBoxStart + marginStartWidth);
         containingBlock->setMarginEndForChild(this, containerWidth - childWidth - containingBlock->marginStartForChild(this) + marginEndWidth);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to