| 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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 | 327 |
| 328 Value FunPosition::evaluate(EvaluationContext& context) const { | 328 Value FunPosition::evaluate(EvaluationContext& context) const { |
| 329 return context.position; | 329 return context.position; |
| 330 } | 330 } |
| 331 | 331 |
| 332 Value FunId::evaluate(EvaluationContext& context) const { | 332 Value FunId::evaluate(EvaluationContext& context) const { |
| 333 Value a = arg(0)->evaluate(context); | 333 Value a = arg(0)->evaluate(context); |
| 334 StringBuilder idList; // A whitespace-separated list of IDs | 334 StringBuilder idList; // A whitespace-separated list of IDs |
| 335 | 335 |
| 336 if (a.isNodeSet()) { | 336 if (a.isNodeSet()) { |
| 337 const NodeSet& nodes = a.toNodeSet(&context); | 337 for (const auto& node : a.toNodeSet(&context)) { |
| 338 for (size_t i = 0; i < nodes.size(); ++i) { | 338 idList.append(stringValue(node)); |
| 339 String str = stringValue(nodes[i]); | |
| 340 idList.append(str); | |
| 341 idList.append(' '); | 339 idList.append(' '); |
| 342 } | 340 } |
| 343 } else { | 341 } else { |
| 344 String str = a.toString(); | 342 idList.append(a.toString()); |
| 345 idList.append(str); | |
| 346 } | 343 } |
| 347 | 344 |
| 348 TreeScope& contextScope = context.node->treeScope(); | 345 TreeScope& contextScope = context.node->treeScope(); |
| 349 NodeSet* result(NodeSet::create()); | 346 NodeSet* result(NodeSet::create()); |
| 350 HeapHashSet<Member<Node>> resultSet; | 347 HeapHashSet<Member<Node>> resultSet; |
| 351 | 348 |
| 352 unsigned startPos = 0; | 349 unsigned startPos = 0; |
| 353 unsigned length = idList.length(); | 350 unsigned length = idList.length(); |
| 354 while (true) { | 351 while (true) { |
| 355 while (startPos < length && isWhitespace(idList[startPos])) | 352 while (startPos < length && isWhitespace(idList[startPos])) |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 Value a = arg(0)->evaluate(context); | 667 Value a = arg(0)->evaluate(context); |
| 671 if (!a.isNodeSet()) | 668 if (!a.isNodeSet()) |
| 672 return 0.0; | 669 return 0.0; |
| 673 | 670 |
| 674 double sum = 0.0; | 671 double sum = 0.0; |
| 675 const NodeSet& nodes = a.toNodeSet(&context); | 672 const NodeSet& nodes = a.toNodeSet(&context); |
| 676 // To be really compliant, we should sort the node-set, as floating point | 673 // To be really compliant, we should sort the node-set, as floating point |
| 677 // addition is not associative. However, this is unlikely to ever become a | 674 // addition is not associative. However, this is unlikely to ever become a |
| 678 // practical issue, and sorting is slow. | 675 // practical issue, and sorting is slow. |
| 679 | 676 |
| 680 for (unsigned i = 0; i < nodes.size(); i++) | 677 for (const auto& node : nodes) |
| 681 sum += Value(stringValue(nodes[i])).toNumber(); | 678 sum += Value(stringValue(node)).toNumber(); |
| 682 | 679 |
| 683 return sum; | 680 return sum; |
| 684 } | 681 } |
| 685 | 682 |
| 686 Value FunFloor::evaluate(EvaluationContext& context) const { | 683 Value FunFloor::evaluate(EvaluationContext& context) const { |
| 687 return floor(arg(0)->evaluate(context).toNumber()); | 684 return floor(arg(0)->evaluate(context).toNumber()); |
| 688 } | 685 } |
| 689 | 686 |
| 690 Value FunCeiling::evaluate(EvaluationContext& context) const { | 687 Value FunCeiling::evaluate(EvaluationContext& context) const { |
| 691 return ceil(arg(0)->evaluate(context).toNumber()); | 688 return ceil(arg(0)->evaluate(context).toNumber()); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 return nullptr; | 763 return nullptr; |
| 767 | 764 |
| 768 Function* function = functionRec->factoryFn(); | 765 Function* function = functionRec->factoryFn(); |
| 769 function->setArguments(args); | 766 function->setArguments(args); |
| 770 function->setName(name); | 767 function->setName(name); |
| 771 return function; | 768 return function; |
| 772 } | 769 } |
| 773 | 770 |
| 774 } // namespace XPath | 771 } // namespace XPath |
| 775 } // namespace blink | 772 } // namespace blink |
| OLD | NEW |