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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/LayoutTextControlSingleLine.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutTextControlSingleLine.cpp b/third_party/WebKit/Source/core/layout/LayoutTextControlSingleLine.cpp
index a86df4b6cec4bb37ef1f3601a7e9612ad6e4c39a..b8619f2aff453f0e0820542e1c912c14261effdc 100644
--- a/third_party/WebKit/Source/core/layout/LayoutTextControlSingleLine.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutTextControlSingleLine.cpp
@@ -165,7 +165,6 @@ void LayoutTextControlSingleLine::layout()
if (innerEditorLayoutObject)
innerEditorSize = innerEditorLayoutObject->size();
placeholderBox->mutableStyleRef().setWidth(Length(innerEditorSize.width() - placeholderBox->borderAndPaddingWidth(), Fixed));
- placeholderBox->mutableStyleRef().setHeight(Length(innerEditorSize.height() - placeholderBox->borderAndPaddingHeight(), Fixed));
bool neededLayout = placeholderBox->needsLayout();
placeholderBox->layoutIfNeeded();
LayoutPoint textOffset;
@@ -175,6 +174,16 @@ void LayoutTextControlSingleLine::layout()
textOffset += toLayoutSize(editingViewPortElement()->layoutBox()->location());
if (containerLayoutObject)
textOffset += toLayoutSize(containerLayoutObject->location());
+ if (innerEditorLayoutObject) {
+ // We use inlineBlockBaseline() for innerEditor because it has no
+ // inline boxes when we show the placeholder.
+ int innerEditorBaseline = innerEditorLayoutObject->inlineBlockBaseline(HorizontalLine);
+ // We use firstLineBoxBaseline() for placeholder.
+ // TODO(tkent): It's inconsistent with innerEditorBaseline. However
+ // placeholderBox->inlineBlockBase() is unexpectedly larger.
+ int placeholderBaseline = placeholderBox->firstLineBoxBaseline();
+ textOffset += LayoutSize(0, innerEditorBaseline - placeholderBaseline);
+ }
placeholderBox->setLocation(textOffset);
// The placeholder gets layout last, after the parent text control and its other children,
« 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