Bug 1076836 - Stop storing a principal in txMozillaXSLTProcessor. r=bz.

--HG--
extra : rebase_source : 2132e67ad948a5068976b0a5ec513b623b08a4cd
This commit is contained in:
Peter Van der Beken 2014-10-03 12:23:10 +02:00
Родитель d6257e640f
Коммит 9611aafacf
5 изменённых файлов: 14 добавлений и 43 удалений

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

@ -663,7 +663,6 @@ nsXMLContentSink::LoadXSLStyleSheet(nsIURI* aUrl)
return NS_OK;
}
processor->Init(mDocument->NodePrincipal());
processor->SetTransformObserver(this);
nsCOMPtr<nsILoadGroup> 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);
}

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

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

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

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

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

@ -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<txIGlobalParameter>::iterator iter(tmp->mVariables);
while (iter.next()) {
cb.NoteXPCOMChild(static_cast<txVariable*>(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()

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

@ -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<nsIPrincipal> mPrincipal;
nsCOMPtr<nsITransformObserver> mObserver;
txOwningExpandedNameMap<txIGlobalParameter> 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