Chromium Code Reviews| 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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 302 | 302 |
| 303 if (m_max == Inf) | 303 if (m_max == Inf) |
| 304 return value >= m_min; | 304 return value >= m_min; |
| 305 | 305 |
| 306 return value >= m_min && value <= m_max; | 306 return value >= m_min && value <= m_max; |
| 307 } | 307 } |
| 308 | 308 |
| 309 void Function::setArguments(HeapVector<Member<Expression>>& args) { | 309 void Function::setArguments(HeapVector<Member<Expression>>& args) { |
| 310 DCHECK(!subExprCount()); | 310 DCHECK(!subExprCount()); |
| 311 | 311 |
| 312 // Some functions use context node as implicit argument, so when explicit argu ments are added, they may no longer be context node sensitive. | 312 // Some functions use context node as implicit argument, so when explicit |
| 313 // arguments are added, they may no longer be context node sensitive. | |
| 313 if (m_name != "lang" && !args.isEmpty()) | 314 if (m_name != "lang" && !args.isEmpty()) |
| 314 setIsContextNodeSensitive(false); | 315 setIsContextNodeSensitive(false); |
| 315 | 316 |
| 316 for (Expression* arg : args) | 317 for (Expression* arg : args) |
| 317 addSubExpression(arg); | 318 addSubExpression(arg); |
| 318 } | 319 } |
| 319 | 320 |
| 320 Value FunLast::evaluate(EvaluationContext& context) const { | 321 Value FunLast::evaluate(EvaluationContext& context) const { |
| 321 return context.size; | 322 return context.size; |
| 322 } | 323 } |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 351 while (startPos < length && isWhitespace(idList[startPos])) | 352 while (startPos < length && isWhitespace(idList[startPos])) |
| 352 ++startPos; | 353 ++startPos; |
| 353 | 354 |
| 354 if (startPos == length) | 355 if (startPos == length) |
| 355 break; | 356 break; |
| 356 | 357 |
| 357 size_t endPos = startPos; | 358 size_t endPos = startPos; |
| 358 while (endPos < length && !isWhitespace(idList[endPos])) | 359 while (endPos < length && !isWhitespace(idList[endPos])) |
| 359 ++endPos; | 360 ++endPos; |
| 360 | 361 |
| 361 // If there are several nodes with the same id, id() should return the first one. | 362 // If there are several nodes with the same id, id() should return the first |
| 362 // In WebKit, getElementById behaves so, too, although its behavior in this case is formally undefined. | 363 // one. In WebKit, getElementById behaves so, too, although its behavior in |
|
jbroman
2016/10/04 19:56:51
ditto
| |
| 364 // this case is formally undefined. | |
| 363 Node* node = contextScope.getElementById( | 365 Node* node = contextScope.getElementById( |
| 364 AtomicString(idList.substring(startPos, endPos - startPos))); | 366 AtomicString(idList.substring(startPos, endPos - startPos))); |
| 365 if (node && resultSet.add(node).isNewEntry) | 367 if (node && resultSet.add(node).isNewEntry) |
| 366 result->append(node); | 368 result->append(node); |
| 367 | 369 |
| 368 startPos = endPos; | 370 startPos = endPos; |
| 369 } | 371 } |
| 370 | 372 |
| 371 result->markSorted(false); | 373 result->markSorted(false); |
| 372 | 374 |
| 373 return Value(result, Value::adopt); | 375 return Value(result, Value::adopt); |
| 374 } | 376 } |
| 375 | 377 |
| 376 static inline String expandedNameLocalPart(Node* node) { | 378 static inline String expandedNameLocalPart(Node* node) { |
| 377 // The local part of an XPath expanded-name matches DOM local name for most no de types, except for namespace nodes and processing instruction nodes. | 379 // The local part of an XPath expanded-name matches DOM local name for most |
| 380 // node types, except for namespace nodes and processing instruction nodes. | |
| 378 // But note that Blink does not support namespace nodes. | 381 // But note that Blink does not support namespace nodes. |
| 379 switch (node->getNodeType()) { | 382 switch (node->getNodeType()) { |
| 380 case Node::kElementNode: | 383 case Node::kElementNode: |
| 381 return toElement(node)->localName(); | 384 return toElement(node)->localName(); |
| 382 case Node::kAttributeNode: | 385 case Node::kAttributeNode: |
| 383 return toAttr(node)->localName(); | 386 return toAttr(node)->localName(); |
| 384 case Node::kProcessingInstructionNode: | 387 case Node::kProcessingInstructionNode: |
| 385 return toProcessingInstruction(node)->target(); | 388 return toProcessingInstruction(node)->target(); |
| 386 default: | 389 default: |
| 387 return String(); | 390 return String(); |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 647 return arg(0)->evaluate(context).toNumber(); | 650 return arg(0)->evaluate(context).toNumber(); |
| 648 } | 651 } |
| 649 | 652 |
| 650 Value FunSum::evaluate(EvaluationContext& context) const { | 653 Value FunSum::evaluate(EvaluationContext& context) const { |
| 651 Value a = arg(0)->evaluate(context); | 654 Value a = arg(0)->evaluate(context); |
| 652 if (!a.isNodeSet()) | 655 if (!a.isNodeSet()) |
| 653 return 0.0; | 656 return 0.0; |
| 654 | 657 |
| 655 double sum = 0.0; | 658 double sum = 0.0; |
| 656 const NodeSet& nodes = a.toNodeSet(&context); | 659 const NodeSet& nodes = a.toNodeSet(&context); |
| 657 // To be really compliant, we should sort the node-set, as floating point addi tion is not associative. | 660 // To be really compliant, we should sort the node-set, as floating point |
| 658 // However, this is unlikely to ever become a practical issue, and sorting is slow. | 661 // addition is not associative. However, this is unlikely to ever become a |
| 662 // practical issue, and sorting is slow. | |
| 659 | 663 |
| 660 for (unsigned i = 0; i < nodes.size(); i++) | 664 for (unsigned i = 0; i < nodes.size(); i++) |
| 661 sum += Value(stringValue(nodes[i])).toNumber(); | 665 sum += Value(stringValue(nodes[i])).toNumber(); |
| 662 | 666 |
| 663 return sum; | 667 return sum; |
| 664 } | 668 } |
| 665 | 669 |
| 666 Value FunFloor::evaluate(EvaluationContext& context) const { | 670 Value FunFloor::evaluate(EvaluationContext& context) const { |
| 667 return floor(arg(0)->evaluate(context).toNumber()); | 671 return floor(arg(0)->evaluate(context).toNumber()); |
| 668 } | 672 } |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 746 return nullptr; | 750 return nullptr; |
| 747 | 751 |
| 748 Function* function = functionRec->factoryFn(); | 752 Function* function = functionRec->factoryFn(); |
| 749 function->setArguments(args); | 753 function->setArguments(args); |
| 750 function->setName(name); | 754 function->setName(name); |
| 751 return function; | 755 return function; |
| 752 } | 756 } |
| 753 | 757 |
| 754 } // namespace XPath | 758 } // namespace XPath |
| 755 } // namespace blink | 759 } // namespace blink |
| OLD | NEW |