Bug 371083: Second installment in our exiting series 'deCOMtaminate the XBL code'. r/sr=jst

This commit is contained in:
jonas@sicking.cc
2007-02-27 00:14:01 +00:00
parent 5ad38eaf58
commit 746d844ba1
15 changed files with 164 additions and 248 deletions

View File

@@ -844,7 +844,7 @@ public:
/** /**
* See FlushSkinBindings on nsBindingManager * See FlushSkinBindings on nsBindingManager
*/ */
virtual nsresult FlushSkinBindings() = 0; virtual void FlushSkinBindings() = 0;
protected: protected:
~nsIDocument() ~nsIDocument()

View File

@@ -1346,35 +1346,29 @@ nsContentUtils::FindFirstChildWithResolvedTag(nsIContent* aParent,
PRInt32 aNamespace, PRInt32 aNamespace,
nsIAtom* aTag) nsIAtom* aTag)
{ {
if (!aParent) { nsIDocument* doc;
if (!aParent || !(doc = aParent->GetOwnerDoc())) {
return nsnull; return nsnull;
} }
nsresult rv; nsBindingManager* bindingManager = doc->BindingManager();
nsCOMPtr<nsIXBLService> xblService =
do_GetService("@mozilla.org/xbl;1", &rv);
PRInt32 namespaceID; PRInt32 namespaceID;
PRUint32 count = aParent->GetChildCount(); PRUint32 count = aParent->GetChildCount();
PRUint32 i; PRUint32 i;
nsCOMPtr<nsIAtom> tag;
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
nsIContent *child = aParent->GetChildAt(i); nsIContent *child = aParent->GetChildAt(i);
xblService->ResolveTag(child, &namespaceID, getter_AddRefs(tag)); nsIAtom* tag = bindingManager->ResolveTag(child, &namespaceID);
if (tag == aTag && namespaceID == aNamespace) { if (tag == aTag && namespaceID == aNamespace) {
return child; return child;
} }
} }
// now look for children in XBL // now look for children in XBL
nsIDocument* doc = aParent->GetDocument();
if (!doc) {
return nsnull;
}
nsCOMPtr<nsIDOMNodeList> children; nsCOMPtr<nsIDOMNodeList> children;
doc->BindingManager()->GetXBLChildNodesFor(aParent, getter_AddRefs(children)); bindingManager->GetXBLChildNodesFor(aParent, getter_AddRefs(children));
if (!children) { if (!children) {
return nsnull; return nsnull;
} }
@@ -1385,7 +1379,7 @@ nsContentUtils::FindFirstChildWithResolvedTag(nsIContent* aParent,
nsCOMPtr<nsIDOMNode> childNode; nsCOMPtr<nsIDOMNode> childNode;
children->Item(i, getter_AddRefs(childNode)); children->Item(i, getter_AddRefs(childNode));
nsCOMPtr<nsIContent> childContent = do_QueryInterface(childNode); nsCOMPtr<nsIContent> childContent = do_QueryInterface(childNode);
xblService->ResolveTag(childContent, &namespaceID, getter_AddRefs(tag)); nsIAtom* tag = bindingManager->ResolveTag(childContent, &namespaceID);
if (tag == aTag && namespaceID == aNamespace) { if (tag == aTag && namespaceID == aNamespace) {
return childContent; return childContent;
} }

View File

@@ -3593,10 +3593,7 @@ nsDocument::GetBoxObjectFor(nsIDOMElement* aElement, nsIBoxObject** aResult)
} }
PRInt32 namespaceID; PRInt32 namespaceID;
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag = mBindingManager->ResolveTag(content, &namespaceID);
nsCOMPtr<nsIXBLService> xblService = do_GetService("@mozilla.org/xbl;1");
NS_ENSURE_TRUE(xblService, NS_ERROR_FAILURE);
xblService->ResolveTag(content, &namespaceID, getter_AddRefs(tag));
nsCAutoString contractID("@mozilla.org/layout/xul-boxobject"); nsCAutoString contractID("@mozilla.org/layout/xul-boxobject");
if (namespaceID == kNameSpaceID_XUL) { if (namespaceID == kNameSpaceID_XUL) {
@@ -3659,10 +3656,10 @@ nsDocument::GetContentListFor(nsIContent* aContent, nsIDOMNodeList** aResult)
return mBindingManager->GetContentListFor(aContent, aResult); return mBindingManager->GetContentListFor(aContent, aResult);
} }
nsresult void
nsDocument::FlushSkinBindings() nsDocument::FlushSkinBindings()
{ {
return mBindingManager->FlushSkinBindings(); mBindingManager->FlushSkinBindings();
} }
struct DirTable { struct DirTable {

View File

@@ -648,7 +648,7 @@ public:
nsIDOMNodeList** aResult); nsIDOMNodeList** aResult);
virtual NS_HIDDEN_(nsresult) GetContentListFor(nsIContent* aContent, virtual NS_HIDDEN_(nsresult) GetContentListFor(nsIContent* aContent,
nsIDOMNodeList** aResult); nsIDOMNodeList** aResult);
virtual NS_HIDDEN_(nsresult) FlushSkinBindings(); virtual NS_HIDDEN_(void) FlushSkinBindings();
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsDocument, nsIDocument) NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsDocument, nsIDocument)

View File

@@ -1899,14 +1899,13 @@ nsGenericElement::doPreHandleEvent(nsIContent* aContent,
// XXX XBL2/sXBL issue // XXX XBL2/sXBL issue
nsIDocument* ownerDoc = aContent->GetOwnerDoc(); nsIDocument* ownerDoc = aContent->GetOwnerDoc();
if (ownerDoc) { if (ownerDoc) {
nsCOMPtr<nsIContent> insertionParent; nsIContent* insertionParent = ownerDoc->BindingManager()->
ownerDoc->BindingManager()-> GetInsertionParent(aContent);
GetInsertionParent(aContent, getter_AddRefs(insertionParent));
NS_ASSERTION(!(aVisitor.mEventTargetAtParent && insertionParent && NS_ASSERTION(!(aVisitor.mEventTargetAtParent && insertionParent &&
aVisitor.mEventTargetAtParent != insertionParent), aVisitor.mEventTargetAtParent != insertionParent),
"Retargeting and having insertion parent!"); "Retargeting and having insertion parent!");
if (insertionParent) { if (insertionParent) {
parent.swap(insertionParent); parent = insertionParent;
} }
} }
@@ -3662,6 +3661,8 @@ nsGenericElement::List(FILE* out, PRInt32 aIndent,
fputs(">\n", out); fputs(">\n", out);
nsGenericElement* nonConstThis = NS_CONST_CAST(nsGenericElement*, this);
// XXX sXBL/XBL2 issue! Owner or current document? // XXX sXBL/XBL2 issue! Owner or current document?
nsIDocument *document = GetOwnerDoc(); nsIDocument *document = GetOwnerDoc();
if (document) { if (document) {
@@ -3669,7 +3670,7 @@ nsGenericElement::List(FILE* out, PRInt32 aIndent,
nsBindingManager* bindingManager = document->BindingManager(); nsBindingManager* bindingManager = document->BindingManager();
nsCOMPtr<nsIDOMNodeList> anonymousChildren; nsCOMPtr<nsIDOMNodeList> anonymousChildren;
bindingManager->GetAnonymousNodesFor(NS_CONST_CAST(nsGenericElement*, this), bindingManager->GetAnonymousNodesFor(nonConstThis,
getter_AddRefs(anonymousChildren)); getter_AddRefs(anonymousChildren));
if (anonymousChildren) { if (anonymousChildren) {
@@ -3690,13 +3691,9 @@ nsGenericElement::List(FILE* out, PRInt32 aIndent,
} }
} }
PRBool hasContentList; if (bindingManager->HasContentListFor(nonConstThis)) {
bindingManager->HasContentListFor(NS_CONST_CAST(nsGenericElement*, this),
&hasContentList);
if (hasContentList) {
nsCOMPtr<nsIDOMNodeList> contentList; nsCOMPtr<nsIDOMNodeList> contentList;
bindingManager->GetContentListFor(NS_CONST_CAST(nsGenericElement*, this), bindingManager->GetContentListFor(nonConstThis,
getter_AddRefs(contentList)); getter_AddRefs(contentList));
NS_ASSERTION(contentList != nsnull, "oops, binding manager lied"); NS_ASSERTION(contentList != nsnull, "oops, binding manager lied");

View File

@@ -558,11 +558,11 @@ nsSVGElement::GetOwnerSVGElement(nsIDOMSVGSVGElement * *aOwnerSVGElement)
bindingManager = ownerDoc->BindingManager(); bindingManager = ownerDoc->BindingManager();
} }
nsCOMPtr<nsIContent> parent; nsIContent* parent = nsnull;
if (bindingManager) { if (bindingManager) {
// we have a binding manager -- do we have an anonymous parent? // we have a binding manager -- do we have an anonymous parent?
bindingManager->GetInsertionParent(this, getter_AddRefs(parent)); parent = bindingManager->GetInsertionParent(this);
} }
if (!parent) { if (!parent) {
@@ -578,12 +578,11 @@ nsSVGElement::GetOwnerSVGElement(nsIDOMSVGSVGElement * *aOwnerSVGElement)
NS_ADDREF(*aOwnerSVGElement); NS_ADDREF(*aOwnerSVGElement);
return NS_OK; return NS_OK;
} }
nsCOMPtr<nsIContent> next; nsIContent* next = nsnull;
if (bindingManager) { if (bindingManager) {
bindingManager->GetInsertionParent(parent, getter_AddRefs(next)); next = bindingManager->GetInsertionParent(parent);
} }
if (!next) { if (!next) {
// no anonymous parent, so use explicit one // no anonymous parent, so use explicit one
next = parent->GetParent(); next = parent->GetParent();

View File

@@ -152,12 +152,12 @@ NS_IMETHODIMP nsSVGGraphicElement::GetCTM(nsIDOMSVGMatrix **_retval)
bindingManager = ownerDoc->BindingManager(); bindingManager = ownerDoc->BindingManager();
} }
nsCOMPtr<nsIContent> parent; nsIContent* parent = nsnull;
nsCOMPtr<nsIDOMSVGMatrix> parentCTM; nsCOMPtr<nsIDOMSVGMatrix> parentCTM;
if (bindingManager) { if (bindingManager) {
// check for an anonymous parent first // check for an anonymous parent first
bindingManager->GetInsertionParent(this, getter_AddRefs(parent)); parent = bindingManager->GetInsertionParent(this);
} }
if (!parent) { if (!parent) {
// if we didn't find an anonymous parent, use the explicit one // if we didn't find an anonymous parent, use the explicit one
@@ -194,12 +194,12 @@ NS_IMETHODIMP nsSVGGraphicElement::GetScreenCTM(nsIDOMSVGMatrix **_retval)
bindingManager = ownerDoc->BindingManager(); bindingManager = ownerDoc->BindingManager();
} }
nsCOMPtr<nsIContent> parent; nsIContent* parent = nsnull;
nsCOMPtr<nsIDOMSVGMatrix> parentScreenCTM; nsCOMPtr<nsIDOMSVGMatrix> parentScreenCTM;
if (bindingManager) { if (bindingManager) {
// check for an anonymous parent first // check for an anonymous parent first
bindingManager->GetInsertionParent(this, getter_AddRefs(parent)); parent = bindingManager->GetInsertionParent(this);
} }
if (!parent) { if (!parent) {
// if we didn't find an anonymous parent, use the explicit one // if we didn't find an anonymous parent, use the explicit one

View File

@@ -731,9 +731,10 @@ nsSVGSVGElement::GetCTM(nsIDOMSVGMatrix **_retval)
nsCOMPtr<nsIDOMSVGMatrix> ancestorCTM; nsCOMPtr<nsIDOMSVGMatrix> ancestorCTM;
while (1) { while (1) {
ancestor = nsnull;
if (bindingManager) { if (bindingManager) {
// check for an anonymous ancestor first // check for an anonymous ancestor first
bindingManager->GetInsertionParent(element, getter_AddRefs(ancestor)); ancestor = bindingManager->GetInsertionParent(element);
} }
if (!ancestor) { if (!ancestor) {
// if we didn't find an anonymous ancestor, use the explicit one // if we didn't find an anonymous ancestor, use the explicit one
@@ -844,9 +845,10 @@ nsSVGSVGElement::GetScreenCTM(nsIDOMSVGMatrix **_retval)
nsCOMPtr<nsIDOMSVGMatrix> ancestorScreenCTM; nsCOMPtr<nsIDOMSVGMatrix> ancestorScreenCTM;
while (1) { while (1) {
ancestor = nsnull;
if (bindingManager) { if (bindingManager) {
// check for an anonymous ancestor first // check for an anonymous ancestor first
bindingManager->GetInsertionParent(element, getter_AddRefs(ancestor)); ancestor = bindingManager->GetInsertionParent(element);
} }
if (!ancestor) { if (!ancestor) {
// if we didn't find an anonymous ancestor, use the explicit one // if we didn't find an anonymous ancestor, use the explicit one

View File

@@ -442,19 +442,15 @@ nsBindingManager::SetBinding(nsIContent* aContent, nsXBLBinding* aBinding)
return result ? NS_OK : NS_ERROR_FAILURE; return result ? NS_OK : NS_ERROR_FAILURE;
} }
nsresult nsIContent*
nsBindingManager::GetInsertionParent(nsIContent* aContent, nsIContent** aResult) nsBindingManager::GetInsertionParent(nsIContent* aContent)
{ {
if (mInsertionParentTable.ops) { if (mInsertionParentTable.ops) {
*aResult = NS_STATIC_CAST(nsIContent*, return NS_STATIC_CAST(nsIContent*,
LookupObject(mInsertionParentTable, aContent)); LookupObject(mInsertionParentTable, aContent));
NS_IF_ADDREF(*aResult);
}
else {
*aResult = nsnull;
} }
return NS_OK; return nsnull;
} }
nsresult nsresult
@@ -463,18 +459,14 @@ nsBindingManager::SetInsertionParent(nsIContent* aContent, nsIContent* aParent)
return SetOrRemoveObject(mInsertionParentTable, aContent, aParent); return SetOrRemoveObject(mInsertionParentTable, aContent, aParent);
} }
nsresult nsIXPConnectWrappedJS*
nsBindingManager::GetWrappedJS(nsIContent* aContent, nsIXPConnectWrappedJS** aResult) nsBindingManager::GetWrappedJS(nsIContent* aContent)
{ {
if (mWrapperTable.ops) { if (mWrapperTable.ops) {
*aResult = NS_STATIC_CAST(nsIXPConnectWrappedJS*, LookupObject(mWrapperTable, aContent)); return NS_STATIC_CAST(nsIXPConnectWrappedJS*, LookupObject(mWrapperTable, aContent));
NS_IF_ADDREF(*aResult);
}
else {
*aResult = nsnull;
} }
return NS_OK; return nsnull;
} }
nsresult nsresult
@@ -497,7 +489,7 @@ nsBindingManager::ChangeDocumentFor(nsIContent* aContent, nsIDocument* aOldDocum
// Hold a ref to the binding so it won't die when we remove it from our // Hold a ref to the binding so it won't die when we remove it from our
// table. // table.
nsRefPtr<nsXBLBinding> binding = nsBindingManager::GetBinding(aContent); nsRefPtr<nsXBLBinding> binding = GetBinding(aContent);
if (binding) { if (binding) {
binding->ChangeDocument(aOldDocument, aNewDocument); binding->ChangeDocument(aOldDocument, aNewDocument);
SetBinding(aContent, nsnull); SetBinding(aContent, nsnull);
@@ -513,25 +505,21 @@ nsBindingManager::ChangeDocumentFor(nsIContent* aContent, nsIDocument* aOldDocum
return NS_OK; return NS_OK;
} }
nsresult nsIAtom*
nsBindingManager::ResolveTag(nsIContent* aContent, PRInt32* aNameSpaceID, nsBindingManager::ResolveTag(nsIContent* aContent, PRInt32* aNameSpaceID)
nsIAtom** aResult)
{ {
nsXBLBinding *binding = nsBindingManager::GetBinding(aContent); nsXBLBinding *binding = GetBinding(aContent);
if (binding) { if (binding) {
*aResult = binding->GetBaseTag(aNameSpaceID); nsIAtom* base = binding->GetBaseTag(aNameSpaceID);
if (*aResult) { if (base) {
NS_ADDREF(*aResult); return base;
return NS_OK;
} }
} }
*aNameSpaceID = aContent->GetNameSpaceID(); *aNameSpaceID = aContent->GetNameSpaceID();
NS_ADDREF(*aResult = aContent->Tag()); return aContent->Tag();
return NS_OK;
} }
nsresult nsresult
@@ -548,7 +536,7 @@ nsBindingManager::GetContentListFor(nsIContent* aContent, nsIDOMNodeList** aResu
if (!*aResult) { if (!*aResult) {
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(aContent)); nsCOMPtr<nsIDOMNode> node(do_QueryInterface(aContent));
return node->GetChildNodes(aResult); node->GetChildNodes(aResult);
} }
return NS_OK; return NS_OK;
@@ -570,16 +558,10 @@ nsBindingManager::SetContentListFor(nsIContent* aContent,
return SetOrRemoveObject(mContentListTable, aContent, contentList); return SetOrRemoveObject(mContentListTable, aContent, contentList);
} }
nsresult PRBool
nsBindingManager::HasContentListFor(nsIContent* aContent, PRBool* aResult) nsBindingManager::HasContentListFor(nsIContent* aContent)
{ {
*aResult = PR_FALSE; return mContentListTable.ops && LookupObject(mContentListTable, aContent);
if (mContentListTable.ops) {
nsISupports* list = LookupObject(mContentListTable, aContent);
*aResult = (list != nsnull);
}
return NS_OK;
} }
nsresult nsresult
@@ -597,7 +579,7 @@ nsBindingManager::GetAnonymousNodesInternal(nsIContent* aContent,
if (!*aResult) { if (!*aResult) {
*aIsAnonymousContentList = PR_FALSE; *aIsAnonymousContentList = PR_FALSE;
nsXBLBinding *binding = nsBindingManager::GetBinding(aContent); nsXBLBinding *binding = GetBinding(aContent);
if (binding) { if (binding) {
*aResult = binding->GetAnonymousNodes().get(); *aResult = binding->GetAnonymousNodes().get();
return NS_OK; return NS_OK;
@@ -700,7 +682,7 @@ nsIContent*
nsBindingManager::GetInsertionPoint(nsIContent* aParent, nsIContent* aChild, nsBindingManager::GetInsertionPoint(nsIContent* aParent, nsIContent* aChild,
PRUint32* aIndex) PRUint32* aIndex)
{ {
nsXBLBinding *binding = nsBindingManager::GetBinding(aParent); nsXBLBinding *binding = GetBinding(aParent);
return binding ? binding->GetInsertionPoint(aChild, aIndex) : nsnull; return binding ? binding->GetInsertionPoint(aChild, aIndex) : nsnull;
} }
@@ -709,7 +691,7 @@ nsBindingManager::GetSingleInsertionPoint(nsIContent* aParent,
PRUint32* aIndex, PRUint32* aIndex,
PRBool* aMultipleInsertionPoints) PRBool* aMultipleInsertionPoints)
{ {
nsXBLBinding *binding = nsBindingManager::GetBinding(aParent); nsXBLBinding *binding = GetBinding(aParent);
if (binding) if (binding)
return binding->GetSingleInsertionPoint(aIndex, aMultipleInsertionPoints); return binding->GetSingleInsertionPoint(aIndex, aMultipleInsertionPoints);
@@ -744,7 +726,7 @@ nsresult
nsBindingManager::RemoveLayeredBinding(nsIContent* aContent, nsIURI* aURL) nsBindingManager::RemoveLayeredBinding(nsIContent* aContent, nsIURI* aURL)
{ {
// Hold a ref to the binding so it won't die when we remove it from our table // Hold a ref to the binding so it won't die when we remove it from our table
nsRefPtr<nsXBLBinding> binding = nsBindingManager::GetBinding(aContent); nsRefPtr<nsXBLBinding> binding = GetBinding(aContent);
if (!binding) { if (!binding) {
return NS_OK; return NS_OK;
@@ -837,18 +819,11 @@ nsBindingManager::AddToAttachedQueue(nsXBLBinding* aBinding)
return NS_OK; return NS_OK;
} }
nsresult void
nsBindingManager::ClearAttachedQueue()
{
mAttachedStack.Clear();
return NS_OK;
}
nsresult
nsBindingManager::ProcessAttachedQueue() nsBindingManager::ProcessAttachedQueue()
{ {
if (mProcessingAttachedStack) if (mProcessingAttachedStack)
return NS_OK; return;
mProcessingAttachedStack = PR_TRUE; mProcessingAttachedStack = PR_TRUE;
@@ -862,8 +837,7 @@ nsBindingManager::ProcessAttachedQueue()
} }
mProcessingAttachedStack = PR_FALSE; mProcessingAttachedStack = PR_FALSE;
ClearAttachedQueue(); mAttachedStack.Clear();
return NS_OK;
} }
PR_STATIC_CALLBACK(PLDHashOperator) PR_STATIC_CALLBACK(PLDHashOperator)
@@ -888,7 +862,7 @@ ExecuteDetachedHandler(void* aBinding, void* aClosure)
return PR_TRUE; return PR_TRUE;
} }
nsresult void
nsBindingManager::ExecuteDetachedHandlers() nsBindingManager::ExecuteDetachedHandlers()
{ {
// Walk our hashtable of bindings. // Walk our hashtable of bindings.
@@ -897,7 +871,6 @@ nsBindingManager::ExecuteDetachedHandlers()
mBindingTable.EnumerateRead(AccumulateBindingsToDetach, &bindingsToDetach); mBindingTable.EnumerateRead(AccumulateBindingsToDetach, &bindingsToDetach);
bindingsToDetach.EnumerateForwards(ExecuteDetachedHandler, nsnull); bindingsToDetach.EnumerateForwards(ExecuteDetachedHandler, nsnull);
} }
return NS_OK;
} }
nsresult nsresult
@@ -915,25 +888,21 @@ nsBindingManager::PutXBLDocumentInfo(nsIXBLDocumentInfo* aDocumentInfo)
return NS_OK; return NS_OK;
} }
nsresult void
nsBindingManager::RemoveXBLDocumentInfo(nsIXBLDocumentInfo* aDocumentInfo) nsBindingManager::RemoveXBLDocumentInfo(nsIXBLDocumentInfo* aDocumentInfo)
{ {
if (!mDocumentTable.IsInitialized()) if (mDocumentTable.IsInitialized()) {
return NS_OK;
mDocumentTable.Remove(aDocumentInfo->DocumentURI()); mDocumentTable.Remove(aDocumentInfo->DocumentURI());
return NS_OK; }
} }
nsresult nsIXBLDocumentInfo*
nsBindingManager::GetXBLDocumentInfo(nsIURI* aURL, nsIXBLDocumentInfo** aResult) nsBindingManager::GetXBLDocumentInfo(nsIURI* aURL)
{ {
*aResult = nsnull;
if (!mDocumentTable.IsInitialized()) if (!mDocumentTable.IsInitialized())
return NS_OK; return nsnull;
mDocumentTable.Get(aURL, aResult); return mDocumentTable.GetWeak(aURL);
return NS_OK;
} }
nsresult nsresult
@@ -950,26 +919,21 @@ nsBindingManager::PutLoadingDocListener(nsIURI* aURL, nsIStreamListener* aListen
return NS_OK; return NS_OK;
} }
nsresult nsIStreamListener*
nsBindingManager::GetLoadingDocListener(nsIURI* aURL, nsIStreamListener** aResult) nsBindingManager::GetLoadingDocListener(nsIURI* aURL)
{ {
*aResult = nsnull;
if (!mLoadingDocTable.IsInitialized()) if (!mLoadingDocTable.IsInitialized())
return NS_OK; return nsnull;
mLoadingDocTable.Get(aURL, aResult); return mLoadingDocTable.GetWeak(aURL);
return NS_OK;
} }
nsresult void
nsBindingManager::RemoveLoadingDocListener(nsIURI* aURL) nsBindingManager::RemoveLoadingDocListener(nsIURI* aURL)
{ {
if (!mLoadingDocTable.IsInitialized()) if (mLoadingDocTable.IsInitialized()) {
return NS_OK;
mLoadingDocTable.Remove(aURL); mLoadingDocTable.Remove(aURL);
}
return NS_OK;
} }
PR_STATIC_CALLBACK(PLDHashOperator) PR_STATIC_CALLBACK(PLDHashOperator)
@@ -987,12 +951,11 @@ MarkForDeath(nsISupports *aKey, nsXBLBinding *aBinding, void* aClosure)
return PL_DHASH_NEXT; return PL_DHASH_NEXT;
} }
nsresult void
nsBindingManager::FlushSkinBindings() nsBindingManager::FlushSkinBindings()
{ {
if (mBindingTable.IsInitialized()) if (mBindingTable.IsInitialized())
mBindingTable.EnumerateRead(MarkForDeath, nsnull); mBindingTable.EnumerateRead(MarkForDeath, nsnull);
return NS_OK;
} }
// Used below to protect from recurring in QI calls through XPConnect. // Used below to protect from recurring in QI calls through XPConnect.
@@ -1012,13 +975,12 @@ nsBindingManager::GetBindingImplementation(nsIContent* aContent, REFNSIID aIID,
void** aResult) void** aResult)
{ {
*aResult = nsnull; *aResult = nsnull;
nsXBLBinding *binding = nsBindingManager::GetBinding(aContent); nsXBLBinding *binding = GetBinding(aContent);
if (binding) { if (binding) {
// The binding should not be asked for nsISupports // The binding should not be asked for nsISupports
NS_ASSERTION(!aIID.Equals(NS_GET_IID(nsISupports)), "Asking a binding for nsISupports"); NS_ASSERTION(!aIID.Equals(NS_GET_IID(nsISupports)), "Asking a binding for nsISupports");
if (binding->ImplementsInterface(aIID)) { if (binding->ImplementsInterface(aIID)) {
nsCOMPtr<nsIXPConnectWrappedJS> wrappedJS; nsCOMPtr<nsIXPConnectWrappedJS> wrappedJS = GetWrappedJS(aContent);
GetWrappedJS(aContent, getter_AddRefs(wrappedJS));
if (wrappedJS) { if (wrappedJS) {
// Protect from recurring in QI calls through XPConnect. // Protect from recurring in QI calls through XPConnect.
@@ -1132,7 +1094,7 @@ nsBindingManager::WalkRules(nsStyleSet* aStyleSet,
nsIContent *content = aData->mContent; nsIContent *content = aData->mContent;
do { do {
nsXBLBinding *binding = nsBindingManager::GetBinding(content); nsXBLBinding *binding = GetBinding(content);
if (binding) { if (binding) {
aData->mScopedRoot = content; aData->mScopedRoot = content;
binding->WalkRules(aFunc, aData); binding->WalkRules(aFunc, aData);
@@ -1166,42 +1128,32 @@ nsBindingManager::WalkRules(nsStyleSet* aStyleSet,
return NS_OK; return NS_OK;
} }
nsresult PRBool
nsBindingManager::ShouldBuildChildFrames(nsIContent* aContent, PRBool* aResult) nsBindingManager::ShouldBuildChildFrames(nsIContent* aContent)
{ {
*aResult = PR_TRUE; nsXBLBinding *binding = GetBinding(aContent);
nsXBLBinding *binding = nsBindingManager::GetBinding(aContent); return !binding || binding->ShouldBuildChildFrames();
if (binding)
*aResult = binding->ShouldBuildChildFrames();
return NS_OK;
} }
nsresult nsIContent*
nsBindingManager::GetNestedInsertionPoint(nsIContent* aParent, nsIContent* aChild, nsIContent** aResult) nsBindingManager::GetNestedInsertionPoint(nsIContent* aParent, nsIContent* aChild)
{ {
*aResult = nsnull;
// Check to see if the content is anonymous. // Check to see if the content is anonymous.
if (aChild->GetBindingParent() == aParent) if (aChild->GetBindingParent() == aParent)
return NS_OK; // It is anonymous. Don't use the insertion point, since that's only return nsnull; // It is anonymous. Don't use the insertion point, since that's only
// for the explicit kids. // for the explicit kids.
PRUint32 index; PRUint32 index;
nsIContent *insertionElement = GetInsertionPoint(aParent, aChild, &index); nsIContent *insertionElement = GetInsertionPoint(aParent, aChild, &index);
if (insertionElement != aParent) { if (insertionElement != aParent) {
// See if we nest even further in. // See if we nest even further in.
nsCOMPtr<nsIContent> nestedPoint; nsIContent* nestedPoint = GetNestedInsertionPoint(insertionElement, aChild);
GetNestedInsertionPoint(insertionElement, aChild, getter_AddRefs(nestedPoint));
if (nestedPoint) if (nestedPoint)
insertionElement = nestedPoint; insertionElement = nestedPoint;
} }
*aResult = insertionElement; return insertionElement;
NS_IF_ADDREF(*aResult);
return NS_OK;
} }
// Note: We don't hold a reference to the document observer; we assume // Note: We don't hold a reference to the document observer; we assume
@@ -1252,8 +1204,7 @@ nsBindingManager::ContentAppended(nsIDocument* aDocument,
nsIContent *child = aContainer->GetChildAt(aNewIndexInContainer); nsIContent *child = aContainer->GetChildAt(aNewIndexInContainer);
nsCOMPtr<nsIContent> ins; nsCOMPtr<nsIContent> ins = GetNestedInsertionPoint(aContainer, child);
GetNestedInsertionPoint(aContainer, child, getter_AddRefs(ins));
if (ins) { if (ins) {
nsCOMPtr<nsIDOMNodeList> nodeList; nsCOMPtr<nsIDOMNodeList> nodeList;
@@ -1300,8 +1251,7 @@ nsBindingManager::ContentInserted(nsIDocument* aDocument,
// XXX This is hacked just to make menus work again. // XXX This is hacked just to make menus work again.
if (aIndexInContainer != -1 && mContentListTable.ops) { if (aIndexInContainer != -1 && mContentListTable.ops) {
// It's not anonymous. // It's not anonymous.
nsCOMPtr<nsIContent> ins; nsCOMPtr<nsIContent> ins = GetNestedInsertionPoint(aContainer, aChild);
GetNestedInsertionPoint(aContainer, aChild, getter_AddRefs(ins));
if (ins) { if (ins) {
nsCOMPtr<nsIDOMNodeList> nodeList; nsCOMPtr<nsIDOMNodeList> nodeList;
@@ -1377,8 +1327,7 @@ nsBindingManager::ContentRemoved(nsIDocument* aDocument,
// It's anonymous. // It's anonymous.
return; return;
nsCOMPtr<nsIContent> point; nsCOMPtr<nsIContent> point = GetNestedInsertionPoint(aContainer, aChild);
GetNestedInsertionPoint(aContainer, aChild, getter_AddRefs(point));
if (point) { if (point) {
nsCOMPtr<nsIDOMNodeList> nodeList; nsCOMPtr<nsIDOMNodeList> nodeList;

View File

@@ -74,12 +74,9 @@ public:
nsXBLBinding* GetBinding(nsIContent* aContent); nsXBLBinding* GetBinding(nsIContent* aContent);
nsresult SetBinding(nsIContent* aContent, nsXBLBinding* aBinding); nsresult SetBinding(nsIContent* aContent, nsXBLBinding* aBinding);
nsresult GetInsertionParent(nsIContent* aContent, nsIContent** aResult); nsIContent* GetInsertionParent(nsIContent* aContent);
nsresult SetInsertionParent(nsIContent* aContent, nsIContent* aResult); nsresult SetInsertionParent(nsIContent* aContent, nsIContent* aResult);
nsresult GetWrappedJS(nsIContent* aContent, nsIXPConnectWrappedJS** aResult);
nsresult SetWrappedJS(nsIContent* aContent, nsIXPConnectWrappedJS* aResult);
/** /**
* Notify the binding manager that an element * Notify the binding manager that an element
* has been moved from one document to another, * has been moved from one document to another,
@@ -98,7 +95,7 @@ public:
nsresult ChangeDocumentFor(nsIContent* aContent, nsIDocument* aOldDocument, nsresult ChangeDocumentFor(nsIContent* aContent, nsIDocument* aOldDocument,
nsIDocument* aNewDocument); nsIDocument* aNewDocument);
nsresult ResolveTag(nsIContent* aContent, PRInt32* aNameSpaceID, nsIAtom** aResult); nsIAtom* ResolveTag(nsIContent* aContent, PRInt32* aNameSpaceID);
/** /**
* Return a list of all explicit children, including any children * Return a list of all explicit children, including any children
@@ -117,7 +114,7 @@ public:
* Determine whether or not the explicit child list has been altered * Determine whether or not the explicit child list has been altered
* by XBL insertion points. * by XBL insertion points.
*/ */
nsresult HasContentListFor(nsIContent* aContent, PRBool* aResult); PRBool HasContentListFor(nsIContent* aContent);
/** /**
* For a given element, retrieve the anonymous child content. * For a given element, retrieve the anonymous child content.
@@ -145,7 +142,7 @@ public:
* anonymous content tree. Specifically, aChild should be inserted * anonymous content tree. Specifically, aChild should be inserted
* beneath aResult at the index specified by aIndex. * beneath aResult at the index specified by aIndex.
*/ */
virtual nsIContent* GetInsertionPoint(nsIContent* aParent, nsIContent* GetInsertionPoint(nsIContent* aParent,
nsIContent* aChild, PRUint32* aIndex); nsIContent* aChild, PRUint32* aIndex);
/** /**
@@ -153,8 +150,7 @@ public:
* element. If other filtered insertion points exist, * element. If other filtered insertion points exist,
* aMultipleInsertionPoints will be set to true. * aMultipleInsertionPoints will be set to true.
*/ */
virtual nsIContent* GetSingleInsertionPoint(nsIContent* aParent, nsIContent* GetSingleInsertionPoint(nsIContent* aParent, PRUint32* aIndex,
PRUint32* aIndex,
PRBool* aMultipleInsertionPoints); PRBool* aMultipleInsertionPoints);
nsresult AddLayeredBinding(nsIContent* aContent, nsIURI* aURL); nsresult AddLayeredBinding(nsIContent* aContent, nsIURI* aURL);
@@ -163,24 +159,23 @@ public:
nsIDocument** aResult); nsIDocument** aResult);
nsresult AddToAttachedQueue(nsXBLBinding* aBinding); nsresult AddToAttachedQueue(nsXBLBinding* aBinding);
nsresult ClearAttachedQueue(); void ProcessAttachedQueue();
nsresult ProcessAttachedQueue();
nsresult ExecuteDetachedHandlers(); void ExecuteDetachedHandlers();
nsresult PutXBLDocumentInfo(nsIXBLDocumentInfo* aDocumentInfo); nsresult PutXBLDocumentInfo(nsIXBLDocumentInfo* aDocumentInfo);
nsresult GetXBLDocumentInfo(nsIURI* aURI, nsIXBLDocumentInfo** aResult); nsIXBLDocumentInfo* GetXBLDocumentInfo(nsIURI* aURI);
nsresult RemoveXBLDocumentInfo(nsIXBLDocumentInfo* aDocumentInfo); void RemoveXBLDocumentInfo(nsIXBLDocumentInfo* aDocumentInfo);
nsresult PutLoadingDocListener(nsIURI* aURL, nsIStreamListener* aListener); nsresult PutLoadingDocListener(nsIURI* aURL, nsIStreamListener* aListener);
nsresult GetLoadingDocListener(nsIURI* aURL, nsIStreamListener** aResult); nsIStreamListener* GetLoadingDocListener(nsIURI* aURL);
nsresult RemoveLoadingDocListener(nsIURI* aURL); void RemoveLoadingDocListener(nsIURI* aURL);
nsresult FlushSkinBindings(); void FlushSkinBindings();
nsresult GetBindingImplementation(nsIContent* aContent, REFNSIID aIID, void** aResult); nsresult GetBindingImplementation(nsIContent* aContent, REFNSIID aIID, void** aResult);
nsresult ShouldBuildChildFrames(nsIContent* aContent, PRBool* aResult); PRBool ShouldBuildChildFrames(nsIContent* aContent);
/** /**
* Add a new observer of document change notifications. Whenever content is * Add a new observer of document change notifications. Whenever content is
@@ -207,6 +202,9 @@ public:
NS_DECL_CYCLE_COLLECTION_CLASS(nsBindingManager) NS_DECL_CYCLE_COLLECTION_CLASS(nsBindingManager)
protected: protected:
nsIXPConnectWrappedJS* GetWrappedJS(nsIContent* aContent);
nsresult SetWrappedJS(nsIContent* aContent, nsIXPConnectWrappedJS* aResult);
nsresult GetXBLChildNodesInternal(nsIContent* aContent, nsresult GetXBLChildNodesInternal(nsIContent* aContent,
nsIDOMNodeList** aResult, nsIDOMNodeList** aResult,
PRBool* aIsAnonymousContentList); PRBool* aIsAnonymousContentList);
@@ -214,7 +212,7 @@ protected:
nsIDOMNodeList** aResult, nsIDOMNodeList** aResult,
PRBool* aIsAnonymousContentList); PRBool* aIsAnonymousContentList);
nsresult GetNestedInsertionPoint(nsIContent* aParent, nsIContent* aChild, nsIContent** aResult); nsIContent* GetNestedInsertionPoint(nsIContent* aParent, nsIContent* aChild);
#define NS_BINDINGMANAGER_NOTIFY_OBSERVERS(func_, params_) \ #define NS_BINDINGMANAGER_NOTIFY_OBSERVERS(func_, params_) \
NS_OBSERVER_ARRAY_NOTIFY_OBSERVERS(mObservers, nsIMutationObserver, \ NS_OBSERVER_ARRAY_NOTIFY_OBSERVERS(mObservers, nsIMutationObserver, \

View File

@@ -419,9 +419,9 @@ nsXBLStreamListener::Load(nsIDOMEvent* aEvent)
} }
// Put our doc info in the doc table. // Put our doc info in the doc table.
nsCOMPtr<nsIXBLDocumentInfo> info;
nsBindingManager *xblDocBindingManager = mBindingDocument->BindingManager(); nsBindingManager *xblDocBindingManager = mBindingDocument->BindingManager();
xblDocBindingManager->GetXBLDocumentInfo(documentURI, getter_AddRefs(info)); nsCOMPtr<nsIXBLDocumentInfo> info =
xblDocBindingManager->GetXBLDocumentInfo(documentURI);
xblDocBindingManager->RemoveXBLDocumentInfo(info); // Break the self-imposed cycle. xblDocBindingManager->RemoveXBLDocumentInfo(info); // Break the self-imposed cycle.
if (!info) { if (!info) {
NS_ERROR("An XBL file is malformed. Did you forget the XBL namespace on the bindings tag?"); NS_ERROR("An XBL file is malformed. Did you forget the XBL namespace on the bindings tag?");
@@ -708,12 +708,13 @@ nsXBLService::ResolveTag(nsIContent* aContent, PRInt32* aNameSpaceID,
{ {
nsIDocument* document = aContent->GetOwnerDoc(); nsIDocument* document = aContent->GetOwnerDoc();
if (document) { if (document) {
return document->BindingManager()->ResolveTag(aContent, aNameSpaceID, *aResult = document->BindingManager()->ResolveTag(aContent, aNameSpaceID);
aResult); NS_IF_ADDREF(*aResult);
} }
else {
*aNameSpaceID = aContent->GetNameSpaceID(); *aNameSpaceID = aContent->GetNameSpaceID();
NS_ADDREF(*aResult = aContent->Tag()); NS_ADDREF(*aResult = aContent->Tag());
}
return NS_OK; return NS_OK;
} }
@@ -737,8 +738,10 @@ nsXBLService::GetXBLDocumentInfo(nsIURI* aURI, nsIContent* aBoundElement, nsIXBL
if (!*aResult) { if (!*aResult) {
// The second line of defense is the binding manager's document table. // The second line of defense is the binding manager's document table.
nsIDocument* boundDocument = aBoundElement->GetOwnerDoc(); nsIDocument* boundDocument = aBoundElement->GetOwnerDoc();
if (boundDocument) if (boundDocument) {
boundDocument->BindingManager()->GetXBLDocumentInfo(aURI, aResult); *aResult = boundDocument->BindingManager()->GetXBLDocumentInfo(aURI);
NS_IF_ADDREF(*aResult);
}
} }
return NS_OK; return NS_OK;
} }
@@ -1063,7 +1066,7 @@ nsXBLService::LoadBindingDocumentInfo(nsIContent* aBoundElement,
if (aBoundDocument) { if (aBoundDocument) {
bindingManager = aBoundDocument->BindingManager(); bindingManager = aBoundDocument->BindingManager();
bindingManager->GetXBLDocumentInfo(documentURI, getter_AddRefs(info)); info = bindingManager->GetXBLDocumentInfo(documentURI);
} }
nsINodeInfo *ni = nsnull; nsINodeInfo *ni = nsnull;
@@ -1083,10 +1086,10 @@ nsXBLService::LoadBindingDocumentInfo(nsIContent* aBoundElement,
// processed whenever the doc does finish loading. // processed whenever the doc does finish loading.
nsCOMPtr<nsIStreamListener> listener; nsCOMPtr<nsIStreamListener> listener;
if (bindingManager) if (bindingManager)
bindingManager->GetLoadingDocListener(documentURI, getter_AddRefs(listener)); listener = bindingManager->GetLoadingDocListener(documentURI);
if (listener) { if (listener) {
nsIStreamListener* ilist = listener.get(); nsXBLStreamListener* xblListener =
nsXBLStreamListener* xblListener = NS_STATIC_CAST(nsXBLStreamListener*, ilist); NS_STATIC_CAST(nsXBLStreamListener*, listener.get());
// Create a new load observer. // Create a new load observer.
if (!xblListener->HasRequest(aBindingURI, aBoundElement)) { if (!xblListener->HasRequest(aBindingURI, aBoundElement)) {
nsXBLBindingRequest* req = nsXBLBindingRequest::Create(mPool, aBindingURI, aBoundElement); nsXBLBindingRequest* req = nsXBLBindingRequest::Create(mPool, aBindingURI, aBoundElement);
@@ -1111,7 +1114,7 @@ nsXBLService::LoadBindingDocumentInfo(nsIContent* aBoundElement,
if (document) { if (document) {
nsBindingManager *xblDocBindingManager = document->BindingManager(); nsBindingManager *xblDocBindingManager = document->BindingManager();
xblDocBindingManager->GetXBLDocumentInfo(documentURI, getter_AddRefs(info)); info = xblDocBindingManager->GetXBLDocumentInfo(documentURI);
if (!info) { if (!info) {
NS_ERROR("An XBL file is malformed. Did you forget the XBL namespace on the bindings tag?"); NS_ERROR("An XBL file is malformed. Did you forget the XBL namespace on the bindings tag?");
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;

View File

@@ -3612,24 +3612,19 @@ nsXULDocument::CheckTemplateBuilderHookup(nsIContent* aElement,
return NS_OK; return NS_OK;
} }
nsresult /* static */ nsresult
nsXULDocument::CreateTemplateBuilder(nsIContent* aElement) nsXULDocument::CreateTemplateBuilder(nsIContent* aElement)
{ {
// Check if need to construct a tree builder or content builder. // Check if need to construct a tree builder or content builder.
PRBool isTreeBuilder = PR_FALSE; PRBool isTreeBuilder = PR_FALSE;
PRInt32 nameSpaceID; nsIDocument *document = aElement->GetOwnerDoc();
nsCOMPtr<nsIAtom> baseTag; NS_ASSERTION(document, "no document");
NS_ENSURE_TRUE(document, NS_ERROR_UNEXPECTED);
nsCOMPtr<nsIXBLService> xblService = do_GetService("@mozilla.org/xbl;1"); PRInt32 nameSpaceID;
if (xblService) { nsIAtom* baseTag = document->BindingManager()->
xblService->ResolveTag(aElement, &nameSpaceID, getter_AddRefs(baseTag)); ResolveTag(aElement, &nameSpaceID);
}
else {
nsINodeInfo *ni = aElement->NodeInfo();
nameSpaceID = ni->NamespaceID();
baseTag = ni->NameAtom();
}
if ((nameSpaceID == kNameSpaceID_XUL) && (baseTag == nsGkAtoms::tree)) { if ((nameSpaceID == kNameSpaceID_XUL) && (baseTag == nsGkAtoms::tree)) {
// By default, we build content for a tree and then we attach // By default, we build content for a tree and then we attach
@@ -3662,12 +3657,6 @@ nsXULDocument::CreateTemplateBuilder(nsIContent* aElement)
getter_AddRefs(bodyContent)); getter_AddRefs(bodyContent));
if (! bodyContent) { if (! bodyContent) {
// Get the document.
nsIDocument *document = aElement->GetDocument();
NS_ASSERTION(document, "no document");
if (! document)
return NS_ERROR_UNEXPECTED;
nsresult rv = document->CreateElem(nsGkAtoms::treechildren, nsresult rv = document->CreateElem(nsGkAtoms::treechildren,
nsnull, kNameSpaceID_XUL, nsnull, kNameSpaceID_XUL,
PR_FALSE, PR_FALSE,

View File

@@ -6078,13 +6078,11 @@ nsCSSFrameConstructor::ConstructXULFrame(nsFrameConstructorState& aState,
if (!newFrame->IsLeaf()) { if (!newFrame->IsLeaf()) {
// XXXbz don't we need calls to ShouldBuildChildFrames // XXXbz don't we need calls to ShouldBuildChildFrames
// elsewhere too? Why only for XUL? // elsewhere too? Why only for XUL?
PRBool processChildren = PR_TRUE; if (mDocument->BindingManager()->ShouldBuildChildFrames(aContent)) {
mDocument->BindingManager()->ShouldBuildChildFrames(aContent,
&processChildren);
if (processChildren)
rv = ProcessChildren(aState, aContent, newFrame, PR_FALSE, rv = ProcessChildren(aState, aContent, newFrame, PR_FALSE,
childItems, PR_FALSE); childItems, PR_FALSE);
} }
}
CreateAnonymousFrames(aTag, aState, aContent, newFrame, PR_FALSE, CreateAnonymousFrames(aTag, aState, aContent, newFrame, PR_FALSE,
childItems); childItems);
@@ -7025,10 +7023,10 @@ nsCSSFrameConstructor::ConstructSVGFrame(nsFrameConstructorState& aState,
PRBool parentIsSVG = PR_FALSE; PRBool parentIsSVG = PR_FALSE;
if (aParentFrame && aParentFrame->GetContent()) { if (aParentFrame && aParentFrame->GetContent()) {
nsCOMPtr<nsIAtom> parentTag;
PRInt32 parentNSID; PRInt32 parentNSID;
nsIAtom* parentTag =
mDocument->BindingManager()->ResolveTag(aParentFrame->GetContent(), mDocument->BindingManager()->ResolveTag(aParentFrame->GetContent(),
&parentNSID, getter_AddRefs(parentTag)); &parentNSID);
parentIsSVG = parentNSID == kNameSpaceID_SVG parentIsSVG = parentNSID == kNameSpaceID_SVG
#ifdef MOZ_SVG_FOREIGNOBJECT #ifdef MOZ_SVG_FOREIGNOBJECT
@@ -7415,9 +7413,9 @@ nsCSSFrameConstructor::ConstructFrameInternal( nsFrameConstructorState& aState,
display = styleContext->GetStyleDisplay(); display = styleContext->GetStyleDisplay();
} }
nsCOMPtr<nsIAtom> baseTag;
PRInt32 nameSpaceID; PRInt32 nameSpaceID;
xblService->ResolveTag(aContent, &nameSpaceID, getter_AddRefs(baseTag)); nsCOMPtr<nsIAtom> baseTag =
mDocument->BindingManager()->ResolveTag(aContent, &nameSpaceID);
if (baseTag != aTag || aNameSpaceID != nameSpaceID) { if (baseTag != aTag || aNameSpaceID != nameSpaceID) {
// Construct the frame using the XBL base tag. // Construct the frame using the XBL base tag.
@@ -8193,10 +8191,9 @@ nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer,
#ifdef MOZ_XUL #ifdef MOZ_XUL
if (aContainer) { if (aContainer) {
nsCOMPtr<nsIAtom> tag;
PRInt32 namespaceID; PRInt32 namespaceID;
mDocument->BindingManager()->ResolveTag(aContainer, &namespaceID, nsIAtom* tag =
getter_AddRefs(tag)); mDocument->BindingManager()->ResolveTag(aContainer, &namespaceID);
// Just ignore tree tags, anyway we don't create any frames for them. // Just ignore tree tags, anyway we don't create any frames for them.
if (tag == nsGkAtoms::treechildren || if (tag == nsGkAtoms::treechildren ||
@@ -8226,19 +8223,14 @@ nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer,
PRBool hasInsertion = PR_FALSE; PRBool hasInsertion = PR_FALSE;
if (!multiple) { if (!multiple) {
nsBindingManager *bindingManager = nsnull;
nsIDocument* document = nsnull; nsIDocument* document = nsnull;
nsIContent *firstAppendedChild = nsIContent *firstAppendedChild =
aContainer->GetChildAt(aNewIndexInContainer); aContainer->GetChildAt(aNewIndexInContainer);
if (firstAppendedChild) { if (firstAppendedChild) {
document = firstAppendedChild->GetDocument(); document = firstAppendedChild->GetDocument();
} }
if (document) if (document &&
bindingManager = document->BindingManager(); document->BindingManager()->GetInsertionParent(firstAppendedChild)) {
if (bindingManager) {
nsCOMPtr<nsIContent> insParent;
bindingManager->GetInsertionParent(firstAppendedChild, getter_AddRefs(insParent));
if (insParent)
hasInsertion = PR_TRUE; hasInsertion = PR_TRUE;
} }
} }
@@ -8696,10 +8688,9 @@ PRBool NotifyListBoxBody(nsPresContext* aPresContext,
} }
} }
nsCOMPtr<nsIAtom> tag;
PRInt32 namespaceID; PRInt32 namespaceID;
aDocument->BindingManager()->ResolveTag(aContainer, &namespaceID, nsIAtom* tag =
getter_AddRefs(tag)); aDocument->BindingManager()->ResolveTag(aContainer, &namespaceID);
// Just ignore tree tags, anyway we don't create any frames for them. // Just ignore tree tags, anyway we don't create any frames for them.
if (tag == nsGkAtoms::treechildren || if (tag == nsGkAtoms::treechildren ||
@@ -10043,9 +10034,8 @@ nsCSSFrameConstructor::AttributeChanged(nsIContent* aContent,
// happen otherwise). // happen otherwise).
if (!primaryFrame && !reframe) { if (!primaryFrame && !reframe) {
PRInt32 namespaceID; PRInt32 namespaceID;
nsCOMPtr<nsIAtom> tag; nsIAtom* tag =
mDocument->BindingManager()->ResolveTag(aContent, &namespaceID, mDocument->BindingManager()->ResolveTag(aContent, &namespaceID);
getter_AddRefs(tag));
if (namespaceID == kNameSpaceID_XUL && if (namespaceID == kNameSpaceID_XUL &&
(tag == nsGkAtoms::listitem || (tag == nsGkAtoms::listitem ||
@@ -10105,9 +10095,8 @@ nsCSSFrameConstructor::AttributeChanged(nsIContent* aContent,
aModType != nsIDOMMutationEvent::REMOVAL) || aModType != nsIDOMMutationEvent::REMOVAL) ||
aAttribute == nsGkAtoms::menuactive)) { aAttribute == nsGkAtoms::menuactive)) {
PRInt32 namespaceID; PRInt32 namespaceID;
nsCOMPtr<nsIAtom> tag; nsIAtom* tag =
mDocument->BindingManager()->ResolveTag(aContent, &namespaceID, mDocument->BindingManager()->ResolveTag(aContent, &namespaceID);
getter_AddRefs(tag));
if (namespaceID == kNameSpaceID_XUL && if (namespaceID == kNameSpaceID_XUL &&
(tag == nsGkAtoms::menupopup || tag == nsGkAtoms::popup || (tag == nsGkAtoms::menupopup || tag == nsGkAtoms::popup ||

View File

@@ -129,10 +129,10 @@ inDOMUtils::GetParentForNode(nsIDOMNode* aNode,
} else if (aShowingAnonymousContent) { } else if (aShowingAnonymousContent) {
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode); nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
if (content) { if (content) {
nsCOMPtr<nsIContent> bparent; nsIContent* bparent = nsnull;
nsRefPtr<nsBindingManager> bindingManager = inLayoutUtils::GetBindingManagerFor(aNode); nsRefPtr<nsBindingManager> bindingManager = inLayoutUtils::GetBindingManagerFor(aNode);
if (bindingManager) { if (bindingManager) {
bindingManager->GetInsertionParent(content, getter_AddRefs(bparent)); bparent = bindingManager->GetInsertionParent(content);
} }
parent = do_QueryInterface(bparent); parent = do_QueryInterface(bparent);

View File

@@ -753,16 +753,15 @@ nsSplitterFrameInner::MouseDown(nsIDOMEvent* aMouseEvent)
while (nsnull != childBox) while (nsnull != childBox)
{ {
nsIContent* content = childBox->GetContent(); nsIContent* content = childBox->GetContent();
nsCOMPtr<nsIAtom> atom;
nsresult rv; nsresult rv;
nsCOMPtr<nsIXBLService> xblService = nsIDocument* doc = content->GetOwnerDoc();
do_GetService("@mozilla.org/xbl;1", &rv); nsIAtom* atom;
if (doc) {
if (NS_SUCCEEDED(rv) && xblService) {
PRInt32 dummy; PRInt32 dummy;
xblService->ResolveTag(content, &dummy, getter_AddRefs(atom)); atom = doc->BindingManager()->ResolveTag(content, &dummy);
} else } else {
atom = content->Tag(); atom = content->Tag();
}
// skip over any splitters // skip over any splitters
if (atom != nsGkAtoms::splitter) { if (atom != nsGkAtoms::splitter) {