[WebIDL] Convert MutationCallback to be a normal generate callback
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Jul 2017 21:07:08 +0000 (21:07 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Jul 2017 21:07:08 +0000 (21:07 +0000)
commite85eccaf710b6d0fa02fba40addb170a534fcad8
tree1fbc1c1560360337f8308b0e8402f31a08410eb3
parentf338247ba3e24b00051744014a28a6b749cc075b
[WebIDL] Convert MutationCallback to be a normal generate callback
https://bugs.webkit.org/show_bug.cgi?id=174140

Reviewed by Chris Dumez.

Source/WebCore:

To make this work more nicely, I:
- Added the ability to for non-nullable interfaces in sequences to be passed
  via a Ref<> rather than a RefPtr<> as a parameter to a callback function.
  (e.g. callback MyCallback = void (sequence<Foo> foos) will now have the
  signature, CallbackResult<void> handleEvent(const Vector<Ref<Foo>>&) rather
  than CallbackResult<void> handleEvent(const Vector<RefPtr<Foo>>&).
- Added a new extended attribute for callback functions called [CallbackNeedsCanInvoke]
  that adds a virtual function called canInvoke() to the generated callback.
  All it does is forward to ActiveDOMCallback's canInvokeCallback, but it
  allows the implementation to get to it. We may one day want to move the
  inheritance of ActiveDOMCallback from the generated source to the base class.
- Added a new extended attribute for callback functions called [CallbackThisObject=Type]
  which allows you to specify that the callback needs a this object in addition
  to its arguments. When specified, the first argument of the C++ implementation
  function will now correspond to the this object, with the remaining arguments
  shifted over one.

* DerivedSources.make:
Add MutationCallback.

* WebCore.xcodeproj/project.pbxproj:
Remove non-generated JSMutationCallback.cpp, and add generated JSMutationCallback.cpp.

* Modules/mediastream/MediaDevicesRequest.cpp:
(WebCore::MediaDevicesRequest::filterDeviceList):
(WebCore::MediaDevicesRequest::start):
* Modules/mediastream/MediaDevicesRequest.h:
Switch to using Ref.

* bindings/IDLTypes.h:
Add InnerParameterType and NullableInnerParameterType type hooks
and specialize wrappers to use Ref for InnerParameterType, and RefPtr
for NullableInnerParameterType.

* bindings/js/JSCallbackData.cpp:
* bindings/js/JSCallbackData.h:
Add support for passing a this object.

* bindings/js/JSMutationCallback.cpp: Removed.
* bindings/js/JSMutationCallback.h: Removed.
Remove custom callback code.

* bindings/js/JSMutationObserverCustom.cpp:
(WebCore::constructJSMutationObserver): Deleted.
Remove no longer needed custom constructor.

* bindings/scripts/CodeGenerator.pm:
(ParseType):
Add helper to parse a type and cache the result.

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateCallbackHeaderContent):
(GenerateCallbackImplementationContent):
Add support for [CallbackNeedsCanInvoke] and [CallbackThisObject]. When [CallbackThisObject]
is not specified, use jsUndefined() as the this object as specified by WebIDL.

* bindings/scripts/IDLAttributes.json:
Add [CallbackNeedsCanInvoke] and [CallbackThisObject].

* bindings/scripts/IDLParser.pm:
(ParseType):
Add entry point to parse a single type.

* css/FontFaceSet.h:
Switch to using Ref.

* dom/MutationCallback.h:
Update signatures.

* dom/MutationCallback.idl: Added.

* dom/MutationObserver.cpp:
(WebCore::MutationObserver::canDeliver):
(WebCore::MutationObserver::deliver):
Switch to new signatures.

* dom/MutationObserver.idl:
Remove CustomConstructor.

* page/IntersectionObserverCallback.h:
Switch to using Ref.

* bindings/scripts/test/JS/JSTestCallbackFunction.cpp:
* bindings/scripts/test/JS/JSTestCallbackFunctionRethrow.cpp:
* bindings/scripts/test/JS/JSTestCallbackFunctionWithThisObject.cpp: Added.
* bindings/scripts/test/JS/JSTestCallbackFunctionWithThisObject.h: Added.
* bindings/scripts/test/JS/JSTestCallbackFunctionWithTypedefs.cpp:
* bindings/scripts/test/JS/JSTestCallbackInterface.cpp:
* bindings/scripts/test/JS/JSTestCallbackInterface.h:
* bindings/scripts/test/JS/JSTestVoidCallbackFunction.cpp:
Add / update bindings tests.

LayoutTests:

* fast/dom/MutationObserver/mutation-observer-constructor-expected.txt:
Update results for standard error messages.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219361 268f45cc-cd09-0410-ab3c-d52691b4dbfc
33 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/MutationObserver/mutation-observer-constructor-expected.txt
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources.make
Source/WebCore/Modules/mediastream/MediaDevicesRequest.cpp
Source/WebCore/Modules/mediastream/MediaDevicesRequest.h
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/IDLTypes.h
Source/WebCore/bindings/js/JSCallbackData.cpp
Source/WebCore/bindings/js/JSCallbackData.h
Source/WebCore/bindings/js/JSMutationCallback.cpp [deleted file]
Source/WebCore/bindings/js/JSMutationObserverCustom.cpp
Source/WebCore/bindings/scripts/CodeGenerator.pm
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/IDLAttributes.json
Source/WebCore/bindings/scripts/IDLParser.pm
Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunction.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionRethrow.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionWithThisObject.cpp [new file with mode: 0644]
Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionWithThisObject.h [new file with mode: 0644]
Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionWithTypedefs.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestCallbackInterface.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestCallbackInterface.h
Source/WebCore/bindings/scripts/test/JS/JSTestVoidCallbackFunction.cpp
Source/WebCore/bindings/scripts/test/TestCallbackFunctionWithThisObject.idl [new file with mode: 0644]
Source/WebCore/bindings/scripts/test/TestCallbackInterface.idl
Source/WebCore/css/FontFaceSet.h
Source/WebCore/dom/MutationCallback.h
Source/WebCore/dom/MutationCallback.idl [moved from Source/WebCore/bindings/js/JSMutationCallback.h with 57% similarity]
Source/WebCore/dom/MutationObserver.cpp
Source/WebCore/dom/MutationObserver.idl
Source/WebCore/page/IntersectionObserverCallback.h