Use a 1-byte enum class for TextDirection
[WebKit-https.git] / Source / WebCore / dom / MessageEvent.idl
index 8cb608a..fa48c8f 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2007 Henry Mason <hmason@mac.com>
  * Copyright (C) 2011 Google Inc. All rights reserved.
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  *
  */
 
-[
-    Exposed=(Window,Worker),
-    ConstructorTemplate=Event,
-] interface MessageEvent : Event {
-    [InitializedByEventConstructor] readonly attribute DOMString origin;
-    [InitializedByEventConstructor] readonly attribute DOMString lastEventId;
-    [InitializedByEventConstructor] readonly attribute EventTarget source; // May be a DOMWindow or a MessagePort.
-
-#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
-    [InitializedByEventConstructor, CachedAttribute, CustomGetter] readonly attribute any data;
-    [InitializedByEventConstructor] readonly attribute MessagePort[] ports;
-
-    [Custom] void initMessageEvent(optional DOMString typeArg,
-                                   optional boolean canBubbleArg,
-                                   optional boolean cancelableArg,
-                                   optional any dataArg,
-                                   optional DOMString originArg,
-                                   optional DOMString lastEventIdArg,
-                                   optional DOMWindow sourceArg,
-                                   optional Array messagePorts);
-
-    [Custom] void webkitInitMessageEvent(optional DOMString typeArg,
-                                         optional boolean canBubbleArg,
-                                         optional boolean cancelableArg,
-                                         optional any dataArg,
-                                         optional DOMString originArg,
-                                         optional DOMString lastEventIdArg,
-                                         optional DOMWindow sourceArg,
-                                         optional Array transferables);
+#if defined(ENABLE_SERVICE_WORKER) && ENABLE_SERVICE_WORKER
+typedef (WindowProxy or MessagePort or ServiceWorker) MessageEventSource;
 #else
-    // Code generator for ObjC bindings does not support custom bindings, thus there is no good way to
-    // return a variant value. As workaround, expose the data attribute as SerializedScriptValue.
-    readonly attribute SerializedScriptValue data;
-
-    // There's no good way to expose an array via the ObjC bindings, so for now just expose a single port.
-    readonly attribute MessagePort messagePort;
-
-    void initMessageEvent(optional DOMString typeArg,
-                          optional boolean canBubbleArg,
-                          optional boolean cancelableArg,
-                          optional SerializedScriptValue? dataArg,
-                          optional DOMString originArg,
-                          optional DOMString lastEventIdArg,
-                          optional DOMWindow? sourceArg,
-                          optional MessagePort? messagePort);
+typedef (WindowProxy or MessagePort) MessageEventSource;
 #endif
 
+[
+    Constructor(DOMString type, optional MessageEventInit eventInitDict),
+    Exposed=(Window,Worker),
+    JSCustomMarkFunction,
+] interface MessageEvent : Event {
+    readonly attribute USVString origin;
+    readonly attribute DOMString lastEventId;
+    readonly attribute MessageEventSource? source;
+    [CustomGetter] readonly attribute any data;
+    readonly attribute FrozenArray<MessagePort> ports;
+
+    void initMessageEvent(DOMString type, optional boolean bubbles = false, optional boolean cancelable = false,
+        optional any data = null, optional USVString originArg = "", optional DOMString lastEventId = "", optional MessageEventSource? source = null,
+        optional sequence<MessagePort> messagePorts = []);
 };
 
+dictionary MessageEventInit : EventInit {
+    any data = null;
+    USVString origin = "";
+    DOMString lastEventId = "";
+    MessageEventSource? source = null;
+    sequence<MessagePort> ports = [];
+};