Bug 641352 - Add nsHTMLTextAreaElement::IsValueEmpty() const. r=bz

This commit is contained in:
Mounir Lamouri 2011-04-12 23:33:01 -07:00
Родитель 703daa2414
Коммит 1267fd5fd1
1 изменённых файлов: 20 добавлений и 10 удалений

Просмотреть файл

@ -295,6 +295,13 @@ protected:
* Get the mutable state of the element.
*/
PRBool IsMutable() const;
/**
* Returns whether the current value is the empty string.
*
* @return whether the current value is the empty string.
*/
bool IsValueEmpty() const;
};
@ -1086,12 +1093,9 @@ nsHTMLTextAreaElement::IntrinsicState() const
}
if (HasAttr(kNameSpaceID_None, nsGkAtoms::placeholder) &&
!nsContentUtils::IsFocusedContent((nsIContent*)(this))) {
nsAutoString value;
GetValueInternal(value, PR_TRUE);
if (value.IsEmpty()) {
state |= NS_EVENT_STATE_MOZ_PLACEHOLDER;
}
!nsContentUtils::IsFocusedContent((nsIContent*)(this)) &&
IsValueEmpty()) {
state |= NS_EVENT_STATE_MOZ_PLACEHOLDER;
}
return state;
@ -1250,6 +1254,15 @@ nsHTMLTextAreaElement::IsMutable() const
return (!HasAttr(kNameSpaceID_None, nsGkAtoms::readonly) && !IsDisabled());
}
bool
nsHTMLTextAreaElement::IsValueEmpty() const
{
nsAutoString value;
GetValueInternal(value, PR_TRUE);
return value.IsEmpty();
}
// nsIConstraintValidation
NS_IMETHODIMP
@ -1297,10 +1310,7 @@ nsHTMLTextAreaElement::IsValueMissing() const
return PR_FALSE;
}
nsAutoString value;
GetValueInternal(value, PR_TRUE);
return value.IsEmpty();
return IsValueEmpty();
}
void