diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2016-04-10 09:28:39 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2016-04-10 09:28:39 +0000 |
commit | 32761a6cee1d0dee366b885b7b9c777e67885688 (patch) | |
tree | d6bec92bebfb216f4126356e55518842c2f476a1 /Source/WebCore/xml/XPathFunctions.cpp | |
parent | a4e969f4965059196ca948db781e52f7cfebf19e (diff) | |
download | WebKitGtk-tarball-32761a6cee1d0dee366b885b7b9c777e67885688.tar.gz |
webkitgtk-2.4.11webkitgtk-2.4.11
Diffstat (limited to 'Source/WebCore/xml/XPathFunctions.cpp')
-rw-r--r-- | Source/WebCore/xml/XPathFunctions.cpp | 56 |
1 files changed, 26 insertions, 30 deletions
diff --git a/Source/WebCore/xml/XPathFunctions.cpp b/Source/WebCore/xml/XPathFunctions.cpp index a66c47191..e6d9809f3 100644 --- a/Source/WebCore/xml/XPathFunctions.cpp +++ b/Source/WebCore/xml/XPathFunctions.cpp @@ -291,7 +291,7 @@ void Function::setArguments(const String& name, Vector<std::unique_ptr<Expressio if (name != "lang" && !arguments.isEmpty()) setIsContextNodeSensitive(false); - setSubexpressions(WTFMove(arguments)); + setSubexpressions(std::move(arguments)); } Value FunLast::evaluate() const @@ -304,27 +304,21 @@ Value FunPosition::evaluate() const return Expression::evaluationContext().position; } -static AtomicString atomicSubstring(StringBuilder& builder, unsigned start, unsigned length) -{ - ASSERT(start <= builder.length()); - ASSERT(length <= builder.length() - start); - if (builder.is8Bit()) - return AtomicString(builder.characters8() + start, length); - return AtomicString(builder.characters16() + start, length); -} - Value FunId::evaluate() const { Value a = argument(0).evaluate(); StringBuilder idList; // A whitespace-separated list of IDs - if (!a.isNodeSet()) - idList.append(a.toString()); - else { - for (auto& node : a.toNodeSet()) { - idList.append(stringValue(node.get())); + if (a.isNodeSet()) { + const NodeSet& nodes = a.toNodeSet(); + for (size_t i = 0; i < nodes.size(); ++i) { + String str = stringValue(nodes[i]); + idList.append(str); idList.append(' '); } + } else { + String str = a.toString(); + idList.append(str); } TreeScope& contextScope = evaluationContext().node->treeScope(); @@ -346,7 +340,7 @@ Value FunId::evaluate() const // If there are several nodes with the same id, id() should return the first one. // In WebKit, getElementById behaves so, too, although its behavior in this case is formally undefined. - Node* node = contextScope.getElementById(atomicSubstring(idList, startPos, endPos - startPos)); + Node* node = contextScope.getElementById(String(idList.deprecatedCharacters() + startPos, endPos - startPos)); if (node && resultSet.add(node).isNewEntry) result.append(node); @@ -355,13 +349,15 @@ Value FunId::evaluate() const result.markSorted(false); - return Value(WTFMove(result)); + return Value(std::move(result)); } static inline String expandedNameLocalPart(Node* node) { - if (is<ProcessingInstruction>(*node)) - return downcast<ProcessingInstruction>(*node).target(); + // The local part of an XPath expanded-name matches DOM local name for most node types, except for namespace nodes and processing instruction nodes. + ASSERT(node->nodeType() != Node::XPATH_NAMESPACE_NODE); // Not supported yet. + if (node->nodeType() == Node::PROCESSING_INSTRUCTION_NODE) + return toProcessingInstruction(node)->target(); return node->localName().string(); } @@ -578,13 +574,13 @@ Value FunLang::evaluate() const { String lang = argument(0).evaluate().toString(); - const Attribute* languageAttribute = nullptr; + const Attribute* languageAttribute = 0; Node* node = evaluationContext().node.get(); while (node) { - if (is<Element>(*node)) { - Element& element = downcast<Element>(*node); - if (element.hasAttributes()) - languageAttribute = element.findAttributeByName(XMLNames::langAttr); + if (node->isElementNode()) { + Element* element = toElement(node); + if (element->hasAttributes()) + languageAttribute = element->findAttributeByName(XMLNames::langAttr); } if (languageAttribute) break; @@ -596,7 +592,7 @@ Value FunLang::evaluate() const String langValue = languageAttribute->value(); while (true) { - if (equalIgnoringASCIICase(langValue, lang)) + if (equalIgnoringCase(langValue, lang)) return true; // Remove suffixes one by one. @@ -632,8 +628,8 @@ Value FunSum::evaluate() const // To be really compliant, we should sort the node-set, as floating point addition is not associative. // However, this is unlikely to ever become a practical issue, and sorting is slow. - for (auto& node : nodes) - sum += Value(stringValue(node.get())).toNumber(); + for (unsigned i = 0; i < nodes.size(); i++) + sum += Value(stringValue(nodes[i])).toNumber(); return sum; } @@ -706,8 +702,8 @@ static void populateFunctionMap(HashMap<String, FunctionMapValue>& functionMap) { "true", { createFunctionTrue, 0 } }, }; - for (auto& function : functions) - functionMap.add(function.name, function.function); + for (size_t i = 0; i < WTF_ARRAY_LENGTH(functions); ++i) + functionMap.add(functions[i].name, functions[i].function); } std::unique_ptr<Function> Function::create(const String& name, unsigned numArguments) @@ -735,7 +731,7 @@ std::unique_ptr<Function> Function::create(const String& name, Vector<std::uniqu { std::unique_ptr<Function> function = create(name, arguments.size()); if (function) - function->setArguments(name, WTFMove(arguments)); + function->setArguments(name, std::move(arguments)); return function; } |