[tbb-commits] [tor-browser] 64/67: Bug 1758062 - Convert parameters upfront. r=smaug, a=tritter

gitolite role git at cupani.torproject.org
Wed May 4 20:45:22 UTC 2022


This is an automated email from the git hooks/post-receive script.

richard pushed a commit to branch geckoview-96.0.3-11.0-1
in repository tor-browser.

commit 589b4d5098addf7ab80c4b1efcfeb73ffbd7ebeb
Author: Peter Van der Beken <peterv at propagandism.org>
AuthorDate: Fri Mar 4 14:00:25 2022 +0000

    Bug 1758062 - Convert parameters upfront. r=smaug, a=tritter
    
    Differential Revision: https://phabricator.services.mozilla.com/D140337
---
 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 c50a66a402014..a982bd118118a 100644
--- a/dom/xslt/xslt/txMozillaXSLTProcessor.cpp
+++ b/dom/xslt/xslt/txMozillaXSLTProcessor.cpp
@@ -198,19 +198,15 @@ nsresult txToFragmentHandlerFactory::createHandlerWith(
 
 class txVariable : public txIGlobalParameter {
  public:
-  explicit txVariable(nsIVariant* aValue) : mValue(aValue) {
-    NS_ASSERTION(aValue, "missing value");
+  explicit txVariable(nsIVariant* aValue, txAExprResult* aTxValue)
+      : mValue(aValue), mTxValue(aTxValue) {
+    NS_ASSERTION(aValue && aTxValue, "missing value");
   }
   explicit txVariable(txAExprResult* aValue) : mTxValue(aValue) {
     NS_ASSERTION(aValue, "missing value");
   }
   nsresult getValue(txAExprResult** aValue) override {
-    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);
@@ -223,10 +219,10 @@ class txVariable : public txIGlobalParameter {
     return NS_OK;
   }
   nsIVariant* getValue() { return mValue; }
-  void setValue(nsIVariant* aValue) {
-    NS_ASSERTION(aValue, "setting variablevalue to null");
+  void setValue(nsIVariant* aValue, txAExprResult* aTxValue) {
+    NS_ASSERTION(aValue && aTxValue, "setting variablevalue to null");
     mValue = aValue;
-    mTxValue = nullptr;
+    mTxValue = aTxValue;
   }
   void setValue(txAExprResult* aValue) {
     NS_ASSERTION(aValue, "setting variablevalue to null");
@@ -234,14 +230,14 @@ class txVariable : public txIGlobalParameter {
     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<nsIVariant> mValue;
   RefPtr<txAExprResult> mTxValue;
 };
@@ -816,13 +812,17 @@ nsresult txMozillaXSLTProcessor::SetParameter(const nsAString& aNamespaceURI,
   RefPtr<nsAtom> localName = NS_Atomize(aLocalName);
   txExpandedName varName(nsId, localName);
 
+  RefPtr<txAExprResult> txValue;
+  rv = txVariable::Convert(value, getter_AddRefs(txValue));
+  NS_ENSURE_SUCCESS(rv, rv);
+
   txVariable* var = static_cast<txVariable*>(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);
 }
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the tbb-commits mailing list