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

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: Addressing comments for LayoutTests and fix for layouttest that get failed 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/forms/button-set-display-flex-justifyContent-center-expected.html ('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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 { 90 {
91 ASSERT(innerStyle->refCount() == 1); 91 ASSERT(innerStyle->refCount() == 1);
92 // RenderBlock::createAnonymousBlock creates a new RenderStyle, so this is 92 // RenderBlock::createAnonymousBlock creates a new RenderStyle, so this is
93 // safe to modify. 93 // safe to modify.
94 innerStyle->setFlexGrow(1.0f); 94 innerStyle->setFlexGrow(1.0f);
95 // Use margin:auto instead of align-items:center to get safe centering, i.e. 95 // 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. 96 // when the content overflows, treat it the same as align-items: flex-start.
97 innerStyle->setMarginTop(Length()); 97 innerStyle->setMarginTop(Length());
98 innerStyle->setMarginBottom(Length()); 98 innerStyle->setMarginBottom(Length());
99 innerStyle->setFlexDirection(style()->flexDirection()); 99 innerStyle->setFlexDirection(style()->flexDirection());
100 innerStyle->setJustifyContent(style()->justifyContent());
101 innerStyle->setFlexWrap(style()->flexWrap());
102 innerStyle->setAlignItems(style()->alignItems());
103 innerStyle->setAlignContent(style()->alignContent());
100 } 104 }
101 105
102 bool RenderButton::canHaveGeneratedChildren() const 106 bool RenderButton::canHaveGeneratedChildren() const
103 { 107 {
104 // Input elements can't have generated children, but button elements can. We 'll 108 // 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 109 // write the code assuming any other button types that might emerge in the f uture
106 // can also have children. 110 // can also have children.
107 return !isHTMLInputElement(*node()); 111 return !isHTMLInputElement(*node());
108 } 112 }
109 113
(...skipping 15 matching lines...) Expand all
125 // baseline for the empty case manually here. 129 // baseline for the empty case manually here.
126 if (direction == HorizontalLine) 130 if (direction == HorizontalLine)
127 return marginTop() + borderTop() + paddingTop() + contentHeight(); 131 return marginTop() + borderTop() + paddingTop() + contentHeight();
128 132
129 return marginRight() + borderRight() + paddingRight() + contentWidth(); 133 return marginRight() + borderRight() + paddingRight() + contentWidth();
130 } 134 }
131 return RenderFlexibleBox::baselinePosition(baseline, firstLine, direction, l inePositionMode); 135 return RenderFlexibleBox::baselinePosition(baseline, firstLine, direction, l inePositionMode);
132 } 136 }
133 137
134 } // namespace WebCore 138 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/fast/forms/button-set-display-flex-justifyContent-center-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698