Title: [219361] trunk
Revision
219361
Author
[email protected]
Date
2017-07-11 14:07:08 -0700 (Tue, 11 Jul 2017)

Log Message

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

Reviewed by Chris Dumez.

Source/WebCore:

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

* DerivedSources.make:
Add MutationCallback.

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

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

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

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

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

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

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

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

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

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

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

* dom/MutationCallback.h:
Update signatures.

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

* dom/MutationObserver.idl:
Remove CustomConstructor.

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

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

LayoutTests:

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

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (219360 => 219361)


--- trunk/LayoutTests/ChangeLog	2017-07-11 20:56:26 UTC (rev 219360)
+++ trunk/LayoutTests/ChangeLog	2017-07-11 21:07:08 UTC (rev 219361)
@@ -1,3 +1,13 @@
+2017-07-10  Sam Weinig  <[email protected]>
+
+        [WebIDL] Convert MutationCallback to be a normal generate callback
+        https://bugs.webkit.org/show_bug.cgi?id=174140
+
+        Reviewed by Chris Dumez.
+
+        * fast/dom/MutationObserver/mutation-observer-constructor-expected.txt:
+        Update results for standard error messages.
+
 2017-07-11  Chris Dumez  <[email protected]>
 
         Window's [[OwnPropertyKeys]] is wrong for cross origin windows

Modified: trunk/LayoutTests/fast/dom/MutationObserver/mutation-observer-constructor-expected.txt (219360 => 219361)


--- trunk/LayoutTests/fast/dom/MutationObserver/mutation-observer-constructor-expected.txt	2017-07-11 20:56:26 UTC (rev 219360)
+++ trunk/LayoutTests/fast/dom/MutationObserver/mutation-observer-constructor-expected.txt	2017-07-11 21:07:08 UTC (rev 219361)
@@ -8,10 +8,10 @@
 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

Modified: trunk/Source/WebCore/CMakeLists.txt (219360 => 219361)


--- trunk/Source/WebCore/CMakeLists.txt	2017-07-11 20:56:26 UTC (rev 219360)
+++ trunk/Source/WebCore/CMakeLists.txt	2017-07-11 21:07:08 UTC (rev 219361)
@@ -464,6 +464,7 @@
     dom/MessagePort.idl
     dom/MouseEvent.idl
     dom/MouseEventInit.idl
+    dom/MutationCallback.idl
     dom/MutationEvent.idl
     dom/MutationObserver.idl
     dom/MutationRecord.idl
@@ -1210,7 +1211,6 @@
     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

Modified: trunk/Source/WebCore/ChangeLog (219360 => 219361)


--- trunk/Source/WebCore/ChangeLog	2017-07-11 20:56:26 UTC (rev 219360)
+++ trunk/Source/WebCore/ChangeLog	2017-07-11 21:07:08 UTC (rev 219361)
@@ -1,3 +1,102 @@
+2017-07-10  Sam Weinig  <[email protected]>
+
+        [WebIDL] Convert MutationCallback to be a normal generate callback
+        https://bugs.webkit.org/show_bug.cgi?id=174140
+
+        Reviewed by Chris Dumez.
+
+        To make this work more nicely, I:
+        - Added the ability to for non-nullable interfaces in sequences to be passed
+          via a Ref<> rather than a RefPtr<> as a parameter to a callback function.
+          (e.g. callback MyCallback = void (sequence<Foo> foos) will now have the 
+          signature, CallbackResult<void> handleEvent(const Vector<Ref<Foo>>&) rather
+          than CallbackResult<void> handleEvent(const Vector<RefPtr<Foo>>&).
+        - Added a new extended attribute for callback functions called [CallbackNeedsCanInvoke]
+          that adds a virtual function called canInvoke() to the generated callback.
+          All it does is forward to ActiveDOMCallback's canInvokeCallback, but it
+          allows the implementation to get to it. We may one day want to move the 
+          inheritance of ActiveDOMCallback from the generated source to the base class.
+        - Added a new extended attribute for callback functions called [CallbackThisObject=Type]
+          which allows you to specify that the callback needs a this object in addition
+          to its arguments. When specified, the first argument of the C++ implementation
+          function will now correspond to the this object, with the remaining arguments
+          shifted over one.
+
+        * DerivedSources.make:
+        Add MutationCallback.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        Remove non-generated JSMutationCallback.cpp, and add generated JSMutationCallback.cpp.
+
+        * Modules/mediastream/MediaDevicesRequest.cpp:
+        (WebCore::MediaDevicesRequest::filterDeviceList):
+        (WebCore::MediaDevicesRequest::start):
+        * Modules/mediastream/MediaDevicesRequest.h:
+        Switch to using Ref.
+
+        * bindings/IDLTypes.h:
+        Add InnerParameterType and NullableInnerParameterType type hooks
+        and specialize wrappers to use Ref for InnerParameterType, and RefPtr
+        for NullableInnerParameterType.
+
+        * bindings/js/JSCallbackData.cpp:
+        * bindings/js/JSCallbackData.h:
+        Add support for passing a this object.
+
+        * bindings/js/JSMutationCallback.cpp: Removed.
+        * bindings/js/JSMutationCallback.h: Removed.
+        Remove custom callback code.
+
+        * bindings/js/JSMutationObserverCustom.cpp:
+        (WebCore::constructJSMutationObserver): Deleted.
+        Remove no longer needed custom constructor.
+
+        * bindings/scripts/CodeGenerator.pm:
+        (ParseType):
+        Add helper to parse a type and cache the result.
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateCallbackHeaderContent):
+        (GenerateCallbackImplementationContent):
+        Add support for [CallbackNeedsCanInvoke] and [CallbackThisObject]. When [CallbackThisObject]
+        is not specified, use jsUndefined() as the this object as specified by WebIDL.
+
+        * bindings/scripts/IDLAttributes.json:
+        Add [CallbackNeedsCanInvoke] and [CallbackThisObject].
+
+        * bindings/scripts/IDLParser.pm:
+        (ParseType):
+        Add entry point to parse a single type.
+
+        * css/FontFaceSet.h:
+        Switch to using Ref.
+
+        * dom/MutationCallback.h:
+        Update signatures.
+
+        * dom/MutationCallback.idl: Added.
+    
+        * dom/MutationObserver.cpp:
+        (WebCore::MutationObserver::canDeliver):
+        (WebCore::MutationObserver::deliver):
+        Switch to new signatures.
+
+        * dom/MutationObserver.idl:
+        Remove CustomConstructor.
+
+        * page/IntersectionObserverCallback.h:
+        Switch to using Ref.
+
+        * bindings/scripts/test/JS/JSTestCallbackFunction.cpp:
+        * bindings/scripts/test/JS/JSTestCallbackFunctionRethrow.cpp:
+        * bindings/scripts/test/JS/JSTestCallbackFunctionWithThisObject.cpp: Added.
+        * bindings/scripts/test/JS/JSTestCallbackFunctionWithThisObject.h: Added.
+        * bindings/scripts/test/JS/JSTestCallbackFunctionWithTypedefs.cpp:
+        * bindings/scripts/test/JS/JSTestCallbackInterface.cpp:
+        * bindings/scripts/test/JS/JSTestCallbackInterface.h:
+        * bindings/scripts/test/JS/JSTestVoidCallbackFunction.cpp:
+        Add / update bindings tests.
+
 2017-07-11  Said Abou-Hallawa  <[email protected]>
 
         RenderImage should not add itself as a RelevantRepaintedObject if its image frame is being decoded

Modified: trunk/Source/WebCore/DerivedSources.make (219360 => 219361)


--- trunk/Source/WebCore/DerivedSources.make	2017-07-11 20:56:26 UTC (rev 219360)
+++ trunk/Source/WebCore/DerivedSources.make	2017-07-11 21:07:08 UTC (rev 219361)
@@ -399,6 +399,7 @@
     $(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 \

Modified: trunk/Source/WebCore/Modules/mediastream/MediaDevicesRequest.cpp (219360 => 219361)


--- trunk/Source/WebCore/Modules/mediastream/MediaDevicesRequest.cpp	2017-07-11 20:56:26 UTC (rev 219360)
+++ trunk/Source/WebCore/Modules/mediastream/MediaDevicesRequest.cpp	2017-07-11 21:07:08 UTC (rev 219361)
@@ -79,7 +79,7 @@
     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 @@
 
     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 @@
         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())

Modified: trunk/Source/WebCore/Modules/mediastream/MediaDevicesRequest.h (219360 => 219361)


--- trunk/Source/WebCore/Modules/mediastream/MediaDevicesRequest.h	2017-07-11 20:56:26 UTC (rev 219360)
+++ trunk/Source/WebCore/Modules/mediastream/MediaDevicesRequest.h	2017-07-11 21:07:08 UTC (rev 219361)
@@ -51,7 +51,7 @@
 
     void contextDestroyed() final;
 
-    void filterDeviceList(Vector<RefPtr<MediaDeviceInfo>>&);
+    void filterDeviceList(Vector<Ref<MediaDeviceInfo>>&);
 
     MediaDevices::EnumerateDevicesPromise m_promise;
     RefPtr<MediaDevicesRequest> m_protector;

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (219360 => 219361)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-07-11 20:56:26 UTC (rev 219360)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-07-11 21:07:08 UTC (rev 219361)
@@ -3256,6 +3256,8 @@
 		7C93F34E1AA6BF0700A98BAB /* ContentExtensionCompiler.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C93F34C1AA6BF0700A98BAB /* ContentExtensionCompiler.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		7C9DBFED1A9C49B1000D6B25 /* JSHTMLAttachmentElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C9DBFEB1A9C49B1000D6B25 /* JSHTMLAttachmentElement.cpp */; };
 		7C9DBFEE1A9C49B1000D6B25 /* JSHTMLAttachmentElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C9DBFEC1A9C49B1000D6B25 /* JSHTMLAttachmentElement.h */; };
+		7CACB6051F1535AD0007101C /* JSMutationCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CACB6031F1535AC0007101C /* JSMutationCallback.cpp */; };
+		7CACB6061F1535AD0007101C /* JSMutationCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CACB6041F1535AC0007101C /* JSMutationCallback.h */; };
 		7CB5CA3F1E525C7100FAEF13 /* MediaQueryExpression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CB5CA3D1E525C6C00FAEF13 /* MediaQueryExpression.cpp */; };
 		7CB5CA401E525C7300FAEF13 /* MediaQueryExpression.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CB5CA3E1E525C6C00FAEF13 /* MediaQueryExpression.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		7CBA5BA71F0B4BDE0034D745 /* JSDOMConvertWebGL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CBA5BA61F0B4BDE0034D745 /* JSDOMConvertWebGL.cpp */; };
@@ -6056,8 +6058,6 @@
 		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 */; };
@@ -11330,6 +11330,9 @@
 		7C9DBFEA1A9C489F000D6B25 /* HTMLAttachmentElement.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = HTMLAttachmentElement.idl; sourceTree = "<group>"; };
 		7C9DBFEB1A9C49B1000D6B25 /* JSHTMLAttachmentElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLAttachmentElement.cpp; sourceTree = "<group>"; };
 		7C9DBFEC1A9C49B1000D6B25 /* JSHTMLAttachmentElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSHTMLAttachmentElement.h; sourceTree = "<group>"; };
+		7CACB6031F1535AC0007101C /* JSMutationCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMutationCallback.cpp; sourceTree = "<group>"; };
+		7CACB6041F1535AC0007101C /* JSMutationCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMutationCallback.h; sourceTree = "<group>"; };
+		7CACB6071F1535DF0007101C /* MutationCallback.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = MutationCallback.idl; sourceTree = "<group>"; };
 		7CB5CA3D1E525C6C00FAEF13 /* MediaQueryExpression.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaQueryExpression.cpp; sourceTree = "<group>"; };
 		7CB5CA3E1E525C6C00FAEF13 /* MediaQueryExpression.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaQueryExpression.h; sourceTree = "<group>"; };
 		7CBA5BA61F0B4BDE0034D745 /* JSDOMConvertWebGL.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMConvertWebGL.cpp; sourceTree = "<group>"; };
@@ -14570,8 +14573,6 @@
 		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>"; };
@@ -22063,6 +22064,8 @@
 				BC64649611D82349006455B0 /* JSDOMStringMap.h */,
 				65DF31E509D1CC60000BE325 /* JSElement.cpp */,
 				65DF31E609D1CC60000BE325 /* JSElement.h */,
+				7CACB6031F1535AC0007101C /* JSMutationCallback.cpp */,
+				7CACB6041F1535AC0007101C /* JSMutationCallback.h */,
 				C6F0902414327D4F00685849 /* JSMutationObserver.cpp */,
 				C6F0902514327D4F00685849 /* JSMutationObserver.h */,
 				C6F08FC71431000D00685849 /* JSMutationRecord.cpp */,
@@ -23946,8 +23949,6 @@
 				93B70D4E09EB0C7C009D8468 /* JSEventListener.h */,
 				935F45400F7C3B5F00D7C1FB /* JSLazyEventListener.cpp */,
 				935F45410F7C3B5F00D7C1FB /* JSLazyEventListener.h */,
-				C6F420A016B7164E0052A9F2 /* JSMutationCallback.cpp */,
-				C6F420A116B7164E0052A9F2 /* JSMutationCallback.h */,
 				BCA378BA0D15F64200B793D6 /* ScheduledAction.cpp */,
 				BCA378BB0D15F64200B793D6 /* ScheduledAction.h */,
 			);
@@ -25803,6 +25804,7 @@
 				85031B310A44EFC700F992E0 /* MouseRelatedEvent.cpp */,
 				85031B320A44EFC700F992E0 /* MouseRelatedEvent.h */,
 				C6F0900114327B6100685849 /* MutationCallback.h */,
+				7CACB6071F1535DF0007101C /* MutationCallback.idl */,
 				85031B330A44EFC700F992E0 /* MutationEvent.cpp */,
 				85031B340A44EFC700F992E0 /* MutationEvent.h */,
 				93EEC1F309C2877700C515D1 /* MutationEvent.idl */,
@@ -27085,6 +27087,7 @@
 				CD19A2681A13E700008D650E /* DiagnosticLoggingClient.h in Headers */,
 				46FCB6181A70820E00C5A21E /* DiagnosticLoggingKeys.h in Headers */,
 				8372DB311A6780A800C697C5 /* DiagnosticLoggingResultType.h in Headers */,
+				7CACB6061F1535AD0007101C /* JSMutationCallback.h in Headers */,
 				CECADFC7153778FF00E37068 /* DictationAlternative.h in Headers */,
 				CECADFC9153778FF00E37068 /* DictationCommand.h in Headers */,
 				D0BD4F5D1408850F006839B6 /* DictationCommandIOS.h in Headers */,
@@ -28124,7 +28127,6 @@
 				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 */,
@@ -30372,8 +30374,7 @@
 		1C09D0501E31C32900725F18 /* libPAL.a */ = {
 			isa = PBXReferenceProxy;
 			fileType = archive.ar;
-			name = libPAL.a;
-			path = lib.a;
+			path = libPAL.a;
 			remoteRef = 1C09D04F1E31C32900725F18 /* PBXContainerItemProxy */;
 			sourceTree = BUILT_PRODUCTS_DIR;
 		};
@@ -32109,6 +32110,7 @@
 				07277E5217D018CC0015534D /* JSMediaStreamTrack.cpp in Sources */,
 				415CDAF71E6CE0DE004F11EE /* JSMediaStreamTrackCustom.cpp in Sources */,
 				07277E5417D018CC0015534D /* JSMediaStreamTrackEvent.cpp in Sources */,
+				7CACB6051F1535AD0007101C /* JSMutationCallback.cpp in Sources */,
 				932CC0D41DFFD667004C0F9F /* JSMediaTrackConstraints.cpp in Sources */,
 				0787C4691BFBDF6F006DCD7F /* JSMediaTrackSupportedConstraints.cpp in Sources */,
 				E107400D0E77BDC00033AF24 /* JSMessageChannel.cpp in Sources */,
@@ -32119,7 +32121,6 @@
 				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 */,

Modified: trunk/Source/WebCore/bindings/IDLTypes.h (219360 => 219361)


--- trunk/Source/WebCore/bindings/IDLTypes.h	2017-07-11 20:56:26 UTC (rev 219360)
+++ trunk/Source/WebCore/bindings/IDLTypes.h	2017-07-11 21:07:08 UTC (rev 219361)
@@ -62,6 +62,9 @@
     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; }
@@ -153,6 +156,9 @@
     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; }
@@ -176,6 +182,9 @@
     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)); }
@@ -185,8 +194,8 @@
 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>> {

Modified: trunk/Source/WebCore/bindings/js/JSCallbackData.cpp (219360 => 219361)


--- trunk/Source/WebCore/bindings/js/JSCallbackData.cpp	2017-07-11 20:56:26 UTC (rev 219360)
+++ trunk/Source/WebCore/bindings/js/JSCallbackData.cpp	2017-07-11 21:07:08 UTC (rev 219361)
@@ -39,7 +39,7 @@
     
 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,8 +79,8 @@
 
     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);
 

Modified: trunk/Source/WebCore/bindings/js/JSCallbackData.h (219360 => 219361)


--- trunk/Source/WebCore/bindings/js/JSCallbackData.h	2017-07-11 20:56:26 UTC (rev 219360)
+++ trunk/Source/WebCore/bindings/js/JSCallbackData.h	2017-07-11 21:07:08 UTC (rev 219361)
@@ -64,7 +64,7 @@
 #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 @@
 
     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,13 +106,13 @@
 
     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:

Deleted: trunk/Source/WebCore/bindings/js/JSMutationCallback.cpp (219360 => 219361)


--- trunk/Source/WebCore/bindings/js/JSMutationCallback.cpp	2017-07-11 20:56:26 UTC (rev 219360)
+++ trunk/Source/WebCore/bindings/js/JSMutationCallback.cpp	2017-07-11 21:07:08 UTC (rev 219361)
@@ -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

Deleted: trunk/Source/WebCore/bindings/js/JSMutationCallback.h (219360 => 219361)


--- trunk/Source/WebCore/bindings/js/JSMutationCallback.h	2017-07-11 20:56:26 UTC (rev 219360)
+++ trunk/Source/WebCore/bindings/js/JSMutationCallback.h	2017-07-11 21:07:08 UTC (rev 219361)
@@ -1,57 +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.
- */
-
-#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

Modified: trunk/Source/WebCore/bindings/js/JSMutationObserverCustom.cpp (219360 => 219361)


--- trunk/Source/WebCore/bindings/js/JSMutationObserverCustom.cpp	2017-07-11 20:56:26 UTC (rev 219360)
+++ trunk/Source/WebCore/bindings/js/JSMutationObserverCustom.cpp	2017-07-11 21:07:08 UTC (rev 219361)
@@ -32,39 +32,12 @@
 #include "config.h"
 #include "JSMutationObserver.h"
 
-#include "ExceptionCode.h"
-#include "JSDOMConstructorBase.h"
-#include "JSMutationCallback.h"
 #include "JSNodeCustom.h"
-#include "MutationObserver.h"
-#include <runtime/Error.h>
-#include <runtime/PrivateName.h>
 
 using namespace JSC;
 
 namespace WebCore {
 
-EncodedJSValue JSC_HOST_CALL constructJSMutationObserver(ExecState& exec)
-{
-    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);
-}
-
 bool JSMutationObserverOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
 {
     for (auto* node : jsCast<JSMutationObserver*>(handle.slot()->asCell())->wrapped().observedNodes()) {

Modified: trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm (219360 => 219361)


--- trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm	2017-07-11 20:56:26 UTC (rev 219360)
+++ trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm	2017-07-11 21:07:08 UTC (rev 219361)
@@ -120,6 +120,7 @@
 my $cachedInterfaces = {};
 my $cachedExternalDictionaries = {};
 my $cachedExternalEnumerations = {};
+my $cachedTypes = {};
 
 sub assert
 {
@@ -369,6 +370,20 @@
     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

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (219360 => 219361)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2017-07-11 20:56:26 UTC (rev 219360)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2017-07-11 21:07:08 UTC (rev 219361)
@@ -599,10 +599,10 @@
 
     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");
@@ -5808,6 +5808,7 @@
     push(@$contentRef, "    static JSC::JSValue getConstructor(JSC::VM&, const JSC::JSGlobalObject*);\n") if @{$constants};
 
     push(@$contentRef, "    virtual bool operator==(const ${name}&) const override;\n\n") if $interfaceOrCallback->extendedAttributes->{CallbackNeedsOperatorEqual};
+    push(@$contentRef, "    virtual bool canInvoke() const override { return ActiveDOMCallback::canInvokeCallback(); }\n\n") if $interfaceOrCallback->extendedAttributes->{CallbackNeedsCanInvoke};
 
     # Operations
     my $numOperations = @{$operations};
@@ -5815,6 +5816,14 @@
         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);
@@ -5946,15 +5955,31 @@
             # 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
@@ -5970,6 +5995,8 @@
             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}) {
@@ -5980,10 +6007,10 @@
 
             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") {
@@ -6018,12 +6045,11 @@
         }
     }
 
-    # toJS() implementation.
     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");
 }
 

Modified: trunk/Source/WebCore/bindings/scripts/IDLAttributes.json (219360 => 219361)


--- trunk/Source/WebCore/bindings/scripts/IDLAttributes.json	2017-07-11 20:56:26 UTC (rev 219360)
+++ trunk/Source/WebCore/bindings/scripts/IDLAttributes.json	2017-07-11 21:07:08 UTC (rev 219361)
@@ -31,9 +31,15 @@
         "CachedAttribute": {
             "contextsAllowed": ["attribute"]
         },
+        "CallbackNeedsCanInvoke": {
+            "contextsAllowed": ["callback-function"]
+        },
         "CallbackNeedsOperatorEqual": {
             "contextsAllowed": ["callback-function"]
         },
+        "CallbackThisObject": {
+            "contextsAllowed": ["callback-function", "operation"]
+        },
         "CallWith": {
             "contextsAllowed": ["attribute", "operation"],
             "values": ["Document", "ScriptExecutionContext", "ScriptState", "GlobalObject", "ActiveWindow", "FirstWindow", "ResponsibleDocument", "World"]

Modified: trunk/Source/WebCore/bindings/scripts/IDLParser.pm (219360 => 219361)


--- trunk/Source/WebCore/bindings/scripts/IDLParser.pm	2017-07-11 20:56:26 UTC (rev 219360)
+++ trunk/Source/WebCore/bindings/scripts/IDLParser.pm	2017-07-11 21:07:08 UTC (rev 219361)
@@ -346,6 +346,30 @@
     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;

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunction.cpp (219360 => 219361)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunction.cpp	2017-07-11 20:56:26 UTC (rev 219360)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunction.cpp	2017-07-11 21:07:08 UTC (rev 219361)
@@ -64,11 +64,12 @@
 
     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 +87,6 @@
         return jsNull();
 
     return static_cast<JSTestCallbackFunction&>(impl).callbackData()->callback();
-
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionRethrow.cpp (219360 => 219361)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionRethrow.cpp	2017-07-11 20:56:26 UTC (rev 219360)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionRethrow.cpp	2017-07-11 21:07:08 UTC (rev 219361)
@@ -67,11 +67,12 @@
 
     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 +91,6 @@
         return jsNull();
 
     return static_cast<JSTestCallbackFunctionRethrow&>(impl).callbackData()->callback();
-
 }
 
 } // namespace WebCore

Added: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionWithThisObject.cpp (0 => 219361)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionWithThisObject.cpp	                        (rev 0)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionWithThisObject.cpp	2017-07-11 21:07:08 UTC (rev 219361)
@@ -0,0 +1,92 @@
+/*
+    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>
+#include <runtime/JSLock.h>
+
+using namespace JSC;
+
+namespace WebCore {
+
+JSTestCallbackFunctionWithThisObject::JSTestCallbackFunctionWithThisObject(JSObject* callback, JSDOMGlobalObject* globalObject)
+    : TestCallbackFunctionWithThisObject()
+    , ActiveDOMCallback(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

Added: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionWithThisObject.h (0 => 219361)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionWithThisObject.h	                        (rev 0)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionWithThisObject.h	2017-07-11 21:07:08 UTC (rev 219361)
@@ -0,0 +1,55 @@
+/*
+    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 "ActiveDOMCallback.h"
+#include "IDLTypes.h"
+#include "JSCallbackData.h"
+#include "TestCallbackFunctionWithThisObject.h"
+#include <wtf/Forward.h>
+
+namespace WebCore {
+
+class JSTestCallbackFunctionWithThisObject final : public TestCallbackFunctionWithThisObject, public ActiveDOMCallback {
+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

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionWithTypedefs.cpp (219360 => 219361)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionWithTypedefs.cpp	2017-07-11 20:56:26 UTC (rev 219360)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionWithTypedefs.cpp	2017-07-11 21:07:08 UTC (rev 219361)
@@ -67,12 +67,13 @@
 
     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 +88,6 @@
         return jsNull();
 
     return static_cast<JSTestCallbackFunctionWithTypedefs&>(impl).callbackData()->callback();
-
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackInterface.cpp (219360 => 219361)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackInterface.cpp	2017-07-11 20:56:26 UTC (rev 219360)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackInterface.cpp	2017-07-11 21:07:08 UTC (rev 219361)
@@ -35,6 +35,7 @@
 #include "JSDOMGlobalObject.h"
 #include "JSDOMStringList.h"
 #include "JSTestNode.h"
+#include "JSTestObj.h"
 #include "ScriptExecutionContext.h"
 #include "SerializedScriptValue.h"
 #include <runtime/FunctionPrototype.h>
@@ -168,10 +169,11 @@
 
     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 +194,12 @@
 
     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 +220,13 @@
 
     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 +247,12 @@
 
     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 +273,12 @@
 
     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 +299,13 @@
 
     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 +326,11 @@
 
     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 +354,12 @@
 
     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 +381,12 @@
 
     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;
@@ -388,6 +398,35 @@
     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;
+     }
+
+    auto throwScope = DECLARE_THROW_SCOPE(vm);
+    auto returnValue = convert<IDLDOMString>(state, jsResult);
+    RETURN_IF_EXCEPTION(throwScope, CallbackResultType::ExceptionThrown);
+    return WTFMove(returnValue);
+}
+
 JSC::JSValue toJS(TestCallbackInterface& impl)
 {
     if (!static_cast<JSTestCallbackInterface&>(impl).callbackData())
@@ -394,7 +433,6 @@
         return jsNull();
 
     return static_cast<JSTestCallbackInterface&>(impl).callbackData()->callback();
-
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackInterface.h (219360 => 219361)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackInterface.h	2017-07-11 20:56:26 UTC (rev 219360)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackInterface.h	2017-07-11 21:07:08 UTC (rev 219361)
@@ -56,6 +56,7 @@
     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*);

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestVoidCallbackFunction.cpp (219360 => 219361)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestVoidCallbackFunction.cpp	2017-07-11 20:56:26 UTC (rev 219360)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestVoidCallbackFunction.cpp	2017-07-11 21:07:08 UTC (rev 219361)
@@ -74,6 +74,7 @@
 
     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 +84,7 @@
     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 +99,6 @@
         return jsNull();
 
     return static_cast<JSTestVoidCallbackFunction&>(impl).callbackData()->callback();
-
 }
 
 } // namespace WebCore

Added: trunk/Source/WebCore/bindings/scripts/test/TestCallbackFunctionWithThisObject.idl (0 => 219361)


--- trunk/Source/WebCore/bindings/scripts/test/TestCallbackFunctionWithThisObject.idl	                        (rev 0)
+++ trunk/Source/WebCore/bindings/scripts/test/TestCallbackFunctionWithThisObject.idl	2017-07-11 21:07:08 UTC (rev 219361)
@@ -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);

Modified: trunk/Source/WebCore/bindings/scripts/test/TestCallbackInterface.idl (219360 => 219361)


--- trunk/Source/WebCore/bindings/scripts/test/TestCallbackInterface.idl	2017-07-11 20:56:26 UTC (rev 219360)
+++ trunk/Source/WebCore/bindings/scripts/test/TestCallbackInterface.idl	2017-07-11 21:07:08 UTC (rev 219361)
@@ -52,4 +52,5 @@
     DOMString callbackWithAReturnValue();
     [RethrowException] DOMString callbackThatRethrowsExceptions(TestCallbackInterfaceEnum enumParam);
     [SkipCallbackInvokeCheck] DOMString callbackThatSkipsInvokeCheck(TestCallbackInterfaceDictionary dictionaryParam);
+    [CallbackThisObject=TestNode] DOMString callbackWithThisObject(TestObj testObjParam);
 };

Modified: trunk/Source/WebCore/css/FontFaceSet.h (219360 => 219361)


--- trunk/Source/WebCore/css/FontFaceSet.h	2017-07-11 20:56:26 UTC (rev 219360)
+++ trunk/Source/WebCore/css/FontFaceSet.h	2017-07-11 21:07:08 UTC (rev 219361)
@@ -84,7 +84,7 @@
         PendingPromise(LoadPromise&&);
 
     public:
-        Vector<RefPtr<FontFace>> faces;
+        Vector<Ref<FontFace>> faces;
         LoadPromise promise;
         bool hasReachedTerminalState { false };
     };

Modified: trunk/Source/WebCore/dom/MutationCallback.h (219360 => 219361)


--- trunk/Source/WebCore/dom/MutationCallback.h	2017-07-11 20:56:26 UTC (rev 219360)
+++ trunk/Source/WebCore/dom/MutationCallback.h	2017-07-11 21:07:08 UTC (rev 219361)
@@ -30,6 +30,7 @@
 
 #pragma once
 
+#include "CallbackResult.h"
 #include <wtf/Ref.h>
 #include <wtf/RefCounted.h>
 #include <wtf/Vector.h>
@@ -43,8 +44,8 @@
 public:
     virtual ~MutationCallback() { }
 
-    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;
+    virtual bool canInvoke() const = 0;
 };
 
 } // namespace WebCore

Added: trunk/Source/WebCore/dom/MutationCallback.idl (0 => 219361)


--- trunk/Source/WebCore/dom/MutationCallback.idl	                        (rev 0)
+++ trunk/Source/WebCore/dom/MutationCallback.idl	2017-07-11 21:07:08 UTC (rev 219361)
@@ -0,0 +1,29 @@
+/*
+ * 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
+ * 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.
+ */
+
+[
+    CallbackNeedsCanInvoke,
+    CallbackThisObject=MutationObserver
+] callback MutationCallback = void (sequence<MutationRecord> mutations, MutationObserver observer);

Modified: trunk/Source/WebCore/dom/MutationObserver.cpp (219360 => 219361)


--- trunk/Source/WebCore/dom/MutationObserver.cpp	2017-07-11 20:56:26 UTC (rev 219360)
+++ trunk/Source/WebCore/dom/MutationObserver.cpp	2017-07-11 21:07:08 UTC (rev 219361)
@@ -209,7 +209,7 @@
 
 bool MutationObserver::canDeliver()
 {
-    return m_callback->canInvokeCallback();
+    return m_callback->canInvoke();
 }
 
 void MutationObserver::deliver()
@@ -232,7 +232,7 @@
     Vector<Ref<MutationRecord>> records;
     records.swap(m_records);
 
-    m_callback->call(records, this);
+    m_callback->handleEvent(*this, records, *this);
 }
 
 void MutationObserver::notifyMutationObservers()

Modified: trunk/Source/WebCore/dom/MutationObserver.idl (219360 => 219361)


--- trunk/Source/WebCore/dom/MutationObserver.idl	2017-07-11 20:56:26 UTC (rev 219360)
+++ trunk/Source/WebCore/dom/MutationObserver.idl	2017-07-11 21:07:08 UTC (rev 219361)
@@ -29,7 +29,7 @@
  */
 
 [
-    CustomConstructor(MutationCallback callback),
+    Constructor(MutationCallback callback),
     CustomIsReachable,
     ImplementationLacksVTable,
     LegacyWindowAlias=WebKitMutationObserver,

Modified: trunk/Source/WebCore/page/IntersectionObserverCallback.h (219360 => 219361)


--- trunk/Source/WebCore/page/IntersectionObserverCallback.h	2017-07-11 20:56:26 UTC (rev 219360)
+++ trunk/Source/WebCore/page/IntersectionObserverCallback.h	2017-07-11 21:07:08 UTC (rev 219361)
@@ -39,7 +39,7 @@
 class IntersectionObserverCallback : public RefCounted<IntersectionObserverCallback> {
 public:
     virtual ~IntersectionObserverCallback() { }
-    virtual CallbackResult<void> handleEvent(const Vector<RefPtr<IntersectionObserverEntry>>&, IntersectionObserver&) = 0;
+    virtual CallbackResult<void> handleEvent(const Vector<Ref<IntersectionObserverEntry>>&, IntersectionObserver&) = 0;
 };
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to