dom/xslt/xpath/txBooleanResult.cpp

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 /*
     7  * Boolean Expression result
     8 */
    10 #include "txExprResult.h"
    12 /**
    13  * Creates a new BooleanResult with the value of the given bool parameter
    14  * @param boolean the bool to use for initialization of this BooleanResult's value
    15 **/
    16 BooleanResult::BooleanResult(bool boolean)
    17     : txAExprResult(nullptr)
    18 {
    19     this->value = boolean;
    20 } //-- BooleanResult
    22 /*
    23  * Virtual Methods from ExprResult
    24 */
    26 short BooleanResult::getResultType() {
    27     return txAExprResult::BOOLEAN;
    28 } //-- getResultType
    30 void
    31 BooleanResult::stringValue(nsString& aResult)
    32 {
    33     if (value) {
    34         aResult.AppendLiteral("true");
    35     }
    36     else {
    37         aResult.AppendLiteral("false");
    38     }
    39 }
    41 const nsString*
    42 BooleanResult::stringValuePointer()
    43 {
    44     // In theory we could set strings containing "true" and "false" somewhere,
    45     // but most stylesheets never get the stringvalue of a bool so that won't
    46     // really buy us anything.
    47     return nullptr;
    48 }
    50 bool BooleanResult::booleanValue() {
    51    return this->value;
    52 } //-- toBoolean
    54 double BooleanResult::numberValue() {
    55     return ( value ) ? 1.0 : 0.0;
    56 } //-- toNumber

mercurial