diff --git a/content/html/content/src/nsHTMLInputElement.cpp b/content/html/content/src/nsHTMLInputElement.cpp
index b626f8109f8..aee46bd28b4 100644
--- a/content/html/content/src/nsHTMLInputElement.cpp
+++ b/content/html/content/src/nsHTMLInputElement.cpp
@@ -3868,12 +3868,13 @@ nsHTMLInputElement::UpdatePatternMismatchValidityState()
void
nsHTMLInputElement::UpdateAllValidityStates(PRBool aNotify)
{
+ PRBool validBefore = IsValid();
UpdateTooLongValidityState();
UpdateValueMissingValidityState();
UpdateTypeMismatchValidityState();
UpdatePatternMismatchValidityState();
- if (aNotify) {
+ if (validBefore != IsValid() && aNotify) {
nsIDocument* doc = GetCurrentDoc();
if (doc) {
MOZ_AUTO_DOC_UPDATE(doc, UPDATE_CONTENT_STATE, PR_TRUE);
diff --git a/content/html/content/src/nsHTMLTextAreaElement.cpp b/content/html/content/src/nsHTMLTextAreaElement.cpp
index 6f5c5d08fe9..4058c592e78 100644
--- a/content/html/content/src/nsHTMLTextAreaElement.cpp
+++ b/content/html/content/src/nsHTMLTextAreaElement.cpp
@@ -1386,20 +1386,27 @@ NS_IMETHODIMP_(void)
nsHTMLTextAreaElement::OnValueChanged(PRBool aNotify)
{
// Update the validity state
+ PRBool validBefore = IsValid();
UpdateTooLongValidityState();
UpdateValueMissingValidityState();
if (aNotify) {
- nsIDocument* doc = GetCurrentDoc();
- if (doc) {
- MOZ_AUTO_DOC_UPDATE(doc, UPDATE_CONTENT_STATE, PR_TRUE);
- doc->ContentStatesChanged(this, nsnull, NS_EVENT_STATE_VALID |
- NS_EVENT_STATE_INVALID |
- // We could check if that is
- // really needed but considering
- // we are already updating the
- // state for valid/invalid...
- NS_EVENT_STATE_MOZ_PLACEHOLDER);
+ nsEventStates states;
+ if (validBefore != IsValid()) {
+ states |= (NS_EVENT_STATE_VALID | NS_EVENT_STATE_INVALID);
+ }
+
+ if (HasAttr(kNameSpaceID_None, nsGkAtoms::placeholder)
+ && !nsContentUtils::IsFocusedContent((nsIContent*)(this))) {
+ states |= NS_EVENT_STATE_MOZ_PLACEHOLDER;
+ }
+
+ if (!states.IsEmpty()) {
+ nsIDocument* doc = GetCurrentDoc();
+ if (doc) {
+ MOZ_AUTO_DOC_UPDATE(doc, UPDATE_CONTENT_STATE, PR_TRUE);
+ doc->ContentStatesChanged(this, nsnull, states);
+ }
}
}
}