| Index: Source/core/xml/XPathValue.cpp
|
| diff --git a/Source/core/xml/XPathValue.cpp b/Source/core/xml/XPathValue.cpp
|
| index bcd39b9c43d75f876fca53325a8c6e8a98e933f9..751323ef511611f55365477f20127fbb8a28e8f8 100644
|
| --- a/Source/core/xml/XPathValue.cpp
|
| +++ b/Source/core/xml/XPathValue.cpp
|
| @@ -27,18 +27,16 @@
|
| #include "config.h"
|
| #include "core/xml/XPathValue.h"
|
|
|
| -#include <limits>
|
| #include "core/xml/XPathExpressionNode.h"
|
| #include "core/xml/XPathUtil.h"
|
| #include "wtf/MathExtras.h"
|
| #include "wtf/StdLibExtras.h"
|
| -
|
| -using std::numeric_limits;
|
| +#include <limits>
|
|
|
| namespace WebCore {
|
| namespace XPath {
|
|
|
| -const Value::AdoptTag Value::adopt = {};
|
| +const Value::AdoptTag Value::adopt = { };
|
|
|
| void ValueData::trace(Visitor* visitor)
|
| {
|
| @@ -78,14 +76,14 @@ NodeSet& Value::modifiableNodeSet()
|
| bool Value::toBoolean() const
|
| {
|
| switch (m_type) {
|
| - case NodeSetValue:
|
| - return !m_data->nodeSet().isEmpty();
|
| - case BooleanValue:
|
| - return m_bool;
|
| - case NumberValue:
|
| - return m_number && !std::isnan(m_number);
|
| - case StringValue:
|
| - return !m_data->m_string.isEmpty();
|
| + case NodeSetValue:
|
| + return !m_data->nodeSet().isEmpty();
|
| + case BooleanValue:
|
| + return m_bool;
|
| + case NumberValue:
|
| + return m_number && !std::isnan(m_number);
|
| + case StringValue:
|
| + return !m_data->m_string.isEmpty();
|
| }
|
| ASSERT_NOT_REACHED();
|
| return false;
|
| @@ -94,29 +92,30 @@ bool Value::toBoolean() const
|
| double Value::toNumber() const
|
| {
|
| switch (m_type) {
|
| - case NodeSetValue:
|
| - return Value(toString()).toNumber();
|
| - case NumberValue:
|
| - return m_number;
|
| - case StringValue: {
|
| - const String& str = m_data->m_string.simplifyWhiteSpace();
|
| -
|
| - // String::toDouble() supports exponential notation, which is not allowed in XPath.
|
| - unsigned len = str.length();
|
| - for (unsigned i = 0; i < len; ++i) {
|
| - UChar c = str[i];
|
| - if (!isASCIIDigit(c) && c != '.' && c != '-')
|
| - return numeric_limits<double>::quiet_NaN();
|
| - }
|
| -
|
| - bool canConvert;
|
| - double value = str.toDouble(&canConvert);
|
| - if (canConvert)
|
| - return value;
|
| - return numeric_limits<double>::quiet_NaN();
|
| + case NodeSetValue:
|
| + return Value(toString()).toNumber();
|
| + case NumberValue:
|
| + return m_number;
|
| + case StringValue: {
|
| + const String& str = m_data->m_string.simplifyWhiteSpace();
|
| +
|
| + // String::toDouble() supports exponential notation, which is not
|
| + // allowed in XPath.
|
| + unsigned len = str.length();
|
| + for (unsigned i = 0; i < len; ++i) {
|
| + UChar c = str[i];
|
| + if (!isASCIIDigit(c) && c != '.' && c != '-')
|
| + return std::numeric_limits<double>::quiet_NaN();
|
| }
|
| - case BooleanValue:
|
| - return m_bool;
|
| +
|
| + bool canConvert;
|
| + double value = str.toDouble(&canConvert);
|
| + if (canConvert)
|
| + return value;
|
| + return std::numeric_limits<double>::quiet_NaN();
|
| + }
|
| + case BooleanValue:
|
| + return m_bool;
|
| }
|
| ASSERT_NOT_REACHED();
|
| return 0.0;
|
| @@ -125,22 +124,22 @@ double Value::toNumber() const
|
| String Value::toString() const
|
| {
|
| switch (m_type) {
|
| - case NodeSetValue:
|
| - if (m_data->nodeSet().isEmpty())
|
| - return "";
|
| - return stringValue(m_data->nodeSet().firstNode());
|
| - case StringValue:
|
| - return m_data->m_string;
|
| - case NumberValue:
|
| - if (std::isnan(m_number))
|
| - return "NaN";
|
| - if (m_number == 0)
|
| - return "0";
|
| - if (std::isinf(m_number))
|
| - return std::signbit(m_number) ? "-Infinity" : "Infinity";
|
| - return String::number(m_number);
|
| - case BooleanValue:
|
| - return m_bool ? "true" : "false";
|
| + case NodeSetValue:
|
| + if (m_data->nodeSet().isEmpty())
|
| + return "";
|
| + return stringValue(m_data->nodeSet().firstNode());
|
| + case StringValue:
|
| + return m_data->m_string;
|
| + case NumberValue:
|
| + if (std::isnan(m_number))
|
| + return "NaN";
|
| + if (m_number == 0)
|
| + return "0";
|
| + if (std::isinf(m_number))
|
| + return std::signbit(m_number) ? "-Infinity" : "Infinity";
|
| + return String::number(m_number);
|
| + case BooleanValue:
|
| + return m_bool ? "true" : "false";
|
| }
|
| ASSERT_NOT_REACHED();
|
| return String();
|
|
|