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

Side by Side Diff: third_party/WebKit/Source/core/xml/XPathPredicate.cpp

Issue 2274573004: Replace ASSERT*() with DCHECK*() in core/xml/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 3 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
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 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 return leftVal + rightVal; 94 return leftVal + rightVal;
95 case OP_Sub: 95 case OP_Sub:
96 return leftVal - rightVal; 96 return leftVal - rightVal;
97 case OP_Mul: 97 case OP_Mul:
98 return leftVal * rightVal; 98 return leftVal * rightVal;
99 case OP_Div: 99 case OP_Div:
100 return leftVal / rightVal; 100 return leftVal / rightVal;
101 case OP_Mod: 101 case OP_Mod:
102 return fmod(leftVal, rightVal); 102 return fmod(leftVal, rightVal);
103 } 103 }
104 ASSERT_NOT_REACHED(); 104 NOTREACHED();
105 return 0.0; 105 return 0.0;
106 } 106 }
107 107
108 EqTestOp::EqTestOp(Opcode opcode, Expression* lhs, Expression* rhs) 108 EqTestOp::EqTestOp(Opcode opcode, Expression* lhs, Expression* rhs)
109 : m_opcode(opcode) 109 : m_opcode(opcode)
110 { 110 {
111 addSubExpression(lhs); 111 addSubExpression(lhs);
112 addSubExpression(rhs); 112 addSubExpression(rhs);
113 } 113 }
114 114
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 return false; 157 return false;
158 } 158 }
159 if (rhs.isBoolean()) { 159 if (rhs.isBoolean()) {
160 // If one object to be compared is a node-set and the other is a 160 // If one object to be compared is a node-set and the other is a
161 // boolean, then the comparison will be true if and only if the 161 // boolean, then the comparison will be true if and only if the
162 // result of performing the comparison on the boolean and on the 162 // result of performing the comparison on the boolean and on the
163 // result of converting the node-set to a boolean using the boolean 163 // result of converting the node-set to a boolean using the boolean
164 // function is true. 164 // function is true.
165 return compare(context, lhs.toBoolean(), rhs); 165 return compare(context, lhs.toBoolean(), rhs);
166 } 166 }
167 ASSERT(0); 167 NOTREACHED();
168 } 168 }
169 if (rhs.isNodeSet()) { 169 if (rhs.isNodeSet()) {
170 const NodeSet& rhsSet = rhs.toNodeSet(&context); 170 const NodeSet& rhsSet = rhs.toNodeSet(&context);
171 if (lhs.isNumber()) { 171 if (lhs.isNumber()) {
172 for (unsigned rindex = 0; rindex < rhsSet.size(); ++rindex) { 172 for (unsigned rindex = 0; rindex < rhsSet.size(); ++rindex) {
173 if (compare(context, lhs, Value(stringValue(rhsSet[rindex])).toN umber())) 173 if (compare(context, lhs, Value(stringValue(rhsSet[rindex])).toN umber()))
174 return true; 174 return true;
175 } 175 }
176 return false; 176 return false;
177 } 177 }
178 if (lhs.isString()) { 178 if (lhs.isString()) {
179 for (unsigned rindex = 0; rindex < rhsSet.size(); ++rindex) { 179 for (unsigned rindex = 0; rindex < rhsSet.size(); ++rindex) {
180 if (compare(context, lhs, stringValue(rhsSet[rindex]))) 180 if (compare(context, lhs, stringValue(rhsSet[rindex])))
181 return true; 181 return true;
182 } 182 }
183 return false; 183 return false;
184 } 184 }
185 if (lhs.isBoolean()) 185 if (lhs.isBoolean())
186 return compare(context, lhs, rhs.toBoolean()); 186 return compare(context, lhs, rhs.toBoolean());
187 ASSERT(0); 187 NOTREACHED();
188 } 188 }
189 189
190 // Neither side is a NodeSet. 190 // Neither side is a NodeSet.
191 switch (m_opcode) { 191 switch (m_opcode) {
192 case OpcodeEqual: 192 case OpcodeEqual:
193 case OpcodeNotEqual: 193 case OpcodeNotEqual:
194 bool equal; 194 bool equal;
195 if (lhs.isBoolean() || rhs.isBoolean()) 195 if (lhs.isBoolean() || rhs.isBoolean())
196 equal = lhs.toBoolean() == rhs.toBoolean(); 196 equal = lhs.toBoolean() == rhs.toBoolean();
197 else if (lhs.isNumber() || rhs.isNumber()) 197 else if (lhs.isNumber() || rhs.isNumber())
198 equal = lhs.toNumber() == rhs.toNumber(); 198 equal = lhs.toNumber() == rhs.toNumber();
199 else 199 else
200 equal = lhs.toString() == rhs.toString(); 200 equal = lhs.toString() == rhs.toString();
201 201
202 if (m_opcode == OpcodeEqual) 202 if (m_opcode == OpcodeEqual)
203 return equal; 203 return equal;
204 return !equal; 204 return !equal;
205 case OpcodeGreaterThan: 205 case OpcodeGreaterThan:
206 return lhs.toNumber() > rhs.toNumber(); 206 return lhs.toNumber() > rhs.toNumber();
207 case OpcodeGreaterOrEqual: 207 case OpcodeGreaterOrEqual:
208 return lhs.toNumber() >= rhs.toNumber(); 208 return lhs.toNumber() >= rhs.toNumber();
209 case OpcodeLessThan: 209 case OpcodeLessThan:
210 return lhs.toNumber() < rhs.toNumber(); 210 return lhs.toNumber() < rhs.toNumber();
211 case OpcodeLessOrEqual: 211 case OpcodeLessOrEqual:
212 return lhs.toNumber() <= rhs.toNumber(); 212 return lhs.toNumber() <= rhs.toNumber();
213 } 213 }
214 ASSERT(0); 214 NOTREACHED();
215 return false; 215 return false;
216 } 216 }
217 217
218 Value EqTestOp::evaluate(EvaluationContext& context) const 218 Value EqTestOp::evaluate(EvaluationContext& context) const
219 { 219 {
220 Value lhs(subExpr(0)->evaluate(context)); 220 Value lhs(subExpr(0)->evaluate(context));
221 Value rhs(subExpr(1)->evaluate(context)); 221 Value rhs(subExpr(1)->evaluate(context));
222 222
223 return compare(context, lhs, rhs); 223 return compare(context, lhs, rhs);
224 } 224 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 { 278 {
279 } 279 }
280 280
281 DEFINE_TRACE(Predicate) 281 DEFINE_TRACE(Predicate)
282 { 282 {
283 visitor->trace(m_expr); 283 visitor->trace(m_expr);
284 } 284 }
285 285
286 bool Predicate::evaluate(EvaluationContext& context) const 286 bool Predicate::evaluate(EvaluationContext& context) const
287 { 287 {
288 ASSERT(m_expr); 288 DCHECK(m_expr);
289 289
290 Value result(m_expr->evaluate(context)); 290 Value result(m_expr->evaluate(context));
291 291
292 // foo[3] means foo[position()=3] 292 // foo[3] means foo[position()=3]
293 if (result.isNumber()) 293 if (result.isNumber())
294 return EqTestOp(EqTestOp::OpcodeEqual, createFunction("position"), new N umber(result.toNumber())).evaluate(context).toBoolean(); 294 return EqTestOp(EqTestOp::OpcodeEqual, createFunction("position"), new N umber(result.toNumber())).evaluate(context).toBoolean();
295 295
296 return result.toBoolean(); 296 return result.toBoolean();
297 } 297 }
298 298
299 } // namespace XPath 299 } // namespace XPath
300 300
301 } // namespace blink 301 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/xml/XPathParser.cpp ('k') | third_party/WebKit/Source/core/xml/XPathResult.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698