| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2005 Frerich Raabe <raabe@kde.org> | 2 * Copyright 2005 Frerich Raabe <raabe@kde.org> |
| 3 * Copyright (C) 2006 Apple Computer, Inc. | 3 * Copyright (C) 2006 Apple Computer, Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 switch (m_type) { | 77 switch (m_type) { |
| 78 case NodeSetValue: | 78 case NodeSetValue: |
| 79 return !m_data->nodeSet().isEmpty(); | 79 return !m_data->nodeSet().isEmpty(); |
| 80 case BooleanValue: | 80 case BooleanValue: |
| 81 return m_bool; | 81 return m_bool; |
| 82 case NumberValue: | 82 case NumberValue: |
| 83 return m_number && !std::isnan(m_number); | 83 return m_number && !std::isnan(m_number); |
| 84 case StringValue: | 84 case StringValue: |
| 85 return !m_data->m_string.isEmpty(); | 85 return !m_data->m_string.isEmpty(); |
| 86 } | 86 } |
| 87 ASSERT_NOT_REACHED(); | 87 NOTREACHED(); |
| 88 return false; | 88 return false; |
| 89 } | 89 } |
| 90 | 90 |
| 91 double Value::toNumber() const | 91 double Value::toNumber() const |
| 92 { | 92 { |
| 93 switch (m_type) { | 93 switch (m_type) { |
| 94 case NodeSetValue: | 94 case NodeSetValue: |
| 95 return Value(toString()).toNumber(); | 95 return Value(toString()).toNumber(); |
| 96 case NumberValue: | 96 case NumberValue: |
| 97 return m_number; | 97 return m_number; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 109 | 109 |
| 110 bool canConvert; | 110 bool canConvert; |
| 111 double value = str.toDouble(&canConvert); | 111 double value = str.toDouble(&canConvert); |
| 112 if (canConvert) | 112 if (canConvert) |
| 113 return value; | 113 return value; |
| 114 return std::numeric_limits<double>::quiet_NaN(); | 114 return std::numeric_limits<double>::quiet_NaN(); |
| 115 } | 115 } |
| 116 case BooleanValue: | 116 case BooleanValue: |
| 117 return m_bool; | 117 return m_bool; |
| 118 } | 118 } |
| 119 ASSERT_NOT_REACHED(); | 119 NOTREACHED(); |
| 120 return 0.0; | 120 return 0.0; |
| 121 } | 121 } |
| 122 | 122 |
| 123 String Value::toString() const | 123 String Value::toString() const |
| 124 { | 124 { |
| 125 switch (m_type) { | 125 switch (m_type) { |
| 126 case NodeSetValue: | 126 case NodeSetValue: |
| 127 if (m_data->nodeSet().isEmpty()) | 127 if (m_data->nodeSet().isEmpty()) |
| 128 return ""; | 128 return ""; |
| 129 return stringValue(m_data->nodeSet().firstNode()); | 129 return stringValue(m_data->nodeSet().firstNode()); |
| 130 case StringValue: | 130 case StringValue: |
| 131 return m_data->m_string; | 131 return m_data->m_string; |
| 132 case NumberValue: | 132 case NumberValue: |
| 133 if (std::isnan(m_number)) | 133 if (std::isnan(m_number)) |
| 134 return "NaN"; | 134 return "NaN"; |
| 135 if (m_number == 0) | 135 if (m_number == 0) |
| 136 return "0"; | 136 return "0"; |
| 137 if (std::isinf(m_number)) | 137 if (std::isinf(m_number)) |
| 138 return std::signbit(m_number) ? "-Infinity" : "Infinity"; | 138 return std::signbit(m_number) ? "-Infinity" : "Infinity"; |
| 139 return String::number(m_number); | 139 return String::number(m_number); |
| 140 case BooleanValue: | 140 case BooleanValue: |
| 141 return m_bool ? "true" : "false"; | 141 return m_bool ? "true" : "false"; |
| 142 } | 142 } |
| 143 ASSERT_NOT_REACHED(); | 143 NOTREACHED(); |
| 144 return String(); | 144 return String(); |
| 145 } | 145 } |
| 146 | 146 |
| 147 } // namespace XPath | 147 } // namespace XPath |
| 148 } // namespace blink | 148 } // namespace blink |
| OLD | NEW |