From 8c94f04dc80052096a4ca74894098da79bf97767 Mon Sep 17 00:00:00 2001 From: "neil@parkwaycc.co.uk" Date: Wed, 9 May 2007 01:54:24 -0700 Subject: [PATCH] Bug 377035 Allow to be anonymous parent of r=Enn sr=roc --- .../base/src/tree/src/nsTreeContentView.cpp | 31 +++++++++---------- .../xul/base/src/tree/src/nsTreeContentView.h | 1 + 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/layout/xul/base/src/tree/src/nsTreeContentView.cpp b/layout/xul/base/src/tree/src/nsTreeContentView.cpp index bdea758e684..cdbf0d22f20 100644 --- a/layout/xul/base/src/tree/src/nsTreeContentView.cpp +++ b/layout/xul/base/src/tree/src/nsTreeContentView.cpp @@ -556,9 +556,9 @@ nsTreeContentView::SetTree(nsITreeBoxObject* aTree) nsCOMPtr bodyElement; mBoxObject->GetTreeBody(getter_AddRefs(bodyElement)); if (bodyElement) { - nsCOMPtr bodyContent = do_QueryInterface(bodyElement); + mBody = do_QueryInterface(bodyElement); PRInt32 index = 0; - Serialize(bodyContent, -1, &index, mRows); + Serialize(mBody, -1, &index, mRows); } } @@ -818,18 +818,16 @@ nsTreeContentView::AttributeChanged(nsIDocument *aDocument, return; } - // If we have a legal tag, go up to the tree and make sure that it's ours. - nsCOMPtr parent = aContent; - nsINodeInfo *ni = nsnull; - do { - parent = parent->GetParent(); - if (parent) - ni = parent->NodeInfo(); - } while (parent && !ni->Equals(nsGkAtoms::tree, kNameSpaceID_XUL)); + // If we have a legal tag, go up to the tree/select and make sure + // that it's ours. - if (parent != mRoot) { - // This is not for us, we can bail out. - return; + for (nsIContent* element = aContent; element != mBody; element = element->GetParent()) { + if (!element) + return; // this is not for us + nsIAtom *parentTag = element->Tag(); + if ((element->IsNodeOfType(nsINode::eXUL) && parentTag == nsGkAtoms::tree) || + (element->IsNodeOfType(nsINode::eHTML) && parentTag == nsGkAtoms::select)) + return; // this is not for us } // Handle changes of the hidden attribute. @@ -989,7 +987,7 @@ nsTreeContentView::ContentInserted(nsIDocument *aDocument, // If we have a legal tag, go up to the tree/select and make sure // that it's ours. - for (nsIContent* element = aContainer; element != mRoot; element = element->GetParent()) { + for (nsIContent* element = aContainer; element != mBody; element = element->GetParent()) { if (!element) return; // this is not for us nsIAtom *parentTag = element->Tag(); @@ -1072,11 +1070,11 @@ nsTreeContentView::ContentRemoved(nsIDocument *aDocument, // If we have a legal tag, go up to the tree/select and make sure // that it's ours. - for (nsIContent* element = aContainer; element != mRoot; element = element->GetParent()) { + for (nsIContent* element = aContainer; element != mBody; element = element->GetParent()) { if (!element) return; // this is not for us nsIAtom *parentTag = element->Tag(); - if ((element->IsNodeOfType(nsINode::eXUL) && parentTag == nsGkAtoms::tree) || + if ((element->IsNodeOfType(nsINode::eXUL) && parentTag == nsGkAtoms::tree) || (element->IsNodeOfType(nsINode::eHTML) && parentTag == nsGkAtoms::select)) return; // this is not for us } @@ -1439,6 +1437,7 @@ nsTreeContentView::ClearRows() Row::Destroy(mAllocator, (Row*)mRows[i]); mRows.Clear(); mRoot = nsnull; + mBody = nsnull; // Remove ourselves from mDocument's observers. if (mDocument) { mDocument->RemoveObserver(this); diff --git a/layout/xul/base/src/tree/src/nsTreeContentView.h b/layout/xul/base/src/tree/src/nsTreeContentView.h index 90411a85c2d..708d79baa2a 100644 --- a/layout/xul/base/src/tree/src/nsTreeContentView.h +++ b/layout/xul/base/src/tree/src/nsTreeContentView.h @@ -132,6 +132,7 @@ class nsTreeContentView : public nsINativeTreeView, nsCOMPtr mBoxObject; nsCOMPtr mSelection; nsCOMPtr mRoot; + nsCOMPtr mBody; nsIDocument* mDocument; // WEAK nsFixedSizeAllocator mAllocator; nsVoidArray mRows;