Bug 377035 Allow <tree> to be anonymous parent of <treechildren> r=Enn sr=roc

This commit is contained in:
neil@parkwaycc.co.uk 2007-05-09 01:54:24 -07:00
Родитель ea86ae6165
Коммит 8c94f04dc8
2 изменённых файлов: 16 добавлений и 16 удалений

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

@ -556,9 +556,9 @@ nsTreeContentView::SetTree(nsITreeBoxObject* aTree)
nsCOMPtr<nsIDOMElement> bodyElement; nsCOMPtr<nsIDOMElement> bodyElement;
mBoxObject->GetTreeBody(getter_AddRefs(bodyElement)); mBoxObject->GetTreeBody(getter_AddRefs(bodyElement));
if (bodyElement) { if (bodyElement) {
nsCOMPtr<nsIContent> bodyContent = do_QueryInterface(bodyElement); mBody = do_QueryInterface(bodyElement);
PRInt32 index = 0; PRInt32 index = 0;
Serialize(bodyContent, -1, &index, mRows); Serialize(mBody, -1, &index, mRows);
} }
} }
@ -818,18 +818,16 @@ nsTreeContentView::AttributeChanged(nsIDocument *aDocument,
return; return;
} }
// If we have a legal tag, go up to the tree and make sure that it's ours. // If we have a legal tag, go up to the tree/select and make sure
nsCOMPtr<nsIContent> parent = aContent; // that it's ours.
nsINodeInfo *ni = nsnull;
do {
parent = parent->GetParent();
if (parent)
ni = parent->NodeInfo();
} while (parent && !ni->Equals(nsGkAtoms::tree, kNameSpaceID_XUL));
if (parent != mRoot) { for (nsIContent* element = aContent; element != mBody; element = element->GetParent()) {
// This is not for us, we can bail out. if (!element)
return; 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. // 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 // If we have a legal tag, go up to the tree/select and make sure
// that it's ours. // that it's ours.
for (nsIContent* element = aContainer; element != mRoot; element = element->GetParent()) { for (nsIContent* element = aContainer; element != mBody; element = element->GetParent()) {
if (!element) if (!element)
return; // this is not for us return; // this is not for us
nsIAtom *parentTag = element->Tag(); 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 // If we have a legal tag, go up to the tree/select and make sure
// that it's ours. // that it's ours.
for (nsIContent* element = aContainer; element != mRoot; element = element->GetParent()) { for (nsIContent* element = aContainer; element != mBody; element = element->GetParent()) {
if (!element) if (!element)
return; // this is not for us return; // this is not for us
nsIAtom *parentTag = element->Tag(); 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)) (element->IsNodeOfType(nsINode::eHTML) && parentTag == nsGkAtoms::select))
return; // this is not for us return; // this is not for us
} }
@ -1439,6 +1437,7 @@ nsTreeContentView::ClearRows()
Row::Destroy(mAllocator, (Row*)mRows[i]); Row::Destroy(mAllocator, (Row*)mRows[i]);
mRows.Clear(); mRows.Clear();
mRoot = nsnull; mRoot = nsnull;
mBody = nsnull;
// Remove ourselves from mDocument's observers. // Remove ourselves from mDocument's observers.
if (mDocument) { if (mDocument) {
mDocument->RemoveObserver(this); mDocument->RemoveObserver(this);

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

@ -132,6 +132,7 @@ class nsTreeContentView : public nsINativeTreeView,
nsCOMPtr<nsITreeBoxObject> mBoxObject; nsCOMPtr<nsITreeBoxObject> mBoxObject;
nsCOMPtr<nsITreeSelection> mSelection; nsCOMPtr<nsITreeSelection> mSelection;
nsCOMPtr<nsIContent> mRoot; nsCOMPtr<nsIContent> mRoot;
nsCOMPtr<nsIContent> mBody;
nsIDocument* mDocument; // WEAK nsIDocument* mDocument; // WEAK
nsFixedSizeAllocator mAllocator; nsFixedSizeAllocator mAllocator;
nsVoidArray mRows; nsVoidArray mRows;