Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(737)

Side by Side Diff: Source/core/xml/XPathValue.cpp

Issue 344553002: Fix style erros in XPath-related files. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/xml/XPathValue.h ('k') | Source/core/xml/XPathVariableReference.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */ 25 */
26 26
27 #include "config.h" 27 #include "config.h"
28 #include "core/xml/XPathValue.h" 28 #include "core/xml/XPathValue.h"
29 29
30 #include <limits>
31 #include "core/xml/XPathExpressionNode.h" 30 #include "core/xml/XPathExpressionNode.h"
32 #include "core/xml/XPathUtil.h" 31 #include "core/xml/XPathUtil.h"
33 #include "wtf/MathExtras.h" 32 #include "wtf/MathExtras.h"
34 #include "wtf/StdLibExtras.h" 33 #include "wtf/StdLibExtras.h"
35 34 #include <limits>
36 using std::numeric_limits;
37 35
38 namespace WebCore { 36 namespace WebCore {
39 namespace XPath { 37 namespace XPath {
40 38
41 const Value::AdoptTag Value::adopt = {}; 39 const Value::AdoptTag Value::adopt = { };
42 40
43 void ValueData::trace(Visitor* visitor) 41 void ValueData::trace(Visitor* visitor)
44 { 42 {
45 visitor->trace(m_nodeSet); 43 visitor->trace(m_nodeSet);
46 } 44 }
47 45
48 void Value::trace(Visitor* visitor) 46 void Value::trace(Visitor* visitor)
49 { 47 {
50 visitor->trace(m_data); 48 visitor->trace(m_data);
51 } 49 }
(...skipping 19 matching lines...) Expand all
71 if (!m_data) 69 if (!m_data)
72 m_data = ValueData::create(); 70 m_data = ValueData::create();
73 71
74 m_type = NodeSetValue; 72 m_type = NodeSetValue;
75 return m_data->nodeSet(); 73 return m_data->nodeSet();
76 } 74 }
77 75
78 bool Value::toBoolean() const 76 bool Value::toBoolean() const
79 { 77 {
80 switch (m_type) { 78 switch (m_type) {
81 case NodeSetValue: 79 case NodeSetValue:
82 return !m_data->nodeSet().isEmpty(); 80 return !m_data->nodeSet().isEmpty();
83 case BooleanValue: 81 case BooleanValue:
84 return m_bool; 82 return m_bool;
85 case NumberValue: 83 case NumberValue:
86 return m_number && !std::isnan(m_number); 84 return m_number && !std::isnan(m_number);
87 case StringValue: 85 case StringValue:
88 return !m_data->m_string.isEmpty(); 86 return !m_data->m_string.isEmpty();
89 } 87 }
90 ASSERT_NOT_REACHED(); 88 ASSERT_NOT_REACHED();
91 return false; 89 return false;
92 } 90 }
93 91
94 double Value::toNumber() const 92 double Value::toNumber() const
95 { 93 {
96 switch (m_type) { 94 switch (m_type) {
97 case NodeSetValue: 95 case NodeSetValue:
98 return Value(toString()).toNumber(); 96 return Value(toString()).toNumber();
99 case NumberValue: 97 case NumberValue:
100 return m_number; 98 return m_number;
101 case StringValue: { 99 case StringValue: {
102 const String& str = m_data->m_string.simplifyWhiteSpace(); 100 const String& str = m_data->m_string.simplifyWhiteSpace();
103 101
104 // String::toDouble() supports exponential notation, which is not al lowed in XPath. 102 // String::toDouble() supports exponential notation, which is not
105 unsigned len = str.length(); 103 // allowed in XPath.
106 for (unsigned i = 0; i < len; ++i) { 104 unsigned len = str.length();
107 UChar c = str[i]; 105 for (unsigned i = 0; i < len; ++i) {
108 if (!isASCIIDigit(c) && c != '.' && c != '-') 106 UChar c = str[i];
109 return numeric_limits<double>::quiet_NaN(); 107 if (!isASCIIDigit(c) && c != '.' && c != '-')
110 } 108 return std::numeric_limits<double>::quiet_NaN();
109 }
111 110
112 bool canConvert; 111 bool canConvert;
113 double value = str.toDouble(&canConvert); 112 double value = str.toDouble(&canConvert);
114 if (canConvert) 113 if (canConvert)
115 return value; 114 return value;
116 return numeric_limits<double>::quiet_NaN(); 115 return std::numeric_limits<double>::quiet_NaN();
117 } 116 }
118 case BooleanValue: 117 case BooleanValue:
119 return m_bool; 118 return m_bool;
120 } 119 }
121 ASSERT_NOT_REACHED(); 120 ASSERT_NOT_REACHED();
122 return 0.0; 121 return 0.0;
123 } 122 }
124 123
125 String Value::toString() const 124 String Value::toString() const
126 { 125 {
127 switch (m_type) { 126 switch (m_type) {
128 case NodeSetValue: 127 case NodeSetValue:
129 if (m_data->nodeSet().isEmpty()) 128 if (m_data->nodeSet().isEmpty())
130 return ""; 129 return "";
131 return stringValue(m_data->nodeSet().firstNode()); 130 return stringValue(m_data->nodeSet().firstNode());
132 case StringValue: 131 case StringValue:
133 return m_data->m_string; 132 return m_data->m_string;
134 case NumberValue: 133 case NumberValue:
135 if (std::isnan(m_number)) 134 if (std::isnan(m_number))
136 return "NaN"; 135 return "NaN";
137 if (m_number == 0) 136 if (m_number == 0)
138 return "0"; 137 return "0";
139 if (std::isinf(m_number)) 138 if (std::isinf(m_number))
140 return std::signbit(m_number) ? "-Infinity" : "Infinity"; 139 return std::signbit(m_number) ? "-Infinity" : "Infinity";
141 return String::number(m_number); 140 return String::number(m_number);
142 case BooleanValue: 141 case BooleanValue:
143 return m_bool ? "true" : "false"; 142 return m_bool ? "true" : "false";
144 } 143 }
145 ASSERT_NOT_REACHED(); 144 ASSERT_NOT_REACHED();
146 return String(); 145 return String();
147 } 146 }
148 147
149 } 148 }
150 } 149 }
OLDNEW
« no previous file with comments | « Source/core/xml/XPathValue.h ('k') | Source/core/xml/XPathVariableReference.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698