From 7cd8d7967022af0f0c85eefce0300e7b9cdf9ed0 Mon Sep 17 00:00:00 2001 From: Peter Van der Beken Date: Wed, 9 Mar 2022 00:23:13 +0000 Subject: [PATCH] [DOM] Convert parameters upfront. --- dom/xslt/xslt/txMozillaXSLTProcessor.cpp | 30 ++++++++++++------------ 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/dom/xslt/xslt/txMozillaXSLTProcessor.cpp b/dom/xslt/xslt/txMozillaXSLTProcessor.cpp index 6aec6052f4..59cd09bd6a 100644 --- a/dom/xslt/xslt/txMozillaXSLTProcessor.cpp +++ b/dom/xslt/xslt/txMozillaXSLTProcessor.cpp @@ -239,9 +239,10 @@ txToFragmentHandlerFactory::createHandlerWith(txOutputFormat* aFormat, class txVariable : public txIGlobalParameter { public: - explicit txVariable(nsIVariant* aValue) : mValue(aValue) + explicit txVariable(nsIVariant* aValue, txAExprResult* aTxValue) + : mValue(aValue) { - NS_ASSERTION(aValue, "missing value"); + NS_ASSERTION(aValue && aTxValue, "missing value"); } explicit txVariable(txAExprResult* aValue) : mTxValue(aValue) { @@ -249,12 +250,7 @@ public: } nsresult getValue(txAExprResult** aValue) { - NS_ASSERTION(mValue || mTxValue, "variablevalue is null"); - - if (!mTxValue) { - nsresult rv = Convert(mValue, getter_AddRefs(mTxValue)); - NS_ENSURE_SUCCESS(rv, rv); - } + NS_ASSERTION(mTxValue, "variablevalue is null"); *aValue = mTxValue; NS_ADDREF(*aValue); @@ -271,11 +267,11 @@ public: { return mValue; } - void setValue(nsIVariant* aValue) + void setValue(nsIVariant* aValue, txAExprResult* aTxValue) { - NS_ASSERTION(aValue, "setting variablevalue to null"); + NS_ASSERTION(aValue && aTxValue, "setting variablevalue to null"); mValue = aValue; - mTxValue = nullptr; + mTxValue = aTxValue; } void setValue(txAExprResult* aValue) { @@ -284,14 +280,14 @@ public: mTxValue = aValue; } + static nsresult Convert(nsIVariant *aValue, txAExprResult** aResult); + friend void ImplCycleCollectionUnlink(txVariable& aVariable); friend void ImplCycleCollectionTraverse( nsCycleCollectionTraversalCallback& aCallback, txVariable& aVariable, const char* aName, uint32_t aFlags); private: - static nsresult Convert(nsIVariant *aValue, txAExprResult** aResult); - nsCOMPtr mValue; RefPtr mTxValue; }; @@ -948,13 +944,17 @@ txMozillaXSLTProcessor::SetParameter(const nsAString & aNamespaceURI, nsCOMPtr localName = NS_Atomize(aLocalName); txExpandedName varName(nsId, localName); + RefPtr txValue; + rv = txVariable::Convert(value, getter_AddRefs(txValue)); + NS_ENSURE_SUCCESS(rv, rv); + txVariable* var = static_cast(mVariables.get(varName)); if (var) { - var->setValue(value); + var->setValue(value, txValue); return NS_OK; } - var = new txVariable(value); + var = new txVariable(value, txValue); return mVariables.add(varName, var); }