diff --git a/content/base/public/nsIDocument.h b/content/base/public/nsIDocument.h index 4ed863e733c..7db0a78ed96 100644 --- a/content/base/public/nsIDocument.h +++ b/content/base/public/nsIDocument.h @@ -844,7 +844,7 @@ public: /** * See FlushSkinBindings on nsBindingManager */ - virtual nsresult FlushSkinBindings() = 0; + virtual void FlushSkinBindings() = 0; protected: ~nsIDocument() diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp index 557c5c129e7..c2f4387d34f 100644 --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -1346,35 +1346,29 @@ nsContentUtils::FindFirstChildWithResolvedTag(nsIContent* aParent, PRInt32 aNamespace, nsIAtom* aTag) { - if (!aParent) { + nsIDocument* doc; + if (!aParent || !(doc = aParent->GetOwnerDoc())) { return nsnull; } + + nsBindingManager* bindingManager = doc->BindingManager(); - nsresult rv; - nsCOMPtr xblService = - do_GetService("@mozilla.org/xbl;1", &rv); PRInt32 namespaceID; PRUint32 count = aParent->GetChildCount(); PRUint32 i; - nsCOMPtr tag; for (i = 0; i < count; i++) { nsIContent *child = aParent->GetChildAt(i); - xblService->ResolveTag(child, &namespaceID, getter_AddRefs(tag)); + nsIAtom* tag = bindingManager->ResolveTag(child, &namespaceID); if (tag == aTag && namespaceID == aNamespace) { return child; } } // now look for children in XBL - nsIDocument* doc = aParent->GetDocument(); - if (!doc) { - return nsnull; - } - nsCOMPtr children; - doc->BindingManager()->GetXBLChildNodesFor(aParent, getter_AddRefs(children)); + bindingManager->GetXBLChildNodesFor(aParent, getter_AddRefs(children)); if (!children) { return nsnull; } @@ -1385,7 +1379,7 @@ nsContentUtils::FindFirstChildWithResolvedTag(nsIContent* aParent, nsCOMPtr childNode; children->Item(i, getter_AddRefs(childNode)); nsCOMPtr childContent = do_QueryInterface(childNode); - xblService->ResolveTag(childContent, &namespaceID, getter_AddRefs(tag)); + nsIAtom* tag = bindingManager->ResolveTag(childContent, &namespaceID); if (tag == aTag && namespaceID == aNamespace) { return childContent; } diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 9994c25e195..6dbcda17f96 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -3593,10 +3593,7 @@ nsDocument::GetBoxObjectFor(nsIDOMElement* aElement, nsIBoxObject** aResult) } PRInt32 namespaceID; - nsCOMPtr tag; - nsCOMPtr xblService = do_GetService("@mozilla.org/xbl;1"); - NS_ENSURE_TRUE(xblService, NS_ERROR_FAILURE); - xblService->ResolveTag(content, &namespaceID, getter_AddRefs(tag)); + nsCOMPtr tag = mBindingManager->ResolveTag(content, &namespaceID); nsCAutoString contractID("@mozilla.org/layout/xul-boxobject"); if (namespaceID == kNameSpaceID_XUL) { @@ -3659,10 +3656,10 @@ nsDocument::GetContentListFor(nsIContent* aContent, nsIDOMNodeList** aResult) return mBindingManager->GetContentListFor(aContent, aResult); } -nsresult +void nsDocument::FlushSkinBindings() { - return mBindingManager->FlushSkinBindings(); + mBindingManager->FlushSkinBindings(); } struct DirTable { diff --git a/content/base/src/nsDocument.h b/content/base/src/nsDocument.h index dc143cfe699..f351f79a064 100644 --- a/content/base/src/nsDocument.h +++ b/content/base/src/nsDocument.h @@ -648,7 +648,7 @@ public: nsIDOMNodeList** aResult); virtual NS_HIDDEN_(nsresult) GetContentListFor(nsIContent* aContent, nsIDOMNodeList** aResult); - virtual NS_HIDDEN_(nsresult) FlushSkinBindings(); + virtual NS_HIDDEN_(void) FlushSkinBindings(); NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsDocument, nsIDocument) diff --git a/content/base/src/nsGenericElement.cpp b/content/base/src/nsGenericElement.cpp index 85a5714adef..0e2ad6f5cd6 100644 --- a/content/base/src/nsGenericElement.cpp +++ b/content/base/src/nsGenericElement.cpp @@ -1899,14 +1899,13 @@ nsGenericElement::doPreHandleEvent(nsIContent* aContent, // XXX XBL2/sXBL issue nsIDocument* ownerDoc = aContent->GetOwnerDoc(); if (ownerDoc) { - nsCOMPtr insertionParent; - ownerDoc->BindingManager()-> - GetInsertionParent(aContent, getter_AddRefs(insertionParent)); + nsIContent* insertionParent = ownerDoc->BindingManager()-> + GetInsertionParent(aContent); NS_ASSERTION(!(aVisitor.mEventTargetAtParent && insertionParent && aVisitor.mEventTargetAtParent != insertionParent), "Retargeting and having insertion parent!"); if (insertionParent) { - parent.swap(insertionParent); + parent = insertionParent; } } @@ -3661,6 +3660,8 @@ nsGenericElement::List(FILE* out, PRInt32 aIndent, } fputs(">\n", out); + + nsGenericElement* nonConstThis = NS_CONST_CAST(nsGenericElement*, this); // XXX sXBL/XBL2 issue! Owner or current document? nsIDocument *document = GetOwnerDoc(); @@ -3669,7 +3670,7 @@ nsGenericElement::List(FILE* out, PRInt32 aIndent, nsBindingManager* bindingManager = document->BindingManager(); nsCOMPtr anonymousChildren; - bindingManager->GetAnonymousNodesFor(NS_CONST_CAST(nsGenericElement*, this), + bindingManager->GetAnonymousNodesFor(nonConstThis, getter_AddRefs(anonymousChildren)); if (anonymousChildren) { @@ -3690,13 +3691,9 @@ nsGenericElement::List(FILE* out, PRInt32 aIndent, } } - PRBool hasContentList; - bindingManager->HasContentListFor(NS_CONST_CAST(nsGenericElement*, this), - &hasContentList); - - if (hasContentList) { + if (bindingManager->HasContentListFor(nonConstThis)) { nsCOMPtr contentList; - bindingManager->GetContentListFor(NS_CONST_CAST(nsGenericElement*, this), + bindingManager->GetContentListFor(nonConstThis, getter_AddRefs(contentList)); NS_ASSERTION(contentList != nsnull, "oops, binding manager lied"); diff --git a/content/svg/content/src/nsSVGElement.cpp b/content/svg/content/src/nsSVGElement.cpp index 06002027b14..5e70a41b13d 100644 --- a/content/svg/content/src/nsSVGElement.cpp +++ b/content/svg/content/src/nsSVGElement.cpp @@ -558,11 +558,11 @@ nsSVGElement::GetOwnerSVGElement(nsIDOMSVGSVGElement * *aOwnerSVGElement) bindingManager = ownerDoc->BindingManager(); } - nsCOMPtr parent; + nsIContent* parent = nsnull; if (bindingManager) { // we have a binding manager -- do we have an anonymous parent? - bindingManager->GetInsertionParent(this, getter_AddRefs(parent)); + parent = bindingManager->GetInsertionParent(this); } if (!parent) { @@ -578,12 +578,11 @@ nsSVGElement::GetOwnerSVGElement(nsIDOMSVGSVGElement * *aOwnerSVGElement) NS_ADDREF(*aOwnerSVGElement); return NS_OK; } - nsCOMPtr next; + nsIContent* next = nsnull; if (bindingManager) { - bindingManager->GetInsertionParent(parent, getter_AddRefs(next)); + next = bindingManager->GetInsertionParent(parent); } - if (!next) { // no anonymous parent, so use explicit one next = parent->GetParent(); diff --git a/content/svg/content/src/nsSVGGraphicElement.cpp b/content/svg/content/src/nsSVGGraphicElement.cpp index d2e9ad97614..87f1b567f50 100644 --- a/content/svg/content/src/nsSVGGraphicElement.cpp +++ b/content/svg/content/src/nsSVGGraphicElement.cpp @@ -152,12 +152,12 @@ NS_IMETHODIMP nsSVGGraphicElement::GetCTM(nsIDOMSVGMatrix **_retval) bindingManager = ownerDoc->BindingManager(); } - nsCOMPtr parent; + nsIContent* parent = nsnull; nsCOMPtr parentCTM; if (bindingManager) { // check for an anonymous parent first - bindingManager->GetInsertionParent(this, getter_AddRefs(parent)); + parent = bindingManager->GetInsertionParent(this); } if (!parent) { // 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(); } - nsCOMPtr parent; + nsIContent* parent = nsnull; nsCOMPtr parentScreenCTM; if (bindingManager) { // check for an anonymous parent first - bindingManager->GetInsertionParent(this, getter_AddRefs(parent)); + parent = bindingManager->GetInsertionParent(this); } if (!parent) { // if we didn't find an anonymous parent, use the explicit one diff --git a/content/svg/content/src/nsSVGSVGElement.cpp b/content/svg/content/src/nsSVGSVGElement.cpp index 3fdd113c4ea..05828df0102 100644 --- a/content/svg/content/src/nsSVGSVGElement.cpp +++ b/content/svg/content/src/nsSVGSVGElement.cpp @@ -731,9 +731,10 @@ nsSVGSVGElement::GetCTM(nsIDOMSVGMatrix **_retval) nsCOMPtr ancestorCTM; while (1) { + ancestor = nsnull; if (bindingManager) { // check for an anonymous ancestor first - bindingManager->GetInsertionParent(element, getter_AddRefs(ancestor)); + ancestor = bindingManager->GetInsertionParent(element); } if (!ancestor) { // if we didn't find an anonymous ancestor, use the explicit one @@ -844,9 +845,10 @@ nsSVGSVGElement::GetScreenCTM(nsIDOMSVGMatrix **_retval) nsCOMPtr ancestorScreenCTM; while (1) { + ancestor = nsnull; if (bindingManager) { // check for an anonymous ancestor first - bindingManager->GetInsertionParent(element, getter_AddRefs(ancestor)); + ancestor = bindingManager->GetInsertionParent(element); } if (!ancestor) { // if we didn't find an anonymous ancestor, use the explicit one diff --git a/content/xbl/src/nsBindingManager.cpp b/content/xbl/src/nsBindingManager.cpp index bf3d2208681..1f5dffd7133 100644 --- a/content/xbl/src/nsBindingManager.cpp +++ b/content/xbl/src/nsBindingManager.cpp @@ -442,19 +442,15 @@ nsBindingManager::SetBinding(nsIContent* aContent, nsXBLBinding* aBinding) return result ? NS_OK : NS_ERROR_FAILURE; } -nsresult -nsBindingManager::GetInsertionParent(nsIContent* aContent, nsIContent** aResult) +nsIContent* +nsBindingManager::GetInsertionParent(nsIContent* aContent) { if (mInsertionParentTable.ops) { - *aResult = NS_STATIC_CAST(nsIContent*, - LookupObject(mInsertionParentTable, aContent)); - NS_IF_ADDREF(*aResult); - } - else { - *aResult = nsnull; + return NS_STATIC_CAST(nsIContent*, + LookupObject(mInsertionParentTable, aContent)); } - return NS_OK; + return nsnull; } nsresult @@ -463,18 +459,14 @@ nsBindingManager::SetInsertionParent(nsIContent* aContent, nsIContent* aParent) return SetOrRemoveObject(mInsertionParentTable, aContent, aParent); } -nsresult -nsBindingManager::GetWrappedJS(nsIContent* aContent, nsIXPConnectWrappedJS** aResult) +nsIXPConnectWrappedJS* +nsBindingManager::GetWrappedJS(nsIContent* aContent) { if (mWrapperTable.ops) { - *aResult = NS_STATIC_CAST(nsIXPConnectWrappedJS*, LookupObject(mWrapperTable, aContent)); - NS_IF_ADDREF(*aResult); - } - else { - *aResult = nsnull; + return NS_STATIC_CAST(nsIXPConnectWrappedJS*, LookupObject(mWrapperTable, aContent)); } - return NS_OK; + return nsnull; } 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 // table. - nsRefPtr binding = nsBindingManager::GetBinding(aContent); + nsRefPtr binding = GetBinding(aContent); if (binding) { binding->ChangeDocument(aOldDocument, aNewDocument); SetBinding(aContent, nsnull); @@ -513,25 +505,21 @@ nsBindingManager::ChangeDocumentFor(nsIContent* aContent, nsIDocument* aOldDocum return NS_OK; } -nsresult -nsBindingManager::ResolveTag(nsIContent* aContent, PRInt32* aNameSpaceID, - nsIAtom** aResult) +nsIAtom* +nsBindingManager::ResolveTag(nsIContent* aContent, PRInt32* aNameSpaceID) { - nsXBLBinding *binding = nsBindingManager::GetBinding(aContent); + nsXBLBinding *binding = GetBinding(aContent); if (binding) { - *aResult = binding->GetBaseTag(aNameSpaceID); + nsIAtom* base = binding->GetBaseTag(aNameSpaceID); - if (*aResult) { - NS_ADDREF(*aResult); - return NS_OK; + if (base) { + return base; } } *aNameSpaceID = aContent->GetNameSpaceID(); - NS_ADDREF(*aResult = aContent->Tag()); - - return NS_OK; + return aContent->Tag(); } nsresult @@ -548,7 +536,7 @@ nsBindingManager::GetContentListFor(nsIContent* aContent, nsIDOMNodeList** aResu if (!*aResult) { nsCOMPtr node(do_QueryInterface(aContent)); - return node->GetChildNodes(aResult); + node->GetChildNodes(aResult); } return NS_OK; @@ -570,16 +558,10 @@ nsBindingManager::SetContentListFor(nsIContent* aContent, return SetOrRemoveObject(mContentListTable, aContent, contentList); } -nsresult -nsBindingManager::HasContentListFor(nsIContent* aContent, PRBool* aResult) +PRBool +nsBindingManager::HasContentListFor(nsIContent* aContent) { - *aResult = PR_FALSE; - if (mContentListTable.ops) { - nsISupports* list = LookupObject(mContentListTable, aContent); - *aResult = (list != nsnull); - } - - return NS_OK; + return mContentListTable.ops && LookupObject(mContentListTable, aContent); } nsresult @@ -597,7 +579,7 @@ nsBindingManager::GetAnonymousNodesInternal(nsIContent* aContent, if (!*aResult) { *aIsAnonymousContentList = PR_FALSE; - nsXBLBinding *binding = nsBindingManager::GetBinding(aContent); + nsXBLBinding *binding = GetBinding(aContent); if (binding) { *aResult = binding->GetAnonymousNodes().get(); return NS_OK; @@ -700,7 +682,7 @@ nsIContent* nsBindingManager::GetInsertionPoint(nsIContent* aParent, nsIContent* aChild, PRUint32* aIndex) { - nsXBLBinding *binding = nsBindingManager::GetBinding(aParent); + nsXBLBinding *binding = GetBinding(aParent); return binding ? binding->GetInsertionPoint(aChild, aIndex) : nsnull; } @@ -709,7 +691,7 @@ nsBindingManager::GetSingleInsertionPoint(nsIContent* aParent, PRUint32* aIndex, PRBool* aMultipleInsertionPoints) { - nsXBLBinding *binding = nsBindingManager::GetBinding(aParent); + nsXBLBinding *binding = GetBinding(aParent); if (binding) return binding->GetSingleInsertionPoint(aIndex, aMultipleInsertionPoints); @@ -744,7 +726,7 @@ nsresult nsBindingManager::RemoveLayeredBinding(nsIContent* aContent, nsIURI* aURL) { // Hold a ref to the binding so it won't die when we remove it from our table - nsRefPtr binding = nsBindingManager::GetBinding(aContent); + nsRefPtr binding = GetBinding(aContent); if (!binding) { return NS_OK; @@ -837,18 +819,11 @@ nsBindingManager::AddToAttachedQueue(nsXBLBinding* aBinding) return NS_OK; } -nsresult -nsBindingManager::ClearAttachedQueue() -{ - mAttachedStack.Clear(); - return NS_OK; -} - -nsresult +void nsBindingManager::ProcessAttachedQueue() { if (mProcessingAttachedStack) - return NS_OK; + return; mProcessingAttachedStack = PR_TRUE; @@ -862,8 +837,7 @@ nsBindingManager::ProcessAttachedQueue() } mProcessingAttachedStack = PR_FALSE; - ClearAttachedQueue(); - return NS_OK; + mAttachedStack.Clear(); } PR_STATIC_CALLBACK(PLDHashOperator) @@ -888,7 +862,7 @@ ExecuteDetachedHandler(void* aBinding, void* aClosure) return PR_TRUE; } -nsresult +void nsBindingManager::ExecuteDetachedHandlers() { // Walk our hashtable of bindings. @@ -897,7 +871,6 @@ nsBindingManager::ExecuteDetachedHandlers() mBindingTable.EnumerateRead(AccumulateBindingsToDetach, &bindingsToDetach); bindingsToDetach.EnumerateForwards(ExecuteDetachedHandler, nsnull); } - return NS_OK; } nsresult @@ -915,25 +888,21 @@ nsBindingManager::PutXBLDocumentInfo(nsIXBLDocumentInfo* aDocumentInfo) return NS_OK; } -nsresult +void nsBindingManager::RemoveXBLDocumentInfo(nsIXBLDocumentInfo* aDocumentInfo) { - if (!mDocumentTable.IsInitialized()) - return NS_OK; - - mDocumentTable.Remove(aDocumentInfo->DocumentURI()); - return NS_OK; + if (mDocumentTable.IsInitialized()) { + mDocumentTable.Remove(aDocumentInfo->DocumentURI()); + } } -nsresult -nsBindingManager::GetXBLDocumentInfo(nsIURI* aURL, nsIXBLDocumentInfo** aResult) +nsIXBLDocumentInfo* +nsBindingManager::GetXBLDocumentInfo(nsIURI* aURL) { - *aResult = nsnull; if (!mDocumentTable.IsInitialized()) - return NS_OK; + return nsnull; - mDocumentTable.Get(aURL, aResult); - return NS_OK; + return mDocumentTable.GetWeak(aURL); } nsresult @@ -950,26 +919,21 @@ nsBindingManager::PutLoadingDocListener(nsIURI* aURL, nsIStreamListener* aListen return NS_OK; } -nsresult -nsBindingManager::GetLoadingDocListener(nsIURI* aURL, nsIStreamListener** aResult) +nsIStreamListener* +nsBindingManager::GetLoadingDocListener(nsIURI* aURL) { - *aResult = nsnull; if (!mLoadingDocTable.IsInitialized()) - return NS_OK; + return nsnull; - mLoadingDocTable.Get(aURL, aResult); - return NS_OK; + return mLoadingDocTable.GetWeak(aURL); } -nsresult +void nsBindingManager::RemoveLoadingDocListener(nsIURI* aURL) { - if (!mLoadingDocTable.IsInitialized()) - return NS_OK; - - mLoadingDocTable.Remove(aURL); - - return NS_OK; + if (mLoadingDocTable.IsInitialized()) { + mLoadingDocTable.Remove(aURL); + } } PR_STATIC_CALLBACK(PLDHashOperator) @@ -987,12 +951,11 @@ MarkForDeath(nsISupports *aKey, nsXBLBinding *aBinding, void* aClosure) return PL_DHASH_NEXT; } -nsresult +void nsBindingManager::FlushSkinBindings() { if (mBindingTable.IsInitialized()) mBindingTable.EnumerateRead(MarkForDeath, nsnull); - return NS_OK; } // Used below to protect from recurring in QI calls through XPConnect. @@ -1012,13 +975,12 @@ nsBindingManager::GetBindingImplementation(nsIContent* aContent, REFNSIID aIID, void** aResult) { *aResult = nsnull; - nsXBLBinding *binding = nsBindingManager::GetBinding(aContent); + nsXBLBinding *binding = GetBinding(aContent); if (binding) { // The binding should not be asked for nsISupports NS_ASSERTION(!aIID.Equals(NS_GET_IID(nsISupports)), "Asking a binding for nsISupports"); if (binding->ImplementsInterface(aIID)) { - nsCOMPtr wrappedJS; - GetWrappedJS(aContent, getter_AddRefs(wrappedJS)); + nsCOMPtr wrappedJS = GetWrappedJS(aContent); if (wrappedJS) { // Protect from recurring in QI calls through XPConnect. @@ -1132,7 +1094,7 @@ nsBindingManager::WalkRules(nsStyleSet* aStyleSet, nsIContent *content = aData->mContent; do { - nsXBLBinding *binding = nsBindingManager::GetBinding(content); + nsXBLBinding *binding = GetBinding(content); if (binding) { aData->mScopedRoot = content; binding->WalkRules(aFunc, aData); @@ -1166,42 +1128,32 @@ nsBindingManager::WalkRules(nsStyleSet* aStyleSet, return NS_OK; } -nsresult -nsBindingManager::ShouldBuildChildFrames(nsIContent* aContent, PRBool* aResult) +PRBool +nsBindingManager::ShouldBuildChildFrames(nsIContent* aContent) { - *aResult = PR_TRUE; + nsXBLBinding *binding = GetBinding(aContent); - nsXBLBinding *binding = nsBindingManager::GetBinding(aContent); - - if (binding) - *aResult = binding->ShouldBuildChildFrames(); - - return NS_OK; + return !binding || binding->ShouldBuildChildFrames(); } -nsresult -nsBindingManager::GetNestedInsertionPoint(nsIContent* aParent, nsIContent* aChild, nsIContent** aResult) +nsIContent* +nsBindingManager::GetNestedInsertionPoint(nsIContent* aParent, nsIContent* aChild) { - *aResult = nsnull; - // Check to see if the content is anonymous. if (aChild->GetBindingParent() == aParent) - return NS_OK; // It is anonymous. Don't use the insertion point, since that's only - // for the explicit kids. + return nsnull; // It is anonymous. Don't use the insertion point, since that's only + // for the explicit kids. PRUint32 index; nsIContent *insertionElement = GetInsertionPoint(aParent, aChild, &index); if (insertionElement != aParent) { // See if we nest even further in. - nsCOMPtr nestedPoint; - GetNestedInsertionPoint(insertionElement, aChild, getter_AddRefs(nestedPoint)); + nsIContent* nestedPoint = GetNestedInsertionPoint(insertionElement, aChild); if (nestedPoint) insertionElement = nestedPoint; } - *aResult = insertionElement; - NS_IF_ADDREF(*aResult); - return NS_OK; + return insertionElement; } // 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); - nsCOMPtr ins; - GetNestedInsertionPoint(aContainer, child, getter_AddRefs(ins)); + nsCOMPtr ins = GetNestedInsertionPoint(aContainer, child); if (ins) { nsCOMPtr nodeList; @@ -1300,8 +1251,7 @@ nsBindingManager::ContentInserted(nsIDocument* aDocument, // XXX This is hacked just to make menus work again. if (aIndexInContainer != -1 && mContentListTable.ops) { // It's not anonymous. - nsCOMPtr ins; - GetNestedInsertionPoint(aContainer, aChild, getter_AddRefs(ins)); + nsCOMPtr ins = GetNestedInsertionPoint(aContainer, aChild); if (ins) { nsCOMPtr nodeList; @@ -1377,8 +1327,7 @@ nsBindingManager::ContentRemoved(nsIDocument* aDocument, // It's anonymous. return; - nsCOMPtr point; - GetNestedInsertionPoint(aContainer, aChild, getter_AddRefs(point)); + nsCOMPtr point = GetNestedInsertionPoint(aContainer, aChild); if (point) { nsCOMPtr nodeList; diff --git a/content/xbl/src/nsBindingManager.h b/content/xbl/src/nsBindingManager.h index b58fb406767..37fb0faaec0 100755 --- a/content/xbl/src/nsBindingManager.h +++ b/content/xbl/src/nsBindingManager.h @@ -74,12 +74,9 @@ public: nsXBLBinding* GetBinding(nsIContent* aContent); nsresult SetBinding(nsIContent* aContent, nsXBLBinding* aBinding); - nsresult GetInsertionParent(nsIContent* aContent, nsIContent** aResult); + nsIContent* GetInsertionParent(nsIContent* aContent); 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 * has been moved from one document to another, @@ -98,7 +95,7 @@ public: nsresult ChangeDocumentFor(nsIContent* aContent, nsIDocument* aOldDocument, 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 @@ -117,7 +114,7 @@ public: * Determine whether or not the explicit child list has been altered * by XBL insertion points. */ - nsresult HasContentListFor(nsIContent* aContent, PRBool* aResult); + PRBool HasContentListFor(nsIContent* aContent); /** * For a given element, retrieve the anonymous child content. @@ -145,17 +142,16 @@ public: * anonymous content tree. Specifically, aChild should be inserted * beneath aResult at the index specified by aIndex. */ - virtual nsIContent* GetInsertionPoint(nsIContent* aParent, - nsIContent* aChild, PRUint32* aIndex); + nsIContent* GetInsertionPoint(nsIContent* aParent, + nsIContent* aChild, PRUint32* aIndex); /** * Return the unfiltered insertion point for the specified parent * element. If other filtered insertion points exist, * aMultipleInsertionPoints will be set to true. */ - virtual nsIContent* GetSingleInsertionPoint(nsIContent* aParent, - PRUint32* aIndex, - PRBool* aMultipleInsertionPoints); + nsIContent* GetSingleInsertionPoint(nsIContent* aParent, PRUint32* aIndex, + PRBool* aMultipleInsertionPoints); nsresult AddLayeredBinding(nsIContent* aContent, nsIURI* aURL); nsresult RemoveLayeredBinding(nsIContent* aContent, nsIURI* aURL); @@ -163,24 +159,23 @@ public: nsIDocument** aResult); nsresult AddToAttachedQueue(nsXBLBinding* aBinding); - nsresult ClearAttachedQueue(); - nsresult ProcessAttachedQueue(); + void ProcessAttachedQueue(); - nsresult ExecuteDetachedHandlers(); + void ExecuteDetachedHandlers(); nsresult PutXBLDocumentInfo(nsIXBLDocumentInfo* aDocumentInfo); - nsresult GetXBLDocumentInfo(nsIURI* aURI, nsIXBLDocumentInfo** aResult); - nsresult RemoveXBLDocumentInfo(nsIXBLDocumentInfo* aDocumentInfo); + nsIXBLDocumentInfo* GetXBLDocumentInfo(nsIURI* aURI); + void RemoveXBLDocumentInfo(nsIXBLDocumentInfo* aDocumentInfo); nsresult PutLoadingDocListener(nsIURI* aURL, nsIStreamListener* aListener); - nsresult GetLoadingDocListener(nsIURI* aURL, nsIStreamListener** aResult); - nsresult RemoveLoadingDocListener(nsIURI* aURL); + nsIStreamListener* GetLoadingDocListener(nsIURI* aURL); + void RemoveLoadingDocListener(nsIURI* aURL); - nsresult FlushSkinBindings(); + void FlushSkinBindings(); 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 @@ -207,6 +202,9 @@ public: NS_DECL_CYCLE_COLLECTION_CLASS(nsBindingManager) protected: + nsIXPConnectWrappedJS* GetWrappedJS(nsIContent* aContent); + nsresult SetWrappedJS(nsIContent* aContent, nsIXPConnectWrappedJS* aResult); + nsresult GetXBLChildNodesInternal(nsIContent* aContent, nsIDOMNodeList** aResult, PRBool* aIsAnonymousContentList); @@ -214,7 +212,7 @@ protected: nsIDOMNodeList** aResult, PRBool* aIsAnonymousContentList); - nsresult GetNestedInsertionPoint(nsIContent* aParent, nsIContent* aChild, nsIContent** aResult); + nsIContent* GetNestedInsertionPoint(nsIContent* aParent, nsIContent* aChild); #define NS_BINDINGMANAGER_NOTIFY_OBSERVERS(func_, params_) \ NS_OBSERVER_ARRAY_NOTIFY_OBSERVERS(mObservers, nsIMutationObserver, \ diff --git a/content/xbl/src/nsXBLService.cpp b/content/xbl/src/nsXBLService.cpp index db6ce3425bc..07b956d3792 100644 --- a/content/xbl/src/nsXBLService.cpp +++ b/content/xbl/src/nsXBLService.cpp @@ -419,9 +419,9 @@ nsXBLStreamListener::Load(nsIDOMEvent* aEvent) } // Put our doc info in the doc table. - nsCOMPtr info; nsBindingManager *xblDocBindingManager = mBindingDocument->BindingManager(); - xblDocBindingManager->GetXBLDocumentInfo(documentURI, getter_AddRefs(info)); + nsCOMPtr info = + xblDocBindingManager->GetXBLDocumentInfo(documentURI); xblDocBindingManager->RemoveXBLDocumentInfo(info); // Break the self-imposed cycle. if (!info) { 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(); if (document) { - return document->BindingManager()->ResolveTag(aContent, aNameSpaceID, - aResult); + *aResult = document->BindingManager()->ResolveTag(aContent, aNameSpaceID); + NS_IF_ADDREF(*aResult); + } + else { + *aNameSpaceID = aContent->GetNameSpaceID(); + NS_ADDREF(*aResult = aContent->Tag()); } - - *aNameSpaceID = aContent->GetNameSpaceID(); - NS_ADDREF(*aResult = aContent->Tag()); return NS_OK; } @@ -737,8 +738,10 @@ nsXBLService::GetXBLDocumentInfo(nsIURI* aURI, nsIContent* aBoundElement, nsIXBL if (!*aResult) { // The second line of defense is the binding manager's document table. nsIDocument* boundDocument = aBoundElement->GetOwnerDoc(); - if (boundDocument) - boundDocument->BindingManager()->GetXBLDocumentInfo(aURI, aResult); + if (boundDocument) { + *aResult = boundDocument->BindingManager()->GetXBLDocumentInfo(aURI); + NS_IF_ADDREF(*aResult); + } } return NS_OK; } @@ -1063,7 +1066,7 @@ nsXBLService::LoadBindingDocumentInfo(nsIContent* aBoundElement, if (aBoundDocument) { bindingManager = aBoundDocument->BindingManager(); - bindingManager->GetXBLDocumentInfo(documentURI, getter_AddRefs(info)); + info = bindingManager->GetXBLDocumentInfo(documentURI); } nsINodeInfo *ni = nsnull; @@ -1083,10 +1086,10 @@ nsXBLService::LoadBindingDocumentInfo(nsIContent* aBoundElement, // processed whenever the doc does finish loading. nsCOMPtr listener; if (bindingManager) - bindingManager->GetLoadingDocListener(documentURI, getter_AddRefs(listener)); + listener = bindingManager->GetLoadingDocListener(documentURI); if (listener) { - nsIStreamListener* ilist = listener.get(); - nsXBLStreamListener* xblListener = NS_STATIC_CAST(nsXBLStreamListener*, ilist); + nsXBLStreamListener* xblListener = + NS_STATIC_CAST(nsXBLStreamListener*, listener.get()); // Create a new load observer. if (!xblListener->HasRequest(aBindingURI, aBoundElement)) { nsXBLBindingRequest* req = nsXBLBindingRequest::Create(mPool, aBindingURI, aBoundElement); @@ -1111,7 +1114,7 @@ nsXBLService::LoadBindingDocumentInfo(nsIContent* aBoundElement, if (document) { nsBindingManager *xblDocBindingManager = document->BindingManager(); - xblDocBindingManager->GetXBLDocumentInfo(documentURI, getter_AddRefs(info)); + info = xblDocBindingManager->GetXBLDocumentInfo(documentURI); if (!info) { NS_ERROR("An XBL file is malformed. Did you forget the XBL namespace on the bindings tag?"); return NS_ERROR_FAILURE; diff --git a/content/xul/document/src/nsXULDocument.cpp b/content/xul/document/src/nsXULDocument.cpp index 1d5cb467596..7c954499f70 100644 --- a/content/xul/document/src/nsXULDocument.cpp +++ b/content/xul/document/src/nsXULDocument.cpp @@ -3612,24 +3612,19 @@ nsXULDocument::CheckTemplateBuilderHookup(nsIContent* aElement, return NS_OK; } -nsresult +/* static */ nsresult nsXULDocument::CreateTemplateBuilder(nsIContent* aElement) { // Check if need to construct a tree builder or content builder. PRBool isTreeBuilder = PR_FALSE; - PRInt32 nameSpaceID; - nsCOMPtr baseTag; + nsIDocument *document = aElement->GetOwnerDoc(); + NS_ASSERTION(document, "no document"); + NS_ENSURE_TRUE(document, NS_ERROR_UNEXPECTED); - nsCOMPtr xblService = do_GetService("@mozilla.org/xbl;1"); - if (xblService) { - xblService->ResolveTag(aElement, &nameSpaceID, getter_AddRefs(baseTag)); - } - else { - nsINodeInfo *ni = aElement->NodeInfo(); - nameSpaceID = ni->NamespaceID(); - baseTag = ni->NameAtom(); - } + PRInt32 nameSpaceID; + nsIAtom* baseTag = document->BindingManager()-> + ResolveTag(aElement, &nameSpaceID); if ((nameSpaceID == kNameSpaceID_XUL) && (baseTag == nsGkAtoms::tree)) { // By default, we build content for a tree and then we attach @@ -3662,12 +3657,6 @@ nsXULDocument::CreateTemplateBuilder(nsIContent* aElement) getter_AddRefs(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, nsnull, kNameSpaceID_XUL, PR_FALSE, diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index ceee555c6a0..386d7118767 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -6078,12 +6078,10 @@ nsCSSFrameConstructor::ConstructXULFrame(nsFrameConstructorState& aState, if (!newFrame->IsLeaf()) { // XXXbz don't we need calls to ShouldBuildChildFrames // elsewhere too? Why only for XUL? - PRBool processChildren = PR_TRUE; - mDocument->BindingManager()->ShouldBuildChildFrames(aContent, - &processChildren); - if (processChildren) + if (mDocument->BindingManager()->ShouldBuildChildFrames(aContent)) { rv = ProcessChildren(aState, aContent, newFrame, PR_FALSE, childItems, PR_FALSE); + } } CreateAnonymousFrames(aTag, aState, aContent, newFrame, PR_FALSE, @@ -7025,10 +7023,10 @@ nsCSSFrameConstructor::ConstructSVGFrame(nsFrameConstructorState& aState, PRBool parentIsSVG = PR_FALSE; if (aParentFrame && aParentFrame->GetContent()) { - nsCOMPtr parentTag; PRInt32 parentNSID; - mDocument->BindingManager()->ResolveTag(aParentFrame->GetContent(), - &parentNSID, getter_AddRefs(parentTag)); + nsIAtom* parentTag = + mDocument->BindingManager()->ResolveTag(aParentFrame->GetContent(), + &parentNSID); parentIsSVG = parentNSID == kNameSpaceID_SVG #ifdef MOZ_SVG_FOREIGNOBJECT @@ -7415,10 +7413,10 @@ nsCSSFrameConstructor::ConstructFrameInternal( nsFrameConstructorState& aState, display = styleContext->GetStyleDisplay(); } - nsCOMPtr baseTag; PRInt32 nameSpaceID; - xblService->ResolveTag(aContent, &nameSpaceID, getter_AddRefs(baseTag)); - + nsCOMPtr baseTag = + mDocument->BindingManager()->ResolveTag(aContent, &nameSpaceID); + if (baseTag != aTag || aNameSpaceID != nameSpaceID) { // Construct the frame using the XBL base tag. rv = ConstructFrameInternal(aState, @@ -8193,10 +8191,9 @@ nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer, #ifdef MOZ_XUL if (aContainer) { - nsCOMPtr tag; PRInt32 namespaceID; - mDocument->BindingManager()->ResolveTag(aContainer, &namespaceID, - getter_AddRefs(tag)); + nsIAtom* tag = + mDocument->BindingManager()->ResolveTag(aContainer, &namespaceID); // Just ignore tree tags, anyway we don't create any frames for them. if (tag == nsGkAtoms::treechildren || @@ -8226,20 +8223,15 @@ nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer, PRBool hasInsertion = PR_FALSE; if (!multiple) { - nsBindingManager *bindingManager = nsnull; nsIDocument* document = nsnull; nsIContent *firstAppendedChild = aContainer->GetChildAt(aNewIndexInContainer); if (firstAppendedChild) { document = firstAppendedChild->GetDocument(); } - if (document) - bindingManager = document->BindingManager(); - if (bindingManager) { - nsCOMPtr insParent; - bindingManager->GetInsertionParent(firstAppendedChild, getter_AddRefs(insParent)); - if (insParent) - hasInsertion = PR_TRUE; + if (document && + document->BindingManager()->GetInsertionParent(firstAppendedChild)) { + hasInsertion = PR_TRUE; } } @@ -8696,10 +8688,9 @@ PRBool NotifyListBoxBody(nsPresContext* aPresContext, } } - nsCOMPtr tag; PRInt32 namespaceID; - aDocument->BindingManager()->ResolveTag(aContainer, &namespaceID, - getter_AddRefs(tag)); + nsIAtom* tag = + aDocument->BindingManager()->ResolveTag(aContainer, &namespaceID); // Just ignore tree tags, anyway we don't create any frames for them. if (tag == nsGkAtoms::treechildren || @@ -10043,9 +10034,8 @@ nsCSSFrameConstructor::AttributeChanged(nsIContent* aContent, // happen otherwise). if (!primaryFrame && !reframe) { PRInt32 namespaceID; - nsCOMPtr tag; - mDocument->BindingManager()->ResolveTag(aContent, &namespaceID, - getter_AddRefs(tag)); + nsIAtom* tag = + mDocument->BindingManager()->ResolveTag(aContent, &namespaceID); if (namespaceID == kNameSpaceID_XUL && (tag == nsGkAtoms::listitem || @@ -10105,9 +10095,8 @@ nsCSSFrameConstructor::AttributeChanged(nsIContent* aContent, aModType != nsIDOMMutationEvent::REMOVAL) || aAttribute == nsGkAtoms::menuactive)) { PRInt32 namespaceID; - nsCOMPtr tag; - mDocument->BindingManager()->ResolveTag(aContent, &namespaceID, - getter_AddRefs(tag)); + nsIAtom* tag = + mDocument->BindingManager()->ResolveTag(aContent, &namespaceID); if (namespaceID == kNameSpaceID_XUL && (tag == nsGkAtoms::menupopup || tag == nsGkAtoms::popup || diff --git a/layout/inspector/src/inDOMUtils.cpp b/layout/inspector/src/inDOMUtils.cpp index 4796c99baca..d76587bc72f 100644 --- a/layout/inspector/src/inDOMUtils.cpp +++ b/layout/inspector/src/inDOMUtils.cpp @@ -129,10 +129,10 @@ inDOMUtils::GetParentForNode(nsIDOMNode* aNode, } else if (aShowingAnonymousContent) { nsCOMPtr content = do_QueryInterface(aNode); if (content) { - nsCOMPtr bparent; + nsIContent* bparent = nsnull; nsRefPtr bindingManager = inLayoutUtils::GetBindingManagerFor(aNode); if (bindingManager) { - bindingManager->GetInsertionParent(content, getter_AddRefs(bparent)); + bparent = bindingManager->GetInsertionParent(content); } parent = do_QueryInterface(bparent); diff --git a/layout/xul/base/src/nsSplitterFrame.cpp b/layout/xul/base/src/nsSplitterFrame.cpp index 59ecbf753bc..a0daa3b43b1 100644 --- a/layout/xul/base/src/nsSplitterFrame.cpp +++ b/layout/xul/base/src/nsSplitterFrame.cpp @@ -753,16 +753,15 @@ nsSplitterFrameInner::MouseDown(nsIDOMEvent* aMouseEvent) while (nsnull != childBox) { nsIContent* content = childBox->GetContent(); - nsCOMPtr atom; nsresult rv; - nsCOMPtr xblService = - do_GetService("@mozilla.org/xbl;1", &rv); - - if (NS_SUCCEEDED(rv) && xblService) { + nsIDocument* doc = content->GetOwnerDoc(); + nsIAtom* atom; + if (doc) { PRInt32 dummy; - xblService->ResolveTag(content, &dummy, getter_AddRefs(atom)); - } else + atom = doc->BindingManager()->ResolveTag(content, &dummy); + } else { atom = content->Tag(); + } // skip over any splitters if (atom != nsGkAtoms::splitter) {