dom/xslt/xpath/txBooleanResult.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial