Title: [161876] trunk
Revision
161876
Author
[email protected]
Date
2014-01-13 04:52:28 -0800 (Mon, 13 Jan 2014)

Log Message

Text should be constructable.
https://bugs.webkit.org/show_bug.cgi?id=115640

Patch by László Langó <[email protected]> on 2014-01-13
Reviewed by Csaba Osztrogonác.

Source/WebCore:

http://dom.spec.whatwg.org/#interface-text
Make Text constructable so that one can do "new Text('abc')"
instead of "document.createTexte('abc')".

Backported from Blink: https://chromium.googlesource.com/chromium/blink/+/cdd5a914daf3862379a5ce4596149bd690d0fa08

Test: fast/dom/Text/text-constructor.html

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

LayoutTests:

* fast/dom/Text/text-constructor-expected.txt: Added.
* fast/dom/Text/text-constructor.html: Added.
* fast/dom/dom-constructors-expected.txt:
* fast/dom/dom-constructors.html:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (161875 => 161876)


--- trunk/LayoutTests/ChangeLog	2014-01-13 11:50:57 UTC (rev 161875)
+++ trunk/LayoutTests/ChangeLog	2014-01-13 12:52:28 UTC (rev 161876)
@@ -1,3 +1,15 @@
+2014-01-13  László Langó  <[email protected]>
+
+        Text should be constructable.
+        https://bugs.webkit.org/show_bug.cgi?id=115640
+
+        Reviewed by Csaba Osztrogonác.
+
+        * fast/dom/Text/text-constructor-expected.txt: Added.
+        * fast/dom/Text/text-constructor.html: Added.
+        * fast/dom/dom-constructors-expected.txt:
+        * fast/dom/dom-constructors.html:
+
 2014-01-13  Zan Dobersek  <[email protected]>
 
         Unreviewed GTK gardening. Rebaselining after r161696. Adding failure expectations

Added: trunk/LayoutTests/fast/dom/Text/text-constructor-expected.txt (0 => 161876)


--- trunk/LayoutTests/fast/dom/Text/text-constructor-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/Text/text-constructor-expected.txt	2014-01-13 12:52:28 UTC (rev 161876)
@@ -0,0 +1,19 @@
+This tests that Text is constructable.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS new Text("one").data is "one"
+PASS new Text().data is ""
+PASS new Text("two").ownerDocument is document
+PASS typeof new Text is "object"
+PASS Object.prototype.toString.call(new Text) is "[object Text]"
+PASS new Text instanceof Text is true
+PASS Object.getPrototypeOf(new Text) is Text.prototype
+PASS new innerWindow.Text("three").ownerDocument is innerDocument
+PASS new innerWindow.Text instanceof innerWindow.Text is true
+PASS Object.getPrototypeOf(new innerWindow.Text) is innerWindow.Text.prototype
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/dom/Text/text-constructor.html (0 => 161876)


--- trunk/LayoutTests/fast/dom/Text/text-constructor.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/Text/text-constructor.html	2014-01-13 12:52:28 UTC (rev 161876)
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<body>
+<script src=""
+<script>
+
+description('This tests that Text is constructable.');
+
+shouldBe('new Text("one").data', '"one"');
+shouldBe('new Text().data', '""');
+shouldBe('new Text("two").ownerDocument', 'document');
+
+shouldBe('typeof new Text', '"object"');
+shouldBe('Object.prototype.toString.call(new Text)', '"[object Text]"');
+shouldBeTrue('new Text instanceof Text');
+shouldBe('Object.getPrototypeOf(new Text)', 'Text.prototype');
+
+var frame = document.createElement('iframe');
+document.body.appendChild(frame);
+var innerWindow = frame.contentWindow;
+var innerDocument = frame.contentDocument;
+
+shouldBe('new innerWindow.Text("three").ownerDocument', 'innerDocument')
+shouldBeTrue('new innerWindow.Text instanceof innerWindow.Text');
+shouldBe('Object.getPrototypeOf(new innerWindow.Text)', 'innerWindow.Text.prototype');
+
+</script>
+<script src=""

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


--- trunk/LayoutTests/fast/dom/dom-constructors-expected.txt	2014-01-13 11:50:57 UTC (rev 161875)
+++ trunk/LayoutTests/fast/dom/dom-constructors-expected.txt	2014-01-13 12:52:28 UTC (rev 161876)
@@ -16,7 +16,6 @@
 PASS TryAllocate('Node') is 'exception'
 PASS TryAllocate('Notation') is 'exception'
 PASS TryAllocate('ProcessingInstruction') is 'exception'
-PASS TryAllocate('Text') is 'exception'
 PASS TryAllocate('HTMLAllCollection') is 'exception'
 PASS TryAllocate('HTMLAnchorElement') is 'exception'
 PASS TryAllocate('HTMLAppletElement') is 'exception'
@@ -134,6 +133,9 @@
 PASS TryAllocate('DOMParser') is '[object DOMParser]'
 PASS TryAllocate('DOMParser') is '[object DOMParser]'
 PASS TryAllocate('DOMParser') is '[object DOMParser]'
+PASS TryAllocate('Text') is '[object Text]'
+PASS TryAllocate('Text') is '[object Text]'
+PASS TryAllocate('Text') is '[object Text]'
 PASS TryAllocate('XMLHttpRequest') is '[object XMLHttpRequest]'
 PASS TryAllocate('XMLHttpRequest') is '[object XMLHttpRequest]'
 PASS TryAllocate('XMLHttpRequest') is '[object XMLHttpRequest]'

Modified: trunk/LayoutTests/fast/dom/dom-constructors.html (161875 => 161876)


--- trunk/LayoutTests/fast/dom/dom-constructors.html	2014-01-13 11:50:57 UTC (rev 161875)
+++ trunk/LayoutTests/fast/dom/dom-constructors.html	2014-01-13 12:52:28 UTC (rev 161876)
@@ -16,7 +16,7 @@
     'Attr', 'CharacterData', 'CDATASection', 'Document',
     'DocumentFragment', 'DocumentType', 'Element', 'Entity',
     'EntityReference', 'HTMLDocument', 'Node', 'Notation',
-    'ProcessingInstruction', 'Text', 'HTMLAllCollection', 'HTMLAnchorElement',
+    'ProcessingInstruction', 'HTMLAllCollection', 'HTMLAnchorElement',
     'HTMLAppletElement', 'HTMLAreaElement', 'HTMLBaseElement',
     'HTMLBaseFontElement', 'HTMLBodyElement',
     'HTMLBRElement', 'HTMLButtonElement', 'HTMLCanvasElement',
@@ -55,7 +55,7 @@
 
 // These objects should have a working constructor.
 var objects_constructor = [
-    'Comment', 'DOMParser', 'XMLHttpRequest', 'XMLSerializer', 'XPathEvaluator',
+    'Comment', 'DOMParser', 'Text', 'XMLHttpRequest', 'XMLSerializer', 'XPathEvaluator',
     'XSLTProcessor'
 ];
 

Modified: trunk/Source/WebCore/ChangeLog (161875 => 161876)


--- trunk/Source/WebCore/ChangeLog	2014-01-13 11:50:57 UTC (rev 161875)
+++ trunk/Source/WebCore/ChangeLog	2014-01-13 12:52:28 UTC (rev 161876)
@@ -1,3 +1,23 @@
+2014-01-13  László Langó  <[email protected]>
+
+        Text should be constructable.
+        https://bugs.webkit.org/show_bug.cgi?id=115640
+
+        Reviewed by Csaba Osztrogonác.
+
+        http://dom.spec.whatwg.org/#interface-text
+        Make Text constructable so that one can do "new Text('abc')"
+        instead of "document.createTexte('abc')".
+
+        Backported from Blink: https://chromium.googlesource.com/chromium/blink/+/cdd5a914daf3862379a5ce4596149bd690d0fa08
+
+        Test: fast/dom/Text/text-constructor.html
+
+        * dom/Text.cpp:
+        (WebCore::Text::create):
+        * dom/Text.h:
+        * dom/Text.idl:
+
 2014-01-13  Zan Dobersek  <[email protected]>
 
         Avoid unnecessary copies of AccessibilityObject::AccessibilityChildrenVector

Modified: trunk/Source/WebCore/dom/Text.cpp (161875 => 161876)


--- trunk/Source/WebCore/dom/Text.cpp	2014-01-13 11:50:57 UTC (rev 161875)
+++ trunk/Source/WebCore/dom/Text.cpp	2014-01-13 12:52:28 UTC (rev 161876)
@@ -46,6 +46,11 @@
     return adoptRef(new Text(document, data, CreateText));
 }
 
+PassRefPtr<Text> Text::create(ScriptExecutionContext& context, const String& data)
+{
+    return adoptRef(new Text(toDocument(context), data, CreateText));
+}
+
 PassRefPtr<Text> Text::createEditingText(Document& document, const String& data)
 {
     return adoptRef(new Text(document, data, CreateEditingText));

Modified: trunk/Source/WebCore/dom/Text.h (161875 => 161876)


--- trunk/Source/WebCore/dom/Text.h	2014-01-13 11:50:57 UTC (rev 161875)
+++ trunk/Source/WebCore/dom/Text.h	2014-01-13 12:52:28 UTC (rev 161876)
@@ -29,12 +29,14 @@
 namespace WebCore {
 
 class RenderText;
+class ScriptExecutionContext;
 
 class Text : public CharacterData {
 public:
     static const unsigned defaultLengthLimit = 1 << 16;
 
     static PassRefPtr<Text> create(Document&, const String&);
+    static PassRefPtr<Text> create(ScriptExecutionContext&, const String&);
     static PassRefPtr<Text> createWithLengthLimit(Document&, const String&, unsigned positionInString, unsigned lengthLimit = defaultLengthLimit);
     static PassRefPtr<Text> createEditingText(Document&, const String&);
 

Modified: trunk/Source/WebCore/dom/Text.idl (161875 => 161876)


--- trunk/Source/WebCore/dom/Text.idl	2014-01-13 11:50:57 UTC (rev 161875)
+++ trunk/Source/WebCore/dom/Text.idl	2014-01-13 12:52:28 UTC (rev 161876)
@@ -16,9 +16,11 @@
  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  * Boston, MA 02110-1301, USA.
  */
+[
+    Constructor([Default=NullString] optional DOMString data),
+    ConstructorCallWith=ScriptExecutionContext
+] interface Text : CharacterData {
 
-interface Text : CharacterData {
-
     // DOM Level 1
 
     [RaisesException] Text splitText([IsIndex,Default=Undefined] optional unsigned long offset);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to