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.

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

mercurial