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

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

Issue 1616553004: Align placeholder element and inner-editor element at their baselines. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 | « third_party/WebKit/LayoutTests/platform/mac/fast/forms/placeholder-position-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) 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 centerContainerIfNeeded(containerLayoutObject); 158 centerContainerIfNeeded(containerLayoutObject);
159 } 159 }
160 160
161 HTMLElement* placeholderElement = inputElement()->placeholderElement(); 161 HTMLElement* placeholderElement = inputElement()->placeholderElement();
162 if (LayoutBox* placeholderBox = placeholderElement ? placeholderElement->lay outBox() : 0) { 162 if (LayoutBox* placeholderBox = placeholderElement ? placeholderElement->lay outBox() : 0) {
163 LayoutSize innerEditorSize; 163 LayoutSize innerEditorSize;
164 164
165 if (innerEditorLayoutObject) 165 if (innerEditorLayoutObject)
166 innerEditorSize = innerEditorLayoutObject->size(); 166 innerEditorSize = innerEditorLayoutObject->size();
167 placeholderBox->mutableStyleRef().setWidth(Length(innerEditorSize.width( ) - placeholderBox->borderAndPaddingWidth(), Fixed)); 167 placeholderBox->mutableStyleRef().setWidth(Length(innerEditorSize.width( ) - placeholderBox->borderAndPaddingWidth(), Fixed));
168 placeholderBox->mutableStyleRef().setHeight(Length(innerEditorSize.heigh t() - placeholderBox->borderAndPaddingHeight(), Fixed));
169 bool neededLayout = placeholderBox->needsLayout(); 168 bool neededLayout = placeholderBox->needsLayout();
170 placeholderBox->layoutIfNeeded(); 169 placeholderBox->layoutIfNeeded();
171 LayoutPoint textOffset; 170 LayoutPoint textOffset;
172 if (innerEditorLayoutObject) 171 if (innerEditorLayoutObject)
173 textOffset = innerEditorLayoutObject->location(); 172 textOffset = innerEditorLayoutObject->location();
174 if (editingViewPortElement() && editingViewPortElement()->layoutBox()) 173 if (editingViewPortElement() && editingViewPortElement()->layoutBox())
175 textOffset += toLayoutSize(editingViewPortElement()->layoutBox()->lo cation()); 174 textOffset += toLayoutSize(editingViewPortElement()->layoutBox()->lo cation());
176 if (containerLayoutObject) 175 if (containerLayoutObject)
177 textOffset += toLayoutSize(containerLayoutObject->location()); 176 textOffset += toLayoutSize(containerLayoutObject->location());
177 if (innerEditorLayoutObject) {
178 // We use inlineBlockBaseline() for innerEditor because it has no
179 // inline boxes when we show the placeholder.
180 int innerEditorBaseline = innerEditorLayoutObject->inlineBlockBaseli ne(HorizontalLine);
181 // We use firstLineBoxBaseline() for placeholder.
182 // TODO(tkent): It's inconsistent with innerEditorBaseline. However
183 // placeholderBox->inlineBlockBase() is unexpectedly larger.
184 int placeholderBaseline = placeholderBox->firstLineBoxBaseline();
185 textOffset += LayoutSize(0, innerEditorBaseline - placeholderBaselin e);
186 }
178 placeholderBox->setLocation(textOffset); 187 placeholderBox->setLocation(textOffset);
179 188
180 // The placeholder gets layout last, after the parent text control and i ts other children, 189 // The placeholder gets layout last, after the parent text control and i ts other children,
181 // so in order to get the correct overflow from the placeholder we need to recompute it now. 190 // so in order to get the correct overflow from the placeholder we need to recompute it now.
182 if (neededLayout) 191 if (neededLayout)
183 computeOverflow(clientLogicalBottom()); 192 computeOverflow(clientLogicalBottom());
184 } 193 }
185 } 194 }
186 195
187 bool LayoutTextControlSingleLine::nodeAtPoint(HitTestResult& result, const HitTe stLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAc tion hitTestAction) 196 bool LayoutTextControlSingleLine::nodeAtPoint(HitTestResult& result, const HitTe stLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAc tion hitTestAction)
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 if (innerEditorElement()) 413 if (innerEditorElement())
405 innerEditorElement()->setScrollTop(newTop); 414 innerEditorElement()->setScrollTop(newTop);
406 } 415 }
407 416
408 HTMLInputElement* LayoutTextControlSingleLine::inputElement() const 417 HTMLInputElement* LayoutTextControlSingleLine::inputElement() const
409 { 418 {
410 return toHTMLInputElement(node()); 419 return toHTMLInputElement(node());
411 } 420 }
412 421
413 } 422 }
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/platform/mac/fast/forms/placeholder-position-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698