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

Unified Diff: Source/core/html/forms/TextFieldInputType.cpp

Issue 1280423002: CSS4: Implement :placeholder-shown pseudo class (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updated as per review comments Created 5 years, 4 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
Index: Source/core/html/forms/TextFieldInputType.cpp
diff --git a/Source/core/html/forms/TextFieldInputType.cpp b/Source/core/html/forms/TextFieldInputType.cpp
index 4c435fcc2e42d408d453d76da7008e956f18db75..42b93f04d328b388e3c17aac7950eb0a9bf7dfde 100644
--- a/Source/core/html/forms/TextFieldInputType.cpp
+++ b/Source/core/html/forms/TextFieldInputType.cpp
@@ -462,6 +462,7 @@ void TextFieldInputType::updatePlaceholderText()
RefPtrWillBeRawPtr<HTMLElement> newElement = HTMLDivElement::create(element().document());
placeholder = newElement.get();
placeholder->setShadowPseudoId(AtomicString("-webkit-input-placeholder", AtomicString::ConstructFromLiteral));
+ placeholder->setInlineStyleProperty(CSSPropertyDisplay, element().isPlaceholderVisible() ? CSSValueBlock : CSSValueNone, true);
placeholder->setAttribute(idAttr, ShadowElementNames::placeholder());
Element* container = containerElement();
Node* previous = container ? container : element().innerEditorElement();
@@ -497,7 +498,7 @@ void TextFieldInputType::subtreeHasChanged()
// sanitizeUserInputValue().
// sanitizeValue() is needed because IME input doesn't dispatch BeforeTextInsertedEvent.
element().setValueFromRenderer(sanitizeValue(convertFromVisibleValue(element().innerEditorValue())));
- element().updatePlaceholderVisibility(false);
+ element().updatePlaceholderVisibility();
element().pseudoStateChanged(CSSSelector::PseudoValid);
element().pseudoStateChanged(CSSSelector::PseudoInvalid);
@@ -526,7 +527,7 @@ void TextFieldInputType::updateView()
{
if (!element().suggestedValue().isNull()) {
element().setInnerEditorValue(element().suggestedValue());
- element().updatePlaceholderVisibility(false);
+ element().updatePlaceholderVisibility();
} else if (element().needsToUpdateViewValue()) {
// Update the view only if needsToUpdateViewValue is true. It protects
// an unacceptable view value from being overwritten with the DOM value.
@@ -535,7 +536,7 @@ void TextFieldInputType::updateView()
// updated. In this case, updateView() is called but we should not
// update the view value.
element().setInnerEditorValue(visibleValue());
- element().updatePlaceholderVisibility(false);
+ element().updatePlaceholderVisibility();
}
}

Powered by Google App Engine
This is Rietveld 408576698