Bug 1431041: Fix placeholder-shown when the value of the input is invalid. r=smaug
Wow, the setup for <input type="number"> is really weird :(. Looking at the callers, this should be sane. MozReview-Commit-ID: C0ZNNSdg0Hb
This commit is contained in:
@@ -6600,7 +6600,7 @@ HTMLInputElement::IntrinsicState() const
|
||||
|
||||
if (PlaceholderApplies() &&
|
||||
HasAttr(kNameSpaceID_None, nsGkAtoms::placeholder) &&
|
||||
IsValueEmpty()) {
|
||||
ShouldShowPlaceholder()) {
|
||||
state |= NS_EVENT_STATE_PLACEHOLDERSHOWN;
|
||||
}
|
||||
|
||||
@@ -6611,6 +6611,24 @@ HTMLInputElement::IntrinsicState() const
|
||||
return state;
|
||||
}
|
||||
|
||||
bool
|
||||
HTMLInputElement::ShouldShowPlaceholder() const
|
||||
{
|
||||
MOZ_ASSERT(PlaceholderApplies());
|
||||
|
||||
if (!IsValueEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// For number controls, even though the (sanitized) value is empty, there may
|
||||
// be text in the anon text control.
|
||||
if (nsNumberControlFrame* frame = do_QueryFrame(GetPrimaryFrame())) {
|
||||
return frame->AnonTextControlIsEmpty();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
HTMLInputElement::AddStates(EventStates aStates)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user