From 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Tue, 27 Jun 2017 06:07:23 +0000 Subject: webkitgtk-2.16.5 --- Source/WebCore/xml/XPathNodeSet.cpp | 49 ++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 25 deletions(-) (limited to 'Source/WebCore/xml/XPathNodeSet.cpp') diff --git a/Source/WebCore/xml/XPathNodeSet.cpp b/Source/WebCore/xml/XPathNodeSet.cpp index 5fcbfaa53..d04bd62c1 100644 --- a/Source/WebCore/xml/XPathNodeSet.cpp +++ b/Source/WebCore/xml/XPathNodeSet.cpp @@ -94,8 +94,8 @@ static void sortBlock(unsigned from, unsigned to, Vector>& parentM unsigned sortedEnd = from; // FIXME: namespace nodes are not implemented. for (unsigned i = sortedEnd; i < to; ++i) { - Node* n = parentMatrix[i][0]; - if (n->isAttributeNode() && toAttr(n)->ownerElement() == commonAncestor) + Node* node = parentMatrix[i][0]; + if (is(*node) && downcast(*node).ownerElement() == commonAncestor) parentMatrix[i].swap(parentMatrix[sortedEnd++]); } if (sortedEnd != from) { @@ -155,15 +155,15 @@ void NodeSet::sort() const Vector> parentMatrix(nodeCount); for (unsigned i = 0; i < nodeCount; ++i) { Vector& parentsVector = parentMatrix[i]; - Node* n = m_nodes[i].get(); - parentsVector.append(n); - if (n->isAttributeNode()) { - n = toAttr(n)->ownerElement(); - parentsVector.append(n); + Node* node = m_nodes[i].get(); + parentsVector.append(node); + if (is(*node)) { + node = downcast(*node).ownerElement(); + parentsVector.append(node); containsAttributeNodes = true; } - while ((n = n->parentNode())) - parentsVector.append(n); + while ((node = node->parentNode())) + parentsVector.append(node); } sortBlock(0, nodeCount, parentMatrix, containsAttributeNodes); @@ -173,15 +173,15 @@ void NodeSet::sort() const for (unsigned i = 0; i < nodeCount; ++i) sortedNodes.append(parentMatrix[i][0]); - m_nodes = std::move(sortedNodes); + m_nodes = WTFMove(sortedNodes); m_isSorted = true; } static Node* findRootNode(Node* node) { - if (node->isAttributeNode()) - node = toAttr(node)->ownerElement(); - if (node->inDocument()) + if (is(*node)) + node = downcast(*node).ownerElement(); + if (node->isConnected()) node = &node->document(); else { while (Node* parent = node->parentNode()) @@ -197,9 +197,8 @@ void NodeSet::traversalSort() const unsigned nodeCount = m_nodes.size(); ASSERT(nodeCount > 1); - for (unsigned i = 0; i < nodeCount; ++i) { - Node* node = m_nodes[i].get(); - nodes.add(node); + for (auto& node : m_nodes) { + nodes.add(node.get()); if (node->isAttributeNode()) containsAttributeNodes = true; } @@ -207,26 +206,26 @@ void NodeSet::traversalSort() const Vector> sortedNodes; sortedNodes.reserveInitialCapacity(nodeCount); - for (Node* n = findRootNode(m_nodes.first().get()); n; n = NodeTraversal::next(n)) { - if (nodes.contains(n)) - sortedNodes.append(n); + for (Node* node = findRootNode(m_nodes.first().get()); node; node = NodeTraversal::next(*node)) { + if (nodes.contains(node)) + sortedNodes.append(node); - if (!containsAttributeNodes || !n->isElementNode()) + if (!containsAttributeNodes || !is(*node)) continue; - Element* element = toElement(n); - if (!element->hasAttributes()) + Element& element = downcast(*node); + if (!element.hasAttributes()) continue; - for (const Attribute& attribute : element->attributesIterator()) { - RefPtr attr = element->attrIfExists(attribute.name()); + for (const Attribute& attribute : element.attributesIterator()) { + RefPtr attr = element.attrIfExists(attribute.name()); if (attr && nodes.contains(attr.get())) sortedNodes.append(attr); } } ASSERT(sortedNodes.size() == nodeCount); - m_nodes = std::move(sortedNodes); + m_nodes = WTFMove(sortedNodes); m_isSorted = true; } -- cgit v1.2.1