diff --git a/mozilla/content/base/public/nsIContent.h b/mozilla/content/base/public/nsIContent.h index 174260fe4c7..6cfec054a94 100644 --- a/mozilla/content/base/public/nsIContent.h +++ b/mozilla/content/base/public/nsIContent.h @@ -61,8 +61,8 @@ class nsIURI; // IID for the nsIContent interface #define NS_ICONTENT_IID \ -{ 0x66b01442, 0x75ed, 0x4605, \ - { 0x87, 0x06, 0x70, 0x22, 0x27, 0x9d, 0x19, 0x0b } } +{ 0x89f20ce8, 0x08cd, 0x4066, \ + { 0x8a, 0xd5, 0x9e, 0x11, 0x1e, 0x43, 0x52, 0x29 } } /** * A node of content in a document's content model. This interface @@ -673,8 +673,12 @@ public: * boolean aFromParser to the NS_NewXXX() constructor for your element and * have the parser pass true. See nsHTMLInputElement.cpp and * nsHTMLContentSink::MakeContentObject(). + * + * @param aHaveNotified Whether there has been a + * ContentInserted/ContentAppended notification for this content node + * yet. */ - virtual void DoneAddingChildren() + virtual void DoneAddingChildren(PRBool aHaveNotified) { } diff --git a/mozilla/content/html/content/src/nsHTMLAppletElement.cpp b/mozilla/content/html/content/src/nsHTMLAppletElement.cpp index 97495c4c1b7..a82df667862 100644 --- a/mozilla/content/html/content/src/nsHTMLAppletElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLAppletElement.cpp @@ -76,7 +76,7 @@ public: // nsIDOMHTMLAppletElement NS_DECL_NSIDOMHTMLAPPLETELEMENT - virtual void DoneAddingChildren(); + virtual void DoneAddingChildren(PRBool aHaveNotified); virtual PRBool IsDoneAddingChildren(); // nsIContent @@ -141,13 +141,13 @@ nsHTMLAppletElement::GetCapabilities() const } void -nsHTMLAppletElement::DoneAddingChildren() +nsHTMLAppletElement::DoneAddingChildren(PRBool aHaveNotified) { mIsDoneAddingChildren = PR_TRUE; // If we're already in the document, start the load, because BindToTree // didn't. if (IsInDoc()) { - StartAppletLoad(MayHaveFrame()); + StartAppletLoad(aHaveNotified); } } diff --git a/mozilla/content/html/content/src/nsHTMLObjectElement.cpp b/mozilla/content/html/content/src/nsHTMLObjectElement.cpp index b82f9123cd3..9d360d2d265 100644 --- a/mozilla/content/html/content/src/nsHTMLObjectElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLObjectElement.cpp @@ -95,7 +95,7 @@ public: NS_IMETHOD SaveState(); virtual PRBool RestoreState(nsPresState* aState); - virtual void DoneAddingChildren(); + virtual void DoneAddingChildren(PRBool aHaveNotified); virtual PRBool IsDoneAddingChildren(); virtual PRBool ParseAttribute(nsIAtom* aAttribute, @@ -139,14 +139,14 @@ nsHTMLObjectElement::IsDoneAddingChildren() } void -nsHTMLObjectElement::DoneAddingChildren() +nsHTMLObjectElement::DoneAddingChildren(PRBool aHaveNotified) { mIsDoneAddingChildren = PR_TRUE; // If we're already in a document, we need to trigger the load // Otherwise, BindToTree takes care of that. if (IsInDoc()) { - StartObjectLoad(MayHaveFrame()); + StartObjectLoad(aHaveNotified); } } diff --git a/mozilla/content/html/content/src/nsHTMLScriptElement.cpp b/mozilla/content/html/content/src/nsHTMLScriptElement.cpp index 7d1dab491fc..e0c9b119876 100644 --- a/mozilla/content/html/content/src/nsHTMLScriptElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLScriptElement.cpp @@ -357,7 +357,7 @@ public: virtual nsresult GetInnerHTML(nsAString& aInnerHTML); virtual nsresult SetInnerHTML(const nsAString& aInnerHTML); - virtual void DoneAddingChildren(); + virtual void DoneAddingChildren(PRBool aHaveNotified); virtual PRBool IsDoneAddingChildren(); protected: @@ -551,7 +551,7 @@ nsHTMLScriptElement::SetInnerHTML(const nsAString& aInnerHTML) } void -nsHTMLScriptElement::DoneAddingChildren() +nsHTMLScriptElement::DoneAddingChildren(PRBool aHaveNotified) { mDoneAddingChildren = PR_TRUE; MaybeProcessScript(); diff --git a/mozilla/content/html/content/src/nsHTMLSelectElement.cpp b/mozilla/content/html/content/src/nsHTMLSelectElement.cpp index 58ec81a4bb1..bc7e2e050aa 100644 --- a/mozilla/content/html/content/src/nsHTMLSelectElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLSelectElement.cpp @@ -243,7 +243,7 @@ public: // nsISelectElement NS_DECL_NSISELECTELEMENT - virtual void DoneAddingChildren(); + virtual void DoneAddingChildren(PRBool aHaveNotified); virtual PRBool IsDoneAddingChildren(); virtual PRBool ParseAttribute(nsIAtom* aAttribute, @@ -1636,7 +1636,7 @@ nsHTMLSelectElement::IsDoneAddingChildren() } void -nsHTMLSelectElement::DoneAddingChildren() +nsHTMLSelectElement::DoneAddingChildren(PRBool aHaveNotified) { mIsDoneAddingChildren = PR_TRUE; diff --git a/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp b/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp index 12f6445db7f..f36e9adea86 100644 --- a/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp @@ -134,7 +134,7 @@ public: nsEventStatus* aEventStatus); virtual void SetFocus(nsPresContext* aPresContext); - virtual void DoneAddingChildren(); + virtual void DoneAddingChildren(PRBool aHaveNotified); virtual PRBool IsDoneAddingChildren(); protected: @@ -612,7 +612,7 @@ nsHTMLTextAreaElement::HandleDOMEvent(nsPresContext* aPresContext, } void -nsHTMLTextAreaElement::DoneAddingChildren() +nsHTMLTextAreaElement::DoneAddingChildren(PRBool aHaveNotified) { if (!mValueChanged) { if (!mDoneAddingChildren) { diff --git a/mozilla/content/html/document/src/nsHTMLContentSink.cpp b/mozilla/content/html/document/src/nsHTMLContentSink.cpp index ce08955d3e5..cc461cfd154 100644 --- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp @@ -410,7 +410,8 @@ protected: // Routines for tags that require special handling when we reach their end // tag. - nsresult ProcessSCRIPTEndTag(nsGenericHTMLElement* content); + nsresult ProcessSCRIPTEndTag(nsGenericHTMLElement* content, + PRBool aHaveNotified); nsresult ProcessSTYLEEndTag(nsGenericHTMLElement* content); nsresult OpenHeadContext(); @@ -728,6 +729,13 @@ public: void DidAddContent(nsIContent* aContent, PRBool aDidNotify = PR_FALSE); void UpdateChildCounts(); +private: + // Function to check whether we've notified for the current content. + // What this actually does is check whether we've notified for all + // of the parent's kids. + PRBool HaveNotifiedForCurrentContent() const; + +public: HTMLContentSink* mSink; PRInt32 mNotifyLevel; nsCOMPtr mLastTextNode; @@ -1282,6 +1290,17 @@ SinkContext::OpenContainer(const nsIParserNode& aNode) return NS_OK; } +PRBool +SinkContext::HaveNotifiedForCurrentContent() const +{ + if (0 < mStackPos) { + nsIContent* parent = mStack[mStackPos - 1].mContent; + return mStack[mStackPos-1].mNumFlushed == parent->GetChildCount(); + } + + return PR_TRUE; +} + nsresult SinkContext::CloseContainer(const nsHTMLTag aTag) { @@ -1376,11 +1395,12 @@ SinkContext::CloseContainer(const nsHTMLTag aTag) case eHTMLTag_textarea: case eHTMLTag_object: case eHTMLTag_applet: - content->DoneAddingChildren(); + content->DoneAddingChildren(HaveNotifiedForCurrentContent()); break; case eHTMLTag_script: - result = mSink->ProcessSCRIPTEndTag(content); + result = mSink->ProcessSCRIPTEndTag(content, + HaveNotifiedForCurrentContent()); break; case eHTMLTag_style: @@ -3994,7 +4014,8 @@ HTMLContentSink::PostEvaluateScript() } nsresult -HTMLContentSink::ProcessSCRIPTEndTag(nsGenericHTMLElement *content) +HTMLContentSink::ProcessSCRIPTEndTag(nsGenericHTMLElement *content, + PRBool aHaveNotified) { nsCOMPtr sele = do_QueryInterface(content); NS_ASSERTION(sele, "Not really closing a script tag?"); @@ -4032,7 +4053,7 @@ HTMLContentSink::ProcessSCRIPTEndTag(nsGenericHTMLElement *content) // Now tell the script that it's ready to go. This will execute the script // and call our ScriptAvailable method. - content->DoneAddingChildren(); + content->DoneAddingChildren(aHaveNotified); // To prevent script evaluation in a frameset document, we suspended // the script loader. Now that the script content has been handled, diff --git a/mozilla/content/xml/document/src/nsXMLContentSink.cpp b/mozilla/content/xml/document/src/nsXMLContentSink.cpp index 48375d10b15..eebd7228abc 100644 --- a/mozilla/content/xml/document/src/nsXMLContentSink.cpp +++ b/mozilla/content/xml/document/src/nsXMLContentSink.cpp @@ -498,7 +498,7 @@ nsXMLContentSink::CloseElement(nsIContent* aContent, nsIContent* aParent, || nodeInfo->NamespaceID() > kNameSpaceID_LastBuiltin #endif ) { - aContent->DoneAddingChildren(); + aContent->DoneAddingChildren(PR_FALSE); } if (!nodeInfo->NamespaceEquals(kNameSpaceID_XHTML) && diff --git a/mozilla/content/xtf/src/nsXTFElementWrapper.cpp b/mozilla/content/xtf/src/nsXTFElementWrapper.cpp index 6964fe029b3..7656bc17980 100644 --- a/mozilla/content/xtf/src/nsXTFElementWrapper.cpp +++ b/mozilla/content/xtf/src/nsXTFElementWrapper.cpp @@ -447,7 +447,7 @@ nsXTFElementWrapper::BeginAddingChildren() } void -nsXTFElementWrapper::DoneAddingChildren() +nsXTFElementWrapper::DoneAddingChildren(PRBool aHaveNotified) { if (mNotificationMask & nsIXTFElement::NOTIFY_DONE_ADDING_CHILDREN) GetXTFElement()->DoneAddingChildren(); diff --git a/mozilla/content/xtf/src/nsXTFElementWrapper.h b/mozilla/content/xtf/src/nsXTFElementWrapper.h index 1633260c5eb..b9ced0d8e0b 100644 --- a/mozilla/content/xtf/src/nsXTFElementWrapper.h +++ b/mozilla/content/xtf/src/nsXTFElementWrapper.h @@ -109,7 +109,7 @@ public: virtual PRInt32 IntrinsicState() const; virtual void BeginAddingChildren(); - virtual void DoneAddingChildren(); + virtual void DoneAddingChildren(PRBool aHaveNotified); // nsIDOMElement specializations: NS_IMETHOD GetAttribute(const nsAString& aName, diff --git a/mozilla/content/xul/document/src/nsXULDocument.cpp b/mozilla/content/xul/document/src/nsXULDocument.cpp index cc18e0ebcb3..7bea0f1c3cf 100644 --- a/mozilla/content/xul/document/src/nsXULDocument.cpp +++ b/mozilla/content/xul/document/src/nsXULDocument.cpp @@ -2787,7 +2787,7 @@ nsXULDocument::ResumeWalk() #ifdef MOZ_XTF if (element->GetNameSpaceID() > kNameSpaceID_LastBuiltin) { - element->DoneAddingChildren(); + element->DoneAddingChildren(PR_FALSE); } #endif }