From c865dc3ca6d4dfcd1259e057afbc119bc098666d Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Thu, 24 Jan 2013 18:45:50 +0100 Subject: [PATCH] Bug 833412 - Remove AddBinding/RemoveBinding and remove dead code. r=bz --- content/base/public/nsIDocument.h | 4 -- content/base/src/Element.cpp | 3 +- content/base/src/nsDocument.cpp | 71 ------------------- content/xbl/src/nsBindingManager.cpp | 28 -------- content/xbl/src/nsBindingManager.h | 3 - content/xbl/src/nsXBLService.cpp | 33 +++------ content/xbl/src/nsXBLService.h | 2 +- .../xml/document/src/nsXMLPrettyPrinter.cpp | 2 +- dom/base/nsDOMClassInfo.cpp | 3 +- dom/interfaces/xbl/nsIDOMDocumentXBL.idl | 7 +- dom/webidl/Document.webidl | 4 -- layout/base/nsCSSFrameConstructor.cpp | 4 +- 12 files changed, 14 insertions(+), 150 deletions(-) diff --git a/content/base/public/nsIDocument.h b/content/base/public/nsIDocument.h index 211d73f609b4..00295da6507e 100644 --- a/content/base/public/nsIDocument.h +++ b/content/base/public/nsIDocument.h @@ -1946,10 +1946,6 @@ public: Element* GetAnonymousElementByAttribute(Element& aElement, const nsAString& aAttrName, const nsAString& aAttrValue); - void AddBinding(Element& aElement, const nsAString& aURI, - mozilla::ErrorResult& rv); - void RemoveBinding(Element& aElement, const nsAString& aURI, - mozilla::ErrorResult& rv); Element* GetBindingParent(nsINode& aNode); void LoadBindingDocument(const nsAString& aURI, mozilla::ErrorResult& rv); already_AddRefed diff --git a/content/base/src/Element.cpp b/content/base/src/Element.cpp index 20880c93415d..8d3c14e7aec6 100644 --- a/content/base/src/Element.cpp +++ b/content/base/src/Element.cpp @@ -404,8 +404,7 @@ Element::WrapObject(JSContext *aCx, JSObject *aScope, } nsRefPtr binding; - xblService->LoadBindings(this, uri, principal, false, getter_AddRefs(binding), - &dummy); + xblService->LoadBindings(this, uri, principal, getter_AddRefs(binding), &dummy); if (binding) { if (nsContentUtils::IsSafeToRunScript()) { diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 3819829b97c1..ca2aee8c1ed2 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -5174,77 +5174,6 @@ nsIDocument::ImportNode(nsINode& aNode, bool aDeep, ErrorResult& rv) const return nullptr; } -NS_IMETHODIMP -nsDocument::AddBinding(nsIDOMElement* aContent, const nsAString& aURI) -{ - nsCOMPtr element = do_QueryInterface(aContent); - NS_ENSURE_ARG_POINTER(element); - ErrorResult rv; - nsIDocument::AddBinding(*element, aURI, rv); - return rv.ErrorCode(); -} - -void -nsIDocument::AddBinding(Element& aContent, const nsAString& aURI, ErrorResult& rv) -{ - rv = nsContentUtils::CheckSameOrigin(this, &aContent); - if (rv.Failed()) { - return; - } - - nsCOMPtr uri; - rv = NS_NewURI(getter_AddRefs(uri), aURI); - if (rv.Failed()) { - return; - } - - // Figure out the right principal to use - nsCOMPtr subject; - nsIScriptSecurityManager* secMan = nsContentUtils::GetSecurityManager(); - if (secMan) { - rv = secMan->GetSubjectPrincipal(getter_AddRefs(subject)); - if (rv.Failed()) { - return; - } - } - - if (!subject) { - // Fall back to our principal. Or should we fall back to the null - // principal? The latter would just mean no binding loads.... - subject = NodePrincipal(); - } - - rv = BindingManager()->AddLayeredBinding(&aContent, uri, subject); -} - -NS_IMETHODIMP -nsDocument::RemoveBinding(nsIDOMElement* aContent, const nsAString& aURI) -{ - nsCOMPtr element = do_QueryInterface(aContent); - NS_ENSURE_ARG_POINTER(element); - ErrorResult rv; - nsIDocument::RemoveBinding(*element, aURI, rv); - return rv.ErrorCode(); -} - -void -nsIDocument::RemoveBinding(Element& aContent, const nsAString& aURI, - ErrorResult& rv) -{ - rv = nsContentUtils::CheckSameOrigin(this, &aContent); - if (rv.Failed()) { - return; - } - - nsCOMPtr uri; - rv = NS_NewURI(getter_AddRefs(uri), aURI); - if (rv.Failed()) { - return; - } - - rv = BindingManager()->RemoveLayeredBinding(&aContent, uri); -} - NS_IMETHODIMP nsDocument::LoadBindingDocument(const nsAString& aURI) { diff --git a/content/xbl/src/nsBindingManager.cpp b/content/xbl/src/nsBindingManager.cpp index c25dce554c7a..ebea653a4b73 100644 --- a/content/xbl/src/nsBindingManager.cpp +++ b/content/xbl/src/nsBindingManager.cpp @@ -834,34 +834,6 @@ nsBindingManager::GetSingleInsertionPoint(nsIContent* aParent, return nullptr; } -nsresult -nsBindingManager::AddLayeredBinding(nsIContent* aContent, nsIURI* aURL, - nsIPrincipal* aOriginPrincipal) -{ - // First we need to load our binding. - nsXBLService* xblService = nsXBLService::GetInstance(); - if (!xblService) - return NS_ERROR_FAILURE; - - // Load the bindings. - nsRefPtr binding; - bool dummy; - xblService->LoadBindings(aContent, aURL, aOriginPrincipal, true, - getter_AddRefs(binding), &dummy); - if (binding) { - AddToAttachedQueue(binding); - ProcessAttachedQueue(); - } - - return NS_OK; -} - -nsresult -nsBindingManager::RemoveLayeredBinding(nsIContent* aContent, nsIURI* aURL) -{ - return ClearBinding(aContent); -} - nsresult nsBindingManager::ClearBinding(nsIContent* aContent) { diff --git a/content/xbl/src/nsBindingManager.h b/content/xbl/src/nsBindingManager.h index 4d1539ffb261..b368ea08cde5 100644 --- a/content/xbl/src/nsBindingManager.h +++ b/content/xbl/src/nsBindingManager.h @@ -157,10 +157,7 @@ public: nsIContent* GetNestedSingleInsertionPoint(nsIContent* aParent, bool* aMultipleInsertionPoints); - nsresult AddLayeredBinding(nsIContent* aContent, nsIURI* aURL, - nsIPrincipal* aOriginPrincipal); nsresult ClearBinding(nsIContent* aContent); - nsresult RemoveLayeredBinding(nsIContent* aContent, nsIURI* aURL); nsresult LoadBindingDocument(nsIDocument* aBoundDoc, nsIURI* aURL, nsIPrincipal* aOriginPrincipal); diff --git a/content/xbl/src/nsXBLService.cpp b/content/xbl/src/nsXBLService.cpp index 5c7540819491..ceb44158d209 100644 --- a/content/xbl/src/nsXBLService.cpp +++ b/content/xbl/src/nsXBLService.cpp @@ -459,7 +459,7 @@ nsXBLService::IsChromeOrResourceURI(nsIURI* aURI) // onto the element. nsresult nsXBLService::LoadBindings(nsIContent* aContent, nsIURI* aURL, - nsIPrincipal* aOriginPrincipal, bool aAugmentFlag, + nsIPrincipal* aOriginPrincipal, nsXBLBinding** aBinding, bool* aResolveStyle) { NS_PRECONDITION(aOriginPrincipal, "Must have an origin principal"); @@ -482,7 +482,7 @@ nsXBLService::LoadBindings(nsIContent* aContent, nsIURI* aURL, nsBindingManager *bindingManager = document->BindingManager(); nsXBLBinding *binding = bindingManager->GetBinding(aContent); - if (binding && !aAugmentFlag) { + if (binding) { nsXBLBinding *styleBinding = binding->GetFirstStyleBinding(); if (styleBinding) { if (binding->MarkedForDeath()) { @@ -520,31 +520,14 @@ nsXBLService::LoadBindings(nsIContent* aContent, nsIURI* aURL, return NS_ERROR_ILLEGAL_VALUE; } - if (aAugmentFlag) { - nsXBLBinding *baseBinding; - nsXBLBinding *nextBinding = newBinding; - do { - baseBinding = nextBinding; - nextBinding = baseBinding->GetBaseBinding(); - baseBinding->SetIsStyleBinding(false); - } while (nextBinding); - - // XXX Handle adjusting the prototype chain! We need to somehow indicate to - // InstallImplementation that the whole chain should just be whacked and rebuilt. - // We are becoming the new binding. - baseBinding->SetBaseBinding(binding); - bindingManager->SetBinding(aContent, newBinding); + // We loaded a style binding. It goes on the end. + if (binding) { + // Get the last binding that is in the append layer. + binding->RootBinding()->SetBaseBinding(newBinding); } else { - // We loaded a style binding. It goes on the end. - if (binding) { - // Get the last binding that is in the append layer. - binding->RootBinding()->SetBaseBinding(newBinding); - } - else { - // Install the binding on the content node. - bindingManager->SetBinding(aContent, newBinding); - } + // Install the binding on the content node. + bindingManager->SetBinding(aContent, newBinding); } { diff --git a/content/xbl/src/nsXBLService.h b/content/xbl/src/nsXBLService.h index e96f1f8f80d3..3f7379caeab0 100644 --- a/content/xbl/src/nsXBLService.h +++ b/content/xbl/src/nsXBLService.h @@ -47,7 +47,7 @@ class nsXBLService : public nsIObserver, // This function loads a particular XBL file and installs all of the bindings // onto the element. aOriginPrincipal must not be null here. nsresult LoadBindings(nsIContent* aContent, nsIURI* aURL, - nsIPrincipal* aOriginPrincipal, bool aAugmentFlag, + nsIPrincipal* aOriginPrincipal, nsXBLBinding** aBinding, bool* aResolveStyle); // Indicates whether or not a binding is fully loaded. diff --git a/content/xml/document/src/nsXMLPrettyPrinter.cpp b/content/xml/document/src/nsXMLPrettyPrinter.cpp index 43b5c8258e13..4680a00f69cd 100644 --- a/content/xml/document/src/nsXMLPrettyPrinter.cpp +++ b/content/xml/document/src/nsXMLPrettyPrinter.cpp @@ -147,7 +147,7 @@ nsXMLPrettyPrinter::PrettyPrint(nsIDocument* aDocument, // Load the bindings. nsRefPtr unused; bool ignored; - rv = xblService->LoadBindings(rootCont, bindingUri, sysPrincipal, false, + rv = xblService->LoadBindings(rootCont, bindingUri, sysPrincipal, getter_AddRefs(unused), &ignored); NS_ENSURE_SUCCESS(rv, rv); diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index bec40fe0561c..b6853e564aa8 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -7598,8 +7598,7 @@ nsElementSH::PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx, NS_ENSURE_TRUE(xblService, NS_ERROR_NOT_AVAILABLE); nsRefPtr binding; - xblService->LoadBindings(element, uri, principal, false, - getter_AddRefs(binding), &dummy); + xblService->LoadBindings(element, uri, principal, getter_AddRefs(binding), &dummy); if (binding) { if (nsContentUtils::IsSafeToRunScript()) { diff --git a/dom/interfaces/xbl/nsIDOMDocumentXBL.idl b/dom/interfaces/xbl/nsIDOMDocumentXBL.idl index 0af449dfce2a..2cf7cf9967ce 100644 --- a/dom/interfaces/xbl/nsIDOMDocumentXBL.idl +++ b/dom/interfaces/xbl/nsIDOMDocumentXBL.idl @@ -5,7 +5,7 @@ #include "domstubs.idl" -[scriptable, uuid(1a38762b-4da5-4f61-80fb-9317e198cb92)] +[scriptable, uuid(af628000-e3fa-40d2-9118-fbaa9f3ec6b9)] interface nsIDOMDocumentXBL : nsISupports { /** @@ -16,11 +16,6 @@ interface nsIDOMDocumentXBL : nsISupports in DOMString attrName, in DOMString attrValue); - void addBinding(in nsIDOMElement elt, - in DOMString bindingURL); - void removeBinding(in nsIDOMElement elt, - in DOMString bindingURL); - nsIDOMElement getBindingParent(in nsIDOMNode node); void loadBindingDocument(in DOMString documentURL); }; diff --git a/dom/webidl/Document.webidl b/dom/webidl/Document.webidl index 37bc79670966..d9d75862e2fe 100644 --- a/dom/webidl/Document.webidl +++ b/dom/webidl/Document.webidl @@ -390,10 +390,6 @@ partial interface Document { NodeList? getAnonymousNodes(Element elt); Element? getAnonymousElementByAttribute(Element elt, DOMString attrName, DOMString attrValue); - [Throws] - void addBinding(Element elt, DOMString bindingURL); - [Throws] - void removeBinding(Element elt, DOMString bindingURL); Element? getBindingParent(Node node); [Throws] void loadBindingDocument(DOMString documentURL); diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index f4c709ddb714..d37cbd1b7b27 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -2355,8 +2355,7 @@ nsCSSFrameConstructor::ConstructDocElementFrame(Element* aDocEle nsRefPtr binding; rv = xblService->LoadBindings(aDocElement, display->mBinding->GetURI(), display->mBinding->mOriginPrincipal, - false, getter_AddRefs(binding), - &resolveStyle); + getter_AddRefs(binding), &resolveStyle); if (NS_FAILED(rv) && rv != NS_ERROR_XBL_BLOCKED) return NS_OK; // Binding will load asynchronously. @@ -5161,7 +5160,6 @@ nsCSSFrameConstructor::AddFrameConstructionItemsInternal(nsFrameConstructorState nsresult rv = xblService->LoadBindings(aContent, display->mBinding->GetURI(), display->mBinding->mOriginPrincipal, - false, getter_AddRefs(newPendingBinding->mBinding), &resolveStyle); if (NS_FAILED(rv) && rv != NS_ERROR_XBL_BLOCKED)