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

Unified 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, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/inspector/InspectorDOMAgent.cpp ('k') | Source/core/xml/XPathStep.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/xml/XPathFunctions.cpp
diff --git a/Source/core/xml/XPathFunctions.cpp b/Source/core/xml/XPathFunctions.cpp
index c8b00c5e78b3b01643b3f34ebf9ef2a347dc83e1..3de9324775fc83d1931798ab1d525fb9f3f91c3a 100644
--- a/Source/core/xml/XPathFunctions.cpp
+++ b/Source/core/xml/XPathFunctions.cpp
@@ -365,9 +365,28 @@ static inline String expandedNameLocalPart(Node* node)
{
// The local part of an XPath expanded-name matches DOM local name for most node types, except for namespace nodes and processing instruction nodes.
// But note that Blink does not support namespace nodes.
- if (node->nodeType() == Node::PROCESSING_INSTRUCTION_NODE)
+ switch (node->nodeType()) {
+ case Node::ELEMENT_NODE:
+ return toElement(node)->localName();
+ case Node::ATTRIBUTE_NODE:
+ return toAttr(node)->localName();
+ case Node::PROCESSING_INSTRUCTION_NODE:
return toProcessingInstruction(node)->target();
- return node->localName().string();
+ default:
+ return String();
+ }
+}
+
+static inline String expandedNamespaceURI(Node* node)
+{
+ switch (node->nodeType()) {
+ case Node::ELEMENT_NODE:
+ return toElement(node)->namespaceURI();
+ case Node::ATTRIBUTE_NODE:
+ return toAttr(node)->namespaceURI();
+ default:
+ return String();
+ }
}
static inline String expandedName(Node* node)
@@ -410,10 +429,10 @@ Value FunNamespaceURI::evaluate(EvaluationContext& context) const
return "";
Node* node = a.toNodeSet(&context).firstNode();
- return node ? node->namespaceURI().string() : "";
+ return node ? expandedNamespaceURI(node) : "";
}
- return context.node->namespaceURI().string();
+ return expandedNamespaceURI(context.node.get());
}
Value FunName::evaluate(EvaluationContext& context) const
« 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