Backout part of the fix for bug 27382 to try to undo Tp regression.

This commit is contained in:
peterv%propagandism.org 2004-08-10 16:16:58 +00:00
Родитель 412251e336
Коммит e53a844bed
23 изменённых файлов: 76 добавлений и 336 удалений

Просмотреть файл

@ -122,7 +122,7 @@ public:
* Get the parent content for this content. * Get the parent content for this content.
* @return the parent, or null if no parent * @return the parent, or null if no parent
*/ */
virtual nsIContent* GetParent() const nsIContent* GetParent() const
{ {
return NS_REINTERPRET_CAST(nsIContent *, mParentPtrBits & ~kParentBitMask); return NS_REINTERPRET_CAST(nsIContent *, mParentPtrBits & ~kParentBitMask);
} }

Просмотреть файл

@ -626,27 +626,6 @@ public:
*/ */
virtual PRInt32 GetDefaultNamespaceID() const = 0; virtual PRInt32 GetDefaultNamespaceID() const = 0;
/**
* Returns false if aContent is an orphan (an orphan is a node that is not a
* descendant of this document but whose ownerDocument pointer points to this
* document).
*/
virtual PRBool IsOrphan(nsIContent* aContent) = 0;
/**
* Add aContent as an orphan of this document (an orphan is a node that is
* not a descendant of this document but whose ownerDocument pointer points
* to this document).
*/
virtual PRBool AddOrphan(nsIContent* aContent) = 0;
/**
* Remove aContent as an orphan of this document (an orphan is a node that is
* not a descendant of this document but whose ownerDocument pointer points
* to this document).
*/
virtual void RemoveOrphan(nsIContent* aContent) = 0;
protected: protected:
nsString mDocumentTitle; nsString mDocumentTitle;
nsCOMPtr<nsIURI> mDocumentURI; nsCOMPtr<nsIURI> mDocumentURI;

Просмотреть файл

@ -72,9 +72,7 @@ nsAttrAndChildArray::~nsAttrAndChildArray()
return; return;
} }
NS_ASSERTION(!mImpl->mMappedAttrs && Clear();
mImpl->mAttrAndChildCount == 0,
"Call nsAttrAndChildArray::Clear() before destruction.");
PR_Free(mImpl); PR_Free(mImpl);
} }

Просмотреть файл

@ -108,12 +108,13 @@ public:
void WalkMappedAttributeStyleRules(nsRuleWalker* aRuleWalker); void WalkMappedAttributeStyleRules(nsRuleWalker* aRuleWalker);
void Compact(); void Compact();
void Clear();
private: private:
nsAttrAndChildArray(const nsAttrAndChildArray& aOther); // Not to be implemented nsAttrAndChildArray(const nsAttrAndChildArray& aOther); // Not to be implemented
nsAttrAndChildArray& operator=(const nsAttrAndChildArray& aOther); // Not to be implemented nsAttrAndChildArray& operator=(const nsAttrAndChildArray& aOther); // Not to be implemented
void Clear();
PRUint32 NonMappedAttrCount() const; PRUint32 NonMappedAttrCount() const;
PRUint32 MappedAttrCount() const; PRUint32 MappedAttrCount() const;

Просмотреть файл

@ -82,13 +82,9 @@ NS_NewCommentNode(nsIContent** aInstancePtrResult, nsIDocument *aOwnerDocument)
{ {
*aInstancePtrResult = nsnull; *aInstancePtrResult = nsnull;
nsCOMPtr<nsIContent> instance = new nsCommentNode(aOwnerDocument); nsCOMPtr<nsIContent> instance = new nsCommentNode(nsnull);
NS_ENSURE_TRUE(instance, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(instance, NS_ERROR_OUT_OF_MEMORY);
if (aOwnerDocument && !aOwnerDocument->AddOrphan(instance)) {
return NS_ERROR_OUT_OF_MEMORY;
}
instance.swap(*aInstancePtrResult); instance.swap(*aInstancePtrResult);
return NS_OK; return NS_OK;
@ -162,7 +158,7 @@ nsCommentNode::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
already_AddRefed<nsITextContent> already_AddRefed<nsITextContent>
nsCommentNode::CloneContent(PRBool aCloneText, nsIDocument *aOwnerDocument) nsCommentNode::CloneContent(PRBool aCloneText, nsIDocument *aOwnerDocument)
{ {
nsCommentNode* it = new nsCommentNode(aOwnerDocument); nsCommentNode* it = new nsCommentNode(nsnull);
if (!it) if (!it)
return nsnull; return nsnull;
@ -172,10 +168,6 @@ nsCommentNode::CloneContent(PRBool aCloneText, nsIDocument *aOwnerDocument)
NS_ADDREF(it); NS_ADDREF(it);
if (aOwnerDocument && !aOwnerDocument->AddOrphan(it)) {
NS_RELEASE(it);
}
return it; return it;
} }

Просмотреть файл

@ -499,14 +499,6 @@ NS_IMPL_ADDREF_USING_AGGREGATOR(nsXPathDocumentTearoff, mDocument)
NS_IMPL_RELEASE_USING_AGGREGATOR(nsXPathDocumentTearoff, mDocument) NS_IMPL_RELEASE_USING_AGGREGATOR(nsXPathDocumentTearoff, mDocument)
class OrphansEntry : public PLDHashEntryHdr
{
public:
nsIContent *mKey; // must be first, to look like PLDHashEntryStub
};
PLDHashTable nsDocument::sOrphans;
// ================================================================== // ==================================================================
// = // =
// ================================================================== // ==================================================================
@ -562,8 +554,6 @@ nsDocument::~nsDocument()
mSubDocuments = nsnull; mSubDocuments = nsnull;
} }
RemoveOrphans();
if (mRootContent) { if (mRootContent) {
if (mRootContent->GetDocument()) { if (mRootContent->GetDocument()) {
// The root content still has a pointer back to the document, // The root content still has a pointer back to the document,
@ -683,15 +673,6 @@ NS_INTERFACE_MAP_END
NS_IMPL_ADDREF(nsDocument) NS_IMPL_ADDREF(nsDocument)
NS_IMPL_RELEASE(nsDocument) NS_IMPL_RELEASE(nsDocument)
// static
void
nsDocument::Shutdown()
{
if (sOrphans.entrySize) {
PL_DHashTableFinish(&sOrphans);
}
}
nsresult nsresult
nsDocument::Init() nsDocument::Init()
{ {
@ -767,8 +748,6 @@ nsDocument::ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup)
mSubDocuments = nsnull; mSubDocuments = nsnull;
} }
RemoveOrphans();
mRootContent = nsnull; mRootContent = nsnull;
PRInt32 count, i; PRInt32 count, i;
count = mChildren.Count(); count = mChildren.Count();
@ -1808,8 +1787,6 @@ nsDocument::SetScriptGlobalObject(nsIScriptGlobalObject *aScriptGlobalObject)
mIsGoingAway = PR_TRUE; mIsGoingAway = PR_TRUE;
RemoveOrphans();
for (indx = 0; indx < count; ++indx) { for (indx = 0; indx < count; ++indx) {
mChildren[indx]->SetDocument(nsnull, PR_TRUE, PR_TRUE); mChildren[indx]->SetDocument(nsnull, PR_TRUE, PR_TRUE);
} }
@ -4461,93 +4438,3 @@ nsDocument::CreateElement(nsINodeInfo *aNodeInfo, PRInt32 aElementType,
return NS_OK; return NS_OK;
} }
PRBool
nsDocument::IsOrphan(nsIContent* aContent)
{
if (mOrphanCache == aContent) {
return PR_TRUE;
}
if (!sOrphans.ops) {
return PR_FALSE;
}
PLDHashEntryHdr *entry = PL_DHashTableOperate(&sOrphans, aContent,
PL_DHASH_LOOKUP);
return PL_DHASH_ENTRY_IS_BUSY(entry);
}
PRBool
nsDocument::AddOrphan(nsIContent* aContent)
{
if (mIsGoingAway || mInDestructor) {
return PR_FALSE;
}
if (mOrphanCache) {
if (!sOrphans.ops &&
!PL_DHashTableInit(&sOrphans, PL_DHashGetStubOps(), nsnull,
sizeof(OrphansEntry), 5)) {
return PR_FALSE;
}
PLDHashEntryHdr *entry = PL_DHashTableOperate(&sOrphans, mOrphanCache,
PL_DHASH_ADD);
if (!entry) {
return PR_FALSE;
}
NS_REINTERPRET_CAST(OrphansEntry*, entry)->mKey = mOrphanCache;
}
mOrphanCache = aContent;
return PR_TRUE;
}
void
nsDocument::RemoveOrphan(nsIContent* aContent)
{
if (mOrphanCache == aContent) {
mOrphanCache = nsnull;
}
else if (sOrphans.ops) {
PL_DHashTableOperate(&sOrphans, aContent, PL_DHASH_REMOVE);
}
}
PR_STATIC_CALLBACK(PLDHashOperator)
RemoveOrphanFromDocument(PLDHashTable *aTable, PLDHashEntryHdr *aHeader,
PRUint32 aNumber, void *aArg)
{
nsIContent *content = NS_REINTERPRET_CAST(OrphansEntry*,
aHeader)->mKey;
nsIDocument *document = content->GetOwnerDoc();
if (document == NS_STATIC_CAST(nsIDocument*, aArg)) {
content->SetDocument(nsnull, PR_TRUE, PR_TRUE);
return PL_DHASH_REMOVE;
}
// XXX Not an orphan anymore if the document pointer has already been
// cleared. This shouldn't happen, but until we clean up
// SetDocument and SetParent it will.
return document ? PL_DHASH_NEXT : PL_DHASH_REMOVE;
}
void
nsDocument::RemoveOrphans()
{
if (mOrphanCache) {
mOrphanCache->SetDocument(nsnull, PR_TRUE, PR_TRUE);
mOrphanCache = nsnull;
}
if (sOrphans.ops) {
PL_DHashTableEnumerate(&sOrphans, RemoveOrphanFromDocument,
NS_STATIC_CAST(nsIDocument*, this));
}
}

Просмотреть файл

@ -502,8 +502,6 @@ public:
// virtual nsIPrincipal* GetPrincipal(); // virtual nsIPrincipal* GetPrincipal();
// Already declared in nsIDocument // Already declared in nsIDocument
static void Shutdown();
virtual nsresult Init(); virtual nsresult Init();
virtual nsresult AddXMLEventsContent(nsIContent * aXMLEventsElement); virtual nsresult AddXMLEventsContent(nsIContent * aXMLEventsElement);
@ -513,10 +511,6 @@ public:
PRBool aDocumentDefaultType, PRBool aDocumentDefaultType,
nsIContent **aResult); nsIContent **aResult);
PRBool IsOrphan(nsIContent* aContent);
PRBool AddOrphan(nsIContent* aContent);
void RemoveOrphan(nsIContent* aContent);
protected: protected:
void RetrieveRelevantHeaders(nsIChannel *aChannel); void RetrieveRelevantHeaders(nsIChannel *aChannel);
@ -606,11 +600,6 @@ private:
nsDocument& operator=(const nsDocument& aOther); nsDocument& operator=(const nsDocument& aOther);
nsXPathDocumentTearoff* mXPathDocument; nsXPathDocumentTearoff* mXPathDocument;
void RemoveOrphans();
nsIContent *mOrphanCache;
static PLDHashTable sOrphans;
}; };

Просмотреть файл

@ -58,8 +58,8 @@
#include "prprf.h" #include "prprf.h"
nsGenericDOMDataNode::nsGenericDOMDataNode(nsIDocument *aDocument) nsGenericDOMDataNode::nsGenericDOMDataNode(nsIDocument *aDocument)
: mDocument(aDocument)
{ {
mParentPtrBits = NS_REINTERPRET_CAST(PtrBits, aDocument);
} }
nsGenericDOMDataNode::~nsGenericDOMDataNode() nsGenericDOMDataNode::~nsGenericDOMDataNode()
@ -73,13 +73,6 @@ nsGenericDOMDataNode::~nsGenericDOMDataNode()
PL_DHashTableOperate(&nsGenericElement::sRangeListsHash, PL_DHashTableOperate(&nsGenericElement::sRangeListsHash,
this, PL_DHASH_REMOVE); this, PL_DHASH_REMOVE);
} }
if (ParentIsDocument()) {
nsIDocument *document = ParentPtrBitsAsDocument();
if (document) {
document->RemoveOrphan(this);
}
}
} }
@ -121,11 +114,11 @@ nsGenericDOMDataNode::GetParentNode(nsIDOMNode** aParentNode)
if (parent) { if (parent) {
rv = CallQueryInterface(parent, aParentNode); rv = CallQueryInterface(parent, aParentNode);
} }
else if (mDocument) {
rv = CallQueryInterface(mDocument, aParentNode);
}
else { else {
nsIDocument *doc = ParentPtrBitsAsDocument(); *aParentNode = nsnull;
if (doc && !doc->IsOrphan(this)) {
rv = CallQueryInterface(doc, aParentNode);
}
} }
NS_ASSERTION(NS_SUCCEEDED(rv), "Must be a DOM Node"); NS_ASSERTION(NS_SUCCEEDED(rv), "Must be a DOM Node");
@ -146,13 +139,10 @@ nsGenericDOMDataNode::GetPreviousSibling(nsIDOMNode** aPrevSibling)
sibling = parent->GetChildAt(pos - 1); sibling = parent->GetChildAt(pos - 1);
} }
} }
else { else if (mDocument) {
nsIDocument *doc = ParentPtrBitsAsDocument(); PRInt32 pos = mDocument->IndexOf(this);
if (doc) { if (pos > 0) {
PRInt32 pos = doc->IndexOf(this); sibling = mDocument->GetChildAt(pos - 1);
if (pos > 0) {
sibling = doc->GetChildAt(pos - 1);
}
} }
} }
@ -179,13 +169,10 @@ nsGenericDOMDataNode::GetNextSibling(nsIDOMNode** aNextSibling)
sibling = parent->GetChildAt(pos + 1); sibling = parent->GetChildAt(pos + 1);
} }
} }
else { else if (mDocument) {
nsIDocument *doc = ParentPtrBitsAsDocument(); PRInt32 pos = mDocument->IndexOf(this);
if (doc) { if (pos > 0) {
PRInt32 pos = doc->IndexOf(this); sibling = mDocument->GetChildAt(pos + 1);
if (pos > 0) {
sibling = doc->GetChildAt(pos + 1);
}
} }
} }
@ -598,67 +585,17 @@ nsGenericDOMDataNode::ToCString(nsAString& aBuf, PRInt32 aOffset,
nsIDocument* nsIDocument*
nsGenericDOMDataNode::GetDocument() const nsGenericDOMDataNode::GetDocument() const
{ {
nsIContent *parent = GetParent(); return GetCurrentDoc();
if (parent) {
return parent->GetDocument();
}
nsIDocument *document = ParentPtrBitsAsDocument();
if (document &&
document->IsOrphan(NS_CONST_CAST(nsGenericDOMDataNode*, this))) {
return nsnull;
}
return document;
} }
void void
nsGenericDOMDataNode::SetDocument(nsIDocument* aDocument, PRBool aDeep, nsGenericDOMDataNode::SetDocument(nsIDocument* aDocument, PRBool aDeep,
PRBool aCompileEventHandlers) PRBool aCompileEventHandlers)
{ {
if (aDocument) { mDocument = aDocument;
if (ParentIsDocument()) { if (mDocument && mText.IsBidi()) {
nsIDocument *document = ParentPtrBitsAsDocument(); aDocument->SetBidiEnabled(PR_TRUE);
if (document) {
document->RemoveOrphan(this);
}
mParentPtrBits =
NS_REINTERPRET_CAST(PtrBits, aDocument) |
(mParentPtrBits & PARENT_BIT_RANGELISTS_OR_LISTENERMANAGER);
}
if (mText.IsBidi()) {
aDocument->SetBidiEnabled(PR_TRUE);
}
} }
else if (ParentIsDocument()) {
// XXX We should call AddOrphan here, but we first need ClearDocumentPointer
// so that RemoveOrphan/RemoveOrphans don't end up here.
mParentPtrBits &= nsIContent::kParentBitMask;
}
}
nsIDocument*
nsGenericDOMDataNode::GetOwnerDoc() const
{
nsIContent *parent = GetParent();
return parent ? parent->GetOwnerDoc() : ParentPtrBitsAsDocument();
}
PRBool
nsGenericDOMDataNode::IsInDoc() const
{
nsIContent *parent = GetParent();
if (parent) {
return parent->IsInDoc();
}
nsIDocument *document = ParentPtrBitsAsDocument();
return document && !document->IsOrphan(NS_CONST_CAST(nsGenericDOMDataNode*,
this));
} }
void void
@ -666,28 +603,9 @@ nsGenericDOMDataNode::SetParent(nsIContent* aParent)
{ {
PtrBits new_bits = NS_REINTERPRET_CAST(PtrBits, aParent); PtrBits new_bits = NS_REINTERPRET_CAST(PtrBits, aParent);
if (aParent) { new_bits |= mParentPtrBits & nsIContent::kParentBitMask;
if (ParentIsDocument()) {
nsIDocument *document = ParentPtrBitsAsDocument();
if (document) {
document->RemoveOrphan(this);
}
}
new_bits |= PARENT_BIT_BITPTR_IS_CONTENT; mParentPtrBits = new_bits;
}
else {
nsIContent *parent = GetParent();
if (parent) {
nsIDocument *document = parent->GetOwnerDoc();
if (document && document->AddOrphan(this)) {
new_bits = NS_REINTERPRET_CAST(PtrBits, document);
}
}
}
mParentPtrBits = new_bits |
(mParentPtrBits & PARENT_BIT_RANGELISTS_OR_LISTENERMANAGER);
} }
PRBool PRBool
@ -1041,9 +959,8 @@ nsGenericDOMDataNode::GetBaseURI() const
} }
nsIURI *uri; nsIURI *uri;
nsIDocument *document = ParentPtrBitsAsDocument(); if (mDocument) {
if (document) { NS_IF_ADDREF(uri = mDocument->GetBaseURI());
NS_IF_ADDREF(uri = document->GetBaseURI());
} }
else { else {
uri = nsnull; uri = nsnull;

Просмотреть файл

@ -56,7 +56,6 @@ class nsINodeInfo;
class nsURI; class nsURI;
#define PARENT_BIT_RANGELISTS_OR_LISTENERMANAGER ((PtrBits)0x1 << 0) #define PARENT_BIT_RANGELISTS_OR_LISTENERMANAGER ((PtrBits)0x1 << 0)
#define PARENT_BIT_BITPTR_IS_CONTENT ((PtrBits)0x1 << 1)
class nsGenericDOMDataNode : public nsITextContent class nsGenericDOMDataNode : public nsITextContent
{ {
@ -169,12 +168,27 @@ public:
nsIDocument* GetDocument() const; nsIDocument* GetDocument() const;
virtual void SetDocument(nsIDocument* aDocument, PRBool aDeep, virtual void SetDocument(nsIDocument* aDocument, PRBool aDeep,
PRBool aCompileEventHandlers); PRBool aCompileEventHandlers);
PRBool IsInDoc() const; PRBool IsInDoc() const
nsIDocument *GetOwnerDoc() const;
nsIContent *GetParent() const
{ {
return ParentIsContent() ? ParentPtrBitsAsContent() : nsnull; return !!mDocument;
} }
nsIDocument *GetCurrentDoc() const
{
return mDocument;
}
nsIDocument *GetOwnerDoc() const
{
if (mDocument) {
return mDocument;
}
nsIContent *parent = GetParent();
return parent ? parent->GetOwnerDoc() : nsnull;
}
virtual void SetParent(nsIContent* aParent); virtual void SetParent(nsIContent* aParent);
virtual PRBool IsNativeAnonymous() const; virtual PRBool IsNativeAnonymous() const;
virtual void SetNativeAnonymous(PRBool aAnonymous); virtual void SetNativeAnonymous(PRBool aAnonymous);
@ -291,24 +305,7 @@ private:
nsGenericElement::sEventListenerManagersHash.ops); nsGenericElement::sEventListenerManagersHash.ops);
} }
PRBool ParentIsDocument() const nsIDocument *mDocument;
{
return !(mParentPtrBits & PARENT_BIT_BITPTR_IS_CONTENT);
}
nsIDocument *ParentPtrBitsAsDocument() const
{
return NS_REINTERPRET_CAST(nsIDocument *,
mParentPtrBits & ~kParentBitMask);
}
PRBool ParentIsContent() const
{
return mParentPtrBits & PARENT_BIT_BITPTR_IS_CONTENT;
}
nsIContent *ParentPtrBitsAsContent() const
{
return NS_REINTERPRET_CAST(nsIContent *,
mParentPtrBits & ~kParentBitMask);
}
}; };
//---------------------------------------------------------------------- //----------------------------------------------------------------------

Просмотреть файл

@ -858,8 +858,6 @@ nsGenericElement::~nsGenericElement()
delete slots; delete slots;
} }
mAttrsAndChildren.Clear();
// No calling GetFlags() beyond this point... // No calling GetFlags() beyond this point...
} }

Просмотреть файл

@ -362,7 +362,7 @@ public:
} }
nsIDocument *GetOwnerDoc() const nsIDocument *GetOwnerDoc() const
{ {
return mNodeInfo->GetDocument(); return nsContentUtils::GetDocument(mNodeInfo);
} }
virtual void SetParent(nsIContent* aParent); virtual void SetParent(nsIContent* aParent);
virtual PRBool IsNativeAnonymous() const; virtual PRBool IsNativeAnonymous() const;

Просмотреть файл

@ -136,13 +136,9 @@ NS_NewTextNode(nsITextContent** aInstancePtrResult,
{ {
*aInstancePtrResult = nsnull; *aInstancePtrResult = nsnull;
nsCOMPtr<nsITextContent> instance = new nsTextNode(aOwnerDocument); nsCOMPtr<nsITextContent> instance = new nsTextNode(nsnull);
NS_ENSURE_TRUE(instance, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(instance, NS_ERROR_OUT_OF_MEMORY);
if (aOwnerDocument && !aOwnerDocument->AddOrphan(instance)) {
return NS_ERROR_OUT_OF_MEMORY;
}
instance.swap(*aInstancePtrResult); instance.swap(*aInstancePtrResult);
return NS_OK; return NS_OK;
@ -214,7 +210,7 @@ nsTextNode::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
already_AddRefed<nsITextContent> already_AddRefed<nsITextContent>
nsTextNode::CloneContent(PRBool aCloneText, nsIDocument *aOwnerDocument) nsTextNode::CloneContent(PRBool aCloneText, nsIDocument *aOwnerDocument)
{ {
nsTextNode* it = new nsTextNode(aOwnerDocument); nsTextNode* it = new nsTextNode(nsnull);
if (!it) if (!it)
return nsnull; return nsnull;
@ -224,10 +220,6 @@ nsTextNode::CloneContent(PRBool aCloneText, nsIDocument *aOwnerDocument)
NS_ADDREF(it); NS_ADDREF(it);
if (aOwnerDocument && !aOwnerDocument->AddOrphan(it)) {
NS_RELEASE(it);
}
return it; return it;
} }

Просмотреть файл

@ -1594,6 +1594,8 @@ SinkContext::AddComment(const nsIParserNode& aNode)
domComment->AppendData(aNode.GetText()); domComment->AppendData(aNode.GetText());
comment->SetDocument(mSink->mDocument, PR_FALSE, PR_TRUE);
NS_ASSERTION(mStackPos > 0, "stack out of bounds"); NS_ASSERTION(mStackPos > 0, "stack out of bounds");
if (mStackPos <= 0) { if (mStackPos <= 0) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -1860,6 +1862,9 @@ SinkContext::FlushText(PRBool* aDidFlush, PRBool aReleaseLast)
mLastTextNode = textContent; mLastTextNode = textContent;
// Set the content's document
mLastTextNode->SetDocument(mSink->mDocument, PR_FALSE, PR_TRUE);
// Set the text in the text node // Set the text in the text node
mLastTextNode->SetText(mText, mTextLength, PR_FALSE); mLastTextNode->SetText(mText, mTextLength, PR_FALSE);
@ -3169,6 +3174,7 @@ HTMLContentSink::SetDocumentTitle(const nsAString& aTitle)
text->SetText(mTitle, PR_TRUE); text->SetText(mTitle, PR_TRUE);
it->AppendChildTo(text, PR_FALSE, PR_FALSE); it->AppendChildTo(text, PR_FALSE, PR_FALSE);
text->SetDocument(mDocument, PR_FALSE, PR_TRUE);
mHead->AppendChildTo(it, PR_FALSE, PR_FALSE); mHead->AppendChildTo(it, PR_FALSE, PR_FALSE);
@ -4219,6 +4225,7 @@ HTMLContentSink::ProcessSCRIPTTag(const nsIParserNode& aNode)
text->SetText(script, PR_TRUE); text->SetText(script, PR_TRUE);
element->AppendChildTo(text, PR_FALSE, PR_FALSE); element->AppendChildTo(text, PR_FALSE, PR_FALSE);
text->SetDocument(mDocument, PR_FALSE, PR_TRUE);
} }
nsCOMPtr<nsIScriptLoader> loader; nsCOMPtr<nsIScriptLoader> loader;

Просмотреть файл

@ -75,7 +75,6 @@ nsSVGElement::~nsSVGElement()
for (i = 0; i < count; ++i) { for (i = 0; i < count; ++i) {
mMappedAttributes.AttrAt(i)->GetSVGValue()->RemoveObserver(this); mMappedAttributes.AttrAt(i)->GetSVGValue()->RemoveObserver(this);
} }
mMappedAttributes.Clear();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

Просмотреть файл

@ -84,13 +84,9 @@ NS_NewXMLCDATASection(nsIContent** aInstancePtrResult,
{ {
*aInstancePtrResult = nsnull; *aInstancePtrResult = nsnull;
nsCOMPtr<nsIContent> instance = new nsXMLCDATASection(aOwnerDocument); nsCOMPtr<nsIContent> instance = new nsXMLCDATASection(nsnull);
NS_ENSURE_TRUE(instance, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(instance, NS_ERROR_OUT_OF_MEMORY);
if (aOwnerDocument && !aOwnerDocument->AddOrphan(instance)) {
return NS_ERROR_OUT_OF_MEMORY;
}
instance.swap(*aInstancePtrResult); instance.swap(*aInstancePtrResult);
return NS_OK; return NS_OK;
@ -170,7 +166,7 @@ nsXMLCDATASection::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
already_AddRefed<nsITextContent> already_AddRefed<nsITextContent>
nsXMLCDATASection::CloneContent(PRBool aCloneText, nsIDocument *aOwnerDocument) nsXMLCDATASection::CloneContent(PRBool aCloneText, nsIDocument *aOwnerDocument)
{ {
nsXMLCDATASection* it = new nsXMLCDATASection(aOwnerDocument); nsXMLCDATASection* it = new nsXMLCDATASection(nsnull);
if (!it) if (!it)
return nsnull; return nsnull;
@ -180,10 +176,6 @@ nsXMLCDATASection::CloneContent(PRBool aCloneText, nsIDocument *aOwnerDocument)
NS_ADDREF(it); NS_ADDREF(it);
if (aOwnerDocument && !aOwnerDocument->AddOrphan(it)) {
NS_RELEASE(it);
}
return it; return it;
} }

Просмотреть файл

@ -57,13 +57,9 @@ NS_NewXMLProcessingInstruction(nsIContent** aInstancePtrResult,
nsCOMPtr<nsIContent> instance; nsCOMPtr<nsIContent> instance;
instance = new nsXMLProcessingInstruction(aTarget, aData, instance = new nsXMLProcessingInstruction(aTarget, aData,
aOwnerDocument); nsnull);
NS_ENSURE_TRUE(instance, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(instance, NS_ERROR_OUT_OF_MEMORY);
if (aOwnerDocument && !aOwnerDocument->AddOrphan(instance)) {
return NS_ERROR_OUT_OF_MEMORY;
}
instance.swap(*aInstancePtrResult); instance.swap(*aInstancePtrResult);
return NS_OK; return NS_OK;
@ -171,15 +167,11 @@ nsXMLProcessingInstruction::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
nsIDocument *document = GetOwnerDoc(); nsIDocument *document = GetOwnerDoc();
nsXMLProcessingInstruction *pi = nsXMLProcessingInstruction *pi =
new nsXMLProcessingInstruction(mTarget, data, document); new nsXMLProcessingInstruction(mTarget, data, nsnull);
if (!pi) { if (!pi) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
if (document) {
document->AddOrphan(pi);
}
NS_ADDREF(*aReturn = pi); NS_ADDREF(*aReturn = pi);
return NS_OK; return NS_OK;

Просмотреть файл

@ -132,16 +132,11 @@ nsXMLStylesheetPI::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
nsAutoString data; nsAutoString data;
GetData(data); GetData(data);
nsIDocument *document = GetOwnerDoc(); nsXMLStylesheetPI *pi = new nsXMLStylesheetPI(data, nsnull);
nsXMLStylesheetPI *pi = new nsXMLStylesheetPI(data, document);
if (!pi) { if (!pi) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
if (document) {
document->AddOrphan(pi);
}
NS_ADDREF(*aReturn = pi); NS_ADDREF(*aReturn = pi);
return NS_OK; return NS_OK;
@ -246,15 +241,11 @@ NS_NewXMLStylesheetProcessingInstruction(nsIContent** aInstancePtrResult,
{ {
*aInstancePtrResult = nsnull; *aInstancePtrResult = nsnull;
nsCOMPtr<nsIContent> instance = new nsXMLStylesheetPI(aData, aOwnerDocument); nsCOMPtr<nsIContent> instance = new nsXMLStylesheetPI(aData, nsnull);
if (!instance) { if (!instance) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
if (aOwnerDocument && !aOwnerDocument->AddOrphan(instance)) {
return NS_ERROR_OUT_OF_MEMORY;
}
instance.swap(*aInstancePtrResult); instance.swap(*aInstancePtrResult);
return NS_OK; return NS_OK;

Просмотреть файл

@ -738,6 +738,9 @@ nsXMLContentSink::FlushText(PRBool aCreateTextNode, PRBool* aDidFlush)
rv = NS_NewTextNode(getter_AddRefs(textContent)); rv = NS_NewTextNode(getter_AddRefs(textContent));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
// Set the content's document
textContent->SetDocument(mDocument, PR_FALSE, PR_TRUE);
// Set the text in the text node // Set the text in the text node
textContent->SetText(mText, mTextLength, PR_FALSE); textContent->SetText(mText, mTextLength, PR_FALSE);
@ -1081,6 +1084,7 @@ nsXMLContentSink::HandleComment(const PRUnichar *aName)
nsCOMPtr<nsIDOMComment> domComment = do_QueryInterface(comment, &result); nsCOMPtr<nsIDOMComment> domComment = do_QueryInterface(comment, &result);
if (domComment) { if (domComment) {
domComment->AppendData(nsDependentString(aName)); domComment->AppendData(nsDependentString(aName));
comment->SetDocument(mDocument, PR_FALSE, PR_TRUE);
result = AddContentAsLeaf(comment); result = AddContentAsLeaf(comment);
} }
} }
@ -1104,6 +1108,7 @@ nsXMLContentSink::HandleCDataSection(const PRUnichar *aData,
nsCOMPtr<nsIDOMCDATASection> domCDATA = do_QueryInterface(cdata); nsCOMPtr<nsIDOMCDATASection> domCDATA = do_QueryInterface(cdata);
if (domCDATA) { if (domCDATA) {
domCDATA->SetData(nsDependentString(aData, aLength)); domCDATA->SetData(nsDependentString(aData, aLength));
cdata->SetDocument(mDocument, PR_FALSE, PR_TRUE);
result = AddContentAsLeaf(cdata); result = AddContentAsLeaf(cdata);
} }
} }

Просмотреть файл

@ -464,8 +464,6 @@ nsXULElement::Init()
nsXULElement::~nsXULElement() nsXULElement::~nsXULElement()
{ {
mAttrsAndChildren.Clear();
if (mPrototype) if (mPrototype)
mPrototype->Release(); mPrototype->Release();

Просмотреть файл

@ -1489,6 +1489,7 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsPresContext* aPresContext
// Set aContent as the parent content so that event handling works. // Set aContent as the parent content so that event handling works.
content->SetParent(aContent); content->SetParent(aContent);
content->SetDocument(aDocument, PR_TRUE, PR_TRUE);
content->SetNativeAnonymous(PR_TRUE); content->SetNativeAnonymous(PR_TRUE);
content->SetBindingParent(content); content->SetBindingParent(content);
@ -1552,6 +1553,7 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsPresContext* aPresContext
// Set aContent as the parent content so that event handling works. // Set aContent as the parent content so that event handling works.
textContent->SetParent(aContent); textContent->SetParent(aContent);
textContent->SetDocument(aDocument, PR_TRUE, PR_TRUE);
textContent->SetNativeAnonymous(PR_TRUE); textContent->SetNativeAnonymous(PR_TRUE);
textContent->SetBindingParent(textContent); textContent->SetBindingParent(textContent);
@ -10172,6 +10174,7 @@ nsCSSFrameConstructor::ConstructAlternateFrame(nsIPresShell* aPresShell,
// Set aContent as the parent content. // Set aContent as the parent content.
altTextContent->SetParent(aContent); altTextContent->SetParent(aContent);
altTextContent->SetDocument(mDocument, PR_TRUE, PR_TRUE);
// Create either an inline frame, block frame, or area frame // Create either an inline frame, block frame, or area frame
nsIFrame* containerFrame; nsIFrame* containerFrame;

Просмотреть файл

@ -147,7 +147,6 @@
#include "nsScriptNameSpaceManager.h" #include "nsScriptNameSpaceManager.h"
#include "nsIControllerContext.h" #include "nsIControllerContext.h"
#include "nsDOMScriptObjectFactory.h" #include "nsDOMScriptObjectFactory.h"
#include "nsDocument.h"
class nsIDocumentLoaderFactory; class nsIDocumentLoaderFactory;
@ -356,7 +355,6 @@ Shutdown()
gInitialized = PR_FALSE; gInitialized = PR_FALSE;
nsDocument::Shutdown();
nsRange::Shutdown(); nsRange::Shutdown();
nsGenericElement::Shutdown(); nsGenericElement::Shutdown();
nsEventListenerManager::Shutdown(); nsEventListenerManager::Shutdown();

Просмотреть файл

@ -1489,6 +1489,7 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsPresContext* aPresContext
// Set aContent as the parent content so that event handling works. // Set aContent as the parent content so that event handling works.
content->SetParent(aContent); content->SetParent(aContent);
content->SetDocument(aDocument, PR_TRUE, PR_TRUE);
content->SetNativeAnonymous(PR_TRUE); content->SetNativeAnonymous(PR_TRUE);
content->SetBindingParent(content); content->SetBindingParent(content);
@ -1552,6 +1553,7 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsPresContext* aPresContext
// Set aContent as the parent content so that event handling works. // Set aContent as the parent content so that event handling works.
textContent->SetParent(aContent); textContent->SetParent(aContent);
textContent->SetDocument(aDocument, PR_TRUE, PR_TRUE);
textContent->SetNativeAnonymous(PR_TRUE); textContent->SetNativeAnonymous(PR_TRUE);
textContent->SetBindingParent(textContent); textContent->SetBindingParent(textContent);
@ -10172,6 +10174,7 @@ nsCSSFrameConstructor::ConstructAlternateFrame(nsIPresShell* aPresShell,
// Set aContent as the parent content. // Set aContent as the parent content.
altTextContent->SetParent(aContent); altTextContent->SetParent(aContent);
altTextContent->SetDocument(mDocument, PR_TRUE, PR_TRUE);
// Create either an inline frame, block frame, or area frame // Create either an inline frame, block frame, or area frame
nsIFrame* containerFrame; nsIFrame* containerFrame;

Просмотреть файл

@ -264,6 +264,8 @@ int main(int argc, char** argv)
txt->AppendData(tmp); txt->AppendData(tmp);
NS_RELEASE(txt); NS_RELEASE(txt);
text->SetDocument(myDoc, PR_FALSE, PR_TRUE);
#if 0 #if 0
// Query ITextContent interface // Query ITextContent interface
nsITextContent* textContent; nsITextContent* textContent;