From 95a6b3471797217a58a46292b702aeceba269bcd Mon Sep 17 00:00:00 2001 From: "hyatt%netscape.com" Date: Wed, 19 May 1999 08:26:21 +0000 Subject: [PATCH] Fix for bug 5911. --- .../templates/src/nsXULTemplateBuilder.cpp | 31 +++++++++++++------ rdf/content/src/nsRDFGenericBuilder.cpp | 31 +++++++++++++------ rdf/content/src/nsRDFMenuBuilder.cpp | 4 +-- rdf/content/src/nsXULTemplateBuilder.cpp | 31 +++++++++++++------ 4 files changed, 65 insertions(+), 32 deletions(-) diff --git a/content/xul/templates/src/nsXULTemplateBuilder.cpp b/content/xul/templates/src/nsXULTemplateBuilder.cpp index 9205d87a045d..386c8fe46ffb 100644 --- a/content/xul/templates/src/nsXULTemplateBuilder.cpp +++ b/content/xul/templates/src/nsXULTemplateBuilder.cpp @@ -1997,19 +1997,30 @@ RDFGenericBuilderImpl::IsElementInWidget(nsIContent* aElement) { // Make sure that we're actually creating content for the tree // content model that we've been assigned to deal with. - nsCOMPtr rootElement; - if (NS_FAILED(FindWidgetRootElement(aElement, getter_AddRefs(rootElement)))) - return PR_FALSE; - nsCOMPtr rootTag; - nsCOMPtr elementTag; - mRoot->GetTag(*getter_AddRefs(rootTag)); - rootElement->GetTag(*getter_AddRefs(elementTag)); + // Walk up the parent chain from us to the root and + // see what we find. + if (aElement == mRoot) + return PR_TRUE; - if (rootTag.get() != elementTag.get()) - return PR_FALSE; + // walk up the tree until you find rootAtom + nsCOMPtr element(do_QueryInterface(aElement)); + nsCOMPtr parent; + element->GetParent(*getter_AddRefs(parent)); + element = parent; + + while (element) { + + if (element.get() == mRoot) + return PR_TRUE; - return PR_TRUE; + // up to the parent... + nsCOMPtr parent; + element->GetParent(*getter_AddRefs(parent)); + element = parent; + } + + return PR_FALSE; } nsresult diff --git a/rdf/content/src/nsRDFGenericBuilder.cpp b/rdf/content/src/nsRDFGenericBuilder.cpp index 9205d87a045d..386c8fe46ffb 100644 --- a/rdf/content/src/nsRDFGenericBuilder.cpp +++ b/rdf/content/src/nsRDFGenericBuilder.cpp @@ -1997,19 +1997,30 @@ RDFGenericBuilderImpl::IsElementInWidget(nsIContent* aElement) { // Make sure that we're actually creating content for the tree // content model that we've been assigned to deal with. - nsCOMPtr rootElement; - if (NS_FAILED(FindWidgetRootElement(aElement, getter_AddRefs(rootElement)))) - return PR_FALSE; - nsCOMPtr rootTag; - nsCOMPtr elementTag; - mRoot->GetTag(*getter_AddRefs(rootTag)); - rootElement->GetTag(*getter_AddRefs(elementTag)); + // Walk up the parent chain from us to the root and + // see what we find. + if (aElement == mRoot) + return PR_TRUE; - if (rootTag.get() != elementTag.get()) - return PR_FALSE; + // walk up the tree until you find rootAtom + nsCOMPtr element(do_QueryInterface(aElement)); + nsCOMPtr parent; + element->GetParent(*getter_AddRefs(parent)); + element = parent; + + while (element) { + + if (element.get() == mRoot) + return PR_TRUE; - return PR_TRUE; + // up to the parent... + nsCOMPtr parent; + element->GetParent(*getter_AddRefs(parent)); + element = parent; + } + + return PR_FALSE; } nsresult diff --git a/rdf/content/src/nsRDFMenuBuilder.cpp b/rdf/content/src/nsRDFMenuBuilder.cpp index 4926e7c07df8..ad1a43388a09 100644 --- a/rdf/content/src/nsRDFMenuBuilder.cpp +++ b/rdf/content/src/nsRDFMenuBuilder.cpp @@ -118,8 +118,8 @@ public: nsresult GetInsertionRootAtom(nsIAtom** aResult) { - NS_ADDREF(kMenuBarAtom); - *aResult = kMenuBarAtom; + NS_ADDREF(kMenuAtom); + *aResult = kMenuAtom; return NS_OK; } diff --git a/rdf/content/src/nsXULTemplateBuilder.cpp b/rdf/content/src/nsXULTemplateBuilder.cpp index 9205d87a045d..386c8fe46ffb 100644 --- a/rdf/content/src/nsXULTemplateBuilder.cpp +++ b/rdf/content/src/nsXULTemplateBuilder.cpp @@ -1997,19 +1997,30 @@ RDFGenericBuilderImpl::IsElementInWidget(nsIContent* aElement) { // Make sure that we're actually creating content for the tree // content model that we've been assigned to deal with. - nsCOMPtr rootElement; - if (NS_FAILED(FindWidgetRootElement(aElement, getter_AddRefs(rootElement)))) - return PR_FALSE; - nsCOMPtr rootTag; - nsCOMPtr elementTag; - mRoot->GetTag(*getter_AddRefs(rootTag)); - rootElement->GetTag(*getter_AddRefs(elementTag)); + // Walk up the parent chain from us to the root and + // see what we find. + if (aElement == mRoot) + return PR_TRUE; - if (rootTag.get() != elementTag.get()) - return PR_FALSE; + // walk up the tree until you find rootAtom + nsCOMPtr element(do_QueryInterface(aElement)); + nsCOMPtr parent; + element->GetParent(*getter_AddRefs(parent)); + element = parent; + + while (element) { + + if (element.get() == mRoot) + return PR_TRUE; - return PR_TRUE; + // up to the parent... + nsCOMPtr parent; + element->GetParent(*getter_AddRefs(parent)); + element = parent; + } + + return PR_FALSE; } nsresult