Rename [GlobalContext] extended attribute to [Exposed] and align with WebIDL
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Apr 2016 14:12:50 +0000 (14:12 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Apr 2016 14:12:50 +0000 (14:12 +0000)
https://bugs.webkit.org/show_bug.cgi?id=156615

Reviewed by Youenn Fablet.

Rename [GlobalContext] extended attribute to [Exposed] and align with WebIDL:
- http://heycam.github.io/webidl/#Exposed

* bindings/scripts/IDLAttributes.txt:
Stop recognizing [GlobalContext] and start recognizing [Exposed].

* bindings/scripts/IDLParser.pm:
(parseIdentifierList):
(parseExtendedAttributeRest2):
Add IDL parser support for having a list of identifiers as value
for an IDL extended attribute, e.g. Exposed=(Window, Worker).

* bindings/scripts/preprocess-idls.pl:
Tweak existing support for [GlobalContext] to use [Exposed] instead
and support the new syntax.

(getInterfaceExtendedAttributesFromIDL):
Do not split on commas that are within brackets.

* Modules/fetch/FetchBody.idl:
* Modules/fetch/FetchHeaders.idl:
* Modules/fetch/FetchRequest.idl:
* Modules/fetch/FetchResponse.idl:
* Modules/streams/ByteLengthQueuingStrategy.idl:
* Modules/streams/CountQueuingStrategy.idl:
* Modules/streams/ReadableStream.idl:
* Modules/streams/ReadableStreamController.idl:
* Modules/streams/ReadableStreamReader.idl:
* Modules/websockets/WebSocket.idl:
* dom/MessageChannel.idl:
* dom/MessageEvent.idl:
* fileapi/Blob.idl:
* fileapi/FileReader.idl:
* fileapi/FileReaderSync.idl:
* html/DOMURL.idl:
* html/ImageData.idl:
* page/EventSource.idl:
* workers/DedicatedWorkerGlobalScope.idl:
* workers/WorkerGlobalScope.idl:
* workers/WorkerLocation.idl:
* xml/XMLHttpRequest.idl:
* xml/XMLHttpRequestEventTarget.idl:
Use [Exposed] instead of [GlobalContext] to match their respective
specifications.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@199587 268f45cc-cd09-0410-ab3c-d52691b4dbfc

27 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/fetch/FetchBody.idl
Source/WebCore/Modules/fetch/FetchHeaders.idl
Source/WebCore/Modules/fetch/FetchRequest.idl
Source/WebCore/Modules/fetch/FetchResponse.idl
Source/WebCore/Modules/streams/ByteLengthQueuingStrategy.idl
Source/WebCore/Modules/streams/CountQueuingStrategy.idl
Source/WebCore/Modules/streams/ReadableStream.idl
Source/WebCore/Modules/streams/ReadableStreamController.idl
Source/WebCore/Modules/streams/ReadableStreamReader.idl
Source/WebCore/Modules/websockets/WebSocket.idl
Source/WebCore/bindings/scripts/IDLAttributes.txt
Source/WebCore/bindings/scripts/IDLParser.pm
Source/WebCore/bindings/scripts/preprocess-idls.pl
Source/WebCore/dom/MessageChannel.idl
Source/WebCore/dom/MessageEvent.idl
Source/WebCore/fileapi/Blob.idl
Source/WebCore/fileapi/FileReader.idl
Source/WebCore/fileapi/FileReaderSync.idl
Source/WebCore/html/DOMURL.idl
Source/WebCore/html/ImageData.idl
Source/WebCore/page/EventSource.idl
Source/WebCore/workers/DedicatedWorkerGlobalScope.idl
Source/WebCore/workers/WorkerGlobalScope.idl
Source/WebCore/workers/WorkerLocation.idl
Source/WebCore/xml/XMLHttpRequest.idl
Source/WebCore/xml/XMLHttpRequestEventTarget.idl

index 0cacb55..ee98e04 100644 (file)
@@ -1,3 +1,55 @@
+2016-04-15  Chris Dumez  <cdumez@apple.com>
+
+        Rename [GlobalContext] extended attribute to [Exposed] and align with WebIDL
+        https://bugs.webkit.org/show_bug.cgi?id=156615
+
+        Reviewed by Youenn Fablet.
+
+        Rename [GlobalContext] extended attribute to [Exposed] and align with WebIDL:
+        - http://heycam.github.io/webidl/#Exposed
+
+        * bindings/scripts/IDLAttributes.txt:
+        Stop recognizing [GlobalContext] and start recognizing [Exposed].
+
+        * bindings/scripts/IDLParser.pm:
+        (parseIdentifierList):
+        (parseExtendedAttributeRest2):
+        Add IDL parser support for having a list of identifiers as value
+        for an IDL extended attribute, e.g. Exposed=(Window, Worker).
+
+        * bindings/scripts/preprocess-idls.pl:
+        Tweak existing support for [GlobalContext] to use [Exposed] instead
+        and support the new syntax.
+
+        (getInterfaceExtendedAttributesFromIDL):
+        Do not split on commas that are within brackets.
+
+        * Modules/fetch/FetchBody.idl:
+        * Modules/fetch/FetchHeaders.idl:
+        * Modules/fetch/FetchRequest.idl:
+        * Modules/fetch/FetchResponse.idl:
+        * Modules/streams/ByteLengthQueuingStrategy.idl:
+        * Modules/streams/CountQueuingStrategy.idl:
+        * Modules/streams/ReadableStream.idl:
+        * Modules/streams/ReadableStreamController.idl:
+        * Modules/streams/ReadableStreamReader.idl:
+        * Modules/websockets/WebSocket.idl:
+        * dom/MessageChannel.idl:
+        * dom/MessageEvent.idl:
+        * fileapi/Blob.idl:
+        * fileapi/FileReader.idl:
+        * fileapi/FileReaderSync.idl:
+        * html/DOMURL.idl:
+        * html/ImageData.idl:
+        * page/EventSource.idl:
+        * workers/DedicatedWorkerGlobalScope.idl:
+        * workers/WorkerGlobalScope.idl:
+        * workers/WorkerLocation.idl:
+        * xml/XMLHttpRequest.idl:
+        * xml/XMLHttpRequestEventTarget.idl:
+        Use [Exposed] instead of [GlobalContext] to match their respective
+        specifications.
+
 2016-04-15  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         Selection.deleteFromDocument should not leave a selection character
index aee776f..19575ca 100644 (file)
@@ -29,7 +29,7 @@
 [
     Conditional=FETCH_API,
     EnabledAtRuntime=FetchAPI,
-    GlobalContext=DOMWindow&WorkerGlobalScope,
+    Exposed=(Window,Worker),
     InterfaceName=Body,
     NoInterfaceObject
 ]
index 6063d7b..99cb08c 100644 (file)
@@ -29,7 +29,7 @@
 [
     Conditional=FETCH_API,
     EnabledAtRuntime=FetchAPI,
-    GlobalContext=DOMWindow&WorkerGlobalScope,
+    Exposed=(Window,Worker),
     ImplementationLacksVTable,
     InterfaceName=Headers,
     JSBuiltinConstructor
index 2794c11..73eaa44 100644 (file)
@@ -42,7 +42,7 @@ enum ReferrerPolicy { "", "no-referrer",  "no-referrer-when-downgrade", "origin-
     ConstructorRaisesException,
     Constructor(FetchRequest input, [Default=Undefined] optional Dictionary init),
     Constructor(DOMString input, [Default=Undefined]  optional Dictionary init),
-    GlobalContext=DOMWindow&WorkerGlobalScope,
+    Exposed=(Window,Worker),
     InterfaceName=Request
 ]
 interface FetchRequest {
index f12275b..37feded 100644 (file)
@@ -32,7 +32,7 @@ enum ResponseType { "basic", "cors", "default", "error", "opaque", "opaqueredire
     Conditional=FETCH_API,
     EnabledAtRuntime=FetchAPI,
     ConstructorCallWith=ScriptExecutionContext,
-    GlobalContext=DOMWindow&WorkerGlobalScope,
+    Exposed=(Window,Worker),
     InterfaceName=Response,
     JSBuiltinConstructor
 ]
index e64b2b9..f8d0cf7 100644 (file)
@@ -31,7 +31,7 @@
     JSBuiltin,
     Constructor,
     Conditional=STREAMS_API,
-    GlobalContext=DOMWindow&WorkerGlobalScope,
+    Exposed=(Window,Worker),
 ] interface ByteLengthQueuingStrategy {
     double size();
 };
index 1323ba2..11cba39 100644 (file)
@@ -31,7 +31,7 @@
     JSBuiltin,
     Constructor,
     Conditional=STREAMS_API,
-    GlobalContext=DOMWindow&WorkerGlobalScope,
+    Exposed=(Window,Worker),
 ] interface CountQueuingStrategy {
     double size();
 };
index b18e58c..248b218 100644 (file)
@@ -30,7 +30,7 @@
 [
     Conditional=STREAMS_API,
     Constructor,
-    GlobalContext=DOMWindow&WorkerGlobalScope,
+    Exposed=(Window,Worker),
     JSBuiltin
 ] interface ReadableStream {
     Promise cancel(optional any reason);
index 0307372..77e2b87 100644 (file)
@@ -30,7 +30,7 @@
 [
     Conditional=STREAMS_API,
     CustomConstructor,
-    GlobalContext=DOMWindow&WorkerGlobalScope,
+    Exposed=(Window,Worker),
     JSBuiltin,
     NoInterfaceObject
 ] interface ReadableStreamController {
index 02a1965..d6007de 100644 (file)
@@ -30,7 +30,7 @@
 [
     Conditional=STREAMS_API,
     CustomConstructor,
-    GlobalContext=DOMWindow&WorkerGlobalScope,
+    Exposed=(Window,Worker),
     JSBuiltin,
     NoInterfaceObject
 ] interface ReadableStreamReader {
index 9a6a327..e07591e 100644 (file)
@@ -30,7 +30,7 @@
  */
 
 [
-    GlobalContext=DOMWindow&WorkerGlobalScope,
+    Exposed=(Window,Worker),
     EnabledAtRuntime,
     Conditional=WEB_SOCKETS,
     ActiveDOMObject,
index 03464d4..afad90d 100644 (file)
@@ -61,11 +61,11 @@ EnabledAtRuntime=*
 EnabledBySetting=*
 EnforceRange
 ExportMacro=WEBCORE_EXPORT|WEBCORE_TESTSUPPORT_EXPORT
+Exposed=*
 ForwardDeclareInHeader
 GenerateIsReachable=|Impl|ImplWebGLRenderingContext|ImplDocument|ImplElementRoot|ImplFrame|ImplOwnerNodeRoot
 GetterRaisesException
 GetterRaisesExceptionWithMessage
-GlobalContext=DOMWindow|WorkerGlobalScope|DedicatedWorkerGlobalScope
 Immutable
 ImplementationLacksVTable
 ImplementationNamespace=*
index 4f1529f..a74aaab 100644 (file)
@@ -1073,6 +1073,19 @@ sub parseSerializationPatternList
     }
 }
 
+sub parseIdentifierList
+{
+    my $self = shift;
+    my $next = $self->nextToken();
+
+    my @identifiers = ();
+    if ($next->type == IdentifierToken) {
+        push(@identifiers, $self->getToken()->value());
+        push(@identifiers, @{$self->parseIdentifiers()});
+    }
+    return @identifiers;
+}
+
 sub parseIdentifiers
 {
     my $self = shift;
@@ -1690,6 +1703,12 @@ sub parseExtendedAttributeRest2
 {
     my $self = shift;
     my $next = $self->nextToken();
+    if ($next->value() eq "(") {
+        $self->assertTokenValue($self->getToken(), "(", __LINE__);
+        my @arguments = $self->parseIdentifierList();
+        $self->assertTokenValue($self->getToken(), ")", __LINE__);
+        return @arguments;
+    }
     if ($next->type() == IdentifierToken || $next->value() eq "::") {
         my $scopedName = $self->parseScopedName();
         return $self->parseExtendedAttributeRest3($scopedName);
index 95f829d..43d56d6 100644 (file)
@@ -115,11 +115,21 @@ foreach my $idlFile (sort keys %idlFileHash) {
     my $extendedAttributes = getInterfaceExtendedAttributesFromIDL($idlFileContents);
     unless ($extendedAttributes->{"NoInterfaceObject"}) {
         if (!isCallbackInterfaceFromIDL($idlFileContents) || interfaceHasConstantAttribute($idlFileContents)) {
-            my @globalContexts = split("&", $extendedAttributes->{"GlobalContext"} || "DOMWindow");
+            my $exposedAttribute = $extendedAttributes->{"Exposed"} || "Window";
+            $exposedAttribute = substr($exposedAttribute, 1, -1) if substr($exposedAttribute, 0, 1) eq "(";
+            my @globalContexts = split(",", $exposedAttribute);
             my $attributeCode = GenerateConstructorAttribute($interfaceName, $extendedAttributes);
-            $windowConstructorsCode .= $attributeCode if grep(/^DOMWindow$/, @globalContexts);
-            $workerGlobalScopeConstructorsCode .= $attributeCode if grep(/^WorkerGlobalScope$/, @globalContexts);
-            $dedicatedWorkerGlobalScopeConstructorsCode .= $attributeCode if grep(/^DedicatedWorkerGlobalScope$/, @globalContexts);
+            foreach my $globalContext (@globalContexts) {
+                if ($globalContext eq "Window") {
+                    $windowConstructorsCode .= $attributeCode;
+                } elsif ($globalContext eq "Worker") {
+                    $workerGlobalScopeConstructorsCode .= $attributeCode;
+                } elsif ($globalContext eq "DedicatedWorker") {
+                    $dedicatedWorkerGlobalScopeConstructorsCode .= $attributeCode;
+                } else {
+                    die "Unsupported global context '$globalContext' used in [Exposed] at $idlFile";
+                }
+            }
         }
     }
     $supplementals{$fullPath} = [];
@@ -309,7 +319,7 @@ sub getInterfaceExtendedAttributesFromIDL
     my $extendedAttributes = {};
 
     if ($fileContents =~ /\[(.*)\]\s+(callback interface|interface|exception)\s+(\w+)/gs) {
-        my @parts = split(',', $1);
+        my @parts = split(m/,(?![^()]*\))/, $1);
         foreach my $part (@parts) {
             my @keyValue = split('=', $part);
             my $key = trim($keyValue[0]);
index f42f09e..285afc9 100644 (file)
@@ -25,7 +25,7 @@
  */
 
 [
-    GlobalContext=DOMWindow&WorkerGlobalScope,
+    Exposed=(Window,Worker),
     Conditional=CHANNEL_MESSAGING,
     Constructor,
     ConstructorCallWith=ScriptExecutionContext,
index 225ec88..74750a3 100644 (file)
@@ -26,7 +26,7 @@
  */
 
 [
-    GlobalContext=DOMWindow&WorkerGlobalScope,
+    Exposed=(Window,Worker),
     ConstructorTemplate=Event,
 ] interface MessageEvent : Event {
     [InitializedByEventConstructor] readonly attribute DOMString origin;
index cc7e4f5..e0c6d26 100644 (file)
@@ -29,7 +29,7 @@
  */
 
 [
-    GlobalContext=DOMWindow&WorkerGlobalScope,
+    Exposed=(Window,Worker),
     GenerateIsReachable=Impl,
     CustomToJSObject,
     CustomConstructor,
index acee0ac..cb8be97 100644 (file)
@@ -30,7 +30,7 @@
  */
 
 [
-    GlobalContext=DOMWindow&WorkerGlobalScope,
+    Exposed=(Window,Worker),
     ActiveDOMObject,
     Constructor,
     ConstructorCallWith=ScriptExecutionContext,
index 1bd217d..5705256 100644 (file)
@@ -31,7 +31,7 @@
 [
     Constructor,
     UsePointersEvenForNonNullableObjectArguments,
-    GlobalContext=WorkerGlobalScope,
+    Exposed=Worker,
 ] interface FileReaderSync {
     [CallWith=ScriptExecutionContext, RaisesException] ArrayBuffer readAsArrayBuffer(Blob blob);
     [CallWith=ScriptExecutionContext, RaisesException] DOMString readAsBinaryString(Blob blob);
index 39c115b..49fe767 100644 (file)
@@ -25,7 +25,7 @@
  */
 
 [
-    GlobalContext=DOMWindow&WorkerGlobalScope,
+    Exposed=(Window,Worker),
     Constructor(DOMString url),
     Constructor(DOMString url, DOMString base),
     Constructor(DOMString url, DOMURL base),
index 980ab2c..b0f7ea2 100644 (file)
@@ -27,7 +27,7 @@
  */
 
 [
-    GlobalContext=DOMWindow&WorkerGlobalScope,
+    Exposed=(Window,Worker),
     CustomToJSObject,
     // FIXME: Without [Default=Undefined] CodeGeneratorJS can't generate JSImageData. But with
     // the extended attribute we accept a value of 0 for sh and don't throw.
index 36f8d89..b069aa8 100644 (file)
@@ -30,7 +30,7 @@
  */
 
 [
-    GlobalContext=DOMWindow&WorkerGlobalScope,
+    Exposed=(Window,Worker),
     ActiveDOMObject,
     Constructor(DOMString url, optional Dictionary eventSourceInit),
     ConstructorCallWith=ScriptExecutionContext,
index 01f3739..90e0cf7 100644 (file)
@@ -29,7 +29,7 @@
  */
 
 [
-    GlobalContext=DedicatedWorkerGlobalScope,
+    Exposed=DedicatedWorker,
     CustomProxyToJSObject,
     JSGenerateToNativeObject,
 ] interface DedicatedWorkerGlobalScope : WorkerGlobalScope {
index e12d265..44d953e 100644 (file)
@@ -25,7 +25,7 @@
  */
 
 [
-    GlobalContext=WorkerGlobalScope,
+    Exposed=Worker,
     CustomProxyToJSObject,
     JSCustomMarkFunction,
     JSCustomGetOwnPropertySlotAndDescriptor,
index 567bdbd..89e09c7 100644 (file)
@@ -27,7 +27,7 @@
  */
 
 [
-    GlobalContext=WorkerGlobalScope,
+    Exposed=Worker,
     GenerateIsReachable=Impl,
     ImplementationLacksVTable,
 ] interface WorkerLocation {
index d47e9f4..fa89466 100644 (file)
@@ -36,7 +36,7 @@ enum XMLHttpRequestResponseType {
 };
 
 [
-    GlobalContext=DOMWindow&WorkerGlobalScope,
+    Exposed=(Window,Worker),
     ActiveDOMObject,
     Constructor,
     ConstructorCallWith=ScriptExecutionContext,
index 19c6551..09ddc77 100644 (file)
@@ -27,7 +27,7 @@
  */
 
 [
-    GlobalContext=DOMWindow&WorkerGlobalScope,
+    Exposed=(Window,Worker),
     SuppressToJSObject,
 ] interface XMLHttpRequestEventTarget : EventTarget {
      attribute EventHandler onloadstart;