[WebIDL] Add support for modern callback syntax
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 5 Nov 2016 00:03:32 +0000 (00:03 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 5 Nov 2016 00:03:32 +0000 (00:03 +0000)
commit1c7ce56ce3e746b2086123fda053b9747e28403d
tree167b39ffe86ff9b6c881d89420ec7ee349677533
parentaec8dd8a3e33a620b0cc06104040813d9f195400
[WebIDL] Add support for modern callback syntax
https://bugs.webkit.org/show_bug.cgi?id=164435

Patch by Sam Weinig <sam@webkit.org> on 2016-11-04
Reviewed by Chris Dumez.

Support new callback syntax:
    callback Function = void (DOMString arg1, long arg2);

This replaces "callback interface" types with a Callback=FunctionOnly
extended attribute.

* Modules/geolocation/PositionCallback.idl:
* Modules/geolocation/PositionErrorCallback.idl:
* Modules/notifications/NotificationPermissionCallback.idl:
* Modules/quota/StorageErrorCallback.idl:
* Modules/quota/StorageQuotaCallback.idl:
* Modules/quota/StorageUsageCallback.idl:
* Modules/webaudio/AudioBufferCallback.idl:
* Modules/webdatabase/DatabaseCallback.idl:
* Modules/webdatabase/SQLStatementCallback.idl:
* Modules/webdatabase/SQLStatementErrorCallback.idl:
* Modules/webdatabase/SQLTransactionCallback.idl:
* Modules/webdatabase/SQLTransactionErrorCallback.idl:
* dom/RequestAnimationFrameCallback.idl:
* dom/StringCallback.idl:
* html/VoidCallback.idl:
* page/IntersectionObserverCallback.idl:
* css/MediaQueryListListener.idl:
Update to new syntax.

* css/MediaQueryListListener.h:
* css/MediaQueryMatcher.cpp:
(WebCore::MediaQueryMatcher::styleResolverChanged):
Switch to using the now required 'handleEvent' name. This is an implementation detail
that we should change.

* bindings/scripts/CodeGenerator.pm:
Update document processing to allow a callback only file. Update callback
type checks to look for a regex that matches in the new format.

* bindings/scripts/CodeGeneratorJS.pm:
(AddToImplIncludesForIDLType):
(AddToIncludesForIDLType):
(AddToImplIncludes):
(AddToIncludes):
Abstract includes functions to allow passing in an include hash.

(GenerateCallbackFunctionHeader):
(GenerateCallbackFunctionImplementation):
(GenerateCallbackInterfaceHeader):
(GenerateCallbackInterfaceImplementation):
(GenerateCallbackHeaderContent):
(GenerateCallbackImplementationContent):
Refactor callback generation code into GenerateCallbackHeaderContent and GenerateCallbackImplementationContent
to allow using it for both the new callbacks as well as the old callback interfaces.

* bindings/scripts/IDLParser.pm:
(Parse):
(applyTypedefs):
(applyTypedefsToOperation):
(parseCallbackRest):
Parse callbacks into the new IDLCallbackFunction type. Ensure that typedefs are applied as well.

* bindings/scripts/IDLAttributes.txt:
Remove support for Callback=FunctionOnly.

* bindings/scripts/test/JS/JSTestCallback.cpp: Removed.
* bindings/scripts/test/JS/JSTestCallback.h: Removed.
* bindings/scripts/test/JS/JSTestCallbackFunction.cpp:
* bindings/scripts/test/JS/JSTestCallbackFunction.h:
* bindings/scripts/test/JS/JSTestCallbackFunctionWithTypedefs.cpp: Added.
* bindings/scripts/test/JS/JSTestCallbackFunctionWithTypedefs.h: Added.
* bindings/scripts/test/JS/JSTestCallbackInterface.cpp: Copied from Source/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp.
* bindings/scripts/test/JS/JSTestCallbackInterface.h: Copied from Source/WebCore/bindings/scripts/test/JS/JSTestCallback.h.
* bindings/scripts/test/JS/JSTestObj.cpp:
* bindings/scripts/test/JS/JSTestTypedefs.cpp:
* bindings/scripts/test/TestCallback.idl: Removed.
* bindings/scripts/test/TestCallbackFunction.idl:
* bindings/scripts/test/TestCallbackFunctionWithTypedefs.idl: Added.
* bindings/scripts/test/TestCallbackInterface.idl: Copied from Source/WebCore/bindings/scripts/test/TestCallback.idl.
* bindings/scripts/test/TestObj.idl:
* bindings/scripts/test/TestTypedefs.idl:
Update existing tests and add new ones to test callback functions specifically.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208408 268f45cc-cd09-0410-ab3c-d52691b4dbfc
37 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/geolocation/PositionCallback.idl
Source/WebCore/Modules/geolocation/PositionErrorCallback.idl
Source/WebCore/Modules/notifications/NotificationPermissionCallback.idl
Source/WebCore/Modules/quota/StorageErrorCallback.idl
Source/WebCore/Modules/quota/StorageQuotaCallback.idl
Source/WebCore/Modules/quota/StorageUsageCallback.idl
Source/WebCore/Modules/webaudio/AudioBufferCallback.idl
Source/WebCore/Modules/webdatabase/DatabaseCallback.idl
Source/WebCore/Modules/webdatabase/SQLStatementCallback.idl
Source/WebCore/Modules/webdatabase/SQLStatementErrorCallback.idl
Source/WebCore/Modules/webdatabase/SQLTransactionCallback.idl
Source/WebCore/Modules/webdatabase/SQLTransactionErrorCallback.idl
Source/WebCore/bindings/scripts/CodeGenerator.pm
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/IDLAttributes.txt
Source/WebCore/bindings/scripts/IDLParser.pm
Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunction.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunction.h
Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionWithTypedefs.cpp [new file with mode: 0644]
Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionWithTypedefs.h [new file with mode: 0644]
Source/WebCore/bindings/scripts/test/JS/JSTestCallbackInterface.cpp [moved from Source/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp with 70% similarity]
Source/WebCore/bindings/scripts/test/JS/JSTestCallbackInterface.h [moved from Source/WebCore/bindings/scripts/test/JS/JSTestCallback.h with 77% similarity]
Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp
Source/WebCore/bindings/scripts/test/TestCallbackFunction.idl
Source/WebCore/bindings/scripts/test/TestCallbackFunctionWithTypedefs.idl [new file with mode: 0644]
Source/WebCore/bindings/scripts/test/TestCallbackInterface.idl [moved from Source/WebCore/bindings/scripts/test/TestCallback.idl with 60% similarity]
Source/WebCore/bindings/scripts/test/TestObj.idl
Source/WebCore/bindings/scripts/test/TestTypedefs.idl
Source/WebCore/css/MediaQueryListListener.h
Source/WebCore/css/MediaQueryListListener.idl
Source/WebCore/css/MediaQueryMatcher.cpp
Source/WebCore/dom/RequestAnimationFrameCallback.idl
Source/WebCore/dom/StringCallback.idl
Source/WebCore/html/VoidCallback.idl
Source/WebCore/page/IntersectionObserverCallback.idl