Bug 342062: Add nsIMutationObserver which has the ability to get notifications for just mutations happening in a subtree under a given node. r/sr=bz
git-svn-id: svn://10.0.0.236/trunk@201460 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -64,6 +64,8 @@
|
||||
#include "prtime.h"
|
||||
#include "prlog.h"
|
||||
#include "nsInt64.h"
|
||||
#include "nsNodeUtils.h"
|
||||
#include "nsIContent.h"
|
||||
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsITextContent.h"
|
||||
@@ -1852,20 +1854,22 @@ HTMLContentSink::~HTMLContentSink()
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
NS_IMPL_ISUPPORTS_INHERITED6(HTMLContentSink,
|
||||
nsContentSink,
|
||||
nsIContentSink,
|
||||
nsIHTMLContentSink,
|
||||
nsITimerCallback,
|
||||
nsIDocumentObserver,
|
||||
nsIMutationObserver,
|
||||
nsIDebugDumpContent)
|
||||
#else
|
||||
NS_IMPL_ISUPPORTS_INHERITED5(HTMLContentSink,
|
||||
nsContentSink,
|
||||
nsIContentSink,
|
||||
nsIHTMLContentSink,
|
||||
nsITimerCallback,
|
||||
nsIDocumentObserver,
|
||||
nsIDebugDumpContent)
|
||||
#else
|
||||
NS_IMPL_ISUPPORTS_INHERITED4(HTMLContentSink,
|
||||
nsContentSink,
|
||||
nsIContentSink,
|
||||
nsIHTMLContentSink,
|
||||
nsITimerCallback,
|
||||
nsIDocumentObserver)
|
||||
nsIMutationObserver)
|
||||
#endif
|
||||
|
||||
static PRBool
|
||||
@@ -3615,7 +3619,7 @@ HTMLContentSink::NotifyAppend(nsIContent* aContainer, PRUint32 aStartIndex)
|
||||
MOZ_TIMER_SAVE(mWatch)
|
||||
MOZ_TIMER_STOP(mWatch);
|
||||
|
||||
mDocument->ContentAppended(aContainer, aStartIndex);
|
||||
nsNodeUtils::ContentAppended(aContainer, aStartIndex);
|
||||
mLastNotificationTime = PR_Now();
|
||||
|
||||
MOZ_TIMER_DEBUGLOG(("Restore: nsHTMLContentSink::NotifyAppend()\n"));
|
||||
@@ -3641,7 +3645,8 @@ HTMLContentSink::NotifyInsert(nsIContent* aContent,
|
||||
MOZ_TIMER_SAVE(mWatch)
|
||||
MOZ_TIMER_STOP(mWatch);
|
||||
|
||||
mDocument->ContentInserted(aContent, aChildContent, aIndexInContainer);
|
||||
nsNodeUtils::ContentInserted(NODE_FROM(aContent, mDocument),
|
||||
aChildContent, aIndexInContainer);
|
||||
mLastNotificationTime = PR_Now();
|
||||
|
||||
MOZ_TIMER_DEBUGLOG(("Restore: nsHTMLContentSink::NotifyInsert()\n"));
|
||||
|
||||
@@ -84,6 +84,7 @@
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsIScrollableView.h"
|
||||
#include "nsAttrName.h"
|
||||
#include "nsNodeUtils.h"
|
||||
|
||||
#include "nsNetCID.h"
|
||||
#include "nsIIOService.h"
|
||||
@@ -1196,42 +1197,40 @@ nsHTMLDocument::SetCompatibilityMode(nsCompatibility aMode)
|
||||
}
|
||||
|
||||
void
|
||||
nsHTMLDocument::ContentAppended(nsIContent* aContainer,
|
||||
nsHTMLDocument::ContentAppended(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
PRInt32 aNewIndexInContainer)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(aContainer, "Null container!");
|
||||
NS_ASSERTION(aDocument == this, "unexpected doc");
|
||||
|
||||
// Register new content. That is the content numbered from
|
||||
// aNewIndexInContainer and upwards.
|
||||
PRUint32 count = aContainer->GetChildCount();
|
||||
|
||||
for (PRUint32 i = aNewIndexInContainer; i < count; ++i) {
|
||||
RegisterNamedItems(aContainer->GetChildAt(i));
|
||||
}
|
||||
|
||||
nsDocument::ContentAppended(aContainer, aNewIndexInContainer);
|
||||
}
|
||||
|
||||
void
|
||||
nsHTMLDocument::ContentInserted(nsIContent* aContainer, nsIContent* aContent,
|
||||
nsHTMLDocument::ContentInserted(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aContent,
|
||||
PRInt32 aIndexInContainer)
|
||||
{
|
||||
NS_ASSERTION(aDocument == this, "unexpected doc");
|
||||
|
||||
NS_ABORT_IF_FALSE(aContent, "Null content!");
|
||||
|
||||
nsresult rv = RegisterNamedItems(aContent);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsDocument::ContentInserted(aContainer, aContent, aIndexInContainer);
|
||||
RegisterNamedItems(aContent);
|
||||
}
|
||||
|
||||
void
|
||||
nsHTMLDocument::ContentRemoved(nsIContent* aContainer, nsIContent* aContent,
|
||||
nsHTMLDocument::ContentRemoved(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(aContent, "Null content!");
|
||||
NS_ASSERTION(aDocument == this, "unexpected doc");
|
||||
|
||||
NS_ABORT_IF_FALSE(aChild, "Null content!");
|
||||
|
||||
if (aContainer == mRootContent) {
|
||||
// Reset mBodyContent in case we got a new body.
|
||||
@@ -1239,13 +1238,7 @@ nsHTMLDocument::ContentRemoved(nsIContent* aContainer, nsIContent* aContent,
|
||||
mBodyContent = nsnull;
|
||||
}
|
||||
|
||||
nsresult rv = UnregisterNamedItems(aContent);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsDocument::ContentRemoved(aContainer, aContent, aIndexInContainer);
|
||||
UnregisterNamedItems(aChild);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1278,9 +1271,12 @@ nsHTMLDocument::AttributeWillChange(nsIContent* aContent, PRInt32 aNameSpaceID,
|
||||
}
|
||||
|
||||
void
|
||||
nsHTMLDocument::AttributeChanged(nsIContent* aContent, PRInt32 aNameSpaceID,
|
||||
nsHTMLDocument::AttributeChanged(nsIDocument* aDocument,
|
||||
nsIContent* aContent, PRInt32 aNameSpaceID,
|
||||
nsIAtom* aAttribute, PRInt32 aModType)
|
||||
{
|
||||
NS_ASSERTION(aDocument == this, "unexpected doc");
|
||||
|
||||
NS_ABORT_IF_FALSE(aContent, "Null content!");
|
||||
NS_PRECONDITION(aAttribute, "Must have an attribute that's changing!");
|
||||
|
||||
@@ -1289,25 +1285,15 @@ nsHTMLDocument::AttributeChanged(nsIContent* aContent, PRInt32 aNameSpaceID,
|
||||
|
||||
nsIAtom* name = IsNamedItem(aContent);
|
||||
if (name) {
|
||||
nsresult rv = UpdateNameTableEntry(name, aContent);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
UpdateNameTableEntry(name, aContent);
|
||||
}
|
||||
} else if (aAttribute == aContent->GetIDAttributeName() &&
|
||||
aNameSpaceID == kNameSpaceID_None) {
|
||||
nsIAtom* id = aContent->GetID();
|
||||
if (id) {
|
||||
nsresult rv = UpdateIdTableEntry(id, aContent);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
UpdateIdTableEntry(id, aContent);
|
||||
}
|
||||
}
|
||||
|
||||
nsDocument::AttributeChanged(aContent, aNameSpaceID, aAttribute, aModType);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2078,7 +2064,7 @@ nsHTMLDocument::OpenCommon(const nsACString& aContentType, PRBool aReplace)
|
||||
|
||||
if (root) {
|
||||
// Tear down the frames for the root element.
|
||||
ContentRemoved(nsnull, root, 0);
|
||||
nsNodeUtils::ContentRemoved(this, root, 0);
|
||||
|
||||
// Put the root element back into the document, we don't notify
|
||||
// the document about this insertion since the sink will do that
|
||||
|
||||
@@ -124,18 +124,6 @@ public:
|
||||
|
||||
virtual NS_HIDDEN_(nsContentList*) GetFormControls();
|
||||
|
||||
virtual void ContentAppended(nsIContent* aContainer,
|
||||
PRInt32 aNewIndexInContainer);
|
||||
virtual void ContentInserted(nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer);
|
||||
virtual void ContentRemoved(nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer);
|
||||
virtual void AttributeChanged(nsIContent* aChild,
|
||||
PRInt32 aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
PRInt32 aModType);
|
||||
virtual void AttributeWillChange(nsIContent* aChild,
|
||||
PRInt32 aNameSpaceID,
|
||||
nsIAtom* aAttribute);
|
||||
@@ -144,6 +132,23 @@ public:
|
||||
|
||||
virtual PRBool IsCaseSensitive();
|
||||
|
||||
// nsIMutationObserver
|
||||
virtual void ContentAppended(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
PRInt32 aNewIndexInContainer);
|
||||
virtual void ContentInserted(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer);
|
||||
virtual void ContentRemoved(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer);
|
||||
virtual void AttributeChanged(nsIDocument* aDocument,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
PRInt32 aModType);
|
||||
// nsIDOMDocument interface
|
||||
NS_DECL_NSIDOMDOCUMENT
|
||||
|
||||
|
||||
Reference in New Issue
Block a user