| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005 Frerich Raabe <raabe@kde.org> | 2 * Copyright (C) 2005 Frerich Raabe <raabe@kde.org> |
| 3 * Copyright (C) 2006, 2009 Apple Inc. | 3 * Copyright (C) 2006, 2009 Apple 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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 | 284 |
| 285 if (m_min == Inf) | 285 if (m_min == Inf) |
| 286 return value <= m_max; | 286 return value <= m_max; |
| 287 | 287 |
| 288 if (m_max == Inf) | 288 if (m_max == Inf) |
| 289 return value >= m_min; | 289 return value >= m_min; |
| 290 | 290 |
| 291 return value >= m_min && value <= m_max; | 291 return value >= m_min && value <= m_max; |
| 292 } | 292 } |
| 293 | 293 |
| 294 void Function::setArguments(WillBeHeapVector<OwnPtrWillBeMember<Expression>>& ar
gs) | 294 void Function::setArguments(HeapVector<Member<Expression>>& args) |
| 295 { | 295 { |
| 296 ASSERT(!subExprCount()); | 296 ASSERT(!subExprCount()); |
| 297 | 297 |
| 298 // Some functions use context node as implicit argument, so when explicit ar
guments are added, they may no longer be context node sensitive. | 298 // Some functions use context node as implicit argument, so when explicit ar
guments are added, they may no longer be context node sensitive. |
| 299 if (m_name != "lang" && !args.isEmpty()) | 299 if (m_name != "lang" && !args.isEmpty()) |
| 300 setIsContextNodeSensitive(false); | 300 setIsContextNodeSensitive(false); |
| 301 | 301 |
| 302 WillBeHeapVector<OwnPtrWillBeMember<Expression>>::iterator end = args.end(); | 302 for (Expression* arg : args) |
| 303 for (WillBeHeapVector<OwnPtrWillBeMember<Expression>>::iterator it = args.be
gin(); it != end; ++it) | 303 addSubExpression(arg); |
| 304 addSubExpression(it->release()); | |
| 305 } | 304 } |
| 306 | 305 |
| 307 Value FunLast::evaluate(EvaluationContext& context) const | 306 Value FunLast::evaluate(EvaluationContext& context) const |
| 308 { | 307 { |
| 309 return context.size; | 308 return context.size; |
| 310 } | 309 } |
| 311 | 310 |
| 312 Value FunPosition::evaluate(EvaluationContext& context) const | 311 Value FunPosition::evaluate(EvaluationContext& context) const |
| 313 { | 312 { |
| 314 return context.position; | 313 return context.position; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 325 String str = stringValue(nodes[i]); | 324 String str = stringValue(nodes[i]); |
| 326 idList.append(str); | 325 idList.append(str); |
| 327 idList.append(' '); | 326 idList.append(' '); |
| 328 } | 327 } |
| 329 } else { | 328 } else { |
| 330 String str = a.toString(); | 329 String str = a.toString(); |
| 331 idList.append(str); | 330 idList.append(str); |
| 332 } | 331 } |
| 333 | 332 |
| 334 TreeScope& contextScope = context.node->treeScope(); | 333 TreeScope& contextScope = context.node->treeScope(); |
| 335 OwnPtrWillBeRawPtr<NodeSet> result(NodeSet::create()); | 334 NodeSet* result(NodeSet::create()); |
| 336 WillBeHeapHashSet<RawPtrWillBeMember<Node>> resultSet; | 335 WillBeHeapHashSet<RawPtrWillBeMember<Node>> resultSet; |
| 337 | 336 |
| 338 unsigned startPos = 0; | 337 unsigned startPos = 0; |
| 339 unsigned length = idList.length(); | 338 unsigned length = idList.length(); |
| 340 while (true) { | 339 while (true) { |
| 341 while (startPos < length && isWhitespace(idList[startPos])) | 340 while (startPos < length && isWhitespace(idList[startPos])) |
| 342 ++startPos; | 341 ++startPos; |
| 343 | 342 |
| 344 if (startPos == length) | 343 if (startPos == length) |
| 345 break; | 344 break; |
| 346 | 345 |
| 347 size_t endPos = startPos; | 346 size_t endPos = startPos; |
| 348 while (endPos < length && !isWhitespace(idList[endPos])) | 347 while (endPos < length && !isWhitespace(idList[endPos])) |
| 349 ++endPos; | 348 ++endPos; |
| 350 | 349 |
| 351 // If there are several nodes with the same id, id() should return the f
irst one. | 350 // If there are several nodes with the same id, id() should return the f
irst one. |
| 352 // In WebKit, getElementById behaves so, too, although its behavior in t
his case is formally undefined. | 351 // In WebKit, getElementById behaves so, too, although its behavior in t
his case is formally undefined. |
| 353 Node* node = contextScope.getElementById(AtomicString(idList.substring(s
tartPos, endPos - startPos))); | 352 Node* node = contextScope.getElementById(AtomicString(idList.substring(s
tartPos, endPos - startPos))); |
| 354 if (node && resultSet.add(node).isNewEntry) | 353 if (node && resultSet.add(node).isNewEntry) |
| 355 result->append(node); | 354 result->append(node); |
| 356 | 355 |
| 357 startPos = endPos; | 356 startPos = endPos; |
| 358 } | 357 } |
| 359 | 358 |
| 360 result->markSorted(false); | 359 result->markSorted(false); |
| 361 | 360 |
| 362 return Value(result.release(), Value::adopt); | 361 return Value(result, Value::adopt); |
| 363 } | 362 } |
| 364 | 363 |
| 365 static inline String expandedNameLocalPart(Node* node) | 364 static inline String expandedNameLocalPart(Node* node) |
| 366 { | 365 { |
| 367 // The local part of an XPath expanded-name matches DOM local name for most
node types, except for namespace nodes and processing instruction nodes. | 366 // The local part of an XPath expanded-name matches DOM local name for most
node types, except for namespace nodes and processing instruction nodes. |
| 368 // But note that Blink does not support namespace nodes. | 367 // But note that Blink does not support namespace nodes. |
| 369 if (node->nodeType() == Node::PROCESSING_INSTRUCTION_NODE) | 368 if (node->nodeType() == Node::PROCESSING_INSTRUCTION_NODE) |
| 370 return toProcessingInstruction(node)->target(); | 369 return toProcessingInstruction(node)->target(); |
| 371 return node->localName().string(); | 370 return node->localName().string(); |
| 372 } | 371 } |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 720 }; | 719 }; |
| 721 | 720 |
| 722 functionMap = new HashMap<String, FunctionRec>; | 721 functionMap = new HashMap<String, FunctionRec>; |
| 723 for (size_t i = 0; i < WTF_ARRAY_LENGTH(functions); ++i) | 722 for (size_t i = 0; i < WTF_ARRAY_LENGTH(functions); ++i) |
| 724 functionMap->set(functions[i].name, functions[i].function); | 723 functionMap->set(functions[i].name, functions[i].function); |
| 725 } | 724 } |
| 726 | 725 |
| 727 | 726 |
| 728 Function* createFunction(const String& name) | 727 Function* createFunction(const String& name) |
| 729 { | 728 { |
| 730 WillBeHeapVector<OwnPtrWillBeMember<Expression>> args; | 729 HeapVector<Member<Expression>> args; |
| 731 return createFunction(name, args); | 730 return createFunction(name, args); |
| 732 } | 731 } |
| 733 | 732 |
| 734 Function* createFunction(const String& name, WillBeHeapVector<OwnPtrWillBeMember
<Expression>>& args) | 733 Function* createFunction(const String& name, HeapVector<Member<Expression>>& arg
s) |
| 735 { | 734 { |
| 736 if (!functionMap) | 735 if (!functionMap) |
| 737 createFunctionMap(); | 736 createFunctionMap(); |
| 738 | 737 |
| 739 HashMap<String, FunctionRec>::iterator functionMapIter = functionMap->find(n
ame); | 738 HashMap<String, FunctionRec>::iterator functionMapIter = functionMap->find(n
ame); |
| 740 FunctionRec* functionRec = 0; | 739 FunctionRec* functionRec = 0; |
| 741 | 740 |
| 742 if (functionMapIter == functionMap->end() || !(functionRec = &functionMapIte
r->value)->args.contains(args.size())) | 741 if (functionMapIter == functionMap->end() || !(functionRec = &functionMapIte
r->value)->args.contains(args.size())) |
| 743 return 0; | 742 return 0; |
| 744 | 743 |
| 745 Function* function = functionRec->factoryFn(); | 744 Function* function = functionRec->factoryFn(); |
| 746 function->setArguments(args); | 745 function->setArguments(args); |
| 747 function->setName(name); | 746 function->setName(name); |
| 748 return function; | 747 return function; |
| 749 } | 748 } |
| 750 | 749 |
| 751 } | 750 } |
| 752 } | 751 } |
| OLD | NEW |