tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

txSingleNodeContext.h (1962B)


      1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* This Source Code Form is subject to the terms of the Mozilla Public
      3 * License, v. 2.0. If a copy of the MPL was not distributed with this
      4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      5 
      6 #ifndef __TX_XPATH_SINGLENODE_CONTEXT
      7 #define __TX_XPATH_SINGLENODE_CONTEXT
      8 
      9 #include "txIXPathContext.h"
     10 #include "txXPathNode.h"
     11 
     12 class txSingleNodeContext : public txIEvalContext {
     13 public:
     14  txSingleNodeContext(const txXPathNode& aContextNode,
     15                      txIMatchContext* aContext)
     16      : mNode(aContextNode), mInner(aContext) {
     17    NS_ASSERTION(aContext, "txIMatchContext must be given");
     18  }
     19 
     20  nsresult getVariable(int32_t aNamespace, nsAtom* aLName,
     21                       txAExprResult*& aResult) override {
     22    NS_ASSERTION(mInner, "mInner is null!!!");
     23    return mInner->getVariable(aNamespace, aLName, aResult);
     24  }
     25 
     26  nsresult isStripSpaceAllowed(const txXPathNode& aNode,
     27                               bool& aAllowed) override {
     28    NS_ASSERTION(mInner, "mInner is null!!!");
     29    return mInner->isStripSpaceAllowed(aNode, aAllowed);
     30  }
     31 
     32  void* getPrivateContext() override {
     33    NS_ASSERTION(mInner, "mInner is null!!!");
     34    return mInner->getPrivateContext();
     35  }
     36 
     37  txResultRecycler* recycler() override {
     38    NS_ASSERTION(mInner, "mInner is null!!!");
     39    return mInner->recycler();
     40  }
     41 
     42  void receiveError(const nsAString& aMsg, nsresult aRes) override {
     43    NS_ASSERTION(mInner, "mInner is null!!!");
     44 #ifdef DEBUG
     45    nsAutoString error(u"forwarded error: "_ns);
     46    error.Append(aMsg);
     47    mInner->receiveError(error, aRes);
     48 #else
     49    mInner->receiveError(aMsg, aRes);
     50 #endif
     51  }
     52 
     53  const txXPathNode& getContextNode() override { return mNode; }
     54 
     55  uint32_t size() override { return 1; }
     56 
     57  uint32_t position() override { return 1; }
     58 
     59 private:
     60  txXPathNode mNode;
     61  txIMatchContext* mInner;
     62 };
     63 
     64 #endif  // __TX_XPATH_SINGLENODE_CONTEXT