зеркало из https://github.com/mozilla/gecko-dev.git
Revert changes that cause mail sort to crash.
This commit is contained in:
Родитель
5eeb6cafd2
Коммит
8dd7b2ed23
|
@ -916,12 +916,6 @@ nsXULElement::InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, nsIDOMN
|
|||
rv = InsertChildAt(newcontent, pos, PR_TRUE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to insert aNewChild");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Because InsertChildAt() only does a "shallow"
|
||||
// SetDocument(), we need to ensure that a "deep" one is
|
||||
// done now...
|
||||
rv = newcontent->SetDocument(mDocument, PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
// XXX Hmm. There's a case here that we handle ambiguously, I
|
||||
|
@ -933,12 +927,6 @@ nsXULElement::InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, nsIDOMN
|
|||
rv = AppendChildTo(newcontent, PR_TRUE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to append a aNewChild");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Because AppendChildTo() only does a "shallow"
|
||||
// SetDocument(), we need to ensure that a "deep" one is done
|
||||
// now...
|
||||
rv = newcontent->SetDocument(mDocument, PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
NS_ADDREF(aNewChild);
|
||||
|
@ -975,12 +963,6 @@ nsXULElement::ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, nsIDOMN
|
|||
if (newelement) {
|
||||
rv = ReplaceChildAt(newelement, pos, PR_TRUE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to replace old child");
|
||||
|
||||
// Because ReplaceChildAt() only does a "shallow"
|
||||
// SetDocument(), we need to ensure that a "deep" one
|
||||
// is done now...
|
||||
rv = newelement->SetDocument(mDocument, PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1874,9 +1856,11 @@ nsXULElement::GetDocument(nsIDocument*& aResult) const
|
|||
NS_IMETHODIMP
|
||||
nsXULElement::SetDocument(nsIDocument* aDocument, PRBool aDeep)
|
||||
{
|
||||
if (aDocument == mDocument)
|
||||
return NS_OK;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
if (aDocument != mDocument) {
|
||||
nsCOMPtr<nsIXULDocument> rdfDoc;
|
||||
if (mDocument) {
|
||||
// Release the named reference to the script object so it can
|
||||
|
@ -1910,7 +1894,6 @@ nsXULElement::SetDocument(nsIDocument* aDocument, PRBool aDeep)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (aDeep && mChildren) {
|
||||
PRUint32 cnt;
|
||||
|
@ -1933,7 +1916,6 @@ nsXULElement::SetDocument(nsIDocument* aDocument, PRBool aDeep)
|
|||
child->SetDocument(aDocument, aDeep);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -2028,10 +2010,10 @@ nsXULElement::InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify)
|
|||
aKid->SetParent(NS_STATIC_CAST(nsIStyledContent*, this));
|
||||
//nsRange::OwnerChildInserted(this, aIndex);
|
||||
|
||||
// N.B. that this is "shallow"!
|
||||
aKid->SetDocument(mDocument, PR_FALSE);
|
||||
//XXXwaterson this should be shallow
|
||||
aKid->SetDocument(mDocument, PR_TRUE);
|
||||
|
||||
if (aNotify && mDocument) {
|
||||
if (aNotify && ElementIsInDocument()) {
|
||||
mDocument->ContentInserted(NS_STATIC_CAST(nsIStyledContent*, this), aKid, aIndex);
|
||||
}
|
||||
}
|
||||
|
@ -2070,17 +2052,18 @@ nsXULElement::ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify)
|
|||
aKid->SetParent(NS_STATIC_CAST(nsIStyledContent*, this));
|
||||
//nsRange::OwnerChildReplaced(this, aIndex, oldKid);
|
||||
|
||||
// N.B. that we only do a "shallow" SetDocument()
|
||||
// here. Callers beware!
|
||||
aKid->SetDocument(mDocument, PR_FALSE);
|
||||
//XXXwaterson this should be shallow
|
||||
aKid->SetDocument(mDocument, PR_TRUE);
|
||||
|
||||
if (aNotify && mDocument) {
|
||||
if (aNotify && ElementIsInDocument()) {
|
||||
mDocument->ContentReplaced(NS_STATIC_CAST(nsIStyledContent*, this), oldKid, aKid, aIndex);
|
||||
}
|
||||
|
||||
#if 0 //XXXwaterson put this in eventually.
|
||||
// This will cause the script object to be unrooted for each
|
||||
// element in the subtree.
|
||||
oldKid->SetDocument(nsnull, PR_TRUE);
|
||||
#endif
|
||||
|
||||
// We've got no mo' parent.
|
||||
oldKid->SetParent(nsnull);
|
||||
|
@ -2107,10 +2090,10 @@ nsXULElement::AppendChildTo(nsIContent* aKid, PRBool aNotify)
|
|||
aKid->SetParent(NS_STATIC_CAST(nsIStyledContent*, this));
|
||||
// ranges don't need adjustment since new child is at end of list
|
||||
|
||||
// N.B. that this is only "shallow". Callers beware!
|
||||
aKid->SetDocument(mDocument, PR_FALSE);
|
||||
//XXXwaterson this should be shallow
|
||||
aKid->SetDocument(mDocument, PR_TRUE);
|
||||
|
||||
if (aNotify && mDocument) {
|
||||
if (aNotify && ElementIsInDocument()) {
|
||||
PRUint32 cnt;
|
||||
rv = mChildren->Count(&cnt);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
@ -2211,13 +2194,15 @@ nsXULElement::RemoveChildAt(PRInt32 aIndex, PRBool aNotify)
|
|||
nsIDocument* doc = mDocument;
|
||||
PRBool removeOk = mChildren->RemoveElementAt(aIndex);
|
||||
//nsRange::OwnerChildRemoved(this, aIndex, oldKid);
|
||||
if (aNotify && removeOk && mDocument) {
|
||||
if (aNotify && removeOk && ElementIsInDocument()) {
|
||||
doc->ContentRemoved(NS_STATIC_CAST(nsIStyledContent*, this), oldKid, aIndex);
|
||||
}
|
||||
|
||||
#if 0 //XXXwaterson put this in eventually
|
||||
// This will cause the script object to be unrooted for each
|
||||
// element in the subtree.
|
||||
oldKid->SetDocument(nsnull, PR_TRUE);
|
||||
#endif
|
||||
|
||||
// We've got no mo' parent.
|
||||
oldKid->SetParent(nsnull);
|
||||
|
@ -3263,6 +3248,37 @@ nsXULElement::ExecuteOnBroadcastHandler(nsIDOMElement* anElement, const nsString
|
|||
}
|
||||
|
||||
|
||||
PRBool
|
||||
nsXULElement::ElementIsInDocument()
|
||||
{
|
||||
// Check to see if the element is really _in_ the document; that
|
||||
// is, that it actually is in the tree rooted at the document's
|
||||
// root content.
|
||||
if (! mDocument)
|
||||
return PR_FALSE;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIContent> root = dont_AddRef( mDocument->GetRootContent() );
|
||||
if (! root)
|
||||
return PR_FALSE;
|
||||
|
||||
// Hack to get off scc's evil-use-of-do_QueryInterface() radar.
|
||||
nsIStyledContent* p = NS_STATIC_CAST(nsIStyledContent*, this);
|
||||
nsCOMPtr<nsIContent> node = do_QueryInterface(p);
|
||||
|
||||
while (node) {
|
||||
if (node == root)
|
||||
return PR_TRUE;
|
||||
|
||||
nsCOMPtr<nsIContent> oldNode = node;
|
||||
rv = oldNode->GetParent(*getter_AddRefs(node));
|
||||
if (NS_FAILED(rv)) return PR_FALSE;
|
||||
}
|
||||
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsXULElement::ExecuteJSCode(nsIDOMElement* anElement, nsEvent* aEvent)
|
||||
{
|
||||
|
|
|
@ -508,6 +508,8 @@ protected:
|
|||
|
||||
nsresult ExecuteOnBroadcastHandler(nsIDOMElement* anElement, const nsString& attrName);
|
||||
|
||||
PRBool ElementIsInDocument();
|
||||
|
||||
static nsresult
|
||||
ExecuteJSCode(nsIDOMElement* anElement, nsEvent* aEvent);
|
||||
|
||||
|
|
|
@ -4001,6 +4001,9 @@ nsXULDocument::CreateElement(PRInt32 aNameSpaceID,
|
|||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
#if 1 // XXXwaterson remove this eventually
|
||||
result->SetDocument(this, PR_FALSE);
|
||||
#endif
|
||||
result->SetContentID(mNextContentID++);
|
||||
|
||||
*aResult = result;
|
||||
|
@ -5665,17 +5668,6 @@ nsXULDocument::InsertElement(nsIContent* aParent, nsIContent* aChild)
|
|||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
// Both InsertChildAt() and AppendChildTo() only do a "shallow"
|
||||
// SetDocument(); make sure that we do a "deep" one now...
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
rv = aParent->GetDocument(*getter_AddRefs(doc));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
NS_ASSERTION(doc != nsnull, "merging into null document");
|
||||
|
||||
rv = aChild->SetDocument(doc, PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -4001,6 +4001,9 @@ nsXULDocument::CreateElement(PRInt32 aNameSpaceID,
|
|||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
#if 1 // XXXwaterson remove this eventually
|
||||
result->SetDocument(this, PR_FALSE);
|
||||
#endif
|
||||
result->SetContentID(mNextContentID++);
|
||||
|
||||
*aResult = result;
|
||||
|
@ -5665,17 +5668,6 @@ nsXULDocument::InsertElement(nsIContent* aParent, nsIContent* aChild)
|
|||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
// Both InsertChildAt() and AppendChildTo() only do a "shallow"
|
||||
// SetDocument(); make sure that we do a "deep" one now...
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
rv = aParent->GetDocument(*getter_AddRefs(doc));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
NS_ASSERTION(doc != nsnull, "merging into null document");
|
||||
|
||||
rv = aChild->SetDocument(doc, PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -916,12 +916,6 @@ nsXULElement::InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, nsIDOMN
|
|||
rv = InsertChildAt(newcontent, pos, PR_TRUE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to insert aNewChild");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Because InsertChildAt() only does a "shallow"
|
||||
// SetDocument(), we need to ensure that a "deep" one is
|
||||
// done now...
|
||||
rv = newcontent->SetDocument(mDocument, PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
// XXX Hmm. There's a case here that we handle ambiguously, I
|
||||
|
@ -933,12 +927,6 @@ nsXULElement::InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, nsIDOMN
|
|||
rv = AppendChildTo(newcontent, PR_TRUE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to append a aNewChild");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Because AppendChildTo() only does a "shallow"
|
||||
// SetDocument(), we need to ensure that a "deep" one is done
|
||||
// now...
|
||||
rv = newcontent->SetDocument(mDocument, PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
NS_ADDREF(aNewChild);
|
||||
|
@ -975,12 +963,6 @@ nsXULElement::ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, nsIDOMN
|
|||
if (newelement) {
|
||||
rv = ReplaceChildAt(newelement, pos, PR_TRUE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to replace old child");
|
||||
|
||||
// Because ReplaceChildAt() only does a "shallow"
|
||||
// SetDocument(), we need to ensure that a "deep" one
|
||||
// is done now...
|
||||
rv = newelement->SetDocument(mDocument, PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1874,9 +1856,11 @@ nsXULElement::GetDocument(nsIDocument*& aResult) const
|
|||
NS_IMETHODIMP
|
||||
nsXULElement::SetDocument(nsIDocument* aDocument, PRBool aDeep)
|
||||
{
|
||||
if (aDocument == mDocument)
|
||||
return NS_OK;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
if (aDocument != mDocument) {
|
||||
nsCOMPtr<nsIXULDocument> rdfDoc;
|
||||
if (mDocument) {
|
||||
// Release the named reference to the script object so it can
|
||||
|
@ -1910,7 +1894,6 @@ nsXULElement::SetDocument(nsIDocument* aDocument, PRBool aDeep)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (aDeep && mChildren) {
|
||||
PRUint32 cnt;
|
||||
|
@ -1933,7 +1916,6 @@ nsXULElement::SetDocument(nsIDocument* aDocument, PRBool aDeep)
|
|||
child->SetDocument(aDocument, aDeep);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -2028,10 +2010,10 @@ nsXULElement::InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify)
|
|||
aKid->SetParent(NS_STATIC_CAST(nsIStyledContent*, this));
|
||||
//nsRange::OwnerChildInserted(this, aIndex);
|
||||
|
||||
// N.B. that this is "shallow"!
|
||||
aKid->SetDocument(mDocument, PR_FALSE);
|
||||
//XXXwaterson this should be shallow
|
||||
aKid->SetDocument(mDocument, PR_TRUE);
|
||||
|
||||
if (aNotify && mDocument) {
|
||||
if (aNotify && ElementIsInDocument()) {
|
||||
mDocument->ContentInserted(NS_STATIC_CAST(nsIStyledContent*, this), aKid, aIndex);
|
||||
}
|
||||
}
|
||||
|
@ -2070,17 +2052,18 @@ nsXULElement::ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify)
|
|||
aKid->SetParent(NS_STATIC_CAST(nsIStyledContent*, this));
|
||||
//nsRange::OwnerChildReplaced(this, aIndex, oldKid);
|
||||
|
||||
// N.B. that we only do a "shallow" SetDocument()
|
||||
// here. Callers beware!
|
||||
aKid->SetDocument(mDocument, PR_FALSE);
|
||||
//XXXwaterson this should be shallow
|
||||
aKid->SetDocument(mDocument, PR_TRUE);
|
||||
|
||||
if (aNotify && mDocument) {
|
||||
if (aNotify && ElementIsInDocument()) {
|
||||
mDocument->ContentReplaced(NS_STATIC_CAST(nsIStyledContent*, this), oldKid, aKid, aIndex);
|
||||
}
|
||||
|
||||
#if 0 //XXXwaterson put this in eventually.
|
||||
// This will cause the script object to be unrooted for each
|
||||
// element in the subtree.
|
||||
oldKid->SetDocument(nsnull, PR_TRUE);
|
||||
#endif
|
||||
|
||||
// We've got no mo' parent.
|
||||
oldKid->SetParent(nsnull);
|
||||
|
@ -2107,10 +2090,10 @@ nsXULElement::AppendChildTo(nsIContent* aKid, PRBool aNotify)
|
|||
aKid->SetParent(NS_STATIC_CAST(nsIStyledContent*, this));
|
||||
// ranges don't need adjustment since new child is at end of list
|
||||
|
||||
// N.B. that this is only "shallow". Callers beware!
|
||||
aKid->SetDocument(mDocument, PR_FALSE);
|
||||
//XXXwaterson this should be shallow
|
||||
aKid->SetDocument(mDocument, PR_TRUE);
|
||||
|
||||
if (aNotify && mDocument) {
|
||||
if (aNotify && ElementIsInDocument()) {
|
||||
PRUint32 cnt;
|
||||
rv = mChildren->Count(&cnt);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
@ -2211,13 +2194,15 @@ nsXULElement::RemoveChildAt(PRInt32 aIndex, PRBool aNotify)
|
|||
nsIDocument* doc = mDocument;
|
||||
PRBool removeOk = mChildren->RemoveElementAt(aIndex);
|
||||
//nsRange::OwnerChildRemoved(this, aIndex, oldKid);
|
||||
if (aNotify && removeOk && mDocument) {
|
||||
if (aNotify && removeOk && ElementIsInDocument()) {
|
||||
doc->ContentRemoved(NS_STATIC_CAST(nsIStyledContent*, this), oldKid, aIndex);
|
||||
}
|
||||
|
||||
#if 0 //XXXwaterson put this in eventually
|
||||
// This will cause the script object to be unrooted for each
|
||||
// element in the subtree.
|
||||
oldKid->SetDocument(nsnull, PR_TRUE);
|
||||
#endif
|
||||
|
||||
// We've got no mo' parent.
|
||||
oldKid->SetParent(nsnull);
|
||||
|
@ -3263,6 +3248,37 @@ nsXULElement::ExecuteOnBroadcastHandler(nsIDOMElement* anElement, const nsString
|
|||
}
|
||||
|
||||
|
||||
PRBool
|
||||
nsXULElement::ElementIsInDocument()
|
||||
{
|
||||
// Check to see if the element is really _in_ the document; that
|
||||
// is, that it actually is in the tree rooted at the document's
|
||||
// root content.
|
||||
if (! mDocument)
|
||||
return PR_FALSE;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIContent> root = dont_AddRef( mDocument->GetRootContent() );
|
||||
if (! root)
|
||||
return PR_FALSE;
|
||||
|
||||
// Hack to get off scc's evil-use-of-do_QueryInterface() radar.
|
||||
nsIStyledContent* p = NS_STATIC_CAST(nsIStyledContent*, this);
|
||||
nsCOMPtr<nsIContent> node = do_QueryInterface(p);
|
||||
|
||||
while (node) {
|
||||
if (node == root)
|
||||
return PR_TRUE;
|
||||
|
||||
nsCOMPtr<nsIContent> oldNode = node;
|
||||
rv = oldNode->GetParent(*getter_AddRefs(node));
|
||||
if (NS_FAILED(rv)) return PR_FALSE;
|
||||
}
|
||||
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsXULElement::ExecuteJSCode(nsIDOMElement* anElement, nsEvent* aEvent)
|
||||
{
|
||||
|
|
|
@ -508,6 +508,8 @@ protected:
|
|||
|
||||
nsresult ExecuteOnBroadcastHandler(nsIDOMElement* anElement, const nsString& attrName);
|
||||
|
||||
PRBool ElementIsInDocument();
|
||||
|
||||
static nsresult
|
||||
ExecuteJSCode(nsIDOMElement* anElement, nsEvent* aEvent);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче