Fix yet more regressions from the don't-flag-clone-xul-nodes-indocument landing. b=380872 r/sr=bz

This commit is contained in:
jonas@sicking.cc 2007-05-24 17:28:20 -07:00
Родитель 3c0d4771eb
Коммит 9d24ba6b07
4 изменённых файлов: 19 добавлений и 4 удалений

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

@ -3651,8 +3651,10 @@ nsDocument::GetBoxObjectFor(nsIDOMElement* aElement, nsIBoxObject** aResult)
{
nsCOMPtr<nsIContent> 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;

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

@ -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<nsIXULDocument> xulDoc = do_QueryInterface(aDocument);
PRUint32 i;
for (i = 0; i < inserts->Length(); ++i) {
nsCOMPtr<nsIContent> 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);
}
}
}
}

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

@ -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

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

@ -1755,7 +1755,9 @@ nsXULElement::GetBoxObject(nsIBoxObject** aResult)
*aResult = nsnull;
// XXX sXBL/XBL2 issue! Owner or current document?
nsCOMPtr<nsIDOMNSDocument> nsDoc(do_QueryInterface(GetCurrentDoc()));
nsIDocument* doc = HasFlag(NODE_FORCE_XBL_BINDINGS) ?
GetOwnerDoc() : GetCurrentDoc();
nsCOMPtr<nsIDOMNSDocument> nsDoc(do_QueryInterface(doc));
return nsDoc ? nsDoc->GetBoxObjectFor(this, aResult) : NS_ERROR_FAILURE;
}