From 82b607721d73d45574aca727903522dcf16b5924 Mon Sep 17 00:00:00 2001 From: Ojan Vafai Date: Wed, 26 Nov 2014 16:39:41 -0800 Subject: [PATCH] Make fixed-width elements not center by default. e223e0c6d51f027196a2597b556641328a65d4b5 accidentally sent all elements down the margin:auto codepath. The patch incorrectly removed just the "&& containingBlockStyle->textAlign() == WEBKIT_CENTER" instead of the whole clause. R=abarth@chromium.org Review URL: https://codereview.chromium.org/760143002 --- engine/core/rendering/RenderBox.cpp | 3 +-- tests/layout/ellipsis-expected.txt | 10 +++++----- tests/layout/fixed-width-expected.txt | 6 ++++++ tests/layout/fixed-width.sky | 4 ++++ tests/lowlevel/iframe-expected.txt | 8 ++++---- tests/lowlevel/img-expected.txt | 4 ++-- 6 files changed, 22 insertions(+), 13 deletions(-) create mode 100644 tests/layout/fixed-width-expected.txt create mode 100644 tests/layout/fixed-width.sky diff --git a/engine/core/rendering/RenderBox.cpp b/engine/core/rendering/RenderBox.cpp index 2706c3bc46b..5b684cc259a 100644 --- a/engine/core/rendering/RenderBox.cpp +++ b/engine/core/rendering/RenderBox.cpp @@ -1647,8 +1647,7 @@ void RenderBox::computeMarginsForDirection(MarginDirection flowDirection, const // CSS 2.1: "If both 'margin-left' and 'margin-right' are 'auto', their used values are equal. This horizontally centers the element // with respect to the edges of the containing block." - if ((marginStartLength.isAuto() && marginEndLength.isAuto() && marginBoxWidth < containerWidth) - || (!marginStartLength.isAuto() && !marginEndLength.isAuto())) { + if (marginStartLength.isAuto() && marginEndLength.isAuto() && marginBoxWidth < containerWidth) { // Other browsers center the margin box for align=center elements so we match them here. LayoutUnit centeredMarginBoxStart = std::max(0, (containerWidth - childWidth - marginStartWidth - marginEndWidth) / 2); marginStart = centeredMarginBoxStart + marginStartWidth; diff --git a/tests/layout/ellipsis-expected.txt b/tests/layout/ellipsis-expected.txt index 5d3ada6bfa5..5efb8354b0a 100644 --- a/tests/layout/ellipsis-expected.txt +++ b/tests/layout/ellipsis-expected.txt @@ -2,20 +2,20 @@ layer at (0,0) size 800x600 RenderView {#document} at (0,0) size 800x600 layer at (0,0) size 800x94 RenderBlock {sky} at (0,0) size 800x94 -layer at (372,0) size 56x69 clip at (375,3) size 50x63 scrollWidth 93 - RenderBlock {div} at (372,0) size 56x69 [border: (3px solid #0000FF)] +layer at (0,0) size 56x69 clip at (3,3) size 50x63 scrollWidth 93 + RenderBlock {div} at (0,0) size 56x69 [border: (3px solid #0000FF)] RenderBlock (anonymous) at (3,3) size 50x19 RenderText {#text} at (0,0) size 91x19 text run at (0,0) width 91: "These lines" RenderBlock (anonymous) at (3,47) size 50x19 RenderText {#text} at (0,0) size 94x19 text run at (0,0) width 94: "all ellipsize." -layer at (375,22) size 56x25 backgroundClip at (375,22) size 50x25 clip at (378,25) size 47x19 outlineClip at (375,3) size 50x63 scrollWidth 53 +layer at (3,22) size 56x25 backgroundClip at (3,22) size 50x25 clip at (6,25) size 47x19 outlineClip at (3,3) size 50x63 scrollWidth 53 RenderBlock {p} at (3,22) size 56x25 [border: (3px solid #FF0000)] RenderText {#text} at (3,3) size 54x19 text run at (3,3) width 54: "should" -layer at (372,69) size 56x25 clip at (375,72) size 50x19 scrollWidth 117 - RenderBlock {p} at (372,69) size 56x25 [border: (3px solid #FF0000)] +layer at (0,69) size 56x25 clip at (3,72) size 50x19 scrollWidth 117 + RenderBlock {p} at (0,69) size 56x25 [border: (3px solid #FF0000)] RenderInline {span} at (0,0) size 117x19 RenderText {#text} at (3,3) size 117x19 text run at (3,3) width 117: "As should this." diff --git a/tests/layout/fixed-width-expected.txt b/tests/layout/fixed-width-expected.txt new file mode 100644 index 00000000000..42df0542211 --- /dev/null +++ b/tests/layout/fixed-width-expected.txt @@ -0,0 +1,6 @@ +layer at (0,0) size 800x600 + RenderView {#document} at (0,0) size 800x600 +layer at (0,0) size 800x50 + RenderBlock {sky} at (0,0) size 800x50 + RenderBlock {div} at (0,0) size 50x50 [bgcolor=#FFC0CB] + diff --git a/tests/layout/fixed-width.sky b/tests/layout/fixed-width.sky new file mode 100644 index 00000000000..d368882214e --- /dev/null +++ b/tests/layout/fixed-width.sky @@ -0,0 +1,4 @@ + + +
+
diff --git a/tests/lowlevel/iframe-expected.txt b/tests/lowlevel/iframe-expected.txt index 0cd442943b8..4f59b2b00a2 100644 --- a/tests/lowlevel/iframe-expected.txt +++ b/tests/lowlevel/iframe-expected.txt @@ -20,8 +20,8 @@ layer at (0,0) size 800x506 RenderBlock (anonymous) at (0,59) size 800x19 RenderText {#text} at (0,0) size 76x19 text run at (0,0) width 76: "correctly." -layer at (230,19) size 340x190 - RenderReplaced {iframe} at (230,19) size 340x190 [border: (20px solid #000000)] -layer at (250,447) size 300x40 - RenderReplaced {iframe} at (250,19) size 300x40 +layer at (0,19) size 340x190 + RenderReplaced {iframe} at (0,19) size 340x190 [border: (20px solid #000000)] +layer at (0,447) size 300x40 + RenderReplaced {iframe} at (0,19) size 300x40 diff --git a/tests/lowlevel/img-expected.txt b/tests/lowlevel/img-expected.txt index 8ca4ad5caff..329fb598e62 100644 --- a/tests/lowlevel/img-expected.txt +++ b/tests/lowlevel/img-expected.txt @@ -2,6 +2,6 @@ layer at (0,0) size 800x600 RenderView {#document} at (0,0) size 800x600 layer at (0,0) size 800x89 RenderBlock {foo} at (0,0) size 800x89 - RenderImage {img} at (272,0) size 256x64 - RenderImage {img} at (350,64) size 100x25 + RenderImage {img} at (0,0) size 256x64 + RenderImage {img} at (0,64) size 100x25