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