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 /**
7 * NumberResult
8 * Represents the a number as the result of evaluating an Expr
9 **/
11 #include "mozilla/FloatingPoint.h"
13 #include "txExprResult.h"
15 /**
16 * Default Constructor
17 **/
19 /**
20 * Creates a new NumberResult with the value of the given double parameter
21 * @param dbl the double to use for initialization of this NumberResult's value
22 **/
23 NumberResult::NumberResult(double aValue, txResultRecycler* aRecycler)
24 : txAExprResult(aRecycler), value(aValue)
25 {
26 } //-- NumberResult
28 /*
29 * Virtual Methods from ExprResult
30 */
32 short NumberResult::getResultType() {
33 return txAExprResult::NUMBER;
34 } //-- getResultType
36 void
37 NumberResult::stringValue(nsString& aResult)
38 {
39 txDouble::toString(value, aResult);
40 }
42 const nsString*
43 NumberResult::stringValuePointer()
44 {
45 return nullptr;
46 }
48 bool NumberResult::booleanValue() {
49 // OG+
50 // As per the XPath spec, the boolean value of a number is true if and only if
51 // it is neither positive 0 nor negative 0 nor NaN
52 return (bool)(value != 0.0 && !mozilla::IsNaN(value));
53 // OG-
54 } //-- booleanValue
56 double NumberResult::numberValue() {
57 return this->value;
58 } //-- numberValue