Reviewed by Geoff.
http://bugs.webkit.org/show_bug.cgi?id=12619
Non-abbreviated XPaths don't work
Test: fast/xpath/ancestor-axis.html
* xml/XPathParser.cpp:
(WebCore::XPath::Parser::lex): Fix axis name parsing to actually work.
* xml/XPathStep.cpp:
(WebCore::XPath::Step::nodeTestMatches): Fix "*" node test to actually work.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@19425 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 0dd5c82..7436745 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,13 @@
+2007-02-06 Alexey Proskuryakov <ap@webkit.org>
+
+ Reviewed by Geoff.
+
+ http://bugs.webkit.org/show_bug.cgi?id=12619
+ Non-abbreviated XPaths don't work
+
+ * fast/xpath/ancestor-axis-expected.txt: Added.
+ * fast/xpath/ancestor-axis.html: Added.
+
2007-02-05 David Kilzer <ddkilzer@webkit.org>
Reviewed by Darin.
diff --git a/LayoutTests/fast/xpath/ancestor-axis-expected.txt b/LayoutTests/fast/xpath/ancestor-axis-expected.txt
new file mode 100644
index 0000000..9559c37
--- /dev/null
+++ b/LayoutTests/fast/xpath/ancestor-axis-expected.txt
@@ -0,0 +1,3 @@
+Test for bug 12619: Non-abbreviated XPaths don't work.
+
+SUCCESS
diff --git a/LayoutTests/fast/xpath/ancestor-axis.html b/LayoutTests/fast/xpath/ancestor-axis.html
new file mode 100644
index 0000000..cb75273
--- /dev/null
+++ b/LayoutTests/fast/xpath/ancestor-axis.html
@@ -0,0 +1,24 @@
+<html>
+<body>
+<p>Test for <a href="http://bugs.webkit.org/show_bug.cgi?id=12619">bug 12619</a>:
+Non-abbreviated XPaths don't work.</p>
+
+ <div id="a"></div>
+
+<script>
+ if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+ try {
+ result = document.evaluate("//div/ancestor::*", document.body, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
+
+ if (2 == result.snapshotLength)
+ document.write("SUCCESS");
+ else
+ document.write("FAILURE: " + result.snapshotLength + " result nodes (should be 2)");
+ } catch (ex) {
+ document.write("FAILURE: " + ex);
+ }
+</script>
+</body>
+</html>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 81a3b04..7a0ec9c 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,17 @@
+2007-02-06 Alexey Proskuryakov <ap@webkit.org>
+
+ Reviewed by Geoff.
+
+ http://bugs.webkit.org/show_bug.cgi?id=12619
+ Non-abbreviated XPaths don't work
+
+ Test: fast/xpath/ancestor-axis.html
+
+ * xml/XPathParser.cpp:
+ (WebCore::XPath::Parser::lex): Fix axis name parsing to actually work.
+ * xml/XPathStep.cpp:
+ (WebCore::XPath::Step::nodeTestMatches): Fix "*" node test to actually work.
+
2007-02-06 Mark Rowe <mrowe@apple.com>
Roll out incomplete support for font-stretch (r19350) at Dave Hyatt's request.
diff --git a/WebCore/xml/XPathParser.cpp b/WebCore/xml/XPathParser.cpp
index bc2c5af..8d9f66f 100644
--- a/WebCore/xml/XPathParser.cpp
+++ b/WebCore/xml/XPathParser.cpp
@@ -423,6 +423,7 @@
switch (tok.type) {
case AXISNAME:
yylval->axis = tok.axis;
+ break;
case MULOP:
case RELOP:
yylval->numop = tok.numop;
diff --git a/WebCore/xml/XPathStep.cpp b/WebCore/xml/XPathStep.cpp
index 383908e..6bcaf43 100644
--- a/WebCore/xml/XPathStep.cpp
+++ b/WebCore/xml/XPathStep.cpp
@@ -198,7 +198,7 @@
(m_namespaceURI.isEmpty() || m_namespaceURI == node->namespaceURI()))
matches.append(node);
}
- return nodes;
+ return matches;
} else if (m_nodeTest == "text()") {
HashSet<Node*> nodeSet;
for (unsigned i = 0; i < nodes.size(); i++) {