Changeset 35143 in webkit
- Timestamp:
- Jul 11, 2008 7:13:27 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 35 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/dom/xhtml/level3/core/nodecomparedocumentposition01-expected.txt
r33979 r35143 1 1 Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodecomparedocumentposition01 2 Status error 3 Message Line 103: TypeError 2 Status Success -
trunk/LayoutTests/dom/xhtml/level3/core/nodecomparedocumentposition02-expected.txt
r33979 r35143 1 1 Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodecomparedocumentposition02 2 Status error 3 Message Line 113: TypeError 2 Status Success -
trunk/LayoutTests/dom/xhtml/level3/core/nodecomparedocumentposition03-expected.txt
r33979 r35143 1 1 Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodecomparedocumentposition03 2 2 Status error 3 Message Line 11 2: TypeError3 Message Line 115: ReferenceError -
trunk/LayoutTests/dom/xhtml/level3/core/nodecomparedocumentposition04-expected.txt
r33979 r35143 1 1 Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodecomparedocumentposition04 2 Status error 3 Message Line 96: TypeError 2 Status Success -
trunk/LayoutTests/dom/xhtml/level3/core/nodecomparedocumentposition05-expected.txt
r33979 r35143 1 1 Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodecomparedocumentposition05 2 2 Status error 3 Message Line 11 3: TypeError3 Message Line 117: ReferenceError -
trunk/LayoutTests/dom/xhtml/level3/core/nodecomparedocumentposition06-expected.txt
r33979 r35143 1 1 Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodecomparedocumentposition06 2 Status error 3 Message Line 103: TypeError 2 Status Success -
trunk/LayoutTests/dom/xhtml/level3/core/nodecomparedocumentposition07-expected.txt
r33979 r35143 1 1 Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodecomparedocumentposition07 2 Status error 3 Message Line 104: TypeError 2 Status Success 4 3 5 4 -
trunk/LayoutTests/dom/xhtml/level3/core/nodecomparedocumentposition08-expected.txt
r33979 r35143 1 1 Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodecomparedocumentposition08 2 Status error 3 Message Line 101: TypeError 2 Status Success -
trunk/LayoutTests/dom/xhtml/level3/core/nodecomparedocumentposition09-expected.txt
r33979 r35143 1 1 Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodecomparedocumentposition09 2 Status error 3 Message Line 105: TypeError 2 Status Success -
trunk/LayoutTests/dom/xhtml/level3/core/nodecomparedocumentposition10-expected.txt
r33979 r35143 1 1 Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodecomparedocumentposition10 2 Status error 3 Message Line 101: TypeError 2 Status Success -
trunk/LayoutTests/dom/xhtml/level3/core/nodecomparedocumentposition11-expected.txt
r33979 r35143 1 1 Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodecomparedocumentposition11 2 Status error 3 Message Line 104: TypeError 2 Status Success -
trunk/LayoutTests/dom/xhtml/level3/core/nodecomparedocumentposition12-expected.txt
r33979 r35143 1 1 Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodecomparedocumentposition12 2 Status error 3 Message Line 101: TypeError 2 Status Success -
trunk/LayoutTests/dom/xhtml/level3/core/nodecomparedocumentposition13-expected.txt
r33979 r35143 1 1 Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodecomparedocumentposition13 2 Status error 3 Message Line 105: TypeError 2 Status Success -
trunk/LayoutTests/dom/xhtml/level3/core/nodecomparedocumentposition16-expected.txt
r33979 r35143 1 1 Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodecomparedocumentposition16 2 2 Status error 3 Message Line 10 6: TypeError3 Message Line 109: ReferenceError -
trunk/LayoutTests/dom/xhtml/level3/core/nodecomparedocumentposition17-expected.txt
r33979 r35143 1 1 Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodecomparedocumentposition17 2 Status error 3 Message Line 104: TypeError 2 Status Success -
trunk/LayoutTests/dom/xhtml/level3/core/nodecomparedocumentposition18-expected.txt
r33979 r35143 1 1 Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodecomparedocumentposition18 2 Status error 3 Message Line 107: TypeError 2 Status Success 4 3 T1T2 -
trunk/LayoutTests/dom/xhtml/level3/core/nodecomparedocumentposition19-expected.txt
r33979 r35143 1 1 Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodecomparedocumentposition19 2 Status error 3 Message Line 116: TypeError 2 Status Success -
trunk/LayoutTests/dom/xhtml/level3/core/nodecomparedocumentposition20-expected.txt
r33979 r35143 1 1 Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodecomparedocumentposition20 2 Status error 3 Message Line 109: TypeError 2 Status Success -
trunk/LayoutTests/dom/xhtml/level3/core/nodecomparedocumentposition21-expected.txt
r33979 r35143 1 1 Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodecomparedocumentposition21 2 Status error 3 Message Line 112: TypeError 2 Status Success -
trunk/LayoutTests/dom/xhtml/level3/core/nodecomparedocumentposition25-expected.txt
r33979 r35143 1 1 Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodecomparedocumentposition25 2 Status error 3 Message Line 105: TypeError 2 Status Success -
trunk/LayoutTests/dom/xhtml/level3/core/nodecomparedocumentposition30-expected.txt
r33979 r35143 1 1 Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodecomparedocumentposition30 2 Status error 3 Message Line 104: TypeError 2 Status Success -
trunk/LayoutTests/dom/xhtml/level3/core/nodecomparedocumentposition31-expected.txt
r33979 r35143 1 1 Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodecomparedocumentposition31 2 Status error 3 Message Line 109: TypeError 2 Status Success -
trunk/LayoutTests/dom/xhtml/level3/core/nodecomparedocumentposition32-expected.txt
r33979 r35143 1 1 Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodecomparedocumentposition32 2 Status error 3 Message Line 106: TypeError 2 Status Success -
trunk/LayoutTests/dom/xhtml/level3/core/nodecomparedocumentposition33-expected.txt
r33979 r35143 1 1 Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodecomparedocumentposition33 2 2 Status error 3 Message Line 1 09: TypeError3 Message Line 116: ReferenceError -
trunk/LayoutTests/dom/xhtml/level3/core/nodecomparedocumentposition34-expected.txt
r33979 r35143 1 1 Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodecomparedocumentposition34 2 Status error 3 Message Line 110: TypeError 2 Status Success -
trunk/LayoutTests/dom/xhtml/level3/core/nodecomparedocumentposition35-expected.txt
r33979 r35143 1 1 Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodecomparedocumentposition35 2 Status error 3 Message Line 103: TypeError 2 Status Success -
trunk/LayoutTests/dom/xhtml/level3/core/nodecomparedocumentposition36-expected.txt
r33979 r35143 1 1 Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodecomparedocumentposition36 2 Status error 3 Message Line 108: TypeError 2 Status Success -
trunk/LayoutTests/dom/xhtml/level3/core/nodecomparedocumentposition37-expected.txt
r33979 r35143 1 1 Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodecomparedocumentposition37 2 Status error 3 Message Line 107: TypeError 2 Status Success -
trunk/LayoutTests/dom/xhtml/level3/core/nodecomparedocumentposition38-expected.txt
r33979 r35143 1 1 Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodecomparedocumentposition38 2 Status error3 Message Line 106: TypeError2 Status failure 3 Message nodecomparedocumentpositionIsContainsFollowing38: assertEquals failed, actual 33, expected 20. -
trunk/LayoutTests/dom/xhtml/level3/core/nodecomparedocumentposition39-expected.txt
r33979 r35143 1 1 Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodecomparedocumentposition39 2 Status error3 Message Line 105: TypeError2 Status failure 3 Message isImplementationSpecific: assertEquals failed, actual 36, expected 32. -
trunk/LayoutTests/dom/xhtml/level3/core/nodecomparedocumentposition40-expected.txt
r33979 r35143 1 1 Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodecomparedocumentposition40 2 Status error3 Message Line 106: TypeError2 Status failure 3 Message isImplementationSpecific: assertEquals failed, actual 36, expected 32. -
trunk/WebCore/ChangeLog
r35141 r35143 1 2008-07-11 David Hyatt <hyatt@apple.com> 2 3 Implement the DOM level 3 compareDocumentPosition method on Node. 4 5 Reviewed by Darin 6 7 * dom/Node.cpp: 8 (WebCore::Node::compareDocumentPosition): 9 * dom/Node.h: 10 * dom/Node.idl: 11 1 12 2008-07-11 Brady Eidson <beidson@apple.com> 2 13 -
trunk/WebCore/dom/Node.cpp
r35122 r35143 1771 1771 } 1772 1772 1773 unsigned short Node::compareDocumentPosition(Node* otherNode, ExceptionCode& ec) 1774 { 1775 // It is not clear what should be done if |otherNode| is 0. 1776 if (!otherNode) 1777 return DOCUMENT_POSITION_DISCONNECTED; 1778 1779 if (otherNode == this) 1780 return DOCUMENT_POSITION_EQUIVALENT; 1781 1782 Attr* attr1 = nodeType() == ATTRIBUTE_NODE ? static_cast<Attr*>(this) : 0; 1783 Attr* attr2 = otherNode->nodeType() == ATTRIBUTE_NODE ? static_cast<Attr*>(otherNode) : 0; 1784 1785 Node* start1 = attr1 ? attr1->ownerElement() : this; 1786 Node* start2 = attr2 ? attr2->ownerElement() : otherNode; 1787 1788 // If either of start1 or start2 is null, then we are disconnected, since one of the nodes is 1789 // an orphaned attribute node. 1790 if (!start1 || !start2) 1791 return DOCUMENT_POSITION_DISCONNECTED | DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC; 1792 1793 Vector<Node*, 16> chain1; 1794 Vector<Node*, 16> chain2; 1795 if (attr1) 1796 chain1.append(attr1); 1797 if (attr2) 1798 chain2.append(attr2); 1799 1800 if (attr1 && attr2 && start1 == start2 && start1) { 1801 // We are comparing two attributes on the same node. Crawl our attribute map 1802 // and see which one we hit first. 1803 NamedAttrMap* map = attr1->ownerElement()->attributes(true); 1804 unsigned length = map->length(); 1805 for (unsigned i = 0; i < length; ++i) { 1806 // If neither of the two determining nodes is a child node and nodeType is the same for both determining nodes, then an 1807 // implementation-dependent order between the determining nodes is returned. This order is stable as long as no nodes of 1808 // the same nodeType are inserted into or removed from the direct container. This would be the case, for example, 1809 // when comparing two attributes of the same element, and inserting or removing additional attributes might change 1810 // the order between existing attributes. 1811 Attribute* attr = map->attributeItem(i); 1812 if (attr1->attr() == attr) 1813 return DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC | DOCUMENT_POSITION_FOLLOWING; 1814 if (attr2->attr() == attr) 1815 return DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC | DOCUMENT_POSITION_PRECEDING; 1816 } 1817 1818 ASSERT_NOT_REACHED(); 1819 return DOCUMENT_POSITION_DISCONNECTED; 1820 } 1821 1822 // If one node is in the document and the other is not, we must be disconnected. 1823 // If the nodes have different owning documents, they must be disconnected. Note that we avoid 1824 // comparing Attr nodes here, since they return false from inDocument() all the time (which seems like a bug). 1825 if (start1->inDocument() != start2->inDocument() || 1826 start1->document() != start2->document()) 1827 return DOCUMENT_POSITION_DISCONNECTED | DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC; 1828 1829 // We need to find a common ancestor container, and then compare the indices of the two immediate children. 1830 Node* current; 1831 for (current = start1; current; current = current->parentNode()) 1832 chain1.append(current); 1833 for (current = start2; current; current = current->parentNode()) 1834 chain2.append(current); 1835 1836 // Walk the two chains backwards and look for the first difference. 1837 unsigned index1 = chain1.size(); 1838 unsigned index2 = chain2.size(); 1839 for (unsigned i = std::min(index1, index2); i; --i) { 1840 Node* child1 = chain1[--index1]; 1841 Node* child2 = chain2[--index2]; 1842 if (child1 != child2) { 1843 // If one of the children is an attribute, it wins. 1844 if (child1->nodeType() == ATTRIBUTE_NODE) 1845 return DOCUMENT_POSITION_FOLLOWING; 1846 if (child2->nodeType() == ATTRIBUTE_NODE) 1847 return DOCUMENT_POSITION_PRECEDING; 1848 1849 // Otherwise we need to see which node occurs first. Crawl backwards from child2 looking for child1. 1850 for (Node* child = child2->previousSibling(); child; child = child->previousSibling()) { 1851 if (child == child1) 1852 return DOCUMENT_POSITION_FOLLOWING; 1853 } 1854 return DOCUMENT_POSITION_PRECEDING; 1855 } 1856 } 1857 1858 // There was no difference between the two parent chains, i.e., one was a subset of the other. The shorter 1859 // chain is the ancestor. 1860 return index1 < index2 ? 1861 DOCUMENT_POSITION_FOLLOWING | DOCUMENT_POSITION_CONTAINED_BY : 1862 DOCUMENT_POSITION_PRECEDING | DOCUMENT_POSITION_CONTAINS; 1863 } 1864 1773 1865 #ifndef NDEBUG 1774 1866 -
trunk/WebCore/dom/Node.h
r35122 r35143 64 64 enum StyleChangeType { NoStyleChange, InlineStyleChange, FullStyleChange }; 65 65 66 const unsigned short DOCUMENT_POSITION_EQUIVALENT = 0x00; 67 const unsigned short DOCUMENT_POSITION_DISCONNECTED = 0x01; 68 const unsigned short DOCUMENT_POSITION_PRECEDING = 0x02; 69 const unsigned short DOCUMENT_POSITION_FOLLOWING = 0x04; 70 const unsigned short DOCUMENT_POSITION_CONTAINS = 0x08; 71 const unsigned short DOCUMENT_POSITION_CONTAINED_BY = 0x10; 72 const unsigned short DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20; 73 66 74 // this class implements nodes, which can have a parent but no children: 67 75 class Node : public TreeShared<Node> { … … 83 91 XPATH_NAMESPACE_NODE = 13 84 92 }; 85 93 86 94 static bool isSupported(const String& feature, const String& version); 87 95 … … 475 483 PassRefPtr<NodeList> querySelectorAll(const String& selectors, ExceptionCode&); 476 484 485 unsigned short compareDocumentPosition(Node*, ExceptionCode&); 486 477 487 private: // members 478 488 DocPtr<Document> m_document; -
trunk/WebCore/dom/Node.idl
r34139 r35143 102 102 [ConvertNullStringTo=Null] DOMString lookupNamespaceURI(in [ConvertNullToNullString] DOMString prefix); 103 103 104 #if 0105 104 // DocumentPosition 106 105 const unsigned short DOCUMENT_POSITION_DISCONNECTED = 0x01; … … 114 113 raises(DOMException); 115 114 115 #if 0 116 116 DOMObject getFeature(in DOMString feature, 117 117 in DOMString version);
Note: See TracChangeset
for help on using the changeset viewer.