Title: [203713] trunk
Revision
203713
Author
cdu...@apple.com
Date
2016-07-25 22:46:53 -0700 (Mon, 25 Jul 2016)

Log Message

Second parameter to Range.setStart() / setEnd() should be mandatory
https://bugs.webkit.org/show_bug.cgi?id=160184

Reviewed by Ryosuke Niwa.

LayoutTests/imported/w3c:

Rebaseline W3C test now that more checks are passing.

* web-platform-tests/dom/interfaces-expected.txt:

Source/WebCore:

Second parameter to Range.setStart() / setEnd() should be mandatory:
- https://dom.spec.whatwg.org/#interface-range

Also use "unsigned long" instead of "long" type for the parameter,
as per the specification.

Firefox and Chrome agree with the specification.

No new tests, rebaselined existing test.

* dom/Range.cpp:
(WebCore::Range::setStart):
(WebCore::Range::setEnd):
(WebCore::Range::checkNodeWOffset):
* dom/Range.h:
* dom/Range.idl:
* dom/RangeBoundaryPoint.h:
(WebCore::RangeBoundaryPoint::set):

LayoutTests:

Update tests to reflect behavior change.

* editing/deleting/delete-uneditable-style.html:
* fast/dom/non-numeric-values-numeric-parameters-expected.txt:
* fast/dom/script-tests/non-numeric-values-numeric-parameters.js:
* fast/regions/simplified-layout-no-regions.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (203712 => 203713)


--- trunk/LayoutTests/ChangeLog	2016-07-26 05:27:51 UTC (rev 203712)
+++ trunk/LayoutTests/ChangeLog	2016-07-26 05:46:53 UTC (rev 203713)
@@ -1,3 +1,17 @@
+2016-07-25  Chris Dumez  <cdu...@apple.com>
+
+        Second parameter to Range.setStart() / setEnd() should be mandatory
+        https://bugs.webkit.org/show_bug.cgi?id=160184
+
+        Reviewed by Ryosuke Niwa.
+
+        Update tests to reflect behavior change.
+
+        * editing/deleting/delete-uneditable-style.html:
+        * fast/dom/non-numeric-values-numeric-parameters-expected.txt:
+        * fast/dom/script-tests/non-numeric-values-numeric-parameters.js:
+        * fast/regions/simplified-layout-no-regions.html:
+
 2016-07-25  Nan Wang  <n_w...@apple.com>
 
         AX: Expose autoFillButtonType to accessibility

Modified: trunk/LayoutTests/editing/deleting/delete-uneditable-style.html (203712 => 203713)


--- trunk/LayoutTests/editing/deleting/delete-uneditable-style.html	2016-07-26 05:27:51 UTC (rev 203712)
+++ trunk/LayoutTests/editing/deleting/delete-uneditable-style.html	2016-07-26 05:46:53 UTC (rev 203713)
@@ -19,7 +19,7 @@
 function $(id) { return document.getElementById(id); }
 
 var range = document.createRange();
-range.setStart($('start'));
+range.setStart($('start'), 0);
 range.setEnd($('end'), NaN);
 
 getSelection().addRange(range);

Modified: trunk/LayoutTests/fast/dom/non-numeric-values-numeric-parameters-expected.txt (203712 => 203713)


--- trunk/LayoutTests/fast/dom/non-numeric-values-numeric-parameters-expected.txt	2016-07-26 05:27:51 UTC (rev 203712)
+++ trunk/LayoutTests/fast/dom/non-numeric-values-numeric-parameters-expected.txt	2016-07-26 05:46:53 UTC (rev 203713)
@@ -51,8 +51,8 @@
 PASS nonNumericPolicy('document.body.attributes.item(x)') is 'any type allowed'
 PASS nonNumericPolicy('document.createNodeIterator(document, x, null, false)') is 'any type allowed'
 PASS nonNumericPolicy('document.getElementsByTagName("div").item(x)') is 'any type allowed (but not omitted)'
-PASS nonNumericPolicy('document.createRange().setStart(document, x)') is 'any type allowed'
-PASS nonNumericPolicy('document.createRange().setEnd(document, x)') is 'any type allowed'
+PASS nonNumericPolicy('document.createRange().setStart(document, x)') is 'any type allowed (but not omitted)'
+PASS nonNumericPolicy('document.createRange().setEnd(document, x)') is 'any type allowed (but not omitted)'
 PASS nonNumericPolicy('document.createRange().comparePoint(document, x)') is 'any type allowed'
 PASS nonNumericPolicy('document.createRange().isPointInRange(document, x)') is 'any type allowed'
 PASS nonNumericPolicy('getSelection().collapse(document, x)') is 'any type allowed'

Modified: trunk/LayoutTests/fast/dom/script-tests/non-numeric-values-numeric-parameters.js (203712 => 203713)


--- trunk/LayoutTests/fast/dom/script-tests/non-numeric-values-numeric-parameters.js	2016-07-26 05:27:51 UTC (rev 203712)
+++ trunk/LayoutTests/fast/dom/script-tests/non-numeric-values-numeric-parameters.js	2016-07-26 05:46:53 UTC (rev 203713)
@@ -303,8 +303,8 @@
 
 // Range
 
-shouldBe("nonNumericPolicy('document.createRange().setStart(document, x)')", "'any type allowed'");
-shouldBe("nonNumericPolicy('document.createRange().setEnd(document, x)')", "'any type allowed'");
+shouldBe("nonNumericPolicy('document.createRange().setStart(document, x)')", "'any type allowed (but not omitted)'");
+shouldBe("nonNumericPolicy('document.createRange().setEnd(document, x)')", "'any type allowed (but not omitted)'");
 shouldBe("nonNumericPolicy('document.createRange().comparePoint(document, x)')", "'any type allowed'");
 shouldBe("nonNumericPolicy('document.createRange().isPointInRange(document, x)')", "'any type allowed'");
 

Modified: trunk/LayoutTests/fast/regions/simplified-layout-no-regions.html (203712 => 203713)


--- trunk/LayoutTests/fast/regions/simplified-layout-no-regions.html	2016-07-26 05:27:51 UTC (rev 203712)
+++ trunk/LayoutTests/fast/regions/simplified-layout-no-regions.html	2016-07-26 05:46:53 UTC (rev 203713)
@@ -34,11 +34,11 @@
 
             document.body.offsetParent;
             var range = document.createRange();
-            range.setStart(document.getElementById("start"));
-            range.setEnd(document.getElementById("start"));
+            range.setStart(document.getElementById("start"), 0);
+            range.setEnd(document.getElementById("start"), 0);
             range.surroundContents(document.getElementById("third"));
             range.setStart(document.getElementById("second"), 1);
-            range.setEnd(document.getElementById("end"));
+            range.setEnd(document.getElementById("end"), 0);
             range.deleteContents();
             document.body.offsetParent;
 

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (203712 => 203713)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2016-07-26 05:27:51 UTC (rev 203712)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2016-07-26 05:46:53 UTC (rev 203713)
@@ -1,5 +1,16 @@
 2016-07-25  Chris Dumez  <cdu...@apple.com>
 
+        Second parameter to Range.setStart() / setEnd() should be mandatory
+        https://bugs.webkit.org/show_bug.cgi?id=160184
+
+        Reviewed by Ryosuke Niwa.
+
+        Rebaseline W3C test now that more checks are passing.
+
+        * web-platform-tests/dom/interfaces-expected.txt:
+
+2016-07-25  Chris Dumez  <cdu...@apple.com>
+
         DOMTokenList.prototype.toString should be enumerable
         https://bugs.webkit.org/show_bug.cgi?id=160182
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/interfaces-expected.txt (203712 => 203713)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/interfaces-expected.txt	2016-07-26 05:27:51 UTC (rev 203712)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/interfaces-expected.txt	2016-07-26 05:46:53 UTC (rev 203713)
@@ -1291,8 +1291,8 @@
 PASS Range interface: attribute endOffset 
 PASS Range interface: attribute collapsed 
 PASS Range interface: attribute commonAncestorContainer 
-FAIL Range interface: operation setStart(Node,unsigned long) assert_equals: property has wrong .length expected 2 but got 1
-FAIL Range interface: operation setEnd(Node,unsigned long) assert_equals: property has wrong .length expected 2 but got 1
+PASS Range interface: operation setStart(Node,unsigned long) 
+PASS Range interface: operation setEnd(Node,unsigned long) 
 PASS Range interface: operation setStartBefore(Node) 
 PASS Range interface: operation setStartAfter(Node) 
 PASS Range interface: operation setEndBefore(Node) 
@@ -1329,13 +1329,9 @@
 PASS Range interface: document.createRange() must inherit property "collapsed" with the proper type (4) 
 PASS Range interface: document.createRange() must inherit property "commonAncestorContainer" with the proper type (5) 
 PASS Range interface: document.createRange() must inherit property "setStart" with the proper type (6) 
-FAIL Range interface: calling setStart(Node,unsigned long) on document.createRange() with too few arguments must throw TypeError assert_throws: Called with 1 arguments function "function () {
-            fn.apply(obj, args);
-        }" did not throw
+PASS Range interface: calling setStart(Node,unsigned long) on document.createRange() with too few arguments must throw TypeError 
 PASS Range interface: document.createRange() must inherit property "setEnd" with the proper type (7) 
-FAIL Range interface: calling setEnd(Node,unsigned long) on document.createRange() with too few arguments must throw TypeError assert_throws: Called with 1 arguments function "function () {
-            fn.apply(obj, args);
-        }" did not throw
+PASS Range interface: calling setEnd(Node,unsigned long) on document.createRange() with too few arguments must throw TypeError 
 PASS Range interface: document.createRange() must inherit property "setStartBefore" with the proper type (8) 
 PASS Range interface: calling setStartBefore(Node) on document.createRange() with too few arguments must throw TypeError 
 PASS Range interface: document.createRange() must inherit property "setStartAfter" with the proper type (9) 
@@ -1384,13 +1380,9 @@
 PASS Range interface: detachedRange must inherit property "collapsed" with the proper type (4) 
 PASS Range interface: detachedRange must inherit property "commonAncestorContainer" with the proper type (5) 
 PASS Range interface: detachedRange must inherit property "setStart" with the proper type (6) 
-FAIL Range interface: calling setStart(Node,unsigned long) on detachedRange with too few arguments must throw TypeError assert_throws: Called with 1 arguments function "function () {
-            fn.apply(obj, args);
-        }" did not throw
+PASS Range interface: calling setStart(Node,unsigned long) on detachedRange with too few arguments must throw TypeError 
 PASS Range interface: detachedRange must inherit property "setEnd" with the proper type (7) 
-FAIL Range interface: calling setEnd(Node,unsigned long) on detachedRange with too few arguments must throw TypeError assert_throws: Called with 1 arguments function "function () {
-            fn.apply(obj, args);
-        }" did not throw
+PASS Range interface: calling setEnd(Node,unsigned long) on detachedRange with too few arguments must throw TypeError 
 PASS Range interface: detachedRange must inherit property "setStartBefore" with the proper type (8) 
 PASS Range interface: calling setStartBefore(Node) on detachedRange with too few arguments must throw TypeError 
 PASS Range interface: detachedRange must inherit property "setStartAfter" with the proper type (9) 

Modified: trunk/Source/WebCore/ChangeLog (203712 => 203713)


--- trunk/Source/WebCore/ChangeLog	2016-07-26 05:27:51 UTC (rev 203712)
+++ trunk/Source/WebCore/ChangeLog	2016-07-26 05:46:53 UTC (rev 203713)
@@ -1,5 +1,31 @@
 2016-07-25  Chris Dumez  <cdu...@apple.com>
 
+        Second parameter to Range.setStart() / setEnd() should be mandatory
+        https://bugs.webkit.org/show_bug.cgi?id=160184
+
+        Reviewed by Ryosuke Niwa.
+
+        Second parameter to Range.setStart() / setEnd() should be mandatory:
+        - https://dom.spec.whatwg.org/#interface-range
+
+        Also use "unsigned long" instead of "long" type for the parameter,
+        as per the specification.
+
+        Firefox and Chrome agree with the specification.
+
+        No new tests, rebaselined existing test.
+
+        * dom/Range.cpp:
+        (WebCore::Range::setStart):
+        (WebCore::Range::setEnd):
+        (WebCore::Range::checkNodeWOffset):
+        * dom/Range.h:
+        * dom/Range.idl:
+        * dom/RangeBoundaryPoint.h:
+        (WebCore::RangeBoundaryPoint::set):
+
+2016-07-25  Chris Dumez  <cdu...@apple.com>
+
         DOMTokenList.prototype.toString should be enumerable
         https://bugs.webkit.org/show_bug.cgi?id=160182
 

Modified: trunk/Source/WebCore/dom/Range.cpp (203712 => 203713)


--- trunk/Source/WebCore/dom/Range.cpp	2016-07-26 05:27:51 UTC (rev 203712)
+++ trunk/Source/WebCore/dom/Range.cpp	2016-07-26 05:46:53 UTC (rev 203713)
@@ -160,7 +160,7 @@
     return startRootContainer != endRootContainer || (Range::compareBoundaryPoints(start, end, ASSERT_NO_EXCEPTION) > 0);
 }
 
-void Range::setStart(Ref<Node>&& refNode, int offset, ExceptionCode& ec)
+void Range::setStart(Ref<Node>&& refNode, unsigned offset, ExceptionCode& ec)
 {
     bool didMoveDocument = false;
     if (&refNode->document() != &ownerDocument()) {
@@ -179,7 +179,7 @@
         collapse(true);
 }
 
-void Range::setEnd(Ref<Node>&& refNode, int offset, ExceptionCode& ec)
+void Range::setEnd(Ref<Node>&& refNode, unsigned offset, ExceptionCode& ec)
 {
     bool didMoveDocument = false;
     if (&refNode->document() != &ownerDocument()) {
@@ -921,7 +921,7 @@
     // This is now a no-op as per the DOM specification.
 }
 
-Node* Range::checkNodeWOffset(Node& node, int offset, ExceptionCode& ec) const
+Node* Range::checkNodeWOffset(Node& node, unsigned offset, ExceptionCode& ec) const
 {
     switch (node.nodeType()) {
         case Node::DOCUMENT_TYPE_NODE:
@@ -931,7 +931,7 @@
         case Node::COMMENT_NODE:
         case Node::TEXT_NODE:
         case Node::PROCESSING_INSTRUCTION_NODE:
-            if (static_cast<unsigned>(offset) > downcast<CharacterData>(node).length())
+            if (offset > downcast<CharacterData>(node).length())
                 ec = INDEX_SIZE_ERR;
             return nullptr;
         case Node::ATTRIBUTE_NODE:

Modified: trunk/Source/WebCore/dom/Range.h (203712 => 203713)


--- trunk/Source/WebCore/dom/Range.h	2016-07-26 05:27:51 UTC (rev 203712)
+++ trunk/Source/WebCore/dom/Range.h	2016-07-26 05:46:53 UTC (rev 203713)
@@ -66,8 +66,8 @@
 
     Node* commonAncestorContainer() const { return commonAncestorContainer(&startContainer(), &endContainer()); }
     WEBCORE_EXPORT static Node* commonAncestorContainer(Node* containerA, Node* containerB);
-    WEBCORE_EXPORT void setStart(Ref<Node>&& container, int offset, ExceptionCode& = ASSERT_NO_EXCEPTION);
-    WEBCORE_EXPORT void setEnd(Ref<Node>&& container, int offset, ExceptionCode& = ASSERT_NO_EXCEPTION);
+    WEBCORE_EXPORT void setStart(Ref<Node>&& container, unsigned offset, ExceptionCode& = ASSERT_NO_EXCEPTION);
+    WEBCORE_EXPORT void setEnd(Ref<Node>&& container, unsigned offset, ExceptionCode& = ASSERT_NO_EXCEPTION);
     WEBCORE_EXPORT void collapse(bool toStart);
     WEBCORE_EXPORT bool isPointInRange(Node& refNode, int offset, ExceptionCode&);
     short comparePoint(Node& refNode, int offset, ExceptionCode&) const;
@@ -159,7 +159,7 @@
 
     void setDocument(Document&);
 
-    Node* checkNodeWOffset(Node&, int offset, ExceptionCode&) const;
+    Node* checkNodeWOffset(Node&, unsigned offset, ExceptionCode&) const;
 
     enum ActionType { Delete, Extract, Clone };
     RefPtr<DocumentFragment> processContents(ActionType, ExceptionCode&);

Modified: trunk/Source/WebCore/dom/Range.idl (203712 => 203713)


--- trunk/Source/WebCore/dom/Range.idl	2016-07-26 05:27:51 UTC (rev 203712)
+++ trunk/Source/WebCore/dom/Range.idl	2016-07-26 05:46:53 UTC (rev 203713)
@@ -33,8 +33,14 @@
     readonly attribute boolean collapsed;
     readonly attribute Node commonAncestorContainer;
 
-    [ObjCLegacyUnnamedParameters, RaisesException] void setStart(Node refNode, optional long offset = 0);
-    [ObjCLegacyUnnamedParameters, RaisesException] void setEnd(Node refNode, optional long offset = 0);
+#if defined(LANGUAGE_JAVASCRIPT) || LANGUAGE_JAVASCRIPT
+    [RaisesException] void setStart(Node refNode, unsigned long offset);
+    [RaisesException] void setEnd(Node refNode, unsigned long offset);
+#else
+    [ObjCLegacyUnnamedParameters, RaisesException] void setStart(Node refNode, long offset);
+    [ObjCLegacyUnnamedParameters, RaisesException] void setEnd(Node refNode, long offset);
+#endif
+
     [RaisesException] void setStartBefore(Node refNode);
     [RaisesException] void setStartAfter(Node refNode);
     [RaisesException] void setEndBefore(Node refNode);

Modified: trunk/Source/WebCore/dom/RangeBoundaryPoint.h (203712 => 203713)


--- trunk/Source/WebCore/dom/RangeBoundaryPoint.h	2016-07-26 05:27:51 UTC (rev 203712)
+++ trunk/Source/WebCore/dom/RangeBoundaryPoint.h	2016-07-26 05:46:53 UTC (rev 203713)
@@ -45,7 +45,7 @@
 
     void clear();
 
-    void set(Ref<Node>&& container, int offset, Node* childBefore);
+    void set(Ref<Node>&& container, unsigned offset, Node* childBefore);
     void setOffset(int offset);
 
     void setToBeforeChild(Node&);
@@ -116,9 +116,8 @@
     m_childBeforeBoundary = nullptr;
 }
 
-inline void RangeBoundaryPoint::set(Ref<Node>&& container, int offset, Node* childBefore)
+inline void RangeBoundaryPoint::set(Ref<Node>&& container, unsigned offset, Node* childBefore)
 {
-    ASSERT(offset >= 0);
     ASSERT(childBefore == (offset ? container->traverseToChildAt(offset - 1) : 0));
     m_containerNode = WTFMove(container);
     m_offsetInContainer = offset;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to