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.
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 #include "txExpr.h"
7 #include "txExprResult.h"
8 #include "txSingleNodeContext.h"
10 txPredicatedNodeTest::txPredicatedNodeTest(txNodeTest* aNodeTest,
11 Expr* aPredicate)
12 : mNodeTest(aNodeTest),
13 mPredicate(aPredicate)
14 {
15 NS_ASSERTION(!mPredicate->isSensitiveTo(Expr::NODESET_CONTEXT),
16 "predicate must not be context-nodeset-sensitive");
17 }
19 bool
20 txPredicatedNodeTest::matches(const txXPathNode& aNode,
21 txIMatchContext* aContext)
22 {
23 if (!mNodeTest->matches(aNode, aContext)) {
24 return false;
25 }
27 txSingleNodeContext context(aNode, aContext);
28 nsRefPtr<txAExprResult> res;
29 nsresult rv = mPredicate->evaluate(&context, getter_AddRefs(res));
30 NS_ENSURE_SUCCESS(rv, false);
32 return res->booleanValue();
33 }
35 double
36 txPredicatedNodeTest::getDefaultPriority()
37 {
38 return 0.5;
39 }
41 bool
42 txPredicatedNodeTest::isSensitiveTo(Expr::ContextSensitivity aContext)
43 {
44 return mNodeTest->isSensitiveTo(aContext) ||
45 mPredicate->isSensitiveTo(aContext);
46 }
48 #ifdef TX_TO_STRING
49 void
50 txPredicatedNodeTest::toString(nsAString& aDest)
51 {
52 mNodeTest->toString(aDest);
53 aDest.Append(char16_t('['));
54 mPredicate->toString(aDest);
55 aDest.Append(char16_t(']'));
56 }
57 #endif