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)
[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

index 7fb5622..51d39a0 100644 (file)
@@ -1,3 +1,13 @@
+2017-08-01  Sam Weinig  <sam@webkit.org>
+
+        [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.
+
 2017-08-03  Chris Dumez  <cdumez@apple.com>
 
         Improve our support for referrer policies
index 4a63076..20a2313 100644 (file)
@@ -8,10 +8,10 @@ PASS typeof WebKitMutationObserver.prototype.observe is "function"
 PASS typeof WebKitMutationObserver.prototype.disconnect is "function"
 PASS typeof observer.observe is "function"
 PASS typeof observer.disconnect is "function"
-PASS new MutationObserver({ handleEvent: function() {} }) threw exception TypeError: Argument 1 ('callback') to the MutationObserver constructor must be an instance of MutationCallback.
-PASS new MutationObserver({}) threw exception TypeError: Argument 1 ('callback') to the MutationObserver constructor must be an instance of MutationCallback.
-PASS new MutationObserver(42) threw exception TypeError: Argument 1 ('callback') to the MutationObserver constructor must be an instance of MutationCallback.
-PASS new MutationObserver("foo") threw exception TypeError: Argument 1 ('callback') to the MutationObserver constructor must be an instance of MutationCallback.
+PASS new MutationObserver({ handleEvent: function() {} }) threw exception TypeError: Argument 1 ('callback') to the MutationObserver constructor must be a function.
+PASS new MutationObserver({}) threw exception TypeError: Argument 1 ('callback') to the MutationObserver constructor must be a function.
+PASS new MutationObserver(42) threw exception TypeError: Argument 1 ('callback') to the MutationObserver constructor must be a function.
+PASS new MutationObserver("foo") threw exception TypeError: Argument 1 ('callback') to the MutationObserver constructor must be a function.
 PASS successfullyParsed is true
 
 TEST COMPLETE
index 74af435..c381b68 100644 (file)
@@ -477,6 +477,7 @@ set(WebCore_NON_SVG_IDL_FILES
     dom/MessagePort.idl
     dom/MouseEvent.idl
     dom/MouseEventInit.idl
+    dom/MutationCallback.idl
     dom/MutationEvent.idl
     dom/MutationObserver.idl
     dom/MutationRecord.idl
@@ -1216,7 +1217,6 @@ set(WebCore_SOURCES
     bindings/js/JSMessageChannelCustom.cpp
     bindings/js/JSMessageEventCustom.cpp
     bindings/js/JSMessagePortCustom.cpp
-    bindings/js/JSMutationCallback.cpp
     bindings/js/JSMutationObserverCustom.cpp
     bindings/js/JSNodeCustom.cpp
     bindings/js/JSNodeIteratorCustom.cpp
index 35dd0ed..a113f22 100644 (file)
@@ -1,3 +1,141 @@
+2017-08-02  Sam Weinig  <sam@webkit.org>
+
+        [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.
+
 2017-08-03  Jeremy Jones  <jeremyj@apple.com>
 
         Use MPAVRoutingController instead of deprecated versions.
index 326705a..27fd1e3 100644 (file)
@@ -406,6 +406,7 @@ JS_BINDING_IDLS = \
     $(WebCore)/dom/MessagePort.idl \
     $(WebCore)/dom/MouseEvent.idl \
     $(WebCore)/dom/MouseEventInit.idl \
+    $(WebCore)/dom/MutationCallback.idl \
     $(WebCore)/dom/MutationEvent.idl \
     $(WebCore)/dom/MutationObserver.idl \
     $(WebCore)/dom/MutationRecord.idl \
index b6e8870..4b57382 100644 (file)
@@ -25,6 +25,7 @@
 
 #pragma once
 
+#include "ActiveDOMCallback.h"
 #include "CallbackResult.h"
 #include <wtf/RefCounted.h>
 
@@ -32,9 +33,10 @@ namespace WebCore {
 
 class Geoposition;
 
-class PositionCallback : public RefCounted<PositionCallback> {
+class PositionCallback : public RefCounted<PositionCallback>, public ActiveDOMCallback {
 public:
-    virtual ~PositionCallback() { }
+    using ActiveDOMCallback::ActiveDOMCallback;
+
     virtual CallbackResult<void> handleEvent(Geoposition*) = 0;
 };
 
index 3fda16a..4816b1d 100644 (file)
@@ -25,6 +25,7 @@
 
 #pragma once
 
+#include "ActiveDOMCallback.h"
 #include "CallbackResult.h"
 #include <wtf/RefCounted.h>
 
@@ -32,9 +33,10 @@ namespace WebCore {
 
 class PositionError;
 
-class PositionErrorCallback : public RefCounted<PositionErrorCallback> {
+class PositionErrorCallback : public RefCounted<PositionErrorCallback>, public ActiveDOMCallback {
 public:
-    virtual ~PositionErrorCallback() { }
+    using ActiveDOMCallback::ActiveDOMCallback;
+
     virtual CallbackResult<void> handleEvent(PositionError&) = 0;
 };
 
index 18e2597..c11827f 100644 (file)
@@ -79,7 +79,7 @@ void MediaDevicesRequest::contextDestroyed()
     ContextDestructionObserver::contextDestroyed();
 }
 
-void MediaDevicesRequest::filterDeviceList(Vector<RefPtr<MediaDeviceInfo>>& devices)
+void MediaDevicesRequest::filterDeviceList(Vector<Ref<MediaDeviceInfo>>& devices)
 {
 #if !PLATFORM(COCOA)
     UNUSED_PARAM(devices);
@@ -95,7 +95,7 @@ void MediaDevicesRequest::filterDeviceList(Vector<RefPtr<MediaDeviceInfo>>& devi
 
     int cameraCount = 0;
     int microphoneCount = 0;
-    devices.removeAllMatching([&](const RefPtr<MediaDeviceInfo>& device) -> bool {
+    devices.removeAllMatching([&](const Ref<MediaDeviceInfo>& device) -> bool {
         if (device->kind() == MediaDeviceInfo::Kind::Videoinput && ++cameraCount > defaultCameraCount)
             return true;
         if (device->kind() == MediaDeviceInfo::Kind::Audioinput && ++microphoneCount > defaultMicrophoneCount)
@@ -120,7 +120,7 @@ void MediaDevicesRequest::start()
         Document& document = downcast<Document>(*scriptExecutionContext());
         document.setDeviceIDHashSalt(deviceIdentifierHashSalt);
 
-        Vector<RefPtr<MediaDeviceInfo>> devices;
+        Vector<Ref<MediaDeviceInfo>> devices;
         for (auto& deviceInfo : captureDevices) {
             auto label = emptyString();
             if (originHasPersistentAccess || document.hasHadActiveMediaStreamTrack())
index 4af017d..33abbd6 100644 (file)
@@ -51,7 +51,7 @@ private:
 
     void contextDestroyed() final;
 
-    void filterDeviceList(Vector<RefPtr<MediaDeviceInfo>>&);
+    void filterDeviceList(Vector<Ref<MediaDeviceInfo>>&);
 
     MediaDevices::EnumerateDevicesPromise m_promise;
     RefPtr<MediaDevicesRequest> m_protector;
index 31d54c1..6db1794 100644 (file)
@@ -27,6 +27,7 @@
 
 #if ENABLE(NOTIFICATIONS)
 
+#include "ActiveDOMCallback.h"
 #include "CallbackResult.h"
 #include "Notification.h"
 #include <wtf/Forward.h>
 
 namespace WebCore {
 
-class NotificationPermissionCallback : public RefCounted<NotificationPermissionCallback> {
+class NotificationPermissionCallback : public RefCounted<NotificationPermissionCallback>, public ActiveDOMCallback {
 public:
-    virtual ~NotificationPermissionCallback() { }
+    using ActiveDOMCallback::ActiveDOMCallback;
+
     virtual CallbackResult<void> handleEvent(Notification::Permission) = 0;
 };
 
index 4f91fb9..32c15e5 100644 (file)
@@ -26,6 +26,7 @@
 
 #if ENABLE(WEB_AUDIO)
 
+#include "ActiveDOMCallback.h"
 #include "CallbackResult.h"
 #include <wtf/RefCounted.h>
 
@@ -33,9 +34,10 @@ namespace WebCore {
 
 class AudioBuffer;
 
-class AudioBufferCallback : public RefCounted<AudioBufferCallback> {
+class AudioBufferCallback : public RefCounted<AudioBufferCallback>, public ActiveDOMCallback {
 public:
-    virtual ~AudioBufferCallback() { }
+    using ActiveDOMCallback::ActiveDOMCallback;
+
     virtual CallbackResult<void> handleEvent(AudioBuffer*) = 0;
 };
 
index 18ab418..3c2b7ad 100644 (file)
@@ -30,6 +30,7 @@
 
 #pragma once
 
+#include "ActiveDOMCallback.h"
 #include "CallbackResult.h"
 #include <wtf/ThreadSafeRefCounted.h>
 
@@ -37,9 +38,10 @@ namespace WebCore {
 
 class Database;
 
-class DatabaseCallback : public ThreadSafeRefCounted<DatabaseCallback> {
+class DatabaseCallback : public ThreadSafeRefCounted<DatabaseCallback>, public ActiveDOMCallback {
 public:
-    virtual ~DatabaseCallback() { }
+    using ActiveDOMCallback::ActiveDOMCallback;
+
     virtual CallbackResult<void> handleEvent(Database&) = 0;
 };
 
index 18733ba..21c9d9e 100644 (file)
@@ -28,6 +28,7 @@
 
 #pragma once
 
+#include "ActiveDOMCallback.h"
 #include "CallbackResult.h"
 #include <wtf/ThreadSafeRefCounted.h>
 
@@ -36,9 +37,10 @@ namespace WebCore {
 class SQLTransaction;
 class SQLResultSet;
 
-class SQLStatementCallback : public ThreadSafeRefCounted<SQLStatementCallback> {
+class SQLStatementCallback : public ThreadSafeRefCounted<SQLStatementCallback>, public ActiveDOMCallback {
 public:
-    virtual ~SQLStatementCallback() { }
+    using ActiveDOMCallback::ActiveDOMCallback;
+
     virtual CallbackResult<void> handleEvent(SQLTransaction&, SQLResultSet&) = 0;
 };
 
index fc9bb72..6f2ed4f 100644 (file)
@@ -28,6 +28,7 @@
 
 #pragma once
 
+#include "ActiveDOMCallback.h"
 #include "CallbackResult.h"
 #include <wtf/ThreadSafeRefCounted.h>
 
@@ -36,9 +37,10 @@ namespace WebCore {
 class SQLTransaction;
 class SQLError;
 
-class SQLStatementErrorCallback : public ThreadSafeRefCounted<SQLStatementErrorCallback> {
+class SQLStatementErrorCallback : public ThreadSafeRefCounted<SQLStatementErrorCallback>, public ActiveDOMCallback {
 public:
-    virtual ~SQLStatementErrorCallback() { }
+    using ActiveDOMCallback::ActiveDOMCallback;
+
     virtual CallbackResult<bool> handleEvent(SQLTransaction&, SQLError&) = 0;
 };
 
index 0cf8872..3253877 100644 (file)
@@ -28,6 +28,7 @@
 
 #pragma once
 
+#include "ActiveDOMCallback.h"
 #include "CallbackResult.h"
 #include <wtf/ThreadSafeRefCounted.h>
 
@@ -35,9 +36,10 @@ namespace WebCore {
 
 class SQLTransaction;
 
-class SQLTransactionCallback : public ThreadSafeRefCounted<SQLTransactionCallback> {
+class SQLTransactionCallback : public ThreadSafeRefCounted<SQLTransactionCallback>, public ActiveDOMCallback {
 public:
-    virtual ~SQLTransactionCallback() { }
+    using ActiveDOMCallback::ActiveDOMCallback;
+
     virtual CallbackResult<void> handleEvent(SQLTransaction&) = 0;
 };
 
index c692437..827d7eb 100644 (file)
@@ -28,6 +28,7 @@
 
 #pragma once
 
+#include "ActiveDOMCallback.h"
 #include "CallbackResult.h"
 #include <wtf/ThreadSafeRefCounted.h>
 
@@ -35,9 +36,10 @@ namespace WebCore {
 
 class SQLError;
 
-class SQLTransactionErrorCallback : public ThreadSafeRefCounted<SQLTransactionErrorCallback> {
+class SQLTransactionErrorCallback : public ThreadSafeRefCounted<SQLTransactionErrorCallback>, public ActiveDOMCallback {
 public:
-    virtual ~SQLTransactionErrorCallback() { }
+    using ActiveDOMCallback::ActiveDOMCallback;
+
     virtual CallbackResult<void> handleEvent(SQLError&) = 0;
 };
 
index 80c4471..b76eea6 100644 (file)
                7CCEBFC01DD8F6AB002C40B8 /* SVGLengthValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CE58D531DD7B09300128552 /* SVGLengthValue.h */; settings = {ATTRIBUTES = (Private, ); }; };
                7CD0BA041B8F79C9005CEBBE /* ActiveDOMCallbackMicrotask.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CD0BA021B8F79C9005CEBBE /* ActiveDOMCallbackMicrotask.cpp */; };
                7CD0BA051B8F79C9005CEBBE /* ActiveDOMCallbackMicrotask.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CD0BA031B8F79C9005CEBBE /* ActiveDOMCallbackMicrotask.h */; };
+               7CD344161F3183A5000DCD49 /* JSMutationCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CD344121F3108E2000DCD49 /* JSMutationCallback.cpp */; };
                7CD494CC1A86EB1D000A87EC /* RenderAttachment.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CD494CA1A86EB1D000A87EC /* RenderAttachment.cpp */; };
                7CD494CD1A86EB1D000A87EC /* RenderAttachment.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CD494CB1A86EB1D000A87EC /* RenderAttachment.h */; settings = {ATTRIBUTES = (Private, ); }; };
                7CDE8EBE1F193BCB00168FE7 /* CSSStyleDeclaration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CDE8EBC1F193BC500168FE7 /* CSSStyleDeclaration.cpp */; };
                C6F0902C14327D4F00685849 /* JSMutationObserver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6F0902414327D4F00685849 /* JSMutationObserver.cpp */; };
                C6F0902D14327D4F00685849 /* JSMutationObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = C6F0902514327D4F00685849 /* JSMutationObserver.h */; };
                C6F0917F143A2BB900685849 /* JSMutationObserverCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6F0917E143A2BB900685849 /* JSMutationObserverCustom.cpp */; };
-               C6F420A216B7164E0052A9F2 /* JSMutationCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6F420A016B7164E0052A9F2 /* JSMutationCallback.cpp */; };
-               C6F420A316B7164E0052A9F2 /* JSMutationCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = C6F420A116B7164E0052A9F2 /* JSMutationCallback.h */; };
                C9026B651B1CF5FE001D99A7 /* JSMediaRemoteControls.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C9026B631B1CF5AB001D99A7 /* JSMediaRemoteControls.cpp */; };
                C9027F411B1D0AD200BFBFEF /* MediaSession.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C9027F3F1B1D0AD200BFBFEF /* MediaSession.cpp */; };
                C9027F421B1D0AD200BFBFEF /* MediaSession.h in Headers */ = {isa = PBXBuildFile; fileRef = C9027F401B1D0AD200BFBFEF /* MediaSession.h */; };
                7CC7E3D617208C0F003C5277 /* IDNScriptWhiteList.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = IDNScriptWhiteList.txt; sourceTree = "<group>"; };
                7CD0BA021B8F79C9005CEBBE /* ActiveDOMCallbackMicrotask.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ActiveDOMCallbackMicrotask.cpp; sourceTree = "<group>"; };
                7CD0BA031B8F79C9005CEBBE /* ActiveDOMCallbackMicrotask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ActiveDOMCallbackMicrotask.h; sourceTree = "<group>"; };
+               7CD3440D1F310836000DCD49 /* MutationCallback.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MutationCallback.idl; sourceTree = "<group>"; };
+               7CD344111F3108DD000DCD49 /* JSMutationCallback.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JSMutationCallback.h; sourceTree = "<group>"; };
+               7CD344121F3108E2000DCD49 /* JSMutationCallback.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSMutationCallback.cpp; sourceTree = "<group>"; };
                7CD494CA1A86EB1D000A87EC /* RenderAttachment.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderAttachment.cpp; sourceTree = "<group>"; };
                7CD494CB1A86EB1D000A87EC /* RenderAttachment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderAttachment.h; sourceTree = "<group>"; };
                7CDE8EBC1F193BC500168FE7 /* CSSStyleDeclaration.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSStyleDeclaration.cpp; sourceTree = "<group>"; };
                C6F0902414327D4F00685849 /* JSMutationObserver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMutationObserver.cpp; sourceTree = "<group>"; };
                C6F0902514327D4F00685849 /* JSMutationObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMutationObserver.h; sourceTree = "<group>"; };
                C6F0917E143A2BB900685849 /* JSMutationObserverCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMutationObserverCustom.cpp; sourceTree = "<group>"; };
-               C6F420A016B7164E0052A9F2 /* JSMutationCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMutationCallback.cpp; sourceTree = "<group>"; };
-               C6F420A116B7164E0052A9F2 /* JSMutationCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMutationCallback.h; sourceTree = "<group>"; };
                C9026B631B1CF5AB001D99A7 /* JSMediaRemoteControls.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMediaRemoteControls.cpp; sourceTree = "<group>"; };
                C9026B641B1CF5AB001D99A7 /* JSMediaRemoteControls.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMediaRemoteControls.h; sourceTree = "<group>"; };
                C9027F3E1B1D0AB900BFBFEF /* MediaSession.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = MediaSession.idl; sourceTree = "<group>"; };
                                46B63F6B1C6E8CDF002E914B /* JSEventTargetCustom.h */,
                                BCCBAD3A0C18BFF800CE890F /* JSHTMLCollectionCustom.cpp */,
                                BC51580A0C03D404008BB0EE /* JSHTMLDocumentCustom.cpp */,
+                               D6F7960C166FFECE0076DD18 /* JSHTMLTemplateElementCustom.cpp */,
                                512BDB4C1C46B0FF006494DF /* JSIDBCursorCustom.cpp */,
                                5141298D1C5FD7E90059E714 /* JSIDBCursorWithValueCustom.cpp */,
                                5141299A1C6C166D0059E714 /* JSIDBIndexCustom.cpp */,
                                415CDAF61E6CE0D3004F11EE /* JSMediaStreamTrackCustom.cpp */,
                                E1A5F99A0E7EAA2500AF85EA /* JSMessageChannelCustom.cpp */,
                                E1ADED460E76B8DD004A1A5E /* JSMessagePortCustom.cpp */,
+                               C6F0917E143A2BB900685849 /* JSMutationObserverCustom.cpp */,
                                BCD9C2600C17AA67005C90A2 /* JSNodeCustom.cpp */,
                                BC9439C2116CF4940048C750 /* JSNodeCustom.h */,
                                1A750DD30A90E729000FF215 /* JSNodeIteratorCustom.cpp */,
                        name = "Promises Only";
                        sourceTree = "<group>";
                };
+               7CD3441B1F32DE30000DCD49 /* Cached Attributes w/ Invalidation */ = {
+                       isa = PBXGroup;
+                       children = (
+                               DEC2975D1B4DEB2A005F5945 /* JSCustomEventCustom.cpp */,
+                               BCE7B1920D4E86960075A539 /* JSHistoryCustom.cpp */,
+                               410B7E711045FAB000D8224F /* JSMessageEventCustom.cpp */,
+                               A85F22081430377D007CC884 /* JSPopStateEventCustom.cpp */,
+                               BC348BBD0DB7F531004ABAB9 /* JSXMLHttpRequestCustom.cpp */,
+                       );
+                       name = "Cached Attributes w/ Invalidation";
+                       sourceTree = "<group>";
+               };
                7E4DE10B198B10810051CB02 /* cocoa */ = {
                        isa = PBXGroup;
                        children = (
                                BC64649611D82349006455B0 /* JSDOMStringMap.h */,
                                65DF31E509D1CC60000BE325 /* JSElement.cpp */,
                                65DF31E609D1CC60000BE325 /* JSElement.h */,
+                               7CD344121F3108E2000DCD49 /* JSMutationCallback.cpp */,
+                               7CD344111F3108DD000DCD49 /* JSMutationCallback.h */,
                                C6F0902414327D4F00685849 /* JSMutationObserver.cpp */,
                                C6F0902514327D4F00685849 /* JSMutationObserver.h */,
                                C6F08FC71431000D00685849 /* JSMutationRecord.cpp */,
                        children = (
                                7C3D8EE41E08BABE0023B084 /* GC / Wrapping Only */,
                                7CBA5BA91F0B51480034D745 /* Promises Only */,
+                               7CD3441B1F32DE30000DCD49 /* Cached Attributes w/ Invalidation */,
                                E157A8E618184C67009F821D /* JSCryptoKeyCustom.cpp */,
                                9BC5F9DF1D5AAF6A002B749D /* JSCustomElementRegistryCustom.cpp */,
-                               DEC2975D1B4DEB2A005F5945 /* JSCustomEventCustom.cpp */,
                                BCD9C25E0C17AA67005C90A2 /* JSDOMWindowCustom.cpp */,
                                652FBBBB0DE27CB60001D386 /* JSDOMWindowCustom.h */,
-                               BCE7B1920D4E86960075A539 /* JSHistoryCustom.cpp */,
                                BC5823F40C0A98DF0053F1B5 /* JSHTMLElementCustom.cpp */,
-                               D6F7960C166FFECE0076DD18 /* JSHTMLTemplateElementCustom.cpp */,
                                BCE1C43F0D9830F4003B02F2 /* JSLocationCustom.cpp */,
-                               410B7E711045FAB000D8224F /* JSMessageEventCustom.cpp */,
-                               C6F0917E143A2BB900685849 /* JSMutationObserverCustom.cpp */,
-                               A85F22081430377D007CC884 /* JSPopStateEventCustom.cpp */,
                                418C395D1C8F0AAB0051C8A3 /* JSReadableStreamSourceCustom.cpp */,
                                57A9C88D1DA70BF800BC7305 /* JSSubtleCryptoCustom.cpp */,
                                E1FF8F661807460800132674 /* JSWebKitSubtleCryptoCustom.cpp */,
-                               BC348BBD0DB7F531004ABAB9 /* JSXMLHttpRequestCustom.cpp */,
                        );
                        name = Custom;
                        sourceTree = "<group>";
                                93B70D4E09EB0C7C009D8468 /* JSEventListener.h */,
                                935F45400F7C3B5F00D7C1FB /* JSLazyEventListener.cpp */,
                                935F45410F7C3B5F00D7C1FB /* JSLazyEventListener.h */,
-                               C6F420A016B7164E0052A9F2 /* JSMutationCallback.cpp */,
-                               C6F420A116B7164E0052A9F2 /* JSMutationCallback.h */,
                                BCA378BA0D15F64200B793D6 /* ScheduledAction.cpp */,
                                BCA378BB0D15F64200B793D6 /* ScheduledAction.h */,
                        );
                                85031B310A44EFC700F992E0 /* MouseRelatedEvent.cpp */,
                                85031B320A44EFC700F992E0 /* MouseRelatedEvent.h */,
                                C6F0900114327B6100685849 /* MutationCallback.h */,
+                               7CD3440D1F310836000DCD49 /* MutationCallback.idl */,
                                85031B330A44EFC700F992E0 /* MutationEvent.cpp */,
                                85031B340A44EFC700F992E0 /* MutationEvent.h */,
                                93EEC1F309C2877700C515D1 /* MutationEvent.idl */,
                                2D6F3E951C1F85550061DBD4 /* JSMockPageOverlay.h in Headers */,
                                A86629D109DA2B48009633A5 /* JSMouseEvent.h in Headers */,
                                830A36BD1DAC5FAD006D7D09 /* JSMouseEventInit.h in Headers */,
-                               C6F420A316B7164E0052A9F2 /* JSMutationCallback.h in Headers */,
                                65DF31FC09D1CC60000BE325 /* JSMutationEvent.h in Headers */,
                                C6F0902D14327D4F00685849 /* JSMutationObserver.h in Headers */,
                                C6F08FCA1431000D00685849 /* JSMutationRecord.h in Headers */,
                                E1ADED470E76B8DD004A1A5E /* JSMessagePortCustom.cpp in Sources */,
                                A86629D209DA2B48009633A5 /* JSMouseEvent.cpp in Sources */,
                                830A36BC1DAC5FAD006D7D09 /* JSMouseEventInit.cpp in Sources */,
-                               C6F420A216B7164E0052A9F2 /* JSMutationCallback.cpp in Sources */,
                                65DF31FB09D1CC60000BE325 /* JSMutationEvent.cpp in Sources */,
                                C6F0902C14327D4F00685849 /* JSMutationObserver.cpp in Sources */,
                                C6F0917F143A2BB900685849 /* JSMutationObserverCustom.cpp in Sources */,
                                B22279F90D00BF220071B782 /* SVGFEOffsetElement.cpp in Sources */,
                                B22279FC0D00BF220071B782 /* SVGFEPointLightElement.cpp in Sources */,
                                B22279FF0D00BF220071B782 /* SVGFESpecularLightingElement.cpp in Sources */,
+                               7CD344161F3183A5000DCD49 /* JSMutationCallback.cpp in Sources */,
                                B2227A020D00BF220071B782 /* SVGFESpotLightElement.cpp in Sources */,
                                B2227A050D00BF220071B782 /* SVGFETileElement.cpp in Sources */,
                                B2227A080D00BF220071B782 /* SVGFETurbulenceElement.cpp in Sources */,
index 8bc8834..61f811d 100644 (file)
@@ -64,6 +64,9 @@ struct IDLType {
     using ParameterType = T;
     using NullableParameterType = std::optional<ImplementationType>;
 
+    using InnerParameterType = T;
+    using NullableInnerParameterType = std::optional<ImplementationType>;
+
     using NullableType = std::optional<ImplementationType>;
     static NullableType nullValue() { return std::nullopt; }
     static bool isNullValue(const NullableType& value) { return !value; }
@@ -157,6 +160,9 @@ template<typename T> struct IDLWrapper : IDLType<RefPtr<T>> {
     using ParameterType = T&;
     using NullableParameterType = T*;
 
+    using InnerParameterType = Ref<T>;
+    using NullableInnerParameterType = RefPtr<T>;
+
     using NullableType = RefPtr<T>;
     static inline std::nullptr_t nullValue() { return nullptr; }
     template<typename U> static inline bool isNullValue(U&& value) { return !value; }
@@ -180,6 +186,9 @@ template<typename T> struct IDLNullable : IDLType<typename T::NullableType> {
     using ParameterType = typename T::NullableParameterType;
     using NullableParameterType = typename T::NullableParameterType;
 
+    using InnerParameterType = typename T::NullableInnerParameterType;
+    using NullableInnerParameterType = typename T::NullableInnerParameterType;
+
     using NullableType = typename T::NullableType;
     static inline auto nullValue() -> decltype(T::nullValue()) { return T::nullValue(); }
     template<typename U> static inline bool isNullValue(U&& value) { return T::isNullValue(std::forward<U>(value)); }
@@ -189,8 +198,8 @@ template<typename T> struct IDLNullable : IDLType<typename T::NullableType> {
 template<typename T> struct IDLSequence : IDLType<Vector<typename T::ImplementationType>> {
     using InnerType = T;
 
-    using ParameterType = const Vector<typename T::ImplementationType>&;
-    using NullableParameterType = const std::optional<Vector<typename T::ImplementationType>>&;
+    using ParameterType = const Vector<typename T::InnerParameterType>&;
+    using NullableParameterType = const std::optional<Vector<typename T::InnerParameterType>>&;
 };
 
 template<typename T> struct IDLFrozenArray : IDLType<Vector<typename T::ImplementationType>> {
index 655eaf4..bcbd41d 100644 (file)
@@ -39,7 +39,7 @@ using namespace JSC;
     
 namespace WebCore {
 
-JSValue JSCallbackData::invokeCallback(JSDOMGlobalObject& globalObject, JSObject* callback, MarkedArgumentBuffer& args, CallbackType method, PropertyName functionName, NakedPtr<JSC::Exception>& returnedException)
+JSValue JSCallbackData::invokeCallback(JSDOMGlobalObject& globalObject, JSObject* callback, JSValue thisValue, MarkedArgumentBuffer& args, CallbackType method, PropertyName functionName, NakedPtr<JSC::Exception>& returnedException)
 {
     ASSERT(callback);
 
@@ -79,14 +79,19 @@ JSValue JSCallbackData::invokeCallback(JSDOMGlobalObject& globalObject, JSObject
 
     returnedException = nullptr;
     JSValue result = context->isDocument()
-        ? JSMainThreadExecState::profiledCall(exec, JSC::ProfilingReason::Other, function, callType, callData, callback, args, returnedException)
-        : JSC::profiledCall(exec, JSC::ProfilingReason::Other, function, callType, callData, callback, args, returnedException);
+        ? JSMainThreadExecState::profiledCall(exec, JSC::ProfilingReason::Other, function, callType, callData, thisValue, args, returnedException)
+        : JSC::profiledCall(exec, JSC::ProfilingReason::Other, function, callType, callData, thisValue, args, returnedException);
 
     InspectorInstrumentation::didCallFunction(cookie, context);
 
     return result;
 }
 
+void JSCallbackDataWeak::visitJSFunction(JSC::SlotVisitor& vistor)
+{
+    vistor.append(m_callback);
+}
+
 bool JSCallbackDataWeak::WeakOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown>, void* context, SlotVisitor& visitor)
 {
     return visitor.containsOpaqueRoot(context);
index 3ea990e..49e1535 100644 (file)
@@ -64,7 +64,7 @@ protected:
 #endif
     }
     
-    static JSC::JSValue invokeCallback(JSDOMGlobalObject&, JSC::JSObject* callback, JSC::MarkedArgumentBuffer&, CallbackType, JSC::PropertyName functionName, NakedPtr<JSC::Exception>& returnedException);
+    static JSC::JSValue invokeCallback(JSDOMGlobalObject&, JSC::JSObject* callback, JSC::JSValue thisValue, JSC::MarkedArgumentBuffer&, CallbackType, JSC::PropertyName functionName, NakedPtr<JSC::Exception>& returnedException);
 
 private:
     JSC::Weak<JSDOMGlobalObject> m_globalObject;
@@ -83,13 +83,13 @@ public:
 
     JSC::JSObject* callback() { return m_callback.get(); }
 
-    JSC::JSValue invokeCallback(JSC::MarkedArgumentBuffer& args, CallbackType callbackType, JSC::PropertyName functionName, NakedPtr<JSC::Exception>& returnedException)
+    JSC::JSValue invokeCallback(JSC::JSValue thisValue, JSC::MarkedArgumentBuffer& args, CallbackType callbackType, JSC::PropertyName functionName, NakedPtr<JSC::Exception>& returnedException)
     {
         auto* globalObject = this->globalObject();
         if (!globalObject)
             return { };
 
-        return JSCallbackData::invokeCallback(*globalObject, callback(), args, callbackType, functionName, returnedException);
+        return JSCallbackData::invokeCallback(*globalObject, callback(), thisValue, args, callbackType, functionName, returnedException);
     }
 
 private:
@@ -106,15 +106,17 @@ public:
 
     JSC::JSObject* callback() { return m_callback.get(); }
 
-    JSC::JSValue invokeCallback(JSC::MarkedArgumentBuffer& args, CallbackType callbackType, JSC::PropertyName functionName, NakedPtr<JSC::Exception>& returnedException)
+    JSC::JSValue invokeCallback(JSC::JSValue thisValue, JSC::MarkedArgumentBuffer& args, CallbackType callbackType, JSC::PropertyName functionName, NakedPtr<JSC::Exception>& returnedException)
     {
         auto* globalObject = this->globalObject();
         if (!globalObject)
             return { };
 
-        return JSCallbackData::invokeCallback(*globalObject, callback(), args, callbackType, functionName, returnedException);
+        return JSCallbackData::invokeCallback(*globalObject, callback(), thisValue, args, callbackType, functionName, returnedException);
     }
 
+    void visitJSFunction(JSC::SlotVisitor&);
+
 private:
     class WeakOwner : public JSC::WeakHandleOwner {
         bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown>, void* context, JSC::SlotVisitor&) override;
diff --git a/Source/WebCore/bindings/js/JSMutationCallback.cpp b/Source/WebCore/bindings/js/JSMutationCallback.cpp
deleted file mode 100644 (file)
index 318cd45..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (C) 2013 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-
-#include "config.h"
-#include "JSMutationCallback.h"
-
-#include "JSDOMConvertInterface.h"
-#include "JSDOMConvertSequences.h"
-#include "JSDOMGlobalObject.h"
-#include "JSMainThreadExecState.h"
-#include "JSMainThreadExecStateInstrumentation.h"
-#include "JSMutationObserver.h"
-#include "JSMutationRecord.h"
-#include "ScriptExecutionContext.h"
-#include <heap/WeakInlines.h>
-#include <runtime/JSLock.h>
-
-using namespace JSC;
-
-namespace WebCore {
-
-JSMutationCallback::JSMutationCallback(JSObject* callback, JSDOMGlobalObject* globalObject)
-    : ActiveDOMCallback(globalObject->scriptExecutionContext())
-    , m_callback(callback)
-    , m_isolatedWorld(globalObject->world())
-{
-}
-
-JSMutationCallback::~JSMutationCallback()
-{
-}
-
-void JSMutationCallback::call(const Vector<Ref<MutationRecord>>& mutations, MutationObserver* observer)
-{
-    if (!canInvokeCallback())
-        return;
-
-    Ref<JSMutationCallback> protectedThis(*this);
-
-    JSLockHolder lock(m_isolatedWorld->vm());
-
-    if (!m_callback)
-        return;
-
-    JSValue callback = m_callback.get();
-    CallData callData;
-    CallType callType = getCallData(callback, callData);
-    if (callType == CallType::None) {
-        ASSERT_NOT_REACHED();
-        return;
-    }
-
-    ScriptExecutionContext* context = scriptExecutionContext();
-    if (!context)
-        return;
-    ASSERT(context->isDocument());
-
-    JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(context, m_isolatedWorld);
-    ExecState* exec = globalObject->globalExec();
-
-    JSValue jsObserver = toJS(exec, globalObject, observer);
-
-    MarkedArgumentBuffer args;
-    args.append(toJS<IDLSequence<IDLInterface<MutationRecord>>>(*exec, *globalObject, mutations));
-    args.append(jsObserver);
-
-    InspectorInstrumentationCookie cookie = JSMainThreadExecState::instrumentFunctionCall(context, callType, callData);
-
-    NakedPtr<JSC::Exception> exception;
-    JSMainThreadExecState::profiledCall(exec, JSC::ProfilingReason::Other, callback, callType, callData, jsObserver, args, exception);
-
-    InspectorInstrumentation::didCallFunction(cookie, context);
-
-    if (exception)
-        reportException(exec, exception);
-}
-
-} // namespace WebCore
index e655202..4dff999 100644 (file)
 #include "config.h"
 #include "JSMutationObserver.h"
 
-#include "JSDOMConstructorBase.h"
-#include "JSMutationCallback.h"
 #include "JSNodeCustom.h"
-#include "MutationObserver.h"
-#include <runtime/Error.h>
-#include <runtime/PrivateName.h>
+#include "MutationCallback.h"
 
 using namespace JSC;
 
 namespace WebCore {
 
-EncodedJSValue JSC_HOST_CALL constructJSMutationObserver(ExecState& exec)
+void JSMutationObserver::visitAdditionalChildren(JSC::SlotVisitor& visitor)
 {
-    VM& vm = exec.vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-
-    if (exec.argumentCount() < 1)
-        return throwVMError(&exec, scope, createNotEnoughArgumentsError(&exec));
-
-    JSObject* object = exec.uncheckedArgument(0).getObject();
-    CallData callData;
-    if (!object || object->methodTable()->getCallData(object, callData) == CallType::None)
-        return throwArgumentTypeError(exec, scope, 0, "callback", "MutationObserver", nullptr, "MutationCallback");
-
-    auto* jsConstructor = jsCast<JSDOMConstructorBase*>(exec.jsCallee());
-    auto callback = JSMutationCallback::create(object, jsConstructor->globalObject());
-    JSObject* jsObserver = asObject(toJSNewlyCreated(&exec, jsConstructor->globalObject(), MutationObserver::create(WTFMove(callback))));
-    PrivateName propertyName;
-    jsObserver->putDirect(vm, propertyName, object);
-    return JSValue::encode(jsObserver);
+    wrapped().callback().visitJSFunction(visitor);
 }
 
 bool JSMutationObserverOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
index 62484f7..e212381 100644 (file)
@@ -120,6 +120,7 @@ my $idlFiles;
 my $cachedInterfaces = {};
 my $cachedExternalDictionaries = {};
 my $cachedExternalEnumerations = {};
+my $cachedTypes = {};
 
 sub assert
 {
@@ -369,6 +370,20 @@ sub ParseInterface
     die("Could NOT find interface definition for $interfaceName in $filename");
 }
 
+sub ParseType
+{
+    my ($object, $typeString) = @_;
+
+    return $cachedTypes->{$typeString} if exists($cachedTypes->{$typeString});
+
+    my $parser = IDLParser->new(1);
+    my $type = $parser->ParseType($typeString, $idlAttributes);
+
+    $cachedTypes->{$typeString} = $type;
+
+    return $type;
+}
+
 # Helpers for all CodeGenerator***.pm modules
 
 sub IsNumericType
index bf8c034..65266d3 100644 (file)
@@ -263,13 +263,6 @@ sub GetCallbackClassName
     return "JS$className";
 }
 
-sub GetJSCallbackDataType
-{
-    my $callback = shift;
-
-    return $callback->extendedAttributes->{IsWeakCallback} ? "JSCallbackDataWeak" : "JSCallbackDataStrong";
-}
-
 sub GetExportMacroForJSClass
 {
     my $interface = shift;
@@ -604,10 +597,10 @@ sub GenerateNamedGetterLambda
 
     push(@$outputArray, "    auto getterFunctor = [] (auto& thisObject, auto propertyName) -> ${returnType} {\n");
 
-    my @args = GenerateCallWithUsingReferences($namedGetterOperation->extendedAttributes->{CallWith}, $outputArray, "std::nullopt", "thisObject", "        ");
-    push(@args, "propertyNameToAtomicString(propertyName)");
+    my @arguments = GenerateCallWithUsingReferences($namedGetterOperation->extendedAttributes->{CallWith}, $outputArray, "std::nullopt", "thisObject", "        ");
+    push(@arguments, "propertyNameToAtomicString(propertyName)");
 
-    push(@$outputArray, "        auto result = thisObject.wrapped().${namedGetterFunctionName}(" . join(", ", @args) . ");\n");
+    push(@$outputArray, "        auto result = thisObject.wrapped().${namedGetterFunctionName}(" . join(", ", @arguments) . ");\n");
     
     if ($namedGetterOperation->extendedAttributes->{MayThrowException}) {
         push(@$outputArray, "        if (result.hasException())\n");
@@ -5779,16 +5772,15 @@ sub GenerateCallbackHeaderContent
     my ($object, $interfaceOrCallback, $operations, $constants, $contentRef, $includesRef) = @_;
 
     my $name = $interfaceOrCallback->type->name;
-    my $callbackDataType = GetJSCallbackDataType($interfaceOrCallback);
+    my $callbackDataType = $interfaceOrCallback->extendedAttributes->{IsWeakCallback} ? "JSCallbackDataWeak" : "JSCallbackDataStrong";
     my $className = "JS${name}";
 
-    $includesRef->{"ActiveDOMCallback.h"} = 1;
     $includesRef->{"IDLTypes.h"} = 1;
     $includesRef->{"JSCallbackData.h"} = 1;
     $includesRef->{"<wtf/Forward.h>"} = 1;
     $includesRef->{"${name}.h"} = 1;
 
-    push(@$contentRef, "class $className final : public ${name}, public ActiveDOMCallback {\n");
+    push(@$contentRef, "class $className final : public ${name} {\n");
     push(@$contentRef, "public:\n");
 
     # The static create() method.
@@ -5813,6 +5805,14 @@ sub GenerateCallbackHeaderContent
         push(@$contentRef, "\n    // Functions\n");
         foreach my $operation (@{$operations}) {
             my @arguments = ();
+
+            my $callbackThisObject = $operation->extendedAttributes->{CallbackThisObject};
+            if ($callbackThisObject) {
+                my $thisObjectType = $codeGenerator->ParseType($callbackThisObject);
+                my $IDLType = GetIDLType($interfaceOrCallback, $thisObjectType);
+                push(@arguments, "typename ${IDLType}::ParameterType thisObject");
+            }
+
             foreach my $argument (@{$operation->arguments}) {
                 my $IDLType = GetIDLType($interfaceOrCallback, $argument->type);
                 push(@arguments, "typename ${IDLType}::ParameterType " . $argument->name);
@@ -5829,10 +5829,10 @@ sub GenerateCallbackHeaderContent
 
     push(@$contentRef, "\nprivate:\n");
 
-    # Constructor
     push(@$contentRef, "    ${className}(JSC::JSObject*, JSDOMGlobalObject*);\n\n");
 
-    # Private members
+    push(@$contentRef, "    virtual void visitJSFunction(JSC::SlotVisitor&) override;\n\n") if $interfaceOrCallback->extendedAttributes->{IsWeakCallback};
+
     push(@$contentRef, "    ${callbackDataType}* m_data;\n");
     push(@$contentRef, "};\n\n");
 
@@ -5846,21 +5846,19 @@ sub GenerateCallbackImplementationContent
     my ($object, $interfaceOrCallback, $operations, $constants, $contentRef, $includesRef) = @_;
 
     my $name = $interfaceOrCallback->type->name;
-    my $callbackDataType = GetJSCallbackDataType($interfaceOrCallback);
+    my $callbackDataType = $interfaceOrCallback->extendedAttributes->{IsWeakCallback} ? "JSCallbackDataWeak" : "JSCallbackDataStrong";
     my $visibleName = $codeGenerator->GetVisibleInterfaceName($interfaceOrCallback);
     my $className = "JS${name}";
 
     $includesRef->{"ScriptExecutionContext.h"} = 1;
-    $includesRef->{"<runtime/JSLock.h>"} = 1;
 
     # Constructor
     push(@$contentRef, "${className}::${className}(JSObject* callback, JSDOMGlobalObject* globalObject)\n");
     if ($interfaceOrCallback->extendedAttributes->{CallbackNeedsOperatorEqual}) {
-        push(@$contentRef, "    : ${name}(${className}Type)\n");
+        push(@$contentRef, "    : ${name}(globalObject->scriptExecutionContext(), ${className}Type)\n");
     } else {
-        push(@$contentRef, "    : ${name}()\n");
+        push(@$contentRef, "    : ${name}(globalObject->scriptExecutionContext())\n");
     }
-    push(@$contentRef, "    , ActiveDOMCallback(globalObject->scriptExecutionContext())\n");
     push(@$contentRef, "    , m_data(new ${callbackDataType}(callback, globalObject, this))\n");
     push(@$contentRef, "{\n");
     push(@$contentRef, "}\n\n");
@@ -5944,15 +5942,31 @@ sub GenerateCallbackImplementationContent
             # FIXME: Change the default name (used for callback functions) to something other than handleEvent. It makes little sense.
             my $functionName = $operation->name || "handleEvent";
 
-            my @args = ();
+            my @arguments = ();
+
+            my $thisValue = "jsUndefined()";
+
+            my $callbackThisObject = $operation->extendedAttributes->{CallbackThisObject};
+            if ($callbackThisObject) {
+                my $thisObjectType = $codeGenerator->ParseType($callbackThisObject);
+
+                AddToIncludesForIDLType($thisObjectType, $includesRef, 1);
+                my $IDLType = GetIDLType($interfaceOrCallback, $thisObjectType);
+                push(@arguments, "typename ${IDLType}::ParameterType thisObject");
+
+                my $thisObjectArgument = IDLArgument->new();
+                $thisObjectArgument->type($thisObjectType);
+
+                $thisValue = NativeToJSValueUsingReferences($thisObjectArgument, $interfaceOrCallback, "thisObject", "globalObject");
+            }
+
             foreach my $argument (@{$operation->arguments}) {
                 AddToIncludesForIDLType($argument->type, $includesRef, 1);
-
                 my $IDLType = GetIDLType($interfaceOrCallback, $argument->type);
-                push(@args, "typename ${IDLType}::ParameterType " . $argument->name);
+                push(@arguments, "typename ${IDLType}::ParameterType " . $argument->name);
             }
             
-            push(@$contentRef, "${nativeReturnType} ${className}::${functionName}(" . join(", ", @args) . ")\n");
+            push(@$contentRef, "${nativeReturnType} ${className}::${functionName}(" . join(", ", @arguments) . ")\n");
             push(@$contentRef, "{\n");
 
             # FIXME: This is needed for NodeFilter, which works even for disconnected iframes. We should investigate
@@ -5968,6 +5982,8 @@ sub GenerateCallbackImplementationContent
             push(@$contentRef, "    JSLockHolder lock(vm);\n");
 
             push(@$contentRef, "    auto& state = *globalObject.globalExec();\n");
+
+            push(@$contentRef, "    JSValue thisValue = ${thisValue};\n");
             push(@$contentRef, "    MarkedArgumentBuffer args;\n");
 
             foreach my $argument (@{$operation->arguments}) {
@@ -5978,10 +5994,10 @@ sub GenerateCallbackImplementationContent
 
             my $callbackInvocation;
             if (ref($interfaceOrCallback) eq "IDLCallbackFunction") {
-                $callbackInvocation = "m_data->invokeCallback(args, JSCallbackData::CallbackType::Function, Identifier(), returnedException)";
+                $callbackInvocation = "m_data->invokeCallback(thisValue, args, JSCallbackData::CallbackType::Function, Identifier(), returnedException)";
             } else {
                 my $callbackType = $numOperations > 1 ? "Object" : "FunctionOrObject";
-                $callbackInvocation = "m_data->invokeCallback(args, JSCallbackData::CallbackType::${callbackType}, Identifier::fromString(&vm, \"${functionName}\"), returnedException)";
+                $callbackInvocation = "m_data->invokeCallback(thisValue, args, JSCallbackData::CallbackType::${callbackType}, Identifier::fromString(&vm, \"${functionName}\"), returnedException)";
             }
 
             if ($operation->type->name eq "void") {
@@ -6016,12 +6032,18 @@ sub GenerateCallbackImplementationContent
         }
     }
 
-    # toJS() implementation.
+    if ($interfaceOrCallback->extendedAttributes->{IsWeakCallback}) {
+        push(@$contentRef, "void ${className}::visitJSFunction(JSC::SlotVisitor& visitor)\n");
+        push(@$contentRef, "{\n");
+        push(@$contentRef, "    m_data->visitJSFunction(visitor);\n");
+        push(@$contentRef, "}\n\n");
+    }
+
     push(@$contentRef, "JSC::JSValue toJS(${name}& impl)\n");
     push(@$contentRef, "{\n");
     push(@$contentRef, "    if (!static_cast<${className}&>(impl).callbackData())\n");
     push(@$contentRef, "        return jsNull();\n\n");
-    push(@$contentRef, "    return static_cast<${className}&>(impl).callbackData()->callback();\n\n");
+    push(@$contentRef, "    return static_cast<${className}&>(impl).callbackData()->callback();\n");
     push(@$contentRef, "}\n\n");
 }
 
index 3d47758..e2f5a89 100644 (file)
@@ -38,6 +38,9 @@
         "CallbackNeedsOperatorEqual": {
             "contextsAllowed": ["callback-function"]
         },
+        "CallbackThisObject": {
+            "contextsAllowed": ["callback-function", "operation"]
+        },
         "CallNamedSetterOnlyForSupportedProperties": {
             "contextsAllowed": ["operation"]
         },
index d2d4e86..7c867d6 100644 (file)
@@ -346,6 +346,30 @@ sub Parse
     return $document;
 }
 
+sub ParseType
+{
+    my ($self, $type, $idlAttributes) = @_;
+
+    $self->{Line} = $type;
+    $self->{DocumentContent} = $type;
+    $self->{ExtendedAttributeMap} = $idlAttributes;
+
+    addBuiltinTypedefs();
+
+    my $result;
+
+    $self->getToken();
+    eval {
+        $result = $self->parseType();
+
+        my $next = $self->nextToken();
+        $self->assertTokenType($next, EmptyToken);
+    };
+    assert $@ . " parsing type ${type}" if $@;
+
+    return $result;
+}
+
 sub nextToken
 {
     my $self = shift;
index 9f675bb..5d9df45 100644 (file)
 #include "JSDOMConvertStrings.h"
 #include "JSDOMExceptionHandling.h"
 #include "ScriptExecutionContext.h"
-#include <runtime/JSLock.h>
 
 using namespace JSC;
 
 namespace WebCore {
 
 JSTestCallbackFunction::JSTestCallbackFunction(JSObject* callback, JSDOMGlobalObject* globalObject)
-    : TestCallbackFunction()
-    , ActiveDOMCallback(globalObject->scriptExecutionContext())
+    : TestCallbackFunction(globalObject->scriptExecutionContext())
     , m_data(new JSCallbackDataStrong(callback, globalObject, this))
 {
 }
@@ -64,11 +62,12 @@ CallbackResult<typename IDLDOMString::ImplementationType> JSTestCallbackFunction
 
     JSLockHolder lock(vm);
     auto& state = *globalObject.globalExec();
+    JSValue thisValue = jsUndefined();
     MarkedArgumentBuffer args;
     args.append(toJS<IDLLong>(argument));
 
     NakedPtr<JSC::Exception> returnedException;
-    auto jsResult = m_data->invokeCallback(args, JSCallbackData::CallbackType::Function, Identifier(), returnedException);
+    auto jsResult = m_data->invokeCallback(thisValue, args, JSCallbackData::CallbackType::Function, Identifier(), returnedException);
     if (returnedException) {
         reportException(&state, returnedException);
         return CallbackResultType::ExceptionThrown;
@@ -86,7 +85,6 @@ JSC::JSValue toJS(TestCallbackFunction& impl)
         return jsNull();
 
     return static_cast<JSTestCallbackFunction&>(impl).callbackData()->callback();
-
 }
 
 } // namespace WebCore
index bfcfd97..2e9b922 100644 (file)
@@ -20,7 +20,6 @@
 
 #pragma once
 
-#include "ActiveDOMCallback.h"
 #include "IDLTypes.h"
 #include "JSCallbackData.h"
 #include "TestCallbackFunction.h"
@@ -28,7 +27,7 @@
 
 namespace WebCore {
 
-class JSTestCallbackFunction final : public TestCallbackFunction, public ActiveDOMCallback {
+class JSTestCallbackFunction final : public TestCallbackFunction {
 public:
     static Ref<JSTestCallbackFunction> create(JSC::JSObject* callback, JSDOMGlobalObject* globalObject)
     {
index 6c32ee0..ba8f3ca 100644 (file)
 #include "JSDOMGlobalObject.h"
 #include "ScriptExecutionContext.h"
 #include <runtime/JSArray.h>
-#include <runtime/JSLock.h>
 
 using namespace JSC;
 
 namespace WebCore {
 
 JSTestCallbackFunctionRethrow::JSTestCallbackFunctionRethrow(JSObject* callback, JSDOMGlobalObject* globalObject)
-    : TestCallbackFunctionRethrow()
-    , ActiveDOMCallback(globalObject->scriptExecutionContext())
+    : TestCallbackFunctionRethrow(globalObject->scriptExecutionContext())
     , m_data(new JSCallbackDataStrong(callback, globalObject, this))
 {
 }
@@ -67,11 +65,12 @@ CallbackResult<typename IDLDOMString::ImplementationType> JSTestCallbackFunction
 
     JSLockHolder lock(vm);
     auto& state = *globalObject.globalExec();
+    JSValue thisValue = jsUndefined();
     MarkedArgumentBuffer args;
     args.append(toJS<IDLSequence<IDLLong>>(state, globalObject, argument));
 
     NakedPtr<JSC::Exception> returnedException;
-    auto jsResult = m_data->invokeCallback(args, JSCallbackData::CallbackType::Function, Identifier(), returnedException);
+    auto jsResult = m_data->invokeCallback(thisValue, args, JSCallbackData::CallbackType::Function, Identifier(), returnedException);
     if (returnedException) {
         auto throwScope = DECLARE_THROW_SCOPE(vm);
         throwException(&state, throwScope, returnedException);
@@ -90,7 +89,6 @@ JSC::JSValue toJS(TestCallbackFunctionRethrow& impl)
         return jsNull();
 
     return static_cast<JSTestCallbackFunctionRethrow&>(impl).callbackData()->callback();
-
 }
 
 } // namespace WebCore
index 99c100f..c180a86 100644 (file)
@@ -20,7 +20,6 @@
 
 #pragma once
 
-#include "ActiveDOMCallback.h"
 #include "IDLTypes.h"
 #include "JSCallbackData.h"
 #include "TestCallbackFunctionRethrow.h"
@@ -28,7 +27,7 @@
 
 namespace WebCore {
 
-class JSTestCallbackFunctionRethrow final : public TestCallbackFunctionRethrow, public ActiveDOMCallback {
+class JSTestCallbackFunctionRethrow final : public TestCallbackFunctionRethrow {
 public:
     static Ref<JSTestCallbackFunctionRethrow> create(JSC::JSObject* callback, JSDOMGlobalObject* globalObject)
     {
diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionWithThisObject.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionWithThisObject.cpp
new file mode 100644 (file)
index 0000000..21b2db7
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+    This file is part of the WebKit open source project.
+    This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#include "JSTestCallbackFunctionWithThisObject.h"
+
+#include "JSDOMConvertInterface.h"
+#include "JSDOMConvertSequences.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMGlobalObject.h"
+#include "JSTestNode.h"
+#include "ScriptExecutionContext.h"
+#include <runtime/JSArray.h>
+
+using namespace JSC;
+
+namespace WebCore {
+
+JSTestCallbackFunctionWithThisObject::JSTestCallbackFunctionWithThisObject(JSObject* callback, JSDOMGlobalObject* globalObject)
+    : TestCallbackFunctionWithThisObject(globalObject->scriptExecutionContext())
+    , m_data(new JSCallbackDataStrong(callback, globalObject, this))
+{
+}
+
+JSTestCallbackFunctionWithThisObject::~JSTestCallbackFunctionWithThisObject()
+{
+    ScriptExecutionContext* context = scriptExecutionContext();
+    // When the context is destroyed, all tasks with a reference to a callback
+    // should be deleted. So if the context is 0, we are on the context thread.
+    if (!context || context->isContextThread())
+        delete m_data;
+    else
+        context->postTask(DeleteCallbackDataTask(m_data));
+#ifndef NDEBUG
+    m_data = nullptr;
+#endif
+}
+
+CallbackResult<typename IDLVoid::ImplementationType> JSTestCallbackFunctionWithThisObject::handleEvent(typename IDLInterface<TestNode>::ParameterType thisObject, typename IDLSequence<IDLInterface<TestNode>>::ParameterType parameter)
+{
+    if (!canInvokeCallback())
+        return CallbackResultType::UnableToExecute;
+
+    Ref<JSTestCallbackFunctionWithThisObject> protectedThis(*this);
+
+    auto& globalObject = *m_data->globalObject();
+    auto& vm = globalObject.vm();
+
+    JSLockHolder lock(vm);
+    auto& state = *globalObject.globalExec();
+    JSValue thisValue = toJS<IDLInterface<TestNode>>(state, globalObject, thisObject);
+    MarkedArgumentBuffer args;
+    args.append(toJS<IDLSequence<IDLInterface<TestNode>>>(state, globalObject, parameter));
+
+    NakedPtr<JSC::Exception> returnedException;
+    m_data->invokeCallback(thisValue, args, JSCallbackData::CallbackType::Function, Identifier(), returnedException);
+    if (returnedException) {
+        reportException(&state, returnedException);
+        return CallbackResultType::ExceptionThrown;
+     }
+
+    return { };
+}
+
+JSC::JSValue toJS(TestCallbackFunctionWithThisObject& impl)
+{
+    if (!static_cast<JSTestCallbackFunctionWithThisObject&>(impl).callbackData())
+        return jsNull();
+
+    return static_cast<JSTestCallbackFunctionWithThisObject&>(impl).callbackData()->callback();
+}
+
+} // namespace WebCore
diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionWithThisObject.h b/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionWithThisObject.h
new file mode 100644 (file)
index 0000000..8721671
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+    This file is part of the WebKit open source project.
+    This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#pragma once
+
+#include "IDLTypes.h"
+#include "JSCallbackData.h"
+#include "TestCallbackFunctionWithThisObject.h"
+#include <wtf/Forward.h>
+
+namespace WebCore {
+
+class JSTestCallbackFunctionWithThisObject final : public TestCallbackFunctionWithThisObject {
+public:
+    static Ref<JSTestCallbackFunctionWithThisObject> create(JSC::JSObject* callback, JSDOMGlobalObject* globalObject)
+    {
+        return adoptRef(*new JSTestCallbackFunctionWithThisObject(callback, globalObject));
+    }
+
+    virtual ScriptExecutionContext* scriptExecutionContext() const { return ContextDestructionObserver::scriptExecutionContext(); }
+
+    virtual ~JSTestCallbackFunctionWithThisObject();
+    JSCallbackDataStrong* callbackData() { return m_data; }
+
+    // Functions
+    virtual CallbackResult<typename IDLVoid::ImplementationType> handleEvent(typename IDLInterface<TestNode>::ParameterType thisObject, typename IDLSequence<IDLInterface<TestNode>>::ParameterType parameter) override;
+
+private:
+    JSTestCallbackFunctionWithThisObject(JSC::JSObject*, JSDOMGlobalObject*);
+
+    JSCallbackDataStrong* m_data;
+};
+
+JSC::JSValue toJS(TestCallbackFunctionWithThisObject&);
+inline JSC::JSValue toJS(TestCallbackFunctionWithThisObject* impl) { return impl ? toJS(*impl) : JSC::jsNull(); }
+
+} // namespace WebCore
index c5282d5..0ea64ba 100644 (file)
 #include "JSDOMGlobalObject.h"
 #include "ScriptExecutionContext.h"
 #include <runtime/JSArray.h>
-#include <runtime/JSLock.h>
 
 using namespace JSC;
 
 namespace WebCore {
 
 JSTestCallbackFunctionWithTypedefs::JSTestCallbackFunctionWithTypedefs(JSObject* callback, JSDOMGlobalObject* globalObject)
-    : TestCallbackFunctionWithTypedefs()
-    , ActiveDOMCallback(globalObject->scriptExecutionContext())
+    : TestCallbackFunctionWithTypedefs(globalObject->scriptExecutionContext())
     , m_data(new JSCallbackDataStrong(callback, globalObject, this))
 {
 }
@@ -67,12 +65,13 @@ CallbackResult<typename IDLVoid::ImplementationType> JSTestCallbackFunctionWithT
 
     JSLockHolder lock(vm);
     auto& state = *globalObject.globalExec();
+    JSValue thisValue = jsUndefined();
     MarkedArgumentBuffer args;
     args.append(toJS<IDLSequence<IDLNullable<IDLLong>>>(state, globalObject, sequenceArg));
     args.append(toJS<IDLLong>(longArg));
 
     NakedPtr<JSC::Exception> returnedException;
-    m_data->invokeCallback(args, JSCallbackData::CallbackType::Function, Identifier(), returnedException);
+    m_data->invokeCallback(thisValue, args, JSCallbackData::CallbackType::Function, Identifier(), returnedException);
     if (returnedException) {
         reportException(&state, returnedException);
         return CallbackResultType::ExceptionThrown;
@@ -87,7 +86,6 @@ JSC::JSValue toJS(TestCallbackFunctionWithTypedefs& impl)
         return jsNull();
 
     return static_cast<JSTestCallbackFunctionWithTypedefs&>(impl).callbackData()->callback();
-
 }
 
 } // namespace WebCore
index ad5ad5f..5de31bb 100644 (file)
@@ -20,7 +20,6 @@
 
 #pragma once
 
-#include "ActiveDOMCallback.h"
 #include "IDLTypes.h"
 #include "JSCallbackData.h"
 #include "TestCallbackFunctionWithTypedefs.h"
@@ -28,7 +27,7 @@
 
 namespace WebCore {
 
-class JSTestCallbackFunctionWithTypedefs final : public TestCallbackFunctionWithTypedefs, public ActiveDOMCallback {
+class JSTestCallbackFunctionWithTypedefs final : public TestCallbackFunctionWithTypedefs {
 public:
     static Ref<JSTestCallbackFunctionWithTypedefs> create(JSC::JSObject* callback, JSDOMGlobalObject* globalObject)
     {
index 6806c01..6002277 100644 (file)
 #include "JSDOMGlobalObject.h"
 #include "JSDOMStringList.h"
 #include "JSTestNode.h"
+#include "JSTestObj.h"
 #include "ScriptExecutionContext.h"
 #include "SerializedScriptValue.h"
 #include <runtime/FunctionPrototype.h>
 #include <runtime/JSCInlines.h>
-#include <runtime/JSLock.h>
 #include <runtime/JSString.h>
 #include <wtf/NeverDestroyed.h>
 
@@ -102,8 +102,7 @@ template<> TestCallbackInterface::Dictionary convertDictionary<TestCallbackInter
 }
 
 JSTestCallbackInterface::JSTestCallbackInterface(JSObject* callback, JSDOMGlobalObject* globalObject)
-    : TestCallbackInterface()
-    , ActiveDOMCallback(globalObject->scriptExecutionContext())
+    : TestCallbackInterface(globalObject->scriptExecutionContext())
     , m_data(new JSCallbackDataStrong(callback, globalObject, this))
 {
 }
@@ -168,10 +167,11 @@ CallbackResult<typename IDLVoid::ImplementationType> JSTestCallbackInterface::ca
 
     JSLockHolder lock(vm);
     auto& state = *globalObject.globalExec();
+    JSValue thisValue = jsUndefined();
     MarkedArgumentBuffer args;
 
     NakedPtr<JSC::Exception> returnedException;
-    m_data->invokeCallback(args, JSCallbackData::CallbackType::Object, Identifier::fromString(&vm, "callbackWithNoParam"), returnedException);
+    m_data->invokeCallback(thisValue, args, JSCallbackData::CallbackType::Object, Identifier::fromString(&vm, "callbackWithNoParam"), returnedException);
     if (returnedException) {
         reportException(&state, returnedException);
         return CallbackResultType::ExceptionThrown;
@@ -192,11 +192,12 @@ CallbackResult<typename IDLVoid::ImplementationType> JSTestCallbackInterface::ca
 
     JSLockHolder lock(vm);
     auto& state = *globalObject.globalExec();
+    JSValue thisValue = jsUndefined();
     MarkedArgumentBuffer args;
     args.append(toJS<IDLFloat32Array>(state, globalObject, arrayParam));
 
     NakedPtr<JSC::Exception> returnedException;
-    m_data->invokeCallback(args, JSCallbackData::CallbackType::Object, Identifier::fromString(&vm, "callbackWithArrayParam"), returnedException);
+    m_data->invokeCallback(thisValue, args, JSCallbackData::CallbackType::Object, Identifier::fromString(&vm, "callbackWithArrayParam"), returnedException);
     if (returnedException) {
         reportException(&state, returnedException);
         return CallbackResultType::ExceptionThrown;
@@ -217,12 +218,13 @@ CallbackResult<typename IDLVoid::ImplementationType> JSTestCallbackInterface::ca
 
     JSLockHolder lock(vm);
     auto& state = *globalObject.globalExec();
+    JSValue thisValue = jsUndefined();
     MarkedArgumentBuffer args;
     args.append(toJS<IDLSerializedScriptValue<SerializedScriptValue>>(state, globalObject, srzParam));
     args.append(toJS<IDLDOMString>(state, strParam));
 
     NakedPtr<JSC::Exception> returnedException;
-    m_data->invokeCallback(args, JSCallbackData::CallbackType::Object, Identifier::fromString(&vm, "callbackWithSerializedScriptValueParam"), returnedException);
+    m_data->invokeCallback(thisValue, args, JSCallbackData::CallbackType::Object, Identifier::fromString(&vm, "callbackWithSerializedScriptValueParam"), returnedException);
     if (returnedException) {
         reportException(&state, returnedException);
         return CallbackResultType::ExceptionThrown;
@@ -243,11 +245,12 @@ CallbackResult<typename IDLVoid::ImplementationType> JSTestCallbackInterface::ca
 
     JSLockHolder lock(vm);
     auto& state = *globalObject.globalExec();
+    JSValue thisValue = jsUndefined();
     MarkedArgumentBuffer args;
     args.append(toJS<IDLInterface<DOMStringList>>(state, globalObject, listParam));
 
     NakedPtr<JSC::Exception> returnedException;
-    m_data->invokeCallback(args, JSCallbackData::CallbackType::Object, Identifier::fromString(&vm, "callbackWithStringList"), returnedException);
+    m_data->invokeCallback(thisValue, args, JSCallbackData::CallbackType::Object, Identifier::fromString(&vm, "callbackWithStringList"), returnedException);
     if (returnedException) {
         reportException(&state, returnedException);
         return CallbackResultType::ExceptionThrown;
@@ -268,11 +271,12 @@ CallbackResult<typename IDLVoid::ImplementationType> JSTestCallbackInterface::ca
 
     JSLockHolder lock(vm);
     auto& state = *globalObject.globalExec();
+    JSValue thisValue = jsUndefined();
     MarkedArgumentBuffer args;
     args.append(toJS<IDLBoolean>(boolParam));
 
     NakedPtr<JSC::Exception> returnedException;
-    m_data->invokeCallback(args, JSCallbackData::CallbackType::Object, Identifier::fromString(&vm, "callbackWithBoolean"), returnedException);
+    m_data->invokeCallback(thisValue, args, JSCallbackData::CallbackType::Object, Identifier::fromString(&vm, "callbackWithBoolean"), returnedException);
     if (returnedException) {
         reportException(&state, returnedException);
         return CallbackResultType::ExceptionThrown;
@@ -293,12 +297,13 @@ CallbackResult<typename IDLVoid::ImplementationType> JSTestCallbackInterface::ca
 
     JSLockHolder lock(vm);
     auto& state = *globalObject.globalExec();
+    JSValue thisValue = jsUndefined();
     MarkedArgumentBuffer args;
     args.append(toJS<IDLLong>(longParam));
     args.append(toJS<IDLInterface<TestNode>>(state, globalObject, testNodeParam));
 
     NakedPtr<JSC::Exception> returnedException;
-    m_data->invokeCallback(args, JSCallbackData::CallbackType::Object, Identifier::fromString(&vm, "callbackRequiresThisToPass"), returnedException);
+    m_data->invokeCallback(thisValue, args, JSCallbackData::CallbackType::Object, Identifier::fromString(&vm, "callbackRequiresThisToPass"), returnedException);
     if (returnedException) {
         reportException(&state, returnedException);
         return CallbackResultType::ExceptionThrown;
@@ -319,10 +324,11 @@ CallbackResult<typename IDLDOMString::ImplementationType> JSTestCallbackInterfac
 
     JSLockHolder lock(vm);
     auto& state = *globalObject.globalExec();
+    JSValue thisValue = jsUndefined();
     MarkedArgumentBuffer args;
 
     NakedPtr<JSC::Exception> returnedException;
-    auto jsResult = m_data->invokeCallback(args, JSCallbackData::CallbackType::Object, Identifier::fromString(&vm, "callbackWithAReturnValue"), returnedException);
+    auto jsResult = m_data->invokeCallback(thisValue, args, JSCallbackData::CallbackType::Object, Identifier::fromString(&vm, "callbackWithAReturnValue"), returnedException);
     if (returnedException) {
         reportException(&state, returnedException);
         return CallbackResultType::ExceptionThrown;
@@ -346,11 +352,12 @@ CallbackResult<typename IDLDOMString::ImplementationType> JSTestCallbackInterfac
 
     JSLockHolder lock(vm);
     auto& state = *globalObject.globalExec();
+    JSValue thisValue = jsUndefined();
     MarkedArgumentBuffer args;
     args.append(toJS<IDLEnumeration<TestCallbackInterface::Enum>>(state, enumParam));
 
     NakedPtr<JSC::Exception> returnedException;
-    auto jsResult = m_data->invokeCallback(args, JSCallbackData::CallbackType::Object, Identifier::fromString(&vm, "callbackThatRethrowsExceptions"), returnedException);
+    auto jsResult = m_data->invokeCallback(thisValue, args, JSCallbackData::CallbackType::Object, Identifier::fromString(&vm, "callbackThatRethrowsExceptions"), returnedException);
     if (returnedException) {
         auto throwScope = DECLARE_THROW_SCOPE(vm);
         throwException(&state, throwScope, returnedException);
@@ -372,11 +379,41 @@ CallbackResult<typename IDLDOMString::ImplementationType> JSTestCallbackInterfac
 
     JSLockHolder lock(vm);
     auto& state = *globalObject.globalExec();
+    JSValue thisValue = jsUndefined();
     MarkedArgumentBuffer args;
     args.append(toJS<IDLDictionary<TestCallbackInterface::Dictionary>>(state, globalObject, dictionaryParam));
 
     NakedPtr<JSC::Exception> returnedException;
-    auto jsResult = m_data->invokeCallback(args, JSCallbackData::CallbackType::Object, Identifier::fromString(&vm, "callbackThatSkipsInvokeCheck"), returnedException);
+    auto jsResult = m_data->invokeCallback(thisValue, args, JSCallbackData::CallbackType::Object, Identifier::fromString(&vm, "callbackThatSkipsInvokeCheck"), returnedException);
+    if (returnedException) {
+        reportException(&state, returnedException);
+        return CallbackResultType::ExceptionThrown;
+     }
+
+    auto throwScope = DECLARE_THROW_SCOPE(vm);
+    auto returnValue = convert<IDLDOMString>(state, jsResult);
+    RETURN_IF_EXCEPTION(throwScope, CallbackResultType::ExceptionThrown);
+    return WTFMove(returnValue);
+}
+
+CallbackResult<typename IDLDOMString::ImplementationType> JSTestCallbackInterface::callbackWithThisObject(typename IDLInterface<TestNode>::ParameterType thisObject, typename IDLInterface<TestObj>::ParameterType testObjParam)
+{
+    if (!canInvokeCallback())
+        return CallbackResultType::UnableToExecute;
+
+    Ref<JSTestCallbackInterface> protectedThis(*this);
+
+    auto& globalObject = *m_data->globalObject();
+    auto& vm = globalObject.vm();
+
+    JSLockHolder lock(vm);
+    auto& state = *globalObject.globalExec();
+    JSValue thisValue = toJS<IDLInterface<TestNode>>(state, globalObject, thisObject);
+    MarkedArgumentBuffer args;
+    args.append(toJS<IDLInterface<TestObj>>(state, globalObject, testObjParam));
+
+    NakedPtr<JSC::Exception> returnedException;
+    auto jsResult = m_data->invokeCallback(thisValue, args, JSCallbackData::CallbackType::Object, Identifier::fromString(&vm, "callbackWithThisObject"), returnedException);
     if (returnedException) {
         reportException(&state, returnedException);
         return CallbackResultType::ExceptionThrown;
@@ -394,7 +431,6 @@ JSC::JSValue toJS(TestCallbackInterface& impl)
         return jsNull();
 
     return static_cast<JSTestCallbackInterface&>(impl).callbackData()->callback();
-
 }
 
 } // namespace WebCore
index 25ef04a..f973aea 100644 (file)
@@ -22,7 +22,6 @@
 
 #if ENABLE(TEST_CONDITIONAL)
 
-#include "ActiveDOMCallback.h"
 #include "IDLTypes.h"
 #include "JSCallbackData.h"
 #include "JSDOMConvertDictionary.h"
@@ -32,7 +31,7 @@
 
 namespace WebCore {
 
-class JSTestCallbackInterface final : public TestCallbackInterface, public ActiveDOMCallback {
+class JSTestCallbackInterface final : public TestCallbackInterface {
 public:
     static Ref<JSTestCallbackInterface> create(JSC::JSObject* callback, JSDOMGlobalObject* globalObject)
     {
@@ -56,6 +55,7 @@ public:
     virtual CallbackResult<typename IDLDOMString::ImplementationType> callbackWithAReturnValue() override;
     virtual CallbackResult<typename IDLDOMString::ImplementationType> callbackThatRethrowsExceptions(typename IDLEnumeration<TestCallbackInterface::Enum>::ParameterType enumParam) override;
     virtual CallbackResult<typename IDLDOMString::ImplementationType> callbackThatSkipsInvokeCheck(typename IDLDictionary<TestCallbackInterface::Dictionary>::ParameterType dictionaryParam) override;
+    virtual CallbackResult<typename IDLDOMString::ImplementationType> callbackWithThisObject(typename IDLInterface<TestNode>::ParameterType thisObject, typename IDLInterface<TestObj>::ParameterType testObjParam) override;
 
 private:
     JSTestCallbackInterface(JSC::JSObject*, JSDOMGlobalObject*);
index 13a34ed..0425d36 100644 (file)
 #include "JSTestNode.h"
 #include "ScriptExecutionContext.h"
 #include "SerializedScriptValue.h"
-#include <runtime/JSLock.h>
 
 using namespace JSC;
 
 namespace WebCore {
 
 JSTestVoidCallbackFunction::JSTestVoidCallbackFunction(JSObject* callback, JSDOMGlobalObject* globalObject)
-    : TestVoidCallbackFunction()
-    , ActiveDOMCallback(globalObject->scriptExecutionContext())
+    : TestVoidCallbackFunction(globalObject->scriptExecutionContext())
     , m_data(new JSCallbackDataStrong(callback, globalObject, this))
 {
 }
@@ -74,6 +72,7 @@ CallbackResult<typename IDLVoid::ImplementationType> JSTestVoidCallbackFunction:
 
     JSLockHolder lock(vm);
     auto& state = *globalObject.globalExec();
+    JSValue thisValue = jsUndefined();
     MarkedArgumentBuffer args;
     args.append(toJS<IDLFloat32Array>(state, globalObject, arrayParam));
     args.append(toJS<IDLSerializedScriptValue<SerializedScriptValue>>(state, globalObject, srzParam));
@@ -83,7 +82,7 @@ CallbackResult<typename IDLVoid::ImplementationType> JSTestVoidCallbackFunction:
     args.append(toJS<IDLInterface<TestNode>>(state, globalObject, testNodeParam));
 
     NakedPtr<JSC::Exception> returnedException;
-    m_data->invokeCallback(args, JSCallbackData::CallbackType::Function, Identifier(), returnedException);
+    m_data->invokeCallback(thisValue, args, JSCallbackData::CallbackType::Function, Identifier(), returnedException);
     if (returnedException) {
         reportException(&state, returnedException);
         return CallbackResultType::ExceptionThrown;
@@ -98,7 +97,6 @@ JSC::JSValue toJS(TestVoidCallbackFunction& impl)
         return jsNull();
 
     return static_cast<JSTestVoidCallbackFunction&>(impl).callbackData()->callback();
-
 }
 
 } // namespace WebCore
index 3344fae..353ecb7 100644 (file)
@@ -22,7 +22,6 @@
 
 #if ENABLE(TEST_CONDITIONAL)
 
-#include "ActiveDOMCallback.h"
 #include "IDLTypes.h"
 #include "JSCallbackData.h"
 #include "TestVoidCallbackFunction.h"
@@ -30,7 +29,7 @@
 
 namespace WebCore {
 
-class JSTestVoidCallbackFunction final : public TestVoidCallbackFunction, public ActiveDOMCallback {
+class JSTestVoidCallbackFunction final : public TestVoidCallbackFunction {
 public:
     static Ref<JSTestVoidCallbackFunction> create(JSC::JSObject* callback, JSDOMGlobalObject* globalObject)
     {
diff --git a/Source/WebCore/bindings/scripts/test/TestCallbackFunctionWithThisObject.idl b/Source/WebCore/bindings/scripts/test/TestCallbackFunctionWithThisObject.idl
new file mode 100644 (file)
index 0000000..616ab86
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ * 3.  Neither the name of Apple Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+    CallbackThisObject=TestNode
+] callback TestCallbackFunctionWithThisObject = void (sequence<TestNode> parameter);
index 6380eef..e24c7bb 100644 (file)
@@ -52,4 +52,5 @@ dictionary TestCallbackInterfaceDictionary {
     DOMString callbackWithAReturnValue();
     [RethrowException] DOMString callbackThatRethrowsExceptions(TestCallbackInterfaceEnum enumParam);
     [SkipCallbackInvokeCheck] DOMString callbackThatSkipsInvokeCheck(TestCallbackInterfaceDictionary dictionaryParam);
+    [CallbackThisObject=TestNode] DOMString callbackWithThisObject(TestObj testObjParam);
 };
index ddc5d9a..0ea3ba9 100644 (file)
@@ -84,7 +84,7 @@ private:
         PendingPromise(LoadPromise&&);
 
     public:
-        Vector<RefPtr<FontFace>> faces;
+        Vector<Ref<FontFace>> faces;
         LoadPromise promise;
         bool hasReachedTerminalState { false };
     };
index af51ef8..d31584a 100644 (file)
@@ -19,6 +19,7 @@
 
 #pragma once
 
+#include "ActiveDOMCallback.h"
 #include "CallbackResult.h"
 #include <wtf/RefCounted.h>
 
@@ -26,7 +27,7 @@ namespace WebCore {
 
 class MediaQueryList;
 
-class MediaQueryListListener : public RefCounted<MediaQueryListListener> {
+class MediaQueryListListener : public RefCounted<MediaQueryListListener>, public ActiveDOMCallback {
 public:
     enum Type {
         JSMediaQueryListListenerType
@@ -34,13 +35,13 @@ public:
 
     virtual CallbackResult<void> handleEvent(MediaQueryList&) = 0;
     virtual bool operator==(const MediaQueryListListener&) const = 0;
-    virtual ~MediaQueryListListener() { }
 
     Type type() const { return m_type; }
 
 protected:
-    explicit MediaQueryListListener(Type type)
-        : m_type(type)
+    explicit MediaQueryListListener(ScriptExecutionContext* context, Type type)
+        : ActiveDOMCallback(context)
+        , m_type(type)
     {
     }
 
index 042802d..2b35b12 100644 (file)
 
 #include "ContextDestructionObserver.h"
 
+namespace JSC {
+class SlotVisitor;
+}
+
 namespace WebCore {
 
 class ScriptExecutionContext;
@@ -43,10 +47,12 @@ class ScriptExecutionContext;
 // context thread.
 class ActiveDOMCallback : public ContextDestructionObserver {
 public:
-    ActiveDOMCallback(ScriptExecutionContext* context);
+    ActiveDOMCallback(ScriptExecutionContext*);
     virtual ~ActiveDOMCallback();
 
     WEBCORE_EXPORT bool canInvokeCallback() const;
+    
+    virtual void visitJSFunction(JSC::SlotVisitor&) { }
 };
 
 } // namespace WebCore
index fbc35ce..8859d53 100644 (file)
@@ -30,6 +30,8 @@
 
 #pragma once
 
+#include "ActiveDOMCallback.h"
+#include "CallbackResult.h"
 #include <wtf/Ref.h>
 #include <wtf/RefCounted.h>
 #include <wtf/Vector.h>
@@ -39,12 +41,11 @@ namespace WebCore {
 class MutationRecord;
 class MutationObserver;
 
-class MutationCallback : public RefCounted<MutationCallback> {
+class MutationCallback : public RefCounted<MutationCallback>, public ActiveDOMCallback {
 public:
-    virtual ~MutationCallback() { }
+    using ActiveDOMCallback::ActiveDOMCallback;
 
-    virtual void call(const Vector<Ref<MutationRecord>>&, MutationObserver*) = 0;
-    virtual bool canInvokeCallback() const = 0;
+    virtual CallbackResult<void> handleEvent(MutationObserver&, const Vector<Ref<MutationRecord>>&, MutationObserver&) = 0;
 };
 
 } // namespace WebCore
similarity index 57%
rename from Source/WebCore/bindings/js/JSMutationCallback.h
rename to Source/WebCore/dom/MutationCallback.idl
index a5b391f..78e2ed0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013 Google Inc. All rights reserved.
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#pragma once
-
-#include "ActiveDOMCallback.h"
-#include "DOMWrapperWorld.h"
-#include "MutationCallback.h"
-#include <heap/Weak.h>
-#include <runtime/JSObject.h>
-
-namespace WebCore {
-
-class JSDOMGlobalObject;
-
-class JSMutationCallback final : public MutationCallback, public ActiveDOMCallback {
-public:
-    static Ref<JSMutationCallback> create(JSC::JSObject* callback, JSDOMGlobalObject* globalObject)
-    {
-        return adoptRef(*new JSMutationCallback(callback, globalObject));
-    }
-
-    virtual ~JSMutationCallback();
-
-    void call(const Vector<Ref<MutationRecord>>&, MutationObserver*) override;
-    bool canInvokeCallback() const override { return ActiveDOMCallback::canInvokeCallback(); }
-
-private:
-    JSMutationCallback(JSC::JSObject* callback, JSDOMGlobalObject*);
-
-    mutable JSC::Weak<JSC::JSObject> m_callback;
-    Ref<DOMWrapperWorld> m_isolatedWorld;
-};
-
-} // namespace WebCore
+[
+    CallbackThisObject=MutationObserver,
+    IsWeakCallback,
+] callback MutationCallback = void (sequence<MutationRecord> mutations, MutationObserver observer);
index c5e55a6..2e9f345 100644 (file)
@@ -232,7 +232,7 @@ void MutationObserver::deliver()
     Vector<Ref<MutationRecord>> records;
     records.swap(m_records);
 
-    m_callback->call(records, this);
+    m_callback->handleEvent(*this, records, *this);
 }
 
 void MutationObserver::notifyMutationObservers()
index b7c71bd..b4731b6 100644 (file)
@@ -93,6 +93,8 @@ public:
 
     HashSet<Node*> observedNodes() const;
 
+    MutationCallback& callback() const { return m_callback.get(); }
+
     static void enqueueSlotChangeEvent(HTMLSlotElement&);
 
 private:
index 7e03b34..1b52a70 100644 (file)
  */
 
 [
-    CustomConstructor(MutationCallback callback),
+    Constructor(MutationCallback callback),
     CustomIsReachable,
     ImplementationLacksVTable,
     LegacyWindowAlias=WebKitMutationObserver,
+    JSCustomMarkFunction
 ] interface MutationObserver {
     [MayThrowException] void observe(Node target, optional MutationObserverInit options);
     void disconnect();
index 86326eb..c4545c2 100644 (file)
@@ -28,8 +28,9 @@
 
 namespace WebCore {
 
-NativeNodeFilter::NativeNodeFilter(Ref<NodeFilterCondition>&& condition)
-    : m_condition(WTFMove(condition))
+NativeNodeFilter::NativeNodeFilter(ScriptExecutionContext* context, Ref<NodeFilterCondition>&& condition)
+    : NodeFilter(context)
+    , m_condition(WTFMove(condition))
 {
 }
 
index 1a1b1cd..a955c6e 100644 (file)
@@ -33,15 +33,15 @@ namespace WebCore {
 
 class NativeNodeFilter final : public NodeFilter {
 public:
-    static Ref<NativeNodeFilter> create(Ref<NodeFilterCondition>&& condition)
+    static Ref<NativeNodeFilter> create(ScriptExecutionContext* context, Ref<NodeFilterCondition>&& condition)
     {
-        return adoptRef(*new NativeNodeFilter(WTFMove(condition)));
+        return adoptRef(*new NativeNodeFilter(context, WTFMove(condition)));
     }
 
     CallbackResult<unsigned short> acceptNode(Node&) override;
 
 private:
-    WEBCORE_EXPORT explicit NativeNodeFilter(Ref<NodeFilterCondition>&&);
+    WEBCORE_EXPORT explicit NativeNodeFilter(ScriptExecutionContext*, Ref<NodeFilterCondition>&&);
 
     Ref<NodeFilterCondition> m_condition;
 };
index 9810a92..64d8028 100644 (file)
@@ -24,6 +24,7 @@
 
 #pragma once
 
+#include "ActiveDOMCallback.h"
 #include "CallbackResult.h"
 #include <wtf/RefCounted.h>
 
@@ -31,9 +32,10 @@ namespace WebCore {
 
 class Node;
 
-class NodeFilter : public RefCounted<NodeFilter> {
+class NodeFilter : public RefCounted<NodeFilter>, public ActiveDOMCallback {
 public:
-    virtual ~NodeFilter() { }
+    using ActiveDOMCallback::ActiveDOMCallback;
+
     virtual CallbackResult<unsigned short> acceptNode(Node&) = 0;
 
     /*
index 683a110..3c67f7d 100644 (file)
 
 #pragma once
 
+#include "ActiveDOMCallback.h"
 #include "CallbackResult.h"
 #include <wtf/RefCounted.h>
 
 namespace WebCore {
 
-class RequestAnimationFrameCallback : public RefCounted<RequestAnimationFrameCallback> {
+class RequestAnimationFrameCallback : public RefCounted<RequestAnimationFrameCallback>, public ActiveDOMCallback {
 public:
-    virtual ~RequestAnimationFrameCallback() { }
+    using ActiveDOMCallback::ActiveDOMCallback;
+
     virtual CallbackResult<void> handleEvent(double highResTimeMs) = 0;
 
     int m_id;
index 6eee72e..ce1c3a5 100644 (file)
@@ -30,6 +30,7 @@
 
 #pragma once
 
+#include "ActiveDOMCallback.h"
 #include "CallbackResult.h"
 #include <wtf/Forward.h>
 #include <wtf/RefCounted.h>
@@ -38,9 +39,10 @@ namespace WebCore {
 
 class ScriptExecutionContext;
 
-class StringCallback : public RefCounted<StringCallback> {
+class StringCallback : public RefCounted<StringCallback>, public ActiveDOMCallback {
 public:
-    virtual ~StringCallback() { }
+    using ActiveDOMCallback::ActiveDOMCallback;
+
     virtual CallbackResult<void> handleEvent(const String& data) = 0;
 
     // Helper to post callback task.
index 59f28dd..19966a9 100644 (file)
@@ -25,6 +25,7 @@
 
 #pragma once
 
+#include "ActiveDOMCallback.h"
 #include "CallbackResult.h"
 #include <wtf/RefCounted.h>
 #include <wtf/RefPtr.h>
@@ -34,9 +35,10 @@ namespace WebCore {
 class Blob;
 class ScriptExecutionContext;
 
-class BlobCallback : public RefCounted<BlobCallback> {
+class BlobCallback : public RefCounted<BlobCallback>, public ActiveDOMCallback {
 public:
-    virtual ~BlobCallback() { }
+    using ActiveDOMCallback::ActiveDOMCallback;
+
     virtual CallbackResult<void> handleEvent(Blob*) = 0;
 
     void scheduleCallback(ScriptExecutionContext&, RefPtr<Blob>&&);
index 5e71633..8abec1b 100644 (file)
 
 #pragma once
 
+#include "ActiveDOMCallback.h"
 #include "CallbackResult.h"
 #include <wtf/RefCounted.h>
 
 namespace WebCore {
 
-class VoidCallback : public RefCounted<VoidCallback> {
+class VoidCallback : public RefCounted<VoidCallback>, public ActiveDOMCallback {
 public:
-    virtual ~VoidCallback() { }
+    using ActiveDOMCallback::ActiveDOMCallback;
+
     virtual CallbackResult<void> handleEvent() = 0;
 };
 
index 10ee150..f7c0e64 100644 (file)
@@ -66,14 +66,17 @@ void reportTransactionFailed(ExecuteSQLCallback& requestCallback, SQLError& erro
 
 class StatementCallback final : public SQLStatementCallback {
 public:
-    static Ref<StatementCallback> create(Ref<ExecuteSQLCallback>&& requestCallback)
+    static Ref<StatementCallback> create(ScriptExecutionContext* context, Ref<ExecuteSQLCallback>&& requestCallback)
     {
-        return adoptRef(*new StatementCallback(WTFMove(requestCallback)));
+        return adoptRef(*new StatementCallback(context, WTFMove(requestCallback)));
     }
 
 private:
-    StatementCallback(Ref<ExecuteSQLCallback>&& requestCallback)
-        : m_requestCallback(WTFMove(requestCallback)) { }
+    StatementCallback(ScriptExecutionContext* context, Ref<ExecuteSQLCallback>&& requestCallback)
+        : SQLStatementCallback(context)
+        , m_requestCallback(WTFMove(requestCallback))
+    {
+    }
 
     CallbackResult<void> handleEvent(SQLTransaction&, SQLResultSet& resultSet) final
     {
@@ -101,14 +104,17 @@ private:
 
 class StatementErrorCallback final : public SQLStatementErrorCallback {
 public:
-    static Ref<StatementErrorCallback> create(Ref<ExecuteSQLCallback>&& requestCallback)
+    static Ref<StatementErrorCallback> create(ScriptExecutionContext* context, Ref<ExecuteSQLCallback>&& requestCallback)
     {
-        return adoptRef(*new StatementErrorCallback(WTFMove(requestCallback)));
+        return adoptRef(*new StatementErrorCallback(context, WTFMove(requestCallback)));
     }
 
 private:
-    StatementErrorCallback(Ref<ExecuteSQLCallback>&& requestCallback)
-        : m_requestCallback(WTFMove(requestCallback)) { }
+    StatementErrorCallback(ScriptExecutionContext* context, Ref<ExecuteSQLCallback>&& requestCallback)
+        : SQLStatementErrorCallback(context)
+        , m_requestCallback(WTFMove(requestCallback))
+    {
+    }
 
     CallbackResult<bool> handleEvent(SQLTransaction&, SQLError& error) final
     {
@@ -121,23 +127,26 @@ private:
 
 class TransactionCallback final : public SQLTransactionCallback {
 public:
-    static Ref<TransactionCallback> create(const String& sqlStatement, Ref<ExecuteSQLCallback>&& requestCallback)
+    static Ref<TransactionCallback> create(ScriptExecutionContext* context, const String& sqlStatement, Ref<ExecuteSQLCallback>&& requestCallback)
     {
-        return adoptRef(*new TransactionCallback(sqlStatement, WTFMove(requestCallback)));
+        return adoptRef(*new TransactionCallback(context, sqlStatement, WTFMove(requestCallback)));
     }
 
 private:
-    TransactionCallback(const String& sqlStatement, Ref<ExecuteSQLCallback>&& requestCallback)
-        : m_sqlStatement(sqlStatement)
-        , m_requestCallback(WTFMove(requestCallback)) { }
+    TransactionCallback(ScriptExecutionContext* context, const String& sqlStatement, Ref<ExecuteSQLCallback>&& requestCallback)
+        : SQLTransactionCallback(context)
+        , m_sqlStatement(sqlStatement)
+        , m_requestCallback(WTFMove(requestCallback))
+    {
+    }
 
     CallbackResult<void> handleEvent(SQLTransaction& transaction) final
     {
         if (!m_requestCallback->isActive())
             return { };
 
-        Ref<SQLStatementCallback> callback(StatementCallback::create(m_requestCallback.copyRef()));
-        Ref<SQLStatementErrorCallback> errorCallback(StatementErrorCallback::create(m_requestCallback.copyRef()));
+        Ref<SQLStatementCallback> callback(StatementCallback::create(scriptExecutionContext(), m_requestCallback.copyRef()));
+        Ref<SQLStatementErrorCallback> errorCallback(StatementErrorCallback::create(scriptExecutionContext(), m_requestCallback.copyRef()));
         transaction.executeSql(m_sqlStatement, { }, WTFMove(callback), WTFMove(errorCallback));
         return { };
     }
@@ -148,14 +157,17 @@ private:
 
 class TransactionErrorCallback final : public SQLTransactionErrorCallback {
 public:
-    static Ref<TransactionErrorCallback> create(Ref<ExecuteSQLCallback>&& requestCallback)
+    static Ref<TransactionErrorCallback> create(ScriptExecutionContext* context, Ref<ExecuteSQLCallback>&& requestCallback)
     {
-        return adoptRef(*new TransactionErrorCallback(WTFMove(requestCallback)));
+        return adoptRef(*new TransactionErrorCallback(context, WTFMove(requestCallback)));
     }
 
 private:
-    TransactionErrorCallback(Ref<ExecuteSQLCallback>&& requestCallback)
-        : m_requestCallback(WTFMove(requestCallback)) { }
+    TransactionErrorCallback(ScriptExecutionContext* context, Ref<ExecuteSQLCallback>&& requestCallback)
+        : SQLTransactionErrorCallback(context)
+        , m_requestCallback(WTFMove(requestCallback))
+    {
+    }
 
     CallbackResult<void> handleEvent(SQLError& error) final
     {
@@ -168,15 +180,18 @@ private:
 
 class TransactionSuccessCallback final : public VoidCallback {
 public:
-    static Ref<TransactionSuccessCallback> create()
+    static Ref<TransactionSuccessCallback> create(ScriptExecutionContext* context)
     {
-        return adoptRef(*new TransactionSuccessCallback());
+        return adoptRef(*new TransactionSuccessCallback(context));
     }
 
     CallbackResult<void> handleEvent() final { return { }; }
 
 private:
-    TransactionSuccessCallback() { }
+    TransactionSuccessCallback(ScriptExecutionContext* context)
+        : VoidCallback(context)
+    {
+    }
 };
 
 } // namespace
@@ -268,9 +283,9 @@ void InspectorDatabaseAgent::executeSQL(ErrorString&, const String& databaseId,
         return;
     }
 
-    database->transaction(TransactionCallback::create(query, requestCallback.copyRef()),
-        TransactionErrorCallback::create(requestCallback.copyRef()),
-        TransactionSuccessCallback::create());
+    database->transaction(TransactionCallback::create(&database->scriptExecutionContext(), query, requestCallback.copyRef()),
+        TransactionErrorCallback::create(&database->scriptExecutionContext(), requestCallback.copyRef()),
+        TransactionSuccessCallback::create(&database->scriptExecutionContext()));
 }
 
 String InspectorDatabaseAgent::databaseId(Database& database)
index 59ba7b0..8592bc6 100644 (file)
@@ -27,6 +27,7 @@
 
 #if ENABLE(INTERSECTION_OBSERVER)
 
+#include "ActiveDOMCallback.h"
 #include "CallbackResult.h"
 #include <wtf/RefCounted.h>
 #include <wtf/Vector.h>
@@ -36,10 +37,11 @@ namespace WebCore {
 class IntersectionObserver;
 class IntersectionObserverEntry;
 
-class IntersectionObserverCallback : public RefCounted<IntersectionObserverCallback> {
+class IntersectionObserverCallback : public RefCounted<IntersectionObserverCallback>, public ActiveDOMCallback {
 public:
-    virtual ~IntersectionObserverCallback() { }
-    virtual CallbackResult<void> handleEvent(const Vector<RefPtr<IntersectionObserverEntry>>&, IntersectionObserver&) = 0;
+    using ActiveDOMCallback::ActiveDOMCallback;
+
+    virtual CallbackResult<void> handleEvent(const Vector<Ref<IntersectionObserverEntry>>&, IntersectionObserver&) = 0;
 };
 
 } // namespace WebCore
index 2599316..5cad8b0 100644 (file)
@@ -25,6 +25,7 @@
 
 #pragma once
 
+#include "ActiveDOMCallback.h"
 #include "CallbackResult.h"
 #include <wtf/RefCounted.h>
 
@@ -33,9 +34,10 @@ namespace WebCore {
 class PerformanceObserver;
 class PerformanceObserverEntryList;
 
-class PerformanceObserverCallback : public RefCounted<PerformanceObserverCallback> {
+class PerformanceObserverCallback : public RefCounted<PerformanceObserverCallback>, public ActiveDOMCallback {
 public:
-    virtual ~PerformanceObserverCallback() { }
+    using ActiveDOMCallback::ActiveDOMCallback;
+
     virtual CallbackResult<void> handleEvent(PerformanceObserverEntryList&, PerformanceObserver&) = 0;
 };
 
index a92bbd7..310daeb 100644 (file)
@@ -1,3 +1,15 @@
+2017-08-02  Sam Weinig  <sam@webkit.org>
+
+        [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.
+
 2017-08-03  Jeremy Jones  <jeremyj@apple.com>
 
         Use MPAVRoutingController instead of deprecated versions.
index 2ea919a..33ce67c 100644 (file)
@@ -1127,7 +1127,7 @@ WebKitDOMNodeIterator* webkit_dom_document_create_node_iterator(WebKitDOMDocumen
     UNUSED_PARAM(error);
     WebCore::Document* item = WebKit::core(self);
     WebCore::Node* convertedRoot = WebKit::core(root);
-    RefPtr<WebCore::NodeFilter> convertedFilter = WebKit::core(filter);
+    RefPtr<WebCore::NodeFilter> convertedFilter = WebKit::core(item, filter);
     RefPtr<WebCore::NodeIterator> gobjectResult = WTF::getPtr(item->createNodeIterator(*convertedRoot, whatToShow, WTF::getPtr(convertedFilter), expandEntityReferences));
     return WebKit::kit(gobjectResult.get());
 }
@@ -1141,7 +1141,7 @@ WebKitDOMTreeWalker* webkit_dom_document_create_tree_walker(WebKitDOMDocument* s
     UNUSED_PARAM(error);
     WebCore::Document* item = WebKit::core(self);
     WebCore::Node* convertedRoot = WebKit::core(root);
-    RefPtr<WebCore::NodeFilter> convertedFilter = WebKit::core(filter);
+    RefPtr<WebCore::NodeFilter> convertedFilter = WebKit::core(item, filter);
     RefPtr<WebCore::TreeWalker> gobjectResult = WTF::getPtr(item->createTreeWalker(*convertedRoot, whatToShow, WTF::getPtr(convertedFilter), expandEntityReferences));
     return WebKit::kit(gobjectResult.get());
 }
index 31c02d0..8747e35 100644 (file)
@@ -20,6 +20,7 @@
 #include "WebKitDOMNodeFilter.h"
 
 #include "GObjectNodeFilterCondition.h"
+#include <WebCore/Document.h>
 #include <WebCore/NativeNodeFilter.h>
 #include "WebKitDOMNode.h"
 #include "WebKitDOMNodeFilterPrivate.h"
@@ -65,14 +66,14 @@ WebKitDOMNodeFilter* kit(WebCore::NodeFilter* coreNodeFilter)
     return nodeFilterMap().get(coreNodeFilter);
 }
 
-RefPtr<WebCore::NodeFilter> core(WebKitDOMNodeFilter* nodeFilter)
+RefPtr<WebCore::NodeFilter> core(WebCore::Document* document, WebKitDOMNodeFilter* nodeFilter)
 {
     if (!nodeFilter)
         return nullptr;
 
     RefPtr<WebCore::NodeFilter> coreNodeFilter = static_cast<WebCore::NodeFilter*>(g_object_get_data(G_OBJECT(nodeFilter), "webkit-core-node-filter"));
     if (!coreNodeFilter) {
-        coreNodeFilter = WebCore::NativeNodeFilter::create(WebKit::GObjectNodeFilterCondition::create(nodeFilter));
+        coreNodeFilter = WebCore::NativeNodeFilter::create(document, WebKit::GObjectNodeFilterCondition::create(nodeFilter));
         nodeFilterMap().add(coreNodeFilter.get(), nodeFilter);
         g_object_weak_ref(G_OBJECT(nodeFilter), nodeFilterObjectDestroyedCallback, coreNodeFilter.get());
         g_object_set_data(G_OBJECT(nodeFilter), "webkit-core-node-filter", coreNodeFilter.get());
index 6bb139b..791f40e 100644 (file)
 #include <webkitdom/WebKitDOMNodeFilter.h>
 
 namespace WebCore {
+class Document;
 class NodeFilter;
 }
 
 namespace WebKit {
 WebKitDOMNodeFilter* kit(WebCore::NodeFilter*);
-RefPtr<WebCore::NodeFilter> core(WebKitDOMNodeFilter*);
+RefPtr<WebCore::NodeFilter> core(WebCore::Document*, WebKitDOMNodeFilter*);
 } // namespace WebKit
 
 #endif /* WebKitDOMNodeFilterPrivate_h */
index b15d24e..e54373a 100644 (file)
@@ -1,3 +1,15 @@
+2017-08-02  Sam Weinig  <sam@webkit.org>
+
+        [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.
+
 2017-08-01  Chris Dumez  <cdumez@apple.com>
 
         Add initial support for navigator.sendBeacon
index 30fcfe8..fdf6e4d 100644 (file)
         raiseTypeErrorException();
     RefPtr<WebCore::NodeFilter> nativeNodeFilter;
     if (filter)
-        nativeNodeFilter = WebCore::NativeNodeFilter::create(WebCore::ObjCNodeFilterCondition::create(filter));
+        nativeNodeFilter = WebCore::NativeNodeFilter::create(IMPL, WebCore::ObjCNodeFilterCondition::create(filter));
     return kit(WTF::getPtr(IMPL->createNodeIterator(*core(root), whatToShow, WTF::getPtr(nativeNodeFilter), expandEntityReferences)));
 }
 
         raiseTypeErrorException();
     RefPtr<WebCore::NodeFilter> nativeNodeFilter;
     if (filter)
-        nativeNodeFilter = WebCore::NativeNodeFilter::create(WebCore::ObjCNodeFilterCondition::create(filter));
+        nativeNodeFilter = WebCore::NativeNodeFilter::create(IMPL, WebCore::ObjCNodeFilterCondition::create(filter));
     return kit(WTF::getPtr(IMPL->createTreeWalker(*core(root), whatToShow, WTF::getPtr(nativeNodeFilter), expandEntityReferences)));
 }