Changeset 203601 in webkit
- Timestamp:
- Jul 22, 2016 9:01:48 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/imported/w3c/ChangeLog
r203552 r203601 1 2016-07-22 Chris Dumez <cdumez@apple.com> 2 3 Parameter to Node.compareDocumentPosition() should be mandatory and non-nullable 4 https://bugs.webkit.org/show_bug.cgi?id=160071 5 6 Reviewed by Ryosuke Niwa. 7 8 Rebaseline several W3C tests now that more checks are passing. 9 10 * web-platform-tests/dom/interfaces-expected.txt: 11 * web-platform-tests/html/dom/interfaces-expected.txt: 12 1 13 2016-07-21 Chris Dumez <cdumez@apple.com> 2 14 -
trunk/LayoutTests/imported/w3c/web-platform-tests/dom/interfaces-expected.txt
r203552 r203601 231 231 PASS Node interface: constant DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC on interface object 232 232 PASS Node interface: constant DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC on interface prototype object 233 FAIL Node interface: operation compareDocumentPosition(Node) assert_equals: property has wrong .length expected 1 but got 0 233 PASS Node interface: operation compareDocumentPosition(Node) 234 234 FAIL Node interface: operation contains(Node) assert_equals: property has wrong .length expected 1 but got 0 235 235 FAIL Node interface: operation lookupPrefix(DOMString) assert_equals: property has wrong .length expected 1 but got 0 … … 384 384 PASS Node interface: new Document() must inherit property "DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC" with the proper type (36) 385 385 PASS Node interface: new Document() must inherit property "compareDocumentPosition" with the proper type (37) 386 FAIL Node interface: calling compareDocumentPosition(Node) on new Document() with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () { 387 fn.apply(obj, args); 388 }" did not throw 386 PASS Node interface: calling compareDocumentPosition(Node) on new Document() with too few arguments must throw TypeError 389 387 PASS Node interface: new Document() must inherit property "contains" with the proper type (38) 390 388 FAIL Node interface: calling contains(Node) on new Document() with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () { … … 526 524 PASS Node interface: xmlDoc must inherit property "DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC" with the proper type (36) 527 525 PASS Node interface: xmlDoc must inherit property "compareDocumentPosition" with the proper type (37) 528 FAIL Node interface: calling compareDocumentPosition(Node) on xmlDoc with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () { 529 fn.apply(obj, args); 530 }" did not throw 526 PASS Node interface: calling compareDocumentPosition(Node) on xmlDoc with too few arguments must throw TypeError 531 527 PASS Node interface: xmlDoc must inherit property "contains" with the proper type (38) 532 528 FAIL Node interface: calling contains(Node) on xmlDoc with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () { … … 646 642 PASS Node interface: document.doctype must inherit property "DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC" with the proper type (36) 647 643 PASS Node interface: document.doctype must inherit property "compareDocumentPosition" with the proper type (37) 648 FAIL Node interface: calling compareDocumentPosition(Node) on document.doctype with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () { 649 fn.apply(obj, args); 650 }" did not throw 644 PASS Node interface: calling compareDocumentPosition(Node) on document.doctype with too few arguments must throw TypeError 651 645 PASS Node interface: document.doctype must inherit property "contains" with the proper type (38) 652 646 FAIL Node interface: calling contains(Node) on document.doctype with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () { … … 754 748 PASS Node interface: document.createDocumentFragment() must inherit property "DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC" with the proper type (36) 755 749 PASS Node interface: document.createDocumentFragment() must inherit property "compareDocumentPosition" with the proper type (37) 756 FAIL Node interface: calling compareDocumentPosition(Node) on document.createDocumentFragment() with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () { 757 fn.apply(obj, args); 758 }" did not throw 750 PASS Node interface: calling compareDocumentPosition(Node) on document.createDocumentFragment() with too few arguments must throw TypeError 759 751 PASS Node interface: document.createDocumentFragment() must inherit property "contains" with the proper type (38) 760 752 FAIL Node interface: calling contains(Node) on document.createDocumentFragment() with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () { … … 971 963 PASS Node interface: element must inherit property "DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC" with the proper type (36) 972 964 PASS Node interface: element must inherit property "compareDocumentPosition" with the proper type (37) 973 FAIL Node interface: calling compareDocumentPosition(Node) on element with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () { 974 fn.apply(obj, args); 975 }" did not throw 965 PASS Node interface: calling compareDocumentPosition(Node) on element with too few arguments must throw TypeError 976 966 PASS Node interface: element must inherit property "contains" with the proper type (38) 977 967 FAIL Node interface: calling contains(Node) on element with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () { … … 1144 1134 PASS Node interface: document.createTextNode("abc") must inherit property "DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC" with the proper type (36) 1145 1135 PASS Node interface: document.createTextNode("abc") must inherit property "compareDocumentPosition" with the proper type (37) 1146 FAIL Node interface: calling compareDocumentPosition(Node) on document.createTextNode("abc") with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () { 1147 fn.apply(obj, args); 1148 }" did not throw 1136 PASS Node interface: calling compareDocumentPosition(Node) on document.createTextNode("abc") with too few arguments must throw TypeError 1149 1137 PASS Node interface: document.createTextNode("abc") must inherit property "contains" with the proper type (38) 1150 1138 FAIL Node interface: calling contains(Node) on document.createTextNode("abc") with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () { … … 1250 1238 PASS Node interface: xmlDoc.createProcessingInstruction("abc", "def") must inherit property "DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC" with the proper type (36) 1251 1239 PASS Node interface: xmlDoc.createProcessingInstruction("abc", "def") must inherit property "compareDocumentPosition" with the proper type (37) 1252 FAIL Node interface: calling compareDocumentPosition(Node) on xmlDoc.createProcessingInstruction("abc", "def") with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () { 1253 fn.apply(obj, args); 1254 }" did not throw 1240 PASS Node interface: calling compareDocumentPosition(Node) on xmlDoc.createProcessingInstruction("abc", "def") with too few arguments must throw TypeError 1255 1241 PASS Node interface: xmlDoc.createProcessingInstruction("abc", "def") must inherit property "contains" with the proper type (38) 1256 1242 FAIL Node interface: calling contains(Node) on xmlDoc.createProcessingInstruction("abc", "def") with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () { … … 1354 1340 PASS Node interface: document.createComment("abc") must inherit property "DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC" with the proper type (36) 1355 1341 PASS Node interface: document.createComment("abc") must inherit property "compareDocumentPosition" with the proper type (37) 1356 FAIL Node interface: calling compareDocumentPosition(Node) on document.createComment("abc") with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () { 1357 fn.apply(obj, args); 1358 }" did not throw 1342 PASS Node interface: calling compareDocumentPosition(Node) on document.createComment("abc") with too few arguments must throw TypeError 1359 1343 PASS Node interface: document.createComment("abc") must inherit property "contains" with the proper type (38) 1360 1344 FAIL Node interface: calling contains(Node) on document.createComment("abc") with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () { -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt
r203552 r203601 365 365 PASS Node interface: iframe.contentDocument must inherit property "DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC" with the proper type (34) 366 366 PASS Node interface: iframe.contentDocument must inherit property "compareDocumentPosition" with the proper type (35) 367 FAIL Node interface: calling compareDocumentPosition(Node) on iframe.contentDocument with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () { 368 fn.apply(obj, args); 369 }" did not throw 367 PASS Node interface: calling compareDocumentPosition(Node) on iframe.contentDocument with too few arguments must throw TypeError 370 368 PASS Node interface: iframe.contentDocument must inherit property "contains" with the proper type (36) 371 369 FAIL Node interface: calling contains(Node) on iframe.contentDocument with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () { … … 643 641 PASS Node interface: new Document() must inherit property "DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC" with the proper type (34) 644 642 PASS Node interface: new Document() must inherit property "compareDocumentPosition" with the proper type (35) 645 FAIL Node interface: calling compareDocumentPosition(Node) on new Document() with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () { 646 fn.apply(obj, args); 647 }" did not throw 643 PASS Node interface: calling compareDocumentPosition(Node) on new Document() with too few arguments must throw TypeError 648 644 PASS Node interface: new Document() must inherit property "contains" with the proper type (36) 649 645 FAIL Node interface: calling contains(Node) on new Document() with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () { … … 924 920 PASS Node interface: document.implementation.createDocument(null, "", null) must inherit property "DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC" with the proper type (34) 925 921 PASS Node interface: document.implementation.createDocument(null, "", null) must inherit property "compareDocumentPosition" with the proper type (35) 926 FAIL Node interface: calling compareDocumentPosition(Node) on document.implementation.createDocument(null, "", null) with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () { 927 fn.apply(obj, args); 928 }" did not throw 922 PASS Node interface: calling compareDocumentPosition(Node) on document.implementation.createDocument(null, "", null) with too few arguments must throw TypeError 929 923 PASS Node interface: document.implementation.createDocument(null, "", null) must inherit property "contains" with the proper type (36) 930 924 FAIL Node interface: calling contains(Node) on document.implementation.createDocument(null, "", null) with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () { … … 1328 1322 PASS Node interface: document.createElement("noscript") must inherit property "DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC" with the proper type (34) 1329 1323 PASS Node interface: document.createElement("noscript") must inherit property "compareDocumentPosition" with the proper type (35) 1330 FAIL Node interface: calling compareDocumentPosition(Node) on document.createElement("noscript") with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () { 1331 fn.apply(obj, args); 1332 }" did not throw 1324 PASS Node interface: calling compareDocumentPosition(Node) on document.createElement("noscript") with too few arguments must throw TypeError 1333 1325 PASS Node interface: document.createElement("noscript") must inherit property "contains" with the proper type (36) 1334 1326 FAIL Node interface: calling contains(Node) on document.createElement("noscript") with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () { -
trunk/Source/WebCore/ChangeLog
r203599 r203601 1 2016-07-22 Chris Dumez <cdumez@apple.com> 2 3 Parameter to Node.compareDocumentPosition() should be mandatory and non-nullable 4 https://bugs.webkit.org/show_bug.cgi?id=160071 5 6 Reviewed by Ryosuke Niwa. 7 8 9 Parameter to Node.compareDocumentPosition() should be mandatory and 10 non-nullable: 11 - https://dom.spec.whatwg.org/#interface-node 12 13 Firefox and Chrome agree with the specification so the compatibility 14 risk should be low. Also, it does not make much sense to call this 15 operation without parameter. 16 17 No new tests, rebaselined existing tests. 18 19 * accessibility/AccessibilityObject.cpp: 20 (WebCore::rangeClosestToRange): 21 * dom/AuthorStyleSheets.cpp: 22 (WebCore::AuthorStyleSheets::addStyleSheetCandidateNode): 23 * dom/Node.cpp: 24 (WebCore::compareDetachedElementsPosition): 25 (WebCore::Node::compareDocumentPosition): 26 * dom/Node.h: 27 * dom/Node.idl: 28 * dom/Position.h: 29 (WebCore::operator<): 30 * html/HTMLFormElement.cpp: 31 (WebCore::HTMLFormElement::formElementIndexWithFormAttribute): 32 (WebCore::HTMLFormElement::formElementIndex): 33 * rendering/RenderNamedFlowThread.cpp: 34 (WebCore::RenderNamedFlowThread::nextRendererForElement): 35 (WebCore::compareRenderNamedFlowFragments): 36 (WebCore::RenderNamedFlowThread::registerNamedFlowContentElement): 37 1 38 2016-07-22 Konstantin Tokarev <annulen@yandex.ru> 2 39 -
trunk/Source/WebCore/accessibility/AccessibilityObject.cpp
r203338 r203601 647 647 // The treeScope for shadow nodes may not be the same scope as another element in a document. 648 648 // Comparisons may fail in that case, which are expected behavior and should not assert. 649 if (afterRange && ( (afterRange->startPosition().anchorNode()->compareDocumentPosition(referenceRange->endPosition().anchorNode()) & Node::DOCUMENT_POSITION_DISCONNECTED) == Node::DOCUMENT_POSITION_DISCONNECTED))649 if (afterRange && (referenceRange->endPosition().isNull() || ((afterRange->startPosition().anchorNode()->compareDocumentPosition(*referenceRange->endPosition().anchorNode()) & Node::DOCUMENT_POSITION_DISCONNECTED) == Node::DOCUMENT_POSITION_DISCONNECTED))) 650 650 return nullptr; 651 651 ASSERT(!afterRange || afterRange->startPosition() >= referenceRange->endPosition()); 652 652 653 if (beforeRange && ( (beforeRange->endPosition().anchorNode()->compareDocumentPosition(referenceRange->startPosition().anchorNode()) & Node::DOCUMENT_POSITION_DISCONNECTED) == Node::DOCUMENT_POSITION_DISCONNECTED))653 if (beforeRange && (referenceRange->startPosition().isNull() || ((beforeRange->endPosition().anchorNode()->compareDocumentPosition(*referenceRange->startPosition().anchorNode()) & Node::DOCUMENT_POSITION_DISCONNECTED) == Node::DOCUMENT_POSITION_DISCONNECTED))) 654 654 return nullptr; 655 655 ASSERT(!beforeRange || beforeRange->endPosition() <= referenceRange->startPosition()); -
trunk/Source/WebCore/dom/AuthorStyleSheets.cpp
r203324 r203601 118 118 --it; 119 119 Node* n = *it; 120 unsigned short position = n->compareDocumentPosition( &node);120 unsigned short position = n->compareDocumentPosition(node); 121 121 if (position == Node::DOCUMENT_POSITION_FOLLOWING) { 122 122 m_styleSheetCandidateNodes.insertBefore(followingNode, &node); -
trunk/Source/WebCore/dom/Node.cpp
r203303 r203601 1510 1510 } 1511 1511 1512 static inline unsigned short compareDetachedElementsPosition(Node * firstNode, Node*secondNode)1512 static inline unsigned short compareDetachedElementsPosition(Node& firstNode, Node& secondNode) 1513 1513 { 1514 1514 // If the 2 nodes are not in the same tree, return the result of adding DOCUMENT_POSITION_DISCONNECTED, … … 1518 1518 // hashes of Node pointers. 1519 1519 // See step 3 in https://dom.spec.whatwg.org/#dom-node-comparedocumentposition 1520 SHA1::Digest firstHash = hashPointer( firstNode);1521 SHA1::Digest secondHash = hashPointer( secondNode);1520 SHA1::Digest firstHash = hashPointer(&firstNode); 1521 SHA1::Digest secondHash = hashPointer(&secondNode); 1522 1522 1523 1523 unsigned short direction = memcmp(firstHash.data(), secondHash.data(), SHA1::hashSize) > 0 ? Node::DOCUMENT_POSITION_PRECEDING : Node::DOCUMENT_POSITION_FOLLOWING; … … 1526 1526 } 1527 1527 1528 unsigned short Node::compareDocumentPosition(Node* otherNode) 1529 { 1530 // It is not clear what should be done if |otherNode| is nullptr. 1531 if (!otherNode) 1532 return DOCUMENT_POSITION_DISCONNECTED; 1533 1534 if (otherNode == this) 1528 unsigned short Node::compareDocumentPosition(Node& otherNode) 1529 { 1530 if (&otherNode == this) 1535 1531 return DOCUMENT_POSITION_EQUIVALENT; 1536 1532 1537 1533 Attr* attr1 = is<Attr>(*this) ? downcast<Attr>(this) : nullptr; 1538 Attr* attr2 = is<Attr>( *otherNode) ?downcast<Attr>(otherNode) : nullptr;1534 Attr* attr2 = is<Attr>(otherNode) ? &downcast<Attr>(otherNode) : nullptr; 1539 1535 1540 1536 Node* start1 = attr1 ? attr1->ownerElement() : this; 1541 Node* start2 = attr2 ? attr2->ownerElement() : otherNode;1537 Node* start2 = attr2 ? attr2->ownerElement() : &otherNode; 1542 1538 1543 1539 // If either of start1 or start2 is null, then we are disconnected, since one of the nodes is 1544 1540 // an orphaned attribute node. 1545 1541 if (!start1 || !start2) 1546 return compareDetachedElementsPosition( this, otherNode);1542 return compareDetachedElementsPosition(*this, otherNode); 1547 1543 1548 1544 Vector<Node*, 16> chain1; … … 1577 1573 // comparing Attr nodes here, since they return false from inDocument() all the time (which seems like a bug). 1578 1574 if (start1->inDocument() != start2->inDocument() || &start1->treeScope() != &start2->treeScope()) 1579 return compareDetachedElementsPosition( this, otherNode);1575 return compareDetachedElementsPosition(*this, otherNode); 1580 1576 1581 1577 // We need to find a common ancestor container, and then compare the indices of the two immediate children. … … 1591 1587 // If the two elements don't have a common root, they're not in the same tree. 1592 1588 if (chain1[index1 - 1] != chain2[index2 - 1]) 1593 return compareDetachedElementsPosition( this, otherNode);1589 return compareDetachedElementsPosition(*this, otherNode); 1594 1590 1595 1591 // Walk the two chains backwards and look for the first difference. -
trunk/Source/WebCore/dom/Node.h
r202358 r203601 495 495 virtual bool willRespondToMouseWheelEvents(); 496 496 497 WEBCORE_EXPORT unsigned short compareDocumentPosition(Node *);497 WEBCORE_EXPORT unsigned short compareDocumentPosition(Node&); 498 498 499 499 Node* toNode() override; -
trunk/Source/WebCore/dom/Node.idl
r203552 r203601 112 112 const unsigned short DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20; 113 113 114 // FIXME: other should be neither optional nor nullable. 115 unsigned short compareDocumentPosition(optional Node? other = null); 114 unsigned short compareDocumentPosition(Node other); 116 115 117 116 // Introduced in DOM4 -
trunk/Source/WebCore/dom/Position.h
r201667 r203601 252 252 if (a.anchorNode() == b.anchorNode()) 253 253 return a.deprecatedEditingOffset() < b.deprecatedEditingOffset(); 254 return b.anchorNode()->compareDocumentPosition( a.anchorNode()) == Node::DOCUMENT_POSITION_PRECEDING;254 return b.anchorNode()->compareDocumentPosition(*a.anchorNode()) == Node::DOCUMENT_POSITION_PRECEDING; 255 255 } 256 256 -
trunk/Source/WebCore/html/HTMLFormElement.cpp
r203337 r203601 530 530 unsigned middle = left + ((right - left) / 2); 531 531 ASSERT(middle < m_associatedElementsBeforeIndex || middle >= m_associatedElementsAfterIndex); 532 position = element->compareDocumentPosition( &m_associatedElements[middle]->asHTMLElement());532 position = element->compareDocumentPosition(m_associatedElements[middle]->asHTMLElement()); 533 533 if (position & DOCUMENT_POSITION_FOLLOWING) 534 534 right = middle; … … 538 538 539 539 ASSERT(left < m_associatedElementsBeforeIndex || left >= m_associatedElementsAfterIndex); 540 position = element->compareDocumentPosition( &m_associatedElements[left]->asHTMLElement());540 position = element->compareDocumentPosition(m_associatedElements[left]->asHTMLElement()); 541 541 if (position & DOCUMENT_POSITION_FOLLOWING) 542 542 return left; … … 553 553 // for performance consideration. 554 554 if (associatedHTMLElement.hasAttributeWithoutSynchronization(formAttr)) { 555 unsigned short position = compareDocumentPosition( &associatedHTMLElement);555 unsigned short position = compareDocumentPosition(associatedHTMLElement); 556 556 if (position & DOCUMENT_POSITION_PRECEDING) { 557 557 ++m_associatedElementsBeforeIndex; -
trunk/Source/WebCore/rendering/RenderNamedFlowThread.cpp
r202358 r203601 102 102 for (auto& child : m_flowThreadChildList) { 103 103 ASSERT(!child->isAnonymous()); 104 unsigned short position = element.compareDocumentPosition(child->element()); 104 ASSERT_WITH_MESSAGE(child->element(), "Can only be null for anonymous renderers"); 105 106 unsigned short position = element.compareDocumentPosition(*child->element()); 105 107 if (position & Node::DOCUMENT_POSITION_FOLLOWING) 106 108 return child; … … 160 162 // If the regions belong to different nodes, compare their position in the DOM. 161 163 if (firstFragment->generatingElement() != secondFragment->generatingElement()) { 162 unsigned short position = firstFragment->generatingElement()->compareDocumentPosition( secondFragment->generatingElement());164 unsigned short position = firstFragment->generatingElement()->compareDocumentPosition(*secondFragment->generatingElement()); 163 165 164 166 // If the second region is contained in the first one, the first region is "less" if it's :before. … … 504 506 // Find the first content node following the new content node. 505 507 for (auto& element : m_contentElements) { 506 unsigned short position = contentElement.compareDocumentPosition( element);508 unsigned short position = contentElement.compareDocumentPosition(*element); 507 509 if (position & Node::DOCUMENT_POSITION_FOLLOWING) { 508 510 m_contentElements.insertBefore(element, &contentElement);
Note: See TracChangeset
for help on using the changeset viewer.