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

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

Issue 1254243002: Remove Node.localName and Node.namespaceURI (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix layout test failure Created 5 years, 4 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
« no previous file with comments | « Source/core/inspector/InspectorDOMAgent.cpp ('k') | Source/core/xml/XPathStep.cpp » ('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 (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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 358
359 result->markSorted(false); 359 result->markSorted(false);
360 360
361 return Value(result, Value::adopt); 361 return Value(result, Value::adopt);
362 } 362 }
363 363
364 static inline String expandedNameLocalPart(Node* node) 364 static inline String expandedNameLocalPart(Node* node)
365 { 365 {
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. 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.
367 // But note that Blink does not support namespace nodes. 367 // But note that Blink does not support namespace nodes.
368 if (node->nodeType() == Node::PROCESSING_INSTRUCTION_NODE) 368 switch (node->nodeType()) {
369 case Node::ELEMENT_NODE:
370 return toElement(node)->localName();
371 case Node::ATTRIBUTE_NODE:
372 return toAttr(node)->localName();
373 case Node::PROCESSING_INSTRUCTION_NODE:
369 return toProcessingInstruction(node)->target(); 374 return toProcessingInstruction(node)->target();
370 return node->localName().string(); 375 default:
376 return String();
377 }
378 }
379
380 static inline String expandedNamespaceURI(Node* node)
381 {
382 switch (node->nodeType()) {
383 case Node::ELEMENT_NODE:
384 return toElement(node)->namespaceURI();
385 case Node::ATTRIBUTE_NODE:
386 return toAttr(node)->namespaceURI();
387 default:
388 return String();
389 }
371 } 390 }
372 391
373 static inline String expandedName(Node* node) 392 static inline String expandedName(Node* node)
374 { 393 {
375 AtomicString prefix; 394 AtomicString prefix;
376 395
377 switch (node->nodeType()) { 396 switch (node->nodeType()) {
378 case Node::ELEMENT_NODE: 397 case Node::ELEMENT_NODE:
379 prefix = toElement(node)->prefix(); 398 prefix = toElement(node)->prefix();
380 break; 399 break;
(...skipping 22 matching lines...) Expand all
403 } 422 }
404 423
405 Value FunNamespaceURI::evaluate(EvaluationContext& context) const 424 Value FunNamespaceURI::evaluate(EvaluationContext& context) const
406 { 425 {
407 if (argCount() > 0) { 426 if (argCount() > 0) {
408 Value a = arg(0)->evaluate(context); 427 Value a = arg(0)->evaluate(context);
409 if (!a.isNodeSet()) 428 if (!a.isNodeSet())
410 return ""; 429 return "";
411 430
412 Node* node = a.toNodeSet(&context).firstNode(); 431 Node* node = a.toNodeSet(&context).firstNode();
413 return node ? node->namespaceURI().string() : ""; 432 return node ? expandedNamespaceURI(node) : "";
414 } 433 }
415 434
416 return context.node->namespaceURI().string(); 435 return expandedNamespaceURI(context.node.get());
417 } 436 }
418 437
419 Value FunName::evaluate(EvaluationContext& context) const 438 Value FunName::evaluate(EvaluationContext& context) const
420 { 439 {
421 if (argCount() > 0) { 440 if (argCount() > 0) {
422 Value a = arg(0)->evaluate(context); 441 Value a = arg(0)->evaluate(context);
423 if (!a.isNodeSet()) 442 if (!a.isNodeSet())
424 return ""; 443 return "";
425 444
426 Node* node = a.toNodeSet(&context).firstNode(); 445 Node* node = a.toNodeSet(&context).firstNode();
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 return nullptr; 761 return nullptr;
743 762
744 Function* function = functionRec->factoryFn(); 763 Function* function = functionRec->factoryFn();
745 function->setArguments(args); 764 function->setArguments(args);
746 function->setName(name); 765 function->setName(name);
747 return function; 766 return function;
748 } 767 }
749 768
750 } 769 }
751 } 770 }
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorDOMAgent.cpp ('k') | Source/core/xml/XPathStep.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698