dom/xslt/xpath/txSingleNodeContext.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     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/. */
     6 #ifndef __TX_XPATH_SINGLENODE_CONTEXT
     7 #define __TX_XPATH_SINGLENODE_CONTEXT
     9 #include "mozilla/Attributes.h"
    10 #include "txIXPathContext.h"
    12 class txSingleNodeContext : public txIEvalContext
    13 {
    14 public:
    15     txSingleNodeContext(const txXPathNode& aContextNode,
    16                         txIMatchContext* aContext)
    17         : mNode(aContextNode),
    18           mInner(aContext)
    19     {
    20         NS_ASSERTION(aContext, "txIMatchContext must be given");
    21     }
    23     nsresult getVariable(int32_t aNamespace, nsIAtom* aLName,
    24                          txAExprResult*& aResult) MOZ_OVERRIDE
    25     {
    26         NS_ASSERTION(mInner, "mInner is null!!!");
    27         return mInner->getVariable(aNamespace, aLName, aResult);
    28     }
    30     bool isStripSpaceAllowed(const txXPathNode& aNode) MOZ_OVERRIDE
    31     {
    32         NS_ASSERTION(mInner, "mInner is null!!!");
    33         return mInner->isStripSpaceAllowed(aNode);
    34     }
    36     void* getPrivateContext() MOZ_OVERRIDE
    37     {
    38         NS_ASSERTION(mInner, "mInner is null!!!");
    39         return mInner->getPrivateContext();
    40     }
    42     txResultRecycler* recycler() MOZ_OVERRIDE
    43     {
    44         NS_ASSERTION(mInner, "mInner is null!!!");
    45         return mInner->recycler();
    46     }
    48     void receiveError(const nsAString& aMsg, nsresult aRes) MOZ_OVERRIDE
    49     {
    50         NS_ASSERTION(mInner, "mInner is null!!!");
    51 #ifdef DEBUG
    52         nsAutoString error(NS_LITERAL_STRING("forwarded error: "));
    53         error.Append(aMsg);
    54         mInner->receiveError(error, aRes);
    55 #else
    56         mInner->receiveError(aMsg, aRes);
    57 #endif
    58     }
    60     const txXPathNode& getContextNode() MOZ_OVERRIDE
    61     {
    62         return mNode;
    63     }
    65     uint32_t size() MOZ_OVERRIDE
    66     {
    67         return 1;
    68     }
    70     uint32_t position() MOZ_OVERRIDE
    71     {
    72         return 1;
    73     }
    75 private:
    76     const txXPathNode& mNode;
    77     txIMatchContext* mInner;
    78 };
    80 #endif // __TX_XPATH_SINGLENODE_CONTEXT

mercurial