Bug 1069015 - Restore code for :placeholder-shown pseudo-class. r=dbaron

This commit is contained in:
Thomas Wisniewski
2016-08-31 14:21:44 -04:00
parent 1aba2010b6
commit eb97b29c77
12 changed files with 106 additions and 1 deletions

View File

@@ -3108,6 +3108,15 @@ HTMLInputElement::SetValueInternal(const nsAString& aValue, uint32_t aFlags)
}
}
// This call might be useless in some situations because if the element is
// a single line text control, nsTextEditorState::SetValue will call
// nsHTMLInputElement::OnValueChanged which is going to call UpdateState()
// if the element is focused. This bug 665547.
if (PlaceholderApplies() &&
HasAttr(kNameSpaceID_None, nsGkAtoms::placeholder)) {
UpdateState(true);
}
return NS_OK;
}
@@ -6488,6 +6497,12 @@ HTMLInputElement::IntrinsicState() const
}
}
if (PlaceholderApplies() &&
HasAttr(kNameSpaceID_None, nsGkAtoms::placeholder) &&
IsValueEmpty()) {
state |= NS_EVENT_STATE_PLACEHOLDERSHOWN;
}
if (mForm && !mForm->GetValidity() && IsSubmitControl()) {
state |= NS_EVENT_STATE_MOZ_SUBMITINVALID;
}
@@ -7918,6 +7933,13 @@ HTMLInputElement::OnValueChanged(bool aNotify, bool aWasInteractiveUserChange)
if (HasDirAuto()) {
SetDirectionIfAuto(true, aNotify);
}
// :placeholder-shown pseudo-class may change when the value changes.
// However, we don't want to waste cycles if the state doesn't apply.
if (PlaceholderApplies() &&
HasAttr(kNameSpaceID_None, nsGkAtoms::placeholder)) {
UpdateState(aNotify);
}
}
NS_IMETHODIMP_(bool)