michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* michael@0: * Boolean Expression result michael@0: */ michael@0: michael@0: #include "txExprResult.h" michael@0: michael@0: /** michael@0: * Creates a new BooleanResult with the value of the given bool parameter michael@0: * @param boolean the bool to use for initialization of this BooleanResult's value michael@0: **/ michael@0: BooleanResult::BooleanResult(bool boolean) michael@0: : txAExprResult(nullptr) michael@0: { michael@0: this->value = boolean; michael@0: } //-- BooleanResult michael@0: michael@0: /* michael@0: * Virtual Methods from ExprResult michael@0: */ michael@0: michael@0: short BooleanResult::getResultType() { michael@0: return txAExprResult::BOOLEAN; michael@0: } //-- getResultType michael@0: michael@0: void michael@0: BooleanResult::stringValue(nsString& aResult) michael@0: { michael@0: if (value) { michael@0: aResult.AppendLiteral("true"); michael@0: } michael@0: else { michael@0: aResult.AppendLiteral("false"); michael@0: } michael@0: } michael@0: michael@0: const nsString* michael@0: BooleanResult::stringValuePointer() michael@0: { michael@0: // In theory we could set strings containing "true" and "false" somewhere, michael@0: // but most stylesheets never get the stringvalue of a bool so that won't michael@0: // really buy us anything. michael@0: return nullptr; michael@0: } michael@0: michael@0: bool BooleanResult::booleanValue() { michael@0: return this->value; michael@0: } //-- toBoolean michael@0: michael@0: double BooleanResult::numberValue() { michael@0: return ( value ) ? 1.0 : 0.0; michael@0: } //-- toNumber