Source/WebCore:
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 3 Aug 2017 17:51:22 +0000 (17:51 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 3 Aug 2017 17:51:22 +0000 (17:51 +0000)
commit8a8830a0e82a721846d792ba8115066bed0076d7
treeed096e75519f465d3b38d824d6d480250693d7ae
parentdfa87d776fe8c29a3bc70be2aa3a6d5fb54ef72d
Source/WebCore:
[WebIDL] Convert MutationCallback to be a normal generated callback
https://bugs.webkit.org/show_bug.cgi?id=174140

Reviewed by Darin Adler.

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 [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.
- Converted callback objects to all inherit directly from ActiveDOMCallback rather
  than having the generated JS callback derived class inherit from it. This allows
  us to have access to a callback's canInvokeCallback() function anywhere (needed
  for MutationCallback) as well as giving a place to put an optional virtual
  visitJSFunction to allow marking weak callbacks (while not an ideal layering,
  this matches what we do in EventListener). This change requires each callback to
  have a bit more code to import the ActiveDOMCallback's constructor and requires
  non-JS derived callbacks to pass a ScriptExecutionContext (e.g. the Document).

* CMakeLists.txt:
* DerivedSources.make:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSMutationCallback.cpp: Removed.
* bindings/js/JSMutationCallback.h: Removed.
Remove custom JSMutationCallback.h/cpp

* Modules/geolocation/PositionCallback.h:
* Modules/geolocation/PositionErrorCallback.h:
* Modules/notifications/NotificationPermissionCallback.h:
* Modules/webaudio/AudioBufferCallback.h:
* Modules/webdatabase/DatabaseCallback.h:
* Modules/webdatabase/SQLStatementCallback.h:
* Modules/webdatabase/SQLStatementErrorCallback.h:
* Modules/webdatabase/SQLTransactionCallback.h:
* Modules/webdatabase/SQLTransactionErrorCallback.h:
* css/MediaQueryListListener.h:
* dom/NodeFilter.h:
* dom/RequestAnimationFrameCallback.h:
* dom/StringCallback.h:
* fileapi/BlobCallback.h:
* html/VoidCallback.h:
* page/IntersectionObserverCallback.h:
* page/PerformanceObserverCallback.h:
Add ActiveDOMCallback as a base class. Import the ActiveDOMCallback constructor.

* Modules/mediastream/MediaDevicesRequest.cpp:
(WebCore::MediaDevicesRequest::filterDeviceList):
(WebCore::MediaDevicesRequest::start):
* Modules/mediastream/MediaDevicesRequest.h:
Change filterDeviceList to take a Vector of Refs.

* 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 and give JSCallbackDataWeak a visitJSFunction
to allow marking the underlying function.

* bindings/js/JSMutationObserverCustom.cpp:
(WebCore::JSMutationObserver::visitAdditionalChildren):
(WebCore::constructJSMutationObserver): Deleted.
Remove the custom constructor and replace it with a custom visitAdditionalChildren
that calls the new ActiveDOMObject's visitJSFunction.

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

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateCallbackHeaderContent):
(GenerateCallbackImplementationContent):
(GetJSCallbackDataType): Deleted.
- Add support for [CallbackThisObject]. When [CallbackThisObject] is not specified, use jsUndefined()
  as the this object as specified by WebIDL.
- Stop inheriting from ActiveDOMCallback now that callbacks need to do this themselves.
- Add a visitJSFunction override for weak callback functions which calls into the callback data.

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

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

* css/FontFaceSet.h:
Use Ref rather than RefPtr for the faces sequence.

* dom/ActiveDOMCallback.h:
(WebCore::ActiveDOMCallback::visitJSFunction):
Add an optional visitJSFunction virtual function so that derived classes
have a way of marking underlying function objects.

* dom/MutationCallback.h:
Convert to support generation (return a CallbackResult, inherit from ActiveDOMObject).

* dom/MutationCallback.idl: Added.
Added to generate the callback. Uses the new [CallbackThisObject].

* dom/MutationObserver.cpp:
(WebCore::MutationObserver::deliver):
Switch to call idiomatic handleEvent, and pass *this as the first parameter
which will be translated into the this object.

* dom/MutationObserver.h:
(WebCore::MutationObserver::callback):
Expose the callback so it can marked during GC.

* dom/MutationObserver.idl:
Remove CustomConstructor and replace it with a custom mark function.

* dom/NativeNodeFilter.cpp:
* dom/NativeNodeFilter.h:
* inspector/InspectorDatabaseAgent.cpp:
Pass now needed ScriptExecutionContext to non-js based callbacks.

* 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:
* bindings/scripts/test/TestCallbackFunctionWithThisObject.idl: Added.
* bindings/scripts/test/TestCallbackInterface.idl:
Add/update tests.

Source/WebKit:
[WebIDL] Convert MutationCallback to be a normal generated callback
https://bugs.webkit.org/show_bug.cgi?id=174140

Reviewed by Darin Adler.

* WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDocument.cpp:
* WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMNodeFilter.cpp:
* WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMNodeFilterPrivate.h:
Pass, now necessary, Document to NativeNodeFilter constructor.

Source/WebKitLegacy/mac:
[WebIDL] Convert MutationCallback to be a normal generated callback
https://bugs.webkit.org/show_bug.cgi?id=174140

Reviewed by Darin Adler.

* DOM/DOMDocument.mm:
(-[DOMDocument createNodeIterator:whatToShow:filter:expandEntityReferences:]):
(-[DOMDocument createTreeWalker:whatToShow:filter:expandEntityReferences:]):
Pass, now necessary, Document to NativeNodeFilter constructor.

LayoutTests:
[WebIDL] Convert MutationCallback to be a normal generate callback
https://bugs.webkit.org/show_bug.cgi?id=174140

Reviewed by Darin Adler.

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

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220210 268f45cc-cd09-0410-ab3c-d52691b4dbfc
64 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/geolocation/PositionCallback.h
Source/WebCore/Modules/geolocation/PositionErrorCallback.h
Source/WebCore/Modules/mediastream/MediaDevicesRequest.cpp
Source/WebCore/Modules/mediastream/MediaDevicesRequest.h
Source/WebCore/Modules/notifications/NotificationPermissionCallback.h
Source/WebCore/Modules/webaudio/AudioBufferCallback.h
Source/WebCore/Modules/webdatabase/DatabaseCallback.h
Source/WebCore/Modules/webdatabase/SQLStatementCallback.h
Source/WebCore/Modules/webdatabase/SQLStatementErrorCallback.h
Source/WebCore/Modules/webdatabase/SQLTransactionCallback.h
Source/WebCore/Modules/webdatabase/SQLTransactionErrorCallback.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/JSTestCallbackFunction.h
Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionRethrow.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionRethrow.h
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/JSTestCallbackFunctionWithTypedefs.h
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/JS/JSTestVoidCallbackFunction.h
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/css/MediaQueryListListener.h
Source/WebCore/dom/ActiveDOMCallback.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.h
Source/WebCore/dom/MutationObserver.idl
Source/WebCore/dom/NativeNodeFilter.cpp
Source/WebCore/dom/NativeNodeFilter.h
Source/WebCore/dom/NodeFilter.h
Source/WebCore/dom/RequestAnimationFrameCallback.h
Source/WebCore/dom/StringCallback.h
Source/WebCore/fileapi/BlobCallback.h
Source/WebCore/html/VoidCallback.h
Source/WebCore/inspector/InspectorDatabaseAgent.cpp
Source/WebCore/page/IntersectionObserverCallback.h
Source/WebCore/page/PerformanceObserverCallback.h
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDocument.cpp
Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMNodeFilter.cpp
Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMNodeFilterPrivate.h
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/DOM/DOMDocument.mm