Line data Source code
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/. */
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 value
15 : **/
16 0 : BooleanResult::BooleanResult(bool boolean)
17 0 : : txAExprResult(nullptr)
18 : {
19 0 : this->value = boolean;
20 0 : } //-- BooleanResult
21 :
22 : /*
23 : * Virtual Methods from ExprResult
24 : */
25 :
26 0 : short BooleanResult::getResultType() {
27 0 : return txAExprResult::BOOLEAN;
28 : } //-- getResultType
29 :
30 : void
31 0 : BooleanResult::stringValue(nsString& aResult)
32 : {
33 0 : if (value) {
34 0 : aResult.AppendLiteral("true");
35 : }
36 : else {
37 0 : aResult.AppendLiteral("false");
38 : }
39 0 : }
40 :
41 : const nsString*
42 0 : 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 0 : return nullptr;
48 : }
49 :
50 0 : bool BooleanResult::booleanValue() {
51 0 : return this->value;
52 : } //-- toBoolean
53 :
54 0 : double BooleanResult::numberValue() {
55 0 : return ( value ) ? 1.0 : 0.0;
56 : } //-- toNumber
|