Index: Source/core/html/HTMLTextFormControlElement.cpp |
diff --git a/Source/core/html/HTMLTextFormControlElement.cpp b/Source/core/html/HTMLTextFormControlElement.cpp |
index 5e180c36bcb567e2f04dc97a2c729b88ba700cea..7cf1d85f7da3796e79f49ad481b216fc135b96a5 100644 |
--- a/Source/core/html/HTMLTextFormControlElement.cpp |
+++ b/Source/core/html/HTMLTextFormControlElement.cpp |
@@ -83,7 +83,7 @@ Node::InsertionNotificationRequest HTMLTextFormControlElement::insertedInto(Cont |
void HTMLTextFormControlElement::dispatchFocusEvent(Element* oldFocusedElement, WebFocusType type, InputDeviceCapabilities* sourceCapabilities) |
{ |
if (supportsPlaceholder()) |
- updatePlaceholderVisibility(false); |
+ updatePlaceholderVisibility(); |
handleFocusEvent(oldFocusedElement, type); |
HTMLFormControlElementWithState::dispatchFocusEvent(oldFocusedElement, type, sourceCapabilities); |
} |
@@ -91,7 +91,7 @@ void HTMLTextFormControlElement::dispatchFocusEvent(Element* oldFocusedElement, |
void HTMLTextFormControlElement::dispatchBlurEvent(Element* newFocusedElement, WebFocusType type, InputDeviceCapabilities* sourceCapabilities) |
{ |
if (supportsPlaceholder()) |
- updatePlaceholderVisibility(false); |
+ updatePlaceholderVisibility(); |
handleBlurEvent(); |
HTMLFormControlElementWithState::dispatchBlurEvent(newFocusedElement, type, sourceCapabilities); |
} |
@@ -147,8 +147,7 @@ bool HTMLTextFormControlElement::placeholderShouldBeVisible() const |
return supportsPlaceholder() |
&& isEmptyValue() |
&& isEmptySuggestedValue() |
- && !isPlaceholderEmpty() |
- && (!layoutObject() || layoutObject()->style()->visibility() == VISIBLE); |
+ && !isPlaceholderEmpty(); |
} |
HTMLElement* HTMLTextFormControlElement::placeholderElement() const |
@@ -156,17 +155,21 @@ HTMLElement* HTMLTextFormControlElement::placeholderElement() const |
return toHTMLElement(userAgentShadowRoot()->getElementById(ShadowElementNames::placeholder())); |
} |
-void HTMLTextFormControlElement::updatePlaceholderVisibility(bool placeholderValueChanged) |
+void HTMLTextFormControlElement::updatePlaceholderVisibility() |
{ |
- if (!supportsPlaceholder()) |
- return; |
- if (!placeholderElement() || placeholderValueChanged) |
- updatePlaceholderText(); |
HTMLElement* placeholder = placeholderElement(); |
- if (!placeholder) |
+ if (!placeholder) { |
+ updatePlaceholderText(); |
return; |
+ } |
- placeholder->setInlineStyleProperty(CSSPropertyDisplay, placeholderShouldBeVisible() ? CSSValueBlock : CSSValueNone); |
+ bool placeHolderWasVisible = isPlaceholderVisible(); |
+ setPlaceholderVisibility(placeholderShouldBeVisible()); |
+ if (placeHolderWasVisible == isPlaceholderVisible()) |
+ return; |
+ |
+ pseudoStateChanged(CSSSelector::PseudoPlaceholderShown); |
+ placeholder->setInlineStyleProperty(CSSPropertyDisplay, isPlaceholderVisible() ? CSSValueBlock : CSSValueNone, true); |
} |
void HTMLTextFormControlElement::setSelectionStart(int start) |
@@ -607,7 +610,8 @@ void HTMLTextFormControlElement::parseAttribute(const QualifiedName& name, const |
UseCounter::count(document(), UseCounter::AutocapitalizeAttribute); |
if (name == placeholderAttr) { |
- updatePlaceholderVisibility(true); |
+ updatePlaceholderText(); |
+ updatePlaceholderVisibility(); |
UseCounter::count(document(), UseCounter::PlaceholderAttribute); |
} else { |
HTMLFormControlElementWithState::parseAttribute(name, value); |