View | Details | Raw Unified | Return to bug 15988
Collapse All | Expand All

(-)WebCore/ChangeLog (+12 lines)
Lines 1-3 Link Here
1
2007-11-15  Alexey Proskuryakov  <ap@webkit.org>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
        http://bugs.webkit.org/show_bug.cgi?id=15988
6
        REGRESSION: XPath preceding-axis query misses nested elements
7
8
        Test: fast/xpath/preceding-axis.xhtml
9
10
        * xml/XPathStep.cpp:
11
        (WebCore::XPath::Step::nodesInAxis): Hopefully correct this time.
12
1
2007-11-14  Brady Eidson <beidson@apple.com>
13
2007-11-14  Brady Eidson <beidson@apple.com>
2
14
3
        Rubberstamped by Sam
15
        Rubberstamped by Sam
(-)WebCore/xml/XPathStep.cpp (-6 / +4 lines)
Lines 169-182 void Step::nodesInAxis(Node* context, No Link Here
169
            if (context->isAttributeNode())
169
            if (context->isAttributeNode())
170
                context = static_cast<Attr*>(context)->ownerElement();
170
                context = static_cast<Attr*>(context)->ownerElement();
171
171
172
            for (Node* p = context; !isRootDomNode(p); p = p->parentNode()) {
172
            Node* n = context;
173
                for (Node* n = p->previousSibling(); n ; n = n->previousSibling()) {
173
            while (Node* parent = n->parent()) {
174
                    for (Node* c = n->lastChild(); c && c != n; c = c->traversePreviousNode(n))
174
                for (n = n->traversePreviousNode(); n != parent; n = n->traversePreviousNode())
175
                        if (nodeMatches(c))
176
                            nodes.append(c);
177
                    if (nodeMatches(n))
175
                    if (nodeMatches(n))
178
                        nodes.append(n);
176
                        nodes.append(n);
179
                }
177
                n = parent;
180
            }
178
            }
181
            nodes.markSorted(false);
179
            nodes.markSorted(false);
182
            return;
180
            return;
(-)LayoutTests/ChangeLog (+10 lines)
Lines 1-3 Link Here
1
2007-11-15  Khoo Yit Phang  <khooyp@cs.umd.edu>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
        http://bugs.webkit.org/show_bug.cgi?id=15988
6
        REGRESSION: XPath preceding-axis query misses nested elements
7
8
        * fast/xpath/preceding-axis-expected.txt: Added.
9
        * fast/xpath/preceding-axis.xhtml: Added.
10
1
2007-11-14  Alexey Proskuryakov  <ap@webkit.org>
11
2007-11-14  Alexey Proskuryakov  <ap@webkit.org>
2
12
3
        Reviewed by Justin Garcia.
13
        Reviewed by Justin Garcia.
(-)LayoutTests/fast/xpath/preceding-axis-expected.txt (+18 lines)
Line 0 Link Here
1
 Querying in the following...
2
3
<div xmlns="http://www.w3.org/1999/xhtml" id="test">
4
    <span id="A"></span>
5
    <div>
6
      <span id="B">
7
        <span id="C"></span>
8
      </span>
9
    </div>
10
    <span id="D"></span>
11
</div>
12
13
Query "preceding::xhtml:span" from span#D
14
Result: span#A span#B span#C
15
Expected: span#A span#B span#C
16
***SUCCESS***
17
18
0
  + text/plain
19
  + text/plain
1
  + native
20
  + native
(-)LayoutTests/fast/xpath/preceding-axis.xhtml (+57 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="utf-8"?>
2
<!DOCTYPE html>
3
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
4
<head>
5
<title>XPath preceding axis misses nested elements</title>
6
<style>div#msg { white-space: pre; }</style>
7
<script>
8
if (window.layoutTestController)
9
    layoutTestController.dumpAsText();
10
11
window.addEventListener("load", function() {
12
    var msg = document.getElementById("msg");
13
    function print(s) { msg.textContent += s; }
14
    function id(el) { return el.tagName + (el.id ? "#" + el.id : ""); }
15
    function query(el, xpath, expected) {
16
        print("Query \"" + xpath + "\" from " + id(el) + "\n");
17
        var res = document.evaluate(xpath,
18
                                    el,
19
                                    function() { return "http://www.w3.org/1999/xhtml"; },
20
                                    XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
21
                                    null);
22
23
        var resstr = "";
24
        for (var i = 0; i &lt; res.snapshotLength; i++) {
25
            var el = res.snapshotItem(i);
26
            resstr += " " + id(el);
27
        }
28
        print("Result:" + resstr + "\n");
29
        print("Expected: " + expected + "\n");
30
        if (resstr != (" " + expected)) {
31
            print("***FAIL***\n");
32
        } else {
33
            print("***SUCCESS***\n");
34
        }
35
        print("\n");
36
    }
37
    
38
    print("Querying in the following...\n\n");
39
    print(document.getElementById("test").outerHTML + "\n\n");
40
    
41
    query(document.getElementById("D"), "preceding::xhtml:span", "span#A span#B span#C");
42
}, false);
43
</script>
44
</head>
45
<body>
46
<div id="test">
47
    <span id="A"/>
48
    <div>
49
      <span id="B">
50
        <span id="C"/>
51
      </span>
52
    </div>
53
    <span id="D"/>
54
</div>
55
<div id="msg"/>
56
</body>
57
</html>
0
  + text/xml
58
  + text/xml

Return to bug 15988