Changeset 143239 in webkit
- Timestamp:
- Feb 18, 2013 10:21:59 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r143238 r143239 1 2013-02-18 Mike West <mkwst@chromium.org> 2 3 compareDocumentPosition reports disconnected nodes as following each other 4 https://bugs.webkit.org/show_bug.cgi?id=108274 5 6 Reviewed by Dimitri Glazkov. 7 8 * fast/dom/compare-document-position-disconnected-nodes-expected.txt: Added. 9 * fast/dom/compare-document-position-disconnected-nodes.html: Added. 10 1 11 2013-02-18 Stephen White <senorblanco@chromium.org> 2 12 -
trunk/Source/WebCore/ChangeLog
r143237 r143239 1 2013-02-18 Mike West <mkwst@chromium.org> 2 3 compareDocumentPosition reports disconnected nodes as following each other 4 https://bugs.webkit.org/show_bug.cgi?id=108274 5 6 Reviewed by Dimitri Glazkov. 7 8 jQuery has had to implement their own sorting mechanism in Sizzle[1] due 9 to Node::compareDocumentPosition always reporting disconnected nodes 10 as following each other. According to spec[2], we should instead be 11 indicating that the result is (a) disconnected, (b) implementation 12 specific, and (c) deterministically ordered. 13 14 [1]: https://github.com/jquery/sizzle/commit/1c8aec91284af8d8c14447976235d5dd72b0d75e 15 [2]: http://dom.spec.whatwg.org/#dom-node-comparedocumentposition 16 17 Test: fast/dom/compare-document-position-disconnected-nodes.html 18 19 * dom/Node.cpp: 20 (WebCore::Node::compareDocumentPosition): 21 After walking the parentNode chain of both Nodes, compare the root. 22 If the Nodes don't share a root, they're in distinct trees, and 23 should return as described above. We determine which element 24 "preceeds" the other in an arbitrary fashion via pointer comparison. 25 1 26 2013-02-18 Andrey Adaikin <aandrey@chromium.org> 2 27 -
trunk/Source/WebCore/dom/Node.cpp
r143112 r143239 1786 1786 for (current = start2; current; current = current->parentNode()) 1787 1787 chain2.append(current); 1788 1789 // Walk the two chains backwards and look for the first difference. 1788 1790 1789 unsigned index1 = chain1.size(); 1791 1790 unsigned index2 = chain2.size(); 1791 1792 // If the two elements don't have a common root, they're not in the same tree. 1793 if (chain1[index1 - 1] != chain2[index2 - 1]) { 1794 unsigned short direction = (start1 > start2) ? DOCUMENT_POSITION_PRECEDING : DOCUMENT_POSITION_FOLLOWING; 1795 return DOCUMENT_POSITION_DISCONNECTED | DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC | direction; 1796 } 1797 1798 // Walk the two chains backwards and look for the first difference. 1792 1799 for (unsigned i = min(index1, index2); i; --i) { 1793 1800 Node* child1 = chain1[--index1];
Note: See TracChangeset
for help on using the changeset viewer.