Title: [207016] trunk
Revision
207016
Author
[email protected]
Date
2016-10-10 13:21:30 -0700 (Mon, 10 Oct 2016)

Log Message

Update MessageEvent to stop using legacy [ConstructorTemplate=Event]
https://bugs.webkit.org/show_bug.cgi?id=163187

Reviewed by Darin Adler.

Source/WebCore:

Update MessageEvent to stop using legacy [ConstructorTemplate=Event] and
use a regular constructor as in the specification:
- https://html.spec.whatwg.org/multipage/comms.html#the-messageevent-interfaces

No new tests, updated existing test.

* bindings/js/JSDOMBinding.h:
(WebCore::toRefPtrNativeArray):
* bindings/js/JSDOMConvert.h:
(WebCore::convertWrapperTypeSequence):
(WebCore::convertWrapperType): Deleted.
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateDefaultValue):
(GenerateDictionaryImplementationContent):
(GetNativeType):
* dom/MessageEvent.cpp:
(WebCore::MessageEvent::MessageEvent):
(WebCore::MessageEvent::create):
(WebCore::MessageEvent::trySerializeData):
(WebCore::MessageEvent::createForBindings): Deleted.
(WebCore::MessageEvent::initMessageEvent): Deleted.
* dom/MessageEvent.h:
* dom/MessageEvent.idl:

LayoutTests:

Rebaseline existing test now that:
- Exception messages are sometimes a bit different
- We properly use the default member value when input is an explicit undefined
- We throw in more cases of bad input

* fast/events/constructors/message-event-constructor-expected.txt:
* fast/events/constructors/message-event-constructor.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (207015 => 207016)


--- trunk/LayoutTests/ChangeLog	2016-10-10 20:14:43 UTC (rev 207015)
+++ trunk/LayoutTests/ChangeLog	2016-10-10 20:21:30 UTC (rev 207016)
@@ -1,3 +1,18 @@
+2016-10-10  Chris Dumez  <[email protected]>
+
+        Update MessageEvent to stop using legacy [ConstructorTemplate=Event]
+        https://bugs.webkit.org/show_bug.cgi?id=163187
+
+        Reviewed by Darin Adler.
+
+        Rebaseline existing test now that:
+        - Exception messages are sometimes a bit different
+        - We properly use the default member value when input is an explicit undefined
+        - We throw in more cases of bad input
+
+        * fast/events/constructors/message-event-constructor-expected.txt:
+        * fast/events/constructors/message-event-constructor.html:
+
 2016-10-10  Antoine Quint  <[email protected]>
 
         [Modern Media Controls] Buttons

Modified: trunk/LayoutTests/fast/events/constructors/message-event-constructor-expected.txt (207015 => 207016)


--- trunk/LayoutTests/fast/events/constructors/message-event-constructor-expected.txt	2016-10-10 20:14:43 UTC (rev 207015)
+++ trunk/LayoutTests/fast/events/constructors/message-event-constructor-expected.txt	2016-10-10 20:21:30 UTC (rev 207016)
@@ -16,7 +16,7 @@
 PASS new MessageEvent('eventType', { cancelable: true }).cancelable is true
 PASS new MessageEvent('eventType', { data: test_object }).data is test_object
 PASS new MessageEvent('eventType', { data: document }).data is document
-PASS new MessageEvent('eventType', { data: undefined }).data is undefined
+PASS new MessageEvent('eventType', { data: undefined }).data is null
 PASS new MessageEvent('eventType', { data: null }).data is null
 PASS new MessageEvent('eventType', { data: false }).data is false
 PASS new MessageEvent('eventType', { data: true }).data is true
@@ -30,7 +30,7 @@
 PASS new MessageEvent('eventType', { get data() { throw 'MessageEvent Error'; } }) threw exception MessageEvent Error.
 PASS new MessageEvent('eventType', { origin: 'melancholy' }).origin is "melancholy"
 PASS new MessageEvent('eventType', { origin: '' }).origin is ""
-PASS new MessageEvent('eventType', { origin: undefined }).origin is "undefined"
+PASS new MessageEvent('eventType', { origin: undefined }).origin is ""
 PASS new MessageEvent('eventType', { origin: null }).origin is "null"
 PASS new MessageEvent('eventType', { origin: false }).origin is "false"
 PASS new MessageEvent('eventType', { origin: true }).origin is "true"
@@ -45,7 +45,7 @@
 PASS new MessageEvent('eventType', { get origin() { throw 'MessageEvent Error'; } }) threw exception MessageEvent Error.
 PASS new MessageEvent('eventType', { lastEventId: 'melancholy' }).lastEventId is "melancholy"
 PASS new MessageEvent('eventType', { lastEventId: '' }).lastEventId is ""
-PASS new MessageEvent('eventType', { lastEventId: undefined }).lastEventId is "undefined"
+PASS new MessageEvent('eventType', { lastEventId: undefined }).lastEventId is ""
 PASS new MessageEvent('eventType', { lastEventId: null }).lastEventId is "null"
 PASS new MessageEvent('eventType', { lastEventId: false }).lastEventId is "false"
 PASS new MessageEvent('eventType', { lastEventId: true }).lastEventId is "true"
@@ -61,20 +61,20 @@
 PASS new MessageEvent('eventType', { source: window }).source is window
 PASS new MessageEvent('eventType', { source: this }).source is this
 PASS new MessageEvent('eventType', { ports: [channel.port1], source: channel.port1 }).source is channel.port1
-PASS new MessageEvent('eventType', { source: test_object }).source is null
+PASS new MessageEvent('eventType', { source: test_object }).source threw exception TypeError: Type error.
 PASS new MessageEvent('eventType', { source: document }).source is null
 PASS new MessageEvent('eventType', { source: document.body }).source is null
 PASS new MessageEvent('eventType', { source: undefined }).source is null
 PASS new MessageEvent('eventType', { source: null }).source is null
-PASS new MessageEvent('eventType', { source: false }).source is null
-PASS new MessageEvent('eventType', { source: true }).source is null
-PASS new MessageEvent('eventType', { source: '' }).source is null
-PASS new MessageEvent('eventType', { source: 'chocolate' }).source is null
-PASS new MessageEvent('eventType', { source: 12345 }).source is null
-PASS new MessageEvent('eventType', { source: 18446744073709551615 }).source is null
-PASS new MessageEvent('eventType', { source: NaN }).source is null
-PASS new MessageEvent('eventType', { source: {valueOf: function () { return window; } } }).source == window is false
-PASS new MessageEvent('eventType', { get source() { return 123; } }).source is null
+PASS new MessageEvent('eventType', { source: false }).source threw exception TypeError: Type error.
+PASS new MessageEvent('eventType', { source: true }).source threw exception TypeError: Type error.
+PASS new MessageEvent('eventType', { source: '' }).source threw exception TypeError: Type error.
+PASS new MessageEvent('eventType', { source: 'chocolate' }).source threw exception TypeError: Type error.
+PASS new MessageEvent('eventType', { source: 12345 }).source threw exception TypeError: Type error.
+PASS new MessageEvent('eventType', { source: 18446744073709551615 }).source threw exception TypeError: Type error.
+PASS new MessageEvent('eventType', { source: NaN }).source threw exception TypeError: Type error.
+PASS new MessageEvent('eventType', { source: {valueOf: function () { return window; } } }) threw exception TypeError: Type error.
+PASS new MessageEvent('eventType', { get source() { return 123; } }).source threw exception TypeError: Type error.
 PASS new MessageEvent('eventType', { get source() { throw 'MessageEvent Error'; } }) threw exception MessageEvent Error.
 PASS new MessageEvent('eventType', { ports: [channel.port1, channel.port2, channel2.port1] }).ports[0] is channel.port1
 PASS new MessageEvent('eventType', { ports: [channel.port1, channel.port2, channel2.port1] }).ports[1] is channel.port2
@@ -81,10 +81,10 @@
 PASS new MessageEvent('eventType', { ports: [channel.port1, channel.port2, channel2.port1] }).ports[2] is channel2.port1
 PASS new MessageEvent('eventType', { ports: [] }).ports is []
 PASS new MessageEvent('eventType', { ports: undefined }).ports is []
-PASS new MessageEvent('eventType', { ports: null }).ports is []
-PASS new MessageEvent('eventType', { ports: [1, 2, 3] }).ports[2] threw exception TypeError: Type error.
-PASS new MessageEvent('eventType', { ports: test_object }).ports threw exception TypeError: Value is not a sequence.
-PASS new MessageEvent('eventType', { ports: document }).ports threw exception TypeError: Value is not a sequence.
+PASS new MessageEvent('eventType', { ports: [1, 2, 3] }).ports[2] threw exception TypeError: Invalid Array element type.
+PASS new MessageEvent('eventType', { ports: test_object }).ports threw exception TypeError: Type error.
+PASS new MessageEvent('eventType', { ports: document }).ports threw exception TypeError: Type error.
+PASS new MessageEvent('eventType', { ports: null }).ports threw exception TypeError: Value is not a sequence.
 PASS new MessageEvent('eventType', { ports: false }).ports threw exception TypeError: Value is not a sequence.
 PASS new MessageEvent('eventType', { ports: true }).ports threw exception TypeError: Value is not a sequence.
 PASS new MessageEvent('eventType', { ports: '' }).ports threw exception TypeError: Value is not a sequence.
@@ -93,8 +93,8 @@
 PASS new MessageEvent('eventType', { ports: 18446744073709551615 }).ports threw exception TypeError: Value is not a sequence.
 PASS new MessageEvent('eventType', { ports: NaN }).ports threw exception TypeError: Value is not a sequence.
 PASS new MessageEvent('eventType', { get ports() { return 123; } }).ports threw exception TypeError: Value is not a sequence.
-PASS new MessageEvent('eventType', { get ports() { throw 'MessageEvent Error'; } }) threw exception MessageEvent Error.
-PASS new MessageEvent('eventType', { ports: {valueOf: function () { return [channel.port1, channel.port2, channel.port2]; } } }).ports[0] threw exception TypeError: Value is not a sequence.
+PASS new MessageEvent('eventType', { get ports() { throw 'MessageEvent Error'; } }) threw exception TypeError: Value is not a sequence.
+PASS new MessageEvent('eventType', { ports: {valueOf: function () { return [channel.port1, channel.port2, channel.port2]; } } }).ports[0] threw exception TypeError: Type error.
 PASS new MessageEvent('eventType', { bubbles: true, cancelable: true, data: test_object, origin: 'wonderful', lastEventId: 'excellent', source: window, ports: [channel.port1, channel.port2, channel2.port1] }).bubbles is true
 PASS new MessageEvent('eventType', { bubbles: true, cancelable: true, data: test_object, origin: 'wonderful', lastEventId: 'excellent', source: window, ports: [channel.port1, channel.port2, channel2.port1] }).cancelable is true
 PASS new MessageEvent('eventType', { bubbles: true, cancelable: true, data: test_object, origin: 'wonderful', lastEventId: 'excellent', source: window, ports: [channel.port1, channel.port2, channel2.port1] }).data is test_object

Modified: trunk/LayoutTests/fast/events/constructors/message-event-constructor.html (207015 => 207016)


--- trunk/LayoutTests/fast/events/constructors/message-event-constructor.html	2016-10-10 20:14:43 UTC (rev 207015)
+++ trunk/LayoutTests/fast/events/constructors/message-event-constructor.html	2016-10-10 20:21:30 UTC (rev 207016)
@@ -30,8 +30,8 @@
 // data is passed.
 shouldBe("new MessageEvent('eventType', { data: test_object }).data", "test_object");
 shouldBe("new MessageEvent('eventType', { data: document }).data", "document");
-shouldBe("new MessageEvent('eventType', { data: undefined }).data", "undefined");
-shouldBe("new MessageEvent('eventType', { data: null }).data", "null");
+shouldBeNull("new MessageEvent('eventType', { data: undefined }).data");
+shouldBeNull("new MessageEvent('eventType', { data: null }).data");
 shouldBe("new MessageEvent('eventType', { data: false }).data", "false");
 shouldBe("new MessageEvent('eventType', { data: true }).data", "true");
 shouldBeEqualToString("new MessageEvent('eventType', { data: '' }).data", "");
@@ -51,7 +51,7 @@
     shouldBeEqualToString("new MessageEvent('eventType', { " + attr + ": '' })." + attr, "");
 
     // Non-strings.
-    shouldBeEqualToString("new MessageEvent('eventType', { " + attr + ": undefined })." + attr, "undefined");
+    shouldBeEqualToString("new MessageEvent('eventType', { " + attr + ": undefined })." + attr, "");
     shouldBeEqualToString("new MessageEvent('eventType', { " + attr + ": null })." + attr, "null");
     shouldBeEqualToString("new MessageEvent('eventType', { " + attr + ": false })." + attr, "false");
     shouldBeEqualToString("new MessageEvent('eventType', { " + attr + ": true })." + attr, "true");
@@ -76,21 +76,21 @@
 shouldBe("new MessageEvent('eventType', { ports: [channel.port1], source: channel.port1 }).source", "channel.port1");
 
 // Unacceptable source objects (not a Window or a MessagePort).
-shouldBe("new MessageEvent('eventType', { source: test_object }).source", "null");
+shouldThrowErrorName("new MessageEvent('eventType', { source: test_object }).source", "TypeError");
 shouldBe("new MessageEvent('eventType', { source: document }).source", "null");
 shouldBe("new MessageEvent('eventType', { source: document.body }).source", "null");
 shouldBe("new MessageEvent('eventType', { source: undefined }).source", "null");
 shouldBe("new MessageEvent('eventType', { source: null }).source", "null");
-shouldBe("new MessageEvent('eventType', { source: false }).source", "null");
-shouldBe("new MessageEvent('eventType', { source: true }).source", "null");
-shouldBe("new MessageEvent('eventType', { source: '' }).source", "null");
-shouldBe("new MessageEvent('eventType', { source: 'chocolate' }).source", "null");
-shouldBe("new MessageEvent('eventType', { source: 12345 }).source", "null");
-shouldBe("new MessageEvent('eventType', { source: 18446744073709551615 }).source", "null");
-shouldBe("new MessageEvent('eventType', { source: NaN }).source", "null");
+shouldThrowErrorName("new MessageEvent('eventType', { source: false }).source", "TypeError");
+shouldThrowErrorName("new MessageEvent('eventType', { source: true }).source", "TypeError");
+shouldThrowErrorName("new MessageEvent('eventType', { source: '' }).source", "TypeError");
+shouldThrowErrorName("new MessageEvent('eventType', { source: 'chocolate' }).source", "TypeError");
+shouldThrowErrorName("new MessageEvent('eventType', { source: 12345 }).source", "TypeError");
+shouldThrowErrorName("new MessageEvent('eventType', { source: 18446744073709551615 }).source", "TypeError");
+shouldThrowErrorName("new MessageEvent('eventType', { source: NaN }).source", "TypeError");
 // Note that valueOf() is not called, when the left hand side is evaluated.
-shouldBeFalse("new MessageEvent('eventType', { source: {valueOf: function () { return window; } } }).source == window");
-shouldBe("new MessageEvent('eventType', { get source() { return 123; } }).source", "null");
+shouldThrowErrorName("new MessageEvent('eventType', { source: {valueOf: function () { return window; } } })", "TypeError");
+shouldThrowErrorName("new MessageEvent('eventType', { get source() { return 123; } }).source", "TypeError");
 shouldThrow("new MessageEvent('eventType', { get source() { throw 'MessageEvent Error'; } })");
 
 // ports is passed.
@@ -101,12 +101,12 @@
 shouldBe("new MessageEvent('eventType', { ports: [channel.port1, channel.port2, channel2.port1] }).ports[2]", "channel2.port1");
 shouldBe("new MessageEvent('eventType', { ports: [] }).ports", "[]");
 shouldBe("new MessageEvent('eventType', { ports: undefined }).ports", "[]");
-shouldBe("new MessageEvent('eventType', { ports: null }).ports", "[]");
 
 // Invalid message ports.
 shouldThrow("new MessageEvent('eventType', { ports: [1, 2, 3] }).ports[2]");
 shouldThrow("new MessageEvent('eventType', { ports: test_object }).ports");
 shouldThrow("new MessageEvent('eventType', { ports: document }).ports");
+shouldThrow("new MessageEvent('eventType', { ports: null }).ports")
 shouldThrow("new MessageEvent('eventType', { ports: false }).ports");
 shouldThrow("new MessageEvent('eventType', { ports: true }).ports");
 shouldThrow("new MessageEvent('eventType', { ports: '' }).ports");

Modified: trunk/Source/WebCore/ChangeLog (207015 => 207016)


--- trunk/Source/WebCore/ChangeLog	2016-10-10 20:14:43 UTC (rev 207015)
+++ trunk/Source/WebCore/ChangeLog	2016-10-10 20:21:30 UTC (rev 207016)
@@ -1,3 +1,34 @@
+2016-10-10  Chris Dumez  <[email protected]>
+
+        Update MessageEvent to stop using legacy [ConstructorTemplate=Event]
+        https://bugs.webkit.org/show_bug.cgi?id=163187
+
+        Reviewed by Darin Adler.
+
+        Update MessageEvent to stop using legacy [ConstructorTemplate=Event] and
+        use a regular constructor as in the specification:
+        - https://html.spec.whatwg.org/multipage/comms.html#the-messageevent-interfaces
+
+        No new tests, updated existing test.
+
+        * bindings/js/JSDOMBinding.h:
+        (WebCore::toRefPtrNativeArray):
+        * bindings/js/JSDOMConvert.h:
+        (WebCore::convertWrapperTypeSequence):
+        (WebCore::convertWrapperType): Deleted.
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateDefaultValue):
+        (GenerateDictionaryImplementationContent):
+        (GetNativeType):
+        * dom/MessageEvent.cpp:
+        (WebCore::MessageEvent::MessageEvent):
+        (WebCore::MessageEvent::create):
+        (WebCore::MessageEvent::trySerializeData):
+        (WebCore::MessageEvent::createForBindings): Deleted.
+        (WebCore::MessageEvent::initMessageEvent): Deleted.
+        * dom/MessageEvent.h:
+        * dom/MessageEvent.idl:
+
 2016-10-10  Antoine Quint  <[email protected]>
 
         [Modern Media Controls] Buttons

Modified: trunk/Source/WebCore/bindings/js/JSDOMBinding.h (207015 => 207016)


--- trunk/Source/WebCore/bindings/js/JSDOMBinding.h	2016-10-10 20:14:43 UTC (rev 207015)
+++ trunk/Source/WebCore/bindings/js/JSDOMBinding.h	2016-10-10 20:21:30 UTC (rev 207016)
@@ -297,7 +297,7 @@
 RefPtr<JSC::Float64Array> toFloat64Array(JSC::JSValue);
 
 template<typename T, typename JSType> Vector<Ref<T>> toRefNativeArray(JSC::ExecState&, JSC::JSValue);
-template<typename T, typename JSType> Vector<RefPtr<T>> toRefPtrNativeArray(JSC::ExecState&, JSC::JSValue);
+template<typename T, typename JSType, typename VectorType = Vector<RefPtr<T>>> VectorType toRefPtrNativeArray(JSC::ExecState&, JSC::JSValue);
 template<typename T> Vector<T> toNativeArray(JSC::ExecState&, JSC::JSValue);
 bool hasIteratorMethod(JSC::ExecState&, JSC::JSValue);
 
@@ -835,18 +835,18 @@
     return result;
 }
 
-template<typename T, typename JST> Vector<RefPtr<T>> toRefPtrNativeArray(JSC::ExecState& exec, JSC::JSValue value)
+template<typename T, typename JST, typename VectorType> VectorType toRefPtrNativeArray(JSC::ExecState& state, JSC::JSValue value)
 {
-    JSC::VM& vm = exec.vm();
+    JSC::VM& vm = state.vm();
     auto scope = DECLARE_THROW_SCOPE(vm);
 
     if (!value.isObject()) {
-        throwSequenceTypeError(exec, scope);
+        throwSequenceTypeError(state, scope);
         return { };
     }
 
-    Vector<RefPtr<T>> result;
-    forEachInIterable(&exec, value, [&result](JSC::VM& vm, JSC::ExecState* state, JSC::JSValue jsValue) {
+    VectorType result;
+    forEachInIterable(&state, value, [&result](JSC::VM& vm, JSC::ExecState* state, JSC::JSValue jsValue) {
         auto scope = DECLARE_THROW_SCOPE(vm);
 
         if (jsValue.inherits(JST::info()))

Modified: trunk/Source/WebCore/bindings/js/JSDOMConvert.h (207015 => 207016)


--- trunk/Source/WebCore/bindings/js/JSDOMConvert.h	2016-10-10 20:14:43 UTC (rev 207015)
+++ trunk/Source/WebCore/bindings/js/JSDOMConvert.h	2016-10-10 20:21:30 UTC (rev 207016)
@@ -49,6 +49,7 @@
 
 enum class IsNullable { No, Yes };
 template<typename T, typename JST> T* convertWrapperType(JSC::ExecState&, JSC::JSValue, IsNullable);
+template<typename T, typename JST, typename VectorType> VectorType convertWrapperTypeSequence(JSC::ExecState&, JSC::JSValue);
 
 // This is where the implementation of the things declared above begins:
 
@@ -77,6 +78,11 @@
     return object;
 }
 
+template<typename T, typename JST, typename VectorType> inline VectorType convertWrapperTypeSequence(JSC::ExecState& state, JSC::JSValue value)
+{
+    return toRefPtrNativeArray<T, JST, VectorType>(state, value);
+}
+
 template<typename T> struct DefaultConverter {
     using OptionalValue = Optional<T>;
 };

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (207015 => 207016)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2016-10-10 20:14:43 UTC (rev 207015)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2016-10-10 20:21:30 UTC (rev 207016)
@@ -986,6 +986,7 @@
     if ($value eq "null") {
         $value = $member->type eq "any" ? "jsNull()" : "nullptr";
     }
+    $value = "{ }" if $value eq "[]";
     $value = "jsUndefined()" if $value eq "undefined";
 
     return $value;
@@ -1120,6 +1121,14 @@
                 $result .= "        Optional<${nativeType}> $key = convertDictionary<${nativeType}>(state, ${key}Value).value();\n";
                 $result .= "        RETURN_IF_EXCEPTION(throwScope, Nullopt);\n";
                 $result .= "        result.$key = $key.value();\n";
+            } elsif ($codeGenerator->IsSequenceOrFrozenArrayType($type)) {
+                my $innerType = $codeGenerator->GetSequenceOrFrozenArrayInnerType($type);
+                if ($codeGenerator->IsWrapperType($innerType)) {
+                    $result .= "        result.$key = convertWrapperTypeSequence<$innerType, JS$innerType, $nativeType>(state, ${key}Value);\n";
+                } else {
+                    $result .= "        result.$key = convert<${nativeType}>(state, ${key}Value);\n";
+                }
+                $result .= "        RETURN_IF_EXCEPTION(throwScope, Nullopt);\n";
             } else {
                 my $conversionRuleWithLeadingComma = GenerateConversionRuleWithLeadingComma($interface, $member);
                 $result .= "        result.$key = convert<${nativeType}>(state, ${key}Value${conversionRuleWithLeadingComma});\n";
@@ -4778,14 +4787,15 @@
     "unsigned short" => "uint16_t",
 );
 
-sub GetVariadicType
+sub GetNativeVectorType
 {
     my ($interface, $type) = @_;
 
-    my $wrappedType = IsNativeType($type) ? GetNativeType($interface, $type) : $type;
-    my $wrapperType = IsNativeType($type) ? "JSC::JSValue" : "JS$wrappedType";
+    die "This should only be called for sequence or array types" unless $codeGenerator->IsSequenceOrFrozenArrayType($type);
 
-    return ($wrapperType, $wrappedType);
+    my $innerType = $codeGenerator->GetSequenceOrFrozenArrayInnerType($type);
+    return "MessagePortArray" if $innerType eq "MessagePort";
+    return "Vector<" . GetNativeVectorInnerType($innerType) . ">";
 }
 
 sub GetNativeType
@@ -4802,7 +4812,7 @@
 
     return "RefPtr<${type}>" if $codeGenerator->IsTypedArrayType($type) and $type ne "ArrayBuffer";
 
-    return "Vector<" . GetNativeVectorInnerType($codeGenerator->GetSequenceOrFrozenArrayInnerType($type)) . ">" if $codeGenerator->IsSequenceOrFrozenArrayType($type);
+    return GetNativeVectorType($interface, $type) if $codeGenerator->IsSequenceOrFrozenArrayType($type);
 
     return "${type}*";
 }

Modified: trunk/Source/WebCore/dom/MessageEvent.cpp (207015 => 207016)


--- trunk/Source/WebCore/dom/MessageEvent.cpp	2016-10-10 20:14:43 UTC (rev 207015)
+++ trunk/Source/WebCore/dom/MessageEvent.cpp	2016-10-10 20:21:30 UTC (rev 207016)
@@ -35,6 +35,8 @@
 
 namespace WebCore {
 
+using namespace JSC;
+
 static inline bool isValidSource(EventTarget* source)
 {
     return !source || source->toDOMWindow() || source->isMessagePort();
@@ -45,10 +47,10 @@
 {
 }
 
-inline MessageEvent::MessageEvent(const AtomicString& type, const MessageEventInit& initializer)
-    : Event(type, initializer)
+inline MessageEvent::MessageEvent(ExecState& state, const AtomicString& type, const Init& initializer, IsTrusted isTrusted)
+    : Event(type, initializer, isTrusted)
     , m_dataType(DataTypeScriptValue)
-    , m_dataAsScriptValue(initializer.data)
+    , m_dataAsScriptValue(state.vm(), initializer.data)
     , m_origin(initializer.origin)
     , m_lastEventId(initializer.lastEventId)
     , m_source(isValidSource(initializer.source.get()) ? initializer.source : nullptr)
@@ -131,9 +133,9 @@
     return adoptRef(*new MessageEvent);
 }
 
-Ref<MessageEvent> MessageEvent::createForBindings(const AtomicString& type, const MessageEventInit& initializer)
+Ref<MessageEvent> MessageEvent::create(ExecState& state, const AtomicString& type, const Init& initializer, IsTrusted isTrusted)
 {
-    return adoptRef(*new MessageEvent(type, initializer));
+    return adoptRef(*new MessageEvent(state, type, initializer, isTrusted));
 }
 
 MessageEvent::~MessageEvent()
@@ -172,7 +174,7 @@
     m_ports = WTFMove(ports);
 }
     
-RefPtr<SerializedScriptValue> MessageEvent::trySerializeData(JSC::ExecState* exec)
+RefPtr<SerializedScriptValue> MessageEvent::trySerializeData(ExecState* exec)
 {
     ASSERT(!m_dataAsScriptValue.hasNoValue());
     

Modified: trunk/Source/WebCore/dom/MessageEvent.h (207015 => 207016)


--- trunk/Source/WebCore/dom/MessageEvent.h	2016-10-10 20:14:43 UTC (rev 207015)
+++ trunk/Source/WebCore/dom/MessageEvent.h	2016-10-10 20:21:30 UTC (rev 207016)
@@ -36,14 +36,6 @@
 
 class Blob;
 
-struct MessageEventInit : public EventInit {
-    Deprecated::ScriptValue data;
-    String origin;
-    String lastEventId;
-    RefPtr<EventTarget> source;
-    MessagePortArray ports;
-};
-
 class MessageEvent final : public Event {
 public:
     static Ref<MessageEvent> create(std::unique_ptr<MessagePortArray>, RefPtr<SerializedScriptValue>&&, const String& origin = { }, const String& lastEventId = { }, EventTarget* source = nullptr);
@@ -52,7 +44,16 @@
     static Ref<MessageEvent> create(Ref<Blob>&& data, const String& origin);
     static Ref<MessageEvent> create(Ref<ArrayBuffer>&& data, const String& origin = { });
     static Ref<MessageEvent> createForBindings();
-    static Ref<MessageEvent> createForBindings(const AtomicString& type, const MessageEventInit&);
+
+    struct Init : EventInit {
+        JSC::JSValue data;
+        String origin;
+        String lastEventId;
+        RefPtr<EventTarget> source;
+        MessagePortArray ports;
+    };
+    static Ref<MessageEvent> create(JSC::ExecState&, const AtomicString& type, const Init&, IsTrusted = IsTrusted::No);
+
     virtual ~MessageEvent();
 
     void initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, const Deprecated::ScriptValue& data, const String& origin, const String& lastEventId, DOMWindow* source, std::unique_ptr<MessagePortArray>);
@@ -86,7 +87,7 @@
     
 private:
     MessageEvent();
-    MessageEvent(const AtomicString&, const MessageEventInit&);
+    MessageEvent(JSC::ExecState&, const AtomicString&, const Init&, IsTrusted);
     MessageEvent(RefPtr<SerializedScriptValue>&& data, const String& origin, const String& lastEventId, EventTarget* source, std::unique_ptr<MessagePortArray>);
     MessageEvent(const AtomicString& type, RefPtr<SerializedScriptValue>&& data, const String& origin, const String& lastEventId);
     MessageEvent(const String& data, const String& origin);

Modified: trunk/Source/WebCore/dom/MessageEvent.idl (207015 => 207016)


--- trunk/Source/WebCore/dom/MessageEvent.idl	2016-10-10 20:14:43 UTC (rev 207015)
+++ trunk/Source/WebCore/dom/MessageEvent.idl	2016-10-10 20:21:30 UTC (rev 207016)
@@ -26,16 +26,16 @@
  */
 
 [
-    ConstructorTemplate=Event,
+    Constructor(DOMString type, optional MessageEventInit eventInitDict),
+    ConstructorCallWith=ScriptState,
     Exposed=(Window,Worker),
 ] interface MessageEvent : Event {
-    [InitializedByEventConstructor] readonly attribute USVString origin;
-    [InitializedByEventConstructor] readonly attribute DOMString lastEventId;
-    [InitializedByEventConstructor] readonly attribute EventTarget source; // May be a DOMWindow or a MessagePort.
+    readonly attribute USVString origin;
+    readonly attribute DOMString lastEventId;
+    readonly attribute EventTarget? source; // May be a DOMWindow or a MessagePort.
+    [CachedAttribute, CustomGetter] readonly attribute any data;
+    readonly attribute FrozenArray<MessagePort> ports;
 
-    [InitializedByEventConstructor, CachedAttribute, CustomGetter] readonly attribute any data;
-    [InitializedByEventConstructor] readonly attribute sequence<MessagePort> ports;
-
     [Custom] void initMessageEvent(optional DOMString typeArg, optional boolean canBubbleArg, optional boolean cancelableArg,
         optional any dataArg, optional USVString originArg, optional DOMString lastEventIdArg, optional DOMWindow sourceArg,
         optional Array messagePorts);
@@ -44,3 +44,11 @@
         optional any dataArg, optional USVString originArg, optional DOMString lastEventIdArg, optional DOMWindow sourceArg,
         optional Array transferables);
 };
+
+dictionary MessageEventInit : EventInit {
+      any data = ""
+      USVString origin = "";
+      DOMString lastEventId = "";
+      EventTarget? source = null;
+      sequence<MessagePort> ports = [];
+};
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to