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