From 9d24ba6b07cfa05889d3aed71e6d7fecaf601fe9 Mon Sep 17 00:00:00 2001 From: "jonas@sicking.cc" Date: Thu, 24 May 2007 17:28:20 -0700 Subject: [PATCH] Fix yet more regressions from the don't-flag-clone-xul-nodes-indocument landing. b=380872 r/sr=bz --- content/base/src/nsDocument.cpp | 6 ++++-- content/base/src/nsGenericElement.cpp | 7 ++++++- content/base/src/nsNodeUtils.cpp | 6 ++++++ content/xul/content/src/nsXULElement.cpp | 4 +++- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index af15c288266a..1802b89a3de7 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -3651,8 +3651,10 @@ nsDocument::GetBoxObjectFor(nsIDOMElement* aElement, nsIBoxObject** aResult) { nsCOMPtr content(do_QueryInterface(aElement)); NS_ENSURE_TRUE(content, NS_ERROR_UNEXPECTED); - NS_ENSURE_TRUE(content->GetCurrentDoc() == this, - NS_ERROR_DOM_WRONG_DOCUMENT_ERR); + + nsIDocument* doc = content->HasFlag(NODE_FORCE_XBL_BINDINGS) ? + content->GetOwnerDoc() : content->GetCurrentDoc(); + NS_ENSURE_TRUE(doc == this, NS_ERROR_DOM_WRONG_DOCUMENT_ERR); *aResult = nsnull; diff --git a/content/base/src/nsGenericElement.cpp b/content/base/src/nsGenericElement.cpp index 15dfd6369dc2..d630de801575 100644 --- a/content/base/src/nsGenericElement.cpp +++ b/content/base/src/nsGenericElement.cpp @@ -115,7 +115,7 @@ #include "nsIFocusController.h" #include "nsIControllers.h" #include "nsXBLInsertionPoint.h" - +#include "nsIXULDocument.h" #include "nsCycleCollectionParticipant.h" #include "nsCCUncollectableMarker.h" @@ -1719,6 +1719,7 @@ BindNodesInInsertPoints(nsXBLBinding* aBinding, nsIContent* aInsertParent, aBinding->GetExistingInsertionPointsFor(aInsertParent); if (inserts) { PRBool allowScripts = aBinding->AllowScripts(); + nsCOMPtr xulDoc = do_QueryInterface(aDocument); PRUint32 i; for (i = 0; i < inserts->Length(); ++i) { nsCOMPtr insertRoot = @@ -1730,6 +1731,10 @@ BindNodesInInsertPoints(nsXBLBinding* aBinding, nsIContent* aInsertParent, rv = child->BindToTree(aDocument, aInsertParent, aBinding->GetBoundElement(), allowScripts); NS_ENSURE_SUCCESS(rv, rv); + + if (xulDoc) { + xulDoc->AddSubtreeToDocument(child); + } } } } diff --git a/content/base/src/nsNodeUtils.cpp b/content/base/src/nsNodeUtils.cpp index a47d8e893471..7d0a9cfe73f0 100755 --- a/content/base/src/nsNodeUtils.cpp +++ b/content/base/src/nsNodeUtils.cpp @@ -69,6 +69,12 @@ } \ prev = node; \ node = node->GetNodeParent(); \ + \ + if (!node && prev->HasFlag(NODE_FORCE_XBL_BINDINGS)) { \ + /* For elements that have the NODE_FORCE_XBL_BINDINGS flag \ + set we need to notify the document */ \ + node = prev->GetOwnerDoc(); \ + } \ } while (node); \ PR_END_MACRO diff --git a/content/xul/content/src/nsXULElement.cpp b/content/xul/content/src/nsXULElement.cpp index 87edae549499..be735fd71732 100644 --- a/content/xul/content/src/nsXULElement.cpp +++ b/content/xul/content/src/nsXULElement.cpp @@ -1755,7 +1755,9 @@ nsXULElement::GetBoxObject(nsIBoxObject** aResult) *aResult = nsnull; // XXX sXBL/XBL2 issue! Owner or current document? - nsCOMPtr nsDoc(do_QueryInterface(GetCurrentDoc())); + nsIDocument* doc = HasFlag(NODE_FORCE_XBL_BINDINGS) ? + GetOwnerDoc() : GetCurrentDoc(); + nsCOMPtr nsDoc(do_QueryInterface(doc)); return nsDoc ? nsDoc->GetBoxObjectFor(this, aResult) : NS_ERROR_FAILURE; }