Bug 609162 - Do not invalidate textarea at every value change when a placeholder is set. r=bz a=bsmedberg
authorMounir Lamouri <mounir.lamouri@gmail.com>
Wed, 24 Nov 2010 00:46:49 +0100
changeset 58141 a26199cd24df75cd83fdce0439a77f722e0a7c0e
parent 58140 023f675df2a0736749c35e0ac35f8feed46d76b5
child 58142 0dccfde3b86c1e7d1aae75b0f941675c3d82412e
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
reviewersbz, bsmedberg
bugs609162
milestone2.0b8pre
Bug 609162 - Do not invalidate textarea at every value change when a placeholder is set. r=bz a=bsmedberg
content/html/content/src/nsHTMLTextAreaElement.cpp
--- a/content/html/content/src/nsHTMLTextAreaElement.cpp
+++ b/content/html/content/src/nsHTMLTextAreaElement.cpp
@@ -556,22 +556,25 @@ nsHTMLTextAreaElement::SetUserInput(cons
   }
   SetValueInternal(aValue, PR_TRUE);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsHTMLTextAreaElement::SetValueChanged(PRBool aValueChanged)
 {
+  PRBool previousValue = mValueChanged;
+
   mValueChanged = aValueChanged;
   if (!aValueChanged && !mState->IsEmpty()) {
     mState->EmptyValue();
   }
 
-  if (HasAttr(kNameSpaceID_None, nsGkAtoms::placeholder)) {
+  if (mValueChanged != previousValue &&
+      HasAttr(kNameSpaceID_None, nsGkAtoms::placeholder)) {
     nsIDocument* doc = GetCurrentDoc();
     if (doc) {
       mozAutoDocUpdate upd(doc, UPDATE_CONTENT_STATE, PR_TRUE);
       doc->ContentStatesChanged(this, nsnull, NS_EVENT_STATE_MOZ_PLACEHOLDER);
     }
   }
 
   return NS_OK;