Tue, 06 Jan 2015 21:39:09 +0100
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 | #include "txExpr.h" |
michael@0 | 7 | #include "nsIAtom.h" |
michael@0 | 8 | #include "txNodeSet.h" |
michael@0 | 9 | #include "nsGkAtoms.h" |
michael@0 | 10 | #include "txIXPathContext.h" |
michael@0 | 11 | |
michael@0 | 12 | //-------------------/ |
michael@0 | 13 | //- VariableRefExpr -/ |
michael@0 | 14 | //-------------------/ |
michael@0 | 15 | |
michael@0 | 16 | /** |
michael@0 | 17 | * Creates a VariableRefExpr with the given variable name |
michael@0 | 18 | **/ |
michael@0 | 19 | VariableRefExpr::VariableRefExpr(nsIAtom* aPrefix, nsIAtom* aLocalName, |
michael@0 | 20 | int32_t aNSID) |
michael@0 | 21 | : mPrefix(aPrefix), mLocalName(aLocalName), mNamespace(aNSID) |
michael@0 | 22 | { |
michael@0 | 23 | NS_ASSERTION(mLocalName, "VariableRefExpr without local name?"); |
michael@0 | 24 | if (mPrefix == nsGkAtoms::_empty) |
michael@0 | 25 | mPrefix = 0; |
michael@0 | 26 | } |
michael@0 | 27 | |
michael@0 | 28 | /** |
michael@0 | 29 | * Evaluates this Expr based on the given context node and processor state |
michael@0 | 30 | * @param context the context node for evaluation of this Expr |
michael@0 | 31 | * @param ps the ContextState containing the stack information needed |
michael@0 | 32 | * for evaluation |
michael@0 | 33 | * @return the result of the evaluation |
michael@0 | 34 | **/ |
michael@0 | 35 | nsresult |
michael@0 | 36 | VariableRefExpr::evaluate(txIEvalContext* aContext, txAExprResult** aResult) |
michael@0 | 37 | { |
michael@0 | 38 | nsresult rv = aContext->getVariable(mNamespace, mLocalName, *aResult); |
michael@0 | 39 | if (NS_FAILED(rv)) { |
michael@0 | 40 | // XXX report error, undefined variable |
michael@0 | 41 | return rv; |
michael@0 | 42 | } |
michael@0 | 43 | return NS_OK; |
michael@0 | 44 | } |
michael@0 | 45 | |
michael@0 | 46 | TX_IMPL_EXPR_STUBS_0(VariableRefExpr, ANY_RESULT) |
michael@0 | 47 | |
michael@0 | 48 | bool |
michael@0 | 49 | VariableRefExpr::isSensitiveTo(ContextSensitivity aContext) |
michael@0 | 50 | { |
michael@0 | 51 | return !!(aContext & VARIABLES_CONTEXT); |
michael@0 | 52 | } |
michael@0 | 53 | |
michael@0 | 54 | #ifdef TX_TO_STRING |
michael@0 | 55 | void |
michael@0 | 56 | VariableRefExpr::toString(nsAString& aDest) |
michael@0 | 57 | { |
michael@0 | 58 | aDest.Append(char16_t('$')); |
michael@0 | 59 | if (mPrefix) { |
michael@0 | 60 | nsAutoString prefix; |
michael@0 | 61 | mPrefix->ToString(prefix); |
michael@0 | 62 | aDest.Append(prefix); |
michael@0 | 63 | aDest.Append(char16_t(':')); |
michael@0 | 64 | } |
michael@0 | 65 | nsAutoString lname; |
michael@0 | 66 | mLocalName->ToString(lname); |
michael@0 | 67 | aDest.Append(lname); |
michael@0 | 68 | } |
michael@0 | 69 | #endif |