compareDocumentPosition reports disconnected nodes as following each other
https://bugs.webkit.org/show_bug.cgi?id=108274

Reviewed by Dimitri Glazkov.

Source/WebCore:

jQuery has had to implement their own sorting mechanism in Sizzle[1] due
to Node::compareDocumentPosition always reporting disconnected nodes
as following each other. According to spec[2], we should instead be
indicating that the result is (a) disconnected, (b) implementation
specific, and (c) deterministically ordered.

[1]: https://github.com/jquery/sizzle/commit/1c8aec91284af8d8c14447976235d5dd72b0d75e
[2]: http://dom.spec.whatwg.org/#dom-node-comparedocumentposition

Test: fast/dom/compare-document-position-disconnected-nodes.html

* dom/Node.cpp:
(WebCore::Node::compareDocumentPosition):
    After walking the parentNode chain of both Nodes, compare the root.
    If the Nodes don't share a root, they're in distinct trees, and
    should return as described above. We determine which element
    "preceeds" the other in an arbitrary fashion via pointer comparison.

LayoutTests:

* fast/dom/compare-document-position-disconnected-nodes-expected.txt: Added.
* fast/dom/compare-document-position-disconnected-nodes.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@143239 268f45cc-cd09-0410-ab3c-d52691b4dbfc