Title: [162601] trunk
Revision
162601
Author
commit-qu...@webkit.org
Date
2014-01-23 00:36:56 -0800 (Thu, 23 Jan 2014)

Log Message

Range should be constructable.
https://bugs.webkit.org/show_bug.cgi?id=115639

Patch by László Langó <llango.u-sze...@partner.samsung.com> on 2014-01-23
Reviewed by Ryosuke Niwa.

Source/WebCore:

http://www.w3.org/TR/2013/WD-dom-20131107/#interface-range
Now we can do `new Range()` instead of `document.createRange()`.

Backported from Blink: https://chromium.googlesource.com/chromium/blink/+/47ca40efdf58a4787aa33aa75a35778899b1c002%5E%21

Test: fast/dom/Range/range-constructor.html

* dom/Range.cpp:
(WebCore::Range::create):
* dom/Range.h:
* dom/Range.idl:

LayoutTests:

* fast/dom/Range/range-constructor-expected.txt: Added.
* fast/dom/Range/range-constructor.html: Added.
* fast/dom/dom-constructors-expected.txt:
* fast/dom/dom-constructors.html:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (162600 => 162601)


--- trunk/LayoutTests/ChangeLog	2014-01-23 08:10:47 UTC (rev 162600)
+++ trunk/LayoutTests/ChangeLog	2014-01-23 08:36:56 UTC (rev 162601)
@@ -1,3 +1,15 @@
+2014-01-23  László Langó  <llango.u-sze...@partner.samsung.com>
+
+        Range should be constructable.
+        https://bugs.webkit.org/show_bug.cgi?id=115639
+
+        Reviewed by Ryosuke Niwa.
+
+        * fast/dom/Range/range-constructor-expected.txt: Added.
+        * fast/dom/Range/range-constructor.html: Added.
+        * fast/dom/dom-constructors-expected.txt:
+        * fast/dom/dom-constructors.html:
+
 2014-01-22  Jinwoo Song  <jinwoo7.s...@samsung.com>
 
         Unreviewed EFL gardening after r162553.

Added: trunk/LayoutTests/fast/dom/Range/range-constructor-expected.txt (0 => 162601)


--- trunk/LayoutTests/fast/dom/Range/range-constructor-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/Range/range-constructor-expected.txt	2014-01-23 08:36:56 UTC (rev 162601)
@@ -0,0 +1,18 @@
+Tests that we can create instances of Range using new
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS typeof new Range is "object"
+PASS Object.prototype.toString.call(new Range) is "[object Range]"
+PASS new Range instanceof Range is true
+PASS Object.getPrototypeOf(new Range) is Range.prototype
+PASS r.toString() is "Test"
+PASS new innerWindow.Range instanceof innerWindow.Range is true
+PASS Object.getPrototypeOf(new innerWindow.Range) is innerWindow.Range.prototype
+PASS r.toString() is "Inner"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+Test
+

Added: trunk/LayoutTests/fast/dom/Range/range-constructor.html (0 => 162601)


--- trunk/LayoutTests/fast/dom/Range/range-constructor.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/Range/range-constructor.html	2014-01-23 08:36:56 UTC (rev 162601)
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<script src=""
+<div id="test-div">Test</div>
+<script>
+
+description('Tests that we can create instances of Range using new');
+
+shouldBe('typeof new Range', '"object"');
+shouldBe('Object.prototype.toString.call(new Range)', '"[object Range]"');
+shouldBeTrue('new Range instanceof Range');
+shouldBe('Object.getPrototypeOf(new Range)', 'Range.prototype');
+
+var r = new Range();
+r.selectNodeContents(document.getElementById('test-div'));
+shouldBe('r.toString()', '"Test"')
+
+var frame = document.createElement('iframe');
+document.body.appendChild(frame);
+var innerWindow = frame.contentWindow;
+var innerDocument = frame.contentDocument;
+innerDocument.body.textContent = 'Inner';
+
+shouldBeTrue('new innerWindow.Range instanceof innerWindow.Range');
+shouldBe('Object.getPrototypeOf(new innerWindow.Range)', 'innerWindow.Range.prototype');
+
+var r = new innerWindow.Range();
+r.selectNodeContents(innerDocument.body);
+shouldBe('r.toString()', '"Inner"');
+
+</script>
+<script src=""

Modified: trunk/LayoutTests/fast/dom/dom-constructors-expected.txt (162600 => 162601)


--- trunk/LayoutTests/fast/dom/dom-constructors-expected.txt	2014-01-23 08:10:47 UTC (rev 162600)
+++ trunk/LayoutTests/fast/dom/dom-constructors-expected.txt	2014-01-23 08:36:56 UTC (rev 162601)
@@ -98,7 +98,6 @@
 PASS TryAllocate('NodeList') is 'exception'
 PASS TryAllocate('Plugin') is 'exception'
 PASS TryAllocate('PluginArray') is 'exception'
-PASS TryAllocate('Range') is 'exception'
 PASS TryAllocate('Rect') is 'exception'
 PASS TryAllocate('StyleSheet') is 'exception'
 PASS TryAllocate('StyleSheetList') is 'exception'
@@ -135,6 +134,9 @@
 PASS TryAllocate('DocumentFragment') is '[object DocumentFragment]'
 PASS TryAllocate('DocumentFragment') is '[object DocumentFragment]'
 PASS TryAllocate('DocumentFragment') is '[object DocumentFragment]'
+PASS TryAllocate('Range') is '[object Range]'
+PASS TryAllocate('Range') is '[object Range]'
+PASS TryAllocate('Range') is '[object Range]'
 PASS TryAllocate('Text') is '[object Text]'
 PASS TryAllocate('Text') is '[object Text]'
 PASS TryAllocate('Text') is '[object Text]'

Modified: trunk/LayoutTests/fast/dom/dom-constructors.html (162600 => 162601)


--- trunk/LayoutTests/fast/dom/dom-constructors.html	2014-01-23 08:10:47 UTC (rev 162600)
+++ trunk/LayoutTests/fast/dom/dom-constructors.html	2014-01-23 08:36:56 UTC (rev 162601)
@@ -108,7 +108,6 @@
     'NodeList',
     'Plugin',
     'PluginArray',
-    'Range',
     'Rect',
     'StyleSheet',
     'StyleSheetList',
@@ -137,6 +136,7 @@
     'Comment',
     'DOMParser',
     'DocumentFragment',
+    'Range',
     'Text',
     'XMLHttpRequest',
     'XMLSerializer',
@@ -162,7 +162,7 @@
 function TryAllocate(node) {
     var Cons = this[node];
     if (!Cons) return 'no constructor';
-    try { return new Cons() + ''; }
+    try { return Object.prototype.toString.call(new Cons()); }
     catch (e) { return 'exception'; }
 }
 

Modified: trunk/Source/WebCore/ChangeLog (162600 => 162601)


--- trunk/Source/WebCore/ChangeLog	2014-01-23 08:10:47 UTC (rev 162600)
+++ trunk/Source/WebCore/ChangeLog	2014-01-23 08:36:56 UTC (rev 162601)
@@ -1,3 +1,22 @@
+2014-01-23  László Langó  <llango.u-sze...@partner.samsung.com>
+
+        Range should be constructable.
+        https://bugs.webkit.org/show_bug.cgi?id=115639
+
+        Reviewed by Ryosuke Niwa.
+
+        http://www.w3.org/TR/2013/WD-dom-20131107/#interface-range
+        Now we can do `new Range()` instead of `document.createRange()`.
+
+        Backported from Blink: https://chromium.googlesource.com/chromium/blink/+/47ca40efdf58a4787aa33aa75a35778899b1c002%5E%21
+
+        Test: fast/dom/Range/range-constructor.html
+
+        * dom/Range.cpp:
+        (WebCore::Range::create):
+        * dom/Range.h:
+        * dom/Range.idl:
+
 2014-01-23  ChangSeok Oh  <changseok...@collabora.com>
 
         Unreviewed build fix for gles after r162565. Add missing definitions.

Modified: trunk/Source/WebCore/dom/Range.cpp (162600 => 162601)


--- trunk/Source/WebCore/dom/Range.cpp	2014-01-23 08:10:47 UTC (rev 162600)
+++ trunk/Source/WebCore/dom/Range.cpp	2014-01-23 08:36:56 UTC (rev 162601)
@@ -104,6 +104,11 @@
     return adoptRef(new Range(ownerDocument, start.containerNode(), start.computeOffsetInContainerNode(), end.containerNode(), end.computeOffsetInContainerNode()));
 }
 
+PassRefPtr<Range> Range::create(ScriptExecutionContext& context)
+{
+    return adoptRef(new Range(toDocument(context)));
+}
+
 #if PLATFORM(IOS)
 PassRefPtr<Range> Range::create(Document& ownerDocument, const VisiblePosition& visibleStart, const VisiblePosition& visibleEnd)
 {

Modified: trunk/Source/WebCore/dom/Range.h (162600 => 162601)


--- trunk/Source/WebCore/dom/Range.h	2014-01-23 08:10:47 UTC (rev 162600)
+++ trunk/Source/WebCore/dom/Range.h	2014-01-23 08:36:56 UTC (rev 162601)
@@ -55,6 +55,7 @@
     static PassRefPtr<Range> create(Document&);
     static PassRefPtr<Range> create(Document&, PassRefPtr<Node> startContainer, int startOffset, PassRefPtr<Node> endContainer, int endOffset);
     static PassRefPtr<Range> create(Document&, const Position&, const Position&);
+    static PassRefPtr<Range> create(ScriptExecutionContext&);
 #if PLATFORM(IOS)
     // FIXME: Consider making this a static non-member, non-friend function.
     static PassRefPtr<Range> create(Document&, const VisiblePosition&, const VisiblePosition&);

Modified: trunk/Source/WebCore/dom/Range.idl (162600 => 162601)


--- trunk/Source/WebCore/dom/Range.idl	2014-01-23 08:10:47 UTC (rev 162600)
+++ trunk/Source/WebCore/dom/Range.idl	2014-01-23 08:36:56 UTC (rev 162601)
@@ -20,7 +20,9 @@
 
 // Introduced in DOM Level 2:
 [
-    ImplementationLacksVTable,
+    Constructor,
+    ConstructorCallWith=ScriptExecutionContext,
+    ImplementationLacksVTable
 ] interface Range {
 
     [GetterRaisesException] readonly attribute Node startContainer;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to