From 9611aafacf3633981a8097f18b2a7a97909bc18f Mon Sep 17 00:00:00 2001 From: Peter Van der Beken Date: Fri, 3 Oct 2014 12:23:10 +0200 Subject: [PATCH] Bug 1076836 - Stop storing a principal in txMozillaXSLTProcessor. r=bz. --HG-- extra : rebase_source : 2132e67ad948a5068976b0a5ec513b623b08a4cd --- dom/xml/nsXMLContentSink.cpp | 4 +-- dom/xslt/nsIDocumentTransformer.h | 8 ++--- dom/xslt/xslt/txMozillaStylesheetCompiler.cpp | 1 - dom/xslt/xslt/txMozillaXSLTProcessor.cpp | 30 ++++--------------- dom/xslt/xslt/txMozillaXSLTProcessor.h | 14 ++------- 5 files changed, 14 insertions(+), 43 deletions(-) diff --git a/dom/xml/nsXMLContentSink.cpp b/dom/xml/nsXMLContentSink.cpp index 8d1d62511eb3..0dcab2088646 100644 --- a/dom/xml/nsXMLContentSink.cpp +++ b/dom/xml/nsXMLContentSink.cpp @@ -663,7 +663,6 @@ nsXMLContentSink::LoadXSLStyleSheet(nsIURI* aUrl) return NS_OK; } - processor->Init(mDocument->NodePrincipal()); processor->SetTransformObserver(this); nsCOMPtr loadGroup = mDocument->GetDocumentLoadGroup(); @@ -671,7 +670,8 @@ nsXMLContentSink::LoadXSLStyleSheet(nsIURI* aUrl) return NS_ERROR_FAILURE; } - if (NS_SUCCEEDED(processor->LoadStyleSheet(aUrl, loadGroup))) { + if (NS_SUCCEEDED(processor->LoadStyleSheet(aUrl, loadGroup, + mDocument->NodePrincipal()))) { mXSLTProcessor.swap(processor); } diff --git a/dom/xslt/nsIDocumentTransformer.h b/dom/xslt/nsIDocumentTransformer.h index 0ee5e5be340b..c5c5dea707b6 100644 --- a/dom/xslt/nsIDocumentTransformer.h +++ b/dom/xslt/nsIDocumentTransformer.h @@ -33,8 +33,8 @@ public: NS_DEFINE_STATIC_IID_ACCESSOR(nsITransformObserver, NS_ITRANSFORMOBSERVER_IID) #define NS_IDOCUMENTTRANSFORMER_IID \ - {0x17c83d91, 0xac2f, 0x4658, \ - { 0x91, 0x6c, 0xcb, 0xc4, 0xd2, 0xb5, 0x2c, 0xe }} +{ 0xc75613ee, 0xcb6e, 0x4bf7, \ + { 0x9e, 0x5b, 0x36, 0x50, 0x69, 0xc1, 0xe3, 0x55 } } class nsIDocumentTransformer : public nsISupports { @@ -42,9 +42,9 @@ public: NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOCUMENTTRANSFORMER_IID) - NS_IMETHOD Init(nsIPrincipal* aPrincipal) = 0; NS_IMETHOD SetTransformObserver(nsITransformObserver* aObserver) = 0; - NS_IMETHOD LoadStyleSheet(nsIURI* aUri, nsILoadGroup* aLoadGroup) = 0; + NS_IMETHOD LoadStyleSheet(nsIURI* aUri, nsILoadGroup* aLoadGroup, + nsIPrincipal* aPrincipal) = 0; NS_IMETHOD SetSourceContentModel(nsIDOMNode* aSource) = 0; NS_IMETHOD CancelLoads() = 0; diff --git a/dom/xslt/xslt/txMozillaStylesheetCompiler.cpp b/dom/xslt/xslt/txMozillaStylesheetCompiler.cpp index eba3683645c6..0747cb89a139 100644 --- a/dom/xslt/xslt/txMozillaStylesheetCompiler.cpp +++ b/dom/xslt/xslt/txMozillaStylesheetCompiler.cpp @@ -700,7 +700,6 @@ void txSyncCompileObserver::onDoneCompiling(txStylesheetCompiler* aCompiler, nsresult TX_CompileStylesheet(nsINode* aNode, txMozillaXSLTProcessor* aProcessor, - nsIPrincipal* aCallerPrincipal, txStylesheet** aStylesheet) { // If we move GetBaseURI to nsINode this can be simplified. diff --git a/dom/xslt/xslt/txMozillaXSLTProcessor.cpp b/dom/xslt/xslt/txMozillaXSLTProcessor.cpp index 379140508531..070892f33339 100644 --- a/dom/xslt/xslt/txMozillaXSLTProcessor.cpp +++ b/dom/xslt/xslt/txMozillaXSLTProcessor.cpp @@ -297,13 +297,11 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(txMozillaXSLTProcessor) NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(txMozillaXSLTProcessor) NS_IMPL_CYCLE_COLLECTION_UNLINK(mEmbeddedStylesheetRoot) NS_IMPL_CYCLE_COLLECTION_UNLINK(mSource) - NS_IMPL_CYCLE_COLLECTION_UNLINK(mPrincipal) tmp->mVariables.clear(); NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(txMozillaXSLTProcessor) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mEmbeddedStylesheetRoot) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSource) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPrincipal) txOwningExpandedNameMap::iterator iter(tmp->mVariables); while (iter.next()) { cb.NoteXPCOMChild(static_cast(iter.value())->getValue()); @@ -320,7 +318,6 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(txMozillaXSLTProcessor) NS_INTERFACE_MAP_ENTRY(nsIXSLTProcessorPrivate) NS_INTERFACE_MAP_ENTRY(nsIDocumentTransformer) NS_INTERFACE_MAP_ENTRY(nsIMutationObserver) - NS_INTERFACE_MAP_ENTRY(nsIJSNativeInitializer) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIXSLTProcessor) NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(XSLTProcessor) NS_INTERFACE_MAP_END @@ -580,7 +577,7 @@ txMozillaXSLTProcessor::ImportStylesheet(nsIDOMNode *aStyle) styleNode->IsNodeOfType(nsINode::eDOCUMENT)), NS_ERROR_INVALID_ARG); - nsresult rv = TX_CompileStylesheet(styleNode, this, mPrincipal, + nsresult rv = TX_CompileStylesheet(styleNode, this, getter_AddRefs(mStylesheet)); // XXX set up exception context, bug 204658 NS_ENSURE_SUCCESS(rv, rv); @@ -1008,9 +1005,10 @@ txMozillaXSLTProcessor::GetFlags(uint32_t* aFlags) } NS_IMETHODIMP -txMozillaXSLTProcessor::LoadStyleSheet(nsIURI* aUri, nsILoadGroup* aLoadGroup) +txMozillaXSLTProcessor::LoadStyleSheet(nsIURI* aUri, nsILoadGroup* aLoadGroup, + nsIPrincipal* aPrincipal) { - nsresult rv = TX_LoadSheet(aUri, this, aLoadGroup, mPrincipal); + nsresult rv = TX_LoadSheet(aUri, this, aLoadGroup, aPrincipal); if (NS_FAILED(rv) && mObserver) { // This is most likely a network or security error, just // use the uri as context. @@ -1181,8 +1179,7 @@ txMozillaXSLTProcessor::ensureStylesheet() style = mStylesheetDocument; } - return TX_CompileStylesheet(style, this, mPrincipal, - getter_AddRefs(mStylesheet)); + return TX_CompileStylesheet(style, this, getter_AddRefs(mStylesheet)); } void @@ -1244,23 +1241,6 @@ txMozillaXSLTProcessor::ContentRemoved(nsIDocument* aDocument, mStylesheet = nullptr; } -NS_IMETHODIMP -txMozillaXSLTProcessor::Initialize(nsISupports* aOwner, JSContext* cx, - JSObject* obj, const JS::CallArgs& args) -{ - MOZ_ASSERT(nsContentUtils::GetCurrentJSContext()); - return Init(nsContentUtils::SubjectPrincipal()); -} - -NS_IMETHODIMP -txMozillaXSLTProcessor::Init(nsIPrincipal* aPrincipal) -{ - NS_ENSURE_ARG_POINTER(aPrincipal); - mPrincipal = aPrincipal; - - return NS_OK; -} - /* static*/ nsresult txMozillaXSLTProcessor::Startup() diff --git a/dom/xslt/xslt/txMozillaXSLTProcessor.h b/dom/xslt/xslt/txMozillaXSLTProcessor.h index 4982237007fb..d6385d02061e 100644 --- a/dom/xslt/xslt/txMozillaXSLTProcessor.h +++ b/dom/xslt/xslt/txMozillaXSLTProcessor.h @@ -13,7 +13,6 @@ #include "nsIXSLTProcessorPrivate.h" #include "txExpandedNameMap.h" #include "txNamespaceMap.h" -#include "nsIJSNativeInitializer.h" #include "nsCycleCollectionParticipant.h" #include "mozilla/Attributes.h" @@ -40,8 +39,7 @@ class txIGlobalParameter; class txMozillaXSLTProcessor MOZ_FINAL : public nsIXSLTProcessor, public nsIXSLTProcessorPrivate, public nsIDocumentTransformer, - public nsStubMutationObserver, - public nsIJSNativeInitializer + public nsStubMutationObserver { public: /** @@ -61,9 +59,9 @@ public: NS_DECL_NSIXSLTPROCESSORPRIVATE // nsIDocumentTransformer interface - NS_IMETHOD Init(nsIPrincipal* aPrincipal) MOZ_OVERRIDE; NS_IMETHOD SetTransformObserver(nsITransformObserver* aObserver) MOZ_OVERRIDE; - NS_IMETHOD LoadStyleSheet(nsIURI* aUri, nsILoadGroup* aLoadGroup) MOZ_OVERRIDE; + NS_IMETHOD LoadStyleSheet(nsIURI* aUri, nsILoadGroup* aLoadGroup, + nsIPrincipal* aPrincipal); NS_IMETHOD SetSourceContentModel(nsIDOMNode* aSource) MOZ_OVERRIDE; NS_IMETHOD CancelLoads() MOZ_OVERRIDE {return NS_OK;} NS_IMETHOD AddXSLTParamNamespace(const nsString& aPrefix, @@ -99,10 +97,6 @@ public: return (mFlags & DISABLE_ALL_LOADS) != 0; } - // nsIJSNativeInitializer - NS_IMETHODIMP Initialize(nsISupports* aOwner, JSContext *cx, JSObject *obj, - const JS::CallArgs& aArgs); - static nsresult Startup(); static void Shutdown(); @@ -124,7 +118,6 @@ private: nsresult mTransformResult; nsresult mCompileResult; nsString mErrorText, mSourceText; - nsCOMPtr mPrincipal; nsCOMPtr mObserver; txOwningExpandedNameMap mVariables; txNamespaceMap mParamNamespaceMap; @@ -139,7 +132,6 @@ extern nsresult TX_LoadSheet(nsIURI* aUri, txMozillaXSLTProcessor* aProcessor, extern nsresult TX_CompileStylesheet(nsINode* aNode, txMozillaXSLTProcessor* aProcessor, - nsIPrincipal* aCallerPrincipal, txStylesheet** aStylesheet); #endif