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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutTextControlSingleLine.cpp

Issue 1499063002: input's placeholder is inconsistently laid out (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Upgraded the test to js-test.js for real! Created 5 years 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 | « third_party/WebKit/Source/core/layout/LayoutBox.cpp ('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) 2006, 2007, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2010 Apple Inc. All rights reserved.
3 * (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 3 * (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
4 * Copyright (C) 2010 Google Inc. All rights reserved. 4 * Copyright (C) 2010 Google Inc. All rights reserved.
5 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 5 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 114
115 // We don't honor paddings and borders for textfields without decorations 115 // We don't honor paddings and borders for textfields without decorations
116 // and type=search if the text height is taller than the contentHeight() 116 // and type=search if the text height is taller than the contentHeight()
117 // because of compability. 117 // because of compability.
118 118
119 LayoutBox* innerEditorLayoutObject = innerEditorElement()->layoutBox(); 119 LayoutBox* innerEditorLayoutObject = innerEditorElement()->layoutBox();
120 bool innerEditorLayoutObjectHadLayout = innerEditorLayoutObject && innerEdit orLayoutObject->needsLayout(); 120 bool innerEditorLayoutObjectHadLayout = innerEditorLayoutObject && innerEdit orLayoutObject->needsLayout();
121 LayoutBox* viewPortLayoutObject = editingViewPortElement() ? editingViewPort Element()->layoutBox() : 0; 121 LayoutBox* viewPortLayoutObject = editingViewPortElement() ? editingViewPort Element()->layoutBox() : 0;
122 122
123 // To ensure consistency between layouts, we need to reset any conditionally overriden height. 123 // To ensure consistency between layouts, we need to reset any conditionally overriden height.
124 if (innerEditorLayoutObject && !innerEditorLayoutObject->styleRef().logicalH eight().isAuto()) { 124 if (innerEditorLayoutObject) {
125 innerEditorLayoutObject->mutableStyleRef().setLogicalHeight(Length(Auto) ); 125 innerEditorLayoutObject->clearOverrideLogicalContentHeight();
126 // TODO(jchaffraix): We could probably skip some of these due to
127 // forcing children relayout below but keeping them for safety for now.
126 layoutScope.setNeedsLayout(innerEditorLayoutObject, LayoutInvalidationRe ason::TextControlChanged); 128 layoutScope.setNeedsLayout(innerEditorLayoutObject, LayoutInvalidationRe ason::TextControlChanged);
127 HTMLElement* placeholderElement = inputElement()->placeholderElement(); 129 HTMLElement* placeholderElement = inputElement()->placeholderElement();
128 if (LayoutBox* placeholderBox = placeholderElement ? placeholderElement- >layoutBox() : 0) 130 if (LayoutBox* placeholderBox = placeholderElement ? placeholderElement- >layoutBox() : 0)
129 layoutScope.setNeedsLayout(placeholderBox, LayoutInvalidationReason: :TextControlChanged); 131 layoutScope.setNeedsLayout(placeholderBox, LayoutInvalidationReason: :TextControlChanged);
130 } 132 }
133 // TODO(jchaffraix): This logic is not correct and will yield to bugs such
134 // as crbug.com/529252. The fix is similar to what is done with
135 // innerEditorLayoutObject above.
131 if (viewPortLayoutObject && !viewPortLayoutObject->styleRef().logicalHeight( ).isAuto()) { 136 if (viewPortLayoutObject && !viewPortLayoutObject->styleRef().logicalHeight( ).isAuto()) {
132 viewPortLayoutObject->mutableStyleRef().setLogicalHeight(Length(Auto)); 137 viewPortLayoutObject->mutableStyleRef().setLogicalHeight(Length(Auto));
133 layoutScope.setNeedsLayout(viewPortLayoutObject, LayoutInvalidationReaso n::TextControlChanged); 138 layoutScope.setNeedsLayout(viewPortLayoutObject, LayoutInvalidationReaso n::TextControlChanged);
134 } 139 }
135 140
136 LayoutBlockFlow::layoutBlock(false); 141 // This is the measuring phase. Thus we force children to be relayout so
142 // that the checks below are executed consistently.
143 LayoutBlockFlow::layoutBlock(true);
137 144
138 Element* container = containerElement(); 145 Element* container = containerElement();
139 LayoutBox* containerLayoutObject = container ? container->layoutBox() : 0; 146 LayoutBox* containerLayoutObject = container ? container->layoutBox() : 0;
140 147
141 // Set the text block height 148 // Set the text block height
142 LayoutUnit desiredLogicalHeight = textBlockLogicalHeight(); 149 LayoutUnit desiredLogicalHeight = textBlockLogicalHeight();
143 LayoutUnit logicalHeightLimit = computeLogicalHeightLimit(); 150 LayoutUnit logicalHeightLimit = computeLogicalHeightLimit();
144 if (innerEditorLayoutObject && innerEditorLayoutObject->logicalHeight() > lo gicalHeightLimit) { 151 if (innerEditorLayoutObject && innerEditorLayoutObject->logicalHeight() > lo gicalHeightLimit) {
145 if (desiredLogicalHeight != innerEditorLayoutObject->logicalHeight()) 152 if (desiredLogicalHeight != innerEditorLayoutObject->logicalHeight())
146 layoutScope.setNeedsLayout(this, LayoutInvalidationReason::TextContr olChanged); 153 layoutScope.setNeedsLayout(this, LayoutInvalidationReason::TextContr olChanged);
147 154
148 m_desiredInnerEditorLogicalHeight = desiredLogicalHeight; 155 m_desiredInnerEditorLogicalHeight = desiredLogicalHeight;
149 156
150 innerEditorLayoutObject->mutableStyleRef().setLogicalHeight(Length(desir edLogicalHeight, Fixed)); 157 innerEditorLayoutObject->setOverrideLogicalContentHeight(desiredLogicalH eight);
151 layoutScope.setNeedsLayout(innerEditorLayoutObject, LayoutInvalidationRe ason::TextControlChanged); 158 layoutScope.setNeedsLayout(innerEditorLayoutObject, LayoutInvalidationRe ason::TextControlChanged);
152 if (viewPortLayoutObject) { 159 if (viewPortLayoutObject) {
153 viewPortLayoutObject->mutableStyleRef().setLogicalHeight(Length(desi redLogicalHeight, Fixed)); 160 viewPortLayoutObject->mutableStyleRef().setLogicalHeight(Length(desi redLogicalHeight, Fixed));
154 layoutScope.setNeedsLayout(viewPortLayoutObject, LayoutInvalidationR eason::TextControlChanged); 161 layoutScope.setNeedsLayout(viewPortLayoutObject, LayoutInvalidationR eason::TextControlChanged);
155 } 162 }
156 } 163 }
157 // The container might be taller because of decoration elements. 164 // The container might be taller because of decoration elements.
158 if (containerLayoutObject) { 165 if (containerLayoutObject) {
159 containerLayoutObject->layoutIfNeeded(); 166 containerLayoutObject->layoutIfNeeded();
160 LayoutUnit containerLogicalHeight = containerLayoutObject->logicalHeight (); 167 LayoutUnit containerLogicalHeight = containerLayoutObject->logicalHeight ();
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 Element* viewPort = editingViewPortElement(); 252 Element* viewPort = editingViewPortElement();
246 if (LayoutObject* viewPortLayoutObject = viewPort ? viewPort->layoutObject() : 0) { 253 if (LayoutObject* viewPortLayoutObject = viewPort ? viewPort->layoutObject() : 0) {
247 viewPortLayoutObject->mutableStyleRef().setHeight(Length()); 254 viewPortLayoutObject->mutableStyleRef().setHeight(Length());
248 viewPortLayoutObject->mutableStyleRef().setWidth(Length()); 255 viewPortLayoutObject->mutableStyleRef().setWidth(Length());
249 } 256 }
250 Element* container = containerElement(); 257 Element* container = containerElement();
251 if (LayoutObject* containerLayoutObject = container ? container->layoutObjec t() : 0) { 258 if (LayoutObject* containerLayoutObject = container ? container->layoutObjec t() : 0) {
252 containerLayoutObject->mutableStyleRef().setHeight(Length()); 259 containerLayoutObject->mutableStyleRef().setHeight(Length());
253 containerLayoutObject->mutableStyleRef().setWidth(Length()); 260 containerLayoutObject->mutableStyleRef().setWidth(Length());
254 } 261 }
255 LayoutObject* innerEditorLayoutObject = innerEditorElement()->layoutObject() ;
256 if (innerEditorLayoutObject && diff.needsFullLayout())
257 innerEditorLayoutObject->setNeedsLayoutAndFullPaintInvalidation(LayoutIn validationReason::StyleChange);
258 if (HTMLElement* placeholder = inputElement()->placeholderElement()) 262 if (HTMLElement* placeholder = inputElement()->placeholderElement())
259 placeholder->setInlineStyleProperty(CSSPropertyTextOverflow, textShouldB eTruncated() ? CSSValueEllipsis : CSSValueClip); 263 placeholder->setInlineStyleProperty(CSSPropertyTextOverflow, textShouldB eTruncated() ? CSSValueEllipsis : CSSValueClip);
260 setHasOverflowClip(false); 264 setHasOverflowClip(false);
261 } 265 }
262 266
263 void LayoutTextControlSingleLine::capsLockStateMayHaveChanged() 267 void LayoutTextControlSingleLine::capsLockStateMayHaveChanged()
264 { 268 {
265 if (!node()) 269 if (!node())
266 return; 270 return;
267 271
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 if (innerEditorElement()) 449 if (innerEditorElement())
446 innerEditorElement()->setScrollTop(newTop); 450 innerEditorElement()->setScrollTop(newTop);
447 } 451 }
448 452
449 HTMLInputElement* LayoutTextControlSingleLine::inputElement() const 453 HTMLInputElement* LayoutTextControlSingleLine::inputElement() const
450 { 454 {
451 return toHTMLInputElement(node()); 455 return toHTMLInputElement(node());
452 } 456 }
453 457
454 } 458 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBox.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698