Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: Source/core/rendering/RenderButton.cpp

Issue 278603002: Centering text inside a button set to display flex with justify-content: center is impossible (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixup for Mac Layout tests Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « LayoutTests/fast/repaint/button-spurious-layout-hint-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /** 1 /**
2 * Copyright (C) 2005 Apple Computer, Inc. 2 * Copyright (C) 2005 Apple Computer, Inc.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 { 82 {
83 RenderBlock::styleDidChange(diff, oldStyle); 83 RenderBlock::styleDidChange(diff, oldStyle);
84 84
85 if (m_inner) // RenderBlock handled updating the anonymous block's style. 85 if (m_inner) // RenderBlock handled updating the anonymous block's style.
86 setupInnerStyle(m_inner->style()); 86 setupInnerStyle(m_inner->style());
87 } 87 }
88 88
89 void RenderButton::setupInnerStyle(RenderStyle* innerStyle) 89 void RenderButton::setupInnerStyle(RenderStyle* innerStyle)
90 { 90 {
91 ASSERT(innerStyle->refCount() == 1); 91 ASSERT(innerStyle->refCount() == 1);
92 // RenderBlock::createAnonymousBlock creates a new RenderStyle, so this is
cbiesinger 2014/05/13 07:58:27 You need to keep this comment.
harpreet.sk 2014/05/13 09:30:44 I will keep this comment in next patch.
93 // safe to modify.
94 innerStyle->setFlexGrow(1.0f);
cbiesinger 2014/05/13 07:58:27 Why remove this line?
harpreet.sk 2014/05/13 09:30:44 Actually i removed this line as this line will dis
95 // Use margin:auto instead of align-items:center to get safe centering, i.e. 92 // Use margin:auto instead of align-items:center to get safe centering, i.e.
96 // when the content overflows, treat it the same as align-items: flex-start. 93 // when the content overflows, treat it the same as align-items: flex-start.
97 innerStyle->setMarginTop(Length()); 94 innerStyle->setMarginTop(Length());
98 innerStyle->setMarginBottom(Length()); 95 innerStyle->setMarginBottom(Length());
96
97 if (innerStyle->textAlign() == LEFT || innerStyle->textAlign() == WEBKIT_LEF T) {
98 innerStyle->setMarginRight(Length());
99 } else if (innerStyle->textAlign() == RIGHT || innerStyle->textAlign() == WE BKIT_RIGHT) {
100 innerStyle->setMarginLeft(Length());
101 } else {
102 innerStyle->setMarginLeft(Length());
103 innerStyle->setMarginRight(Length());
104 }
105
99 innerStyle->setFlexDirection(style()->flexDirection()); 106 innerStyle->setFlexDirection(style()->flexDirection());
100 } 107 }
101 108
102 bool RenderButton::canHaveGeneratedChildren() const 109 bool RenderButton::canHaveGeneratedChildren() const
103 { 110 {
104 // Input elements can't have generated children, but button elements can. We 'll 111 // Input elements can't have generated children, but button elements can. We 'll
105 // write the code assuming any other button types that might emerge in the f uture 112 // write the code assuming any other button types that might emerge in the f uture
106 // can also have children. 113 // can also have children.
107 return !isHTMLInputElement(*node()); 114 return !isHTMLInputElement(*node());
108 } 115 }
(...skipping 16 matching lines...) Expand all
125 // baseline for the empty case manually here. 132 // baseline for the empty case manually here.
126 if (direction == HorizontalLine) 133 if (direction == HorizontalLine)
127 return marginTop() + borderTop() + paddingTop() + contentHeight(); 134 return marginTop() + borderTop() + paddingTop() + contentHeight();
128 135
129 return marginRight() + borderRight() + paddingRight() + contentWidth(); 136 return marginRight() + borderRight() + paddingRight() + contentWidth();
130 } 137 }
131 return RenderFlexibleBox::baselinePosition(baseline, firstLine, direction, l inePositionMode); 138 return RenderFlexibleBox::baselinePosition(baseline, firstLine, direction, l inePositionMode);
132 } 139 }
133 140
134 } // namespace WebCore 141 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/fast/repaint/button-spurious-layout-hint-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698