mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
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
This commit is contained in:
parent
759c4387ac
commit
82b607721d
@ -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<LayoutUnit>(0, (containerWidth - childWidth - marginStartWidth - marginEndWidth) / 2);
|
||||
marginStart = centeredMarginBoxStart + marginStartWidth;
|
||||
|
||||
@ -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."
|
||||
|
||||
6
tests/layout/fixed-width-expected.txt
Normal file
6
tests/layout/fixed-width-expected.txt
Normal file
@ -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]
|
||||
|
||||
4
tests/layout/fixed-width.sky
Normal file
4
tests/layout/fixed-width.sky
Normal file
@ -0,0 +1,4 @@
|
||||
<sky>
|
||||
<import src="../resources/dump-as-render-tree.sky" />
|
||||
<div style="width: 50px; height: 50px; background-color: pink;"></div>
|
||||
</sky>
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user