txBooleanResult.cpp (1350B)
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 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/. */ 5 6 /* 7 * Boolean Expression result 8 */ 9 10 #include "txExprResult.h" 11 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 15 * value 16 **/ 17 BooleanResult::BooleanResult(bool boolean) : txAExprResult(nullptr) { 18 this->value = boolean; 19 } //-- BooleanResult 20 21 /* 22 * Virtual Methods from ExprResult 23 */ 24 25 short BooleanResult::getResultType() { 26 return txAExprResult::BOOLEAN; 27 } //-- getResultType 28 29 void BooleanResult::stringValue(nsString& aResult) { 30 if (value) { 31 aResult.AppendLiteral("true"); 32 } else { 33 aResult.AppendLiteral("false"); 34 } 35 } 36 37 const nsString* BooleanResult::stringValuePointer() { 38 // In theory we could set strings containing "true" and "false" somewhere, 39 // but most stylesheets never get the stringvalue of a bool so that won't 40 // really buy us anything. 41 return nullptr; 42 } 43 44 bool BooleanResult::booleanValue() { return this->value; } //-- toBoolean 45 46 double BooleanResult::numberValue() { 47 return (value) ? 1.0 : 0.0; 48 } //-- toNumber