merge
authorDão Gottwald <dao@mozilla.com>
Thu, 13 Aug 2009 09:55:09 +0200
changeset 31424 bc03cb3fd8ba3593ed031f526f950e4eca89775f
parent 31423 52d5e6ab0cfea58801eb317790b19ed16b427509 (current diff)
parent 31420 a7511af18bcea2eaebe6867bbfe8475f885ada73 (diff)
child 31425 6d21a1f546736499561b105d8d7cdfbb1e2eb4bc
push id1
push usersledru@mozilla.com
push dateThu, 04 Dec 2014 17:57:20 +0000
milestone1.9.2a2pre
merge
--- a/parser/html/nsHtml5TreeOperation.cpp
+++ b/parser/html/nsHtml5TreeOperation.cpp
@@ -34,19 +34,24 @@
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsHtml5TreeOperation.h"
+#include "nsContentUtils.h"
 #include "nsNodeUtils.h"
 #include "nsAttrName.h"
 #include "nsHtml5TreeBuilder.h"
+#include "nsIDOMMutationEvent.h"
+#include "mozAutoDocUpdate.h"
+#include "nsBindingManager.h"
+#include "nsXBLBinding.h"
 
 nsHtml5TreeOperation::nsHtml5TreeOperation()
  : mOpCode(eTreeOpAppend)
 {
   MOZ_COUNT_CTOR(nsHtml5TreeOperation);
 }
 
 nsHtml5TreeOperation::~nsHtml5TreeOperation()
@@ -112,26 +117,58 @@ nsHtml5TreeOperation::Perform(nsHtml5Tre
       PRUint32 childCount = doc->GetChildCount();
       rv = doc->AppendChildTo(mNode, PR_FALSE);
       NS_ENSURE_SUCCESS(rv, rv);
       nsNodeUtils::ContentInserted(doc, mNode, childCount);
       return rv;
     }
     case eTreeOpAddAttributes: {
       // mNode holds the new attributes and mParent is the target
+      nsIDocument* document = mParent->GetCurrentDoc();
+      
       PRUint32 len = mNode->GetAttrCount();
       for (PRUint32 i = 0; i < len; ++i) {
         const nsAttrName* attrName = mNode->GetAttrNameAt(i);
         nsIAtom* localName = attrName->LocalName();
         PRInt32 nsuri = attrName->NamespaceID();
         if (!mParent->HasAttr(nsuri, localName)) {
           nsAutoString value;
           mNode->GetAttr(nsuri, localName, value);
-          mParent->SetAttr(nsuri, localName, attrName->GetPrefix(), value, PR_TRUE);
-          // XXX should not fire mutation event here
+          
+          // the manual notification code is based on nsGenericElement
+          
+          PRUint32 stateMask = PRUint32(mParent->IntrinsicState());
+          nsNodeUtils::AttributeWillChange(mParent, 
+                                           nsuri,
+                                           localName,
+                                           static_cast<PRUint8>(nsIDOMMutationEvent::ADDITION));
+          
+          mParent->SetAttr(nsuri, localName, attrName->GetPrefix(), value, PR_FALSE);
+          
+          if (document || mParent->HasFlag(NODE_FORCE_XBL_BINDINGS)) {
+            nsIDocument* ownerDoc = mParent->GetOwnerDoc();
+            if (ownerDoc) {
+              nsRefPtr<nsXBLBinding> binding =
+                ownerDoc->BindingManager()->GetBinding(mParent);
+              if (binding) {
+                binding->AttributeChanged(localName, nsuri, PR_FALSE, PR_FALSE);
+              }
+            }
+          }
+          
+          stateMask = stateMask ^ PRUint32(mParent->IntrinsicState());
+          if (stateMask && document) {
+            MOZ_AUTO_DOC_UPDATE(document, UPDATE_CONTENT_STATE, PR_TRUE);
+            document->ContentStatesChanged(mParent, nsnull, stateMask);
+          }
+          nsNodeUtils::AttributeChanged(mParent, 
+                                        nsuri, 
+                                        localName, 
+                                        static_cast<PRUint8>(nsIDOMMutationEvent::ADDITION),
+                                        stateMask);
         }
       }
       return rv;
     }
     case eTreeOpDoneAddingChildren: {
       mNode->DoneAddingChildren(PR_FALSE);
       return rv;
     }