summaryrefslogtreecommitdiff
path: root/Source/WebKit2/Shared
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebKit2/Shared
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebKit2/Shared')
-rw-r--r--Source/WebKit2/Shared/API/APIArray.cpp (renamed from Source/WebKit2/Shared/APIArray.cpp)22
-rw-r--r--Source/WebKit2/Shared/API/APIArray.h (renamed from Source/WebKit2/Shared/APIArray.h)31
-rw-r--r--Source/WebKit2/Shared/API/APIClient.h (renamed from Source/WebKit2/Shared/APIClient.h)0
-rw-r--r--Source/WebKit2/Shared/API/APIData.cpp (renamed from Source/WebKit2/Shared/APIData.cpp)8
-rw-r--r--Source/WebKit2/Shared/API/APIData.h (renamed from Source/WebKit2/Shared/APIData.h)22
-rw-r--r--Source/WebKit2/Shared/API/APIDictionary.cpp (renamed from Source/WebKit2/Shared/ImmutableDictionary.cpp)39
-rw-r--r--Source/WebKit2/Shared/API/APIDictionary.h (renamed from Source/WebKit2/Shared/ImmutableDictionary.h)43
-rw-r--r--Source/WebKit2/Shared/API/APIError.cpp (renamed from Source/WebKit2/Shared/APIError.cpp)4
-rw-r--r--Source/WebKit2/Shared/API/APIError.h (renamed from Source/WebKit2/Shared/APIError.h)17
-rw-r--r--Source/WebKit2/Shared/API/APIFrameHandle.cpp74
-rw-r--r--Source/WebKit2/Shared/API/APIFrameHandle.h (renamed from Source/WebKit2/Shared/APIFrameHandle.h)21
-rw-r--r--Source/WebKit2/Shared/API/APIGeometry.cpp (renamed from Source/WebKit2/Shared/APIGeometry.cpp)16
-rw-r--r--Source/WebKit2/Shared/API/APIGeometry.h (renamed from Source/WebKit2/Shared/APIGeometry.h)29
-rw-r--r--Source/WebKit2/Shared/API/APINumber.h (renamed from Source/WebKit2/Shared/APINumber.h)13
-rw-r--r--Source/WebKit2/Shared/API/APIObject.cpp (renamed from Source/WebKit2/Shared/APIObject.cpp)0
-rw-r--r--Source/WebKit2/Shared/API/APIObject.h (renamed from Source/WebKit2/Shared/APIObject.h)78
-rw-r--r--Source/WebKit2/Shared/API/APIPageGroupHandle.cpp63
-rw-r--r--Source/WebKit2/Shared/API/APIPageGroupHandle.h (renamed from Source/WebKit2/Shared/InteractionInformationAtPosition.h)62
-rw-r--r--Source/WebKit2/Shared/API/APIPageHandle.cpp74
-rw-r--r--Source/WebKit2/Shared/API/APIPageHandle.h (renamed from Source/WebKit2/Shared/APIPageHandle.h)19
-rw-r--r--Source/WebKit2/Shared/API/APISecurityOrigin.h67
-rw-r--r--Source/WebKit2/Shared/API/APISerializedScriptValue.h (renamed from Source/WebKit2/Shared/WebSerializedScriptValue.h)32
-rw-r--r--Source/WebKit2/Shared/API/APIString.h79
-rw-r--r--Source/WebKit2/Shared/API/APIURL.h (renamed from Source/WebKit2/Shared/APIURL.h)31
-rw-r--r--Source/WebKit2/Shared/API/APIURLRequest.cpp (renamed from Source/WebKit2/Shared/APIURLRequest.cpp)13
-rw-r--r--Source/WebKit2/Shared/API/APIURLRequest.h (renamed from Source/WebKit2/Shared/APIURLRequest.h)12
-rw-r--r--Source/WebKit2/Shared/API/APIURLResponse.cpp (renamed from Source/WebKit2/Shared/APIURLResponse.cpp)4
-rw-r--r--Source/WebKit2/Shared/API/APIURLResponse.h (renamed from Source/WebKit2/Shared/APIURLResponse.h)12
-rw-r--r--Source/WebKit2/Shared/API/APIUserContentURLPattern.h (renamed from Source/WebKit2/Shared/WebUserContentURLPattern.h)27
-rw-r--r--Source/WebKit2/Shared/API/c/WKActionMenuItemTypes.h59
-rw-r--r--Source/WebKit2/Shared/API/c/WKActionMenuTypes.h (renamed from Source/WebKit2/Shared/CommandLine.h)45
-rw-r--r--Source/WebKit2/Shared/API/c/WKArray.cpp10
-rw-r--r--Source/WebKit2/Shared/API/c/WKArray.h2
-rw-r--r--Source/WebKit2/Shared/API/c/WKBase.h52
-rw-r--r--Source/WebKit2/Shared/API/c/WKCertificateInfo.h2
-rw-r--r--Source/WebKit2/Shared/API/c/WKConnectionRef.h12
-rw-r--r--Source/WebKit2/Shared/API/c/WKContextMenuItem.cpp48
-rw-r--r--Source/WebKit2/Shared/API/c/WKContextMenuItem.h4
-rw-r--r--Source/WebKit2/Shared/API/c/WKContextMenuItemTypes.h2
-rw-r--r--Source/WebKit2/Shared/API/c/WKData.cpp2
-rw-r--r--Source/WebKit2/Shared/API/c/WKData.h2
-rw-r--r--Source/WebKit2/Shared/API/c/WKDeclarationSpecifiers.h10
-rw-r--r--Source/WebKit2/Shared/API/c/WKDeprecatedFunctions.cpp67
-rw-r--r--Source/WebKit2/Shared/API/c/WKDiagnosticLoggingResultType.h (renamed from Source/WebKit2/Shared/API/c/soup/WKBaseSoup.h)25
-rw-r--r--Source/WebKit2/Shared/API/c/WKDictionary.cpp13
-rw-r--r--Source/WebKit2/Shared/API/c/WKDictionary.h2
-rw-r--r--Source/WebKit2/Shared/API/c/WKErrorRef.cpp (renamed from Source/WebKit2/Shared/API/c/WKError.cpp)2
-rw-r--r--Source/WebKit2/Shared/API/c/WKErrorRef.h (renamed from Source/WebKit2/Shared/API/c/WKError.h)13
-rw-r--r--Source/WebKit2/Shared/API/c/WKEvent.h5
-rw-r--r--Source/WebKit2/Shared/API/c/WKGeometry.cpp6
-rw-r--r--Source/WebKit2/Shared/API/c/WKGeometry.h2
-rw-r--r--Source/WebKit2/Shared/API/c/WKImage.cpp4
-rw-r--r--Source/WebKit2/Shared/API/c/WKImage.h9
-rw-r--r--Source/WebKit2/Shared/API/c/WKImmediateActionTypes.h52
-rw-r--r--Source/WebKit2/Shared/API/c/WKMutableArray.cpp2
-rw-r--r--Source/WebKit2/Shared/API/c/WKMutableArray.h2
-rw-r--r--Source/WebKit2/Shared/API/c/WKMutableDictionary.cpp5
-rw-r--r--Source/WebKit2/Shared/API/c/WKMutableDictionary.h2
-rw-r--r--Source/WebKit2/Shared/API/c/WKNumber.cpp12
-rw-r--r--Source/WebKit2/Shared/API/c/WKNumber.h2
-rw-r--r--Source/WebKit2/Shared/API/c/WKPluginInformation.cpp56
-rw-r--r--Source/WebKit2/Shared/API/c/WKPluginInformation.h2
-rw-r--r--Source/WebKit2/Shared/API/c/WKRenderLayer.cpp14
-rw-r--r--Source/WebKit2/Shared/API/c/WKRenderLayer.h9
-rw-r--r--Source/WebKit2/Shared/API/c/WKRenderObject.cpp18
-rw-r--r--Source/WebKit2/Shared/API/c/WKRenderObject.h7
-rw-r--r--Source/WebKit2/Shared/API/c/WKSecurityOriginRef.cpp (renamed from Source/WebKit2/Shared/API/c/WKSecurityOrigin.cpp)30
-rw-r--r--Source/WebKit2/Shared/API/c/WKSecurityOriginRef.h (renamed from Source/WebKit2/Shared/API/c/WKSecurityOrigin.h)8
-rw-r--r--Source/WebKit2/Shared/API/c/WKSerializedScriptValue.cpp12
-rw-r--r--Source/WebKit2/Shared/API/c/WKSerializedScriptValue.h2
-rw-r--r--Source/WebKit2/Shared/API/c/WKSerializedScriptValuePrivate.h2
-rw-r--r--Source/WebKit2/Shared/API/c/WKSharedAPICast.h228
-rw-r--r--Source/WebKit2/Shared/API/c/WKString.cpp74
-rw-r--r--Source/WebKit2/Shared/API/c/WKString.h3
-rw-r--r--Source/WebKit2/Shared/API/c/WKStringPrivate.h2
-rw-r--r--Source/WebKit2/Shared/API/c/WKType.cpp7
-rw-r--r--Source/WebKit2/Shared/API/c/WKType.h2
-rw-r--r--Source/WebKit2/Shared/API/c/WKURL.cpp6
-rw-r--r--Source/WebKit2/Shared/API/c/WKURL.h2
-rw-r--r--Source/WebKit2/Shared/API/c/WKURLRequest.cpp10
-rw-r--r--Source/WebKit2/Shared/API/c/WKURLRequest.h4
-rw-r--r--Source/WebKit2/Shared/API/c/WKURLResponse.h2
-rw-r--r--Source/WebKit2/Shared/API/c/WKUserContentURLPattern.cpp7
-rw-r--r--Source/WebKit2/Shared/API/c/WKUserContentURLPattern.h2
-rw-r--r--Source/WebKit2/Shared/API/c/WKUserScriptInjectionTime.h4
-rw-r--r--Source/WebKit2/Shared/API/c/cairo/WKImageCairo.cpp8
-rw-r--r--Source/WebKit2/Shared/API/c/cairo/WKImageCairo.h4
-rw-r--r--Source/WebKit2/Shared/APIString.h120
-rw-r--r--Source/WebKit2/Shared/APIWebArchive.h80
-rw-r--r--Source/WebKit2/Shared/APIWebArchiveResource.h72
-rw-r--r--Source/WebKit2/Shared/ActivityAssertion.cpp10
-rw-r--r--Source/WebKit2/Shared/ActivityAssertion.h7
-rw-r--r--Source/WebKit2/Shared/AssistedNodeInformation.cpp169
-rw-r--r--Source/WebKit2/Shared/AssistedNodeInformation.h119
-rw-r--r--Source/WebKit2/Shared/AsyncRequest.cpp67
-rw-r--r--Source/WebKit2/Shared/AsyncRequest.h153
-rw-r--r--Source/WebKit2/Shared/Authentication/AuthenticationManager.cpp273
-rw-r--r--Source/WebKit2/Shared/Authentication/AuthenticationManager.h59
-rw-r--r--Source/WebKit2/Shared/Authentication/AuthenticationManager.messages.in2
-rw-r--r--Source/WebKit2/Shared/Authentication/soup/AuthenticationManagerSoup.cpp (renamed from Source/WebKit2/Shared/MutableDictionary.cpp)24
-rw-r--r--Source/WebKit2/Shared/BlobDataFileReferenceWithSandboxExtension.cpp (renamed from Source/WebKit2/Shared/WebResourceBuffer.cpp)34
-rw-r--r--Source/WebKit2/Shared/BlobDataFileReferenceWithSandboxExtension.h (renamed from Source/WebKit2/Shared/MutableDictionary.h)34
-rw-r--r--Source/WebKit2/Shared/BlockingResponseMap.h21
-rw-r--r--Source/WebKit2/Shared/CacheModel.cpp146
-rw-r--r--Source/WebKit2/Shared/CacheModel.h6
-rw-r--r--Source/WebKit2/Shared/ChildProcess.cpp60
-rw-r--r--Source/WebKit2/Shared/ChildProcess.h34
-rw-r--r--Source/WebKit2/Shared/ChildProcess.messages.in (renamed from Source/WebKit2/Shared/Network/CustomProtocols/CustomProtocolManager.messages.in)16
-rw-r--r--Source/WebKit2/Shared/ChildProcessProxy.cpp169
-rw-r--r--Source/WebKit2/Shared/ChildProcessProxy.h116
-rw-r--r--Source/WebKit2/Shared/ContextMenuContextData.cpp143
-rw-r--r--Source/WebKit2/Shared/ContextMenuContextData.h105
-rw-r--r--Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedBackingStore.cpp191
-rw-r--r--Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedBackingStore.h93
-rw-r--r--Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp924
-rw-r--r--Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.h101
-rw-r--r--Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp682
-rw-r--r--Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.h194
-rw-r--r--Source/WebKit2/Shared/CoordinatedGraphics/SimpleViewportController.cpp172
-rw-r--r--Source/WebKit2/Shared/CoordinatedGraphics/SimpleViewportController.h81
-rw-r--r--Source/WebKit2/Shared/CoordinatedGraphics/WebCoordinatedSurface.cpp131
-rw-r--r--Source/WebKit2/Shared/CoordinatedGraphics/WebCoordinatedSurface.h83
-rw-r--r--Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.cpp173
-rw-r--r--Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.h (renamed from Source/WebKit2/Shared/WebNetworkInfo.h)59
-rw-r--r--Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadSafeCoordinatedSurface.cpp87
-rw-r--r--Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadSafeCoordinatedSurface.h58
-rw-r--r--Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp222
-rw-r--r--Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h109
-rw-r--r--Source/WebKit2/Shared/CoreIPCSupport/WebContextMessageKinds.h52
-rw-r--r--Source/WebKit2/Shared/Databases/DatabaseProcessCreationParameters.cpp61
-rw-r--r--Source/WebKit2/Shared/Databases/DatabaseProcessCreationParameters.h57
-rw-r--r--Source/WebKit2/Shared/Databases/IndexedDB/IDBUtilities.cpp60
-rw-r--r--Source/WebKit2/Shared/Databases/IndexedDB/IDBUtilities.h47
-rw-r--r--Source/WebKit2/Shared/Databases/IndexedDB/WebIDBResult.cpp54
-rw-r--r--Source/WebKit2/Shared/Databases/IndexedDB/WebIDBResult.h (renamed from Source/WebKit2/Shared/FileAPI/BlobRegistrationData.h)52
-rw-r--r--Source/WebKit2/Shared/Downloads/Download.cpp165
-rw-r--r--Source/WebKit2/Shared/Downloads/Download.h141
-rw-r--r--Source/WebKit2/Shared/Downloads/DownloadAuthenticationClient.h66
-rw-r--r--Source/WebKit2/Shared/Downloads/DownloadManager.cpp94
-rw-r--r--Source/WebKit2/Shared/Downloads/DownloadManager.h87
-rw-r--r--Source/WebKit2/Shared/Downloads/soup/DownloadSoup.cpp310
-rw-r--r--Source/WebKit2/Shared/DragControllerAction.h2
-rw-r--r--Source/WebKit2/Shared/DrawingAreaInfo.h8
-rw-r--r--Source/WebKit2/Shared/EditingRange.h84
-rw-r--r--Source/WebKit2/Shared/EditorState.cpp123
-rw-r--r--Source/WebKit2/Shared/EditorState.h122
-rw-r--r--Source/WebKit2/Shared/FileAPI/BlobRegistrationData.cpp182
-rw-r--r--Source/WebKit2/Shared/FontInfo.cpp (renamed from Source/WebKit2/Shared/OriginAndDatabases.cpp)49
-rw-r--r--Source/WebKit2/Shared/FontInfo.h12
-rw-r--r--Source/WebKit2/Shared/FrameInfoData.cpp55
-rw-r--r--Source/WebKit2/Shared/FrameInfoData.h (renamed from Source/WebKit2/Shared/APIPageHandle.cpp)33
-rw-r--r--Source/WebKit2/Shared/Gamepad/GamepadData.cpp119
-rw-r--r--Source/WebKit2/Shared/Gamepad/GamepadData.h77
-rw-r--r--Source/WebKit2/Shared/HangDetectionDisabler.h (renamed from Source/WebKit2/Shared/Network/NetworkProcessSupplement.h)36
-rw-r--r--Source/WebKit2/Shared/ImageOptions.h6
-rw-r--r--Source/WebKit2/Shared/LayerTreeContext.cpp (renamed from Source/WebKit2/Shared/gtk/LayerTreeContextGtk.cpp)22
-rw-r--r--Source/WebKit2/Shared/LayerTreeContext.h42
-rw-r--r--Source/WebKit2/Shared/LoadParameters.cpp125
-rw-r--r--Source/WebKit2/Shared/LoadParameters.h74
-rw-r--r--Source/WebKit2/Shared/NativeWebGestureEvent.h (renamed from Source/WebKit2/Shared/Downloads/soup/DownloadSoupErrors.h)29
-rw-r--r--Source/WebKit2/Shared/NativeWebKeyboardEvent.h36
-rw-r--r--Source/WebKit2/Shared/NativeWebMouseEvent.h19
-rw-r--r--Source/WebKit2/Shared/NativeWebTouchEvent.h30
-rw-r--r--Source/WebKit2/Shared/NativeWebWheelEvent.h17
-rw-r--r--Source/WebKit2/Shared/NavigationActionData.cpp31
-rw-r--r--Source/WebKit2/Shared/NavigationActionData.h25
-rw-r--r--Source/WebKit2/Shared/Network/CustomProtocols/CustomProtocolManager.h123
-rw-r--r--Source/WebKit2/Shared/Network/CustomProtocols/soup/CustomProtocolManagerImpl.cpp207
-rw-r--r--Source/WebKit2/Shared/Network/CustomProtocols/soup/CustomProtocolManagerImpl.h74
-rw-r--r--Source/WebKit2/Shared/Network/CustomProtocols/soup/CustomProtocolManagerSoup.cpp113
-rw-r--r--Source/WebKit2/Shared/Network/NetworkProcessCreationParameters.cpp115
-rw-r--r--Source/WebKit2/Shared/Network/NetworkProcessCreationParameters.h88
-rw-r--r--Source/WebKit2/Shared/Network/NetworkResourceLoadParameters.cpp157
-rw-r--r--Source/WebKit2/Shared/Network/NetworkResourceLoadParameters.h71
-rw-r--r--Source/WebKit2/Shared/PlatformPopupMenuData.cpp14
-rw-r--r--Source/WebKit2/Shared/PlatformPopupMenuData.h13
-rw-r--r--Source/WebKit2/Shared/Plugins/NPIdentifierData.cpp8
-rw-r--r--Source/WebKit2/Shared/Plugins/NPIdentifierData.h8
-rw-r--r--Source/WebKit2/Shared/Plugins/NPObjectMessageReceiver.cpp23
-rw-r--r--Source/WebKit2/Shared/Plugins/NPObjectMessageReceiver.h2
-rw-r--r--Source/WebKit2/Shared/Plugins/NPObjectProxy.cpp6
-rw-r--r--Source/WebKit2/Shared/Plugins/NPRemoteObjectMap.cpp48
-rw-r--r--Source/WebKit2/Shared/Plugins/NPRemoteObjectMap.h4
-rw-r--r--Source/WebKit2/Shared/Plugins/NPVariantData.cpp8
-rw-r--r--Source/WebKit2/Shared/Plugins/NPVariantData.h8
-rw-r--r--Source/WebKit2/Shared/Plugins/Netscape/NetscapePluginModule.cpp13
-rw-r--r--Source/WebKit2/Shared/Plugins/Netscape/NetscapePluginModule.h6
-rw-r--r--Source/WebKit2/Shared/Plugins/Netscape/PluginInformation.cpp24
-rw-r--r--Source/WebKit2/Shared/Plugins/Netscape/PluginInformation.h12
-rw-r--r--Source/WebKit2/Shared/Plugins/Netscape/x11/NetscapePluginModuleX11.cpp14
-rw-r--r--Source/WebKit2/Shared/Plugins/PluginModuleInfo.h16
-rw-r--r--Source/WebKit2/Shared/Plugins/PluginProcessCreationParameters.cpp28
-rw-r--r--Source/WebKit2/Shared/Plugins/PluginProcessCreationParameters.h23
-rw-r--r--Source/WebKit2/Shared/Plugins/PluginQuirks.h10
-rw-r--r--Source/WebKit2/Shared/Plugins/unix/PluginSearchPath.cpp76
-rw-r--r--Source/WebKit2/Shared/Plugins/unix/PluginSearchPath.h (renamed from Source/WebKit2/Shared/ConnectionStack.cpp)17
-rw-r--r--Source/WebKit2/Shared/PrintInfo.cpp9
-rw-r--r--Source/WebKit2/Shared/PrintInfo.h12
-rw-r--r--Source/WebKit2/Shared/ProcessExecutablePath.h4
-rw-r--r--Source/WebKit2/Shared/RTCNetwork.cpp217
-rw-r--r--Source/WebKit2/Shared/RTCNetwork.h (renamed from Source/WebKit2/Shared/ConnectionStack.h)96
-rw-r--r--Source/WebKit2/Shared/SandboxExtension.h64
-rw-r--r--Source/WebKit2/Shared/SandboxInitializationParameters.h14
-rw-r--r--Source/WebKit2/Shared/Scrolling/RemoteScrollingCoordinatorTransaction.cpp665
-rw-r--r--Source/WebKit2/Shared/Scrolling/RemoteScrollingCoordinatorTransaction.h (renamed from Source/WebKit2/Shared/SecurityOriginData.h)58
-rw-r--r--Source/WebKit2/Shared/SecurityOriginData.cpp114
-rw-r--r--Source/WebKit2/Shared/SessionState.cpp211
-rw-r--r--Source/WebKit2/Shared/SessionState.h129
-rw-r--r--Source/WebKit2/Shared/SessionTracker.cpp64
-rw-r--r--Source/WebKit2/Shared/SessionTracker.h24
-rw-r--r--Source/WebKit2/Shared/ShareableBitmap.cpp94
-rw-r--r--Source/WebKit2/Shared/ShareableBitmap.h42
-rw-r--r--Source/WebKit2/Shared/ShareableResource.cpp58
-rw-r--r--Source/WebKit2/Shared/ShareableResource.h17
-rw-r--r--Source/WebKit2/Shared/StatisticsData.cpp4
-rw-r--r--Source/WebKit2/Shared/StatisticsData.h8
-rw-r--r--Source/WebKit2/Shared/TextCheckerState.h23
-rw-r--r--Source/WebKit2/Shared/UpdateInfo.cpp4
-rw-r--r--Source/WebKit2/Shared/UpdateInfo.h9
-rw-r--r--Source/WebKit2/Shared/UserData.cpp352
-rw-r--r--Source/WebKit2/Shared/UserData.h32
-rw-r--r--Source/WebKit2/Shared/UserMessageCoders.h538
-rw-r--r--Source/WebKit2/Shared/VisibleContentRectUpdateInfo.cpp135
-rw-r--r--Source/WebKit2/Shared/VisibleContentRectUpdateInfo.h136
-rw-r--r--Source/WebKit2/Shared/VisitedLinkTable.cpp10
-rw-r--r--Source/WebKit2/Shared/VisitedLinkTable.h1
-rw-r--r--Source/WebKit2/Shared/WebBackForwardListItem.cpp100
-rw-r--r--Source/WebKit2/Shared/WebBackForwardListItem.h58
-rw-r--r--Source/WebKit2/Shared/WebCertificateInfo.h6
-rw-r--r--Source/WebKit2/Shared/WebCompiledContentExtension.cpp89
-rw-r--r--Source/WebKit2/Shared/WebCompiledContentExtension.h63
-rw-r--r--Source/WebKit2/Shared/WebCompiledContentExtensionData.cpp80
-rw-r--r--Source/WebKit2/Shared/WebCompiledContentExtensionData.h80
-rw-r--r--Source/WebKit2/Shared/WebConnection.cpp24
-rw-r--r--Source/WebKit2/Shared/WebConnection.h12
-rw-r--r--Source/WebKit2/Shared/WebConnection.messages.in4
-rw-r--r--Source/WebKit2/Shared/WebContextMenuItem.cpp7
-rw-r--r--Source/WebKit2/Shared/WebContextMenuItem.h13
-rw-r--r--Source/WebKit2/Shared/WebContextMenuItemData.cpp17
-rw-r--r--Source/WebKit2/Shared/WebContextMenuItemData.h17
-rw-r--r--Source/WebKit2/Shared/WebCoreArgumentCoders.cpp1789
-rw-r--r--Source/WebKit2/Shared/WebCoreArgumentCoders.h582
-rw-r--r--Source/WebKit2/Shared/WebEvent.cpp23
-rw-r--r--Source/WebKit2/Shared/WebEvent.h171
-rw-r--r--Source/WebKit2/Shared/WebEventConversion.cpp150
-rw-r--r--Source/WebKit2/Shared/WebEventConversion.h18
-rw-r--r--Source/WebKit2/Shared/WebFindOptions.h3
-rw-r--r--Source/WebKit2/Shared/WebGeolocationPosition.cpp5
-rw-r--r--Source/WebKit2/Shared/WebGeolocationPosition.h11
-rw-r--r--Source/WebKit2/Shared/WebHitTestResult.cpp108
-rw-r--r--Source/WebKit2/Shared/WebHitTestResult.h93
-rw-r--r--Source/WebKit2/Shared/WebHitTestResultData.cpp209
-rw-r--r--Source/WebKit2/Shared/WebHitTestResultData.h93
-rw-r--r--Source/WebKit2/Shared/WebImage.cpp24
-rw-r--r--Source/WebKit2/Shared/WebImage.h20
-rw-r--r--Source/WebKit2/Shared/WebKeyboardEvent.cpp110
-rw-r--r--Source/WebKit2/Shared/WebKit2Initialize.cpp15
-rw-r--r--Source/WebKit2/Shared/WebKit2Initialize.h5
-rw-r--r--Source/WebKit2/Shared/WebMediaSessionMetadata.cpp (renamed from Source/WebKit2/Shared/Downloads/gtk/DownloadSoupErrorsGtk.cpp)21
-rw-r--r--Source/WebKit2/Shared/WebMediaSessionMetadata.h (renamed from Source/WebKit2/Shared/WebOpenPanelParameters.h)40
-rw-r--r--Source/WebKit2/Shared/WebMemorySampler.cpp190
-rw-r--r--Source/WebKit2/Shared/WebMemorySampler.h12
-rw-r--r--Source/WebKit2/Shared/WebMouseEvent.cpp40
-rw-r--r--Source/WebKit2/Shared/WebNavigationDataStore.h8
-rw-r--r--Source/WebKit2/Shared/WebOpenPanelParameters.cpp69
-rw-r--r--Source/WebKit2/Shared/WebPageCreationParameters.cpp103
-rw-r--r--Source/WebKit2/Shared/WebPageCreationParameters.h65
-rw-r--r--Source/WebKit2/Shared/WebPageGroupData.cpp15
-rw-r--r--Source/WebKit2/Shared/WebPageGroupData.h16
-rw-r--r--Source/WebKit2/Shared/WebPlatformTouchPoint.cpp9
-rw-r--r--Source/WebKit2/Shared/WebPopupItem.cpp5
-rw-r--r--Source/WebKit2/Shared/WebPopupItem.h10
-rw-r--r--Source/WebKit2/Shared/WebPreferencesDefinitions.h384
-rw-r--r--Source/WebKit2/Shared/WebPreferencesKeys.cpp48
-rw-r--r--Source/WebKit2/Shared/WebPreferencesKeys.h (renamed from Source/WebKit2/Shared/OriginAndDatabases.h)36
-rw-r--r--Source/WebKit2/Shared/WebPreferencesStore.cpp250
-rw-r--r--Source/WebKit2/Shared/WebPreferencesStore.h362
-rw-r--r--Source/WebKit2/Shared/WebProcessCreationParameters.cpp245
-rw-r--r--Source/WebKit2/Shared/WebProcessCreationParameters.h152
-rw-r--r--Source/WebKit2/Shared/WebRenderLayer.cpp34
-rw-r--r--Source/WebKit2/Shared/WebRenderLayer.h9
-rw-r--r--Source/WebKit2/Shared/WebRenderObject.cpp86
-rw-r--r--Source/WebKit2/Shared/WebRenderObject.h17
-rw-r--r--Source/WebKit2/Shared/WebSQLiteDatabaseTracker.cpp82
-rw-r--r--Source/WebKit2/Shared/WebSQLiteDatabaseTracker.h (renamed from Source/WebKit2/Shared/WebResourceBuffer.h)41
-rw-r--r--Source/WebKit2/Shared/WebSecurityOrigin.h83
-rw-r--r--Source/WebKit2/Shared/WebTouchEvent.cpp13
-rw-r--r--Source/WebKit2/Shared/WebUserContentControllerDataTypes.cpp89
-rw-r--r--Source/WebKit2/Shared/WebUserContentControllerDataTypes.h68
-rw-r--r--Source/WebKit2/Shared/WebWheelEvent.cpp13
-rw-r--r--Source/WebKit2/Shared/WebsiteData/WebsiteData.cpp (renamed from Source/WebKit2/Shared/WebBatteryStatus.cpp)59
-rw-r--r--Source/WebKit2/Shared/WebsiteData/WebsiteData.h63
-rw-r--r--Source/WebKit2/Shared/WebsiteData/WebsiteDataFetchOption.h (renamed from Source/WebKit2/Shared/Plugins/PluginModuleInfo.cpp)12
-rw-r--r--Source/WebKit2/Shared/WebsiteData/WebsiteDataType.h54
-rw-r--r--Source/WebKit2/Shared/WebsitePolicies.h61
-rw-r--r--Source/WebKit2/Shared/cairo/ShareableBitmapCairo.cpp16
-rw-r--r--Source/WebKit2/Shared/gtk/ArgumentCodersGtk.cpp145
-rw-r--r--Source/WebKit2/Shared/gtk/ArgumentCodersGtk.h23
-rw-r--r--Source/WebKit2/Shared/gtk/NativeWebKeyboardEventGtk.cpp8
-rw-r--r--Source/WebKit2/Shared/gtk/NativeWebTouchEventGtk.cpp12
-rw-r--r--Source/WebKit2/Shared/gtk/ProcessExecutablePathGtk.cpp22
-rw-r--r--Source/WebKit2/Shared/gtk/WebContextMenuItemGtk.cpp181
-rw-r--r--Source/WebKit2/Shared/gtk/WebContextMenuItemGtk.h (renamed from Source/WebKit2/Shared/WebBatteryStatus.h)61
-rw-r--r--Source/WebKit2/Shared/gtk/WebEventFactory.cpp104
-rw-r--r--Source/WebKit2/Shared/gtk/WebEventFactory.h7
-rw-r--r--Source/WebKit2/Shared/gtk/WebKit2WaylandProtocol.xml37
-rw-r--r--Source/WebKit2/Shared/gtk/WebSelectionData.cpp54
-rw-r--r--Source/WebKit2/Shared/gtk/WebSelectionData.h42
-rw-r--r--Source/WebKit2/Shared/linux/WebMemorySamplerLinux.cpp163
-rw-r--r--Source/WebKit2/Shared/soup/WebCoreArgumentCodersSoup.cpp150
-rw-r--r--Source/WebKit2/Shared/unix/ChildProcessMain.cpp (renamed from Source/WebKit2/Shared/APIFrameHandle.cpp)24
-rw-r--r--Source/WebKit2/Shared/unix/ChildProcessMain.h69
312 files changed, 15279 insertions, 7090 deletions
diff --git a/Source/WebKit2/Shared/APIArray.cpp b/Source/WebKit2/Shared/API/APIArray.cpp
index 9b7f63896..9548ab724 100644
--- a/Source/WebKit2/Shared/APIArray.cpp
+++ b/Source/WebKit2/Shared/API/APIArray.cpp
@@ -30,17 +30,17 @@
namespace API {
-PassRefPtr<Array> Array::create()
+Ref<Array> Array::create()
{
return create(Vector<RefPtr<Object>>());
}
-PassRefPtr<Array> Array::create(Vector<RefPtr<Object>> elements)
+Ref<Array> Array::create(Vector<RefPtr<Object>>&& elements)
{
- return adoptRef(new Array(std::move(elements)));
+ return adoptRef(*new Array(WTFMove(elements)));
}
-PassRefPtr<Array> Array::createStringArray(const Vector<WTF::String>& strings)
+Ref<Array> Array::createStringArray(const Vector<WTF::String>& strings)
{
Vector<RefPtr<Object>> elements;
elements.reserveInitialCapacity(strings.size());
@@ -48,7 +48,7 @@ PassRefPtr<Array> Array::createStringArray(const Vector<WTF::String>& strings)
for (const auto& string : strings)
elements.uncheckedAppend(API::String::create(string));
- return create(std::move(elements));
+ return create(WTFMove(elements));
}
Vector<WTF::String> Array::toStringVector()
@@ -65,9 +65,17 @@ Vector<WTF::String> Array::toStringVector()
return patternsVector;
}
-Array::Array(Vector<RefPtr<Object>> elements)
- : m_elements(std::move(elements))
+Ref<API::Array> Array::copy()
{
+ size_t size = this->size();
+ if (!size)
+ return Array::create();
+
+ Vector<RefPtr<Object>> elements;
+ elements.reserveInitialCapacity(size);
+ for (const auto& entry : this->elements())
+ elements.uncheckedAppend(entry);
+ return Array::create(WTFMove(elements));
}
Array::~Array()
diff --git a/Source/WebKit2/Shared/APIArray.h b/Source/WebKit2/Shared/API/APIArray.h
index addbae9c0..1fef06932 100644
--- a/Source/WebKit2/Shared/APIArray.h
+++ b/Source/WebKit2/Shared/API/APIArray.h
@@ -30,7 +30,6 @@
#include <wtf/Forward.h>
#include <wtf/IteratorAdaptors.h>
#include <wtf/IteratorRange.h>
-#include <wtf/PassRefPtr.h>
#include <wtf/Vector.h>
namespace API {
@@ -51,17 +50,18 @@ private:
using ElementsOfTypeRange = WTF::IteratorRange<WTF::TransformIterator<GetObjectTransform<T>, WTF::FilterIterator<IsTypePredicate<T>, Vector<RefPtr<Object>>::const_iterator>>>;
public:
- static PassRefPtr<Array> create();
- static PassRefPtr<Array> create(Vector<RefPtr<Object>> elements);
- static PassRefPtr<Array> createStringArray(const Vector<WTF::String>&);
+ static Ref<Array> create();
+ static Ref<Array> create(Vector<RefPtr<Object>>&&);
+ static Ref<Array> createStringArray(const Vector<WTF::String>&);
Vector<WTF::String> toStringVector();
+ Ref<Array> copy();
virtual ~Array();
template<typename T>
T* at(size_t i) const
{
- if (m_elements[i]->type() != T::APIType)
+ if (!m_elements[i] || m_elements[i]->type() != T::APIType)
return nullptr;
return static_cast<T*>(m_elements[i].get());
@@ -82,8 +82,27 @@ public:
);
}
+ template<typename MatchFunction>
+ unsigned removeAllMatching(const MatchFunction& matchFunction)
+ {
+ return m_elements.removeAllMatching(matchFunction);
+ }
+
+ template<typename T, typename MatchFunction>
+ unsigned removeAllOfTypeMatching(const MatchFunction& matchFunction)
+ {
+ return m_elements.removeAllMatching([&] (const RefPtr<Object>& object) -> bool {
+ if (object->type() != T::APIType)
+ return false;
+ return matchFunction(static_pointer_cast<T>(object));
+ });
+ }
+
private:
- explicit Array(Vector<RefPtr<Object>> elements);
+ explicit Array(Vector<RefPtr<Object>>&& elements)
+ : m_elements(WTFMove(elements))
+ {
+ }
Vector<RefPtr<Object>> m_elements;
};
diff --git a/Source/WebKit2/Shared/APIClient.h b/Source/WebKit2/Shared/API/APIClient.h
index 2d2d89a5c..2d2d89a5c 100644
--- a/Source/WebKit2/Shared/APIClient.h
+++ b/Source/WebKit2/Shared/API/APIClient.h
diff --git a/Source/WebKit2/Shared/APIData.cpp b/Source/WebKit2/Shared/API/APIData.cpp
index 57bf8c741..61343bd94 100644
--- a/Source/WebKit2/Shared/APIData.cpp
+++ b/Source/WebKit2/Shared/API/APIData.cpp
@@ -26,17 +26,17 @@
#include "config.h"
#include "APIData.h"
-#include "ArgumentDecoder.h"
-#include "ArgumentEncoder.h"
+#include "Decoder.h"
+#include "Encoder.h"
namespace API {
-void Data::encode(IPC::ArgumentEncoder& encoder) const
+void Data::encode(IPC::Encoder& encoder) const
{
encoder << dataReference();
}
-bool Data::decode(IPC::ArgumentDecoder& decoder, RefPtr<API::Object>& result)
+bool Data::decode(IPC::Decoder& decoder, RefPtr<API::Object>& result)
{
IPC::DataReference dataReference;
if (!decoder.decode(dataReference))
diff --git a/Source/WebKit2/Shared/APIData.h b/Source/WebKit2/Shared/API/APIData.h
index bb0216bdd..066fa441f 100644
--- a/Source/WebKit2/Shared/APIData.h
+++ b/Source/WebKit2/Shared/API/APIData.h
@@ -32,22 +32,24 @@
#include <wtf/Vector.h>
namespace IPC {
-class ArgumentDecoder;
-class ArgumentEncoder;
+class Decoder;
+class Encoder;
}
+OBJC_CLASS NSData;
+
namespace API {
class Data : public ObjectImpl<API::Object::Type::Data> {
public:
typedef void (*FreeDataFunction)(unsigned char*, const void* context);
- static PassRefPtr<Data> createWithoutCopying(const unsigned char* bytes, size_t size, FreeDataFunction freeDataFunction, const void* context)
+ static Ref<Data> createWithoutCopying(const unsigned char* bytes, size_t size, FreeDataFunction freeDataFunction, const void* context)
{
- return adoptRef(new Data(bytes, size, freeDataFunction, context));
+ return adoptRef(*new Data(bytes, size, freeDataFunction, context));
}
- static PassRefPtr<Data> create(const unsigned char* bytes, size_t size)
+ static Ref<Data> create(const unsigned char* bytes, size_t size)
{
unsigned char *copiedBytes = 0;
@@ -59,11 +61,15 @@ public:
return createWithoutCopying(copiedBytes, size, fastFreeBytes, 0);
}
- static PassRefPtr<Data> create(const Vector<unsigned char>& buffer)
+ static Ref<Data> create(const Vector<unsigned char>& buffer)
{
return create(buffer.data(), buffer.size());
}
+#if PLATFORM(COCOA)
+ static Ref<Data> createWithoutCopying(RetainPtr<NSData>);
+#endif
+
~Data()
{
m_freeDataFunction(const_cast<unsigned char*>(m_bytes), m_context);
@@ -74,8 +80,8 @@ public:
IPC::DataReference dataReference() const { return IPC::DataReference(m_bytes, m_size); }
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, RefPtr<API::Object>&);
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, RefPtr<API::Object>&);
private:
Data(const unsigned char* bytes, size_t size, FreeDataFunction freeDataFunction, const void* context)
diff --git a/Source/WebKit2/Shared/ImmutableDictionary.cpp b/Source/WebKit2/Shared/API/APIDictionary.cpp
index cac14035d..894e98dd1 100644
--- a/Source/WebKit2/Shared/ImmutableDictionary.cpp
+++ b/Source/WebKit2/Shared/API/APIDictionary.cpp
@@ -24,33 +24,33 @@
*/
#include "config.h"
-#include "ImmutableDictionary.h"
+#include "APIDictionary.h"
#include "APIArray.h"
#include "APIString.h"
-namespace WebKit {
+namespace API {
-RefPtr<ImmutableDictionary> ImmutableDictionary::create()
+Ref<Dictionary> Dictionary::create()
{
return create({ });
}
-RefPtr<ImmutableDictionary> ImmutableDictionary::create(MapType map)
+Ref<Dictionary> Dictionary::create(MapType map)
{
- return adoptRef(new ImmutableDictionary(std::move(map)));
+ return adoptRef(*new Dictionary(WTFMove(map)));
}
-ImmutableDictionary::ImmutableDictionary(MapType map)
- : m_map(std::move(map))
+Dictionary::Dictionary(MapType map)
+ : m_map(WTFMove(map))
{
}
-ImmutableDictionary::~ImmutableDictionary()
+Dictionary::~Dictionary()
{
}
-PassRefPtr<API::Array> ImmutableDictionary::keys() const
+Ref<Array> Dictionary::keys() const
{
if (m_map.isEmpty())
return API::Array::create();
@@ -61,7 +61,24 @@ PassRefPtr<API::Array> ImmutableDictionary::keys() const
for (const auto& key : m_map.keys())
keys.uncheckedAppend(API::String::create(key));
- return API::Array::create(std::move(keys));
+ return API::Array::create(WTFMove(keys));
}
-} // namespace WebKit
+bool Dictionary::add(const WTF::String& key, PassRefPtr<API::Object> item)
+{
+ MapType::AddResult result = m_map.add(key, item);
+ return result.isNewEntry;
+}
+
+bool Dictionary::set(const WTF::String& key, PassRefPtr<API::Object> item)
+{
+ MapType::AddResult result = m_map.set(key, item);
+ return result.isNewEntry;
+}
+
+void Dictionary::remove(const WTF::String& key)
+{
+ m_map.remove(key);
+}
+
+} // namespace API
diff --git a/Source/WebKit2/Shared/ImmutableDictionary.h b/Source/WebKit2/Shared/API/APIDictionary.h
index b04046842..50599129a 100644
--- a/Source/WebKit2/Shared/ImmutableDictionary.h
+++ b/Source/WebKit2/Shared/API/APIDictionary.h
@@ -23,38 +23,31 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef ImmutableDictionary_h
-#define ImmutableDictionary_h
+#ifndef APIDictionary_h
+#define APIDictionary_h
#include "APIObject.h"
#include <wtf/HashMap.h>
-#include <wtf/PassRefPtr.h>
#include <wtf/text/StringHash.h>
#include <wtf/text/WTFString.h>
namespace API {
-class Array;
-}
-
-namespace WebKit {
-// ImmutableDictionary - An immutable dictionary type suitable for vending to an API.
+class Array;
-class ImmutableDictionary : public API::ObjectImpl<API::Object::Type::Dictionary> {
+class Dictionary final : public ObjectImpl<Object::Type::Dictionary> {
public:
- typedef HashMap<String, RefPtr<API::Object>> MapType;
+ typedef HashMap<WTF::String, RefPtr<Object>> MapType;
- static RefPtr<ImmutableDictionary> create();
- static RefPtr<ImmutableDictionary> create(MapType);
+ static Ref<Dictionary> create();
+ static Ref<Dictionary> create(MapType);
- virtual ~ImmutableDictionary();
-
- virtual bool isMutable() { return false; }
+ virtual ~Dictionary();
template<typename T>
- T* get(const String& key) const
+ T* get(const WTF::String& key) const
{
- RefPtr<API::Object> item = m_map.get(key);
+ RefPtr<Object> item = m_map.get(key);
if (!item)
return 0;
@@ -64,30 +57,34 @@ public:
return static_cast<T*>(item.get());
}
- API::Object* get(const String& key) const
+ Object* get(const WTF::String& key) const
{
return m_map.get(key);
}
- API::Object* get(const String& key, bool& exists) const
+ Object* get(const WTF::String& key, bool& exists) const
{
auto it = m_map.find(key);
exists = it != m_map.end();
return it->value.get();
}
- PassRefPtr<API::Array> keys() const;
+ Ref<Array> keys() const;
+
+ bool add(const WTF::String& key, PassRefPtr<Object>);
+ bool set(const WTF::String& key, PassRefPtr<Object>);
+ void remove(const WTF::String& key);
size_t size() const { return m_map.size(); }
const MapType& map() const { return m_map; }
protected:
- explicit ImmutableDictionary(MapType);
+ explicit Dictionary(MapType);
MapType m_map;
};
-} // namespace WebKit
+} // namespace API
-#endif // ImmutableDictionary_h
+#endif // APIDictionary_h
diff --git a/Source/WebKit2/Shared/APIError.cpp b/Source/WebKit2/Shared/API/APIError.cpp
index 86a1db0b0..839fb0f14 100644
--- a/Source/WebKit2/Shared/APIError.cpp
+++ b/Source/WebKit2/Shared/API/APIError.cpp
@@ -38,12 +38,12 @@ const WTF::String& Error::webKitErrorDomain()
return webKitErrorDomainString;
}
-void Error::encode(IPC::ArgumentEncoder& encoder) const
+void Error::encode(IPC::Encoder& encoder) const
{
encoder << platformError();
}
-bool Error::decode(IPC::ArgumentDecoder& decoder, RefPtr<Object>& result)
+bool Error::decode(IPC::Decoder& decoder, RefPtr<Object>& result)
{
WebCore::ResourceError error;
if (!decoder.decode(error))
diff --git a/Source/WebKit2/Shared/APIError.h b/Source/WebKit2/Shared/API/APIError.h
index 8cb1cf419..8c36027df 100644
--- a/Source/WebKit2/Shared/APIError.h
+++ b/Source/WebKit2/Shared/API/APIError.h
@@ -28,25 +28,24 @@
#include "APIObject.h"
#include <WebCore/ResourceError.h>
-#include <wtf/PassRefPtr.h>
namespace IPC {
-class ArgumentDecoder;
-class ArgumentEncoder;
+class Decoder;
+class Encoder;
}
namespace API {
class Error : public ObjectImpl<Object::Type::Error> {
public:
- static PassRefPtr<Error> create()
+ static Ref<Error> create()
{
- return adoptRef(new Error);
+ return adoptRef(*new Error);
}
- static PassRefPtr<Error> create(const WebCore::ResourceError& error)
+ static Ref<Error> create(const WebCore::ResourceError& error)
{
- return adoptRef(new Error(error));
+ return adoptRef(*new Error(error));
}
static const WTF::String& webKitErrorDomain();
@@ -58,8 +57,8 @@ public:
const WebCore::ResourceError& platformError() const { return m_platformError; }
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, RefPtr<Object>&);
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, RefPtr<Object>&);
private:
Error()
diff --git a/Source/WebKit2/Shared/API/APIFrameHandle.cpp b/Source/WebKit2/Shared/API/APIFrameHandle.cpp
new file mode 100644
index 000000000..79646ac6e
--- /dev/null
+++ b/Source/WebKit2/Shared/API/APIFrameHandle.cpp
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2013 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.
+ */
+
+#include "config.h"
+#include "APIFrameHandle.h"
+
+#include "Decoder.h"
+#include "Encoder.h"
+
+namespace API {
+
+Ref<FrameHandle> FrameHandle::create(uint64_t frameID)
+{
+ return adoptRef(*new FrameHandle(frameID, false));
+}
+
+Ref<FrameHandle> FrameHandle::createAutoconverting(uint64_t frameID)
+{
+ return adoptRef(*new FrameHandle(frameID, true));
+}
+
+FrameHandle::FrameHandle(uint64_t frameID, bool isAutoconverting)
+ : m_frameID(frameID)
+ , m_isAutoconverting(isAutoconverting)
+{
+}
+
+FrameHandle::~FrameHandle()
+{
+}
+
+void FrameHandle::encode(IPC::Encoder& encoder) const
+{
+ encoder << m_frameID;
+ encoder << m_isAutoconverting;
+}
+
+bool FrameHandle::decode(IPC::Decoder& decoder, RefPtr<Object>& result)
+{
+ uint64_t frameID;
+ if (!decoder.decode(frameID))
+ return false;
+
+ bool isAutoconverting;
+ if (!decoder.decode(isAutoconverting))
+ return false;
+
+ result = isAutoconverting ? createAutoconverting(frameID) : create(frameID);
+ return true;
+}
+
+} // namespace API
diff --git a/Source/WebKit2/Shared/APIFrameHandle.h b/Source/WebKit2/Shared/API/APIFrameHandle.h
index e69136649..b10e808a4 100644
--- a/Source/WebKit2/Shared/APIFrameHandle.h
+++ b/Source/WebKit2/Shared/API/APIFrameHandle.h
@@ -27,21 +27,32 @@
#define APIFrameHandle_h
#include "APIObject.h"
-#include <wtf/RefPtr.h>
+#include <wtf/Ref.h>
+
+namespace IPC {
+class Decoder;
+class Encoder;
+}
namespace API {
class FrameHandle : public ObjectImpl<Object::Type::FrameHandle> {
public:
- static RefPtr<FrameHandle> create(uint64_t frameID);
+ static Ref<FrameHandle> create(uint64_t frameID);
+ static Ref<FrameHandle> createAutoconverting(uint64_t frameID);
+
+ explicit FrameHandle(uint64_t frameID, bool isAutoconverting);
virtual ~FrameHandle();
uint64_t frameID() const { return m_frameID; }
+ bool isAutoconverting() const { return m_isAutoconverting; }
-private:
- explicit FrameHandle(uint64_t frameID);
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, RefPtr<Object>&);
- uint64_t m_frameID;
+private:
+ const uint64_t m_frameID;
+ const bool m_isAutoconverting;
};
} // namespace API
diff --git a/Source/WebKit2/Shared/APIGeometry.cpp b/Source/WebKit2/Shared/API/APIGeometry.cpp
index c59827b18..3d8cb61a3 100644
--- a/Source/WebKit2/Shared/APIGeometry.cpp
+++ b/Source/WebKit2/Shared/API/APIGeometry.cpp
@@ -26,18 +26,18 @@
#include "config.h"
#include "APIGeometry.h"
-#include "ArgumentDecoder.h"
-#include "ArgumentEncoder.h"
+#include "Decoder.h"
+#include "Encoder.h"
namespace API {
-void Point::encode(IPC::ArgumentEncoder& encoder) const
+void Point::encode(IPC::Encoder& encoder) const
{
encoder << m_point.x;
encoder << m_point.y;
}
-bool Point::decode(IPC::ArgumentDecoder& decoder, RefPtr<API::Object>& result)
+bool Point::decode(IPC::Decoder& decoder, RefPtr<API::Object>& result)
{
WKPoint point;
if (!decoder.decode(point.x))
@@ -50,13 +50,13 @@ bool Point::decode(IPC::ArgumentDecoder& decoder, RefPtr<API::Object>& result)
}
-void Size::encode(IPC::ArgumentEncoder& encoder) const
+void Size::encode(IPC::Encoder& encoder) const
{
encoder << m_size.width;
encoder << m_size.height;
}
-bool Size::decode(IPC::ArgumentDecoder& decoder, RefPtr<API::Object>& result)
+bool Size::decode(IPC::Decoder& decoder, RefPtr<API::Object>& result)
{
WKSize size;
if (!decoder.decode(size.width))
@@ -69,7 +69,7 @@ bool Size::decode(IPC::ArgumentDecoder& decoder, RefPtr<API::Object>& result)
}
-void Rect::encode(IPC::ArgumentEncoder& encoder) const
+void Rect::encode(IPC::Encoder& encoder) const
{
encoder << m_rect.origin.x;
encoder << m_rect.origin.y;
@@ -77,7 +77,7 @@ void Rect::encode(IPC::ArgumentEncoder& encoder) const
encoder << m_rect.size.height;
}
-bool Rect::decode(IPC::ArgumentDecoder& decoder, RefPtr<API::Object>& result)
+bool Rect::decode(IPC::Decoder& decoder, RefPtr<API::Object>& result)
{
WKRect rect;
if (!decoder.decode(rect.origin.x))
diff --git a/Source/WebKit2/Shared/APIGeometry.h b/Source/WebKit2/Shared/API/APIGeometry.h
index 2efcb47c1..0ff94cca9 100644
--- a/Source/WebKit2/Shared/APIGeometry.h
+++ b/Source/WebKit2/Shared/API/APIGeometry.h
@@ -29,26 +29,25 @@
#include "APIObject.h"
#include "WKGeometry.h"
#include <WebCore/FloatRect.h>
-#include <wtf/PassRefPtr.h>
namespace IPC {
-class ArgumentDecoder;
-class ArgumentEncoder;
+class Decoder;
+class Encoder;
}
namespace API {
class Size : public API::ObjectImpl<API::Object::Type::Size> {
public:
- static PassRefPtr<Size> create(const WKSize& size)
+ static Ref<Size> create(const WKSize& size)
{
- return adoptRef(new Size(size));
+ return adoptRef(*new Size(size));
}
const WKSize& size() const { return m_size; }
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, RefPtr<API::Object>&);
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, RefPtr<API::Object>&);
private:
explicit Size(const WKSize& size)
@@ -61,15 +60,15 @@ private:
class Point : public API::ObjectImpl<API::Object::Type::Point> {
public:
- static PassRefPtr<Point> create(const WKPoint& point)
+ static Ref<Point> create(const WKPoint& point)
{
- return adoptRef(new Point(point));
+ return adoptRef(*new Point(point));
}
const WKPoint& point() const { return m_point; }
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, RefPtr<API::Object>&);
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, RefPtr<API::Object>&);
private:
explicit Point(const WKPoint& point)
@@ -81,15 +80,15 @@ private:
class Rect : public API::ObjectImpl<API::Object::Type::Rect> {
public:
- static PassRefPtr<Rect> create(const WKRect& rect)
+ static Ref<Rect> create(const WKRect& rect)
{
- return adoptRef(new Rect(rect));
+ return adoptRef(*new Rect(rect));
}
const WKRect& rect() const { return m_rect; }
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, RefPtr<API::Object>&);
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, RefPtr<API::Object>&);
private:
explicit Rect(const WKRect& rect)
diff --git a/Source/WebKit2/Shared/APINumber.h b/Source/WebKit2/Shared/API/APINumber.h
index 02a4da97f..fe5734981 100644
--- a/Source/WebKit2/Shared/APINumber.h
+++ b/Source/WebKit2/Shared/API/APINumber.h
@@ -27,28 +27,27 @@
#define APINumber_h
#include "APIObject.h"
-#include "ArgumentDecoder.h"
-#include "ArgumentEncoder.h"
-#include <wtf/PassRefPtr.h>
+#include "Decoder.h"
+#include "Encoder.h"
namespace API {
template<typename NumberType, API::Object::Type APIObjectType>
class Number : public ObjectImpl<APIObjectType> {
public:
- static PassRefPtr<Number> create(NumberType value)
+ static Ref<Number> create(NumberType value)
{
- return adoptRef(new Number(value));
+ return adoptRef(*new Number(value));
}
NumberType value() const { return m_value; }
- void encode(IPC::ArgumentEncoder& encoder) const
+ void encode(IPC::Encoder& encoder) const
{
encoder << m_value;
}
- static bool decode(IPC::ArgumentDecoder& decoder, RefPtr<Object>& result)
+ static bool decode(IPC::Decoder& decoder, RefPtr<Object>& result)
{
NumberType value;
if (!decoder.decode(value))
diff --git a/Source/WebKit2/Shared/APIObject.cpp b/Source/WebKit2/Shared/API/APIObject.cpp
index 26e38f008..26e38f008 100644
--- a/Source/WebKit2/Shared/APIObject.cpp
+++ b/Source/WebKit2/Shared/API/APIObject.cpp
diff --git a/Source/WebKit2/Shared/APIObject.h b/Source/WebKit2/Shared/API/APIObject.h
index 38155d1e6..f2cb0540a 100644
--- a/Source/WebKit2/Shared/APIObject.h
+++ b/Source/WebKit2/Shared/API/APIObject.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-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
@@ -31,14 +31,14 @@
#include <wtf/RefPtr.h>
#include <wtf/ThreadSafeRefCounted.h>
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
#include "WKFoundation.h"
#ifdef __OBJC__
#include "WKObject.h"
#endif
#endif
-#define DELEGATE_REF_COUNTING_TO_COCOA (PLATFORM(MAC) && WK_API_ENABLED)
+#define DELEGATE_REF_COUNTING_TO_COCOA (PLATFORM(COCOA) && WK_API_ENABLED)
#if DELEGATE_REF_COUNTING_TO_COCOA
OBJC_CLASS NSObject;
@@ -69,16 +69,20 @@ public:
Image,
PageGroupData,
PageHandle,
+ PageGroupHandle,
ProtectionSpace,
RenderLayer,
RenderObject,
SecurityOrigin,
+ SessionState,
SerializedScriptValue,
String,
URL,
URLRequest,
URLResponse,
UserContentURLPattern,
+ UserScript,
+ UserStyleSheet,
WebArchive,
WebArchiveResource,
@@ -94,18 +98,18 @@ public:
// UIProcess types
ApplicationCacheManager,
+ AutomationSession,
BackForwardList,
BackForwardListItem,
- BatteryManager,
- BatteryStatus,
CacheManager,
ColorPickerResultListener,
- Context,
+ ContextMenuListener,
CookieManager,
- DatabaseManager,
Download,
+ ExperimentalFeature,
FormSubmissionListener,
Frame,
+ FrameInfo,
FramePolicyListener,
FullScreenManager,
GeolocationManager,
@@ -117,9 +121,10 @@ public:
Inspector,
KeyValueStorageManager,
MediaCacheManager,
+ Navigation,
+ NavigationAction,
NavigationData,
- NetworkInfo,
- NetworkInfoManager,
+ NavigationResponse,
Notification,
NotificationManager,
NotificationPermissionRequest,
@@ -127,19 +132,46 @@ public:
OpenPanelResultListener,
OriginDataManager,
Page,
+ PageConfiguration,
PageGroup,
+ ProcessPool,
+ ProcessPoolConfiguration,
PluginSiteDataManager,
Preferences,
- Session,
+ ResourceLoadStatisticsStore,
+ RunBeforeUnloadConfirmPanelResultListener,
+ RunJavaScriptAlertResultListener,
+ RunJavaScriptConfirmResultListener,
+ RunJavaScriptPromptResultListener,
TextChecker,
+ UserContentController,
+ UserContentExtension,
+ UserContentExtensionStore,
+ UserContentWorld,
+ UserInitiatedAction,
+ UserMediaPermissionCheck,
+ UserMediaPermissionRequest,
Vibration,
ViewportAttributes,
+ VisitedLinkStore,
+ WebResourceLoadStatisticsManager,
+ WebsiteDataRecord,
+ WebsiteDataStore,
+ WebsitePolicies,
+ WindowFeatures,
+
+#if ENABLE(MEDIA_SESSION)
+ MediaSessionFocusManager,
+ MediaSessionMetadata,
+#endif
// Bundle types
Bundle,
BundleBackForwardList,
BundleBackForwardListItem,
+ BundleCSSStyleDeclarationHandle,
BundleDOMWindowExtension,
+ BundleFileHandle,
BundleFrame,
BundleHitTestResult,
BundleInspector,
@@ -160,13 +192,6 @@ public:
SoupRequestManager,
SoupCustomProtocolRequestManager,
#endif
-#if PLATFORM(EFL)
- PopupMenuItem,
-#if ENABLE(TOUCH_EVENTS)
- TouchPoint,
- TouchEvent,
-#endif
-#endif
};
virtual ~Object()
@@ -191,6 +216,9 @@ public:
void deref();
#endif // DELEGATE_REF_COUNTING_TO_COCOA
+ static void* wrap(API::Object*);
+ static API::Object* unwrap(void*);
+
protected:
Object();
@@ -221,14 +249,26 @@ protected:
{
}
- virtual Type type() const override { return APIType; }
+ Type type() const override { return APIType; }
#if DELEGATE_REF_COUNTING_TO_COCOA
void* operator new(size_t size) { return newObject(size, APIType); }
- void* operator new(size_t size, void* value) { return value; }
+ void* operator new(size_t, void* value) { return value; }
#endif
};
+#if !DELEGATE_REF_COUNTING_TO_COCOA
+inline void* Object::wrap(API::Object* object)
+{
+ return static_cast<void*>(object);
+}
+
+inline API::Object* Object::unwrap(void* object)
+{
+ return static_cast<API::Object*>(object);
+}
+#endif
+
} // namespace Object
#undef DELEGATE_REF_COUNTING_TO_COCOA
diff --git a/Source/WebKit2/Shared/API/APIPageGroupHandle.cpp b/Source/WebKit2/Shared/API/APIPageGroupHandle.cpp
new file mode 100644
index 000000000..c8fd224ee
--- /dev/null
+++ b/Source/WebKit2/Shared/API/APIPageGroupHandle.cpp
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+#include "config.h"
+#include "APIPageGroupHandle.h"
+
+#include "Decoder.h"
+#include "Encoder.h"
+
+namespace API {
+
+Ref<PageGroupHandle> PageGroupHandle::create(WebKit::WebPageGroupData&& webPageGroupData)
+{
+ return adoptRef(*new PageGroupHandle(WTFMove(webPageGroupData)));
+}
+
+PageGroupHandle::PageGroupHandle(WebKit::WebPageGroupData&& webPageGroupData)
+ : m_webPageGroupData(WTFMove(webPageGroupData))
+{
+}
+
+PageGroupHandle::~PageGroupHandle()
+{
+}
+
+void PageGroupHandle::encode(IPC::Encoder& encoder) const
+{
+ encoder << m_webPageGroupData;
+}
+
+bool PageGroupHandle::decode(IPC::Decoder& decoder, RefPtr<Object>& result)
+{
+ WebKit::WebPageGroupData webPageGroupData;
+ if (!decoder.decode(webPageGroupData))
+ return false;
+
+ result = create(WTFMove(webPageGroupData));
+ return true;
+}
+
+}
diff --git a/Source/WebKit2/Shared/InteractionInformationAtPosition.h b/Source/WebKit2/Shared/API/APIPageGroupHandle.h
index c2a0be461..eaca5dfbd 100644
--- a/Source/WebKit2/Shared/InteractionInformationAtPosition.h
+++ b/Source/WebKit2/Shared/API/APIPageGroupHandle.h
@@ -23,37 +23,37 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef InteractionInformationAtPosition_h
-#define InteractionInformationAtPosition_h
-
-#include "ArgumentCoders.h"
-#include <WebCore/IntPoint.h>
-#include <wtf/text/WTFString.h>
-
-#if PLATFORM(IOS)
-#include <WebCore/SelectionRect.h>
-#endif
-
-namespace WebKit {
-
-#if PLATFORM(IOS)
-struct InteractionInformationAtPosition {
- InteractionInformationAtPosition()
- : nodeAtPositionIsAssistedNode(false)
- {
- }
-
- WebCore::IntPoint point;
- bool nodeAtPositionIsAssistedNode;
- String clickableElementName;
- String url;
- Vector<WebCore::SelectionRect> selectionRects;
-
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, InteractionInformationAtPosition&);
-};
-#endif
+#ifndef APIPageGroupHandle_h
+#define APIPageGroupHandle_h
+
+#include "APIObject.h"
+#include "WebPageGroupData.h"
+#include <wtf/RefPtr.h>
+namespace IPC {
+class Decoder;
+class Encoder;
}
-#endif // InteractionInformationAtPosition_h
+namespace API {
+
+class PageGroupHandle : public ObjectImpl<Object::Type::PageGroupHandle> {
+public:
+ static Ref<PageGroupHandle> create(WebKit::WebPageGroupData&&);
+ virtual ~PageGroupHandle();
+
+ const WebKit::WebPageGroupData& webPageGroupData() const { return m_webPageGroupData; }
+
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, RefPtr<Object>&);
+
+private:
+ explicit PageGroupHandle(WebKit::WebPageGroupData&&);
+
+ const WebKit::WebPageGroupData m_webPageGroupData;
+};
+
+} // namespace API
+
+
+#endif // APIPageGroupHandle_h
diff --git a/Source/WebKit2/Shared/API/APIPageHandle.cpp b/Source/WebKit2/Shared/API/APIPageHandle.cpp
new file mode 100644
index 000000000..a6a009955
--- /dev/null
+++ b/Source/WebKit2/Shared/API/APIPageHandle.cpp
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2013 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.
+ */
+
+#include "config.h"
+#include "APIPageHandle.h"
+
+#include "Decoder.h"
+#include "Encoder.h"
+
+namespace API {
+
+Ref<PageHandle> PageHandle::create(uint64_t pageID)
+{
+ return adoptRef(*new PageHandle(pageID, false));
+}
+
+Ref<PageHandle> PageHandle::createAutoconverting(uint64_t pageID)
+{
+ return adoptRef(*new PageHandle(pageID, true));
+}
+
+PageHandle::PageHandle(uint64_t pageID, bool isAutoconverting)
+ : m_pageID(pageID)
+ , m_isAutoconverting(isAutoconverting)
+{
+}
+
+PageHandle::~PageHandle()
+{
+}
+
+void PageHandle::encode(IPC::Encoder& encoder) const
+{
+ encoder << m_pageID;
+ encoder << m_isAutoconverting;
+}
+
+bool PageHandle::decode(IPC::Decoder& decoder, RefPtr<Object>& result)
+{
+ uint64_t pageID;
+ if (!decoder.decode(pageID))
+ return false;
+
+ bool isAutoconverting;
+ if (!decoder.decode(isAutoconverting))
+ return false;
+
+ result = isAutoconverting ? createAutoconverting(pageID) : create(pageID);
+ return true;
+}
+
+} // namespace API
diff --git a/Source/WebKit2/Shared/APIPageHandle.h b/Source/WebKit2/Shared/API/APIPageHandle.h
index 4e2df974e..f30fafbdc 100644
--- a/Source/WebKit2/Shared/APIPageHandle.h
+++ b/Source/WebKit2/Shared/API/APIPageHandle.h
@@ -27,21 +27,32 @@
#define APIPageHandle_h
#include "APIObject.h"
-#include <wtf/RefPtr.h>
+#include <wtf/Ref.h>
+
+namespace IPC {
+class Decoder;
+class Encoder;
+}
namespace API {
class PageHandle : public ObjectImpl<Object::Type::PageHandle> {
public:
- static RefPtr<PageHandle> create(uint64_t pageID);
+ static Ref<PageHandle> create(uint64_t pageID);
+ static Ref<PageHandle> createAutoconverting(uint64_t pageID);
virtual ~PageHandle();
uint64_t pageID() const { return m_pageID; }
+ bool isAutoconverting() const { return m_isAutoconverting; }
+
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, RefPtr<Object>&);
private:
- explicit PageHandle(uint64_t pageID);
+ explicit PageHandle(uint64_t pageID, bool isAutoconverting);
- uint64_t m_pageID;
+ const uint64_t m_pageID;
+ const bool m_isAutoconverting;
};
} // namespace API
diff --git a/Source/WebKit2/Shared/API/APISecurityOrigin.h b/Source/WebKit2/Shared/API/APISecurityOrigin.h
new file mode 100644
index 000000000..8917c6704
--- /dev/null
+++ b/Source/WebKit2/Shared/API/APISecurityOrigin.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#pragma once
+
+#include "APIObject.h"
+#include <WebCore/SecurityOrigin.h>
+#include <wtf/PassRefPtr.h>
+
+namespace API {
+
+class SecurityOrigin : public API::ObjectImpl<API::Object::Type::SecurityOrigin> {
+public:
+ static RefPtr<SecurityOrigin> createFromString(const WTF::String& string)
+ {
+ return create(WebCore::SecurityOrigin::createFromString(string));
+ }
+
+ static RefPtr<SecurityOrigin> create(const WTF::String& protocol, const WTF::String& host, std::optional<uint16_t> port)
+ {
+ return create(WebCore::SecurityOrigin::create(protocol, host, port));
+ }
+
+ static RefPtr<SecurityOrigin> create(const WebCore::SecurityOrigin& securityOrigin)
+ {
+ return adoptRef(new SecurityOrigin(securityOrigin));
+ }
+
+ WebCore::SecurityOrigin& securityOrigin() const { return *m_securityOrigin; }
+
+private:
+ SecurityOrigin(PassRefPtr<WebCore::SecurityOrigin> securityOrigin)
+ : m_securityOrigin(securityOrigin)
+ {
+ }
+
+ SecurityOrigin(const WebCore::SecurityOrigin& securityOrigin)
+ : m_securityOrigin(securityOrigin.isolatedCopy())
+ {
+ }
+
+ RefPtr<WebCore::SecurityOrigin> m_securityOrigin;
+};
+
+}
diff --git a/Source/WebKit2/Shared/WebSerializedScriptValue.h b/Source/WebKit2/Shared/API/APISerializedScriptValue.h
index eaedee7e2..6569d4d4c 100644
--- a/Source/WebKit2/Shared/WebSerializedScriptValue.h
+++ b/Source/WebKit2/Shared/API/APISerializedScriptValue.h
@@ -23,8 +23,8 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef WebSerializedScriptValue_h
-#define WebSerializedScriptValue_h
+#ifndef APISerializedScriptValue_h
+#define APISerializedScriptValue_h
#include "APIObject.h"
@@ -32,39 +32,43 @@
#include <WebCore/SerializedScriptValue.h>
#include <wtf/RefPtr.h>
-namespace WebKit {
+namespace API {
-class WebSerializedScriptValue : public API::ObjectImpl<API::Object::Type::SerializedScriptValue> {
+class SerializedScriptValue : public API::ObjectImpl<API::Object::Type::SerializedScriptValue> {
public:
- static PassRefPtr<WebSerializedScriptValue> create(PassRefPtr<WebCore::SerializedScriptValue> serializedValue)
+ static Ref<SerializedScriptValue> create(PassRefPtr<WebCore::SerializedScriptValue> serializedValue)
{
- return adoptRef(new WebSerializedScriptValue(serializedValue));
+ return adoptRef(*new SerializedScriptValue(serializedValue));
}
- static PassRefPtr<WebSerializedScriptValue> create(JSContextRef context, JSValueRef value, JSValueRef* exception)
+ static RefPtr<SerializedScriptValue> create(JSContextRef context, JSValueRef value, JSValueRef* exception)
{
RefPtr<WebCore::SerializedScriptValue> serializedValue = WebCore::SerializedScriptValue::create(context, value, exception);
if (!serializedValue)
- return 0;
- return adoptRef(new WebSerializedScriptValue(serializedValue.get()));
+ return nullptr;
+ return adoptRef(*new SerializedScriptValue(serializedValue.get()));
}
- static PassRefPtr<WebSerializedScriptValue> adopt(Vector<uint8_t>& buffer)
+ static Ref<SerializedScriptValue> adopt(Vector<uint8_t>&& buffer)
{
- return adoptRef(new WebSerializedScriptValue(WebCore::SerializedScriptValue::adopt(buffer)));
+ return adoptRef(*new SerializedScriptValue(WebCore::SerializedScriptValue::adopt(WTFMove(buffer))));
}
JSValueRef deserialize(JSContextRef context, JSValueRef* exception)
{
return m_serializedScriptValue->deserialize(context, exception);
}
+
+#if PLATFORM(COCOA) && defined(__OBJC__)
+ static id deserialize(WebCore::SerializedScriptValue&, JSValueRef* exception);
+#endif
IPC::DataReference dataReference() const { return m_serializedScriptValue->data(); }
- void* internalRepresentation() { return m_serializedScriptValue.get(); }
+ WebCore::SerializedScriptValue* internalRepresentation() { return m_serializedScriptValue.get(); }
private:
- explicit WebSerializedScriptValue(PassRefPtr<WebCore::SerializedScriptValue> serializedScriptValue)
+ explicit SerializedScriptValue(PassRefPtr<WebCore::SerializedScriptValue> serializedScriptValue)
: m_serializedScriptValue(serializedScriptValue)
{
}
@@ -74,4 +78,4 @@ private:
}
-#endif // WebSerializedScriptValue_h
+#endif
diff --git a/Source/WebKit2/Shared/API/APIString.h b/Source/WebKit2/Shared/API/APIString.h
new file mode 100644
index 000000000..2722b1b8b
--- /dev/null
+++ b/Source/WebKit2/Shared/API/APIString.h
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef APIString_h
+#define APIString_h
+
+#include "APIObject.h"
+#include <wtf/Ref.h>
+#include <wtf/text/StringView.h>
+#include <wtf/text/WTFString.h>
+#include <wtf/unicode/UTF8.h>
+
+namespace API {
+
+class String final : public ObjectImpl<Object::Type::String> {
+public:
+ static Ref<String> createNull()
+ {
+ return adoptRef(*new String);
+ }
+
+ static Ref<String> create(WTF::String&& string)
+ {
+ return adoptRef(*new String(string.isNull() ? WTF::String(StringImpl::empty()) : string.isolatedCopy()));
+ }
+
+ static Ref<String> create(const WTF::String& string)
+ {
+ return create(string.isolatedCopy());
+ }
+
+ virtual ~String()
+ {
+ }
+
+ WTF::StringView stringView() const { return m_string; }
+ WTF::String string() const { return m_string.isolatedCopy(); }
+
+private:
+ String()
+ : m_string()
+ {
+ }
+
+ String(WTF::String&& string)
+ : m_string(WTFMove(string))
+ {
+ ASSERT(!m_string.isNull());
+ ASSERT(m_string.isSafeToSendToAnotherThread());
+ }
+
+ const WTF::String m_string;
+};
+
+} // namespace WebKit
+
+#endif // APIString_h
diff --git a/Source/WebKit2/Shared/APIURL.h b/Source/WebKit2/Shared/API/APIURL.h
index 0e1e03c7b..7e0fae174 100644
--- a/Source/WebKit2/Shared/APIURL.h
+++ b/Source/WebKit2/Shared/API/APIURL.h
@@ -29,28 +29,26 @@
#include "APIObject.h"
#include "WebCoreArgumentCoders.h"
#include <WebCore/URL.h>
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/PassRefPtr.h>
+#include <wtf/Forward.h>
#include <wtf/text/WTFString.h>
namespace API {
class URL : public ObjectImpl<Object::Type::URL> {
public:
- static PassRefPtr<URL> create(const WTF::String& string)
+ static Ref<URL> create(const WTF::String& string)
{
- return adoptRef(new URL(string));
+ return adoptRef(*new URL(string));
}
- static PassRefPtr<URL> create(const URL* baseURL, const WTF::String& relativeURL)
+ static Ref<URL> create(const URL* baseURL, const WTF::String& relativeURL)
{
ASSERT(baseURL);
baseURL->parseURLIfNecessary();
auto absoluteURL = std::make_unique<WebCore::URL>(*baseURL->m_parsedURL.get(), relativeURL);
const WTF::String& absoluteURLString = absoluteURL->string();
- return adoptRef(new URL(std::move(absoluteURL), absoluteURLString));
+ return adoptRef(*new URL(WTFMove(absoluteURL), absoluteURLString));
}
bool isNull() const { return m_string.isNull(); }
@@ -58,6 +56,11 @@ public:
const WTF::String& string() const { return m_string; }
+ static bool equals(const URL& a, const URL& b)
+ {
+ return a.url() == b.url();
+ }
+
WTF::String host() const
{
parseURLIfNecessary();
@@ -67,7 +70,7 @@ public:
WTF::String protocol() const
{
parseURLIfNecessary();
- return m_parsedURL->isValid() ? m_parsedURL->protocol() : WTF::String();
+ return m_parsedURL->isValid() ? m_parsedURL->protocol().toString() : WTF::String();
}
WTF::String path() const
@@ -82,12 +85,12 @@ public:
return m_parsedURL->isValid() ? m_parsedURL->lastPathComponent() : WTF::String();
}
- void encode(IPC::ArgumentEncoder& encoder) const
+ void encode(IPC::Encoder& encoder) const
{
encoder << m_string;
}
- static bool decode(IPC::ArgumentDecoder& decoder, RefPtr<Object>& result)
+ static bool decode(IPC::Decoder& decoder, RefPtr<Object>& result)
{
WTF::String string;
if (!decoder.decode(string))
@@ -105,10 +108,16 @@ private:
URL(std::unique_ptr<WebCore::URL> parsedURL, const WTF::String& string)
: m_string(string)
- , m_parsedURL(std::move(parsedURL))
+ , m_parsedURL(WTFMove(parsedURL))
{
}
+ const WebCore::URL& url() const
+ {
+ parseURLIfNecessary();
+ return *m_parsedURL;
+ }
+
void parseURLIfNecessary() const
{
if (m_parsedURL)
diff --git a/Source/WebKit2/Shared/APIURLRequest.cpp b/Source/WebKit2/Shared/API/APIURLRequest.cpp
index b9165ea06..ac904d409 100644
--- a/Source/WebKit2/Shared/APIURLRequest.cpp
+++ b/Source/WebKit2/Shared/API/APIURLRequest.cpp
@@ -26,8 +26,8 @@
#include "config.h"
#include "APIURLRequest.h"
-#include "WebContext.h"
#include "WebCoreArgumentCoders.h"
+#include "WebProcessPool.h"
using namespace WebCore;
using namespace WebKit;
@@ -44,22 +44,21 @@ double URLRequest::defaultTimeoutInterval()
return ResourceRequest::defaultTimeoutInterval();
}
-// FIXME: This function should really be on WebContext.
+// FIXME: This function should really be on WebProcessPool or WebPageProxy.
void URLRequest::setDefaultTimeoutInterval(double timeoutInterval)
{
ResourceRequest::setDefaultTimeoutInterval(timeoutInterval);
- const Vector<WebContext*>& contexts = WebContext::allContexts();
- for (size_t i = 0; i < contexts.size(); ++i)
- contexts[i]->setDefaultRequestTimeoutInterval(timeoutInterval);
+ for (auto* processPool : WebProcessPool::allProcessPools())
+ processPool->setDefaultRequestTimeoutInterval(timeoutInterval);
}
-void URLRequest::encode(IPC::ArgumentEncoder& encoder) const
+void URLRequest::encode(IPC::Encoder& encoder) const
{
encoder << resourceRequest();
}
-bool URLRequest::decode(IPC::ArgumentDecoder& decoder, RefPtr<Object>& result)
+bool URLRequest::decode(IPC::Decoder& decoder, RefPtr<Object>& result)
{
ResourceRequest request;
if (!decoder.decode(request))
diff --git a/Source/WebKit2/Shared/APIURLRequest.h b/Source/WebKit2/Shared/API/APIURLRequest.h
index d5e4d4a2e..2a01602de 100644
--- a/Source/WebKit2/Shared/APIURLRequest.h
+++ b/Source/WebKit2/Shared/API/APIURLRequest.h
@@ -31,17 +31,17 @@
#include <wtf/Forward.h>
namespace IPC {
-class ArgumentDecoder;
-class ArgumentEncoder;
+class Decoder;
+class Encoder;
}
namespace API {
class URLRequest : public ObjectImpl<Object::Type::URLRequest> {
public:
- static PassRefPtr<URLRequest> create(const WebCore::ResourceRequest& request)
+ static Ref<URLRequest> create(const WebCore::ResourceRequest& request)
{
- return adoptRef(new URLRequest(request));
+ return adoptRef(*new URLRequest(request));
}
const WebCore::ResourceRequest& resourceRequest() const { return m_request; }
@@ -49,8 +49,8 @@ public:
static double defaultTimeoutInterval(); // May return 0 when using platform default.
static void setDefaultTimeoutInterval(double);
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, RefPtr<Object>&);
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, RefPtr<Object>&);
private:
explicit URLRequest(const WebCore::ResourceRequest&);
diff --git a/Source/WebKit2/Shared/APIURLResponse.cpp b/Source/WebKit2/Shared/API/APIURLResponse.cpp
index 226d624cb..1d93b62d3 100644
--- a/Source/WebKit2/Shared/APIURLResponse.cpp
+++ b/Source/WebKit2/Shared/API/APIURLResponse.cpp
@@ -37,12 +37,12 @@ URLResponse::URLResponse(const WebCore::ResourceResponse& response)
{
}
-void URLResponse::encode(IPC::ArgumentEncoder& encoder) const
+void URLResponse::encode(IPC::Encoder& encoder) const
{
encoder << resourceResponse();
}
-bool URLResponse::decode(IPC::ArgumentDecoder& decoder, RefPtr<Object>& result)
+bool URLResponse::decode(IPC::Decoder& decoder, RefPtr<Object>& result)
{
ResourceResponse response;
if (!decoder.decode(response))
diff --git a/Source/WebKit2/Shared/APIURLResponse.h b/Source/WebKit2/Shared/API/APIURLResponse.h
index 2790b9fbe..125e03711 100644
--- a/Source/WebKit2/Shared/APIURLResponse.h
+++ b/Source/WebKit2/Shared/API/APIURLResponse.h
@@ -31,23 +31,23 @@
#include <wtf/Forward.h>
namespace IPC {
-class ArgumentDecoder;
-class ArgumentEncoder;
+class Decoder;
+class Encoder;
}
namespace API {
class URLResponse : public ObjectImpl<Object::Type::URLResponse> {
public:
- static PassRefPtr<URLResponse> create(const WebCore::ResourceResponse& response)
+ static Ref<URLResponse> create(const WebCore::ResourceResponse& response)
{
- return adoptRef(new URLResponse(response));
+ return adoptRef(*new URLResponse(response));
}
const WebCore::ResourceResponse& resourceResponse() const { return m_response; }
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, RefPtr<Object>&);
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, RefPtr<Object>&);
private:
explicit URLResponse(const WebCore::ResourceResponse&);
diff --git a/Source/WebKit2/Shared/WebUserContentURLPattern.h b/Source/WebKit2/Shared/API/APIUserContentURLPattern.h
index 348cb212c..aff461310 100644
--- a/Source/WebKit2/Shared/WebUserContentURLPattern.h
+++ b/Source/WebKit2/Shared/API/APIUserContentURLPattern.h
@@ -23,43 +23,42 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef WebUserContentURLPattern_h
-#define WebUserContentURLPattern_h
+#ifndef APIUserContentURLPattern_h
+#define APIUserContentURLPattern_h
#include "APIObject.h"
#include <WebCore/URL.h>
#include <WebCore/UserContentURLPattern.h>
-#include <wtf/RefPtr.h>
-namespace WebKit {
+namespace API {
-class WebUserContentURLPattern : public API::ObjectImpl<API::Object::Type::UserContentURLPattern> {
+class UserContentURLPattern : public API::ObjectImpl<API::Object::Type::UserContentURLPattern> {
public:
- static PassRefPtr<WebUserContentURLPattern> create(const String& pattern)
+ static Ref<UserContentURLPattern> create(const WTF::String& pattern)
{
- return adoptRef(new WebUserContentURLPattern(pattern));
+ return adoptRef(*new UserContentURLPattern(pattern));
}
- const String& host() const { return m_pattern.host(); }
- const String& scheme() const { return m_pattern.scheme(); }
+ const WTF::String& host() const { return m_pattern.host(); }
+ const WTF::String& scheme() const { return m_pattern.scheme(); }
bool isValid() const { return m_pattern.isValid(); };
- bool matchesURL(const String& url) const { return m_pattern.matches(WebCore::URL(WebCore::ParsedURLString, url)); }
+ bool matchesURL(const WTF::String& url) const { return m_pattern.matches(WebCore::URL(WebCore::ParsedURLString, url)); }
bool matchesSubdomains() const { return m_pattern.matchSubdomains(); }
- const String& patternString() const { return m_patternString; }
+ const WTF::String& patternString() const { return m_patternString; }
private:
- explicit WebUserContentURLPattern(const String& pattern)
+ explicit UserContentURLPattern(const WTF::String& pattern)
: m_pattern(WebCore::UserContentURLPattern(pattern))
, m_patternString(pattern)
{
}
WebCore::UserContentURLPattern m_pattern;
- String m_patternString;
+ WTF::String m_patternString;
};
}
-#endif // WebUserContentURLPattern_h
+#endif
diff --git a/Source/WebKit2/Shared/API/c/WKActionMenuItemTypes.h b/Source/WebKit2/Shared/API/c/WKActionMenuItemTypes.h
new file mode 100644
index 000000000..7ab00f53a
--- /dev/null
+++ b/Source/WebKit2/Shared/API/c/WKActionMenuItemTypes.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+#ifndef WKActionMenuItemTypes_h
+#define WKActionMenuItemTypes_h
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Deprecated; remove when there are no more clients.
+enum {
+ kWKContextActionItemTagNoAction = 0,
+ kWKContextActionItemTagOpenLinkInDefaultBrowser,
+ kWKContextActionItemTagPreviewLink,
+ kWKContextActionItemTagAddLinkToSafariReadingList,
+ kWKContextActionItemTagCopyImage,
+ kWKContextActionItemTagAddImageToPhotos,
+ kWKContextActionItemTagSaveImageToDownloads,
+ kWKContextActionItemTagShareImage,
+ kWKContextActionItemTagCopyText,
+ kWKContextActionItemTagLookupText,
+ kWKContextActionItemTagPaste,
+ kWKContextActionItemTagTextSuggestions,
+ kWKContextActionItemTagCopyVideoURL,
+ kWKContextActionItemTagSaveVideoToDownloads,
+ kWKContextActionItemTagShareVideo,
+ kWKContextActionItemTagShareLink
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKActionMenuItemTypes_h */
diff --git a/Source/WebKit2/Shared/CommandLine.h b/Source/WebKit2/Shared/API/c/WKActionMenuTypes.h
index f5955e754..4769c390d 100644
--- a/Source/WebKit2/Shared/CommandLine.h
+++ b/Source/WebKit2/Shared/API/c/WKActionMenuTypes.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -23,32 +23,33 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef CommandLine_h
-#define CommandLine_h
+#ifndef WKActionMenuTypes_h
+#define WKActionMenuTypes_h
-#include <wtf/HashMap.h>
-#include <wtf/text/StringHash.h>
-#include <wtf/text/WTFString.h>
+#include <stdint.h>
-namespace WebKit {
-
-// Very specialized command line parser. Expects the command line arguments in
-// -key value and will store the parsed arguments in a map.
-
-class CommandLine {
-public:
-#if PLATFORM(MAC)
- bool parse(int argc, char** argv);
+#ifdef __cplusplus
+extern "C" {
#endif
- String operator[](const String& key) const
- {
- return m_args.get(key);
- }
-private:
- HashMap<String, String> m_args;
+// Deprecated; remove when there are no more clients.
+enum {
+ kWKActionMenuNone = 0,
+ kWKActionMenuLink,
+ kWKActionMenuImage,
+ kWKActionMenuDataDetectedItem,
+ kWKActionMenuReadOnlyText,
+ kWKActionMenuEditableText,
+ kWKActionMenuEditableTextWithSuggestions,
+ kWKActionMenuWhitespaceInEditableArea,
+ kWKActionMenuVideo,
+ kWKActionMenuMailtoLink,
+ kWKActionMenuTelLink
};
+typedef uint32_t _WKActionMenuType;
+#ifdef __cplusplus
}
+#endif
-#endif // CommandLine_h
+#endif /* WKActionMenuTypes_h */
diff --git a/Source/WebKit2/Shared/API/c/WKArray.cpp b/Source/WebKit2/Shared/API/c/WKArray.cpp
index 30f9781f3..844161124 100644
--- a/Source/WebKit2/Shared/API/c/WKArray.cpp
+++ b/Source/WebKit2/Shared/API/c/WKArray.cpp
@@ -42,9 +42,9 @@ WKArrayRef WKArrayCreate(WKTypeRef* values, size_t numberOfValues)
elements.reserveInitialCapacity(numberOfValues);
for (size_t i = 0; i < numberOfValues; ++i)
- elements.uncheckedAppend(const_cast<API::Object*>(static_cast<const API::Object*>(values[i])));
+ elements.uncheckedAppend(toImpl(values[i]));
- return toAPI(API::Array::create(std::move(elements)).leakRef());
+ return toAPI(&API::Array::create(WTFMove(elements)).leakRef());
}
WKArrayRef WKArrayCreateAdoptingValues(WKTypeRef* values, size_t numberOfValues)
@@ -53,14 +53,14 @@ WKArrayRef WKArrayCreateAdoptingValues(WKTypeRef* values, size_t numberOfValues)
elements.reserveInitialCapacity(numberOfValues);
for (size_t i = 0; i < numberOfValues; ++i)
- elements.uncheckedAppend(adoptRef(const_cast<API::Object*>(static_cast<const API::Object*>(values[i]))));
+ elements.uncheckedAppend(adoptRef(toImpl(values[i])));
- return toAPI(API::Array::create(std::move(elements)).leakRef());
+ return toAPI(&API::Array::create(WTFMove(elements)).leakRef());
}
WKTypeRef WKArrayGetItemAtIndex(WKArrayRef arrayRef, size_t index)
{
- return toImpl(arrayRef)->at(index);
+ return toAPI(toImpl(arrayRef)->at(index));
}
size_t WKArrayGetSize(WKArrayRef arrayRef)
diff --git a/Source/WebKit2/Shared/API/c/WKArray.h b/Source/WebKit2/Shared/API/c/WKArray.h
index 25900f313..ff8d39bfe 100644
--- a/Source/WebKit2/Shared/API/c/WKArray.h
+++ b/Source/WebKit2/Shared/API/c/WKArray.h
@@ -26,7 +26,7 @@
#ifndef WKArray_h
#define WKArray_h
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#include <stddef.h>
diff --git a/Source/WebKit2/Shared/API/c/WKBase.h b/Source/WebKit2/Shared/API/c/WKBase.h
index d41894c13..2e8fbfbbe 100644
--- a/Source/WebKit2/Shared/API/c/WKBase.h
+++ b/Source/WebKit2/Shared/API/c/WKBase.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2017 Apple Inc. All rights reserved.
* Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -27,23 +27,15 @@
#ifndef WKBase_h
#define WKBase_h
-#include <WebKit2/WKDeclarationSpecifiers.h>
+#include <WebKit/WKDeclarationSpecifiers.h>
#include <stdint.h>
#if defined(BUILDING_GTK__)
-#include <WebKit2/WKBaseGtk.h>
+#include <WebKit/WKBaseGtk.h>
#endif
-#if defined(WTF_USE_SOUP)
-#include <WebKit2/WKBaseSoup.h>
-#endif
-
-#if defined(BUILDING_EFL__)
-#include <WebKit2/WKBaseEfl.h>
-#endif
-
-#if defined(__APPLE__)
-#include <WebKit2/WKBaseMac.h>
+#if defined(__APPLE__) && !defined(BUILDING_GTK__)
+#include <WebKit/WKBaseMac.h>
#endif
/* WebKit2 shared types */
@@ -89,16 +81,17 @@ typedef const struct OpaqueWKAuthenticationChallenge* WKAuthenticationChallengeR
typedef const struct OpaqueWKAuthenticationDecisionListener* WKAuthenticationDecisionListenerRef;
typedef const struct OpaqueWKBackForwardList* WKBackForwardListRef;
typedef const struct OpaqueWKBackForwardListItem* WKBackForwardListItemRef;
-typedef const struct OpaqueWKBatteryManager* WKBatteryManagerRef;
-typedef const struct OpaqueWKBatteryStatus* WKBatteryStatusRef;
typedef const struct OpaqueWKResourceCacheManager* WKResourceCacheManagerRef;
typedef const struct OpaqueWKColorPickerResultListener* WKColorPickerResultListenerRef;
typedef const struct OpaqueWKContext* WKContextRef;
+typedef const struct OpaqueWKContextConfiguration* WKContextConfigurationRef;
+typedef const struct OpaqueWKContextMenuListener* WKContextMenuListenerRef;
typedef const struct OpaqueWKCookieManager* WKCookieManagerRef;
typedef const struct OpaqueWKCredential* WKCredentialRef;
-typedef const struct OpaqueWKDatabaseManager* WKDatabaseManagerRef;
typedef const struct OpaqueWKDownload* WKDownloadRef;
typedef const struct OpaqueWKFormSubmissionListener* WKFormSubmissionListenerRef;
+typedef const struct OpaqueWKFrameHandle* WKFrameHandleRef;
+typedef const struct OpaqueWKFrameInfo* WKFrameInfoRef;
typedef const struct OpaqueWKFrame* WKFrameRef;
typedef const struct OpaqueWKFramePolicyListener* WKFramePolicyListenerRef;
typedef const struct OpaqueWKGeolocationManager* WKGeolocationManagerRef;
@@ -109,26 +102,42 @@ typedef const struct OpaqueWKHitTestResult* WKHitTestResultRef;
typedef const struct OpaqueWKIconDatabase* WKIconDatabaseRef;
typedef const struct OpaqueWKInspector* WKInspectorRef;
typedef const struct OpaqueWKKeyValueStorageManager* WKKeyValueStorageManagerRef;
-typedef const struct OpaqueWKMediaCacheManager* WKMediaCacheManagerRef;
+typedef const struct OpaqueWKMediaSessionFocusManager* WKMediaSessionFocusManagerRef;
+typedef const struct OpaqueWKMediaSessionMetadata* WKMediaSessionMetadataRef;
+typedef const struct OpaqueWKNavigationAction* WKNavigationActionRef;
typedef const struct OpaqueWKNavigationData* WKNavigationDataRef;
-typedef const struct OpaqueWKNetworkInfoManager* WKNetworkInfoManagerRef;
-typedef const struct OpaqueWKNetworkInfo* WKNetworkInfoRef;
+typedef const struct OpaqueWKNavigation* WKNavigationRef;
+typedef const struct OpaqueWKNavigationResponse* WKNavigationResponseRef;
typedef const struct OpaqueWKNotification* WKNotificationRef;
typedef const struct OpaqueWKNotificationManager* WKNotificationManagerRef;
typedef const struct OpaqueWKNotificationPermissionRequest* WKNotificationPermissionRequestRef;
typedef const struct OpaqueWKNotificationProvider* WKNotificationProviderRef;
typedef const struct OpaqueWKOpenPanelParameters* WKOpenPanelParametersRef;
typedef const struct OpaqueWKOpenPanelResultListener* WKOpenPanelResultListenerRef;
-typedef const struct OpaqueWKOriginDataManager* WKOriginDataManagerRef;
typedef const struct OpaqueWKPage* WKPageRef;
+typedef const struct OpaqueWKPageConfiguration* WKPageConfigurationRef;
typedef const struct OpaqueWKPageGroup* WKPageGroupRef;
-typedef const struct OpaqueWKPluginSiteDataManager* WKPluginSiteDataManagerRef;
typedef const struct OpaqueWKPreferences* WKPreferencesRef;
typedef const struct OpaqueWKProtectionSpace* WKProtectionSpaceRef;
+typedef const struct OpaqueWKPageRunBeforeUnloadConfirmPanelResultListener* WKPageRunBeforeUnloadConfirmPanelResultListenerRef;
+typedef const struct OpaqueWKPageRunJavaScriptAlertResultListener* WKPageRunJavaScriptAlertResultListenerRef;
+typedef const struct OpaqueWKPageRunJavaScriptConfirmResultListener* WKPageRunJavaScriptConfirmResultListenerRef;
+typedef const struct OpaqueWKPageRunJavaScriptPromptResultListener* WKPageRunJavaScriptPromptResultListenerRef;
+typedef const struct OpaqueWKResourceLoadStatisticsManager* WKResourceLoadStatisticsManagerRef;
typedef const struct OpaqueWKTextChecker* WKTextCheckerRef;
typedef const struct OpaqueWKSession* WKSessionRef;
+typedef const struct OpaqueWKSessionState* WKSessionStateRef;
+typedef const struct OpaqueWKUserContentController* WKUserContentControllerRef;
+typedef const struct OpaqueWKUserContentExtensionStore* WKUserContentExtensionStoreRef;
+typedef const struct OpaqueWKUserContentFilter* WKUserContentFilterRef;
+typedef const struct OpaqueWKUserMediaPermissionCheck* WKUserMediaPermissionCheckRef;
+typedef const struct OpaqueWKUserMediaPermissionRequest* WKUserMediaPermissionRequestRef;
+typedef const struct OpaqueWKUserScript* WKUserScriptRef;
typedef const struct OpaqueWKVibration* WKVibrationRef;
typedef const struct OpaqueWKViewportAttributes* WKViewportAttributesRef;
+typedef const struct OpaqueWKWebsiteDataStore* WKWebsiteDataStoreRef;
+typedef const struct OpaqueWKWebsitePolicies* WKWebsitePoliciesRef;
+typedef const struct OpaqueWKWindowFeatures* WKWindowFeaturesRef;
/* WebKit2 Bundle types */
@@ -137,6 +146,7 @@ typedef const struct OpaqueWKBundleBackForwardList* WKBundleBackForwardListRef;
typedef const struct OpaqueWKBundleBackForwardListItem* WKBundleBackForwardListItemRef;
typedef const struct OpaqueWKBundleDOMCSSStyleDeclaration* WKBundleCSSStyleDeclarationRef;
typedef const struct OpaqueWKBundleDOMWindowExtension* WKBundleDOMWindowExtensionRef;
+typedef const struct OpaqueWKBundleFileHandle* WKBundleFileHandleRef;
typedef const struct OpaqueWKBundleFrame* WKBundleFrameRef;
typedef const struct OpaqueWKBundleHitTestResult* WKBundleHitTestResultRef;
typedef const struct OpaqueWKBundleInspector* WKBundleInspectorRef;
diff --git a/Source/WebKit2/Shared/API/c/WKCertificateInfo.h b/Source/WebKit2/Shared/API/c/WKCertificateInfo.h
index d4a2ed91d..f88f93c1a 100644
--- a/Source/WebKit2/Shared/API/c/WKCertificateInfo.h
+++ b/Source/WebKit2/Shared/API/c/WKCertificateInfo.h
@@ -26,7 +26,7 @@
#ifndef WKCertificateInfo_h
#define WKCertificateInfo_h
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#ifdef __cplusplus
extern "C" {
diff --git a/Source/WebKit2/Shared/API/c/WKConnectionRef.h b/Source/WebKit2/Shared/API/c/WKConnectionRef.h
index 614024575..fd94cb614 100644
--- a/Source/WebKit2/Shared/API/c/WKConnectionRef.h
+++ b/Source/WebKit2/Shared/API/c/WKConnectionRef.h
@@ -26,7 +26,7 @@
#ifndef WKConnectionRef_h
#define WKConnectionRef_h
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#ifdef __cplusplus
extern "C" {
@@ -48,16 +48,6 @@ typedef struct WKConnectionClientV0 {
WKConnectionDidCloseCallback didClose;
} WKConnectionClientV0;
-enum { WKConnectionClientCurrentVersion WK_ENUM_DEPRECATED("Use an explicit version number instead") = 0 };
-typedef struct WKConnectionClient {
- int version;
- const void * clientInfo;
-
- // Version 0.
- WKConnectionDidReceiveMessageCallback didReceiveMessage;
- WKConnectionDidCloseCallback didClose;
-} WKConnectionClient WK_DEPRECATED("Use an explicit versioned struct instead");
-
WK_EXPORT WKTypeID WKConnectionGetTypeID();
WK_EXPORT void WKConnectionSetConnectionClient(WKConnectionRef connection, const WKConnectionClientBase* client);
diff --git a/Source/WebKit2/Shared/API/c/WKContextMenuItem.cpp b/Source/WebKit2/Shared/API/c/WKContextMenuItem.cpp
index 53064ff50..0514f1825 100644
--- a/Source/WebKit2/Shared/API/c/WKContextMenuItem.cpp
+++ b/Source/WebKit2/Shared/API/c/WKContextMenuItem.cpp
@@ -32,10 +32,6 @@
#include "WKAPICast.h"
#include "WKContextMenuItemTypes.h"
-#if PLATFORM(MAC)
-#import <mach-o/dyld.h>
-#endif
-
using namespace WebCore;
using namespace WebKit;
@@ -51,7 +47,7 @@ WKTypeID WKContextMenuItemGetTypeID()
WKContextMenuItemRef WKContextMenuItemCreateAsAction(WKContextMenuItemTag tag, WKStringRef title, bool enabled)
{
#if ENABLE(CONTEXT_MENUS)
- return toAPI(WebContextMenuItem::create(WebContextMenuItemData(ActionType, toImpl(tag), toImpl(title)->string(), enabled, false)).leakRef());
+ return toAPI(&WebContextMenuItem::create(WebContextMenuItemData(ActionType, toImpl(tag), toImpl(title)->string(), enabled, false)).leakRef());
#else
UNUSED_PARAM(tag);
UNUSED_PARAM(title);
@@ -63,7 +59,7 @@ WKContextMenuItemRef WKContextMenuItemCreateAsAction(WKContextMenuItemTag tag, W
WKContextMenuItemRef WKContextMenuItemCreateAsCheckableAction(WKContextMenuItemTag tag, WKStringRef title, bool enabled, bool checked)
{
#if ENABLE(CONTEXT_MENUS)
- return toAPI(WebContextMenuItem::create(WebContextMenuItemData(CheckableActionType, toImpl(tag), toImpl(title)->string(), enabled, checked)).leakRef());
+ return toAPI(&WebContextMenuItem::create(WebContextMenuItemData(CheckableActionType, toImpl(tag), toImpl(title)->string(), enabled, checked)).leakRef());
#else
UNUSED_PARAM(tag);
UNUSED_PARAM(title);
@@ -94,38 +90,10 @@ WKContextMenuItemRef WKContextMenuItemSeparatorItem()
#endif
}
-#if ENABLE(CONTEXT_MENUS)
-#if PLATFORM(MAC)
-static WKContextMenuItemTag compatibleContextMenuItemTag(WKContextMenuItemTag tag)
-{
- static bool needsWorkaround = ^bool {
- const int32_t safariFrameworkVersionWithIncompatibleContextMenuItemTags = 0x02181900; // 536.25.0 (Safari 6.0)
- return NSVersionOfRunTimeLibrary("Safari") == safariFrameworkVersionWithIncompatibleContextMenuItemTags;
- }();
-
- if (!needsWorkaround)
- return tag;
-
- // kWKContextMenuItemTagDictationAlternative was inserted before kWKContextMenuItemTagInspectElement.
- // DictationAlternative is now at the end like it should have been. To be compatible we need to return
- // InspectElement for DictationAlternative and shift InspectElement and after by one.
- if (tag == kWKContextMenuItemTagDictationAlternative)
- return kWKContextMenuItemTagInspectElement;
- if (tag >= kWKContextMenuItemTagInspectElement && tag < kWKContextMenuItemBaseApplicationTag)
- return tag + 1;
- return tag;
-}
-#endif
-#endif // ENABLE(CONTEXT_MENUS)
-
WKContextMenuItemTag WKContextMenuItemGetTag(WKContextMenuItemRef itemRef)
{
#if ENABLE(CONTEXT_MENUS)
-#if PLATFORM(MAC)
- return compatibleContextMenuItemTag(toAPI(toImpl(itemRef)->data()->action()));
-#else
- return toAPI(toImpl(itemRef)->data()->action());
-#endif
+ return toAPI(toImpl(itemRef)->data().action());
#else
UNUSED_PARAM(itemRef);
return toAPI(ContextMenuItemTagNoAction);
@@ -135,7 +103,7 @@ WKContextMenuItemTag WKContextMenuItemGetTag(WKContextMenuItemRef itemRef)
WKContextMenuItemType WKContextMenuItemGetType(WKContextMenuItemRef itemRef)
{
#if ENABLE(CONTEXT_MENUS)
- return toAPI(toImpl(itemRef)->data()->type());
+ return toAPI(toImpl(itemRef)->data().type());
#else
UNUSED_PARAM(itemRef);
return toAPI(ActionType);
@@ -145,7 +113,7 @@ WKContextMenuItemType WKContextMenuItemGetType(WKContextMenuItemRef itemRef)
WKStringRef WKContextMenuItemCopyTitle(WKContextMenuItemRef itemRef)
{
#if ENABLE(CONTEXT_MENUS)
- return toCopiedAPI(toImpl(itemRef)->data()->title().impl());
+ return toCopiedAPI(toImpl(itemRef)->data().title().impl());
#else
UNUSED_PARAM(itemRef);
return 0;
@@ -155,7 +123,7 @@ WKStringRef WKContextMenuItemCopyTitle(WKContextMenuItemRef itemRef)
bool WKContextMenuItemGetEnabled(WKContextMenuItemRef itemRef)
{
#if ENABLE(CONTEXT_MENUS)
- return toImpl(itemRef)->data()->enabled();
+ return toImpl(itemRef)->data().enabled();
#else
UNUSED_PARAM(itemRef);
return false;
@@ -165,7 +133,7 @@ bool WKContextMenuItemGetEnabled(WKContextMenuItemRef itemRef)
bool WKContextMenuItemGetChecked(WKContextMenuItemRef itemRef)
{
#if ENABLE(CONTEXT_MENUS)
- return toImpl(itemRef)->data()->checked();
+ return toImpl(itemRef)->data().checked();
#else
UNUSED_PARAM(itemRef);
return false;
@@ -175,7 +143,7 @@ bool WKContextMenuItemGetChecked(WKContextMenuItemRef itemRef)
WKArrayRef WKContextMenuCopySubmenuItems(WKContextMenuItemRef itemRef)
{
#if ENABLE(CONTEXT_MENUS)
- return toAPI(toImpl(itemRef)->submenuItemsAsAPIArray().leakRef());
+ return toAPI(&toImpl(itemRef)->submenuItemsAsAPIArray().leakRef());
#else
UNUSED_PARAM(itemRef);
return 0;
diff --git a/Source/WebKit2/Shared/API/c/WKContextMenuItem.h b/Source/WebKit2/Shared/API/c/WKContextMenuItem.h
index 9b978400c..caf1b7632 100644
--- a/Source/WebKit2/Shared/API/c/WKContextMenuItem.h
+++ b/Source/WebKit2/Shared/API/c/WKContextMenuItem.h
@@ -26,8 +26,8 @@
#ifndef WKContextMenuItem_h
#define WKContextMenuItem_h
-#include <WebKit2/WKBase.h>
-#include <WebKit2/WKContextMenuItemTypes.h>
+#include <WebKit/WKBase.h>
+#include <WebKit/WKContextMenuItemTypes.h>
#ifdef __cplusplus
extern "C" {
diff --git a/Source/WebKit2/Shared/API/c/WKContextMenuItemTypes.h b/Source/WebKit2/Shared/API/c/WKContextMenuItemTypes.h
index f61703e32..2a67631c4 100644
--- a/Source/WebKit2/Shared/API/c/WKContextMenuItemTypes.h
+++ b/Source/WebKit2/Shared/API/c/WKContextMenuItemTypes.h
@@ -121,6 +121,8 @@ enum {
kWKContextMenuItemTagSelectAll,
kWKContextMenuItemTagOpenLinkInThisWindow,
kWKContextMenuItemTagToggleVideoFullscreen,
+ kWKContextMenuItemTagShareMenu,
+ kWKContextMenuItemTagToggleVideoEnhancedFullscreen,
kWKContextMenuItemBaseApplicationTag = 10000
};
typedef uint32_t WKContextMenuItemTag;
diff --git a/Source/WebKit2/Shared/API/c/WKData.cpp b/Source/WebKit2/Shared/API/c/WKData.cpp
index ebc40b142..fdbca73dc 100644
--- a/Source/WebKit2/Shared/API/c/WKData.cpp
+++ b/Source/WebKit2/Shared/API/c/WKData.cpp
@@ -38,7 +38,7 @@ WKTypeID WKDataGetTypeID()
WKDataRef WKDataCreate(const unsigned char* bytes, size_t size)
{
- return toAPI(API::Data::create(bytes, size).leakRef());
+ return toAPI(&API::Data::create(bytes, size).leakRef());
}
const unsigned char* WKDataGetBytes(WKDataRef dataRef)
diff --git a/Source/WebKit2/Shared/API/c/WKData.h b/Source/WebKit2/Shared/API/c/WKData.h
index a647ee4e4..19e1fff7c 100644
--- a/Source/WebKit2/Shared/API/c/WKData.h
+++ b/Source/WebKit2/Shared/API/c/WKData.h
@@ -26,7 +26,7 @@
#ifndef WKData_h
#define WKData_h
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#include <stddef.h>
diff --git a/Source/WebKit2/Shared/API/c/WKDeclarationSpecifiers.h b/Source/WebKit2/Shared/API/c/WKDeclarationSpecifiers.h
index b5d8f13cb..ce8adcfbb 100644
--- a/Source/WebKit2/Shared/API/c/WKDeclarationSpecifiers.h
+++ b/Source/WebKit2/Shared/API/c/WKDeclarationSpecifiers.h
@@ -51,15 +51,9 @@
#endif
#if defined(__has_extension) && __has_extension(enumerator_attributes) && __has_extension(attribute_unavailable_with_message)
-#define WK_DEPRECATED(message) __attribute__((deprecated(message)))
+#define WK_C_DEPRECATED(message) __attribute__((deprecated(message)))
#else
-#define WK_DEPRECATED(message)
-#endif
-
-#if defined(__has_extension) && __has_extension(enumerator_attributes) && __has_extension(attribute_unavailable_with_message)
-#define WK_ENUM_DEPRECATED(message) __attribute__((deprecated(message)))
-#else
-#define WK_ENUM_DEPRECATED(message)
+#define WK_C_DEPRECATED(message)
#endif
#endif /* WKDeclarationSpecifiers_h */
diff --git a/Source/WebKit2/Shared/API/c/WKDeprecatedFunctions.cpp b/Source/WebKit2/Shared/API/c/WKDeprecatedFunctions.cpp
index 1319b76f3..915f44a7f 100644
--- a/Source/WebKit2/Shared/API/c/WKDeprecatedFunctions.cpp
+++ b/Source/WebKit2/Shared/API/c/WKDeprecatedFunctions.cpp
@@ -25,10 +25,15 @@
#include "config.h"
-#include "MutableDictionary.h"
+#include "APIDictionary.h"
+#include "APIUserContentExtension.h"
+#include "WKAPICast.h"
#include "WKArray.h"
+#include "WKContextPrivate.h"
#include "WKMutableDictionary.h"
-#include "WKSharedAPICast.h"
+#include "WKPreferencesRefPrivate.h"
+#include "WebPageGroup.h"
+#include "WebUserContentControllerProxy.h"
#if PLATFORM(MAC)
#include "WKContextPrivateMac.h"
@@ -36,53 +41,53 @@
// Deprecated functions that should be removed from the framework once nobody uses them.
-using namespace WebKit;
-
extern "C" {
-WK_EXPORT bool WKArrayIsMutable(WKArrayRef array);
-
-WK_EXPORT bool WKDictionaryAddItem(WKMutableDictionaryRef dictionary, WKStringRef key, WKTypeRef item);
-WK_EXPORT bool WKDictionaryIsMutable(WKDictionaryRef dictionary);
-WK_EXPORT void WKDictionaryRemoveItem(WKMutableDictionaryRef dictionary, WKStringRef key);
-
-#if PLATFORM(MAC)
-WK_EXPORT CGContextRef WKGraphicsContextGetCGContext(WKGraphicsContextRef graphicsContext);
-#endif
+WK_EXPORT WKStringRef WKPageGroupCopyIdentifier(WKPageGroupRef pageGroup);
+WK_EXPORT void WKPageGroupAddUserContentFilter(WKPageGroupRef pageGroup, WKUserContentFilterRef userContentFilter);
+WK_EXPORT void WKPageGroupRemoveUserContentFilter(WKPageGroupRef pageGroup, WKStringRef userContentFilterName);
+WK_EXPORT void WKPageGroupRemoveAllUserContentFilters(WKPageGroupRef pageGroup);
}
-bool WKArrayIsMutable(WKArrayRef)
-{
- return false;
-}
+using namespace WebKit;
-bool WKDictionaryIsMutable(WKDictionaryRef dictionaryRef)
+void WKContextSetUsesNetworkProcess(WKContextRef, bool)
{
- return toImpl(dictionaryRef)->isMutable();
}
-bool WKDictionaryAddItem(WKMutableDictionaryRef dictionaryRef, WKStringRef keyRef, WKTypeRef itemRef)
+void WKContextSetProcessModel(WKContextRef, WKProcessModel)
{
- return toImpl(dictionaryRef)->add(toImpl(keyRef)->string(), toImpl(itemRef));
}
-void WKDictionaryRemoveItem(WKMutableDictionaryRef dictionaryRef, WKStringRef keyRef)
+WKStringRef WKPageGroupCopyIdentifier(WKPageGroupRef)
{
- toImpl(dictionaryRef)->remove(toImpl(keyRef)->string());
+ return nullptr;
}
-
-#if PLATFORM(MAC)
-CGContextRef WKGraphicsContextGetCGContext(WKGraphicsContextRef graphicsContext)
+void WKPageGroupAddUserContentFilter(WKPageGroupRef pageGroupRef, WKUserContentFilterRef userContentFilterRef)
{
- return nullptr;
+#if ENABLE(CONTENT_EXTENSIONS)
+ toImpl(pageGroupRef)->userContentController().addUserContentExtension(*toImpl(userContentFilterRef));
+#else
+ UNUSED_PARAM(pageGroupRef);
+ UNUSED_PARAM(userContentFilterRef);
+#endif
}
-bool WKContextGetProcessSuppressionEnabled(WKContextRef)
+void WKPageGroupRemoveUserContentFilter(WKPageGroupRef pageGroupRef, WKStringRef userContentFilterNameRef)
{
- return true;
+#if ENABLE(CONTENT_EXTENSIONS)
+ toImpl(pageGroupRef)->userContentController().removeUserContentExtension(toWTFString(userContentFilterNameRef));
+#else
+ UNUSED_PARAM(pageGroupRef);
+ UNUSED_PARAM(userContentFilterNameRef);
+#endif
}
-void WKContextSetProcessSuppressionEnabled(WKContextRef, bool)
+void WKPageGroupRemoveAllUserContentFilters(WKPageGroupRef pageGroupRef)
{
-}
+#if ENABLE(CONTENT_EXTENSIONS)
+ toImpl(pageGroupRef)->userContentController().removeAllUserContentExtensions();
+#else
+ UNUSED_PARAM(pageGroupRef);
#endif
+}
diff --git a/Source/WebKit2/Shared/API/c/soup/WKBaseSoup.h b/Source/WebKit2/Shared/API/c/WKDiagnosticLoggingResultType.h
index 600f0857f..581c74f96 100644
--- a/Source/WebKit2/Shared/API/c/soup/WKBaseSoup.h
+++ b/Source/WebKit2/Shared/API/c/WKDiagnosticLoggingResultType.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Igalia S.L.
+ * Copyright (C) 2013, 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
@@ -23,14 +23,23 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef WKBaseSoup_h
-#define WKBaseSoup_h
+#ifndef WKDiagnosticLoggingResultType_h
+#define WKDiagnosticLoggingResultType_h
-#ifndef WKBase_h
-#error "Please #include \"WKBase.h\" instead of this file directly."
+#ifdef __cplusplus
+extern "C" {
#endif
-typedef const struct OpaqueWKSoupRequestManager* WKSoupRequestManagerRef;
-typedef const struct OpaqueWKSoupCustomProtocolRequestManager* WKSoupCustomProtocolRequestManagerRef;
+enum {
+ kWKDiagnosticLoggingResultPass = 0,
+ kWKDiagnosticLoggingResultFail = 1,
+ kWKDiagnosticLoggingResultNoop = 2,
+};
+typedef uint32_t WKDiagnosticLoggingResultType;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKDiagnosticLoggingResultType_h */
-#endif /* WKBaseSoup_h */
diff --git a/Source/WebKit2/Shared/API/c/WKDictionary.cpp b/Source/WebKit2/Shared/API/c/WKDictionary.cpp
index 44c61e162..654e1e61e 100644
--- a/Source/WebKit2/Shared/API/c/WKDictionary.cpp
+++ b/Source/WebKit2/Shared/API/c/WKDictionary.cpp
@@ -27,28 +27,28 @@
#include "WKDictionary.h"
#include "APIArray.h"
-#include "ImmutableDictionary.h"
+#include "APIDictionary.h"
#include "WKAPICast.h"
using namespace WebKit;
WKTypeID WKDictionaryGetTypeID()
{
- return toAPI(ImmutableDictionary::APIType);
+ return toAPI(API::Dictionary::APIType);
}
WK_EXPORT WKDictionaryRef WKDictionaryCreate(const WKStringRef* keys, const WKTypeRef* values, size_t numberOfValues)
{
- ImmutableDictionary::MapType map;
+ API::Dictionary::MapType map;
for (size_t i = 0; i < numberOfValues; ++i)
map.add(toImpl(keys[i])->string(), toImpl(values[i]));
- return toAPI(ImmutableDictionary::create(std::move(map)).release().leakRef());
+ return toAPI(&API::Dictionary::create(WTFMove(map)).leakRef());
}
WKTypeRef WKDictionaryGetItemForKey(WKDictionaryRef dictionaryRef, WKStringRef key)
{
- return toImpl(dictionaryRef)->get(toImpl(key)->string());
+ return toAPI(toImpl(dictionaryRef)->get(toImpl(key)->string()));
}
size_t WKDictionaryGetSize(WKDictionaryRef dictionaryRef)
@@ -58,6 +58,5 @@ size_t WKDictionaryGetSize(WKDictionaryRef dictionaryRef)
WKArrayRef WKDictionaryCopyKeys(WKDictionaryRef dictionaryRef)
{
- RefPtr<API::Array> keys = toImpl(dictionaryRef)->keys();
- return toAPI(keys.release().leakRef());
+ return toAPI(&toImpl(dictionaryRef)->keys().leakRef());
}
diff --git a/Source/WebKit2/Shared/API/c/WKDictionary.h b/Source/WebKit2/Shared/API/c/WKDictionary.h
index c416e3c29..e486cc2a8 100644
--- a/Source/WebKit2/Shared/API/c/WKDictionary.h
+++ b/Source/WebKit2/Shared/API/c/WKDictionary.h
@@ -26,7 +26,7 @@
#ifndef WKDictionary_h
#define WKDictionary_h
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#include <stddef.h>
diff --git a/Source/WebKit2/Shared/API/c/WKError.cpp b/Source/WebKit2/Shared/API/c/WKErrorRef.cpp
index 315f43e9f..c1e75eb00 100644
--- a/Source/WebKit2/Shared/API/c/WKError.cpp
+++ b/Source/WebKit2/Shared/API/c/WKErrorRef.cpp
@@ -24,7 +24,7 @@
*/
#include "config.h"
-#include "WKError.h"
+#include "WKErrorRef.h"
#include "APIError.h"
#include "WKAPICast.h"
diff --git a/Source/WebKit2/Shared/API/c/WKError.h b/Source/WebKit2/Shared/API/c/WKErrorRef.h
index b099b732c..0d76384d3 100644
--- a/Source/WebKit2/Shared/API/c/WKError.h
+++ b/Source/WebKit2/Shared/API/c/WKErrorRef.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -23,10 +23,10 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef WKError_h
-#define WKError_h
+#ifndef WKErrorRef_h
+#define WKErrorRef_h
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#ifdef __cplusplus
extern "C" {
@@ -37,6 +37,8 @@ enum {
kWKErrorCodeCannotShowURL = 101,
kWKErrorCodeFrameLoadInterruptedByPolicyChange = 102,
kWKErrorCodeCannotUseRestrictedPort = 103,
+ kWKErrorCodeFrameLoadBlockedByContentBlocker = 104,
+ kWKErrorCodeFrameLoadBlockedByContentFilter = 105,
kWKErrorCodeCannotFindPlugIn = 200,
kWKErrorCodeCannotLoadPlugIn = 201,
kWKErrorCodeJavaUnavailable = 202,
@@ -45,7 +47,6 @@ enum {
kWKErrorCodeInsecurePlugInVersion = 205,
kWKErrorInternal = 300,
};
-typedef uint32_t WKErrorCode;
WK_EXPORT WKTypeID WKErrorGetTypeID();
@@ -60,4 +61,4 @@ WK_EXPORT WKStringRef WKErrorCopyLocalizedDescription(WKErrorRef error);
}
#endif
-#endif // WKError_h
+#endif // WKErrorRef_h
diff --git a/Source/WebKit2/Shared/API/c/WKEvent.h b/Source/WebKit2/Shared/API/c/WKEvent.h
index b15c47ad2..477d554c9 100644
--- a/Source/WebKit2/Shared/API/c/WKEvent.h
+++ b/Source/WebKit2/Shared/API/c/WKEvent.h
@@ -26,7 +26,7 @@
#ifndef WKEvent_h
#define WKEvent_h
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#ifdef __cplusplus
extern "C" {
@@ -36,7 +36,8 @@ enum {
kWKEventModifiersShiftKey = 1 << 0,
kWKEventModifiersControlKey = 1 << 1,
kWKEventModifiersAltKey = 1 << 2,
- kWKEventModifiersMetaKey = 1 << 3
+ kWKEventModifiersMetaKey = 1 << 3,
+ kWKEventModifiersCapsLockKey = 1 << 4
};
typedef uint32_t WKEventModifiers;
diff --git a/Source/WebKit2/Shared/API/c/WKGeometry.cpp b/Source/WebKit2/Shared/API/c/WKGeometry.cpp
index 96c3f19f7..e1ea82435 100644
--- a/Source/WebKit2/Shared/API/c/WKGeometry.cpp
+++ b/Source/WebKit2/Shared/API/c/WKGeometry.cpp
@@ -48,17 +48,17 @@ WKTypeID WKRectGetTypeID()
WKPointRef WKPointCreate(WKPoint point)
{
- return toAPI(API::Point::create(point).leakRef());
+ return toAPI(&API::Point::create(point).leakRef());
}
WKSizeRef WKSizeCreate(WKSize size)
{
- return toAPI(API::Size::create(size).leakRef());
+ return toAPI(&API::Size::create(size).leakRef());
}
WKRectRef WKRectCreate(WKRect rect)
{
- return toAPI(API::Rect::create(rect).leakRef());
+ return toAPI(&API::Rect::create(rect).leakRef());
}
WKSize WKSizeGetValue(WKSizeRef size)
diff --git a/Source/WebKit2/Shared/API/c/WKGeometry.h b/Source/WebKit2/Shared/API/c/WKGeometry.h
index 97bf242e9..124fe2498 100644
--- a/Source/WebKit2/Shared/API/c/WKGeometry.h
+++ b/Source/WebKit2/Shared/API/c/WKGeometry.h
@@ -26,7 +26,7 @@
#ifndef WKGeometry_h
#define WKGeometry_h
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#ifdef __cplusplus
extern "C" {
diff --git a/Source/WebKit2/Shared/API/c/WKImage.cpp b/Source/WebKit2/Shared/API/c/WKImage.cpp
index 23278b3a7..2741199e2 100644
--- a/Source/WebKit2/Shared/API/c/WKImage.cpp
+++ b/Source/WebKit2/Shared/API/c/WKImage.cpp
@@ -38,8 +38,8 @@ WKTypeID WKImageGetTypeID()
WKImageRef WKImageCreate(WKSize size, WKImageOptions options)
{
- RefPtr<WebImage> webImage = WebImage::create(toIntSize(size), toImageOptions(options));
- return toAPI(webImage.release().leakRef());
+ auto webImage = WebImage::create(toIntSize(size), toImageOptions(options));
+ return toAPI(webImage.leakRef());
}
WKSize WKImageGetSize(WKImageRef imageRef)
diff --git a/Source/WebKit2/Shared/API/c/WKImage.h b/Source/WebKit2/Shared/API/c/WKImage.h
index 07437bd76..27a34544e 100644
--- a/Source/WebKit2/Shared/API/c/WKImage.h
+++ b/Source/WebKit2/Shared/API/c/WKImage.h
@@ -26,8 +26,8 @@
#ifndef WKImage_h
#define WKImage_h
-#include <WebKit2/WKBase.h>
-#include <WebKit2/WKGeometry.h>
+#include <WebKit/WKBase.h>
+#include <WebKit/WKGeometry.h>
#ifdef __cplusplus
extern "C" {
@@ -42,7 +42,10 @@ enum {
kWKSnapshotOptionsShareable = 1 << 0,
kWKSnapshotOptionsExcludeSelectionHighlighting = 1 << 1,
kWKSnapshotOptionsInViewCoordinates = 1 << 2,
- kWKSnapshotOptionsPaintSelectionRectangle = 1 << 3
+ kWKSnapshotOptionsPaintSelectionRectangle = 1 << 3,
+ kWKSnapshotOptionsForceBlackText = 1 << 4,
+ kWKSnapshotOptionsForceWhiteText = 1 << 5,
+ kWKSnapshotOptionsPrinting = 1 << 6,
};
typedef uint32_t WKSnapshotOptions;
diff --git a/Source/WebKit2/Shared/API/c/WKImmediateActionTypes.h b/Source/WebKit2/Shared/API/c/WKImmediateActionTypes.h
new file mode 100644
index 000000000..5fdc29a9e
--- /dev/null
+++ b/Source/WebKit2/Shared/API/c/WKImmediateActionTypes.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+#ifndef WKImmediateActionTypes_h
+#define WKImmediateActionTypes_h
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum {
+ kWKImmediateActionNone = 0,
+ kWKImmediateActionLinkPreview,
+ kWKImmediateActionDataDetectedItem,
+ kWKImmediateActionLookupText,
+ kWKImmediateActionMailtoLink,
+ kWKImmediateActionTelLink
+};
+
+#ifndef _WKImmediateActionType
+#define _WKImmediateActionType uint32_t
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKImmediateActionTypes_h */
diff --git a/Source/WebKit2/Shared/API/c/WKMutableArray.cpp b/Source/WebKit2/Shared/API/c/WKMutableArray.cpp
index f06782dae..5dc85260f 100644
--- a/Source/WebKit2/Shared/API/c/WKMutableArray.cpp
+++ b/Source/WebKit2/Shared/API/c/WKMutableArray.cpp
@@ -33,7 +33,7 @@ using namespace WebKit;
WKMutableArrayRef WKMutableArrayCreate()
{
- return const_cast<WKMutableArrayRef>(toAPI(API::Array::create().leakRef()));
+ return const_cast<WKMutableArrayRef>(toAPI(&API::Array::create().leakRef()));
}
void WKArrayAppendItem(WKMutableArrayRef arrayRef, WKTypeRef itemRef)
diff --git a/Source/WebKit2/Shared/API/c/WKMutableArray.h b/Source/WebKit2/Shared/API/c/WKMutableArray.h
index 7f05c2830..80bd8c029 100644
--- a/Source/WebKit2/Shared/API/c/WKMutableArray.h
+++ b/Source/WebKit2/Shared/API/c/WKMutableArray.h
@@ -26,7 +26,7 @@
#ifndef WKMutableArray_h
#define WKMutableArray_h
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#include <stddef.h>
#ifndef __cplusplus
diff --git a/Source/WebKit2/Shared/API/c/WKMutableDictionary.cpp b/Source/WebKit2/Shared/API/c/WKMutableDictionary.cpp
index 7ea5a3630..96b89bd45 100644
--- a/Source/WebKit2/Shared/API/c/WKMutableDictionary.cpp
+++ b/Source/WebKit2/Shared/API/c/WKMutableDictionary.cpp
@@ -26,15 +26,14 @@
#include "config.h"
#include "WKMutableDictionary.h"
-#include "MutableDictionary.h"
+#include "APIDictionary.h"
#include "WKAPICast.h"
using namespace WebKit;
WKMutableDictionaryRef WKMutableDictionaryCreate()
{
- RefPtr<MutableDictionary> dictionary = MutableDictionary::create();
- return toAPI(dictionary.release().leakRef());
+ return const_cast<WKMutableDictionaryRef>(toAPI(&API::Dictionary::create().leakRef()));
}
bool WKDictionarySetItem(WKMutableDictionaryRef dictionaryRef, WKStringRef keyRef, WKTypeRef itemRef)
diff --git a/Source/WebKit2/Shared/API/c/WKMutableDictionary.h b/Source/WebKit2/Shared/API/c/WKMutableDictionary.h
index e8297daa8..0c3b33a12 100644
--- a/Source/WebKit2/Shared/API/c/WKMutableDictionary.h
+++ b/Source/WebKit2/Shared/API/c/WKMutableDictionary.h
@@ -26,7 +26,7 @@
#ifndef WKMutableDictionary_h
#define WKMutableDictionary_h
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#ifndef __cplusplus
#include <stdbool.h>
diff --git a/Source/WebKit2/Shared/API/c/WKNumber.cpp b/Source/WebKit2/Shared/API/c/WKNumber.cpp
index 11300632c..418e029ea 100644
--- a/Source/WebKit2/Shared/API/c/WKNumber.cpp
+++ b/Source/WebKit2/Shared/API/c/WKNumber.cpp
@@ -38,8 +38,8 @@ WKTypeID WKBooleanGetTypeID()
WKBooleanRef WKBooleanCreate(bool value)
{
- RefPtr<API::Boolean> booleanObject = API::Boolean::create(value);
- return toAPI(booleanObject.release().leakRef());
+ auto booleanObject = API::Boolean::create(value);
+ return toAPI(&booleanObject.leakRef());
}
bool WKBooleanGetValue(WKBooleanRef booleanRef)
@@ -54,8 +54,8 @@ WKTypeID WKDoubleGetTypeID()
WKDoubleRef WKDoubleCreate(double value)
{
- RefPtr<API::Double> doubleObject = API::Double::create(value);
- return toAPI(doubleObject.release().leakRef());
+ auto doubleObject = API::Double::create(value);
+ return toAPI(&doubleObject.leakRef());
}
double WKDoubleGetValue(WKDoubleRef doubleRef)
@@ -70,8 +70,8 @@ WKTypeID WKUInt64GetTypeID()
WKUInt64Ref WKUInt64Create(uint64_t value)
{
- RefPtr<API::UInt64> uint64Object = API::UInt64::create(value);
- return toAPI(uint64Object.release().leakRef());
+ auto uint64Object = API::UInt64::create(value);
+ return toAPI(&uint64Object.leakRef());
}
uint64_t WKUInt64GetValue(WKUInt64Ref uint64Ref)
diff --git a/Source/WebKit2/Shared/API/c/WKNumber.h b/Source/WebKit2/Shared/API/c/WKNumber.h
index c8c912965..2ebe73a8c 100644
--- a/Source/WebKit2/Shared/API/c/WKNumber.h
+++ b/Source/WebKit2/Shared/API/c/WKNumber.h
@@ -26,7 +26,7 @@
#ifndef WKNumber_h
#define WKNumber_h
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#ifdef __cplusplus
extern "C" {
diff --git a/Source/WebKit2/Shared/API/c/WKPluginInformation.cpp b/Source/WebKit2/Shared/API/c/WKPluginInformation.cpp
index a4a1ce743..e3ae4f5f0 100644
--- a/Source/WebKit2/Shared/API/c/WKPluginInformation.cpp
+++ b/Source/WebKit2/Shared/API/c/WKPluginInformation.cpp
@@ -35,8 +35,8 @@ using namespace WebKit;
WKStringRef WKPluginInformationBundleIdentifierKey()
{
#if ENABLE(NETSCAPE_PLUGIN_API)
- static API::String* key = API::String::create(pluginInformationBundleIdentifierKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(pluginInformationBundleIdentifierKey()).leakRef();
+ return toAPI(&key);
#else
return 0;
#endif
@@ -45,8 +45,8 @@ WKStringRef WKPluginInformationBundleIdentifierKey()
WKStringRef WKPluginInformationBundleVersionKey()
{
#if ENABLE(NETSCAPE_PLUGIN_API)
- static API::String* key = API::String::create(pluginInformationBundleVersionKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(pluginInformationBundleVersionKey()).leakRef();
+ return toAPI(&key);
#else
return 0;
#endif
@@ -55,8 +55,8 @@ WKStringRef WKPluginInformationBundleVersionKey()
WKStringRef WKPluginInformationBundleShortVersionKey()
{
#if ENABLE(NETSCAPE_PLUGIN_API)
- static API::String* key = API::String::create(pluginInformationBundleShortVersionKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(pluginInformationBundleShortVersionKey()).leakRef();
+ return toAPI(&key);
#else
return 0;
#endif
@@ -65,8 +65,8 @@ WKStringRef WKPluginInformationBundleShortVersionKey()
WKStringRef WKPluginInformationPathKey()
{
#if ENABLE(NETSCAPE_PLUGIN_API)
- static API::String* key = API::String::create(pluginInformationPathKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(pluginInformationPathKey()).leakRef();
+ return toAPI(&key);
#else
return 0;
#endif
@@ -75,8 +75,8 @@ WKStringRef WKPluginInformationPathKey()
WKStringRef WKPluginInformationDisplayNameKey()
{
#if ENABLE(NETSCAPE_PLUGIN_API)
- static API::String* key = API::String::create(pluginInformationDisplayNameKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(pluginInformationDisplayNameKey()).leakRef();
+ return toAPI(&key);
#else
return 0;
#endif
@@ -85,8 +85,8 @@ WKStringRef WKPluginInformationDisplayNameKey()
WKStringRef WKPluginInformationDefaultLoadPolicyKey()
{
#if ENABLE(NETSCAPE_PLUGIN_API)
- static API::String* key = API::String::create(pluginInformationDefaultLoadPolicyKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(pluginInformationDefaultLoadPolicyKey()).leakRef();
+ return toAPI(&key);
#else
return 0;
#endif
@@ -95,8 +95,8 @@ WKStringRef WKPluginInformationDefaultLoadPolicyKey()
WKStringRef WKPluginInformationUpdatePastLastBlockedVersionIsKnownAvailableKey()
{
#if ENABLE(NETSCAPE_PLUGIN_API)
- static API::String* key = API::String::create(pluginInformationUpdatePastLastBlockedVersionIsKnownAvailableKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(pluginInformationUpdatePastLastBlockedVersionIsKnownAvailableKey()).leakRef();
+ return toAPI(&key);
#else
return 0;
#endif
@@ -105,8 +105,8 @@ WKStringRef WKPluginInformationUpdatePastLastBlockedVersionIsKnownAvailableKey()
WKStringRef WKPluginInformationHasSandboxProfileKey()
{
#if ENABLE(NETSCAPE_PLUGIN_API)
- static API::String* key = API::String::create(pluginInformationHasSandboxProfileKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(pluginInformationHasSandboxProfileKey()).leakRef();
+ return toAPI(&key);
#else
return 0;
#endif
@@ -115,8 +115,8 @@ WKStringRef WKPluginInformationHasSandboxProfileKey()
WKStringRef WKPluginInformationFrameURLKey()
{
#if ENABLE(NETSCAPE_PLUGIN_API)
- static API::String* key = API::String::create(pluginInformationFrameURLKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(pluginInformationFrameURLKey()).leakRef();
+ return toAPI(&key);
#else
return 0;
#endif
@@ -125,8 +125,8 @@ WKStringRef WKPluginInformationFrameURLKey()
WKStringRef WKPluginInformationMIMETypeKey()
{
#if ENABLE(NETSCAPE_PLUGIN_API)
- static API::String* key = API::String::create(pluginInformationMIMETypeKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(pluginInformationMIMETypeKey()).leakRef();
+ return toAPI(&key);
#else
return 0;
#endif
@@ -135,8 +135,8 @@ WKStringRef WKPluginInformationMIMETypeKey()
WKStringRef WKPluginInformationPageURLKey()
{
#if ENABLE(NETSCAPE_PLUGIN_API)
- static API::String* key = API::String::create(pluginInformationPageURLKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(pluginInformationPageURLKey()).leakRef();
+ return toAPI(&key);
#else
return 0;
#endif
@@ -145,8 +145,8 @@ WKStringRef WKPluginInformationPageURLKey()
WKStringRef WKPluginInformationPluginspageAttributeURLKey()
{
#if ENABLE(NETSCAPE_PLUGIN_API)
- static API::String* key = API::String::create(pluginInformationPluginspageAttributeURLKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(pluginInformationPluginspageAttributeURLKey()).leakRef();
+ return toAPI(&key);
#else
return 0;
#endif
@@ -155,8 +155,8 @@ WKStringRef WKPluginInformationPluginspageAttributeURLKey()
WKStringRef WKPluginInformationPluginURLKey()
{
#if ENABLE(NETSCAPE_PLUGIN_API)
- static API::String* key = API::String::create(pluginInformationPluginURLKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(pluginInformationPluginURLKey()).leakRef();
+ return toAPI(&key);
#else
return 0;
#endif
@@ -165,8 +165,8 @@ WKStringRef WKPluginInformationPluginURLKey()
WKStringRef WKPlugInInformationReplacementObscuredKey()
{
#if ENABLE(NETSCAPE_PLUGIN_API)
- static API::String* key = API::String::create(plugInInformationReplacementObscuredKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(plugInInformationReplacementObscuredKey()).leakRef();
+ return toAPI(&key);
#else
return 0;
#endif
diff --git a/Source/WebKit2/Shared/API/c/WKPluginInformation.h b/Source/WebKit2/Shared/API/c/WKPluginInformation.h
index 0bcaef192..08970844b 100644
--- a/Source/WebKit2/Shared/API/c/WKPluginInformation.h
+++ b/Source/WebKit2/Shared/API/c/WKPluginInformation.h
@@ -26,7 +26,7 @@
#ifndef WKPluginInformation_h
#define WKPluginInformation_h
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#ifdef __cplusplus
extern "C" {
diff --git a/Source/WebKit2/Shared/API/c/WKRenderLayer.cpp b/Source/WebKit2/Shared/API/c/WKRenderLayer.cpp
index 82cf959be..da21e69aa 100644
--- a/Source/WebKit2/Shared/API/c/WKRenderLayer.cpp
+++ b/Source/WebKit2/Shared/API/c/WKRenderLayer.cpp
@@ -53,7 +53,7 @@ WKStringRef WKRenderLayerCopyElementTagName(WKRenderLayerRef renderLayerRef)
if (!renderLayer->renderer()->elementTagName().isNull())
return toCopiedAPI(renderLayer->renderer()->elementTagName());
- return 0;
+ return nullptr;
}
WKStringRef WKRenderLayerCopyElementID(WKRenderLayerRef renderLayerRef)
@@ -62,7 +62,7 @@ WKStringRef WKRenderLayerCopyElementID(WKRenderLayerRef renderLayerRef)
if (!renderLayer->renderer()->elementID().isNull())
return toCopiedAPI(renderLayer->renderer()->elementID());
- return 0;
+ return nullptr;
}
WKArrayRef WKRenderLayerGetElementClassNames(WKRenderLayerRef renderLayerRef)
@@ -110,6 +110,11 @@ WKCompositingLayerType WKRenderLayerGetCompositingLayerType(WKRenderLayerRef ren
return kWKCompositingLayerTypeNone;
}
+WK_EXPORT double WKRenderLayerGetBackingStoreMemoryEstimate(WKRenderLayerRef renderLayerRef)
+{
+ return toImpl(renderLayerRef)->backingStoreMemoryEstimate();
+}
+
WKArrayRef WKRenderLayerGetNegativeZOrderList(WKRenderLayerRef renderLayerRef)
{
return toAPI(toImpl(renderLayerRef)->negativeZOrderList());
@@ -124,3 +129,8 @@ WKArrayRef WKRenderLayerGetPositiveZOrderList(WKRenderLayerRef renderLayerRef)
{
return toAPI(toImpl(renderLayerRef)->positiveZOrderList());
}
+
+WKRenderLayerRef WKRenderLayerGetFrameContentsLayer(WKRenderLayerRef renderLayerRef)
+{
+ return toAPI(toImpl(renderLayerRef)->frameContentsLayer());
+}
diff --git a/Source/WebKit2/Shared/API/c/WKRenderLayer.h b/Source/WebKit2/Shared/API/c/WKRenderLayer.h
index 72f28e0b9..7aeae7855 100644
--- a/Source/WebKit2/Shared/API/c/WKRenderLayer.h
+++ b/Source/WebKit2/Shared/API/c/WKRenderLayer.h
@@ -27,8 +27,8 @@
#define WKRenderLayer_h
-#include <WebKit2/WKBase.h>
-#include <WebKit2/WKGeometry.h>
+#include <WebKit/WKBase.h>
+#include <WebKit/WKGeometry.h>
#ifdef __cplusplus
extern "C" {
@@ -38,7 +38,7 @@ WK_EXPORT WKTypeID WKRenderLayerGetTypeID();
WK_EXPORT WKRenderObjectRef WKRenderLayerGetRenderer(WKRenderLayerRef renderLayer);
-// FIXME: Remove this function once Safari does not require it.
+// FIXME: Remove this function once Safari does not require it. Clients can access this data via the renderer.
WK_EXPORT WKStringRef WKRenderLayerCopyRendererName(WKRenderLayerRef renderLayer);
// FIXME: Remove these three functions once Safari does not require them.
@@ -62,11 +62,14 @@ enum WKCompositingLayerType {
typedef enum WKCompositingLayerType WKCompositingLayerType;
WK_EXPORT WKCompositingLayerType WKRenderLayerGetCompositingLayerType(WKRenderLayerRef renderLayer);
+WK_EXPORT double WKRenderLayerGetBackingStoreMemoryEstimate(WKRenderLayerRef renderLayer);
WK_EXPORT WKArrayRef WKRenderLayerGetNegativeZOrderList(WKRenderLayerRef renderLayer);
WK_EXPORT WKArrayRef WKRenderLayerGetNormalFlowList(WKRenderLayerRef renderLayer);
WK_EXPORT WKArrayRef WKRenderLayerGetPositiveZOrderList(WKRenderLayerRef renderLayer);
+WK_EXPORT WKRenderLayerRef WKRenderLayerGetFrameContentsLayer(WKRenderLayerRef renderLayer);
+
#ifdef __cplusplus
}
#endif
diff --git a/Source/WebKit2/Shared/API/c/WKRenderObject.cpp b/Source/WebKit2/Shared/API/c/WKRenderObject.cpp
index 864b6e7ad..df2e743dd 100644
--- a/Source/WebKit2/Shared/API/c/WKRenderObject.cpp
+++ b/Source/WebKit2/Shared/API/c/WKRenderObject.cpp
@@ -42,13 +42,27 @@ WKStringRef WKRenderObjectCopyName(WKRenderObjectRef renderObjectRef)
return toCopiedAPI(toImpl(renderObjectRef)->name());
}
+WKStringRef WKRenderObjectCopyTextSnippet(WKRenderObjectRef renderObjectRef)
+{
+ WebRenderObject* renderObject = toImpl(renderObjectRef);
+ if (!renderObject->textSnippet().isNull())
+ return toCopiedAPI(renderObject->textSnippet());
+
+ return nullptr;
+}
+
+unsigned WKRenderObjectGetTextLength(WKRenderObjectRef renderObjectRef)
+{
+ return toImpl(renderObjectRef)->textLength();
+}
+
WKStringRef WKRenderObjectCopyElementTagName(WKRenderObjectRef renderObjectRef)
{
WebRenderObject* renderObject = toImpl(renderObjectRef);
if (!renderObject->elementTagName().isNull())
return toCopiedAPI(renderObject->elementTagName());
- return 0;
+ return nullptr;
}
WKStringRef WKRenderObjectCopyElementID(WKRenderObjectRef renderObjectRef)
@@ -57,7 +71,7 @@ WKStringRef WKRenderObjectCopyElementID(WKRenderObjectRef renderObjectRef)
if (!renderObject->elementID().isNull())
return toCopiedAPI(renderObject->elementID());
- return 0;
+ return nullptr;
}
WKArrayRef WKRenderObjectGetElementClassNames(WKRenderObjectRef renderObjectRef)
diff --git a/Source/WebKit2/Shared/API/c/WKRenderObject.h b/Source/WebKit2/Shared/API/c/WKRenderObject.h
index 965cf2a96..0973ae8cf 100644
--- a/Source/WebKit2/Shared/API/c/WKRenderObject.h
+++ b/Source/WebKit2/Shared/API/c/WKRenderObject.h
@@ -26,8 +26,8 @@
#ifndef WKRenderObject_h
#define WKRenderObject_h
-#include <WebKit2/WKBase.h>
-#include <WebKit2/WKGeometry.h>
+#include <WebKit/WKBase.h>
+#include <WebKit/WKGeometry.h>
#ifdef __cplusplus
extern "C" {
@@ -36,7 +36,8 @@ extern "C" {
WK_EXPORT WKTypeID WKRenderObjectGetTypeID();
WK_EXPORT WKStringRef WKRenderObjectCopyName(WKRenderObjectRef renderObject);
-
+WK_EXPORT WKStringRef WKRenderObjectCopyTextSnippet(WKRenderObjectRef renderObject);
+WK_EXPORT unsigned WKRenderObjectGetTextLength(WKRenderObjectRef renderObject);
WK_EXPORT WKStringRef WKRenderObjectCopyElementTagName(WKRenderObjectRef renderObject);
WK_EXPORT WKStringRef WKRenderObjectCopyElementID(WKRenderObjectRef renderObject);
WK_EXPORT WKArrayRef WKRenderObjectGetElementClassNames(WKRenderObjectRef renderObject);
diff --git a/Source/WebKit2/Shared/API/c/WKSecurityOrigin.cpp b/Source/WebKit2/Shared/API/c/WKSecurityOriginRef.cpp
index f7291065f..d1160740c 100644
--- a/Source/WebKit2/Shared/API/c/WKSecurityOrigin.cpp
+++ b/Source/WebKit2/Shared/API/c/WKSecurityOriginRef.cpp
@@ -24,59 +24,61 @@
*/
#include "config.h"
-#include "WKSecurityOrigin.h"
+#include "WKSecurityOriginRef.h"
+#include "APISecurityOrigin.h"
#include "WKAPICast.h"
-#include "WebSecurityOrigin.h"
+#include <WebCore/SecurityOriginData.h>
using namespace WebKit;
WKTypeID WKSecurityOriginGetTypeID()
{
- return toAPI(WebSecurityOrigin::APIType);
+ return toAPI(API::SecurityOrigin::APIType);
}
WKSecurityOriginRef WKSecurityOriginCreateFromString(WKStringRef string)
{
- RefPtr<WebSecurityOrigin> securityOrigin = WebSecurityOrigin::createFromString(toImpl(string)->string());
- return toAPI(securityOrigin.release().leakRef());
+ return toAPI(API::SecurityOrigin::create(WebCore::SecurityOrigin::createFromString(toImpl(string)->string())).leakRef());
}
WKSecurityOriginRef WKSecurityOriginCreateFromDatabaseIdentifier(WKStringRef identifier)
{
- RefPtr<WebSecurityOrigin> securityOrigin = WebSecurityOrigin::createFromDatabaseIdentifier(toImpl(identifier)->string());
- return toAPI(securityOrigin.release().leakRef());
+ auto origin = WebCore::SecurityOriginData::fromDatabaseIdentifier(toImpl(identifier)->string());
+ if (!origin)
+ return nullptr;
+ return toAPI(API::SecurityOrigin::create(origin.value().securityOrigin()).leakRef());
}
WKSecurityOriginRef WKSecurityOriginCreate(WKStringRef protocol, WKStringRef host, int port)
{
- RefPtr<WebSecurityOrigin> securityOrigin = WebSecurityOrigin::create(toImpl(protocol)->string(), toImpl(host)->string(), port);
- return toAPI(securityOrigin.release().leakRef());
+ auto securityOrigin = API::SecurityOrigin::create(toImpl(protocol)->string(), toImpl(host)->string(), port);
+ return toAPI(securityOrigin.leakRef());
}
WKStringRef WKSecurityOriginCopyDatabaseIdentifier(WKSecurityOriginRef securityOrigin)
{
- return toCopiedAPI(toImpl(securityOrigin)->databaseIdentifier());
+ return toCopiedAPI(WebCore::SecurityOriginData::fromSecurityOrigin(toImpl(securityOrigin)->securityOrigin()).databaseIdentifier());
}
WKStringRef WKSecurityOriginCopyToString(WKSecurityOriginRef securityOrigin)
{
- return toCopiedAPI(toImpl(securityOrigin)->toString());
+ return toCopiedAPI(toImpl(securityOrigin)->securityOrigin().toString());
}
WKStringRef WKSecurityOriginCopyProtocol(WKSecurityOriginRef securityOrigin)
{
- return toCopiedAPI(toImpl(securityOrigin)->protocol());
+ return toCopiedAPI(toImpl(securityOrigin)->securityOrigin().protocol());
}
WKStringRef WKSecurityOriginCopyHost(WKSecurityOriginRef securityOrigin)
{
- return toCopiedAPI(toImpl(securityOrigin)->host());
+ return toCopiedAPI(toImpl(securityOrigin)->securityOrigin().host());
}
unsigned short WKSecurityOriginGetPort(WKSecurityOriginRef securityOrigin)
{
- return toImpl(securityOrigin)->port();
+ return toImpl(securityOrigin)->securityOrigin().port().value_or(0);
}
// For backwards ABI compatibility.
diff --git a/Source/WebKit2/Shared/API/c/WKSecurityOrigin.h b/Source/WebKit2/Shared/API/c/WKSecurityOriginRef.h
index d932e93a4..3c3356b38 100644
--- a/Source/WebKit2/Shared/API/c/WKSecurityOrigin.h
+++ b/Source/WebKit2/Shared/API/c/WKSecurityOriginRef.h
@@ -23,10 +23,10 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef WKSecurityOrigin_h
-#define WKSecurityOrigin_h
+#ifndef WKSecurityOriginRef_h
+#define WKSecurityOriginRef_h
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#ifdef __cplusplus
extern "C" {
@@ -48,4 +48,4 @@ WK_EXPORT unsigned short WKSecurityOriginGetPort(WKSecurityOriginRef securityOri
}
#endif
-#endif /* WKSecurityOrigin_h */
+#endif /* WKSecurityOriginRef_h */
diff --git a/Source/WebKit2/Shared/API/c/WKSerializedScriptValue.cpp b/Source/WebKit2/Shared/API/c/WKSerializedScriptValue.cpp
index f45c388e9..862fd7f60 100644
--- a/Source/WebKit2/Shared/API/c/WKSerializedScriptValue.cpp
+++ b/Source/WebKit2/Shared/API/c/WKSerializedScriptValue.cpp
@@ -27,26 +27,26 @@
#include "WKSerializedScriptValue.h"
#include "WKSerializedScriptValuePrivate.h"
+#include "APISerializedScriptValue.h"
#include "WKAPICast.h"
-#include "WebSerializedScriptValue.h"
using namespace WebKit;
WKTypeID WKSerializedScriptValueGetTypeID()
{
- return toAPI(WebSerializedScriptValue::APIType);
+ return toAPI(API::SerializedScriptValue::APIType);
}
WKSerializedScriptValueRef WKSerializedScriptValueCreate(JSContextRef context, JSValueRef value, JSValueRef* exception)
{
- RefPtr<WebSerializedScriptValue> serializedValue = WebSerializedScriptValue::create(context, value, exception);
- return toAPI(serializedValue.release().leakRef());
+ auto serializedValue = API::SerializedScriptValue::create(context, value, exception);
+ return toAPI(serializedValue.leakRef());
}
WKSerializedScriptValueRef WKSerializedScriptValueCreateWithInternalRepresentation(void* internalRepresentation)
{
- RefPtr<WebSerializedScriptValue> serializedValue = WebSerializedScriptValue::create(static_cast<WebCore::SerializedScriptValue*>(internalRepresentation));
- return toAPI(serializedValue.release().leakRef());
+ auto serializedValue = API::SerializedScriptValue::create(static_cast<WebCore::SerializedScriptValue*>(internalRepresentation));
+ return toAPI(&serializedValue.leakRef());
}
JSValueRef WKSerializedScriptValueDeserialize(WKSerializedScriptValueRef scriptValueRef, JSContextRef contextRef, JSValueRef* exception)
diff --git a/Source/WebKit2/Shared/API/c/WKSerializedScriptValue.h b/Source/WebKit2/Shared/API/c/WKSerializedScriptValue.h
index 3f73d7a06..625afe05b 100644
--- a/Source/WebKit2/Shared/API/c/WKSerializedScriptValue.h
+++ b/Source/WebKit2/Shared/API/c/WKSerializedScriptValue.h
@@ -27,7 +27,7 @@
#define WKSerializedScriptValue_h
#include <JavaScriptCore/JavaScript.h>
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#ifdef __cplusplus
extern "C" {
diff --git a/Source/WebKit2/Shared/API/c/WKSerializedScriptValuePrivate.h b/Source/WebKit2/Shared/API/c/WKSerializedScriptValuePrivate.h
index 27e184906..837067fb7 100644
--- a/Source/WebKit2/Shared/API/c/WKSerializedScriptValuePrivate.h
+++ b/Source/WebKit2/Shared/API/c/WKSerializedScriptValuePrivate.h
@@ -26,7 +26,7 @@
#ifndef WKSerializedScriptValuePrivate_h
#define WKSerializedScriptValuePrivate_h
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#ifdef __cplusplus
extern "C" {
diff --git a/Source/WebKit2/Shared/API/c/WKSharedAPICast.h b/Source/WebKit2/Shared/API/c/WKSharedAPICast.h
index 8439dbca4..864baff16 100644
--- a/Source/WebKit2/Shared/API/c/WKSharedAPICast.h
+++ b/Source/WebKit2/Shared/API/c/WKSharedAPICast.h
@@ -28,7 +28,7 @@
#include "APIError.h"
#include "APINumber.h"
-#include "APISession.h"
+#include "APISecurityOrigin.h"
#include "APIString.h"
#include "APIURL.h"
#include "APIURLRequest.h"
@@ -37,6 +37,7 @@
#include "SameDocumentNavigationType.h"
#include "WKBase.h"
#include "WKContextMenuItemTypes.h"
+#include "WKDiagnosticLoggingResultType.h"
#include "WKEvent.h"
#include "WKFindOptions.h"
#include "WKGeometry.h"
@@ -48,8 +49,8 @@
#include "WKUserScriptInjectionTime.h"
#include "WebEvent.h"
#include "WebFindOptions.h"
-#include "WebSecurityOrigin.h"
#include <WebCore/ContextMenuItem.h>
+#include <WebCore/DiagnosticLoggingResultType.h>
#include <WebCore/FloatRect.h>
#include <WebCore/FrameLoaderTypes.h>
#include <WebCore/IntRect.h>
@@ -61,34 +62,32 @@
namespace API {
class Array;
+class Dictionary;
class Data;
class Point;
class Rect;
+class SecurityOrigin;
+class SerializedScriptValue;
class Size;
+class UserContentURLPattern;
+class WebArchive;
+class WebArchiveResource;
}
namespace WebKit {
-class ImmutableDictionary;
-class MutableDictionary;
class ObjCObjectGraph;
-class WebArchive;
-class WebArchiveResource;
class WebCertificateInfo;
class WebConnection;
class WebContextMenuItem;
-class WebGraphicsContext;
class WebImage;
-class WebSecurityOrigin;
-class WebSerializedScriptValue;
-class WebUserContentURLPattern;
-template<typename APIType> struct APITypeInfo { };
-template<typename ImplType> struct ImplTypeInfo { };
+template<typename APIType> struct APITypeInfo;
+template<typename ImplType> struct ImplTypeInfo;
#define WK_ADD_API_MAPPING(TheAPIType, TheImplType) \
- template<> struct APITypeInfo<TheAPIType> { typedef TheImplType* ImplType; }; \
- template<> struct ImplTypeInfo<TheImplType*> { typedef TheAPIType APIType; };
+ template<> struct APITypeInfo<TheAPIType> { typedef TheImplType ImplType; }; \
+ template<> struct ImplTypeInfo<TheImplType> { typedef TheAPIType APIType; };
WK_ADD_API_MAPPING(WKArrayRef, API::Array)
WK_ADD_API_MAPPING(WKBooleanRef, API::Boolean)
@@ -96,16 +95,14 @@ WK_ADD_API_MAPPING(WKCertificateInfoRef, WebCertificateInfo)
WK_ADD_API_MAPPING(WKConnectionRef, WebConnection)
WK_ADD_API_MAPPING(WKContextMenuItemRef, WebContextMenuItem)
WK_ADD_API_MAPPING(WKDataRef, API::Data)
-WK_ADD_API_MAPPING(WKDictionaryRef, ImmutableDictionary)
+WK_ADD_API_MAPPING(WKDictionaryRef, API::Dictionary)
WK_ADD_API_MAPPING(WKDoubleRef, API::Double)
WK_ADD_API_MAPPING(WKErrorRef, API::Error)
-WK_ADD_API_MAPPING(WKGraphicsContextRef, WebGraphicsContext)
WK_ADD_API_MAPPING(WKImageRef, WebImage)
-WK_ADD_API_MAPPING(WKMutableDictionaryRef, MutableDictionary)
WK_ADD_API_MAPPING(WKPointRef, API::Point)
WK_ADD_API_MAPPING(WKRectRef, API::Rect)
-WK_ADD_API_MAPPING(WKSecurityOriginRef, WebSecurityOrigin)
-WK_ADD_API_MAPPING(WKSerializedScriptValueRef, WebSerializedScriptValue)
+WK_ADD_API_MAPPING(WKSecurityOriginRef, API::SecurityOrigin)
+WK_ADD_API_MAPPING(WKSerializedScriptValueRef, API::SerializedScriptValue)
WK_ADD_API_MAPPING(WKSizeRef, API::Size)
WK_ADD_API_MAPPING(WKStringRef, API::String)
WK_ADD_API_MAPPING(WKTypeRef, API::Object)
@@ -113,24 +110,30 @@ WK_ADD_API_MAPPING(WKUInt64Ref, API::UInt64)
WK_ADD_API_MAPPING(WKURLRef, API::URL)
WK_ADD_API_MAPPING(WKURLRequestRef, API::URLRequest)
WK_ADD_API_MAPPING(WKURLResponseRef, API::URLResponse)
-WK_ADD_API_MAPPING(WKUserContentURLPatternRef, WebUserContentURLPattern)
-WK_ADD_API_MAPPING(WKSessionRef, API::Session)
+WK_ADD_API_MAPPING(WKUserContentURLPatternRef, API::UserContentURLPattern)
-template<> struct APITypeInfo<WKMutableArrayRef> { typedef API::Array* ImplType; };
+template<> struct APITypeInfo<WKMutableArrayRef> { typedef API::Array ImplType; };
+template<> struct APITypeInfo<WKMutableDictionaryRef> { typedef API::Dictionary ImplType; };
-#if PLATFORM(MAC)
-WK_ADD_API_MAPPING(WKWebArchiveRef, WebArchive)
-WK_ADD_API_MAPPING(WKWebArchiveResourceRef, WebArchiveResource)
+#if PLATFORM(COCOA)
+WK_ADD_API_MAPPING(WKWebArchiveRef, API::WebArchive)
+WK_ADD_API_MAPPING(WKWebArchiveResourceRef, API::WebArchiveResource)
WK_ADD_API_MAPPING(WKObjCTypeWrapperRef, ObjCObjectGraph)
#endif
-template<typename T>
-inline typename ImplTypeInfo<T>::APIType toAPI(T t)
+template<typename T, typename APIType = typename ImplTypeInfo<T>::APIType>
+auto toAPI(T* t) -> APIType
+{
+ return reinterpret_cast<APIType>(API::Object::wrap(t));
+}
+
+template<typename T, typename ImplType = typename APITypeInfo<T>::ImplType>
+auto toImpl(T t) -> ImplType*
{
- return reinterpret_cast<typename ImplTypeInfo<T>::APIType>(t);
+ return static_cast<ImplType*>(API::Object::unwrap(static_cast<void*>(const_cast<typename std::remove_const<typename std::remove_pointer<T>::type>::type*>(t))));
}
-template<typename ImplType, typename APIType = typename ImplTypeInfo<ImplType*>::APIType>
+template<typename ImplType, typename APIType = typename ImplTypeInfo<ImplType>::APIType>
class ProxyingRefPtr {
public:
ProxyingRefPtr(PassRefPtr<ImplType> impl)
@@ -138,26 +141,17 @@ public:
{
}
+ ProxyingRefPtr(Ref<ImplType>&& impl)
+ : m_impl(WTFMove(impl))
+ {
+ }
+
operator APIType() { return toAPI(m_impl.get()); }
private:
RefPtr<ImplType> m_impl;
};
-/* Opaque typing convenience methods */
-
-template<typename T>
-inline typename APITypeInfo<T>::ImplType toImpl(T t)
-{
- // An example of the conversions that take place:
- // const struct OpaqueWKArray* -> const struct OpaqueWKArray -> struct OpaqueWKArray -> struct OpaqueWKArray* -> API::Array*
-
- typedef typename std::remove_pointer<T>::type PotentiallyConstValueType;
- typedef typename std::remove_const<PotentiallyConstValueType>::type NonConstValueType;
-
- return reinterpret_cast<typename APITypeInfo<T>::ImplType>(const_cast<NonConstValueType*>(t));
-}
-
/* Special cases. */
inline ProxyingRefPtr<API::String> toAPI(StringImpl* string)
@@ -167,23 +161,21 @@ inline ProxyingRefPtr<API::String> toAPI(StringImpl* string)
inline WKStringRef toCopiedAPI(const String& string)
{
- RefPtr<API::String> apiString = API::String::create(string);
- return toAPI(apiString.release().leakRef());
+ return toAPI(&API::String::create(string).leakRef());
}
inline ProxyingRefPtr<API::URL> toURLRef(StringImpl* string)
{
if (!string)
- return ProxyingRefPtr<API::URL>(0);
+ return ProxyingRefPtr<API::URL>(nullptr);
return ProxyingRefPtr<API::URL>(API::URL::create(String(string)));
}
inline WKURLRef toCopiedURLAPI(const String& string)
{
if (!string)
- return 0;
- RefPtr<API::URL> url = API::URL::create(string);
- return toAPI(url.release().leakRef());
+ return nullptr;
+ return toAPI(&API::URL::create(string).leakRef());
}
inline String toWTFString(WKStringRef stringRef)
@@ -219,7 +211,7 @@ inline WKSecurityOriginRef toCopiedAPI(WebCore::SecurityOrigin* origin)
{
if (!origin)
return 0;
- return toAPI(WebSecurityOrigin::create(origin).leakRef());
+ return toAPI(API::SecurityOrigin::create(*origin).leakRef());
}
/* Geometry conversions */
@@ -300,6 +292,8 @@ inline WKEventModifiers toAPI(WebEvent::Modifiers modifiers)
wkModifiers |= kWKEventModifiersAltKey;
if (modifiers & WebEvent::MetaKey)
wkModifiers |= kWKEventModifiersMetaKey;
+ if (modifiers & WebEvent::CapsLockKey)
+ wkModifiers |= kWKEventModifiersCapsLockKey;
return wkModifiers;
}
@@ -342,7 +336,7 @@ inline WKContextMenuItemTag toAPI(WebCore::ContextMenuAction action)
return kWKContextMenuItemTagDownloadImageToDisk;
case WebCore::ContextMenuItemTagCopyImageToClipboard:
return kWKContextMenuItemTagCopyImageToClipboard;
-#if PLATFORM(EFL) || PLATFORM(GTK)
+#if PLATFORM(GTK)
case WebCore::ContextMenuItemTagCopyImageUrlToClipboard:
return kWKContextMenuItemTagCopyImageUrlToClipboard;
#endif
@@ -362,7 +356,7 @@ inline WKContextMenuItemTag toAPI(WebCore::ContextMenuAction action)
return kWKContextMenuItemTagCut;
case WebCore::ContextMenuItemTagPaste:
return kWKContextMenuItemTagPaste;
-#if PLATFORM(EFL) || PLATFORM(GTK)
+#if PLATFORM(GTK)
case WebCore::ContextMenuItemTagSelectAll:
return kWKContextMenuItemTagSelectAll;
#endif
@@ -452,10 +446,8 @@ inline WKContextMenuItemTag toAPI(WebCore::ContextMenuAction action)
return kWKContextMenuItemTagPDFFacingPagesScrolling;
case WebCore::ContextMenuItemTagDictationAlternative:
return kWKContextMenuItemTagDictationAlternative;
-#if ENABLE(INSPECTOR)
case WebCore::ContextMenuItemTagInspectElement:
return kWKContextMenuItemTagInspectElement;
-#endif
case WebCore::ContextMenuItemTagTextDirectionMenu:
return kWKContextMenuItemTagTextDirectionMenu;
case WebCore::ContextMenuItemTagTextDirectionDefault:
@@ -478,11 +470,13 @@ inline WKContextMenuItemTag toAPI(WebCore::ContextMenuAction action)
return kWKContextMenuItemTagToggleVideoFullscreen;
case WebCore::ContextMenuItemTagEnterVideoFullscreen:
return kWKContextMenuItemTagEnterVideoFullscreen;
+ case WebCore::ContextMenuItemTagToggleVideoEnhancedFullscreen:
+ return kWKContextMenuItemTagToggleVideoEnhancedFullscreen;
case WebCore::ContextMenuItemTagMediaPlayPause:
return kWKContextMenuItemTagMediaPlayPause;
case WebCore::ContextMenuItemTagMediaMute:
return kWKContextMenuItemTagMediaMute;
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
case WebCore::ContextMenuItemTagCorrectSpellingAutomatically:
return kWKContextMenuItemTagCorrectSpellingAutomatically;
case WebCore::ContextMenuItemTagSubstitutionsMenu:
@@ -510,11 +504,11 @@ inline WKContextMenuItemTag toAPI(WebCore::ContextMenuAction action)
case WebCore::ContextMenuItemTagChangeBack:
return kWKContextMenuItemTagChangeBack;
#endif
- case WebCore::ContextMenuItemTagOpenLinkInThisWindow:
- return kWKContextMenuItemTagOpenLinkInThisWindow;
+ case WebCore::ContextMenuItemTagShareMenu:
+ return kWKContextMenuItemTagShareMenu;
default:
- if (action < WebCore::ContextMenuItemBaseApplicationTag)
- LOG_ERROR("ContextMenuAction %i is an unknown tag but is below the allowable custom tag value of %i", action, WebCore:: ContextMenuItemBaseApplicationTag);
+ if (action < WebCore::ContextMenuItemBaseApplicationTag && !(action >= WebCore::ContextMenuItemBaseCustomTag && action <= WebCore::ContextMenuItemLastCustomTag))
+ LOG_ERROR("ContextMenuAction %i is an unknown tag but is below the allowable custom tag value of %i", action, WebCore::ContextMenuItemBaseApplicationTag);
return static_cast<WKContextMenuItemTag>(action);
}
}
@@ -537,7 +531,7 @@ inline WebCore::ContextMenuAction toImpl(WKContextMenuItemTag tag)
case kWKContextMenuItemTagCopyImageToClipboard:
return WebCore::ContextMenuItemTagCopyImageToClipboard;
case kWKContextMenuItemTagOpenFrameInNewWindow:
-#if PLATFORM(EFL) || PLATFORM(GTK)
+#if PLATFORM(GTK)
case kWKContextMenuItemTagCopyImageUrlToClipboard:
return WebCore::ContextMenuItemTagCopyImageUrlToClipboard;
#endif
@@ -556,7 +550,7 @@ inline WebCore::ContextMenuAction toImpl(WKContextMenuItemTag tag)
return WebCore::ContextMenuItemTagCut;
case kWKContextMenuItemTagPaste:
return WebCore::ContextMenuItemTagPaste;
-#if PLATFORM(EFL) || PLATFORM(GTK)
+#if PLATFORM(GTK)
case kWKContextMenuItemTagSelectAll:
return WebCore::ContextMenuItemTagSelectAll;
#endif
@@ -646,10 +640,8 @@ inline WebCore::ContextMenuAction toImpl(WKContextMenuItemTag tag)
return WebCore::ContextMenuItemTagPDFFacingPagesScrolling;
case kWKContextMenuItemTagDictationAlternative:
return WebCore::ContextMenuItemTagDictationAlternative;
-#if ENABLE(INSPECTOR)
case kWKContextMenuItemTagInspectElement:
return WebCore::ContextMenuItemTagInspectElement;
-#endif
case kWKContextMenuItemTagTextDirectionMenu:
return WebCore::ContextMenuItemTagTextDirectionMenu;
case kWKContextMenuItemTagTextDirectionDefault:
@@ -672,11 +664,13 @@ inline WebCore::ContextMenuAction toImpl(WKContextMenuItemTag tag)
return WebCore::ContextMenuItemTagToggleVideoFullscreen;
case kWKContextMenuItemTagEnterVideoFullscreen:
return WebCore::ContextMenuItemTagEnterVideoFullscreen;
+ case kWKContextMenuItemTagToggleVideoEnhancedFullscreen:
+ return WebCore::ContextMenuItemTagToggleVideoEnhancedFullscreen;
case kWKContextMenuItemTagMediaPlayPause:
return WebCore::ContextMenuItemTagMediaPlayPause;
case kWKContextMenuItemTagMediaMute:
return WebCore::ContextMenuItemTagMediaMute;
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
case kWKContextMenuItemTagCorrectSpellingAutomatically:
return WebCore::ContextMenuItemTagCorrectSpellingAutomatically;
case kWKContextMenuItemTagSubstitutionsMenu:
@@ -703,11 +697,12 @@ inline WebCore::ContextMenuAction toImpl(WKContextMenuItemTag tag)
return WebCore::ContextMenuItemTagCapitalize;
case kWKContextMenuItemTagChangeBack:
return WebCore::ContextMenuItemTagChangeBack;
+ case kWKContextMenuItemTagShareMenu:
+ return WebCore::ContextMenuItemTagShareMenu;
#endif
case kWKContextMenuItemTagOpenLinkInThisWindow:
- return WebCore::ContextMenuItemTagOpenLinkInThisWindow;
default:
- if (tag < kWKContextMenuItemBaseApplicationTag)
+ if (tag < kWKContextMenuItemBaseApplicationTag && !(tag >= WebCore::ContextMenuItemBaseCustomTag && tag <= WebCore::ContextMenuItemLastCustomTag))
LOG_ERROR("WKContextMenuItemTag %i is an unknown tag but is below the allowable custom tag value of %i", tag, kWKContextMenuItemBaseApplicationTag);
return static_cast<WebCore::ContextMenuAction>(tag);
}
@@ -759,22 +754,22 @@ inline WKFrameNavigationType toAPI(WebCore::NavigationType type)
WKFrameNavigationType wkType = kWKFrameNavigationTypeOther;
switch (type) {
- case WebCore::NavigationTypeLinkClicked:
+ case WebCore::NavigationType::LinkClicked:
wkType = kWKFrameNavigationTypeLinkClicked;
break;
- case WebCore::NavigationTypeFormSubmitted:
+ case WebCore::NavigationType::FormSubmitted:
wkType = kWKFrameNavigationTypeFormSubmitted;
break;
- case WebCore::NavigationTypeBackForward:
+ case WebCore::NavigationType::BackForward:
wkType = kWKFrameNavigationTypeBackForward;
break;
- case WebCore::NavigationTypeReload:
+ case WebCore::NavigationType::Reload:
wkType = kWKFrameNavigationTypeReload;
break;
- case WebCore::NavigationTypeFormResubmitted:
+ case WebCore::NavigationType::FormResubmitted:
wkType = kWKFrameNavigationTypeFormResubmitted;
break;
- case WebCore::NavigationTypeOther:
+ case WebCore::NavigationType::Other:
wkType = kWKFrameNavigationTypeOther;
break;
}
@@ -804,6 +799,66 @@ inline WKSameDocumentNavigationType toAPI(SameDocumentNavigationType type)
return wkType;
}
+inline SameDocumentNavigationType toSameDocumentNavigationType(WKSameDocumentNavigationType wkType)
+{
+ SameDocumentNavigationType type = SameDocumentNavigationAnchorNavigation;
+
+ switch (wkType) {
+ case kWKSameDocumentNavigationAnchorNavigation:
+ type = SameDocumentNavigationAnchorNavigation;
+ break;
+ case kWKSameDocumentNavigationSessionStatePush:
+ type = SameDocumentNavigationSessionStatePush;
+ break;
+ case kWKSameDocumentNavigationSessionStateReplace:
+ type = SameDocumentNavigationSessionStateReplace;
+ break;
+ case kWKSameDocumentNavigationSessionStatePop:
+ type = SameDocumentNavigationSessionStatePop;
+ break;
+ }
+
+ return type;
+}
+
+inline WKDiagnosticLoggingResultType toAPI(WebCore::DiagnosticLoggingResultType type)
+{
+ WKDiagnosticLoggingResultType wkType;
+
+ switch (type) {
+ case WebCore::DiagnosticLoggingResultPass:
+ wkType = kWKDiagnosticLoggingResultPass;
+ break;
+ case WebCore::DiagnosticLoggingResultFail:
+ wkType = kWKDiagnosticLoggingResultFail;
+ break;
+ case WebCore::DiagnosticLoggingResultNoop:
+ wkType = kWKDiagnosticLoggingResultNoop;
+ break;
+ }
+
+ return wkType;
+}
+
+inline WebCore::DiagnosticLoggingResultType toDiagnosticLoggingResultType(WKDiagnosticLoggingResultType wkType)
+{
+ WebCore::DiagnosticLoggingResultType type;
+
+ switch (wkType) {
+ case kWKDiagnosticLoggingResultPass:
+ type = WebCore::DiagnosticLoggingResultPass;
+ break;
+ case kWKDiagnosticLoggingResultFail:
+ type = WebCore::DiagnosticLoggingResultFail;
+ break;
+ case kWKDiagnosticLoggingResultNoop:
+ type = WebCore::DiagnosticLoggingResultNoop;
+ break;
+ }
+
+ return type;
+}
+
inline WKLayoutMilestones toWKLayoutMilestones(WebCore::LayoutMilestones milestones)
{
unsigned wkMilestones = 0;
@@ -848,15 +903,15 @@ inline WebCore::PageVisibilityState toPageVisibilityState(WKPageVisibilityState
{
switch (wkPageVisibilityState) {
case kWKPageVisibilityStateVisible:
- return WebCore::PageVisibilityStateVisible;
+ return WebCore::PageVisibilityState::Visible;
case kWKPageVisibilityStateHidden:
- return WebCore::PageVisibilityStateHidden;
+ return WebCore::PageVisibilityState::Hidden;
case kWKPageVisibilityStatePrerender:
- return WebCore::PageVisibilityStatePrerender;
+ return WebCore::PageVisibilityState::Prerender;
}
ASSERT_NOT_REACHED();
- return WebCore::PageVisibilityStateVisible;
+ return WebCore::PageVisibilityState::Visible;
}
inline ImageOptions toImageOptions(WKImageOptions wkImageOptions)
@@ -891,11 +946,17 @@ inline SnapshotOptions toSnapshotOptions(WKSnapshotOptions wkSnapshotOptions)
snapshotOptions |= SnapshotOptionsInViewCoordinates;
if (wkSnapshotOptions & kWKSnapshotOptionsPaintSelectionRectangle)
snapshotOptions |= SnapshotOptionsPaintSelectionRectangle;
+ if (wkSnapshotOptions & kWKSnapshotOptionsForceBlackText)
+ snapshotOptions |= SnapshotOptionsForceBlackText;
+ if (wkSnapshotOptions & kWKSnapshotOptionsForceWhiteText)
+ snapshotOptions |= SnapshotOptionsForceWhiteText;
+ if (wkSnapshotOptions & kWKSnapshotOptionsPrinting)
+ snapshotOptions |= SnapshotOptionsPrinting;
return snapshotOptions;
}
-inline WebCore::UserScriptInjectionTime toUserScriptInjectionTime(WKUserScriptInjectionTime wkInjectedTime)
+inline WebCore::UserScriptInjectionTime toUserScriptInjectionTime(_WKUserScriptInjectionTime wkInjectedTime)
{
switch (wkInjectedTime) {
case kWKInjectAtDocumentStart:
@@ -908,6 +969,19 @@ inline WebCore::UserScriptInjectionTime toUserScriptInjectionTime(WKUserScriptIn
return WebCore::InjectAtDocumentStart;
}
+inline _WKUserScriptInjectionTime toWKUserScriptInjectionTime(WebCore::UserScriptInjectionTime injectedTime)
+{
+ switch (injectedTime) {
+ case WebCore::InjectAtDocumentStart:
+ return kWKInjectAtDocumentStart;
+ case WebCore::InjectAtDocumentEnd:
+ return kWKInjectAtDocumentEnd;
+ }
+
+ ASSERT_NOT_REACHED();
+ return kWKInjectAtDocumentStart;
+}
+
inline WebCore::UserContentInjectedFrames toUserContentInjectedFrames(WKUserContentInjectedFrames wkInjectedFrames)
{
switch (wkInjectedFrames) {
diff --git a/Source/WebKit2/Shared/API/c/WKString.cpp b/Source/WebKit2/Shared/API/c/WKString.cpp
index 5f13b9ca7..650367045 100644
--- a/Source/WebKit2/Shared/API/c/WKString.cpp
+++ b/Source/WebKit2/Shared/API/c/WKString.cpp
@@ -28,6 +28,9 @@
#include "WKStringPrivate.h"
#include "WKAPICast.h"
+#include <JavaScriptCore/InitializeThreading.h>
+#include <JavaScriptCore/JSStringRef.h>
+#include <JavaScriptCore/OpaqueJSString.h>
using namespace WebKit;
@@ -38,58 +41,101 @@ WKTypeID WKStringGetTypeID()
WKStringRef WKStringCreateWithUTF8CString(const char* string)
{
- RefPtr<API::String> apiString = API::String::createFromUTF8String(string);
- return toAPI(apiString.release().leakRef());
+ return toAPI(&API::String::create(WTF::String::fromUTF8(string)).leakRef());
}
bool WKStringIsEmpty(WKStringRef stringRef)
{
- return toImpl(stringRef)->isEmpty();
+ return toImpl(stringRef)->stringView().isEmpty();
}
size_t WKStringGetLength(WKStringRef stringRef)
{
- return toImpl(stringRef)->length();
+ return toImpl(stringRef)->stringView().length();
}
size_t WKStringGetCharacters(WKStringRef stringRef, WKChar* buffer, size_t bufferLength)
{
- COMPILE_ASSERT(sizeof(WKChar) == sizeof(UChar), WKStringGetCharacters_sizeof_WKChar_matches_UChar);
- return (toImpl(stringRef)->getCharacters(static_cast<UChar*>(buffer), bufferLength));
+ static_assert(sizeof(WKChar) == sizeof(UChar), "Size of WKChar must match size of UChar");
+
+ unsigned unsignedBufferLength = std::min<size_t>(bufferLength, std::numeric_limits<unsigned>::max());
+ auto substring = toImpl(stringRef)->stringView().substring(0, unsignedBufferLength);
+
+ substring.getCharactersWithUpconvert(reinterpret_cast<UChar*>(buffer));
+ return substring.length();
}
size_t WKStringGetMaximumUTF8CStringSize(WKStringRef stringRef)
{
- return toImpl(stringRef)->maximumUTF8CStringSize();
+ return toImpl(stringRef)->stringView().length() * 3 + 1;
+}
+
+enum StrictType { NonStrict = false, Strict = true };
+
+template <StrictType strict>
+size_t WKStringGetUTF8CStringImpl(WKStringRef stringRef, char* buffer, size_t bufferSize)
+{
+ if (!bufferSize)
+ return 0;
+
+ auto stringView = toImpl(stringRef)->stringView();
+
+ char* p = buffer;
+ WTF::Unicode::ConversionResult result;
+
+ if (stringView.is8Bit()) {
+ const LChar* characters = stringView.characters8();
+ result = WTF::Unicode::convertLatin1ToUTF8(&characters, characters + stringView.length(), &p, p + bufferSize - 1);
+ } else {
+ const UChar* characters = stringView.characters16();
+ result = WTF::Unicode::convertUTF16ToUTF8(&characters, characters + stringView.length(), &p, p + bufferSize - 1, strict);
+ }
+
+ if (result != WTF::Unicode::conversionOK && result != WTF::Unicode::targetExhausted)
+ return 0;
+
+ *p++ = '\0';
+ return p - buffer;
}
size_t WKStringGetUTF8CString(WKStringRef stringRef, char* buffer, size_t bufferSize)
{
- return toImpl(stringRef)->getUTF8CString(buffer, bufferSize);
+ return WKStringGetUTF8CStringImpl<StrictType::Strict>(stringRef, buffer, bufferSize);
+}
+
+size_t WKStringGetUTF8CStringNonStrict(WKStringRef stringRef, char* buffer, size_t bufferSize)
+{
+ return WKStringGetUTF8CStringImpl<StrictType::NonStrict>(stringRef, buffer, bufferSize);
}
bool WKStringIsEqual(WKStringRef aRef, WKStringRef bRef)
{
- return toImpl(aRef)->equal(toImpl(bRef));
+ return toImpl(aRef)->stringView() == toImpl(bRef)->stringView();
}
bool WKStringIsEqualToUTF8CString(WKStringRef aRef, const char* b)
{
- return toImpl(aRef)->equalToUTF8String(b);
+ // FIXME: Should we add a fast path that avoids memory allocation when the string is all ASCII?
+ // FIXME: We can do even the general case more efficiently if we write a function in StringView that understands UTF-8 C strings.
+ return toImpl(aRef)->stringView() == WTF::String::fromUTF8(b);
}
bool WKStringIsEqualToUTF8CStringIgnoringCase(WKStringRef aRef, const char* b)
{
- return toImpl(aRef)->equalToUTF8StringIgnoringCase(b);
+ // FIXME: Should we add a fast path that avoids memory allocation when the string is all ASCII?
+ // FIXME: We can do even the general case more efficiently if we write a function in StringView that understands UTF-8 C strings.
+ return equalIgnoringASCIICase(toImpl(aRef)->stringView(), WTF::String::fromUTF8(b));
}
WKStringRef WKStringCreateWithJSString(JSStringRef jsStringRef)
{
- RefPtr<API::String> apiString = API::String::create(jsStringRef);
- return toAPI(apiString.release().leakRef());
+ auto apiString = jsStringRef ? API::String::create(jsStringRef->string()) : API::String::createNull();
+
+ return toAPI(&apiString.leakRef());
}
JSStringRef WKStringCopyJSString(WKStringRef stringRef)
{
- return toImpl(stringRef)->createJSString();
+ JSC::initializeThreading();
+ return OpaqueJSString::create(toImpl(stringRef)->string()).leakRef();
}
diff --git a/Source/WebKit2/Shared/API/c/WKString.h b/Source/WebKit2/Shared/API/c/WKString.h
index dd5b877a7..4c6a20422 100644
--- a/Source/WebKit2/Shared/API/c/WKString.h
+++ b/Source/WebKit2/Shared/API/c/WKString.h
@@ -26,7 +26,7 @@
#ifndef WKString_h
#define WKString_h
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#include <stddef.h>
#ifndef __cplusplus
@@ -55,6 +55,7 @@ WK_EXPORT size_t WKStringGetCharacters(WKStringRef string, WKChar* buffer, size_
WK_EXPORT size_t WKStringGetMaximumUTF8CStringSize(WKStringRef string);
WK_EXPORT size_t WKStringGetUTF8CString(WKStringRef string, char* buffer, size_t bufferSize);
+WK_EXPORT size_t WKStringGetUTF8CStringNonStrict(WKStringRef string, char* buffer, size_t bufferSize);
WK_EXPORT bool WKStringIsEqual(WKStringRef a, WKStringRef b);
WK_EXPORT bool WKStringIsEqualToUTF8CString(WKStringRef a, const char* b);
diff --git a/Source/WebKit2/Shared/API/c/WKStringPrivate.h b/Source/WebKit2/Shared/API/c/WKStringPrivate.h
index f174f0166..74bc8a1f0 100644
--- a/Source/WebKit2/Shared/API/c/WKStringPrivate.h
+++ b/Source/WebKit2/Shared/API/c/WKStringPrivate.h
@@ -27,7 +27,7 @@
#define WKStringPrivate_h
#include <JavaScriptCore/JavaScript.h>
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#ifdef __cplusplus
extern "C" {
diff --git a/Source/WebKit2/Shared/API/c/WKType.cpp b/Source/WebKit2/Shared/API/c/WKType.cpp
index bb165e4dd..fd20e6fff 100644
--- a/Source/WebKit2/Shared/API/c/WKType.cpp
+++ b/Source/WebKit2/Shared/API/c/WKType.cpp
@@ -33,16 +33,17 @@ using namespace WebKit;
WKTypeID WKGetTypeID(WKTypeRef typeRef)
{
- return toAPI(static_cast<API::Object*>(const_cast<void*>(typeRef))->type());
+ return toAPI(toImpl(typeRef)->type());
}
WKTypeRef WKRetain(WKTypeRef typeRef)
{
- static_cast<API::Object*>(const_cast<void*>(typeRef))->ref();
+ toImpl(typeRef)->ref();
+
return typeRef;
}
void WKRelease(WKTypeRef typeRef)
{
- static_cast<API::Object*>(const_cast<void*>(typeRef))->deref();
+ toImpl(typeRef)->deref();
}
diff --git a/Source/WebKit2/Shared/API/c/WKType.h b/Source/WebKit2/Shared/API/c/WKType.h
index 02f036c6f..e57ea379c 100644
--- a/Source/WebKit2/Shared/API/c/WKType.h
+++ b/Source/WebKit2/Shared/API/c/WKType.h
@@ -26,7 +26,7 @@
#ifndef WKType_h
#define WKType_h
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#ifdef __cplusplus
extern "C" {
diff --git a/Source/WebKit2/Shared/API/c/WKURL.cpp b/Source/WebKit2/Shared/API/c/WKURL.cpp
index 80bbb10df..f1a1ea546 100644
--- a/Source/WebKit2/Shared/API/c/WKURL.cpp
+++ b/Source/WebKit2/Shared/API/c/WKURL.cpp
@@ -37,12 +37,12 @@ WKTypeID WKURLGetTypeID()
WKURLRef WKURLCreateWithUTF8CString(const char* string)
{
- return toAPI(API::URL::create(String::fromUTF8(string)).leakRef());
+ return toAPI(&API::URL::create(String::fromUTF8(string)).leakRef());
}
WKURLRef WKURLCreateWithBaseURL(WKURLRef baseURL, const char* relative)
{
- return toAPI(API::URL::create(toImpl(baseURL), String::fromUTF8(relative)).leakRef());
+ return toAPI(&API::URL::create(toImpl(baseURL), String::fromUTF8(relative)).leakRef());
}
WKStringRef WKURLCopyString(WKURLRef url)
@@ -52,7 +52,7 @@ WKStringRef WKURLCopyString(WKURLRef url)
bool WKURLIsEqual(WKURLRef a, WKURLRef b)
{
- return toImpl(a)->string() == toImpl(b)->string();
+ return API::URL::equals(*toImpl(a), *toImpl(b));
}
WKStringRef WKURLCopyHostName(WKURLRef url)
diff --git a/Source/WebKit2/Shared/API/c/WKURL.h b/Source/WebKit2/Shared/API/c/WKURL.h
index 2c0a02cc4..6bbc2b392 100644
--- a/Source/WebKit2/Shared/API/c/WKURL.h
+++ b/Source/WebKit2/Shared/API/c/WKURL.h
@@ -26,7 +26,7 @@
#ifndef WKURL_h
#define WKURL_h
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#ifdef __cplusplus
extern "C" {
diff --git a/Source/WebKit2/Shared/API/c/WKURLRequest.cpp b/Source/WebKit2/Shared/API/c/WKURLRequest.cpp
index edbf219dc..736e1f3e6 100644
--- a/Source/WebKit2/Shared/API/c/WKURLRequest.cpp
+++ b/Source/WebKit2/Shared/API/c/WKURLRequest.cpp
@@ -28,6 +28,7 @@
#include "APIURLRequest.h"
#include "WKAPICast.h"
+#include "WKData.h"
#include <WebCore/URL.h>
using namespace WebCore;
@@ -40,7 +41,7 @@ WKTypeID WKURLRequestGetTypeID()
WKURLRequestRef WKURLRequestCreateWithWKURL(WKURLRef url)
{
- return toAPI(API::URLRequest::create(URL(URL(), toImpl(url)->string())).leakRef());
+ return toAPI(&API::URLRequest::create(URL(URL(), toImpl(url)->string())).leakRef());
}
WKURLRef WKURLRequestCopyURL(WKURLRequestRef requestRef)
@@ -58,6 +59,13 @@ WKStringRef WKURLRequestCopyHTTPMethod(WKURLRequestRef requestRef)
return toCopiedAPI(toImpl(requestRef)->resourceRequest().httpMethod());
}
+WKURLRequestRef WKURLRequestCopySettingHTTPBody(WKURLRequestRef requestRef, WKDataRef body)
+{
+ WebCore::ResourceRequest requestCopy(toImpl(requestRef)->resourceRequest());
+ requestCopy.setHTTPBody(FormData::create(WKDataGetBytes(body), WKDataGetSize(body)));
+ return toAPI(&API::URLRequest::create(requestCopy).leakRef());
+}
+
void WKURLRequestSetDefaultTimeoutInterval(double timeoutInterval)
{
API::URLRequest::setDefaultTimeoutInterval(timeoutInterval);
diff --git a/Source/WebKit2/Shared/API/c/WKURLRequest.h b/Source/WebKit2/Shared/API/c/WKURLRequest.h
index 85df3d389..174180423 100644
--- a/Source/WebKit2/Shared/API/c/WKURLRequest.h
+++ b/Source/WebKit2/Shared/API/c/WKURLRequest.h
@@ -26,7 +26,7 @@
#ifndef WKURLRequest_h
#define WKURLRequest_h
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#ifdef __cplusplus
extern "C" {
@@ -42,6 +42,8 @@ WK_EXPORT WKURLRef WKURLRequestCopyFirstPartyForCookies(WKURLRequestRef);
WK_EXPORT WKStringRef WKURLRequestCopyHTTPMethod(WKURLRequestRef);
+WK_EXPORT WKURLRequestRef WKURLRequestCopySettingHTTPBody(WKURLRequestRef, WKDataRef);
+
WK_EXPORT void WKURLRequestSetDefaultTimeoutInterval(double);
#ifdef __cplusplus
diff --git a/Source/WebKit2/Shared/API/c/WKURLResponse.h b/Source/WebKit2/Shared/API/c/WKURLResponse.h
index d56027ae9..9093b7791 100644
--- a/Source/WebKit2/Shared/API/c/WKURLResponse.h
+++ b/Source/WebKit2/Shared/API/c/WKURLResponse.h
@@ -26,7 +26,7 @@
#ifndef WKURLResponse_h
#define WKURLResponse_h
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#ifdef __cplusplus
extern "C" {
diff --git a/Source/WebKit2/Shared/API/c/WKUserContentURLPattern.cpp b/Source/WebKit2/Shared/API/c/WKUserContentURLPattern.cpp
index f6a204ab6..ceedc7696 100644
--- a/Source/WebKit2/Shared/API/c/WKUserContentURLPattern.cpp
+++ b/Source/WebKit2/Shared/API/c/WKUserContentURLPattern.cpp
@@ -26,21 +26,20 @@
#include "config.h"
#include "WKUserContentURLPattern.h"
+#include "APIUserContentURLPattern.h"
#include "WKAPICast.h"
#include "WKString.h"
-#include "WebUserContentURLPattern.h"
using namespace WebKit;
WKTypeID WKUserContentURLPatternGetTypeID()
{
- return toAPI(WebUserContentURLPattern::APIType);
+ return toAPI(API::UserContentURLPattern::APIType);
}
WKUserContentURLPatternRef WKUserContentURLPatternCreate(WKStringRef patternRef)
{
- RefPtr<WebUserContentURLPattern> userContentURLPattern = WebUserContentURLPattern::create(toImpl(patternRef)->string());
- return toAPI(userContentURLPattern.release().leakRef());
+ return toAPI(&API::UserContentURLPattern::create(toImpl(patternRef)->string()).leakRef());
}
WKStringRef WKUserContentURLPatternCopyHost(WKUserContentURLPatternRef urlPatternRef)
diff --git a/Source/WebKit2/Shared/API/c/WKUserContentURLPattern.h b/Source/WebKit2/Shared/API/c/WKUserContentURLPattern.h
index 6e4c6c132..407729663 100644
--- a/Source/WebKit2/Shared/API/c/WKUserContentURLPattern.h
+++ b/Source/WebKit2/Shared/API/c/WKUserContentURLPattern.h
@@ -27,7 +27,7 @@
#define WKUserContentURLPattern_h
#include <JavaScriptCore/JavaScript.h>
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#ifdef __cplusplus
extern "C" {
diff --git a/Source/WebKit2/Shared/API/c/WKUserScriptInjectionTime.h b/Source/WebKit2/Shared/API/c/WKUserScriptInjectionTime.h
index f4d38b2c1..45d241072 100644
--- a/Source/WebKit2/Shared/API/c/WKUserScriptInjectionTime.h
+++ b/Source/WebKit2/Shared/API/c/WKUserScriptInjectionTime.h
@@ -26,10 +26,10 @@
#ifndef WKUserScriptInjectionTime_h
#define WKUserScriptInjectionTime_h
-enum WKUserScriptInjectionTime {
+enum _WKUserScriptInjectionTime {
kWKInjectAtDocumentStart,
kWKInjectAtDocumentEnd
};
-typedef enum WKUserScriptInjectionTime WKUserScriptInjectionTime;
+typedef enum _WKUserScriptInjectionTime _WKUserScriptInjectionTime;
#endif /* WKUserScriptInjectionTime_h */
diff --git a/Source/WebKit2/Shared/API/c/cairo/WKImageCairo.cpp b/Source/WebKit2/Shared/API/c/cairo/WKImageCairo.cpp
index afb49932b..bb2485f6a 100644
--- a/Source/WebKit2/Shared/API/c/cairo/WKImageCairo.cpp
+++ b/Source/WebKit2/Shared/API/c/cairo/WKImageCairo.cpp
@@ -39,14 +39,14 @@ using namespace WebCore;
cairo_surface_t* WKImageCreateCairoSurface(WKImageRef imageRef)
{
// We cannot pass a RefPtr through the API here, so we just leak the reference.
- return toImpl(imageRef)->bitmap()->createCairoSurface().leakRef();
+ return toImpl(imageRef)->bitmap().createCairoSurface().leakRef();
}
WKImageRef WKImageCreateFromCairoSurface(cairo_surface_t* surface, WKImageOptions options)
{
IntSize imageSize(cairo_image_surface_get_width(surface), cairo_image_surface_get_height(surface));
- RefPtr<WebImage> webImage = WebImage::create(imageSize, toImageOptions(options));
- auto graphicsContext = webImage->bitmap()->createGraphicsContext();
+ auto webImage = WebImage::create(imageSize, toImageOptions(options));
+ auto graphicsContext = webImage->bitmap().createGraphicsContext();
cairo_t* cr = graphicsContext->platformContext()->cr();
cairo_set_source_surface(cr, surface, 0, 0);
@@ -54,5 +54,5 @@ WKImageRef WKImageCreateFromCairoSurface(cairo_surface_t* surface, WKImageOption
cairo_rectangle(cr, 0, 0, imageSize.width(), imageSize.height());
cairo_fill(cr);
- return toAPI(webImage.release().leakRef());
+ return toAPI(webImage.leakRef());
}
diff --git a/Source/WebKit2/Shared/API/c/cairo/WKImageCairo.h b/Source/WebKit2/Shared/API/c/cairo/WKImageCairo.h
index 5c1e5413f..06749f6a2 100644
--- a/Source/WebKit2/Shared/API/c/cairo/WKImageCairo.h
+++ b/Source/WebKit2/Shared/API/c/cairo/WKImageCairo.h
@@ -27,8 +27,8 @@
#ifndef WKImageCairo_h
#define WKImageCairo_h
-#include <WebKit2/WKBase.h>
-#include <WebKit2/WKImage.h>
+#include <WebKit/WKBase.h>
+#include <WebKit/WKImage.h>
typedef struct _cairo_surface cairo_surface_t;
diff --git a/Source/WebKit2/Shared/APIString.h b/Source/WebKit2/Shared/APIString.h
deleted file mode 100644
index 767f16245..000000000
--- a/Source/WebKit2/Shared/APIString.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-
-#ifndef APIString_h
-#define APIString_h
-
-#include "APIObject.h"
-#include <JavaScriptCore/InitializeThreading.h>
-#include <JavaScriptCore/JSStringRef.h>
-#include <JavaScriptCore/OpaqueJSString.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/text/WTFString.h>
-#include <wtf/unicode/UTF8.h>
-
-namespace API {
-
-class String final : public ObjectImpl<Object::Type::String> {
-public:
- static PassRefPtr<String> createNull()
- {
- return adoptRef(new String);
- }
-
- static PassRefPtr<String> create(const WTF::String& string)
- {
- return adoptRef(new String(string));
- }
-
- static PassRefPtr<String> create(JSStringRef jsStringRef)
- {
- return adoptRef(new String(jsStringRef->string()));
- }
-
- static PassRefPtr<String> createFromUTF8String(const char* string)
- {
- return adoptRef(new String(WTF::String::fromUTF8(string)));
- }
-
- virtual ~String()
- {
- }
-
- bool isNull() const { return m_string.isNull(); }
- bool isEmpty() const { return m_string.isEmpty(); }
-
- size_t length() const { return m_string.length(); }
- size_t getCharacters(UChar* buffer, size_t bufferLength) const
- {
- if (!bufferLength)
- return 0;
- bufferLength = std::min(bufferLength, static_cast<size_t>(m_string.length()));
- memcpy(buffer, m_string.deprecatedCharacters(), bufferLength * sizeof(UChar));
- return bufferLength;
- }
-
- size_t maximumUTF8CStringSize() const { return m_string.length() * 3 + 1; }
- size_t getUTF8CString(char* buffer, size_t bufferSize)
- {
- if (!bufferSize)
- return 0;
- char* p = buffer;
- const UChar* d = m_string.deprecatedCharacters();
- WTF::Unicode::ConversionResult result = WTF::Unicode::convertUTF16ToUTF8(&d, d + m_string.length(), &p, p + bufferSize - 1, /* strict */ true);
- *p++ = '\0';
- if (result != WTF::Unicode::conversionOK && result != WTF::Unicode::targetExhausted)
- return 0;
- return p - buffer;
- }
-
- bool equal(String* other) { return m_string == other->m_string; }
- bool equalToUTF8String(const char* other) { return m_string == WTF::String::fromUTF8(other); }
- bool equalToUTF8StringIgnoringCase(const char* other) { return equalIgnoringCase(m_string, other); }
-
- const WTF::String& string() const { return m_string; }
-
- JSStringRef createJSString() const
- {
- JSC::initializeThreading();
- return OpaqueJSString::create(m_string).leakRef();
- }
-
-private:
- String()
- : m_string()
- {
- }
-
- String(const WTF::String& string)
- : m_string(!string.impl() ? WTF::String(StringImpl::empty()) : string)
- {
- }
-
- WTF::String m_string;
-};
-
-} // namespace WebKit
-
-#endif // APIString_h
diff --git a/Source/WebKit2/Shared/APIWebArchive.h b/Source/WebKit2/Shared/APIWebArchive.h
new file mode 100644
index 000000000..8375777db
--- /dev/null
+++ b/Source/WebKit2/Shared/APIWebArchive.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2013 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.
+ */
+
+#ifndef WebArchive_h
+#define WebArchive_h
+
+#if PLATFORM(COCOA)
+
+#include "APIObject.h"
+#include <wtf/RefPtr.h>
+
+namespace API {
+class Array;
+class Data;
+}
+
+namespace WebCore {
+class LegacyWebArchive;
+class Range;
+}
+
+namespace API {
+
+class WebArchiveResource;
+
+class WebArchive : public API::ObjectImpl<API::Object::Type::WebArchive> {
+public:
+ virtual ~WebArchive();
+
+ static Ref<WebArchive> create(WebArchiveResource* mainResource, RefPtr<API::Array>&& subresources, RefPtr<API::Array>&& subframeArchives);
+ static Ref<WebArchive> create(API::Data*);
+ static Ref<WebArchive> create(RefPtr<WebCore::LegacyWebArchive>&&);
+ static Ref<WebArchive> create(WebCore::Range*);
+
+ WebArchiveResource* mainResource();
+ API::Array* subresources();
+ API::Array* subframeArchives();
+
+ Ref<API::Data> data();
+
+ WebCore::LegacyWebArchive* coreLegacyWebArchive();
+
+private:
+ WebArchive(WebArchiveResource* mainResource, RefPtr<API::Array>&& subresources, RefPtr<API::Array>&& subframeArchives);
+ WebArchive(API::Data*);
+ WebArchive(RefPtr<WebCore::LegacyWebArchive>&&);
+
+ RefPtr<WebCore::LegacyWebArchive> m_legacyWebArchive;
+ RefPtr<WebArchiveResource> m_cachedMainResource;
+ RefPtr<API::Array> m_cachedSubresources;
+ RefPtr<API::Array> m_cachedSubframeArchives;
+};
+
+} // namespace API
+
+#endif // PLATFORM(COCOA)
+
+#endif // WebArchive_h
diff --git a/Source/WebKit2/Shared/APIWebArchiveResource.h b/Source/WebKit2/Shared/APIWebArchiveResource.h
new file mode 100644
index 000000000..1eb9264b3
--- /dev/null
+++ b/Source/WebKit2/Shared/APIWebArchiveResource.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2013 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.
+ */
+
+#ifndef WebArchiveResource_h
+#define WebArchiveResource_h
+
+#if PLATFORM(COCOA)
+
+#include "APIObject.h"
+#include <wtf/Forward.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace API {
+class Data;
+class URL;
+}
+
+namespace WebCore {
+class ArchiveResource;
+}
+
+namespace API {
+
+class WebArchiveResource : public API::ObjectImpl<API::Object::Type::WebArchiveResource> {
+public:
+ virtual ~WebArchiveResource();
+
+ static Ref<WebArchiveResource> create(API::Data*, const String& URL, const String& MIMEType, const String& textEncoding);
+ static Ref<WebArchiveResource> create(PassRefPtr<WebCore::ArchiveResource>);
+
+ Ref<API::Data> data();
+ String URL();
+ String MIMEType();
+ String textEncoding();
+
+ WebCore::ArchiveResource* coreArchiveResource();
+
+private:
+ WebArchiveResource(API::Data*, const String& URL, const String& MIMEType, const String& textEncoding);
+ WebArchiveResource(PassRefPtr<WebCore::ArchiveResource>);
+
+ RefPtr<WebCore::ArchiveResource> m_archiveResource;
+};
+
+} // namespace API
+
+#endif // PLATFORM(COCOA)
+
+#endif // WebArchiveResource_h
diff --git a/Source/WebKit2/Shared/ActivityAssertion.cpp b/Source/WebKit2/Shared/ActivityAssertion.cpp
index 322291106..52d14ee19 100644
--- a/Source/WebKit2/Shared/ActivityAssertion.cpp
+++ b/Source/WebKit2/Shared/ActivityAssertion.cpp
@@ -26,19 +26,17 @@
#include "config.h"
#include "ActivityAssertion.h"
-#include "ChildProcess.h"
-
namespace WebKit {
-ActivityAssertion::ActivityAssertion(ChildProcess& process)
- : m_process(process)
+ActivityAssertion::ActivityAssertion(CountedUserActivity& activity)
+ : m_activity(activity)
{
- m_process.incrementActiveTaskCount();
+ m_activity.increment();
}
ActivityAssertion::~ActivityAssertion()
{
- m_process.decrementActiveTaskCount();
+ m_activity.decrement();
}
}
diff --git a/Source/WebKit2/Shared/ActivityAssertion.h b/Source/WebKit2/Shared/ActivityAssertion.h
index 59581bd2b..b5a19f908 100644
--- a/Source/WebKit2/Shared/ActivityAssertion.h
+++ b/Source/WebKit2/Shared/ActivityAssertion.h
@@ -26,20 +26,19 @@
#ifndef ActivityAssertion_h
#define ActivityAssertion_h
+#include <WebCore/CountedUserActivity.h>
#include <wtf/Noncopyable.h>
namespace WebKit {
-class ChildProcess;
-
class ActivityAssertion {
WTF_MAKE_NONCOPYABLE(ActivityAssertion);
public:
- ActivityAssertion(ChildProcess&);
+ explicit ActivityAssertion(CountedUserActivity&);
~ActivityAssertion();
private:
- ChildProcess& m_process;
+ CountedUserActivity& m_activity;
};
}
diff --git a/Source/WebKit2/Shared/AssistedNodeInformation.cpp b/Source/WebKit2/Shared/AssistedNodeInformation.cpp
new file mode 100644
index 000000000..ac96f00b7
--- /dev/null
+++ b/Source/WebKit2/Shared/AssistedNodeInformation.cpp
@@ -0,0 +1,169 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+#include "config.h"
+#include "AssistedNodeInformation.h"
+
+#include "WebCoreArgumentCoders.h"
+
+namespace WebKit {
+
+#if PLATFORM(IOS)
+void OptionItem::encode(IPC::Encoder& encoder) const
+{
+ encoder << text;
+ encoder << isGroup;
+ encoder << isSelected;
+ encoder << disabled;
+ encoder << parentGroupID;
+}
+
+bool OptionItem::decode(IPC::Decoder& decoder, OptionItem& result)
+{
+ if (!decoder.decode(result.text))
+ return false;
+
+ if (!decoder.decode(result.isGroup))
+ return false;
+
+ if (!decoder.decode(result.isSelected))
+ return false;
+
+ if (!decoder.decode(result.disabled))
+ return false;
+
+ if (!decoder.decode(result.parentGroupID))
+ return false;
+
+ return true;
+}
+
+void AssistedNodeInformation::encode(IPC::Encoder& encoder) const
+{
+ encoder << elementRect;
+ encoder << selectionRect;
+ encoder << minimumScaleFactor;
+ encoder << maximumScaleFactor;
+ encoder << maximumScaleFactorIgnoringAlwaysScalable;
+ encoder << nodeFontSize;
+ encoder << hasNextNode;
+ encoder << hasPreviousNode;
+ encoder << isAutocorrect;
+ encoder << isRTL;
+ encoder.encodeEnum(autocapitalizeType);
+ encoder.encodeEnum(elementType);
+ encoder << formAction;
+ encoder << selectOptions;
+ encoder << selectedIndex;
+ encoder << isMultiSelect;
+ encoder << isReadOnly;
+ encoder << allowsUserScaling;
+ encoder << allowsUserScalingIgnoringAlwaysScalable;
+ encoder << insideFixedPosition;
+ encoder << value;
+ encoder << valueAsNumber;
+ encoder << title;
+ encoder.encodeEnum(autofillFieldName);
+}
+
+bool AssistedNodeInformation::decode(IPC::Decoder& decoder, AssistedNodeInformation& result)
+{
+ if (!decoder.decode(result.elementRect))
+ return false;
+
+ if (!decoder.decode(result.selectionRect))
+ return false;
+
+ if (!decoder.decode(result.minimumScaleFactor))
+ return false;
+
+ if (!decoder.decode(result.maximumScaleFactor))
+ return false;
+
+ if (!decoder.decode(result.maximumScaleFactorIgnoringAlwaysScalable))
+ return false;
+
+ if (!decoder.decode(result.nodeFontSize))
+ return false;
+
+ if (!decoder.decode(result.hasNextNode))
+ return false;
+
+ if (!decoder.decode(result.hasPreviousNode))
+ return false;
+
+ if (!decoder.decode(result.isAutocorrect))
+ return false;
+
+ if (!decoder.decode(result.isRTL))
+ return false;
+
+ if (!decoder.decodeEnum(result.autocapitalizeType))
+ return false;
+
+ if (!decoder.decodeEnum(result.elementType))
+ return false;
+
+ if (!decoder.decode(result.formAction))
+ return false;
+
+ if (!decoder.decode(result.selectOptions))
+ return false;
+
+ if (!decoder.decode(result.selectedIndex))
+ return false;
+
+ if (!decoder.decode(result.isMultiSelect))
+ return false;
+
+ if (!decoder.decode(result.isReadOnly))
+ return false;
+
+ if (!decoder.decode(result.allowsUserScaling))
+ return false;
+
+ if (!decoder.decode(result.allowsUserScalingIgnoringAlwaysScalable))
+ return false;
+
+ if (!decoder.decode(result.insideFixedPosition))
+ return false;
+
+ if (!decoder.decode(result.value))
+ return false;
+
+ if (!decoder.decode(result.valueAsNumber))
+ return false;
+
+ if (!decoder.decode(result.title))
+ return false;
+
+ if (!decoder.decodeEnum(result.autofillFieldName))
+ return false;
+
+ return true;
+}
+#endif
+
+}
diff --git a/Source/WebKit2/Shared/AssistedNodeInformation.h b/Source/WebKit2/Shared/AssistedNodeInformation.h
new file mode 100644
index 000000000..c67193759
--- /dev/null
+++ b/Source/WebKit2/Shared/AssistedNodeInformation.h
@@ -0,0 +1,119 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+#pragma once
+
+#include "ArgumentCoders.h"
+#include <WebCore/AutocapitalizeTypes.h>
+#include <WebCore/Autofill.h>
+#include <WebCore/IntRect.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebKit {
+
+enum class InputType {
+ None,
+ ContentEditable,
+ Text,
+ Password,
+ TextArea,
+ Search,
+ Email,
+ URL,
+ Phone,
+ Number,
+ NumberPad,
+ Date,
+ DateTime,
+ DateTimeLocal,
+ Month,
+ Week,
+ Time,
+ Select
+};
+
+#if PLATFORM(IOS)
+struct OptionItem {
+ OptionItem() { }
+
+ OptionItem(const OptionItem& item)
+ : text(item.text)
+ , isGroup(item.isGroup)
+ , isSelected(item.isSelected)
+ , disabled(item.disabled)
+ , parentGroupID(item.parentGroupID)
+ {
+ }
+
+ OptionItem(const String& text, bool isGroup, int parentID, bool selected, bool disabled)
+ : text(text)
+ , isGroup(isGroup)
+ , isSelected(selected)
+ , disabled(disabled)
+ , parentGroupID(parentID)
+ {
+ }
+ String text;
+ bool isGroup { false };
+ bool isSelected { false };
+ bool disabled { false };
+ int parentGroupID { 0 };
+
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, OptionItem&);
+};
+
+struct AssistedNodeInformation {
+ WebCore::IntRect elementRect;
+ WebCore::IntRect selectionRect;
+ double minimumScaleFactor { -INFINITY };
+ double maximumScaleFactor { INFINITY };
+ double maximumScaleFactorIgnoringAlwaysScalable { INFINITY };
+ double nodeFontSize { 0 };
+ bool hasNextNode { false };
+ bool hasPreviousNode { false };
+ bool isAutocorrect { false };
+ bool isRTL { false };
+ bool isMultiSelect { false };
+ bool isReadOnly {false };
+ bool allowsUserScaling { false };
+ bool allowsUserScalingIgnoringAlwaysScalable { false };
+ bool insideFixedPosition { false };
+ AutocapitalizeType autocapitalizeType { AutocapitalizeTypeDefault };
+ InputType elementType { InputType::None };
+ String formAction;
+ Vector<OptionItem> selectOptions;
+ int selectedIndex { -1 };
+ String value;
+ double valueAsNumber { 0 };
+ String title;
+ WebCore::AutofillFieldName autofillFieldName { WebCore::AutofillFieldName::None };
+
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, AssistedNodeInformation&);
+};
+#endif
+
+}
diff --git a/Source/WebKit2/Shared/AsyncRequest.cpp b/Source/WebKit2/Shared/AsyncRequest.cpp
new file mode 100644
index 000000000..a4f8b025f
--- /dev/null
+++ b/Source/WebKit2/Shared/AsyncRequest.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2013 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. ``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
+ * 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 "AsyncRequest.h"
+
+#include <wtf/RunLoop.h>
+
+namespace WebKit {
+
+static uint64_t generateRequestID()
+{
+ ASSERT(RunLoop::isMain());
+ static uint64_t requestID = 0;
+ return ++requestID;
+}
+
+AsyncRequest::AsyncRequest(std::function<void ()> abortHandler)
+ : m_abortHandler(WTFMove(abortHandler))
+ , m_requestID(generateRequestID())
+{
+}
+
+AsyncRequest::~AsyncRequest()
+{
+ ASSERT(!m_abortHandler);
+}
+
+void AsyncRequest::setAbortHandler(std::function<void ()> handler)
+{
+ m_abortHandler = WTFMove(handler);
+}
+
+void AsyncRequest::requestAborted()
+{
+ if (m_abortHandler) {
+ m_abortHandler();
+ m_abortHandler = nullptr;
+ }
+
+ clearCompletionHandler();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/Shared/AsyncRequest.h b/Source/WebKit2/Shared/AsyncRequest.h
new file mode 100644
index 000000000..5f327c496
--- /dev/null
+++ b/Source/WebKit2/Shared/AsyncRequest.h
@@ -0,0 +1,153 @@
+/*
+ * Copyright (C) 2013 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. ``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
+ * 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.
+ *
+ */
+
+#ifndef AsyncRequest_h
+#define AsyncRequest_h
+
+#include <functional>
+#include <wtf/HashMap.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebKit {
+
+class AsyncRequest : public RefCounted<AsyncRequest> {
+public:
+ virtual ~AsyncRequest();
+
+ uint64_t requestID() { return m_requestID; }
+
+ void setAbortHandler(std::function<void ()>);
+ void requestAborted();
+ template<typename... Arguments> void completeRequest(Arguments&&... arguments);
+
+protected:
+ explicit AsyncRequest(std::function<void ()> abortHandler);
+
+ virtual void clearCompletionHandler() = 0;
+
+ std::function<void ()> m_abortHandler;
+
+private:
+ uint64_t m_requestID;
+};
+
+template <typename... Arguments>
+class AsyncRequestImpl final : public AsyncRequest {
+public:
+ template<typename T> using ArgumentType = typename std::conditional<std::is_integral<T>::value, T, const T&>::type;
+
+ static Ref<AsyncRequest> create(std::function<void(ArgumentType<Arguments>...)> completionHandler)
+ {
+ return adoptRef(*new AsyncRequestImpl<Arguments...>(WTFMove(completionHandler), nullptr));
+ }
+
+ static Ref<AsyncRequest> create(std::function<void(ArgumentType<Arguments>...)> completionHandler, std::function<void()> abortHandler)
+ {
+ return adoptRef(*new AsyncRequestImpl<Arguments...>(WTFMove(completionHandler), WTFMove(abortHandler)));
+ }
+
+ virtual ~AsyncRequestImpl()
+ {
+ ASSERT(!m_completionHandler);
+ }
+
+ template<typename... RequestArguments>
+ void completeRequest(RequestArguments&&... arguments)
+ {
+ m_completionHandler(std::forward<RequestArguments>(arguments)...);
+ m_completionHandler = nullptr;
+ }
+
+private:
+ AsyncRequestImpl(std::function<void (ArgumentType<Arguments>...)> completionHandler, std::function<void ()> abortHandler)
+ : AsyncRequest(WTFMove(abortHandler))
+ , m_completionHandler(WTFMove(completionHandler))
+ {
+ ASSERT(m_completionHandler);
+ }
+
+ void clearCompletionHandler() override
+ {
+ m_completionHandler = nullptr;
+ }
+
+ std::function<void (ArgumentType<Arguments>...)> m_completionHandler;
+};
+
+template<typename... Arguments> void AsyncRequest::completeRequest(Arguments&&... arguments)
+{
+ auto* request = static_cast<AsyncRequestImpl<typename std::decay<Arguments>::type...>*>(this);
+ request->completeRequest(std::forward<Arguments>(arguments)...);
+ m_abortHandler = nullptr;
+}
+
+class AsyncRequestMap {
+public:
+ AsyncRequestMap()
+#ifndef NDEBUG
+ : m_lastRequestIDTaken(std::numeric_limits<uint64_t>::max())
+#endif
+ { }
+
+ Ref<AsyncRequest> take(uint64_t requestID)
+ {
+#ifndef NDEBUG
+ ASSERT_WITH_MESSAGE(requestID != m_lastRequestIDTaken, "Attempt to take the same AsyncRequest twice in a row. A background queue might have dispatched both an error callback and a success callback?");
+ m_lastRequestIDTaken = requestID;
+#endif
+
+ RefPtr<AsyncRequest> request = m_requestMap.take(requestID);
+ RELEASE_ASSERT(request);
+
+ return adoptRef(*request.leakRef());
+ }
+
+ void add(uint64_t requestID, PassRefPtr<AsyncRequest> request)
+ {
+ m_requestMap.add(requestID, request);
+ }
+
+ void clear()
+ {
+ m_requestMap.clear();
+ }
+
+ WTF::IteratorRange<HashMap<uint64_t, RefPtr<AsyncRequest>>::iterator::Values> values()
+ {
+ return m_requestMap.values();
+ }
+
+private:
+ HashMap<uint64_t, RefPtr<AsyncRequest>> m_requestMap;
+#ifndef NDEBUG
+ uint64_t m_lastRequestIDTaken;
+#endif
+};
+
+} // namespace WebKit
+
+#endif // AsyncRequest_h
diff --git a/Source/WebKit2/Shared/Authentication/AuthenticationManager.cpp b/Source/WebKit2/Shared/Authentication/AuthenticationManager.cpp
index 6e1e06d4a..f16ffa50f 100644
--- a/Source/WebKit2/Shared/Authentication/AuthenticationManager.cpp
+++ b/Source/WebKit2/Shared/Authentication/AuthenticationManager.cpp
@@ -30,6 +30,8 @@
#include "ChildProcess.h"
#include "Download.h"
#include "DownloadProxyMessages.h"
+#include "NetworkProcessProxyMessages.h"
+#include "PendingDownload.h"
#include "WebCoreArgumentCoders.h"
#include "WebFrame.h"
#include "WebPage.h"
@@ -37,22 +39,24 @@
#include <WebCore/AuthenticationChallenge.h>
#include <WebCore/AuthenticationClient.h>
-#if ENABLE(NETWORK_PROCESS)
-#include "NetworkProcessProxyMessages.h"
-#endif
-
using namespace WebCore;
namespace WebKit {
static uint64_t generateAuthenticationChallengeID()
{
- ASSERT(isMainThread());
+ ASSERT(RunLoop::isMain());
static int64_t uniqueAuthenticationChallengeID;
return ++uniqueAuthenticationChallengeID;
}
+static bool canCoalesceChallenge(const WebCore::AuthenticationChallenge& challenge)
+{
+ // Do not coalesce server trust evaluation requests because ProtectionSpace comparison does not evaluate server trust (e.g. certificate).
+ return challenge.protectionSpace().authenticationScheme() != ProtectionSpaceAuthenticationSchemeServerTrustEvaluationRequested;
+}
+
const char* AuthenticationManager::supplementName()
{
return "AuthenticationManager";
@@ -64,41 +68,129 @@ AuthenticationManager::AuthenticationManager(ChildProcess* process)
m_process->addMessageReceiver(Messages::AuthenticationManager::messageReceiverName(), *this);
}
-uint64_t AuthenticationManager::establishIdentifierForChallenge(const WebCore::AuthenticationChallenge& authenticationChallenge)
+uint64_t AuthenticationManager::addChallengeToChallengeMap(Challenge&& challenge)
{
- ASSERT(isMainThread());
+ ASSERT(RunLoop::isMain());
uint64_t challengeID = generateAuthenticationChallengeID();
- m_challenges.set(challengeID, authenticationChallenge);
+ m_challenges.set(challengeID, WTFMove(challenge));
return challengeID;
}
+bool AuthenticationManager::shouldCoalesceChallenge(uint64_t pageID, uint64_t challengeID, const AuthenticationChallenge& challenge) const
+{
+ if (!canCoalesceChallenge(challenge))
+ return false;
+
+ for (auto& item : m_challenges) {
+ if (item.key != challengeID && item.value.pageID == pageID && ProtectionSpace::compare(challenge.protectionSpace(), item.value.challenge.protectionSpace()))
+ return true;
+ }
+ return false;
+}
+
+Vector<uint64_t> AuthenticationManager::coalesceChallengesMatching(uint64_t challengeID) const
+{
+ auto iterator = m_challenges.find(challengeID);
+ ASSERT(iterator != m_challenges.end());
+
+ auto& challenge = iterator->value;
+
+ Vector<uint64_t> challengesToCoalesce;
+ challengesToCoalesce.append(challengeID);
+
+ if (!canCoalesceChallenge(challenge.challenge))
+ return challengesToCoalesce;
+
+ for (auto& item : m_challenges) {
+ if (item.key != challengeID && item.value.pageID == challenge.pageID && ProtectionSpace::compare(challenge.challenge.protectionSpace(), item.value.challenge.protectionSpace()))
+ challengesToCoalesce.append(item.key);
+ }
+
+ return challengesToCoalesce;
+}
+
void AuthenticationManager::didReceiveAuthenticationChallenge(WebFrame* frame, const AuthenticationChallenge& authenticationChallenge)
{
ASSERT(frame);
ASSERT(frame->page());
+
+ auto pageID = frame->page()->pageID();
+ uint64_t challengeID = addChallengeToChallengeMap({pageID, authenticationChallenge
+#if USE(NETWORK_SESSION)
+ , { }
+#endif
+ });
+
+ // Coalesce challenges in the same protection space and in the same page.
+ if (shouldCoalesceChallenge(pageID, challengeID, authenticationChallenge))
+ return;
- m_process->send(Messages::WebPageProxy::DidReceiveAuthenticationChallenge(frame->frameID(), authenticationChallenge, establishIdentifierForChallenge(authenticationChallenge)), frame->page()->pageID());
+ m_process->send(Messages::WebPageProxy::DidReceiveAuthenticationChallenge(frame->frameID(), authenticationChallenge, challengeID), frame->page()->pageID());
}
-#if ENABLE(NETWORK_PROCESS)
-void AuthenticationManager::didReceiveAuthenticationChallenge(uint64_t pageID, uint64_t frameID, const AuthenticationChallenge& authenticationChallenge)
+#if USE(NETWORK_SESSION)
+void AuthenticationManager::didReceiveAuthenticationChallenge(uint64_t pageID, uint64_t frameID, const AuthenticationChallenge& authenticationChallenge, ChallengeCompletionHandler&& completionHandler)
{
ASSERT(pageID);
ASSERT(frameID);
+
+ uint64_t challengeID = addChallengeToChallengeMap({ pageID, authenticationChallenge, WTFMove(completionHandler) });
+
+ // Coalesce challenges in the same protection space and in the same page.
+ if (shouldCoalesceChallenge(pageID, challengeID, authenticationChallenge))
+ return;
- m_process->send(Messages::NetworkProcessProxy::DidReceiveAuthenticationChallenge(pageID, frameID, authenticationChallenge, establishIdentifierForChallenge(authenticationChallenge)));
+ m_process->send(Messages::NetworkProcessProxy::DidReceiveAuthenticationChallenge(pageID, frameID, authenticationChallenge, challengeID));
+}
+
+void AuthenticationManager::didReceiveAuthenticationChallenge(PendingDownload& pendingDownload, const WebCore::AuthenticationChallenge& authenticationChallenge, ChallengeCompletionHandler&& completionHandler)
+{
+ uint64_t dummyPageID = 0;
+ uint64_t challengeID = addChallengeToChallengeMap({ dummyPageID, authenticationChallenge, WTFMove(completionHandler) });
+
+ // Coalesce challenges in the same protection space and in the same page.
+ if (shouldCoalesceChallenge(dummyPageID, challengeID, authenticationChallenge))
+ return;
+
+ pendingDownload.send(Messages::DownloadProxy::DidReceiveAuthenticationChallenge(authenticationChallenge, challengeID));
}
#endif
+void AuthenticationManager::didReceiveAuthenticationChallenge(uint64_t pageID, uint64_t frameID, const AuthenticationChallenge& authenticationChallenge)
+{
+ ASSERT(pageID);
+ ASSERT(frameID);
+
+ uint64_t challengeID = addChallengeToChallengeMap({pageID, authenticationChallenge
+#if USE(NETWORK_SESSION)
+ , { }
+#endif
+ });
+
+ // Coalesce challenges in the same protection space and in the same page.
+ if (shouldCoalesceChallenge(pageID, challengeID, authenticationChallenge))
+ return;
+
+ m_process->send(Messages::NetworkProcessProxy::DidReceiveAuthenticationChallenge(pageID, frameID, authenticationChallenge, challengeID));
+}
-void AuthenticationManager::didReceiveAuthenticationChallenge(Download* download, const AuthenticationChallenge& authenticationChallenge)
+#if !USE(NETWORK_SESSION)
+void AuthenticationManager::didReceiveAuthenticationChallenge(Download& download, const AuthenticationChallenge& authenticationChallenge)
{
- download->send(Messages::DownloadProxy::DidReceiveAuthenticationChallenge(authenticationChallenge, establishIdentifierForChallenge(authenticationChallenge)));
+ uint64_t dummyPageID = 0;
+ uint64_t challengeID = addChallengeToChallengeMap({dummyPageID, authenticationChallenge});
+
+ // Coalesce challenges in the same protection space and in the same page.
+ if (shouldCoalesceChallenge(dummyPageID, challengeID, authenticationChallenge))
+ return;
+
+ download.send(Messages::DownloadProxy::DidReceiveAuthenticationChallenge(authenticationChallenge, challengeID));
}
+#endif
// Currently, only Mac knows how to respond to authentication challenges with certificate info.
#if !HAVE(SEC_IDENTITY)
-bool AuthenticationManager::tryUseCertificateInfoForChallenge(const WebCore::AuthenticationChallenge&, const CertificateInfo&)
+bool AuthenticationManager::tryUseCertificateInfoForChallenge(const WebCore::AuthenticationChallenge&, const CertificateInfo&, const ChallengeCompletionHandler&)
{
return false;
}
@@ -106,54 +198,153 @@ bool AuthenticationManager::tryUseCertificateInfoForChallenge(const WebCore::Aut
void AuthenticationManager::useCredentialForChallenge(uint64_t challengeID, const Credential& credential, const CertificateInfo& certificateInfo)
{
- ASSERT(isMainThread());
+ ASSERT(RunLoop::isMain());
+
+ for (auto& coalescedChallengeID : coalesceChallengesMatching(challengeID))
+ useCredentialForSingleChallenge(coalescedChallengeID, credential, certificateInfo);
+}
+
+void AuthenticationManager::useCredentialForSingleChallenge(uint64_t challengeID, const Credential& credential, const CertificateInfo& certificateInfo)
+{
+ auto challenge = m_challenges.take(challengeID);
+ ASSERT(!challenge.challenge.isNull());
- AuthenticationChallenge challenge = m_challenges.take(challengeID);
- ASSERT(!challenge.isNull());
+#if USE(NETWORK_SESSION)
+ auto completionHandler = WTFMove(challenge.completionHandler);
+#else
+ ChallengeCompletionHandler completionHandler = nullptr;
+#endif
- if (tryUseCertificateInfoForChallenge(challenge, certificateInfo))
+ if (tryUseCertificateInfoForChallenge(challenge.challenge, certificateInfo, completionHandler))
return;
-
- AuthenticationClient* coreClient = challenge.authenticationClient();
- if (!coreClient) {
- // This authentication challenge comes from a download.
- Download::receivedCredential(challenge, credential);
+
+ AuthenticationClient* coreClient = challenge.challenge.authenticationClient();
+#if USE(NETWORK_SESSION)
+ // If there is a completion handler, then there is no AuthenticationClient.
+ // FIXME: Remove the use of AuthenticationClient in WebKit2 once NETWORK_SESSION is used for all loads.
+ if (completionHandler) {
+ ASSERT(!coreClient);
+ completionHandler(AuthenticationChallengeDisposition::UseCredential, credential);
return;
}
+#endif
- coreClient->receivedCredential(challenge, credential);
+ if (coreClient)
+ coreClient->receivedCredential(challenge.challenge, credential);
+ else
+ receivedCredential(challenge.challenge, credential);
}
void AuthenticationManager::continueWithoutCredentialForChallenge(uint64_t challengeID)
{
- ASSERT(isMainThread());
+ ASSERT(RunLoop::isMain());
- AuthenticationChallenge challenge = m_challenges.take(challengeID);
- ASSERT(!challenge.isNull());
- AuthenticationClient* coreClient = challenge.authenticationClient();
- if (!coreClient) {
- // This authentication challenge comes from a download.
- Download::receivedRequestToContinueWithoutCredential(challenge);
+ for (auto& coalescedChallengeID : coalesceChallengesMatching(challengeID))
+ continueWithoutCredentialForSingleChallenge(coalescedChallengeID);
+}
+
+void AuthenticationManager::continueWithoutCredentialForSingleChallenge(uint64_t challengeID)
+{
+ auto challenge = m_challenges.take(challengeID);
+ ASSERT(!challenge.challenge.isNull());
+
+ AuthenticationClient* coreClient = challenge.challenge.authenticationClient();
+#if USE(NETWORK_SESSION)
+ if (challenge.completionHandler) {
+ ASSERT(!coreClient);
+ challenge.completionHandler(AuthenticationChallengeDisposition::UseCredential, Credential());
return;
}
+#endif
- coreClient->receivedRequestToContinueWithoutCredential(challenge);
+ if (coreClient)
+ coreClient->receivedRequestToContinueWithoutCredential(challenge.challenge);
+ else
+ receivedRequestToContinueWithoutCredential(challenge.challenge);
}
void AuthenticationManager::cancelChallenge(uint64_t challengeID)
{
- ASSERT(isMainThread());
+ ASSERT(RunLoop::isMain());
+
+ for (auto& coalescedChallengeID : coalesceChallengesMatching(challengeID))
+ cancelSingleChallenge(coalescedChallengeID);
+}
+
+void AuthenticationManager::cancelSingleChallenge(uint64_t challengeID)
+{
+ auto challenge = m_challenges.take(challengeID);
+ ASSERT(!challenge.challenge.isNull());
+
+ AuthenticationClient* coreClient = challenge.challenge.authenticationClient();
+#if USE(NETWORK_SESSION)
+ if (challenge.completionHandler) {
+ ASSERT(!coreClient);
+ challenge.completionHandler(AuthenticationChallengeDisposition::Cancel, Credential());
+ return;
+ }
+#endif
+
+ if (coreClient)
+ coreClient->receivedCancellation(challenge.challenge);
+ else
+ receivedCancellation(challenge.challenge);
+}
+
+void AuthenticationManager::performDefaultHandling(uint64_t challengeID)
+{
+ ASSERT(RunLoop::isMain());
- AuthenticationChallenge challenge = m_challenges.take(challengeID);
- ASSERT(!challenge.isNull());
- AuthenticationClient* coreClient = challenge.authenticationClient();
- if (!coreClient) {
- // This authentication challenge comes from a download.
- Download::receivedCancellation(challenge);
+ for (auto& coalescedChallengeID : coalesceChallengesMatching(challengeID))
+ performDefaultHandlingForSingleChallenge(coalescedChallengeID);
+}
+
+void AuthenticationManager::performDefaultHandlingForSingleChallenge(uint64_t challengeID)
+{
+ auto challenge = m_challenges.take(challengeID);
+ ASSERT(!challenge.challenge.isNull());
+
+ AuthenticationClient* coreClient = challenge.challenge.authenticationClient();
+#if USE(NETWORK_SESSION)
+ if (challenge.completionHandler) {
+ ASSERT(!coreClient);
+ challenge.completionHandler(AuthenticationChallengeDisposition::PerformDefaultHandling, Credential());
return;
}
+#endif
+
+ if (coreClient)
+ coreClient->receivedRequestToPerformDefaultHandling(challenge.challenge);
+ else
+ receivedRequestToPerformDefaultHandling(challenge.challenge);
+}
+
+void AuthenticationManager::rejectProtectionSpaceAndContinue(uint64_t challengeID)
+{
+ ASSERT(RunLoop::isMain());
+
+ for (auto& coalescedChallengeID : coalesceChallengesMatching(challengeID))
+ rejectProtectionSpaceAndContinueForSingleChallenge(coalescedChallengeID);
+}
+
+void AuthenticationManager::rejectProtectionSpaceAndContinueForSingleChallenge(uint64_t challengeID)
+{
+ auto challenge = m_challenges.take(challengeID);
+ ASSERT(!challenge.challenge.isNull());
+
+ AuthenticationClient* coreClient = challenge.challenge.authenticationClient();
+#if USE(NETWORK_SESSION)
+ if (challenge.completionHandler) {
+ ASSERT(!coreClient);
+ challenge.completionHandler(AuthenticationChallengeDisposition::RejectProtectionSpace, Credential());
+ return;
+ }
+#endif
- coreClient->receivedCancellation(challenge);
+ if (coreClient)
+ coreClient->receivedChallengeRejection(challenge.challenge);
+ else
+ receivedChallengeRejection(challenge.challenge);
}
} // namespace WebKit
diff --git a/Source/WebKit2/Shared/Authentication/AuthenticationManager.h b/Source/WebKit2/Shared/Authentication/AuthenticationManager.h
index 6882092f2..6372cd277 100644
--- a/Source/WebKit2/Shared/Authentication/AuthenticationManager.h
+++ b/Source/WebKit2/Shared/Authentication/AuthenticationManager.h
@@ -31,6 +31,7 @@
#include "WebProcessSupplement.h"
#include <WebCore/AuthenticationChallenge.h>
#include <wtf/Forward.h>
+#include <wtf/Function.h>
#include <wtf/HashMap.h>
namespace WebCore {
@@ -43,8 +44,18 @@ namespace WebKit {
class ChildProcess;
class Download;
+class DownloadID;
+class PendingDownload;
class WebFrame;
+enum class AuthenticationChallengeDisposition {
+ UseCredential,
+ PerformDefaultHandling,
+ Cancel,
+ RejectProtectionSpace
+};
+typedef Function<void(AuthenticationChallengeDisposition, const WebCore::Credential&)> ChallengeCompletionHandler;
+
class AuthenticationManager : public WebProcessSupplement, public NetworkProcessSupplement, public IPC::MessageReceiver {
WTF_MAKE_NONCOPYABLE(AuthenticationManager);
public:
@@ -52,31 +63,63 @@ public:
static const char* supplementName();
+#if USE(NETWORK_SESSION)
+ void didReceiveAuthenticationChallenge(uint64_t pageID, uint64_t frameID, const WebCore::AuthenticationChallenge&, ChallengeCompletionHandler&&);
+ void didReceiveAuthenticationChallenge(PendingDownload&, const WebCore::AuthenticationChallenge&, ChallengeCompletionHandler&&);
+#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
+ void continueCanAuthenticateAgainstProtectionSpace(DownloadID, bool canAuthenticate);
+#endif
+#endif
// Called for resources in the WebProcess (NetworkProcess disabled)
void didReceiveAuthenticationChallenge(WebFrame*, const WebCore::AuthenticationChallenge&);
// Called for resources in the NetworkProcess (NetworkProcess enabled)
void didReceiveAuthenticationChallenge(uint64_t pageID, uint64_t frameID, const WebCore::AuthenticationChallenge&);
- // Called for downloads with or without the NetworkProcess
- void didReceiveAuthenticationChallenge(Download*, const WebCore::AuthenticationChallenge&);
+#if !USE(NETWORK_SESSION)
+ void didReceiveAuthenticationChallenge(Download&, const WebCore::AuthenticationChallenge&);
+#endif
void useCredentialForChallenge(uint64_t challengeID, const WebCore::Credential&, const WebCore::CertificateInfo&);
void continueWithoutCredentialForChallenge(uint64_t challengeID);
void cancelChallenge(uint64_t challengeID);
-
+ void performDefaultHandling(uint64_t challengeID);
+ void rejectProtectionSpaceAndContinue(uint64_t challengeID);
+
uint64_t outstandingAuthenticationChallengeCount() const { return m_challenges.size(); }
+ static void receivedCredential(const WebCore::AuthenticationChallenge&, const WebCore::Credential&);
+ static void receivedRequestToContinueWithoutCredential(const WebCore::AuthenticationChallenge&);
+ static void receivedCancellation(const WebCore::AuthenticationChallenge&);
+ static void receivedRequestToPerformDefaultHandling(const WebCore::AuthenticationChallenge&);
+ static void receivedChallengeRejection(const WebCore::AuthenticationChallenge&);
+
private:
+ struct Challenge {
+ uint64_t pageID;
+ WebCore::AuthenticationChallenge challenge;
+#if USE(NETWORK_SESSION)
+ ChallengeCompletionHandler completionHandler;
+#endif
+ };
+
// IPC::MessageReceiver
- virtual void didReceiveMessage(IPC::Connection*, IPC::MessageDecoder&) override;
+ void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
+
+ bool tryUseCertificateInfoForChallenge(const WebCore::AuthenticationChallenge&, const WebCore::CertificateInfo&, const ChallengeCompletionHandler&);
+
+ uint64_t addChallengeToChallengeMap(Challenge&&);
+ bool shouldCoalesceChallenge(uint64_t pageID, uint64_t challengeID, const WebCore::AuthenticationChallenge&) const;
- bool tryUseCertificateInfoForChallenge(const WebCore::AuthenticationChallenge&, const WebCore::CertificateInfo&);
+ void useCredentialForSingleChallenge(uint64_t challengeID, const WebCore::Credential&, const WebCore::CertificateInfo&);
+ void continueWithoutCredentialForSingleChallenge(uint64_t challengeID);
+ void cancelSingleChallenge(uint64_t challengeID);
+ void performDefaultHandlingForSingleChallenge(uint64_t challengeID);
+ void rejectProtectionSpaceAndContinueForSingleChallenge(uint64_t challengeID);
- uint64_t establishIdentifierForChallenge(const WebCore::AuthenticationChallenge&);
+ Vector<uint64_t> coalesceChallengesMatching(uint64_t challengeID) const;
ChildProcess* m_process;
- typedef HashMap<uint64_t, WebCore::AuthenticationChallenge> AuthenticationChallengeMap;
- AuthenticationChallengeMap m_challenges;
+ HashMap<uint64_t, Challenge> m_challenges;
};
} // namespace WebKit
diff --git a/Source/WebKit2/Shared/Authentication/AuthenticationManager.messages.in b/Source/WebKit2/Shared/Authentication/AuthenticationManager.messages.in
index 34db9b208..da79cecf5 100644
--- a/Source/WebKit2/Shared/Authentication/AuthenticationManager.messages.in
+++ b/Source/WebKit2/Shared/Authentication/AuthenticationManager.messages.in
@@ -24,4 +24,6 @@ messages -> AuthenticationManager {
void UseCredentialForChallenge(uint64_t challengeID, WebCore::Credential credential, WebCore::CertificateInfo certificate);
void ContinueWithoutCredentialForChallenge(uint64_t challengeID);
void CancelChallenge(uint64_t challengeID);
+ void PerformDefaultHandling(uint64_t challengeID);
+ void RejectProtectionSpaceAndContinue(uint64_t challengeID);
}
diff --git a/Source/WebKit2/Shared/MutableDictionary.cpp b/Source/WebKit2/Shared/Authentication/soup/AuthenticationManagerSoup.cpp
index 2b3df7ed0..c26f2e5e7 100644
--- a/Source/WebKit2/Shared/MutableDictionary.cpp
+++ b/Source/WebKit2/Shared/Authentication/soup/AuthenticationManagerSoup.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -24,34 +24,30 @@
*/
#include "config.h"
-#include "MutableDictionary.h"
+#include "AuthenticationManager.h"
+
+using namespace WebCore;
namespace WebKit {
-MutableDictionary::MutableDictionary()
- : ImmutableDictionary({ })
+void AuthenticationManager::receivedCredential(const AuthenticationChallenge&, const Credential&)
{
}
-MutableDictionary::~MutableDictionary()
+void AuthenticationManager::receivedRequestToContinueWithoutCredential(const AuthenticationChallenge&)
{
}
-bool MutableDictionary::add(const String& key, PassRefPtr<API::Object> item)
+void AuthenticationManager::receivedCancellation(const AuthenticationChallenge&)
{
- MapType::AddResult result = m_map.add(key, item);
- return result.isNewEntry;
}
-bool MutableDictionary::set(const String& key, PassRefPtr<API::Object> item)
+void AuthenticationManager::receivedRequestToPerformDefaultHandling(const AuthenticationChallenge&)
{
- MapType::AddResult result = m_map.set(key, item);
- return result.isNewEntry;
}
-void MutableDictionary::remove(const String& key)
+void AuthenticationManager::receivedChallengeRejection(const AuthenticationChallenge&)
{
- m_map.remove(key);
}
-} // namespace WebKit
+}
diff --git a/Source/WebKit2/Shared/WebResourceBuffer.cpp b/Source/WebKit2/Shared/BlobDataFileReferenceWithSandboxExtension.cpp
index 54b9eb32e..fb5e04f05 100644
--- a/Source/WebKit2/Shared/WebResourceBuffer.cpp
+++ b/Source/WebKit2/Shared/BlobDataFileReferenceWithSandboxExtension.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -24,40 +24,32 @@
*/
#include "config.h"
-#include "WebResourceBuffer.h"
+#include "BlobDataFileReferenceWithSandboxExtension.h"
-#if ENABLE(SHAREABLE_RESOURCE)
-
-#include "Logging.h"
-#include "ShareableResource.h"
+#include "SandboxExtension.h"
namespace WebKit {
-WebResourceBuffer::WebResourceBuffer(PassRefPtr<ShareableResource> resource)
- : m_resource(resource)
+BlobDataFileReferenceWithSandboxExtension::BlobDataFileReferenceWithSandboxExtension(const String& path, PassRefPtr<SandboxExtension> sandboxExtension)
+ : BlobDataFileReference(path)
+ , m_sandboxExtension(sandboxExtension)
{
- ASSERT(m_resource);
}
-WebResourceBuffer::~WebResourceBuffer()
+BlobDataFileReferenceWithSandboxExtension::~BlobDataFileReferenceWithSandboxExtension()
{
}
-const char* WebResourceBuffer::data() const
+void BlobDataFileReferenceWithSandboxExtension::prepareForFileAccess()
{
- return reinterpret_cast<const char*>(m_resource->data());
+ if (m_sandboxExtension)
+ m_sandboxExtension->consume();
}
-unsigned WebResourceBuffer::size() const
+void BlobDataFileReferenceWithSandboxExtension::revokeFileAccess()
{
- return m_resource->size();
+ if (m_sandboxExtension)
+ m_sandboxExtension->revoke();
}
-bool WebResourceBuffer::isEmpty() const
-{
- return !m_resource || !m_resource->size();
}
-
-} // namespace WebKit
-
-#endif // ENABLE(SHAREABLE_RESOURCE)
diff --git a/Source/WebKit2/Shared/MutableDictionary.h b/Source/WebKit2/Shared/BlobDataFileReferenceWithSandboxExtension.h
index ec39e7050..7ae8d2a6f 100644
--- a/Source/WebKit2/Shared/MutableDictionary.h
+++ b/Source/WebKit2/Shared/BlobDataFileReferenceWithSandboxExtension.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -23,34 +23,32 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef MutableDictionary_h
-#define MutableDictionary_h
+#ifndef BlobDataFileReferenceWithSandboxExtension_h
+#define BlobDataFileReferenceWithSandboxExtension_h
-#include "ImmutableDictionary.h"
+#include <WebCore/BlobDataFileReference.h>
namespace WebKit {
-// MutableDictionary - A mutable dictionary type suitable for vending to an API.
+class SandboxExtension;
-class MutableDictionary : public ImmutableDictionary {
+class BlobDataFileReferenceWithSandboxExtension final : public WebCore::BlobDataFileReference {
public:
- static PassRefPtr<MutableDictionary> create()
+ static Ref<BlobDataFileReference> create(const String& path, PassRefPtr<SandboxExtension> sandboxExtension)
{
- return adoptRef(new MutableDictionary);
+ return adoptRef(*new BlobDataFileReferenceWithSandboxExtension(path, sandboxExtension));
}
- ~MutableDictionary();
-
- bool add(const String& key, PassRefPtr<API::Object>);
- bool set(const String& key, PassRefPtr<API::Object>);
- void remove(const String& key);
+private:
+ BlobDataFileReferenceWithSandboxExtension(const String& path, PassRefPtr<SandboxExtension>);
+ virtual ~BlobDataFileReferenceWithSandboxExtension();
- virtual bool isMutable() { return true; }
+ void prepareForFileAccess() override;
+ void revokeFileAccess() override;
-private:
- MutableDictionary();
+ RefPtr<SandboxExtension> m_sandboxExtension;
};
-} // namespace WebKit
+}
-#endif // MutableDictionary_h
+#endif // BlobDataFileReferenceWithSandboxExtension_h
diff --git a/Source/WebKit2/Shared/BlockingResponseMap.h b/Source/WebKit2/Shared/BlockingResponseMap.h
index f4529af4f..728c8477b 100644
--- a/Source/WebKit2/Shared/BlockingResponseMap.h
+++ b/Source/WebKit2/Shared/BlockingResponseMap.h
@@ -26,8 +26,9 @@
#ifndef BlockingResponseMap_h
#define BlockingResponseMap_h
-#include <condition_variable>
+#include <wtf/Condition.h>
#include <wtf/HashMap.h>
+#include <wtf/Lock.h>
#include <wtf/Noncopyable.h>
template<typename T>
@@ -40,7 +41,7 @@ public:
std::unique_ptr<T> waitForResponse(uint64_t requestID)
{
while (true) {
- std::unique_lock<std::mutex> lock(m_mutex);
+ std::unique_lock<Lock> lock(m_mutex);
if (m_canceled)
return nullptr;
@@ -56,26 +57,26 @@ public:
void didReceiveResponse(uint64_t requestID, std::unique_ptr<T> response)
{
- std::lock_guard<std::mutex> lock(m_mutex);
+ std::lock_guard<Lock> lock(m_mutex);
ASSERT(!m_responses.contains(requestID));
- m_responses.set(requestID, std::move(response));
+ m_responses.set(requestID, WTFMove(response));
- // FIXME: Waking up all threads is quite inefficient.
- m_condition.notify_all();
+ // FIXME: Could get a slight speed-up from using notifyOne().
+ m_condition.notifyAll();
}
void cancel()
{
m_canceled = true;
- // FIXME: Waking up all threads is quite inefficient.
- m_condition.notify_all();
+ // FIXME: Could get a slight speed-up from using notifyOne().
+ m_condition.notifyAll();
}
private:
- std::mutex m_mutex;
- std::condition_variable m_condition;
+ Lock m_mutex;
+ Condition m_condition;
HashMap<uint64_t, std::unique_ptr<T>> m_responses;
bool m_canceled;
diff --git a/Source/WebKit2/Shared/CacheModel.cpp b/Source/WebKit2/Shared/CacheModel.cpp
index 9439e5a78..403f34dfc 100644
--- a/Source/WebKit2/Shared/CacheModel.cpp
+++ b/Source/WebKit2/Shared/CacheModel.cpp
@@ -27,13 +27,15 @@
#include "CacheModel.h"
#include <algorithm>
+#include <wtf/RAMSize.h>
+#include <wtf/StdLibExtras.h>
namespace WebKit {
-void calculateCacheSizes(CacheModel cacheModel, uint64_t memorySize, uint64_t diskFreeSize,
- unsigned& cacheTotalCapacity, unsigned& cacheMinDeadCapacity, unsigned& cacheMaxDeadCapacity, double& deadDecodedDataDeletionInterval,
- unsigned& pageCacheCapacity, unsigned long& urlCacheMemoryCapacity, unsigned long& urlCacheDiskCapacity)
+void calculateMemoryCacheSizes(CacheModel cacheModel, unsigned& cacheTotalCapacity, unsigned& cacheMinDeadCapacity, unsigned& cacheMaxDeadCapacity, std::chrono::seconds& deadDecodedDataDeletionInterval, unsigned& pageCacheCapacity)
{
+ uint64_t memorySize = ramSize() / MB;
+
switch (cacheModel) {
case CacheModelDocumentViewer: {
// Page cache capacity (in pages)
@@ -41,30 +43,22 @@ void calculateCacheSizes(CacheModel cacheModel, uint64_t memorySize, uint64_t di
// Object cache capacities (in bytes)
if (memorySize >= 2048)
- cacheTotalCapacity = 96 * 1024 * 1024;
+ cacheTotalCapacity = 96 * MB;
else if (memorySize >= 1536)
- cacheTotalCapacity = 64 * 1024 * 1024;
+ cacheTotalCapacity = 64 * MB;
else if (memorySize >= 1024)
- cacheTotalCapacity = 32 * 1024 * 1024;
+ cacheTotalCapacity = 32 * MB;
else if (memorySize >= 512)
- cacheTotalCapacity = 16 * 1024 * 1024;
+ cacheTotalCapacity = 16 * MB;
cacheMinDeadCapacity = 0;
cacheMaxDeadCapacity = 0;
- // Foundation memory cache capacity (in bytes)
- urlCacheMemoryCapacity = 0;
-
- // Foundation disk cache capacity (in bytes)
- urlCacheDiskCapacity = 0;
-
break;
}
case CacheModelDocumentBrowser: {
// Page cache capacity (in pages)
- if (memorySize >= 1024)
- pageCacheCapacity = 3;
- else if (memorySize >= 512)
+ if (memorySize >= 512)
pageCacheCapacity = 2;
else if (memorySize >= 256)
pageCacheCapacity = 1;
@@ -73,44 +67,22 @@ void calculateCacheSizes(CacheModel cacheModel, uint64_t memorySize, uint64_t di
// Object cache capacities (in bytes)
if (memorySize >= 2048)
- cacheTotalCapacity = 96 * 1024 * 1024;
+ cacheTotalCapacity = 96 * MB;
else if (memorySize >= 1536)
- cacheTotalCapacity = 64 * 1024 * 1024;
+ cacheTotalCapacity = 64 * MB;
else if (memorySize >= 1024)
- cacheTotalCapacity = 32 * 1024 * 1024;
+ cacheTotalCapacity = 32 * MB;
else if (memorySize >= 512)
- cacheTotalCapacity = 16 * 1024 * 1024;
+ cacheTotalCapacity = 16 * MB;
cacheMinDeadCapacity = cacheTotalCapacity / 8;
cacheMaxDeadCapacity = cacheTotalCapacity / 4;
- // Foundation memory cache capacity (in bytes)
- if (memorySize >= 2048)
- urlCacheMemoryCapacity = 4 * 1024 * 1024;
- else if (memorySize >= 1024)
- urlCacheMemoryCapacity = 2 * 1024 * 1024;
- else if (memorySize >= 512)
- urlCacheMemoryCapacity = 1 * 1024 * 1024;
- else
- urlCacheMemoryCapacity = 512 * 1024;
-
- // Foundation disk cache capacity (in bytes)
- if (diskFreeSize >= 16384)
- urlCacheDiskCapacity = 50 * 1024 * 1024;
- else if (diskFreeSize >= 8192)
- urlCacheDiskCapacity = 40 * 1024 * 1024;
- else if (diskFreeSize >= 4096)
- urlCacheDiskCapacity = 30 * 1024 * 1024;
- else
- urlCacheDiskCapacity = 20 * 1024 * 1024;
-
break;
}
case CacheModelPrimaryWebBrowser: {
// Page cache capacity (in pages)
- if (memorySize >= 1024)
- pageCacheCapacity = 3;
- else if (memorySize >= 512)
+ if (memorySize >= 512)
pageCacheCapacity = 2;
else if (memorySize >= 256)
pageCacheCapacity = 1;
@@ -119,16 +91,16 @@ void calculateCacheSizes(CacheModel cacheModel, uint64_t memorySize, uint64_t di
// Object cache capacities (in bytes)
// (Testing indicates that value / MB depends heavily on content and
- // browsing pattern. Even growth above 128MB can have substantial
+ // browsing pattern. Even growth above 128MB can have substantial
// value / MB for some content / browsing patterns.)
if (memorySize >= 2048)
- cacheTotalCapacity = 128 * 1024 * 1024;
+ cacheTotalCapacity = 128 * MB;
else if (memorySize >= 1536)
- cacheTotalCapacity = 96 * 1024 * 1024;
+ cacheTotalCapacity = 96 * MB;
else if (memorySize >= 1024)
- cacheTotalCapacity = 64 * 1024 * 1024;
+ cacheTotalCapacity = 64 * MB;
else if (memorySize >= 512)
- cacheTotalCapacity = 32 * 1024 * 1024;
+ cacheTotalCapacity = 32 * MB;
cacheMinDeadCapacity = cacheTotalCapacity / 4;
cacheMaxDeadCapacity = cacheTotalCapacity / 2;
@@ -137,32 +109,86 @@ void calculateCacheSizes(CacheModel cacheModel, uint64_t memorySize, uint64_t di
// can prove that the overall system gain would justify the regression.
cacheMaxDeadCapacity = std::max(24u, cacheMaxDeadCapacity);
- deadDecodedDataDeletionInterval = 60;
+ deadDecodedDataDeletionInterval = std::chrono::seconds { 60 };
+
+ break;
+ }
+ default:
+ ASSERT_NOT_REACHED();
+ };
+}
+void calculateURLCacheSizes(CacheModel cacheModel, uint64_t diskFreeSize, unsigned& urlCacheMemoryCapacity, uint64_t& urlCacheDiskCapacity)
+{
+ switch (cacheModel) {
+ case CacheModelDocumentViewer: {
+ // Foundation memory cache capacity (in bytes)
+ urlCacheMemoryCapacity = 0;
+
+ // Disk cache capacity (in bytes)
+ urlCacheDiskCapacity = 0;
+
+ break;
+ }
+ case CacheModelDocumentBrowser: {
+ uint64_t memorySize = ramSize() / MB;
+
+ // Foundation memory cache capacity (in bytes)
+ if (memorySize >= 2048)
+ urlCacheMemoryCapacity = 4 * MB;
+ else if (memorySize >= 1024)
+ urlCacheMemoryCapacity = 2 * MB;
+ else if (memorySize >= 512)
+ urlCacheMemoryCapacity = 1 * MB;
+ else
+ urlCacheMemoryCapacity = 512 * KB;
+
+ // Disk cache capacity (in bytes)
+ if (diskFreeSize >= 16384)
+ urlCacheDiskCapacity = 75 * MB;
+ else if (diskFreeSize >= 8192)
+ urlCacheDiskCapacity = 40 * MB;
+ else if (diskFreeSize >= 4096)
+ urlCacheDiskCapacity = 30 * MB;
+ else
+ urlCacheDiskCapacity = 20 * MB;
+
+ break;
+ }
+ case CacheModelPrimaryWebBrowser: {
+ uint64_t memorySize = ramSize() / MB;
+
+#if PLATFORM(IOS)
+ if (memorySize >= 1024)
+ urlCacheMemoryCapacity = 16 * MB;
+ else
+ urlCacheMemoryCapacity = 8 * MB;
+#else
// Foundation memory cache capacity (in bytes)
// (These values are small because WebCore does most caching itself.)
if (memorySize >= 1024)
- urlCacheMemoryCapacity = 4 * 1024 * 1024;
+ urlCacheMemoryCapacity = 4 * MB;
else if (memorySize >= 512)
- urlCacheMemoryCapacity = 2 * 1024 * 1024;
+ urlCacheMemoryCapacity = 2 * MB;
else if (memorySize >= 256)
- urlCacheMemoryCapacity = 1 * 1024 * 1024;
+ urlCacheMemoryCapacity = 1 * MB;
else
- urlCacheMemoryCapacity = 512 * 1024;
+ urlCacheMemoryCapacity = 512 * KB;
+#endif
- // Foundation disk cache capacity (in bytes)
+ // Disk cache capacity (in bytes)
if (diskFreeSize >= 16384)
- urlCacheDiskCapacity = 175 * 1024 * 1024;
+ urlCacheDiskCapacity = 500 * MB;
else if (diskFreeSize >= 8192)
- urlCacheDiskCapacity = 150 * 1024 * 1024;
+ urlCacheDiskCapacity = 250 * MB;
else if (diskFreeSize >= 4096)
- urlCacheDiskCapacity = 125 * 1024 * 1024;
+ urlCacheDiskCapacity = 125 * MB;
else if (diskFreeSize >= 2048)
- urlCacheDiskCapacity = 100 * 1024 * 1024;
+ urlCacheDiskCapacity = 100 * MB;
else if (diskFreeSize >= 1024)
- urlCacheDiskCapacity = 75 * 1024 * 1024;
+ urlCacheDiskCapacity = 75 * MB;
else
- urlCacheDiskCapacity = 50 * 1024 * 1024;
+ urlCacheDiskCapacity = 50 * MB;
break;
}
diff --git a/Source/WebKit2/Shared/CacheModel.h b/Source/WebKit2/Shared/CacheModel.h
index fe8c9bbee..cf473454f 100644
--- a/Source/WebKit2/Shared/CacheModel.h
+++ b/Source/WebKit2/Shared/CacheModel.h
@@ -26,6 +26,7 @@
#ifndef CacheModel_h
#define CacheModel_h
+#include <chrono>
#include <stdint.h>
namespace WebKit {
@@ -36,9 +37,8 @@ enum CacheModel {
CacheModelPrimaryWebBrowser
};
-void calculateCacheSizes(CacheModel cacheModel, uint64_t memorySize, uint64_t diskFreeSize,
- unsigned& cacheTotalCapacity, unsigned& cacheMinDeadCapacity, unsigned& cacheMaxDeadCapacity, double& deadDecodedDataDeletionInterval,
- unsigned& pageCacheCapacity, unsigned long& urlCacheMemoryCapacity, unsigned long& urlCacheDiskCapacity);
+void calculateMemoryCacheSizes(CacheModel, unsigned& cacheTotalCapacity, unsigned& cacheMinDeadCapacity, unsigned& cacheMaxDeadCapacity, std::chrono::seconds& deadDecodedDataDeletionInterval, unsigned& pageCacheCapacity);
+void calculateURLCacheSizes(CacheModel, uint64_t diskFreeSize, unsigned& urlCacheMemoryCapacity, uint64_t& urlCacheDiskCapacity);
} // namespace WebKit
diff --git a/Source/WebKit2/Shared/ChildProcess.cpp b/Source/WebKit2/Shared/ChildProcess.cpp
index 749009e54..cde508ca5 100644
--- a/Source/WebKit2/Shared/ChildProcess.cpp
+++ b/Source/WebKit2/Shared/ChildProcess.cpp
@@ -26,6 +26,7 @@
#include "config.h"
#include "ChildProcess.h"
+#include "Logging.h"
#include "SandboxInitializationParameters.h"
#include <unistd.h>
@@ -36,7 +37,6 @@ ChildProcess::ChildProcess()
, m_terminationCounter(0)
, m_terminationTimer(RunLoop::main(), this, &ChildProcess::terminationTimerFired)
, m_processSuppressionDisabled("Process Suppression Disabled by UIProcess")
- , m_activeTasks("Process Suppression Disabled by WebProcess")
{
}
@@ -50,10 +50,11 @@ static void didCloseOnConnectionWorkQueue(IPC::Connection*)
// the process will exit forcibly.
auto watchdogDelay = std::chrono::seconds(10);
- WorkQueue::create("com.apple.WebKit.ChildProcess.WatchDogQueue")->dispatchAfter(watchdogDelay, []{
+ WorkQueue::create("com.apple.WebKit.ChildProcess.WatchDogQueue")->dispatchAfter(watchdogDelay, [] {
// We use _exit here since the watchdog callback is called from another thread and we don't want
// global destructors or atexit handlers to be called from this thread while the main thread is busy
// doing its thing.
+ RELEASE_LOG_ERROR(IPC, "Exiting process early due to unacknowledged closed-connection");
_exit(EXIT_FAILURE);
});
}
@@ -62,13 +63,17 @@ void ChildProcess::initialize(const ChildProcessInitializationParameters& parame
{
platformInitialize();
+#if PLATFORM(COCOA)
+ m_priorityBoostMessage = parameters.priorityBoostMessage;
+#endif
+
initializeProcess(parameters);
initializeProcessName(parameters);
SandboxInitializationParameters sandboxParameters;
initializeSandbox(parameters, sandboxParameters);
- m_connection = IPC::Connection::createClientConnection(parameters.connectionIdentifier, this, RunLoop::main());
+ m_connection = IPC::Connection::createClientConnection(parameters.connectionIdentifier, *this);
m_connection->setDidCloseOnConnectionWorkQueueCallback(didCloseOnConnectionWorkQueue);
initializeConnection(m_connection.get());
m_connection->open();
@@ -76,23 +81,10 @@ void ChildProcess::initialize(const ChildProcessInitializationParameters& parame
void ChildProcess::setProcessSuppressionEnabled(bool enabled)
{
- if (processSuppressionEnabled() == enabled)
- return;
-
if (enabled)
- m_processSuppressionDisabled.endActivity();
+ m_processSuppressionDisabled.stop();
else
- m_processSuppressionDisabled.beginActivity();
-}
-
-void ChildProcess::incrementActiveTaskCount()
-{
- m_activeTasks.beginActivity();
-}
-
-void ChildProcess::decrementActiveTaskCount()
-{
- m_activeTasks.endActivity();
+ m_processSuppressionDisabled.start();
}
void ChildProcess::initializeProcess(const ChildProcessInitializationParameters&)
@@ -122,6 +114,16 @@ void ChildProcess::removeMessageReceiver(IPC::StringReference messageReceiverNam
m_messageReceiverMap.removeMessageReceiver(messageReceiverName, destinationID);
}
+void ChildProcess::removeMessageReceiver(IPC::StringReference messageReceiverName)
+{
+ m_messageReceiverMap.removeMessageReceiver(messageReceiverName);
+}
+
+void ChildProcess::removeMessageReceiver(IPC::MessageReceiver& messageReceiver)
+{
+ m_messageReceiverMap.removeMessageReceiver(messageReceiver);
+}
+
void ChildProcess::disableTermination()
{
m_terminationCounter++;
@@ -164,9 +166,16 @@ void ChildProcess::terminationTimerFired()
void ChildProcess::stopRunLoop()
{
- RunLoop::main()->stop();
+ platformStopRunLoop();
}
+#if !PLATFORM(IOS)
+void ChildProcess::platformStopRunLoop()
+{
+ RunLoop::main().stop();
+}
+#endif
+
void ChildProcess::terminate()
{
m_connection->invalidate();
@@ -174,7 +183,12 @@ void ChildProcess::terminate()
stopRunLoop();
}
-#if !PLATFORM(MAC)
+void ChildProcess::shutDown()
+{
+ terminate();
+}
+
+#if !PLATFORM(COCOA)
void ChildProcess::platformInitialize()
{
}
@@ -182,6 +196,12 @@ void ChildProcess::platformInitialize()
void ChildProcess::initializeSandbox(const ChildProcessInitializationParameters&, SandboxInitializationParameters&)
{
}
+
+void ChildProcess::didReceiveInvalidMessage(IPC::Connection&, IPC::StringReference messageReceiverName, IPC::StringReference messageName)
+{
+ WTFLogAlways("Received invalid message: '%s::%s'", messageReceiverName.toString().data(), messageName.toString().data());
+ CRASH();
+}
#endif
} // namespace WebKit
diff --git a/Source/WebKit2/Shared/ChildProcess.h b/Source/WebKit2/Shared/ChildProcess.h
index 7bad87f6d..8ba24de45 100644
--- a/Source/WebKit2/Shared/ChildProcess.h
+++ b/Source/WebKit2/Shared/ChildProcess.h
@@ -31,7 +31,6 @@
#include "MessageSender.h"
#include <WebCore/UserActivity.h>
#include <wtf/HashMap.h>
-#include <wtf/RetainPtr.h>
#include <wtf/RunLoop.h>
#include <wtf/text/StringHash.h>
#include <wtf/text/WTFString.h>
@@ -45,6 +44,9 @@ struct ChildProcessInitializationParameters {
String clientIdentifier;
IPC::Connection::Identifier connectionIdentifier;
HashMap<String, String> extraInitializationData;
+#if PLATFORM(COCOA)
+ OSObjectPtr<xpc_object_t> priorityBoostMessage;
+#endif
};
class ChildProcess : protected IPC::Connection::Client, public IPC::MessageSender {
@@ -61,13 +63,12 @@ public:
void addMessageReceiver(IPC::StringReference messageReceiverName, IPC::MessageReceiver&);
void addMessageReceiver(IPC::StringReference messageReceiverName, uint64_t destinationID, IPC::MessageReceiver&);
void removeMessageReceiver(IPC::StringReference messageReceiverName, uint64_t destinationID);
+ void removeMessageReceiver(IPC::StringReference messageReceiverName);
+ void removeMessageReceiver(IPC::MessageReceiver&);
void setProcessSuppressionEnabled(bool);
- bool processSuppressionEnabled() const { return !m_processSuppressionDisabled.isActive(); }
- void incrementActiveTaskCount();
- void decrementActiveTaskCount();
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
void setApplicationIsDaemon();
void setQOS(int latencyQOS, int throughputQOS);
#endif
@@ -87,23 +88,35 @@ protected:
virtual void initializeSandbox(const ChildProcessInitializationParameters&, SandboxInitializationParameters&);
virtual void initializeConnection(IPC::Connection*);
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100
+ static void setSharedHTTPCookieStorage(const Vector<uint8_t>& identifier);
+#endif
+
virtual bool shouldTerminate() = 0;
virtual void terminate();
virtual void stopRunLoop();
-#if PLATFORM(MAC)
+#if USE(APPKIT)
static void stopNSAppRunLoop();
#endif
+ void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
+
private:
// IPC::MessageSender
- virtual IPC::Connection* messageSenderConnection() override;
- virtual uint64_t messageSenderDestinationID() override;
+ IPC::Connection* messageSenderConnection() override;
+ uint64_t messageSenderDestinationID() override;
+
+ // IPC::Connection::Client.
+ void didReceiveInvalidMessage(IPC::Connection&, IPC::StringReference messageReceiverName, IPC::StringReference messageName) final;
+
+ void shutDown();
void terminationTimerFired();
void platformInitialize();
+ void platformStopRunLoop();
// The timeout, in seconds, before this process will be terminated if termination
// has been enabled. If the timeout is 0 seconds, the process will be terminated immediately.
@@ -119,7 +132,10 @@ private:
IPC::MessageReceiverMap m_messageReceiverMap;
UserActivity m_processSuppressionDisabled;
- UserActivity m_activeTasks;
+
+#if PLATFORM(COCOA)
+ OSObjectPtr<xpc_object_t> m_priorityBoostMessage;
+#endif
};
} // namespace WebKit
diff --git a/Source/WebKit2/Shared/Network/CustomProtocols/CustomProtocolManager.messages.in b/Source/WebKit2/Shared/ChildProcess.messages.in
index 2376d929d..49dfb050c 100644
--- a/Source/WebKit2/Shared/Network/CustomProtocols/CustomProtocolManager.messages.in
+++ b/Source/WebKit2/Shared/ChildProcess.messages.in
@@ -1,4 +1,4 @@
-# Copyright (C) 2012 Apple Inc. All rights reserved.
+# 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
@@ -20,16 +20,6 @@
# 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.
-#if ENABLE(CUSTOM_PROTOCOLS)
-
-messages -> CustomProtocolManager {
- DidFailWithError(uint64_t customProtocolID, WebCore::ResourceError error)
- DidLoadData(uint64_t customProtocolID, IPC::DataReference data)
- DidReceiveResponse(uint64_t customProtocolID, WebCore::ResourceResponse response, uint32_t cacheStoragePolicy)
- DidFinishLoading(uint64_t customProtocolID)
-
- RegisterScheme(String name)
- UnregisterScheme(String name)
+messages -> ChildProcess {
+ ShutDown()
}
-
-#endif // ENABLE(CUSTOM_PROTOCOLS)
diff --git a/Source/WebKit2/Shared/ChildProcessProxy.cpp b/Source/WebKit2/Shared/ChildProcessProxy.cpp
deleted file mode 100644
index 264d10b24..000000000
--- a/Source/WebKit2/Shared/ChildProcessProxy.cpp
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "config.h"
-#include "ChildProcessProxy.h"
-
-#include <wtf/RunLoop.h>
-
-namespace WebKit {
-
-ChildProcessProxy::ChildProcessProxy()
-{
-}
-
-ChildProcessProxy::~ChildProcessProxy()
-{
- if (m_connection)
- m_connection->invalidate();
-
- if (m_processLauncher) {
- m_processLauncher->invalidate();
- m_processLauncher = 0;
- }
-}
-
-ChildProcessProxy* ChildProcessProxy::fromConnection(IPC::Connection* connection)
-{
- ASSERT(connection);
-
- ChildProcessProxy* childProcessProxy = static_cast<ChildProcessProxy*>(connection->client());
- ASSERT(childProcessProxy->connection() == connection);
-
- return childProcessProxy;
-}
-
-void ChildProcessProxy::connect()
-{
- ASSERT(!m_processLauncher);
- ProcessLauncher::LaunchOptions launchOptions;
- getLaunchOptions(launchOptions);
- m_processLauncher = ProcessLauncher::create(this, launchOptions);
-}
-
-void ChildProcessProxy::terminate()
-{
- if (m_processLauncher)
- m_processLauncher->terminateProcess();
-}
-
-bool ChildProcessProxy::sendMessage(std::unique_ptr<IPC::MessageEncoder> encoder, unsigned messageSendFlags)
-{
- // If we're waiting for the child process to launch, we need to stash away the messages so we can send them once we have a connection.
- if (isLaunching()) {
- m_pendingMessages.append(std::make_pair(std::move(encoder), messageSendFlags));
- return true;
- }
-
- // If the web process has exited, connection will be null here.
- if (!m_connection)
- return false;
-
- return connection()->sendMessage(std::move(encoder), messageSendFlags);
-}
-
-void ChildProcessProxy::addMessageReceiver(IPC::StringReference messageReceiverName, IPC::MessageReceiver& messageReceiver)
-{
- m_messageReceiverMap.addMessageReceiver(messageReceiverName, messageReceiver);
-}
-
-void ChildProcessProxy::addMessageReceiver(IPC::StringReference messageReceiverName, uint64_t destinationID, IPC::MessageReceiver& messageReceiver)
-{
- m_messageReceiverMap.addMessageReceiver(messageReceiverName, destinationID, messageReceiver);
-}
-
-void ChildProcessProxy::removeMessageReceiver(IPC::StringReference messageReceiverName, uint64_t destinationID)
-{
- m_messageReceiverMap.removeMessageReceiver(messageReceiverName, destinationID);
-}
-
-bool ChildProcessProxy::dispatchMessage(IPC::Connection* connection, IPC::MessageDecoder& decoder)
-{
- return m_messageReceiverMap.dispatchMessage(connection, decoder);
-}
-
-bool ChildProcessProxy::dispatchSyncMessage(IPC::Connection* connection, IPC::MessageDecoder& decoder, std::unique_ptr<IPC::MessageEncoder>& replyEncoder)
-{
- return m_messageReceiverMap.dispatchSyncMessage(connection, decoder, replyEncoder);
-}
-
-bool ChildProcessProxy::isLaunching() const
-{
- if (m_processLauncher)
- return m_processLauncher->isLaunching();
-
- return false;
-}
-
-void ChildProcessProxy::didFinishLaunching(ProcessLauncher*, IPC::Connection::Identifier connectionIdentifier)
-{
- ASSERT(!m_connection);
-
- m_connection = IPC::Connection::createServerConnection(connectionIdentifier, this, RunLoop::main());
-#if OS(DARWIN)
- m_connection->setShouldCloseConnectionOnMachExceptions();
-#endif
-
- connectionWillOpen(m_connection.get());
- m_connection->open();
-
- for (size_t i = 0; i < m_pendingMessages.size(); ++i) {
- std::unique_ptr<IPC::MessageEncoder> message = std::move(m_pendingMessages[i].first);
- unsigned messageSendFlags = m_pendingMessages[i].second;
- m_connection->sendMessage(std::move(message), messageSendFlags);
- }
-
- m_pendingMessages.clear();
-}
-
-void ChildProcessProxy::abortProcessLaunchIfNeeded()
-{
- if (!isLaunching())
- return;
-
- m_processLauncher->invalidate();
- m_processLauncher = 0;
-}
-
-void ChildProcessProxy::clearConnection()
-{
- if (!m_connection)
- return;
-
- connectionWillClose(m_connection.get());
-
- m_connection->invalidate();
- m_connection = nullptr;
-}
-
-void ChildProcessProxy::connectionWillOpen(IPC::Connection*)
-{
-}
-
-void ChildProcessProxy::connectionWillClose(IPC::Connection*)
-{
-}
-
-} // namespace WebKit
diff --git a/Source/WebKit2/Shared/ChildProcessProxy.h b/Source/WebKit2/Shared/ChildProcessProxy.h
deleted file mode 100644
index f53b98a52..000000000
--- a/Source/WebKit2/Shared/ChildProcessProxy.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#ifndef ChildProcessProxy_h
-#define ChildProcessProxy_h
-
-#include "Connection.h"
-#include "MessageReceiverMap.h"
-#include "ProcessLauncher.h"
-
-#include <wtf/ThreadSafeRefCounted.h>
-
-namespace WebKit {
-
-class ChildProcessProxy : ProcessLauncher::Client, public IPC::Connection::Client, public ThreadSafeRefCounted<ChildProcessProxy> {
- WTF_MAKE_NONCOPYABLE(ChildProcessProxy);
-
-public:
- ChildProcessProxy();
- virtual ~ChildProcessProxy();
-
- // FIXME: This function does an unchecked upcast, and it is only used in a deprecated code path. Would like to get rid of it.
- static ChildProcessProxy* fromConnection(IPC::Connection*);
-
- void connect();
- void terminate();
-
- template<typename T> bool send(T&& message, uint64_t destinationID, unsigned messageSendFlags = 0);
- template<typename T> bool sendSync(T&& message, typename T::Reply&&, uint64_t destinationID, std::chrono::milliseconds timeout = std::chrono::seconds(1));
-
- IPC::Connection* connection() const
- {
- ASSERT(m_connection);
- return m_connection.get();
- }
-
- void addMessageReceiver(IPC::StringReference messageReceiverName, IPC::MessageReceiver&);
- void addMessageReceiver(IPC::StringReference messageReceiverName, uint64_t destinationID, IPC::MessageReceiver&);
- void removeMessageReceiver(IPC::StringReference messageReceiverName, uint64_t destinationID);
-
- bool isValid() const { return m_connection; }
- bool isLaunching() const;
- bool canSendMessage() const { return isValid() || isLaunching(); }
-
- PlatformProcessIdentifier processIdentifier() const { return m_processLauncher->processIdentifier(); }
-
- bool sendMessage(std::unique_ptr<IPC::MessageEncoder>, unsigned messageSendFlags);
-
-protected:
- void clearConnection();
- void abortProcessLaunchIfNeeded();
-
- // ProcessLauncher::Client
- virtual void didFinishLaunching(ProcessLauncher*, IPC::Connection::Identifier) override;
-
- bool dispatchMessage(IPC::Connection*, IPC::MessageDecoder&);
- bool dispatchSyncMessage(IPC::Connection*, IPC::MessageDecoder&, std::unique_ptr<IPC::MessageEncoder>&);
-
-private:
- virtual void getLaunchOptions(ProcessLauncher::LaunchOptions&) = 0;
- virtual void connectionWillOpen(IPC::Connection*);
- virtual void connectionWillClose(IPC::Connection*);
-
- Vector<std::pair<std::unique_ptr<IPC::MessageEncoder>, unsigned>> m_pendingMessages;
- RefPtr<ProcessLauncher> m_processLauncher;
- RefPtr<IPC::Connection> m_connection;
- IPC::MessageReceiverMap m_messageReceiverMap;
-};
-
-template<typename T>
-bool ChildProcessProxy::send(T&& message, uint64_t destinationID, unsigned messageSendFlags)
-{
- COMPILE_ASSERT(!T::isSync, AsyncMessageExpected);
-
- auto encoder = std::make_unique<IPC::MessageEncoder>(T::receiverName(), T::name(), destinationID);
- encoder->encode(message.arguments());
-
- return sendMessage(std::move(encoder), messageSendFlags);
-}
-
-template<typename U>
-bool ChildProcessProxy::sendSync(U&& message, typename U::Reply&& reply, uint64_t destinationID, std::chrono::milliseconds timeout)
-{
- COMPILE_ASSERT(U::isSync, SyncMessageExpected);
-
- if (!m_connection)
- return false;
-
- return connection()->sendSync(std::forward<U>(message), std::move(reply), destinationID, timeout);
-}
-
-} // namespace WebKit
-
-#endif // ChildProcessProxy_h
diff --git a/Source/WebKit2/Shared/ContextMenuContextData.cpp b/Source/WebKit2/Shared/ContextMenuContextData.cpp
new file mode 100644
index 000000000..39bdb32e1
--- /dev/null
+++ b/Source/WebKit2/Shared/ContextMenuContextData.cpp
@@ -0,0 +1,143 @@
+/*
+ * Copyright (C) 2014 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. ``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
+ * 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 "ContextMenuContextData.h"
+
+#if ENABLE(CONTEXT_MENUS)
+
+#include "WebCoreArgumentCoders.h"
+#include <WebCore/ContextMenuContext.h>
+#include <WebCore/GraphicsContext.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+ContextMenuContextData::ContextMenuContextData()
+ : m_type(Type::ContextMenu)
+#if ENABLE(SERVICE_CONTROLS)
+ , m_selectionIsEditable(false)
+#endif
+{
+}
+
+ContextMenuContextData::ContextMenuContextData(const WebCore::IntPoint& menuLocation, const Vector<WebKit::WebContextMenuItemData>& menuItems, const ContextMenuContext& context)
+#if ENABLE(SERVICE_CONTROLS)
+ : m_type(context.controlledImage() ? Type::ServicesMenu : Type::ContextMenu)
+#else
+ : m_type(Type::ContextMenu)
+#endif
+ , m_menuLocation(menuLocation)
+ , m_menuItems(menuItems)
+ , m_webHitTestResultData(context.hitTestResult(), true)
+ , m_selectedText(context.selectedText())
+#if ENABLE(SERVICE_CONTROLS)
+ , m_selectionIsEditable(false)
+#endif
+{
+#if ENABLE(SERVICE_CONTROLS)
+ Image* image = context.controlledImage();
+ if (!image)
+ return;
+
+ // FIXME: figure out the rounding startegy for ShareableBitmap.
+ m_controlledImage = ShareableBitmap::createShareable(IntSize(image->size()), ShareableBitmap::SupportsAlpha);
+ m_controlledImage->createGraphicsContext()->drawImage(*image, IntPoint());
+#endif
+}
+
+void ContextMenuContextData::encode(IPC::Encoder& encoder) const
+{
+ encoder.encodeEnum(m_type);
+ encoder << m_menuLocation;
+ encoder << m_menuItems;
+ encoder << m_webHitTestResultData;
+ encoder << m_selectedText;
+
+#if ENABLE(SERVICE_CONTROLS)
+ ShareableBitmap::Handle handle;
+ if (m_controlledImage)
+ m_controlledImage->createHandle(handle, SharedMemory::Protection::ReadOnly);
+ encoder << handle;
+ encoder << m_controlledSelectionData;
+ encoder << m_selectedTelephoneNumbers;
+ encoder << m_selectionIsEditable;
+#endif
+}
+
+bool ContextMenuContextData::decode(IPC::Decoder& decoder, ContextMenuContextData& result)
+{
+ if (!decoder.decodeEnum(result.m_type))
+ return false;
+
+ if (!decoder.decode(result.m_menuLocation))
+ return false;
+
+ if (!decoder.decode(result.m_menuItems))
+ return false;
+
+ if (!decoder.decode(result.m_webHitTestResultData))
+ return false;
+
+ if (!decoder.decode(result.m_selectedText))
+ return false;
+
+#if ENABLE(SERVICE_CONTROLS)
+ ShareableBitmap::Handle handle;
+ if (!decoder.decode(handle))
+ return false;
+
+ if (!handle.isNull())
+ result.m_controlledImage = ShareableBitmap::create(handle, SharedMemory::Protection::ReadOnly);
+
+ if (!decoder.decode(result.m_controlledSelectionData))
+ return false;
+ if (!decoder.decode(result.m_selectedTelephoneNumbers))
+ return false;
+ if (!decoder.decode(result.m_selectionIsEditable))
+ return false;
+#endif
+
+ return true;
+}
+
+#if ENABLE(SERVICE_CONTROLS)
+bool ContextMenuContextData::controlledDataIsEditable() const
+{
+ if (!m_controlledSelectionData.isEmpty())
+ return m_selectionIsEditable;
+
+ if (m_controlledImage)
+ return m_webHitTestResultData.isContentEditable;
+
+ return false;
+}
+#endif
+
+} // namespace WebKit
+
+#endif // ENABLE(CONTEXT_MENUS)
diff --git a/Source/WebKit2/Shared/ContextMenuContextData.h b/Source/WebKit2/Shared/ContextMenuContextData.h
new file mode 100644
index 000000000..734973ae0
--- /dev/null
+++ b/Source/WebKit2/Shared/ContextMenuContextData.h
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2014 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. ``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
+ * 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.
+ *
+ */
+
+#ifndef ContextMenuContextData_h
+#define ContextMenuContextData_h
+
+#if ENABLE(CONTEXT_MENUS)
+
+#include "ShareableBitmap.h"
+#include "WebContextMenuItemData.h"
+#include "WebHitTestResultData.h"
+
+namespace IPC {
+class Decoder;
+class Encoder;
+}
+
+namespace WebCore {
+class ContextMenuContext;
+}
+
+namespace WebKit {
+
+class ContextMenuContextData {
+public:
+ enum class Type {
+ ContextMenu,
+ ServicesMenu,
+ };
+
+ ContextMenuContextData();
+ ContextMenuContextData(const WebCore::IntPoint& menuLocation, const Vector<WebKit::WebContextMenuItemData>& menuItems, const WebCore::ContextMenuContext&);
+
+ Type type() const { return m_type; }
+ const WebCore::IntPoint& menuLocation() const { return m_menuLocation; }
+ const Vector<WebKit::WebContextMenuItemData>& menuItems() const { return m_menuItems; }
+
+ const WebHitTestResultData& webHitTestResultData() const { return m_webHitTestResultData; }
+ const String& selectedText() const { return m_selectedText; }
+
+#if ENABLE(SERVICE_CONTROLS)
+ ContextMenuContextData(const WebCore::IntPoint& menuLocation, const Vector<uint8_t>& selectionData, const Vector<String>& selectedTelephoneNumbers, bool isEditable)
+ : m_type(Type::ServicesMenu)
+ , m_menuLocation(menuLocation)
+ , m_controlledSelectionData(selectionData)
+ , m_selectedTelephoneNumbers(selectedTelephoneNumbers)
+ , m_selectionIsEditable(isEditable)
+ {
+ }
+
+ ShareableBitmap* controlledImage() const { return m_controlledImage.get(); }
+ const Vector<uint8_t>& controlledSelectionData() const { return m_controlledSelectionData; }
+ const Vector<String>& selectedTelephoneNumbers() const { return m_selectedTelephoneNumbers; }
+
+ bool isServicesMenu() const { return m_type == ContextMenuContextData::Type::ServicesMenu; }
+ bool controlledDataIsEditable() const;
+#endif
+
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, ContextMenuContextData&);
+
+private:
+ Type m_type;
+
+ WebCore::IntPoint m_menuLocation;
+ Vector<WebKit::WebContextMenuItemData> m_menuItems;
+
+ WebHitTestResultData m_webHitTestResultData;
+ String m_selectedText;
+
+#if ENABLE(SERVICE_CONTROLS)
+ RefPtr<ShareableBitmap> m_controlledImage;
+ Vector<uint8_t> m_controlledSelectionData;
+ Vector<String> m_selectedTelephoneNumbers;
+ bool m_selectionIsEditable;
+#endif
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(CONTEXT_MENUS)
+#endif // ContextMenuContextData_h
diff --git a/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedBackingStore.cpp b/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedBackingStore.cpp
new file mode 100644
index 000000000..bb46942a1
--- /dev/null
+++ b/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedBackingStore.cpp
@@ -0,0 +1,191 @@
+/*
+ Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
+
+ 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 "CoordinatedBackingStore.h"
+
+#if USE(COORDINATED_GRAPHICS)
+#include <WebCore/CoordinatedSurface.h>
+#include <WebCore/GraphicsLayer.h>
+#include <WebCore/TextureMapper.h>
+#include <WebCore/TextureMapperGL.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void CoordinatedBackingStoreTile::swapBuffers(TextureMapper& textureMapper)
+{
+ if (!m_surface)
+ return;
+
+ FloatRect tileRect(m_tileRect);
+ tileRect.scale(1. / m_scale);
+ bool shouldReset = false;
+ if (tileRect != rect()) {
+ setRect(tileRect);
+ shouldReset = true;
+ }
+ RefPtr<BitmapTexture> texture = this->texture();
+ if (!texture) {
+ texture = textureMapper.createTexture();
+ setTexture(texture.get());
+ shouldReset = true;
+ }
+
+ if (m_surface->supportsAlpha() == texture->isOpaque())
+ shouldReset = true;
+
+ ASSERT(textureMapper.maxTextureSize().width() >= m_tileRect.size().width());
+ ASSERT(textureMapper.maxTextureSize().height() >= m_tileRect.size().height());
+ if (shouldReset)
+ texture->reset(m_tileRect.size(), m_surface->supportsAlpha());
+
+ m_surface->copyToTexture(texture, m_sourceRect, m_surfaceOffset);
+ m_surface = nullptr;
+}
+
+void CoordinatedBackingStoreTile::setBackBuffer(const IntRect& tileRect, const IntRect& sourceRect, PassRefPtr<CoordinatedSurface> buffer, const IntPoint& offset)
+{
+ m_sourceRect = sourceRect;
+ m_tileRect = tileRect;
+ m_surfaceOffset = offset;
+ m_surface = buffer;
+}
+
+void CoordinatedBackingStore::createTile(uint32_t id, float scale)
+{
+ m_tiles.add(id, CoordinatedBackingStoreTile(scale));
+ m_scale = scale;
+}
+
+void CoordinatedBackingStore::removeTile(uint32_t id)
+{
+ ASSERT(m_tiles.contains(id));
+ m_tilesToRemove.add(id);
+}
+
+void CoordinatedBackingStore::removeAllTiles()
+{
+ for (auto& key : m_tiles.keys())
+ m_tilesToRemove.add(key);
+}
+
+void CoordinatedBackingStore::updateTile(uint32_t id, const IntRect& sourceRect, const IntRect& tileRect, PassRefPtr<CoordinatedSurface> backBuffer, const IntPoint& offset)
+{
+ CoordinatedBackingStoreTileMap::iterator it = m_tiles.find(id);
+ ASSERT(it != m_tiles.end());
+ it->value.setBackBuffer(tileRect, sourceRect, backBuffer, offset);
+}
+
+RefPtr<BitmapTexture> CoordinatedBackingStore::texture() const
+{
+ for (auto& tile : m_tiles.values()) {
+ RefPtr<BitmapTexture> texture = tile.texture();
+ if (texture)
+ return texture;
+ }
+
+ return RefPtr<BitmapTexture>();
+}
+
+void CoordinatedBackingStore::setSize(const FloatSize& size)
+{
+ m_pendingSize = size;
+}
+
+void CoordinatedBackingStore::paintTilesToTextureMapper(Vector<TextureMapperTile*>& tiles, TextureMapper& textureMapper, const TransformationMatrix& transform, float opacity, const FloatRect& rect)
+{
+ for (auto& tile : tiles)
+ tile->paint(textureMapper, transform, opacity, calculateExposedTileEdges(rect, tile->rect()));
+}
+
+TransformationMatrix CoordinatedBackingStore::adjustedTransformForRect(const FloatRect& targetRect)
+{
+ return TransformationMatrix::rectToRect(rect(), targetRect);
+}
+
+void CoordinatedBackingStore::paintToTextureMapper(TextureMapper& textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity)
+{
+ if (m_tiles.isEmpty())
+ return;
+ ASSERT(!m_size.isZero());
+
+ Vector<TextureMapperTile*> tilesToPaint;
+ Vector<TextureMapperTile*> previousTilesToPaint;
+
+ // We have to do this every time we paint, in case the opacity has changed.
+ FloatRect coveredRect;
+ for (auto& tile : m_tiles.values()) {
+ if (!tile.texture())
+ continue;
+
+ if (tile.scale() == m_scale) {
+ tilesToPaint.append(&tile);
+ coveredRect.unite(tile.rect());
+ continue;
+ }
+
+ // Only show the previous tile if the opacity is high, otherwise effect looks like a bug.
+ // We show the previous-scale tile anyway if it doesn't intersect with any current-scale tile.
+ if (opacity < 0.95 && coveredRect.intersects(tile.rect()))
+ continue;
+
+ previousTilesToPaint.append(&tile);
+ }
+
+ // targetRect is on the contents coordinate system, so we must compare two rects on the contents coordinate system.
+ // See TiledBackingStore.
+ TransformationMatrix adjustedTransform = transform * adjustedTransformForRect(targetRect);
+
+ paintTilesToTextureMapper(previousTilesToPaint, textureMapper, adjustedTransform, opacity, rect());
+ paintTilesToTextureMapper(tilesToPaint, textureMapper, adjustedTransform, opacity, rect());
+}
+
+void CoordinatedBackingStore::drawBorder(TextureMapper& textureMapper, const Color& borderColor, float borderWidth, const FloatRect& targetRect, const TransformationMatrix& transform)
+{
+ TransformationMatrix adjustedTransform = transform * adjustedTransformForRect(targetRect);
+ for (auto& tile : m_tiles.values())
+ textureMapper.drawBorder(borderColor, borderWidth, tile.rect(), adjustedTransform);
+}
+
+void CoordinatedBackingStore::drawRepaintCounter(TextureMapper& textureMapper, int repaintCount, const Color& borderColor, const FloatRect& targetRect, const TransformationMatrix& transform)
+{
+ TransformationMatrix adjustedTransform = transform * adjustedTransformForRect(targetRect);
+ for (auto& tile : m_tiles.values())
+ textureMapper.drawNumber(repaintCount, borderColor, tile.rect().location(), adjustedTransform);
+}
+
+void CoordinatedBackingStore::commitTileOperations(TextureMapper& textureMapper)
+{
+ if (!m_pendingSize.isZero()) {
+ m_size = m_pendingSize;
+ m_pendingSize = FloatSize();
+ }
+
+ for (auto& tileToRemove : m_tilesToRemove)
+ m_tiles.remove(tileToRemove);
+ m_tilesToRemove.clear();
+
+ for (auto& tile : m_tiles.values())
+ tile.swapBuffers(textureMapper);
+}
+
+} // namespace WebCore
+#endif // USE(COORDINATED_GRAPHICS)
diff --git a/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedBackingStore.h b/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedBackingStore.h
new file mode 100644
index 000000000..166c0a1c7
--- /dev/null
+++ b/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedBackingStore.h
@@ -0,0 +1,93 @@
+/*
+ Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
+
+ 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.
+ */
+
+#ifndef CoordinatedBackingStore_h
+#define CoordinatedBackingStore_h
+
+#if USE(COORDINATED_GRAPHICS)
+
+#include <WebCore/TextureMapper.h>
+#include <WebCore/TextureMapperBackingStore.h>
+#include <WebCore/TextureMapperTile.h>
+#include <wtf/HashMap.h>
+#include <wtf/HashSet.h>
+
+
+namespace WebCore {
+class CoordinatedSurface;
+}
+
+namespace WebKit {
+
+class CoordinatedBackingStoreTile : public WebCore::TextureMapperTile {
+public:
+ explicit CoordinatedBackingStoreTile(float scale = 1)
+ : WebCore::TextureMapperTile(WebCore::FloatRect())
+ , m_scale(scale)
+ {
+ }
+
+ inline float scale() const { return m_scale; }
+ void swapBuffers(WebCore::TextureMapper&);
+ void setBackBuffer(const WebCore::IntRect&, const WebCore::IntRect&, PassRefPtr<WebCore::CoordinatedSurface> buffer, const WebCore::IntPoint&);
+
+private:
+ RefPtr<WebCore::CoordinatedSurface> m_surface;
+ WebCore::IntRect m_sourceRect;
+ WebCore::IntRect m_tileRect;
+ WebCore::IntPoint m_surfaceOffset;
+ float m_scale;
+};
+
+class CoordinatedBackingStore : public WebCore::TextureMapperBackingStore {
+public:
+ void createTile(uint32_t tileID, float);
+ void removeTile(uint32_t tileID);
+ void removeAllTiles();
+ void updateTile(uint32_t tileID, const WebCore::IntRect&, const WebCore::IntRect&, PassRefPtr<WebCore::CoordinatedSurface>, const WebCore::IntPoint&);
+ static Ref<CoordinatedBackingStore> create() { return adoptRef(*new CoordinatedBackingStore); }
+ void commitTileOperations(WebCore::TextureMapper&);
+ RefPtr<WebCore::BitmapTexture> texture() const override;
+ void setSize(const WebCore::FloatSize&);
+ void paintToTextureMapper(WebCore::TextureMapper&, const WebCore::FloatRect&, const WebCore::TransformationMatrix&, float) override;
+ void drawBorder(WebCore::TextureMapper&, const WebCore::Color&, float borderWidth, const WebCore::FloatRect&, const WebCore::TransformationMatrix&) override;
+ void drawRepaintCounter(WebCore::TextureMapper&, int repaintCount, const WebCore::Color&, const WebCore::FloatRect&, const WebCore::TransformationMatrix&) override;
+
+private:
+ CoordinatedBackingStore()
+ : m_scale(1.)
+ { }
+ void paintTilesToTextureMapper(Vector<WebCore::TextureMapperTile*>&, WebCore::TextureMapper&, const WebCore::TransformationMatrix&, float, const WebCore::FloatRect&);
+ WebCore::TransformationMatrix adjustedTransformForRect(const WebCore::FloatRect&);
+ WebCore::FloatRect rect() const { return WebCore::FloatRect(WebCore::FloatPoint::zero(), m_size); }
+
+ typedef HashMap<uint32_t, CoordinatedBackingStoreTile> CoordinatedBackingStoreTileMap;
+ CoordinatedBackingStoreTileMap m_tiles;
+ HashSet<uint32_t> m_tilesToRemove;
+ // FIXME: m_pendingSize should be removed after the following bug is fixed: https://bugs.webkit.org/show_bug.cgi?id=108294
+ WebCore::FloatSize m_pendingSize;
+ WebCore::FloatSize m_size;
+ float m_scale;
+};
+
+} // namespace WebKit
+
+#endif // USE(COORDINATED_GRAPHICS)
+
+#endif // CoordinatedBackingStore_h
diff --git a/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp b/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp
new file mode 100644
index 000000000..9492d826f
--- /dev/null
+++ b/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp
@@ -0,0 +1,924 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2012 Company 100, Inc.
+ *
+ * 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 "CoordinatedGraphicsArgumentCoders.h"
+
+#if USE(COORDINATED_GRAPHICS)
+#include "WebCoordinatedSurface.h"
+#include "WebCoreArgumentCoders.h"
+#include <WebCore/Animation.h>
+#include <WebCore/Color.h>
+#include <WebCore/CoordinatedGraphicsState.h>
+#include <WebCore/FilterOperations.h>
+#include <WebCore/FloatPoint3D.h>
+#include <WebCore/IdentityTransformOperation.h>
+#include <WebCore/IntPoint.h>
+#include <WebCore/Length.h>
+#include <WebCore/Matrix3DTransformOperation.h>
+#include <WebCore/MatrixTransformOperation.h>
+#include <WebCore/PerspectiveTransformOperation.h>
+#include <WebCore/RotateTransformOperation.h>
+#include <WebCore/ScaleTransformOperation.h>
+#include <WebCore/SkewTransformOperation.h>
+#include <WebCore/SurfaceUpdateInfo.h>
+#include <WebCore/TextureMapperAnimation.h>
+#include <WebCore/TimingFunction.h>
+#include <WebCore/TransformationMatrix.h>
+#include <WebCore/TranslateTransformOperation.h>
+
+using namespace WebCore;
+using namespace WebKit;
+
+namespace IPC {
+
+void ArgumentCoder<WebCore::FilterOperations>::encode(Encoder& encoder, const WebCore::FilterOperations& filters)
+{
+ encoder << static_cast<uint32_t>(filters.size());
+ for (size_t i = 0; i < filters.size(); ++i) {
+ const FilterOperation& filter = *filters.at(i);
+ FilterOperation::OperationType type = filter.type();
+ encoder.encodeEnum(type);
+ switch (type) {
+ case FilterOperation::GRAYSCALE:
+ case FilterOperation::SEPIA:
+ case FilterOperation::SATURATE:
+ case FilterOperation::HUE_ROTATE:
+ encoder << static_cast<double>(downcast<BasicColorMatrixFilterOperation>(filter).amount());
+ break;
+ case FilterOperation::INVERT:
+ case FilterOperation::BRIGHTNESS:
+ case FilterOperation::CONTRAST:
+ case FilterOperation::OPACITY:
+ encoder << static_cast<double>(downcast<BasicComponentTransferFilterOperation>(filter).amount());
+ break;
+ case FilterOperation::BLUR:
+ ArgumentCoder<Length>::encode(encoder, downcast<BlurFilterOperation>(filter).stdDeviation());
+ break;
+ case FilterOperation::DROP_SHADOW: {
+ const DropShadowFilterOperation& shadow = downcast<DropShadowFilterOperation>(filter);
+ ArgumentCoder<IntPoint>::encode(encoder, shadow.location());
+ encoder << static_cast<int32_t>(shadow.stdDeviation());
+ ArgumentCoder<Color>::encode(encoder, shadow.color());
+ break;
+ }
+ case FilterOperation::REFERENCE:
+ case FilterOperation::PASSTHROUGH:
+ case FilterOperation::DEFAULT:
+ case FilterOperation::NONE:
+ break;
+ }
+ }
+}
+
+bool ArgumentCoder<WebCore::FilterOperations>::decode(Decoder& decoder, WebCore::FilterOperations& filters)
+{
+ uint32_t size;
+ if (!decoder.decode(size))
+ return false;
+
+ Vector<RefPtr<FilterOperation> >& operations = filters.operations();
+
+ for (size_t i = 0; i < size; ++i) {
+ FilterOperation::OperationType type;
+ RefPtr<FilterOperation> filter;
+ if (!decoder.decodeEnum(type))
+ return false;
+
+ switch (type) {
+ case FilterOperation::GRAYSCALE:
+ case FilterOperation::SEPIA:
+ case FilterOperation::SATURATE:
+ case FilterOperation::HUE_ROTATE: {
+ double value;
+ if (!decoder.decode(value))
+ return false;
+ filter = BasicColorMatrixFilterOperation::create(value, type);
+ break;
+ }
+ case FilterOperation::INVERT:
+ case FilterOperation::BRIGHTNESS:
+ case FilterOperation::CONTRAST:
+ case FilterOperation::OPACITY: {
+ double value;
+ if (!decoder.decode(value))
+ return false;
+ filter = BasicComponentTransferFilterOperation::create(value, type);
+ break;
+ }
+ case FilterOperation::BLUR: {
+ Length length;
+ if (!ArgumentCoder<Length>::decode(decoder, length))
+ return false;
+ filter = BlurFilterOperation::create(length);
+ break;
+ }
+ case FilterOperation::DROP_SHADOW: {
+ IntPoint location;
+ int32_t stdDeviation;
+ Color color;
+ if (!ArgumentCoder<IntPoint>::decode(decoder, location))
+ return false;
+ if (!decoder.decode(stdDeviation))
+ return false;
+ if (!ArgumentCoder<Color>::decode(decoder, color))
+ return false;
+ filter = DropShadowFilterOperation::create(location, stdDeviation, color);
+ break;
+ }
+ case FilterOperation::REFERENCE:
+ case FilterOperation::PASSTHROUGH:
+ case FilterOperation::DEFAULT:
+ case FilterOperation::NONE:
+ break;
+ }
+
+ if (filter)
+ operations.append(filter);
+ }
+
+ return true;
+}
+
+void ArgumentCoder<TransformOperations>::encode(Encoder& encoder, const TransformOperations& transformOperations)
+{
+ encoder << static_cast<uint32_t>(transformOperations.size());
+ for (const auto& operation : transformOperations.operations()) {
+ encoder.encodeEnum(operation->type());
+
+ switch (operation->type()) {
+ case TransformOperation::SCALE_X:
+ case TransformOperation::SCALE_Y:
+ case TransformOperation::SCALE:
+ case TransformOperation::SCALE_Z:
+ case TransformOperation::SCALE_3D: {
+ const auto& scaleOperation = downcast<ScaleTransformOperation>(*operation);
+ encoder << scaleOperation.x();
+ encoder << scaleOperation.y();
+ encoder << scaleOperation.z();
+ break;
+ }
+ case TransformOperation::TRANSLATE_X:
+ case TransformOperation::TRANSLATE_Y:
+ case TransformOperation::TRANSLATE:
+ case TransformOperation::TRANSLATE_Z:
+ case TransformOperation::TRANSLATE_3D: {
+ const auto& translateOperation = downcast<TranslateTransformOperation>(*operation);
+ ArgumentCoder<Length>::encode(encoder, translateOperation.x());
+ ArgumentCoder<Length>::encode(encoder, translateOperation.y());
+ ArgumentCoder<Length>::encode(encoder, translateOperation.z());
+ break;
+ }
+ case TransformOperation::ROTATE:
+ case TransformOperation::ROTATE_X:
+ case TransformOperation::ROTATE_Y:
+ case TransformOperation::ROTATE_3D: {
+ const auto& rotateOperation = downcast<RotateTransformOperation>(*operation);
+ encoder << rotateOperation.x();
+ encoder << rotateOperation.y();
+ encoder << rotateOperation.z();
+ encoder << rotateOperation.angle();
+ break;
+ }
+ case TransformOperation::SKEW_X:
+ case TransformOperation::SKEW_Y:
+ case TransformOperation::SKEW: {
+ const auto& skewOperation = downcast<SkewTransformOperation>(*operation);
+ encoder << skewOperation.angleX();
+ encoder << skewOperation.angleY();
+ break;
+ }
+ case TransformOperation::MATRIX:
+ ArgumentCoder<TransformationMatrix>::encode(encoder, downcast<MatrixTransformOperation>(*operation).matrix());
+ break;
+ case TransformOperation::MATRIX_3D:
+ ArgumentCoder<TransformationMatrix>::encode(encoder, downcast<Matrix3DTransformOperation>(*operation).matrix());
+ break;
+ case TransformOperation::PERSPECTIVE:
+ ArgumentCoder<Length>::encode(encoder, downcast<PerspectiveTransformOperation>(*operation).perspective());
+ break;
+ case TransformOperation::IDENTITY:
+ break;
+ case TransformOperation::NONE:
+ ASSERT_NOT_REACHED();
+ break;
+ }
+ }
+}
+
+bool ArgumentCoder<TransformOperations>::decode(Decoder& decoder, TransformOperations& transformOperations)
+{
+ uint32_t operationsSize;
+ if (!decoder.decode(operationsSize))
+ return false;
+
+ for (size_t i = 0; i < operationsSize; ++i) {
+ TransformOperation::OperationType operationType;
+ if (!decoder.decodeEnum(operationType))
+ return false;
+
+ switch (operationType) {
+ case TransformOperation::SCALE_X:
+ case TransformOperation::SCALE_Y:
+ case TransformOperation::SCALE:
+ case TransformOperation::SCALE_Z:
+ case TransformOperation::SCALE_3D: {
+ double x, y, z;
+ if (!decoder.decode(x))
+ return false;
+ if (!decoder.decode(y))
+ return false;
+ if (!decoder.decode(z))
+ return false;
+ transformOperations.operations().append(ScaleTransformOperation::create(x, y, z, operationType));
+ break;
+ }
+ case TransformOperation::TRANSLATE_X:
+ case TransformOperation::TRANSLATE_Y:
+ case TransformOperation::TRANSLATE:
+ case TransformOperation::TRANSLATE_Z:
+ case TransformOperation::TRANSLATE_3D: {
+ Length x, y, z;
+ if (!ArgumentCoder<Length>::decode(decoder, x))
+ return false;
+ if (!ArgumentCoder<Length>::decode(decoder, y))
+ return false;
+ if (!ArgumentCoder<Length>::decode(decoder, z))
+ return false;
+ transformOperations.operations().append(TranslateTransformOperation::create(x, y, z, operationType));
+ break;
+ }
+ case TransformOperation::ROTATE:
+ case TransformOperation::ROTATE_X:
+ case TransformOperation::ROTATE_Y:
+ case TransformOperation::ROTATE_3D: {
+ double x, y, z, angle;
+ if (!decoder.decode(x))
+ return false;
+ if (!decoder.decode(y))
+ return false;
+ if (!decoder.decode(z))
+ return false;
+ if (!decoder.decode(angle))
+ return false;
+ transformOperations.operations().append(RotateTransformOperation::create(x, y, z, angle, operationType));
+ break;
+ }
+ case TransformOperation::SKEW_X:
+ case TransformOperation::SKEW_Y:
+ case TransformOperation::SKEW: {
+ double angleX, angleY;
+ if (!decoder.decode(angleX))
+ return false;
+ if (!decoder.decode(angleY))
+ return false;
+ transformOperations.operations().append(SkewTransformOperation::create(angleX, angleY, operationType));
+ break;
+ }
+ case TransformOperation::MATRIX: {
+ TransformationMatrix matrix;
+ if (!ArgumentCoder<TransformationMatrix>::decode(decoder, matrix))
+ return false;
+ transformOperations.operations().append(MatrixTransformOperation::create(matrix));
+ break;
+ }
+ case TransformOperation::MATRIX_3D: {
+ TransformationMatrix matrix;
+ if (!ArgumentCoder<TransformationMatrix>::decode(decoder, matrix))
+ return false;
+ transformOperations.operations().append(Matrix3DTransformOperation::create(matrix));
+ break;
+ }
+ case TransformOperation::PERSPECTIVE: {
+ Length perspective;
+ if (!ArgumentCoder<Length>::decode(decoder, perspective))
+ return false;
+ transformOperations.operations().append(PerspectiveTransformOperation::create(perspective));
+ break;
+ }
+ case TransformOperation::IDENTITY:
+ transformOperations.operations().append(IdentityTransformOperation::create());
+ break;
+ case TransformOperation::NONE:
+ ASSERT_NOT_REACHED();
+ break;
+ }
+ }
+ return true;
+}
+
+static void encodeTimingFunction(Encoder& encoder, const TimingFunction* timingFunction)
+{
+ if (!timingFunction) {
+ encoder.encodeEnum(TimingFunction::TimingFunctionType(-1));
+ return;
+ }
+
+ TimingFunction::TimingFunctionType type = timingFunction ? timingFunction->type() : TimingFunction::LinearFunction;
+ encoder.encodeEnum(type);
+ switch (type) {
+ case TimingFunction::LinearFunction:
+ break;
+ case TimingFunction::CubicBezierFunction: {
+ const CubicBezierTimingFunction* cubic = static_cast<const CubicBezierTimingFunction*>(timingFunction);
+ CubicBezierTimingFunction::TimingFunctionPreset bezierPreset = cubic->timingFunctionPreset();
+ encoder.encodeEnum(bezierPreset);
+ if (bezierPreset == CubicBezierTimingFunction::Custom) {
+ encoder << cubic->x1();
+ encoder << cubic->y1();
+ encoder << cubic->x2();
+ encoder << cubic->y2();
+ }
+ break;
+ }
+ case TimingFunction::StepsFunction: {
+ const StepsTimingFunction* steps = static_cast<const StepsTimingFunction*>(timingFunction);
+ encoder << static_cast<uint32_t>(steps->numberOfSteps());
+ encoder << steps->stepAtStart();
+ break;
+ }
+ case TimingFunction::SpringFunction: {
+ const SpringTimingFunction* spring = static_cast<const SpringTimingFunction*>(timingFunction);
+ encoder << spring->mass();
+ encoder << spring->stiffness();
+ encoder << spring->damping();
+ encoder << spring->initialVelocity();
+ break;
+ }
+ }
+}
+
+bool decodeTimingFunction(Decoder& decoder, RefPtr<TimingFunction>& timingFunction)
+{
+ TimingFunction::TimingFunctionType type;
+ if (!decoder.decodeEnum(type))
+ return false;
+
+ if (type == TimingFunction::TimingFunctionType(-1))
+ return true;
+
+ switch (type) {
+ case TimingFunction::LinearFunction:
+ timingFunction = LinearTimingFunction::create();
+ return true;
+ case TimingFunction::CubicBezierFunction: {
+ double x1, y1, x2, y2;
+ CubicBezierTimingFunction::TimingFunctionPreset bezierPreset;
+ if (!decoder.decodeEnum(bezierPreset))
+ return false;
+ if (bezierPreset != CubicBezierTimingFunction::Custom) {
+ timingFunction = CubicBezierTimingFunction::create(bezierPreset);
+ return true;
+ }
+ if (!decoder.decode(x1))
+ return false;
+ if (!decoder.decode(y1))
+ return false;
+ if (!decoder.decode(x2))
+ return false;
+ if (!decoder.decode(y2))
+ return false;
+
+ timingFunction = CubicBezierTimingFunction::create(x1, y1, x2, y2);
+ return true;
+ }
+ case TimingFunction::StepsFunction: {
+ uint32_t numberOfSteps;
+ bool stepAtStart;
+ if (!decoder.decode(numberOfSteps))
+ return false;
+ if (!decoder.decode(stepAtStart))
+ return false;
+
+ timingFunction = StepsTimingFunction::create(numberOfSteps, stepAtStart);
+ return true;
+ }
+ case TimingFunction::SpringFunction: {
+ double mass;
+ if (!decoder.decode(mass))
+ return false;
+ double stiffness;
+ if (!decoder.decode(stiffness))
+ return false;
+ double damping;
+ if (!decoder.decode(damping))
+ return false;
+ double initialVelocity;
+ if (!decoder.decode(initialVelocity))
+ return false;
+
+ timingFunction = SpringTimingFunction::create(mass, stiffness, damping, initialVelocity);
+ return true;
+ }
+ }
+
+ return false;
+}
+
+void ArgumentCoder<TextureMapperAnimation>::encode(Encoder& encoder, const TextureMapperAnimation& animation)
+{
+ encoder << animation.name();
+ encoder << animation.boxSize();
+ encoder.encodeEnum(animation.state());
+ encoder << animation.startTime();
+ encoder << animation.pauseTime();
+ encoder << animation.listsMatch();
+
+ RefPtr<Animation> animationObject = animation.animation();
+ encoder.encodeEnum(animationObject->direction());
+ encoder << static_cast<uint32_t>(animationObject->fillMode());
+ encoder << animationObject->duration();
+ encoder << animationObject->iterationCount();
+ encodeTimingFunction(encoder, animationObject->timingFunction());
+
+ const KeyframeValueList& keyframes = animation.keyframes();
+ encoder.encodeEnum(keyframes.property());
+ encoder << static_cast<uint32_t>(keyframes.size());
+ for (size_t i = 0; i < keyframes.size(); ++i) {
+ const AnimationValue& value = keyframes.at(i);
+ encoder << value.keyTime();
+ encodeTimingFunction(encoder, value.timingFunction());
+ switch (keyframes.property()) {
+ case AnimatedPropertyOpacity:
+ encoder << static_cast<const FloatAnimationValue&>(value).value();
+ break;
+ case AnimatedPropertyTransform:
+ encoder << static_cast<const TransformAnimationValue&>(value).value();
+ break;
+ case AnimatedPropertyFilter:
+ encoder << static_cast<const FilterAnimationValue&>(value).value();
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+bool ArgumentCoder<TextureMapperAnimation>::decode(Decoder& decoder, TextureMapperAnimation& animation)
+{
+ String name;
+ FloatSize boxSize;
+ TextureMapperAnimation::AnimationState state;
+ double startTime;
+ double pauseTime;
+ bool listsMatch;
+
+ Animation::AnimationDirection direction;
+ unsigned fillMode;
+ double duration;
+ double iterationCount;
+ RefPtr<TimingFunction> timingFunction;
+ RefPtr<Animation> animationObject;
+
+ if (!decoder.decode(name))
+ return false;
+ if (!decoder.decode(boxSize))
+ return false;
+ if (!decoder.decodeEnum(state))
+ return false;
+ if (!decoder.decode(startTime))
+ return false;
+ if (!decoder.decode(pauseTime))
+ return false;
+ if (!decoder.decode(listsMatch))
+ return false;
+ if (!decoder.decodeEnum(direction))
+ return false;
+ if (!decoder.decode(fillMode))
+ return false;
+ if (!decoder.decode(duration))
+ return false;
+ if (!decoder.decode(iterationCount))
+ return false;
+ if (!decodeTimingFunction(decoder, timingFunction))
+ return false;
+
+ animationObject = Animation::create();
+ animationObject->setDirection(direction);
+ animationObject->setFillMode(fillMode);
+ animationObject->setDuration(duration);
+ animationObject->setIterationCount(iterationCount);
+ if (timingFunction)
+ animationObject->setTimingFunction(WTFMove(timingFunction));
+
+ AnimatedPropertyID property;
+ if (!decoder.decodeEnum(property))
+ return false;
+ KeyframeValueList keyframes(property);
+ unsigned keyframesSize;
+ if (!decoder.decode(keyframesSize))
+ return false;
+ for (unsigned i = 0; i < keyframesSize; ++i) {
+ double keyTime;
+ RefPtr<TimingFunction> timingFunction;
+ if (!decoder.decode(keyTime))
+ return false;
+ if (!decodeTimingFunction(decoder, timingFunction))
+ return false;
+
+ switch (property) {
+ case AnimatedPropertyOpacity: {
+ float value;
+ if (!decoder.decode(value))
+ return false;
+ keyframes.insert(std::make_unique<FloatAnimationValue>(keyTime, value, timingFunction.get()));
+ break;
+ }
+ case AnimatedPropertyTransform: {
+ TransformOperations transform;
+ if (!decoder.decode(transform))
+ return false;
+ keyframes.insert(std::make_unique<TransformAnimationValue>(keyTime, transform, timingFunction.get()));
+ break;
+ }
+ case AnimatedPropertyFilter: {
+ FilterOperations filter;
+ if (!decoder.decode(filter))
+ return false;
+ keyframes.insert(std::make_unique<FilterAnimationValue>(keyTime, filter, timingFunction.get()));
+ break;
+ }
+ default:
+ break;
+ }
+ }
+
+ animation = TextureMapperAnimation(name, keyframes, boxSize, *animationObject, listsMatch, startTime, pauseTime, state);
+ return true;
+}
+
+void ArgumentCoder<TextureMapperAnimations>::encode(Encoder& encoder, const TextureMapperAnimations& animations)
+{
+ encoder << animations.animations();
+}
+
+bool ArgumentCoder<TextureMapperAnimations>::decode(Decoder& decoder, TextureMapperAnimations& animations)
+{
+ return decoder.decode(animations.animations());
+}
+
+bool ArgumentCoder<WebCore::GraphicsSurfaceToken>::decode(Decoder& decoder, WebCore::GraphicsSurfaceToken& token)
+{
+#if OS(DARWIN)
+ Attachment frontAttachment, backAttachment;
+ if (!decoder.decode(frontAttachment))
+ return false;
+ if (!decoder.decode(backAttachment))
+ return false;
+
+ token = GraphicsSurfaceToken(frontAttachment.port(), backAttachment.port());
+#elif OS(LINUX)
+ if (!decoder.decode(token.frontBufferHandle))
+ return false;
+#endif
+ return true;
+}
+#endif
+
+void ArgumentCoder<SurfaceUpdateInfo>::encode(Encoder& encoder, const SurfaceUpdateInfo& surfaceUpdateInfo)
+{
+ SimpleArgumentCoder<SurfaceUpdateInfo>::encode(encoder, surfaceUpdateInfo);
+}
+
+bool ArgumentCoder<SurfaceUpdateInfo>::decode(Decoder& decoder, SurfaceUpdateInfo& surfaceUpdateInfo)
+{
+ return SimpleArgumentCoder<SurfaceUpdateInfo>::decode(decoder, surfaceUpdateInfo);
+}
+
+void ArgumentCoder<CoordinatedGraphicsLayerState>::encode(Encoder& encoder, const CoordinatedGraphicsLayerState& state)
+{
+ encoder << state.changeMask;
+
+ if (state.flagsChanged)
+ encoder << state.flags;
+
+ if (state.positionChanged)
+ encoder << state.pos;
+
+ if (state.anchorPointChanged)
+ encoder << state.anchorPoint;
+
+ if (state.sizeChanged)
+ encoder << state.size;
+
+ if (state.transformChanged)
+ encoder << state.transform;
+
+ if (state.childrenTransformChanged)
+ encoder << state.childrenTransform;
+
+ if (state.contentsRectChanged)
+ encoder << state.contentsRect;
+
+ if (state.contentsTilingChanged) {
+ encoder << state.contentsTileSize;
+ encoder << state.contentsTilePhase;
+ }
+
+ if (state.opacityChanged)
+ encoder << state.opacity;
+
+ if (state.solidColorChanged)
+ encoder << state.solidColor;
+
+ if (state.debugBorderColorChanged)
+ encoder << state.debugBorderColor;
+
+ if (state.debugBorderWidthChanged)
+ encoder << state.debugBorderWidth;
+
+ if (state.filtersChanged)
+ encoder << state.filters;
+
+ if (state.animationsChanged)
+ encoder << state.animations;
+
+ if (state.childrenChanged)
+ encoder << state.children;
+
+ encoder << state.tilesToCreate;
+ encoder << state.tilesToRemove;
+
+ if (state.replicaChanged)
+ encoder << state.replica;
+
+ if (state.maskChanged)
+ encoder << state.mask;
+
+ if (state.imageChanged)
+ encoder << state.imageID;
+
+ if (state.repaintCountChanged)
+ encoder << state.repaintCount;
+
+ encoder << state.tilesToUpdate;
+
+ if (state.committedScrollOffsetChanged)
+ encoder << state.committedScrollOffset;
+}
+
+bool ArgumentCoder<CoordinatedGraphicsLayerState>::decode(Decoder& decoder, CoordinatedGraphicsLayerState& state)
+{
+ if (!decoder.decode(state.changeMask))
+ return false;
+
+ if (state.flagsChanged && !decoder.decode(state.flags))
+ return false;
+
+ if (state.positionChanged && !decoder.decode(state.pos))
+ return false;
+
+ if (state.anchorPointChanged && !decoder.decode(state.anchorPoint))
+ return false;
+
+ if (state.sizeChanged && !decoder.decode(state.size))
+ return false;
+
+ if (state.transformChanged && !decoder.decode(state.transform))
+ return false;
+
+ if (state.childrenTransformChanged && !decoder.decode(state.childrenTransform))
+ return false;
+
+ if (state.contentsRectChanged && !decoder.decode(state.contentsRect))
+ return false;
+
+ if (state.contentsTilingChanged) {
+ if (!decoder.decode(state.contentsTileSize))
+ return false;
+ if (!decoder.decode(state.contentsTilePhase))
+ return false;
+ }
+
+ if (state.opacityChanged && !decoder.decode(state.opacity))
+ return false;
+
+ if (state.solidColorChanged && !decoder.decode(state.solidColor))
+ return false;
+
+ if (state.debugBorderColorChanged && !decoder.decode(state.debugBorderColor))
+ return false;
+
+ if (state.debugBorderWidthChanged && !decoder.decode(state.debugBorderWidth))
+ return false;
+
+ if (state.filtersChanged && !decoder.decode(state.filters))
+ return false;
+
+ if (state.animationsChanged && !decoder.decode(state.animations))
+ return false;
+
+ if (state.childrenChanged && !decoder.decode(state.children))
+ return false;
+
+ if (!decoder.decode(state.tilesToCreate))
+ return false;
+
+ if (!decoder.decode(state.tilesToRemove))
+ return false;
+
+ if (state.replicaChanged && !decoder.decode(state.replica))
+ return false;
+
+ if (state.maskChanged && !decoder.decode(state.mask))
+ return false;
+
+ if (state.imageChanged && !decoder.decode(state.imageID))
+ return false;
+
+ if (state.repaintCountChanged && !decoder.decode(state.repaintCount))
+ return false;
+
+ if (!decoder.decode(state.tilesToUpdate))
+ return false;
+
+ if (state.committedScrollOffsetChanged && !decoder.decode(state.committedScrollOffset))
+ return false;
+
+ return true;
+}
+
+void ArgumentCoder<TileUpdateInfo>::encode(Encoder& encoder, const TileUpdateInfo& updateInfo)
+{
+ SimpleArgumentCoder<TileUpdateInfo>::encode(encoder, updateInfo);
+}
+
+bool ArgumentCoder<TileUpdateInfo>::decode(Decoder& decoder, TileUpdateInfo& updateInfo)
+{
+ return SimpleArgumentCoder<TileUpdateInfo>::decode(decoder, updateInfo);
+}
+
+void ArgumentCoder<TileCreationInfo>::encode(Encoder& encoder, const TileCreationInfo& updateInfo)
+{
+ SimpleArgumentCoder<TileCreationInfo>::encode(encoder, updateInfo);
+}
+
+bool ArgumentCoder<TileCreationInfo>::decode(Decoder& decoder, TileCreationInfo& updateInfo)
+{
+ return SimpleArgumentCoder<TileCreationInfo>::decode(decoder, updateInfo);
+}
+
+static void encodeCoordinatedSurface(Encoder& encoder, const RefPtr<CoordinatedSurface>& surface)
+{
+ bool isValidSurface = false;
+ if (!surface) {
+ encoder << isValidSurface;
+ return;
+ }
+
+ WebCoordinatedSurface* webCoordinatedSurface = static_cast<WebCoordinatedSurface*>(surface.get());
+ WebCoordinatedSurface::Handle handle;
+ if (webCoordinatedSurface->createHandle(handle))
+ isValidSurface = true;
+
+ encoder << isValidSurface;
+
+ if (isValidSurface)
+ encoder << handle;
+}
+
+static bool decodeCoordinatedSurface(Decoder& decoder, RefPtr<CoordinatedSurface>& surface)
+{
+ bool isValidSurface;
+ if (!decoder.decode(isValidSurface))
+ return false;
+
+ if (!isValidSurface)
+ return true;
+
+ WebCoordinatedSurface::Handle handle;
+ if (!decoder.decode(handle))
+ return false;
+
+ surface = WebCoordinatedSurface::create(handle);
+ return true;
+}
+
+void ArgumentCoder<CoordinatedGraphicsState>::encode(Encoder& encoder, const CoordinatedGraphicsState& state)
+{
+ encoder << state.rootCompositingLayer;
+ encoder << state.scrollPosition;
+ encoder << state.contentsSize;
+ encoder << state.coveredRect;
+
+ encoder << state.layersToCreate;
+ encoder << state.layersToUpdate;
+ encoder << state.layersToRemove;
+
+ encoder << state.imagesToCreate;
+ encoder << state.imagesToRemove;
+
+ // We need to encode WebCoordinatedSurface::Handle right after it's creation.
+ // That's why we cannot use simple std::pair encoder.
+ encoder << static_cast<uint64_t>(state.imagesToUpdate.size());
+ for (size_t i = 0; i < state.imagesToUpdate.size(); ++i) {
+ encoder << state.imagesToUpdate[i].first;
+ encodeCoordinatedSurface(encoder, state.imagesToUpdate[i].second);
+ }
+ encoder << state.imagesToClear;
+
+ encoder << static_cast<uint64_t>(state.updateAtlasesToCreate.size());
+ for (size_t i = 0; i < state.updateAtlasesToCreate.size(); ++i) {
+ encoder << state.updateAtlasesToCreate[i].first;
+ encodeCoordinatedSurface(encoder, state.updateAtlasesToCreate[i].second);
+ }
+ encoder << state.updateAtlasesToRemove;
+}
+
+bool ArgumentCoder<CoordinatedGraphicsState>::decode(Decoder& decoder, CoordinatedGraphicsState& state)
+{
+ if (!decoder.decode(state.rootCompositingLayer))
+ return false;
+
+ if (!decoder.decode(state.scrollPosition))
+ return false;
+
+ if (!decoder.decode(state.contentsSize))
+ return false;
+
+ if (!decoder.decode(state.coveredRect))
+ return false;
+
+ if (!decoder.decode(state.layersToCreate))
+ return false;
+
+ if (!decoder.decode(state.layersToUpdate))
+ return false;
+
+ if (!decoder.decode(state.layersToRemove))
+ return false;
+
+ if (!decoder.decode(state.imagesToCreate))
+ return false;
+
+ if (!decoder.decode(state.imagesToRemove))
+ return false;
+
+ uint64_t sizeOfImagesToUpdate;
+ if (!decoder.decode(sizeOfImagesToUpdate))
+ return false;
+
+ for (uint64_t i = 0; i < sizeOfImagesToUpdate; ++i) {
+ CoordinatedImageBackingID imageID;
+ if (!decoder.decode(imageID))
+ return false;
+
+ RefPtr<CoordinatedSurface> surface;
+ if (!decodeCoordinatedSurface(decoder, surface))
+ return false;
+
+ state.imagesToUpdate.append(std::make_pair(imageID, surface.release()));
+ }
+
+ if (!decoder.decode(state.imagesToClear))
+ return false;
+
+ uint64_t sizeOfUpdateAtlasesToCreate;
+ if (!decoder.decode(sizeOfUpdateAtlasesToCreate))
+ return false;
+
+ for (uint64_t i = 0; i < sizeOfUpdateAtlasesToCreate; ++i) {
+ uint32_t atlasID;
+ if (!decoder.decode(atlasID))
+ return false;
+
+ RefPtr<CoordinatedSurface> surface;
+ if (!decodeCoordinatedSurface(decoder, surface))
+ return false;
+
+ state.updateAtlasesToCreate.append(std::make_pair(atlasID, surface.release()));
+ }
+
+ if (!decoder.decode(state.updateAtlasesToRemove))
+ return false;
+
+ return true;
+}
+
+} // namespace IPC
+
+#endif // USE(COORDINATED_GRAPHICS)
diff --git a/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.h b/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.h
new file mode 100644
index 000000000..dd0c10b59
--- /dev/null
+++ b/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.h
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2012 Company 100, Inc.
+ *
+ * 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.
+ */
+
+#ifndef CoordinatedGraphicsArgumentCoders_h
+#define CoordinatedGraphicsArgumentCoders_h
+
+#if USE(COORDINATED_GRAPHICS)
+#include "ArgumentCoders.h"
+
+namespace WebCore {
+struct CoordinatedGraphicsLayerState;
+struct CoordinatedGraphicsState;
+class FloatPoint3D;
+class TextureMapperAnimation;
+class TextureMapperAnimations;
+class SurfaceUpdateInfo;
+struct TileCreationInfo;
+struct TileUpdateInfo;
+class TransformationMatrix;
+class TransformOperations;
+struct Length;
+
+class FilterOperations;
+}
+
+namespace IPC {
+
+template<> struct ArgumentCoder<WebCore::FilterOperations> {
+ static void encode(Encoder&, const WebCore::FilterOperations&);
+ static bool decode(Decoder&, WebCore::FilterOperations&);
+};
+
+template<> struct ArgumentCoder<WebCore::TransformOperations> {
+ static void encode(Encoder&, const WebCore::TransformOperations&);
+ static bool decode(Decoder&, WebCore::TransformOperations&);
+};
+
+template<> struct ArgumentCoder<WebCore::TextureMapperAnimations> {
+ static void encode(Encoder&, const WebCore::TextureMapperAnimations&);
+ static bool decode(Decoder&, WebCore::TextureMapperAnimations&);
+};
+
+template<> struct ArgumentCoder<WebCore::TextureMapperAnimation> {
+ static void encode(Encoder&, const WebCore::TextureMapperAnimation&);
+ static bool decode(Decoder&, WebCore::TextureMapperAnimation&);
+};
+
+template<> struct ArgumentCoder<WebCore::SurfaceUpdateInfo> {
+ static void encode(Encoder&, const WebCore::SurfaceUpdateInfo&);
+ static bool decode(Decoder&, WebCore::SurfaceUpdateInfo&);
+};
+
+template<> struct ArgumentCoder<WebCore::CoordinatedGraphicsLayerState> {
+ static void encode(Encoder&, const WebCore::CoordinatedGraphicsLayerState&);
+ static bool decode(Decoder&, WebCore::CoordinatedGraphicsLayerState&);
+};
+
+template<> struct ArgumentCoder<WebCore::TileUpdateInfo> {
+ static void encode(Encoder&, const WebCore::TileUpdateInfo&);
+ static bool decode(Decoder&, WebCore::TileUpdateInfo&);
+};
+
+template<> struct ArgumentCoder<WebCore::TileCreationInfo> {
+ static void encode(Encoder&, const WebCore::TileCreationInfo&);
+ static bool decode(Decoder&, WebCore::TileCreationInfo&);
+};
+
+template<> struct ArgumentCoder<WebCore::CoordinatedGraphicsState> {
+ static void encode(Encoder&, const WebCore::CoordinatedGraphicsState&);
+ static bool decode(Decoder&, WebCore::CoordinatedGraphicsState&);
+};
+
+} // namespace IPC
+
+#endif // USE(COORDINATED_GRAPHICS)
+
+#endif // CoordinatedGraphicsArgumentCoders_h
diff --git a/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp b/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp
new file mode 100644
index 000000000..b94faea2c
--- /dev/null
+++ b/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp
@@ -0,0 +1,682 @@
+/*
+ Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
+ Copyright (C) 2012 Company 100, Inc.
+
+ 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"
+
+#if USE(COORDINATED_GRAPHICS)
+#include "CoordinatedGraphicsScene.h"
+
+#include "CoordinatedBackingStore.h"
+#include <WebCore/TextureMapper.h>
+#include <WebCore/TextureMapperBackingStore.h>
+#include <WebCore/TextureMapperGL.h>
+#include <WebCore/TextureMapperLayer.h>
+#include <wtf/Atomics.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void CoordinatedGraphicsScene::dispatchOnMainThread(Function<void()>&& function)
+{
+ if (isMainThread()) {
+ function();
+ return;
+ }
+
+ RunLoop::main().dispatch([protectedThis = makeRef(*this), function = WTFMove(function)] {
+ function();
+ });
+}
+
+void CoordinatedGraphicsScene::dispatchOnClientRunLoop(Function<void()>&& function)
+{
+ if (&m_clientRunLoop == &RunLoop::current()) {
+ function();
+ return;
+ }
+
+ m_clientRunLoop.dispatch([protectedThis = makeRef(*this), function = WTFMove(function)] {
+ function();
+ });
+}
+
+static bool layerShouldHaveBackingStore(TextureMapperLayer* layer)
+{
+ return layer->drawsContent() && layer->contentsAreVisible() && !layer->size().isEmpty();
+}
+
+CoordinatedGraphicsScene::CoordinatedGraphicsScene(CoordinatedGraphicsSceneClient* client)
+ : m_client(client)
+ , m_isActive(false)
+ , m_rootLayerID(InvalidCoordinatedLayerID)
+ , m_viewBackgroundColor(Color::white)
+ , m_clientRunLoop(RunLoop::current())
+{
+}
+
+CoordinatedGraphicsScene::~CoordinatedGraphicsScene()
+{
+}
+
+void CoordinatedGraphicsScene::paintToCurrentGLContext(const TransformationMatrix& matrix, float opacity, const FloatRect& clipRect, const Color& backgroundColor, bool drawsBackground, const FloatPoint& contentPosition, TextureMapper::PaintFlags PaintFlags)
+{
+ if (!m_textureMapper) {
+ m_textureMapper = TextureMapper::create();
+ static_cast<TextureMapperGL*>(m_textureMapper.get())->setEnableEdgeDistanceAntialiasing(true);
+ }
+
+ syncRemoteContent();
+
+ adjustPositionForFixedLayers(contentPosition);
+ TextureMapperLayer* currentRootLayer = rootLayer();
+ if (!currentRootLayer)
+ return;
+
+#if USE(COORDINATED_GRAPHICS_THREADED)
+ for (auto& proxy : m_platformLayerProxies.values())
+ proxy->swapBuffer();
+#endif
+
+ currentRootLayer->setTextureMapper(m_textureMapper.get());
+ currentRootLayer->applyAnimationsRecursively();
+ m_textureMapper->beginPainting(PaintFlags);
+ m_textureMapper->beginClip(TransformationMatrix(), clipRect);
+
+ if (drawsBackground) {
+ RGBA32 rgba = makeRGBA32FromFloats(backgroundColor.red(),
+ backgroundColor.green(), backgroundColor.blue(),
+ backgroundColor.alpha() * opacity);
+ m_textureMapper->drawSolidColor(clipRect, TransformationMatrix(), Color(rgba));
+ } else {
+ GraphicsContext3D* context = static_cast<TextureMapperGL*>(m_textureMapper.get())->graphicsContext3D();
+ context->clearColor(m_viewBackgroundColor.red() / 255.0f, m_viewBackgroundColor.green() / 255.0f, m_viewBackgroundColor.blue() / 255.0f, m_viewBackgroundColor.alpha() / 255.0f);
+ context->clear(GraphicsContext3D::COLOR_BUFFER_BIT);
+ }
+
+ if (currentRootLayer->opacity() != opacity || currentRootLayer->transform() != matrix) {
+ currentRootLayer->setOpacity(opacity);
+ currentRootLayer->setTransform(matrix);
+ }
+
+ currentRootLayer->paint();
+ m_fpsCounter.updateFPSAndDisplay(*m_textureMapper, clipRect.location(), matrix);
+ m_textureMapper->endClip();
+ m_textureMapper->endPainting();
+
+ if (currentRootLayer->descendantsOrSelfHaveRunningAnimations())
+ updateViewport();
+}
+
+void CoordinatedGraphicsScene::updateViewport()
+{
+ if (!m_client)
+ return;
+ dispatchOnClientRunLoop([this] {
+ if (m_client)
+ m_client->updateViewport();
+ });
+}
+
+void CoordinatedGraphicsScene::adjustPositionForFixedLayers(const FloatPoint& contentPosition)
+{
+ if (m_fixedLayers.isEmpty())
+ return;
+
+ // Fixed layer positions are updated by the web process when we update the visible contents rect / scroll position.
+ // If we want those layers to follow accurately the viewport when we move between the web process updates, we have to offset
+ // them by the delta between the current position and the position of the viewport used for the last layout.
+ FloatSize delta = contentPosition - m_renderedContentsScrollPosition;
+
+ for (auto& fixedLayer : m_fixedLayers.values())
+ fixedLayer->setScrollPositionDeltaIfNeeded(delta);
+}
+
+void CoordinatedGraphicsScene::syncPlatformLayerIfNeeded(TextureMapperLayer* layer, const CoordinatedGraphicsLayerState& state)
+{
+#if USE(COORDINATED_GRAPHICS_THREADED)
+ if (!state.platformLayerChanged)
+ return;
+
+ if (state.platformLayerProxy) {
+ m_platformLayerProxies.set(layer, state.platformLayerProxy);
+ state.platformLayerProxy->activateOnCompositingThread(this, layer);
+ } else
+ m_platformLayerProxies.remove(layer);
+#else
+ UNUSED_PARAM(layer);
+ UNUSED_PARAM(state);
+#endif
+}
+
+#if USE(COORDINATED_GRAPHICS_THREADED)
+void CoordinatedGraphicsScene::onNewBufferAvailable()
+{
+ updateViewport();
+}
+#endif
+
+void CoordinatedGraphicsScene::setLayerRepaintCountIfNeeded(TextureMapperLayer* layer, const CoordinatedGraphicsLayerState& state)
+{
+ if (!layer->isShowingRepaintCounter() || !state.repaintCountChanged)
+ return;
+
+ layer->setRepaintCount(state.repaintCount);
+}
+
+void CoordinatedGraphicsScene::setLayerChildrenIfNeeded(TextureMapperLayer* layer, const CoordinatedGraphicsLayerState& state)
+{
+ if (!state.childrenChanged)
+ return;
+
+ Vector<TextureMapperLayer*> children;
+ children.reserveCapacity(state.children.size());
+ for (auto& child : state.children)
+ children.append(layerByID(child));
+
+ layer->setChildren(children);
+}
+
+void CoordinatedGraphicsScene::setLayerFiltersIfNeeded(TextureMapperLayer* layer, const CoordinatedGraphicsLayerState& state)
+{
+ if (!state.filtersChanged)
+ return;
+
+ layer->setFilters(state.filters);
+}
+
+void CoordinatedGraphicsScene::setLayerState(CoordinatedLayerID id, const CoordinatedGraphicsLayerState& layerState)
+{
+ ASSERT(m_rootLayerID != InvalidCoordinatedLayerID);
+ TextureMapperLayer* layer = layerByID(id);
+
+ if (layerState.positionChanged)
+ layer->setPosition(layerState.pos);
+
+ if (layerState.anchorPointChanged)
+ layer->setAnchorPoint(layerState.anchorPoint);
+
+ if (layerState.sizeChanged)
+ layer->setSize(layerState.size);
+
+ if (layerState.transformChanged)
+ layer->setTransform(layerState.transform);
+
+ if (layerState.childrenTransformChanged)
+ layer->setChildrenTransform(layerState.childrenTransform);
+
+ if (layerState.contentsRectChanged)
+ layer->setContentsRect(layerState.contentsRect);
+
+ if (layerState.contentsTilingChanged) {
+ layer->setContentsTilePhase(layerState.contentsTilePhase);
+ layer->setContentsTileSize(layerState.contentsTileSize);
+ }
+
+ if (layerState.opacityChanged)
+ layer->setOpacity(layerState.opacity);
+
+ if (layerState.solidColorChanged)
+ layer->setSolidColor(layerState.solidColor);
+
+ if (layerState.debugBorderColorChanged || layerState.debugBorderWidthChanged)
+ layer->setDebugVisuals(layerState.showDebugBorders, layerState.debugBorderColor, layerState.debugBorderWidth, layerState.showRepaintCounter);
+
+ if (layerState.replicaChanged)
+ layer->setReplicaLayer(getLayerByIDIfExists(layerState.replica));
+
+ if (layerState.maskChanged)
+ layer->setMaskLayer(getLayerByIDIfExists(layerState.mask));
+
+ if (layerState.imageChanged)
+ assignImageBackingToLayer(layer, layerState.imageID);
+
+ if (layerState.flagsChanged) {
+ layer->setContentsOpaque(layerState.contentsOpaque);
+ layer->setDrawsContent(layerState.drawsContent);
+ layer->setContentsVisible(layerState.contentsVisible);
+ layer->setBackfaceVisibility(layerState.backfaceVisible);
+
+ // Never clip the root layer.
+ layer->setMasksToBounds(id == m_rootLayerID ? false : layerState.masksToBounds);
+ layer->setPreserves3D(layerState.preserves3D);
+
+ bool fixedToViewportChanged = layer->fixedToViewport() != layerState.fixedToViewport;
+ layer->setFixedToViewport(layerState.fixedToViewport);
+ if (fixedToViewportChanged) {
+ if (layerState.fixedToViewport)
+ m_fixedLayers.add(id, layer);
+ else
+ m_fixedLayers.remove(id);
+ }
+
+ layer->setIsScrollable(layerState.isScrollable);
+ }
+
+ if (layerState.committedScrollOffsetChanged)
+ layer->didCommitScrollOffset(layerState.committedScrollOffset);
+
+ prepareContentBackingStore(layer);
+
+ // Apply Operations.
+ setLayerChildrenIfNeeded(layer, layerState);
+ createTilesIfNeeded(layer, layerState);
+ removeTilesIfNeeded(layer, layerState);
+ updateTilesIfNeeded(layer, layerState);
+ setLayerFiltersIfNeeded(layer, layerState);
+ setLayerAnimationsIfNeeded(layer, layerState);
+ syncPlatformLayerIfNeeded(layer, layerState);
+ setLayerRepaintCountIfNeeded(layer, layerState);
+}
+
+TextureMapperLayer* CoordinatedGraphicsScene::getLayerByIDIfExists(CoordinatedLayerID id)
+{
+ return (id != InvalidCoordinatedLayerID) ? layerByID(id) : 0;
+}
+
+void CoordinatedGraphicsScene::createLayers(const Vector<CoordinatedLayerID>& layerIDs)
+{
+ for (auto& layerID : layerIDs)
+ createLayer(layerID);
+}
+
+void CoordinatedGraphicsScene::createLayer(CoordinatedLayerID id)
+{
+ std::unique_ptr<TextureMapperLayer> newLayer = std::make_unique<TextureMapperLayer>();
+ newLayer->setID(id);
+ newLayer->setScrollClient(this);
+ m_layers.add(id, WTFMove(newLayer));
+}
+
+void CoordinatedGraphicsScene::deleteLayers(const Vector<CoordinatedLayerID>& layerIDs)
+{
+ for (auto& layerID : layerIDs)
+ deleteLayer(layerID);
+}
+
+void CoordinatedGraphicsScene::deleteLayer(CoordinatedLayerID layerID)
+{
+ std::unique_ptr<TextureMapperLayer> layer = m_layers.take(layerID);
+ ASSERT(layer);
+
+ m_backingStores.remove(layer.get());
+ m_fixedLayers.remove(layerID);
+#if USE(COORDINATED_GRAPHICS_THREADED)
+ if (auto platformLayerProxy = m_platformLayerProxies.take(layer.get()))
+ platformLayerProxy->invalidate();
+#endif
+}
+
+void CoordinatedGraphicsScene::setRootLayerID(CoordinatedLayerID layerID)
+{
+ ASSERT(layerID != InvalidCoordinatedLayerID);
+ ASSERT(m_rootLayerID == InvalidCoordinatedLayerID);
+
+ m_rootLayerID = layerID;
+
+ TextureMapperLayer* layer = layerByID(layerID);
+ ASSERT(m_rootLayer->children().isEmpty());
+ m_rootLayer->addChild(layer);
+}
+
+void CoordinatedGraphicsScene::prepareContentBackingStore(TextureMapperLayer* layer)
+{
+ if (!layerShouldHaveBackingStore(layer)) {
+ removeBackingStoreIfNeeded(layer);
+ return;
+ }
+
+ createBackingStoreIfNeeded(layer);
+ resetBackingStoreSizeToLayerSize(layer);
+}
+
+void CoordinatedGraphicsScene::createBackingStoreIfNeeded(TextureMapperLayer* layer)
+{
+ if (m_backingStores.contains(layer))
+ return;
+
+ RefPtr<CoordinatedBackingStore> backingStore(CoordinatedBackingStore::create());
+ m_backingStores.add(layer, backingStore);
+ layer->setBackingStore(backingStore);
+}
+
+void CoordinatedGraphicsScene::removeBackingStoreIfNeeded(TextureMapperLayer* layer)
+{
+ RefPtr<CoordinatedBackingStore> backingStore = m_backingStores.take(layer);
+ if (!backingStore)
+ return;
+
+ layer->setBackingStore(0);
+}
+
+void CoordinatedGraphicsScene::resetBackingStoreSizeToLayerSize(TextureMapperLayer* layer)
+{
+ RefPtr<CoordinatedBackingStore> backingStore = m_backingStores.get(layer);
+ ASSERT(backingStore);
+ backingStore->setSize(layer->size());
+ m_backingStoresWithPendingBuffers.add(backingStore);
+}
+
+void CoordinatedGraphicsScene::createTilesIfNeeded(TextureMapperLayer* layer, const CoordinatedGraphicsLayerState& state)
+{
+ if (state.tilesToCreate.isEmpty())
+ return;
+
+ RefPtr<CoordinatedBackingStore> backingStore = m_backingStores.get(layer);
+ ASSERT(backingStore || !layerShouldHaveBackingStore(layer));
+ if (!backingStore)
+ return;
+
+ for (auto& tile : state.tilesToCreate)
+ backingStore->createTile(tile.tileID, tile.scale);
+}
+
+void CoordinatedGraphicsScene::removeTilesIfNeeded(TextureMapperLayer* layer, const CoordinatedGraphicsLayerState& state)
+{
+ if (state.tilesToRemove.isEmpty())
+ return;
+
+ RefPtr<CoordinatedBackingStore> backingStore = m_backingStores.get(layer);
+ if (!backingStore)
+ return;
+
+ for (auto& tile : state.tilesToRemove)
+ backingStore->removeTile(tile);
+
+ m_backingStoresWithPendingBuffers.add(backingStore);
+}
+
+void CoordinatedGraphicsScene::updateTilesIfNeeded(TextureMapperLayer* layer, const CoordinatedGraphicsLayerState& state)
+{
+ if (state.tilesToUpdate.isEmpty())
+ return;
+
+ RefPtr<CoordinatedBackingStore> backingStore = m_backingStores.get(layer);
+ ASSERT(backingStore || !layerShouldHaveBackingStore(layer));
+ if (!backingStore)
+ return;
+
+ for (auto& tile : state.tilesToUpdate) {
+ const SurfaceUpdateInfo& surfaceUpdateInfo = tile.updateInfo;
+
+ SurfaceMap::iterator surfaceIt = m_surfaces.find(surfaceUpdateInfo.atlasID);
+ ASSERT(surfaceIt != m_surfaces.end());
+
+ backingStore->updateTile(tile.tileID, surfaceUpdateInfo.updateRect, tile.tileRect, surfaceIt->value, surfaceUpdateInfo.surfaceOffset);
+ m_backingStoresWithPendingBuffers.add(backingStore);
+ }
+}
+
+void CoordinatedGraphicsScene::syncUpdateAtlases(const CoordinatedGraphicsState& state)
+{
+ for (auto& atlas : state.updateAtlasesToCreate)
+ createUpdateAtlas(atlas.first, atlas.second);
+
+ for (auto& atlas : state.updateAtlasesToRemove)
+ removeUpdateAtlas(atlas);
+}
+
+void CoordinatedGraphicsScene::createUpdateAtlas(uint32_t atlasID, PassRefPtr<CoordinatedSurface> surface)
+{
+ ASSERT(!m_surfaces.contains(atlasID));
+ m_surfaces.add(atlasID, surface);
+}
+
+void CoordinatedGraphicsScene::removeUpdateAtlas(uint32_t atlasID)
+{
+ ASSERT(m_surfaces.contains(atlasID));
+ m_surfaces.remove(atlasID);
+}
+
+void CoordinatedGraphicsScene::syncImageBackings(const CoordinatedGraphicsState& state)
+{
+ for (auto& image : state.imagesToRemove)
+ removeImageBacking(image);
+
+ for (auto& image : state.imagesToCreate)
+ createImageBacking(image);
+
+ for (auto& image : state.imagesToUpdate)
+ updateImageBacking(image.first, image.second);
+
+ for (auto& image : state.imagesToClear)
+ clearImageBackingContents(image);
+}
+
+void CoordinatedGraphicsScene::createImageBacking(CoordinatedImageBackingID imageID)
+{
+ ASSERT(!m_imageBackings.contains(imageID));
+ RefPtr<CoordinatedBackingStore> backingStore(CoordinatedBackingStore::create());
+ m_imageBackings.add(imageID, backingStore.release());
+}
+
+void CoordinatedGraphicsScene::updateImageBacking(CoordinatedImageBackingID imageID, PassRefPtr<CoordinatedSurface> surface)
+{
+ ASSERT(m_imageBackings.contains(imageID));
+ ImageBackingMap::iterator it = m_imageBackings.find(imageID);
+ RefPtr<CoordinatedBackingStore> backingStore = it->value;
+
+ // CoordinatedImageBacking is realized to CoordinatedBackingStore with only one tile in UI Process.
+ backingStore->createTile(1 /* id */, 1 /* scale */);
+ IntRect rect(IntPoint::zero(), surface->size());
+ // See CoordinatedGraphicsLayer::shouldDirectlyCompositeImage()
+ ASSERT(2000 >= std::max(rect.width(), rect.height()));
+ backingStore->setSize(rect.size());
+ backingStore->updateTile(1 /* id */, rect, rect, surface, rect.location());
+
+ m_backingStoresWithPendingBuffers.add(backingStore);
+}
+
+void CoordinatedGraphicsScene::clearImageBackingContents(CoordinatedImageBackingID imageID)
+{
+ ASSERT(m_imageBackings.contains(imageID));
+ ImageBackingMap::iterator it = m_imageBackings.find(imageID);
+ RefPtr<CoordinatedBackingStore> backingStore = it->value;
+ backingStore->removeAllTiles();
+ m_backingStoresWithPendingBuffers.add(backingStore);
+}
+
+void CoordinatedGraphicsScene::removeImageBacking(CoordinatedImageBackingID imageID)
+{
+ ASSERT(m_imageBackings.contains(imageID));
+
+ // We don't want TextureMapperLayer refers a dangling pointer.
+ m_releasedImageBackings.append(m_imageBackings.take(imageID));
+}
+
+void CoordinatedGraphicsScene::assignImageBackingToLayer(TextureMapperLayer* layer, CoordinatedImageBackingID imageID)
+{
+ if (imageID == InvalidCoordinatedImageBackingID) {
+ layer->setContentsLayer(0);
+ return;
+ }
+
+ ImageBackingMap::iterator it = m_imageBackings.find(imageID);
+ ASSERT(it != m_imageBackings.end());
+ layer->setContentsLayer(it->value.get());
+}
+
+void CoordinatedGraphicsScene::removeReleasedImageBackingsIfNeeded()
+{
+ m_releasedImageBackings.clear();
+}
+
+void CoordinatedGraphicsScene::commitPendingBackingStoreOperations()
+{
+ for (auto& backingStore : m_backingStoresWithPendingBuffers)
+ backingStore->commitTileOperations(*m_textureMapper);
+
+ m_backingStoresWithPendingBuffers.clear();
+}
+
+void CoordinatedGraphicsScene::commitSceneState(const CoordinatedGraphicsState& state)
+{
+ if (!m_client)
+ return;
+
+ m_renderedContentsScrollPosition = state.scrollPosition;
+
+ createLayers(state.layersToCreate);
+ deleteLayers(state.layersToRemove);
+
+ if (state.rootCompositingLayer != m_rootLayerID)
+ setRootLayerID(state.rootCompositingLayer);
+
+ syncImageBackings(state);
+ syncUpdateAtlases(state);
+
+ for (auto& layer : state.layersToUpdate)
+ setLayerState(layer.first, layer.second);
+
+ commitPendingBackingStoreOperations();
+ removeReleasedImageBackingsIfNeeded();
+
+ // The pending tiles state is on its way for the screen, tell the web process to render the next one.
+ renderNextFrame();
+}
+
+void CoordinatedGraphicsScene::renderNextFrame()
+{
+ if (!m_client)
+ return;
+ dispatchOnMainThread([this] {
+ if (m_client)
+ m_client->renderNextFrame();
+ });
+}
+
+void CoordinatedGraphicsScene::ensureRootLayer()
+{
+ if (m_rootLayer)
+ return;
+
+ m_rootLayer = std::make_unique<TextureMapperLayer>();
+ m_rootLayer->setMasksToBounds(false);
+ m_rootLayer->setDrawsContent(false);
+ m_rootLayer->setAnchorPoint(FloatPoint3D(0, 0, 0));
+
+ // The root layer should not have zero size, or it would be optimized out.
+ m_rootLayer->setSize(FloatSize(1.0, 1.0));
+
+ ASSERT(m_textureMapper);
+ m_rootLayer->setTextureMapper(m_textureMapper.get());
+}
+
+void CoordinatedGraphicsScene::syncRemoteContent()
+{
+ // We enqueue messages and execute them during paint, as they require an active GL context.
+ ensureRootLayer();
+
+ Vector<std::function<void()>> renderQueue;
+ bool calledOnMainThread = WTF::isMainThread();
+ if (!calledOnMainThread)
+ m_renderQueueMutex.lock();
+ renderQueue = WTFMove(m_renderQueue);
+ if (!calledOnMainThread)
+ m_renderQueueMutex.unlock();
+
+ for (auto& function : renderQueue)
+ function();
+}
+
+void CoordinatedGraphicsScene::purgeGLResources()
+{
+ ASSERT(!m_client);
+
+ m_imageBackings.clear();
+ m_releasedImageBackings.clear();
+#if USE(COORDINATED_GRAPHICS_THREADED)
+ for (auto& proxy : m_platformLayerProxies.values())
+ proxy->invalidate();
+ m_platformLayerProxies.clear();
+#endif
+ m_surfaces.clear();
+
+ m_rootLayer = nullptr;
+ m_rootLayerID = InvalidCoordinatedLayerID;
+ m_layers.clear();
+ m_fixedLayers.clear();
+ m_textureMapper = nullptr;
+ m_backingStores.clear();
+ m_backingStoresWithPendingBuffers.clear();
+}
+
+void CoordinatedGraphicsScene::commitScrollOffset(uint32_t layerID, const IntSize& offset)
+{
+ if (!m_client)
+ return;
+ dispatchOnMainThread([this, layerID, offset] {
+ if (m_client)
+ m_client->commitScrollOffset(layerID, offset);
+ });
+}
+
+void CoordinatedGraphicsScene::setLayerAnimationsIfNeeded(TextureMapperLayer* layer, const CoordinatedGraphicsLayerState& state)
+{
+ if (!state.animationsChanged)
+ return;
+
+ layer->setAnimations(state.animations);
+}
+
+void CoordinatedGraphicsScene::detach()
+{
+ ASSERT(isMainThread());
+ m_isActive = false;
+ m_client = nullptr;
+ LockHolder locker(m_renderQueueMutex);
+ m_renderQueue.clear();
+}
+
+void CoordinatedGraphicsScene::appendUpdate(std::function<void()>&& function)
+{
+ if (!m_isActive)
+ return;
+
+ ASSERT(isMainThread());
+ LockHolder locker(m_renderQueueMutex);
+ m_renderQueue.append(WTFMove(function));
+}
+
+void CoordinatedGraphicsScene::setActive(bool active)
+{
+ if (!m_client)
+ return;
+
+ if (m_isActive == active)
+ return;
+
+ // Have to clear render queue in both cases.
+ // If there are some updates in queue during activation then those updates are from previous instance of paint node
+ // and cannot be applied to the newly created instance.
+ m_renderQueue.clear();
+ m_isActive = active;
+ if (m_isActive)
+ renderNextFrame();
+}
+
+TextureMapperLayer* CoordinatedGraphicsScene::findScrollableContentsLayerAt(const FloatPoint& point)
+{
+ return rootLayer() ? rootLayer()->findScrollableContentsLayerAt(point) : 0;
+}
+
+} // namespace WebKit
+
+#endif // USE(COORDINATED_GRAPHICS)
diff --git a/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.h b/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.h
new file mode 100644
index 000000000..128b7be76
--- /dev/null
+++ b/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.h
@@ -0,0 +1,194 @@
+/*
+ Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
+ Copyright (C) 2013 Company 100, Inc.
+
+ 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.
+*/
+
+#ifndef CoordinatedGraphicsScene_h
+#define CoordinatedGraphicsScene_h
+
+#if USE(COORDINATED_GRAPHICS)
+#include <WebCore/CoordinatedGraphicsState.h>
+#include <WebCore/CoordinatedSurface.h>
+#include <WebCore/GraphicsContext.h>
+#include <WebCore/GraphicsLayer.h>
+#include <WebCore/IntRect.h>
+#include <WebCore/IntSize.h>
+#include <WebCore/TextureMapper.h>
+#include <WebCore/TextureMapperBackingStore.h>
+#include <WebCore/TextureMapperFPSCounter.h>
+#include <WebCore/TextureMapperLayer.h>
+#include <WebCore/Timer.h>
+#include <wtf/Function.h>
+#include <wtf/HashSet.h>
+#include <wtf/Lock.h>
+#include <wtf/RunLoop.h>
+#include <wtf/ThreadingPrimitives.h>
+#include <wtf/Vector.h>
+
+#if USE(COORDINATED_GRAPHICS_THREADED)
+#include <WebCore/TextureMapperPlatformLayerProxy.h>
+#endif
+
+namespace WebKit {
+
+class CoordinatedBackingStore;
+
+class CoordinatedGraphicsSceneClient {
+public:
+ virtual ~CoordinatedGraphicsSceneClient() { }
+ virtual void renderNextFrame() = 0;
+ virtual void updateViewport() = 0;
+ virtual void commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset) = 0;
+};
+
+class CoordinatedGraphicsScene : public ThreadSafeRefCounted<CoordinatedGraphicsScene>, public WebCore::TextureMapperLayer::ScrollingClient
+#if USE(COORDINATED_GRAPHICS_THREADED)
+ , public WebCore::TextureMapperPlatformLayerProxy::Compositor
+#endif
+{
+public:
+ explicit CoordinatedGraphicsScene(CoordinatedGraphicsSceneClient*);
+ virtual ~CoordinatedGraphicsScene();
+ void paintToCurrentGLContext(const WebCore::TransformationMatrix&, float, const WebCore::FloatRect&, const WebCore::Color& backgroundColor, bool drawsBackground, const WebCore::FloatPoint&, WebCore::TextureMapper::PaintFlags = 0);
+ void detach();
+ void appendUpdate(std::function<void()>&&);
+
+ WebCore::TextureMapperLayer* findScrollableContentsLayerAt(const WebCore::FloatPoint&);
+
+ void commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset) override;
+
+ // The painting thread must lock the main thread to use below two methods, because two methods access members that the main thread manages. See m_client.
+ // Currently, QQuickWebPage::updatePaintNode() locks the main thread before calling both methods.
+ void purgeGLResources();
+
+ bool isActive() const { return m_isActive; }
+ void setActive(bool);
+
+ void commitSceneState(const WebCore::CoordinatedGraphicsState&);
+
+ void setViewBackgroundColor(const WebCore::Color& color) { m_viewBackgroundColor = color; }
+ WebCore::Color viewBackgroundColor() const { return m_viewBackgroundColor; }
+
+private:
+ void setRootLayerID(WebCore::CoordinatedLayerID);
+ void createLayers(const Vector<WebCore::CoordinatedLayerID>&);
+ void deleteLayers(const Vector<WebCore::CoordinatedLayerID>&);
+ void setLayerState(WebCore::CoordinatedLayerID, const WebCore::CoordinatedGraphicsLayerState&);
+ void setLayerChildrenIfNeeded(WebCore::TextureMapperLayer*, const WebCore::CoordinatedGraphicsLayerState&);
+ void updateTilesIfNeeded(WebCore::TextureMapperLayer*, const WebCore::CoordinatedGraphicsLayerState&);
+ void createTilesIfNeeded(WebCore::TextureMapperLayer*, const WebCore::CoordinatedGraphicsLayerState&);
+ void removeTilesIfNeeded(WebCore::TextureMapperLayer*, const WebCore::CoordinatedGraphicsLayerState&);
+ void setLayerFiltersIfNeeded(WebCore::TextureMapperLayer*, const WebCore::CoordinatedGraphicsLayerState&);
+ void setLayerAnimationsIfNeeded(WebCore::TextureMapperLayer*, const WebCore::CoordinatedGraphicsLayerState&);
+ void syncPlatformLayerIfNeeded(WebCore::TextureMapperLayer*, const WebCore::CoordinatedGraphicsLayerState&);
+ void setLayerRepaintCountIfNeeded(WebCore::TextureMapperLayer*, const WebCore::CoordinatedGraphicsLayerState&);
+
+ void syncUpdateAtlases(const WebCore::CoordinatedGraphicsState&);
+ void createUpdateAtlas(uint32_t atlasID, PassRefPtr<WebCore::CoordinatedSurface>);
+ void removeUpdateAtlas(uint32_t atlasID);
+
+ void syncImageBackings(const WebCore::CoordinatedGraphicsState&);
+ void createImageBacking(WebCore::CoordinatedImageBackingID);
+ void updateImageBacking(WebCore::CoordinatedImageBackingID, PassRefPtr<WebCore::CoordinatedSurface>);
+ void clearImageBackingContents(WebCore::CoordinatedImageBackingID);
+ void removeImageBacking(WebCore::CoordinatedImageBackingID);
+
+ WebCore::TextureMapperLayer* layerByID(WebCore::CoordinatedLayerID id)
+ {
+ ASSERT(m_layers.contains(id));
+ ASSERT(id != WebCore::InvalidCoordinatedLayerID);
+ return m_layers.get(id);
+ }
+ WebCore::TextureMapperLayer* getLayerByIDIfExists(WebCore::CoordinatedLayerID);
+ WebCore::TextureMapperLayer* rootLayer() { return m_rootLayer.get(); }
+
+ void syncRemoteContent();
+ void adjustPositionForFixedLayers(const WebCore::FloatPoint& contentPosition);
+
+ void dispatchOnMainThread(Function<void()>&&);
+ void dispatchOnClientRunLoop(Function<void()>&&);
+ void updateViewport();
+ void renderNextFrame();
+
+ void createLayer(WebCore::CoordinatedLayerID);
+ void deleteLayer(WebCore::CoordinatedLayerID);
+
+ void assignImageBackingToLayer(WebCore::TextureMapperLayer*, WebCore::CoordinatedImageBackingID);
+ void removeReleasedImageBackingsIfNeeded();
+ void ensureRootLayer();
+ void commitPendingBackingStoreOperations();
+
+ void prepareContentBackingStore(WebCore::TextureMapperLayer*);
+ void createBackingStoreIfNeeded(WebCore::TextureMapperLayer*);
+ void removeBackingStoreIfNeeded(WebCore::TextureMapperLayer*);
+ void resetBackingStoreSizeToLayerSize(WebCore::TextureMapperLayer*);
+
+#if USE(COORDINATED_GRAPHICS_THREADED)
+ void onNewBufferAvailable() override;
+#endif
+
+ // Render queue can be accessed ony from main thread or updatePaintNode call stack!
+ Vector<std::function<void()>> m_renderQueue;
+ Lock m_renderQueueMutex;
+
+ std::unique_ptr<WebCore::TextureMapper> m_textureMapper;
+
+ typedef HashMap<WebCore::CoordinatedImageBackingID, RefPtr<CoordinatedBackingStore>> ImageBackingMap;
+ ImageBackingMap m_imageBackings;
+ Vector<RefPtr<CoordinatedBackingStore>> m_releasedImageBackings;
+
+ typedef HashMap<WebCore::TextureMapperLayer*, RefPtr<CoordinatedBackingStore>> BackingStoreMap;
+ BackingStoreMap m_backingStores;
+
+ HashSet<RefPtr<CoordinatedBackingStore>> m_backingStoresWithPendingBuffers;
+
+#if USE(COORDINATED_GRAPHICS_THREADED)
+ typedef HashMap<WebCore::TextureMapperLayer*, RefPtr<WebCore::TextureMapperPlatformLayerProxy>> PlatformLayerProxyMap;
+ PlatformLayerProxyMap m_platformLayerProxies;
+#endif
+
+ typedef HashMap<uint32_t /* atlasID */, RefPtr<WebCore::CoordinatedSurface>> SurfaceMap;
+ SurfaceMap m_surfaces;
+
+ // Below two members are accessed by only the main thread. The painting thread must lock the main thread to access both members.
+ CoordinatedGraphicsSceneClient* m_client;
+ bool m_isActive;
+
+ std::unique_ptr<WebCore::TextureMapperLayer> m_rootLayer;
+
+ typedef HashMap<WebCore::CoordinatedLayerID, std::unique_ptr<WebCore::TextureMapperLayer>> LayerMap;
+ LayerMap m_layers;
+ typedef HashMap<WebCore::CoordinatedLayerID, WebCore::TextureMapperLayer*> LayerRawPtrMap;
+ LayerRawPtrMap m_fixedLayers;
+ WebCore::CoordinatedLayerID m_rootLayerID;
+ WebCore::FloatPoint m_scrollPosition;
+ WebCore::FloatPoint m_renderedContentsScrollPosition;
+ WebCore::Color m_viewBackgroundColor;
+
+ WebCore::TextureMapperFPSCounter m_fpsCounter;
+
+ RunLoop& m_clientRunLoop;
+};
+
+} // namespace WebKit
+
+#endif // USE(COORDINATED_GRAPHICS)
+
+#endif // CoordinatedGraphicsScene_h
+
+
diff --git a/Source/WebKit2/Shared/CoordinatedGraphics/SimpleViewportController.cpp b/Source/WebKit2/Shared/CoordinatedGraphics/SimpleViewportController.cpp
new file mode 100644
index 000000000..a5eaafea4
--- /dev/null
+++ b/Source/WebKit2/Shared/CoordinatedGraphics/SimpleViewportController.cpp
@@ -0,0 +1,172 @@
+/*
+ * Copyright (C) 2011, 2012 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2011 Benjamin Poulain <benjamin@webkit.org>
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ * 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 program 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 program; 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 "SimpleViewportController.h"
+
+#if USE(COORDINATED_GRAPHICS_THREADED)
+
+using namespace WebCore;
+
+namespace WebKit {
+
+SimpleViewportController::SimpleViewportController(const IntSize& size)
+ : m_viewportSize(size)
+{
+ resetViewportToDefaultState();
+}
+
+void SimpleViewportController::didChangeViewportSize(const IntSize& newSize)
+{
+ if (newSize.isEmpty())
+ return;
+
+ m_viewportSize = newSize;
+ updateMinimumScaleToFit();
+}
+
+void SimpleViewportController::didChangeContentsSize(const IntSize& newSize)
+{
+ m_contentsSize = newSize;
+
+ updateMinimumScaleToFit();
+
+ if (m_initiallyFitToViewport) {
+ // Restrict scale factors to m_minimumScaleToFit.
+ ASSERT(m_minimumScaleToFit > 0);
+ m_rawAttributes.initialScale = m_minimumScaleToFit;
+ restrictScaleFactorToInitialScaleIfNotUserScalable(m_rawAttributes);
+ }
+}
+
+void SimpleViewportController::didChangeViewportAttributes(ViewportAttributes&& newAttributes)
+{
+ if (newAttributes.layoutSize.isEmpty()) {
+ resetViewportToDefaultState();
+ return;
+ }
+
+ m_hasViewportAttribute = true;
+
+ m_rawAttributes = WTFMove(newAttributes);
+ m_allowsUserScaling = m_rawAttributes.userScalable;
+ m_initiallyFitToViewport = m_rawAttributes.initialScale < 0;
+
+ if (!m_initiallyFitToViewport)
+ restrictScaleFactorToInitialScaleIfNotUserScalable(m_rawAttributes);
+
+ updateMinimumScaleToFit();
+}
+
+void SimpleViewportController::didScroll(const IntPoint& position)
+{
+ m_contentsPosition = position;
+}
+
+FloatRect SimpleViewportController::visibleContentsRect() const
+{
+ if (m_viewportSize.isEmpty() || m_contentsSize.isEmpty())
+ return { };
+
+ FloatRect visibleContentsRect(boundContentsPosition(m_contentsPosition), visibleContentsSize());
+ visibleContentsRect.intersect(FloatRect(FloatPoint::zero(), m_contentsSize));
+ return visibleContentsRect;
+}
+
+FloatSize SimpleViewportController::visibleContentsSize() const
+{
+ return FloatSize(m_viewportSize.width() / m_pageScaleFactor, m_viewportSize.height() / m_pageScaleFactor);
+}
+
+FloatPoint SimpleViewportController::boundContentsPositionAtScale(const FloatPoint& framePosition, float scale) const
+{
+ // We need to floor the viewport here as to allow aligning the content in device units. If not,
+ // it might not be possible to scroll the last pixel and that affects fixed position elements.
+ return FloatPoint(
+ clampTo(framePosition.x(), .0f, std::max(.0f, m_contentsSize.width() - floorf(m_viewportSize.width() / scale))),
+ clampTo(framePosition.y(), .0f, std::max(.0f, m_contentsSize.height() - floorf(m_viewportSize.height() / scale))));
+}
+
+FloatPoint SimpleViewportController::boundContentsPosition(const FloatPoint& framePosition) const
+{
+ return boundContentsPositionAtScale(framePosition, m_pageScaleFactor);
+}
+
+bool fuzzyCompare(float a, float b, float epsilon)
+{
+ return std::abs(a - b) < epsilon;
+}
+
+bool SimpleViewportController::updateMinimumScaleToFit()
+{
+ if (m_viewportSize.isEmpty() || m_contentsSize.isEmpty() || !m_hasViewportAttribute)
+ return false;
+
+ bool currentlyScaledToFit = fuzzyCompare(m_pageScaleFactor, m_minimumScaleToFit, 0.0001);
+
+ float minimumScale = computeMinimumScaleFactorForContentContained(m_rawAttributes, roundedIntSize(m_viewportSize), roundedIntSize(m_contentsSize));
+
+ if (minimumScale <= 0)
+ return false;
+
+ if (!fuzzyCompare(minimumScale, m_minimumScaleToFit, 0.0001)) {
+ m_minimumScaleToFit = minimumScale;
+
+ if (currentlyScaledToFit)
+ m_pageScaleFactor = m_minimumScaleToFit;
+ else {
+ // Ensure the effective scale stays within bounds.
+ float boundedScale = innerBoundedViewportScale(m_pageScaleFactor);
+ if (!fuzzyCompare(boundedScale, m_pageScaleFactor, 0.0001))
+ m_pageScaleFactor = boundedScale;
+ }
+
+ return true;
+ }
+ return false;
+}
+
+float SimpleViewportController::innerBoundedViewportScale(float viewportScale) const
+{
+ return clampTo(viewportScale, m_minimumScaleToFit, m_rawAttributes.maximumScale);
+}
+
+void SimpleViewportController::resetViewportToDefaultState()
+{
+ m_hasViewportAttribute = false;
+ m_pageScaleFactor = 1;
+ m_minimumScaleToFit = 1;
+
+ // Initializing Viewport Raw Attributes to avoid random negative or infinity scale factors
+ // if there is a race condition between the first layout and setting the viewport attributes for the first time.
+ m_rawAttributes.minimumScale = 1;
+ m_rawAttributes.maximumScale = 1;
+ m_rawAttributes.userScalable = m_allowsUserScaling;
+
+ // The initial scale might be implicit and set to -1, in this case we have to infer it
+ // using the viewport size and the final layout size.
+ // To be able to assert for valid scale we initialize it to -1.
+ m_rawAttributes.initialScale = -1;
+}
+
+} // namespace WebCore
+
+#endif // USE(COORDINATED_GRAPHICS_THREADED)
diff --git a/Source/WebKit2/Shared/CoordinatedGraphics/SimpleViewportController.h b/Source/WebKit2/Shared/CoordinatedGraphics/SimpleViewportController.h
new file mode 100644
index 000000000..0bd1a3587
--- /dev/null
+++ b/Source/WebKit2/Shared/CoordinatedGraphics/SimpleViewportController.h
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2011, 2012 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2011 Benjamin Poulain <benjamin@webkit.org>
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ * 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 program 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 program; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef SimpleViewportController_h
+#define SimpleViewportController_h
+
+#if USE(COORDINATED_GRAPHICS_THREADED)
+
+#include <WebCore/FloatPoint.h>
+#include <WebCore/FloatRect.h>
+#include <WebCore/FloatSize.h>
+#include <WebCore/IntRect.h>
+#include <WebCore/IntSize.h>
+#include <WebCore/ViewportArguments.h>
+#include <wtf/Noncopyable.h>
+
+namespace WebKit {
+
+class SimpleViewportController {
+ WTF_MAKE_NONCOPYABLE(SimpleViewportController);
+public:
+ SimpleViewportController(const WebCore::IntSize&);
+
+ void didChangeViewportSize(const WebCore::IntSize&);
+ void didChangeContentsSize(const WebCore::IntSize&);
+ void didChangeViewportAttributes(WebCore::ViewportAttributes&&);
+ void didScroll(const WebCore::IntPoint&);
+
+ WebCore::FloatRect visibleContentsRect() const;
+ float pageScaleFactor() const { return m_pageScaleFactor; }
+
+private:
+ WebCore::FloatSize visibleContentsSize() const;
+
+ void applyScaleAfterRenderingContents(float scale);
+ void applyPositionAfterRenderingContents(const WebCore::FloatPoint& pos);
+
+ WebCore::FloatPoint boundContentsPosition(const WebCore::FloatPoint&) const;
+ WebCore::FloatPoint boundContentsPositionAtScale(const WebCore::FloatPoint&, float scale) const;
+
+ bool updateMinimumScaleToFit();
+ float innerBoundedViewportScale(float) const;
+
+ void resetViewportToDefaultState();
+
+ WebCore::IntPoint m_contentsPosition;
+ WebCore::FloatSize m_contentsSize;
+ WebCore::FloatSize m_viewportSize;
+ float m_pageScaleFactor { 1 };
+
+ bool m_allowsUserScaling { false };
+ float m_minimumScaleToFit { 1 };
+ bool m_initiallyFitToViewport { false };
+
+ bool m_hasViewportAttribute { false };
+ WebCore::ViewportAttributes m_rawAttributes;
+};
+
+} // namespace WebKit
+
+#endif // USE(COORDINATED_GRAPHICS_THREADED)
+
+#endif // SimpleViewportController_h
diff --git a/Source/WebKit2/Shared/CoordinatedGraphics/WebCoordinatedSurface.cpp b/Source/WebKit2/Shared/CoordinatedGraphics/WebCoordinatedSurface.cpp
new file mode 100644
index 000000000..0ad1e7f86
--- /dev/null
+++ b/Source/WebKit2/Shared/CoordinatedGraphics/WebCoordinatedSurface.cpp
@@ -0,0 +1,131 @@
+/*
+ Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
+ Copyright (C) 2012 Company 100, Inc.
+
+ 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 "WebCoordinatedSurface.h"
+
+#if USE(COORDINATED_GRAPHICS)
+#include "CoordinatedGraphicsArgumentCoders.h"
+#include "GraphicsContext.h"
+#include "WebCoreArgumentCoders.h"
+#include <WebCore/GraphicsSurfaceToken.h>
+
+#if USE(TEXTURE_MAPPER)
+#include "BitmapTextureGL.h"
+#include "TextureMapperGL.h"
+#endif
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebCoordinatedSurface::Handle::Handle()
+{
+}
+
+void WebCoordinatedSurface::Handle::encode(IPC::Encoder& encoder) const
+{
+ encoder << m_size << m_flags;
+ encoder << m_bitmapHandle;
+}
+
+bool WebCoordinatedSurface::Handle::decode(IPC::Decoder& decoder, Handle& handle)
+{
+ if (!decoder.decode(handle.m_size))
+ return false;
+ if (!decoder.decode(handle.m_flags))
+ return false;
+ if (!decoder.decode(handle.m_bitmapHandle))
+ return false;
+
+ return true;
+}
+
+RefPtr<WebCoordinatedSurface> WebCoordinatedSurface::create(const IntSize& size, CoordinatedSurface::Flags flags)
+{
+ if (auto bitmap = ShareableBitmap::createShareable(size, (flags & SupportsAlpha) ? ShareableBitmap::SupportsAlpha : ShareableBitmap::NoFlags))
+ return create(size, flags, WTFMove(bitmap));
+
+ return nullptr;
+}
+
+std::unique_ptr<GraphicsContext> WebCoordinatedSurface::createGraphicsContext(const IntRect& rect)
+{
+ ASSERT(m_bitmap);
+ auto graphicsContext = m_bitmap->createGraphicsContext();
+ graphicsContext->clip(rect);
+ graphicsContext->translate(rect.x(), rect.y());
+ return graphicsContext;
+}
+
+Ref<WebCoordinatedSurface> WebCoordinatedSurface::create(const IntSize& size, CoordinatedSurface::Flags flags, RefPtr<ShareableBitmap> bitmap)
+{
+ return adoptRef(*new WebCoordinatedSurface(size, flags, bitmap));
+}
+
+WebCoordinatedSurface::WebCoordinatedSurface(const IntSize& size, CoordinatedSurface::Flags flags, RefPtr<ShareableBitmap> bitmap)
+ : CoordinatedSurface(size, flags)
+ , m_bitmap(bitmap)
+{
+}
+
+WebCoordinatedSurface::~WebCoordinatedSurface()
+{
+}
+
+RefPtr<WebCoordinatedSurface> WebCoordinatedSurface::create(const Handle& handle)
+{
+ RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(handle.m_bitmapHandle);
+ if (!bitmap)
+ return nullptr;
+
+ return create(handle.m_size, handle.m_flags, WTFMove(bitmap));
+}
+
+bool WebCoordinatedSurface::createHandle(Handle& handle)
+{
+ handle.m_size = m_size;
+ handle.m_flags = m_flags;
+
+ if (!m_bitmap->createHandle(handle.m_bitmapHandle))
+ return false;
+
+ return true;
+}
+
+void WebCoordinatedSurface::paintToSurface(const IntRect& rect, CoordinatedSurface::Client& client)
+{
+ auto context = createGraphicsContext(rect);
+ client.paintToSurfaceContext(*context);
+}
+
+#if USE(TEXTURE_MAPPER)
+void WebCoordinatedSurface::copyToTexture(RefPtr<WebCore::BitmapTexture> passTexture, const IntRect& target, const IntPoint& sourceOffset)
+{
+ RefPtr<BitmapTexture> texture(passTexture);
+
+ ASSERT(m_bitmap);
+ RefPtr<Image> image = m_bitmap->createImage();
+ texture->updateContents(image.get(), target, sourceOffset, BitmapTexture::UpdateCanModifyOriginalImageData);
+}
+#endif // USE(TEXTURE_MAPPER)
+
+} // namespace WebKit
+#endif // USE(COORDINATED_GRAPHICS)
diff --git a/Source/WebKit2/Shared/CoordinatedGraphics/WebCoordinatedSurface.h b/Source/WebKit2/Shared/CoordinatedGraphics/WebCoordinatedSurface.h
new file mode 100644
index 000000000..88a0c1059
--- /dev/null
+++ b/Source/WebKit2/Shared/CoordinatedGraphics/WebCoordinatedSurface.h
@@ -0,0 +1,83 @@
+/*
+ Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
+ Copyright (C) 2012 Company 100, Inc.
+
+ 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.
+ */
+
+#ifndef WebCoordinatedSurface_h
+#define WebCoordinatedSurface_h
+
+#if USE(COORDINATED_GRAPHICS)
+#include "ShareableBitmap.h"
+#include <WebCore/CoordinatedSurface.h>
+
+namespace WebCore {
+class BitmapTexture;
+class GraphicsContext;
+}
+
+namespace WebKit {
+
+class WebCoordinatedSurface : public WebCore::CoordinatedSurface {
+public:
+ class Handle {
+ WTF_MAKE_NONCOPYABLE(Handle);
+ public:
+ Handle();
+
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, Handle&);
+
+ private:
+ friend class WebCoordinatedSurface;
+ mutable ShareableBitmap::Handle m_bitmapHandle;
+ WebCore::IntSize m_size;
+ WebCore::CoordinatedSurface::Flags m_flags;
+ };
+
+ // Create a new WebCoordinatedSurface, and allocate either a GraphicsSurface or a ShareableBitmap as backing.
+ static RefPtr<WebCoordinatedSurface> create(const WebCore::IntSize&, Flags);
+
+ // Create a shareable surface from a handle.
+ static RefPtr<WebCoordinatedSurface> create(const Handle&);
+
+ // Create a handle.
+ bool createHandle(Handle&);
+
+ virtual ~WebCoordinatedSurface();
+
+ void paintToSurface(const WebCore::IntRect&, WebCore::CoordinatedSurface::Client&) override;
+
+#if USE(TEXTURE_MAPPER)
+ void copyToTexture(RefPtr<WebCore::BitmapTexture>, const WebCore::IntRect& target, const WebCore::IntPoint& sourceOffset) override;
+#endif
+
+private:
+ WebCoordinatedSurface(const WebCore::IntSize&, Flags, RefPtr<ShareableBitmap>);
+
+ // Create a WebCoordinatedSurface referencing an existing ShareableBitmap.
+ static Ref<WebCoordinatedSurface> create(const WebCore::IntSize&, Flags, RefPtr<ShareableBitmap>);
+
+ std::unique_ptr<WebCore::GraphicsContext> createGraphicsContext(const WebCore::IntRect&);
+
+ RefPtr<ShareableBitmap> m_bitmap;
+};
+
+} // namespace WebKit
+
+#endif // USE(COORDINATED_GRAPHICS)
+#endif // WebCoordinatedSurface_h
diff --git a/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.cpp b/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.cpp
new file mode 100644
index 000000000..a6eee3fd9
--- /dev/null
+++ b/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.cpp
@@ -0,0 +1,173 @@
+/*
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ * 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 "CompositingRunLoop.h"
+
+#if USE(COORDINATED_GRAPHICS_THREADED)
+
+#include <wtf/HashMap.h>
+#include <wtf/MainThread.h>
+#include <wtf/NeverDestroyed.h>
+#include <wtf/WorkQueue.h>
+
+#if USE(GLIB_EVENT_LOOP)
+#include <glib.h>
+#endif
+
+namespace WebKit {
+
+class WorkQueuePool {
+ WTF_MAKE_NONCOPYABLE(WorkQueuePool);
+ friend class NeverDestroyed<WorkQueuePool>;
+public:
+ static WorkQueuePool& singleton()
+ {
+ ASSERT(isMainThread());
+ static NeverDestroyed<WorkQueuePool> workQueuePool;
+ return workQueuePool;
+ }
+
+ void dispatch(void* context, Function<void ()>&& function)
+ {
+ ASSERT(isMainThread());
+ getOrCreateWorkQueueForContext(context).dispatch(WTFMove(function));
+ }
+
+ RunLoop& runLoop(void* context)
+ {
+ return getOrCreateWorkQueueForContext(context).runLoop();
+ }
+
+ void invalidate(void* context)
+ {
+ auto workQueue = m_workQueueMap.take(context);
+ ASSERT(workQueue);
+ if (m_workQueueMap.isEmpty()) {
+ m_sharedWorkQueue = nullptr;
+ m_threadCount = 0;
+ } else if (workQueue->hasOneRef())
+ m_threadCount--;
+ }
+
+private:
+ WorkQueuePool()
+ {
+#if PLATFORM(GTK)
+ m_threadCountLimit = 1;
+#else
+ m_threadCountLimit = std::numeric_limits<unsigned>::max();
+#endif
+ }
+
+ WorkQueue& getOrCreateWorkQueueForContext(void* context)
+ {
+ auto addResult = m_workQueueMap.add(context, nullptr);
+ if (addResult.isNewEntry) {
+ // FIXME: This is OK for now, and it works for a single-thread limit. But for configurations where more (but not unlimited)
+ // threads could be used, one option would be to use a HashSet here and disperse the contexts across the available threads.
+ if (m_threadCount >= m_threadCountLimit) {
+ ASSERT(m_sharedWorkQueue);
+ addResult.iterator->value = m_sharedWorkQueue;
+ } else {
+ addResult.iterator->value = WorkQueue::create("org.webkit.ThreadedCompositorWorkQueue");
+ if (!m_threadCount)
+ m_sharedWorkQueue = addResult.iterator->value;
+ m_threadCount++;
+ }
+ }
+
+ return *addResult.iterator->value;
+ }
+
+ HashMap<void*, RefPtr<WorkQueue>> m_workQueueMap;
+ RefPtr<WorkQueue> m_sharedWorkQueue;
+ unsigned m_threadCount { 0 };
+ unsigned m_threadCountLimit;
+};
+
+CompositingRunLoop::CompositingRunLoop(std::function<void ()>&& updateFunction)
+ : m_updateTimer(WorkQueuePool::singleton().runLoop(this), this, &CompositingRunLoop::updateTimerFired)
+ , m_updateFunction(WTFMove(updateFunction))
+{
+#if USE(GLIB_EVENT_LOOP)
+ m_updateTimer.setPriority(G_PRIORITY_HIGH_IDLE);
+#endif
+}
+
+CompositingRunLoop::~CompositingRunLoop()
+{
+ ASSERT(isMainThread());
+ // Make sure the WorkQueue is deleted after the CompositingRunLoop, because m_updateTimer has a reference
+ // of the WorkQueue run loop. Passing this is not a problem because the pointer will only be used as a
+ // HashMap key by WorkQueuePool.
+ RunLoop::main().dispatch([context = this] { WorkQueuePool::singleton().invalidate(context); });
+}
+
+void CompositingRunLoop::performTask(Function<void ()>&& function)
+{
+ ASSERT(isMainThread());
+ WorkQueuePool::singleton().dispatch(this, WTFMove(function));
+}
+
+void CompositingRunLoop::performTaskSync(Function<void ()>&& function)
+{
+ ASSERT(isMainThread());
+ LockHolder locker(m_dispatchSyncConditionMutex);
+ WorkQueuePool::singleton().dispatch(this, [this, function = WTFMove(function)] {
+ function();
+ LockHolder locker(m_dispatchSyncConditionMutex);
+ m_dispatchSyncCondition.notifyOne();
+ });
+ m_dispatchSyncCondition.wait(m_dispatchSyncConditionMutex);
+}
+
+void CompositingRunLoop::startUpdateTimer(UpdateTiming timing)
+{
+ if (m_updateTimer.isActive())
+ return;
+
+ const static double targetFPS = 60;
+ double nextUpdateTime = 0;
+ if (timing == WaitUntilNextFrame)
+ nextUpdateTime = std::max((1 / targetFPS) - (monotonicallyIncreasingTime() - m_lastUpdateTime), 0.0);
+
+ m_updateTimer.startOneShot(nextUpdateTime);
+}
+
+void CompositingRunLoop::stopUpdateTimer()
+{
+ m_updateTimer.stop();
+}
+
+void CompositingRunLoop::updateTimerFired()
+{
+ m_updateFunction();
+ m_lastUpdateTime = monotonicallyIncreasingTime();
+}
+
+} // namespace WebKit
+
+#endif // USE(COORDINATED_GRAPHICS_THREADED)
diff --git a/Source/WebKit2/Shared/WebNetworkInfo.h b/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.h
index ec575d0db..52b5d7d10 100644
--- a/Source/WebKit2/Shared/WebNetworkInfo.h
+++ b/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ * Copyright (C) 2014 Igalia S.L.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -23,48 +23,51 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef WebNetworkInfo_h
-#define WebNetworkInfo_h
+#ifndef CompositingRunLoop_h
+#define CompositingRunLoop_h
-#if ENABLE(NETWORK_INFO)
+#if USE(COORDINATED_GRAPHICS_THREADED)
-#include "APIObject.h"
-#include "ArgumentDecoder.h"
-#include "ArgumentEncoder.h"
-#include <wtf/PassRefPtr.h>
+#include <wtf/Condition.h>
+#include <wtf/FastMalloc.h>
+#include <wtf/Function.h>
+#include <wtf/NeverDestroyed.h>
+#include <wtf/Noncopyable.h>
+#include <wtf/RunLoop.h>
namespace WebKit {
-class WebNetworkInfo : public API::ObjectImpl<API::Object::Type::NetworkInfo> {
+class CompositingRunLoop {
+ WTF_MAKE_NONCOPYABLE(CompositingRunLoop);
+ WTF_MAKE_FAST_ALLOCATED;
public:
- struct Data {
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, Data&);
-
- double bandwidth;
- bool metered;
+ enum UpdateTiming {
+ Immediate,
+ WaitUntilNextFrame,
};
- static PassRefPtr<WebNetworkInfo> create(double bandwidth, bool metered)
- {
- return adoptRef(new WebNetworkInfo(bandwidth, metered));
- }
-
- virtual ~WebNetworkInfo();
+ CompositingRunLoop(std::function<void ()>&&);
+ ~CompositingRunLoop();
- double bandwidth() const { return m_data.bandwidth; }
- bool metered() const { return m_data.metered; }
+ void performTask(Function<void ()>&&);
+ void performTaskSync(Function<void ()>&&);
- const Data& data() const { return m_data; }
+ void startUpdateTimer(UpdateTiming = Immediate);
+ void stopUpdateTimer();
private:
- WebNetworkInfo(double bandwidth, bool metered);
+ void updateTimerFired();
+
+ RunLoop::Timer<CompositingRunLoop> m_updateTimer;
+ std::function<void ()> m_updateFunction;
+ Lock m_dispatchSyncConditionMutex;
+ Condition m_dispatchSyncCondition;
- Data m_data;
+ double m_lastUpdateTime { 0 };
};
} // namespace WebKit
-#endif // ENABLE(NETWORK_INFO)
+#endif // USE(COORDINATED_GRAPHICS_THREADED)
-#endif // WebNetworkInfo_h
+#endif // CompositingRunLoop_h
diff --git a/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadSafeCoordinatedSurface.cpp b/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadSafeCoordinatedSurface.cpp
new file mode 100644
index 000000000..54b7ef96f
--- /dev/null
+++ b/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadSafeCoordinatedSurface.cpp
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ * 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"
+
+#if USE(COORDINATED_GRAPHICS)
+#include "ThreadSafeCoordinatedSurface.h"
+
+#include <WebCore/TextureMapperGL.h>
+#include <wtf/StdLibExtras.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+Ref<ThreadSafeCoordinatedSurface> ThreadSafeCoordinatedSurface::create(const IntSize& size, CoordinatedSurface::Flags flags)
+{
+ // Making an unconditionally unaccelerated buffer here is OK because this code
+ // isn't used by any platforms that respect the accelerated bit.
+ return adoptRef(*new ThreadSafeCoordinatedSurface(size, flags, ImageBuffer::create(size, Unaccelerated)));
+}
+
+ThreadSafeCoordinatedSurface::ThreadSafeCoordinatedSurface(const IntSize& size, CoordinatedSurface::Flags flags, std::unique_ptr<ImageBuffer> buffer)
+ : CoordinatedSurface(size, flags)
+ , m_imageBuffer(WTFMove(buffer))
+{
+}
+
+ThreadSafeCoordinatedSurface::~ThreadSafeCoordinatedSurface()
+{
+}
+
+void ThreadSafeCoordinatedSurface::paintToSurface(const IntRect& rect, CoordinatedSurface::Client& client)
+{
+ GraphicsContext& context = beginPaint(rect);
+ client.paintToSurfaceContext(context);
+ endPaint();
+}
+
+GraphicsContext& ThreadSafeCoordinatedSurface::beginPaint(const IntRect& rect)
+{
+ ASSERT(m_imageBuffer);
+ GraphicsContext& graphicsContext = m_imageBuffer->context();
+ graphicsContext.save();
+ graphicsContext.clip(rect);
+ graphicsContext.translate(rect.x(), rect.y());
+ return graphicsContext;
+}
+
+void ThreadSafeCoordinatedSurface::endPaint()
+{
+ ASSERT(m_imageBuffer);
+ m_imageBuffer->context().restore();
+}
+
+void ThreadSafeCoordinatedSurface::copyToTexture(RefPtr<BitmapTexture> texture, const IntRect& target, const IntPoint& sourceOffset)
+{
+ ASSERT(m_imageBuffer);
+ RefPtr<Image> image = m_imageBuffer->copyImage(DontCopyBackingStore);
+ texture->updateContents(image.get(), target, sourceOffset, BitmapTexture::UpdateCanModifyOriginalImageData);
+}
+
+} // namespace WebCore
+
+#endif // USE(COORDINATED_GRAPHICS)
diff --git a/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadSafeCoordinatedSurface.h b/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadSafeCoordinatedSurface.h
new file mode 100644
index 000000000..f460eaa01
--- /dev/null
+++ b/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadSafeCoordinatedSurface.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ * 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.
+ */
+
+#ifndef ThreadSafeCoordinatedSurface_h
+#define ThreadSafeCoordinatedSurface_h
+
+#if USE(COORDINATED_GRAPHICS)
+#include <WebCore/CoordinatedSurface.h>
+#include <WebCore/ImageBuffer.h>
+
+namespace WebKit {
+
+class ThreadSafeCoordinatedSurface : public WebCore::CoordinatedSurface {
+public:
+ virtual ~ThreadSafeCoordinatedSurface();
+
+ // Create a new ThreadSafeCoordinatedSurface and allocate either a GraphicsSurface or a ImageBuffer as backing.
+ static Ref<ThreadSafeCoordinatedSurface> create(const WebCore::IntSize&, WebCore::CoordinatedSurface::Flags);
+
+ void paintToSurface(const WebCore::IntRect&, WebCore::CoordinatedSurface::Client&) override;
+ void copyToTexture(RefPtr<WebCore::BitmapTexture>, const WebCore::IntRect& target, const WebCore::IntPoint& sourceOffset) override;
+
+private:
+ ThreadSafeCoordinatedSurface(const WebCore::IntSize&, WebCore::CoordinatedSurface::Flags, std::unique_ptr<WebCore::ImageBuffer>);
+
+ WebCore::GraphicsContext& beginPaint(const WebCore::IntRect&);
+ void endPaint();
+
+ std::unique_ptr<WebCore::ImageBuffer> m_imageBuffer;
+};
+
+} // namespace WebKit
+
+#endif // USE(COORDINATED_GRAPHICS)
+
+#endif // ThreadSafeCoordinatedSurface_h
diff --git a/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp b/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp
new file mode 100644
index 000000000..c7ad837c8
--- /dev/null
+++ b/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp
@@ -0,0 +1,222 @@
+/*
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ * 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 "ThreadedCompositor.h"
+
+#if USE(COORDINATED_GRAPHICS_THREADED)
+
+#include "CompositingRunLoop.h"
+#include <WebCore/PlatformDisplay.h>
+#include <WebCore/TransformationMatrix.h>
+
+#if USE(OPENGL_ES_2)
+#include <GLES2/gl2.h>
+#else
+#include <GL/gl.h>
+#endif
+
+using namespace WebCore;
+
+namespace WebKit {
+
+Ref<ThreadedCompositor> ThreadedCompositor::create(Client& client, const IntSize& viewportSize, float scaleFactor, uint64_t nativeSurfaceHandle, ShouldDoFrameSync doFrameSync, TextureMapper::PaintFlags paintFlags)
+{
+ return adoptRef(*new ThreadedCompositor(client, viewportSize, scaleFactor, nativeSurfaceHandle, doFrameSync, paintFlags));
+}
+
+ThreadedCompositor::ThreadedCompositor(Client& client, const IntSize& viewportSize, float scaleFactor, uint64_t nativeSurfaceHandle, ShouldDoFrameSync doFrameSync, TextureMapper::PaintFlags paintFlags)
+ : m_client(client)
+ , m_viewportSize(viewportSize)
+ , m_scaleFactor(scaleFactor)
+ , m_nativeSurfaceHandle(nativeSurfaceHandle)
+ , m_doFrameSync(doFrameSync)
+ , m_paintFlags(paintFlags)
+ , m_needsResize(!viewportSize.isEmpty())
+ , m_compositingRunLoop(std::make_unique<CompositingRunLoop>([this] { renderLayerTree(); }))
+{
+ m_compositingRunLoop->performTaskSync([this, protectedThis = makeRef(*this)] {
+ m_scene = adoptRef(new CoordinatedGraphicsScene(this));
+ if (m_nativeSurfaceHandle) {
+ createGLContext();
+ m_scene->setActive(true);
+ } else
+ m_scene->setActive(false);
+ });
+}
+
+ThreadedCompositor::~ThreadedCompositor()
+{
+}
+
+void ThreadedCompositor::createGLContext()
+{
+ ASSERT(!isMainThread());
+ ASSERT(m_nativeSurfaceHandle);
+
+ m_context = GLContext::createContextForWindow(reinterpret_cast<GLNativeWindowType>(m_nativeSurfaceHandle), &PlatformDisplay::sharedDisplayForCompositing());
+ if (!m_context)
+ return;
+
+ if (m_doFrameSync == ShouldDoFrameSync::No) {
+ if (m_context->makeContextCurrent())
+ m_context->swapInterval(0);
+ }
+}
+
+void ThreadedCompositor::invalidate()
+{
+ m_scene->detach();
+ m_compositingRunLoop->stopUpdateTimer();
+ m_compositingRunLoop->performTaskSync([this, protectedThis = makeRef(*this)] {
+ m_scene->purgeGLResources();
+ m_context = nullptr;
+ m_scene = nullptr;
+ });
+ m_compositingRunLoop = nullptr;
+}
+
+void ThreadedCompositor::setNativeSurfaceHandleForCompositing(uint64_t handle)
+{
+ m_compositingRunLoop->stopUpdateTimer();
+ m_compositingRunLoop->performTaskSync([this, protectedThis = makeRef(*this), handle] {
+ // A new native handle can't be set without destroying the previous one first if any.
+ ASSERT(!!handle ^ !!m_nativeSurfaceHandle);
+ m_nativeSurfaceHandle = handle;
+ if (m_nativeSurfaceHandle) {
+ createGLContext();
+ m_scene->setActive(true);
+ } else {
+ m_scene->setActive(false);
+ m_context = nullptr;
+ }
+ });
+}
+
+void ThreadedCompositor::setScaleFactor(float scale)
+{
+ m_compositingRunLoop->performTask([this, protectedThis = makeRef(*this), scale] {
+ m_scaleFactor = scale;
+ scheduleDisplayImmediately();
+ });
+}
+
+void ThreadedCompositor::setScrollPosition(const IntPoint& scrollPosition, float scale)
+{
+ m_compositingRunLoop->performTask([this, protectedThis = makeRef(*this), scrollPosition, scale] {
+ m_scrollPosition = scrollPosition;
+ m_scaleFactor = scale;
+ scheduleDisplayImmediately();
+ });
+}
+
+void ThreadedCompositor::setViewportSize(const IntSize& viewportSize, float scale)
+{
+ m_compositingRunLoop->performTaskSync([this, protectedThis = makeRef(*this), viewportSize, scale] {
+ m_viewportSize = viewportSize;
+ m_scaleFactor = scale;
+ m_needsResize = true;
+ scheduleDisplayImmediately();
+ });
+}
+
+void ThreadedCompositor::setDrawsBackground(bool drawsBackground)
+{
+ m_compositingRunLoop->performTask([this, protectedThis = Ref<ThreadedCompositor>(*this), drawsBackground] {
+ m_drawsBackground = drawsBackground;
+ scheduleDisplayImmediately();
+ });
+}
+
+void ThreadedCompositor::renderNextFrame()
+{
+ ASSERT(isMainThread());
+ m_client.renderNextFrame();
+}
+
+void ThreadedCompositor::commitScrollOffset(uint32_t layerID, const IntSize& offset)
+{
+ ASSERT(isMainThread());
+ m_client.commitScrollOffset(layerID, offset);
+}
+
+void ThreadedCompositor::updateViewport()
+{
+ m_compositingRunLoop->startUpdateTimer(CompositingRunLoop::WaitUntilNextFrame);
+}
+
+void ThreadedCompositor::scheduleDisplayImmediately()
+{
+ m_compositingRunLoop->startUpdateTimer(CompositingRunLoop::Immediate);
+}
+
+void ThreadedCompositor::forceRepaint()
+{
+ m_compositingRunLoop->performTaskSync([this, protectedThis = makeRef(*this)] {
+ renderLayerTree();
+ });
+}
+
+void ThreadedCompositor::renderLayerTree()
+{
+ if (!m_scene || !m_scene->isActive())
+ return;
+
+ if (!m_context || !m_context->makeContextCurrent())
+ return;
+
+ if (m_needsResize) {
+ glViewport(0, 0, m_viewportSize.width(), m_viewportSize.height());
+ m_needsResize = false;
+ }
+ FloatRect clipRect(0, 0, m_viewportSize.width(), m_viewportSize.height());
+
+ TransformationMatrix viewportTransform;
+ viewportTransform.scale(m_scaleFactor);
+ viewportTransform.translate(-m_scrollPosition.x(), -m_scrollPosition.y());
+
+ if (!m_drawsBackground) {
+ glClearColor(0, 0, 0, 0);
+ glClear(GL_COLOR_BUFFER_BIT);
+ }
+
+ m_scene->paintToCurrentGLContext(viewportTransform, 1, clipRect, Color::transparent, !m_drawsBackground, m_scrollPosition, m_paintFlags);
+
+ m_context->swapBuffers();
+}
+
+void ThreadedCompositor::updateSceneState(const CoordinatedGraphicsState& state)
+{
+ ASSERT(isMainThread());
+ RefPtr<CoordinatedGraphicsScene> scene = m_scene;
+ m_scene->appendUpdate([scene, state] {
+ scene->commitSceneState(state);
+ });
+
+ scheduleDisplayImmediately();
+}
+
+}
+#endif // USE(COORDINATED_GRAPHICS_THREADED)
diff --git a/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h b/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h
new file mode 100644
index 000000000..bac81a396
--- /dev/null
+++ b/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ * 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.
+ */
+
+#ifndef ThreadedCompositor_h
+#define ThreadedCompositor_h
+
+#if USE(COORDINATED_GRAPHICS_THREADED)
+
+#include "CompositingRunLoop.h"
+#include "CoordinatedGraphicsScene.h"
+#include <WebCore/GLContext.h>
+#include <WebCore/IntSize.h>
+#include <WebCore/TextureMapper.h>
+#include <wtf/FastMalloc.h>
+#include <wtf/Noncopyable.h>
+#include <wtf/ThreadSafeRefCounted.h>
+
+namespace WebCore {
+struct CoordinatedGraphicsState;
+}
+
+namespace WebKit {
+
+class CoordinatedGraphicsScene;
+class CoordinatedGraphicsSceneClient;
+
+class ThreadedCompositor : public CoordinatedGraphicsSceneClient, public ThreadSafeRefCounted<ThreadedCompositor> {
+ WTF_MAKE_NONCOPYABLE(ThreadedCompositor);
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ class Client {
+ public:
+ virtual void renderNextFrame() = 0;
+ virtual void commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset) = 0;
+ };
+
+ enum class ShouldDoFrameSync { No, Yes };
+
+ static Ref<ThreadedCompositor> create(Client&, const WebCore::IntSize&, float scaleFactor, uint64_t nativeSurfaceHandle = 0, ShouldDoFrameSync = ShouldDoFrameSync::Yes, WebCore::TextureMapper::PaintFlags = 0);
+ virtual ~ThreadedCompositor();
+
+ void setNativeSurfaceHandleForCompositing(uint64_t);
+ void setScaleFactor(float);
+ void setScrollPosition(const WebCore::IntPoint&, float scale);
+ void setViewportSize(const WebCore::IntSize&, float scale);
+ void setDrawsBackground(bool);
+
+ void updateSceneState(const WebCore::CoordinatedGraphicsState&);
+
+ void invalidate();
+
+ void forceRepaint();
+
+private:
+ ThreadedCompositor(Client&, const WebCore::IntSize&, float scaleFactor, uint64_t nativeSurfaceHandle, ShouldDoFrameSync, WebCore::TextureMapper::PaintFlags);
+
+ // CoordinatedGraphicsSceneClient
+ void renderNextFrame() override;
+ void updateViewport() override;
+ void commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset) override;
+
+ void renderLayerTree();
+ void scheduleDisplayImmediately();
+
+ void createGLContext();
+
+ Client& m_client;
+ RefPtr<CoordinatedGraphicsScene> m_scene;
+ std::unique_ptr<WebCore::GLContext> m_context;
+
+ WebCore::IntSize m_viewportSize;
+ WebCore::IntPoint m_scrollPosition;
+ float m_scaleFactor { 1 };
+ bool m_drawsBackground { true };
+ uint64_t m_nativeSurfaceHandle;
+ ShouldDoFrameSync m_doFrameSync;
+ WebCore::TextureMapper::PaintFlags m_paintFlags { 0 };
+ bool m_needsResize { false };
+
+ std::unique_ptr<CompositingRunLoop> m_compositingRunLoop;
+};
+
+} // namespace WebKit
+
+#endif
+
+#endif // ThreadedCompositor_h
diff --git a/Source/WebKit2/Shared/CoreIPCSupport/WebContextMessageKinds.h b/Source/WebKit2/Shared/CoreIPCSupport/WebContextMessageKinds.h
deleted file mode 100644
index 48958102c..000000000
--- a/Source/WebKit2/Shared/CoreIPCSupport/WebContextMessageKinds.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-
-#ifndef WebContextMessageKinds_h
-#define WebContextMessageKinds_h
-
-// Messages sent from the injected bundle to the WebContext.
-
-#include "StringReference.h"
-
-namespace WebContextLegacyMessages {
-
-inline IPC::StringReference messageReceiverName()
-{
- return IPC::StringReference("WebContextLegacyMessage");
-}
-
-inline IPC::StringReference postMessageMessageName()
-{
- return IPC::StringReference("PostMessage");
-}
-
-inline IPC::StringReference postSynchronousMessageMessageName()
-{
- return IPC::StringReference("PostSynchronousMessage");
-}
-
-} // namespace WebContextLegacyMessages
-
-#endif // InjectedBundleMessageKinds_h
diff --git a/Source/WebKit2/Shared/Databases/DatabaseProcessCreationParameters.cpp b/Source/WebKit2/Shared/Databases/DatabaseProcessCreationParameters.cpp
new file mode 100644
index 000000000..e43320171
--- /dev/null
+++ b/Source/WebKit2/Shared/Databases/DatabaseProcessCreationParameters.cpp
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2013 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.
+ */
+
+#include "config.h"
+#include "DatabaseProcessCreationParameters.h"
+
+#if ENABLE(DATABASE_PROCESS)
+
+#include "ArgumentCoders.h"
+
+namespace WebKit {
+
+DatabaseProcessCreationParameters::DatabaseProcessCreationParameters()
+{
+}
+
+void DatabaseProcessCreationParameters::encode(IPC::Encoder& encoder) const
+{
+#if ENABLE(INDEXED_DATABASE)
+ encoder << indexedDatabaseDirectory;
+ encoder << indexedDatabaseDirectoryExtensionHandle;
+#endif
+}
+
+bool DatabaseProcessCreationParameters::decode(IPC::Decoder& decoder, DatabaseProcessCreationParameters& result)
+{
+#if ENABLE(INDEXED_DATABASE)
+ if (!decoder.decode(result.indexedDatabaseDirectory))
+ return false;
+ if (!decoder.decode(result.indexedDatabaseDirectoryExtensionHandle))
+ return false;
+#endif
+
+ return true;
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(DATABASE_PROCESS)
diff --git a/Source/WebKit2/Shared/Databases/DatabaseProcessCreationParameters.h b/Source/WebKit2/Shared/Databases/DatabaseProcessCreationParameters.h
new file mode 100644
index 000000000..0d450f8b9
--- /dev/null
+++ b/Source/WebKit2/Shared/Databases/DatabaseProcessCreationParameters.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2013 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. ``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
+ * 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.
+ *
+ */
+
+#ifndef DatabaseProcessCreationParameters_h
+#define DatabaseProcessCreationParameters_h
+
+#include "SandboxExtension.h"
+#include <wtf/text/WTFString.h>
+
+#if ENABLE(DATABASE_PROCESS)
+
+namespace IPC {
+class Decoder;
+class Encoder;
+}
+
+namespace WebKit {
+
+struct DatabaseProcessCreationParameters {
+ DatabaseProcessCreationParameters();
+
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, DatabaseProcessCreationParameters&);
+
+#if ENABLE(INDEXED_DATABASE)
+ String indexedDatabaseDirectory;
+ SandboxExtension::Handle indexedDatabaseDirectoryExtensionHandle;
+#endif
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(DATABASE_PROCESS)
+#endif // DatabaseProcessCreationParameters_h
diff --git a/Source/WebKit2/Shared/Databases/IndexedDB/IDBUtilities.cpp b/Source/WebKit2/Shared/Databases/IndexedDB/IDBUtilities.cpp
new file mode 100644
index 000000000..9ec76ff0c
--- /dev/null
+++ b/Source/WebKit2/Shared/Databases/IndexedDB/IDBUtilities.cpp
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2013 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. ``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
+ * 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 "IDBUtilities.h"
+
+#include <WebCore/SecurityOrigin.h>
+#include <wtf/text/StringBuilder.h>
+
+#if ENABLE(INDEXED_DATABASE)
+
+namespace WebKit {
+
+String uniqueDatabaseIdentifier(const String& databaseName, const WebCore::SecurityOrigin& openingOrigin, const WebCore::SecurityOrigin& mainFrameOrigin)
+{
+ StringBuilder stringBuilder;
+
+ String originString = openingOrigin.toString();
+ if (originString == "null")
+ return String();
+ stringBuilder.append(originString);
+ stringBuilder.append('_');
+
+ originString = mainFrameOrigin.toString();
+ if (originString == "null")
+ return String();
+ stringBuilder.append(originString);
+
+ stringBuilder.append('_');
+ stringBuilder.append(databaseName);
+
+ return stringBuilder.toString();
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(INDEXED_DATABASE)
diff --git a/Source/WebKit2/Shared/Databases/IndexedDB/IDBUtilities.h b/Source/WebKit2/Shared/Databases/IndexedDB/IDBUtilities.h
new file mode 100644
index 000000000..f7d4325f0
--- /dev/null
+++ b/Source/WebKit2/Shared/Databases/IndexedDB/IDBUtilities.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2013 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. ``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
+ * 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.
+ *
+ */
+
+#ifndef IDBUtilities_h
+#define IDBUtilities_h
+
+#include <wtf/text/WTFString.h>
+
+#if ENABLE(INDEXED_DATABASE)
+
+namespace WebCore {
+
+class SecurityOrigin;
+
+} // namespace WebCore
+
+namespace WebKit {
+
+String uniqueDatabaseIdentifier(const String& databaseName, const WebCore::SecurityOrigin& openingOrigin, const WebCore::SecurityOrigin& mainFrameOrigin);
+
+} // namespace WebKit
+
+#endif // ENABLE(INDEXED_DATABASE)
+#endif // IDBUtilities_h
diff --git a/Source/WebKit2/Shared/Databases/IndexedDB/WebIDBResult.cpp b/Source/WebKit2/Shared/Databases/IndexedDB/WebIDBResult.cpp
new file mode 100644
index 000000000..706c62eb5
--- /dev/null
+++ b/Source/WebKit2/Shared/Databases/IndexedDB/WebIDBResult.cpp
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#include "config.h"
+#include "WebIDBResult.h"
+
+#if ENABLE(INDEXED_DATABASE)
+
+#include "WebCoreArgumentCoders.h"
+
+namespace WebKit {
+
+void WebIDBResult::encode(IPC::Encoder& encoder) const
+{
+ m_resultData.encode(encoder);
+ m_handles.encode(encoder);
+}
+
+bool WebIDBResult::decode(IPC::Decoder& decoder, WebIDBResult& result)
+{
+ if (!WebCore::IDBResultData::decode(decoder, result.m_resultData))
+ return false;
+
+ if (!SandboxExtension::HandleArray::decode(decoder, result.m_handles))
+ return false;
+
+ return true;
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(INDEXED_DATABASE)
diff --git a/Source/WebKit2/Shared/FileAPI/BlobRegistrationData.h b/Source/WebKit2/Shared/Databases/IndexedDB/WebIDBResult.h
index 71f9c0920..777b8e268 100644
--- a/Source/WebKit2/Shared/FileAPI/BlobRegistrationData.h
+++ b/Source/WebKit2/Shared/Databases/IndexedDB/WebIDBResult.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -23,39 +23,45 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef BlobRegistrationData_h
-#define BlobRegistrationData_h
+#pragma once
-#if ENABLE(BLOB) && ENABLE(NETWORK_PROCESS)
+#if ENABLE(INDEXED_DATABASE)
#include "SandboxExtension.h"
-
-namespace WebCore {
-class BlobData;
-}
+#include <WebCore/IDBResultData.h>
+#include <wtf/Noncopyable.h>
namespace WebKit {
-class BlobRegistrationData {
-WTF_MAKE_NONCOPYABLE(BlobRegistrationData);
+class WebIDBResult {
+ WTF_MAKE_NONCOPYABLE(WebIDBResult);
public:
- BlobRegistrationData();
- BlobRegistrationData(std::unique_ptr<WebCore::BlobData>);
- ~BlobRegistrationData();
+ WebIDBResult()
+ {
+ }
+
+ WebIDBResult(const WebCore::IDBResultData& resultData)
+ : m_resultData(resultData)
+ {
+ }
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, BlobRegistrationData&);
+ WebIDBResult(const WebCore::IDBResultData& resultData, SandboxExtension::HandleArray&& handles)
+ : m_resultData(resultData)
+ , m_handles(WTFMove(handles))
+ {
+ }
- std::unique_ptr<WebCore::BlobData> releaseData() const;
- const SandboxExtension::HandleArray& sandboxExtensions() const { return m_sandboxExtensions; }
+ const WebCore::IDBResultData& resultData() const { return m_resultData; }
+ const SandboxExtension::HandleArray& handles() const { return m_handles; }
+
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, WebIDBResult&);
private:
- mutable std::unique_ptr<WebCore::BlobData> m_data;
- SandboxExtension::HandleArray m_sandboxExtensions;
+ WebCore::IDBResultData m_resultData;
+ SandboxExtension::HandleArray m_handles;
};
-}
-
-#endif // ENABLE(BLOB) && ENABLE(NETWORK_PROCESS)
+} // namespace WebKit
-#endif // BlobRegistrationData_h
+#endif // ENABLE(INDEXED_DATABASE)
diff --git a/Source/WebKit2/Shared/Downloads/Download.cpp b/Source/WebKit2/Shared/Downloads/Download.cpp
deleted file mode 100644
index 77229d73e..000000000
--- a/Source/WebKit2/Shared/Downloads/Download.cpp
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Copyright (C) 2010, 2011 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.
- */
-
-#include "config.h"
-#include "Download.h"
-
-#include "AuthenticationManager.h"
-#include "Connection.h"
-#include "DataReference.h"
-#include "DownloadAuthenticationClient.h"
-#include "DownloadProxyMessages.h"
-#include "DownloadManager.h"
-#include "SandboxExtension.h"
-#include "WebCoreArgumentCoders.h"
-
-using namespace WebCore;
-
-namespace WebKit {
-
-Download::Download(DownloadManager& downloadManager, uint64_t downloadID, const ResourceRequest& request)
- : m_downloadManager(downloadManager)
- , m_downloadID(downloadID)
- , m_request(request)
-#if USE(CFNETWORK)
- , m_allowOverwrite(false)
-#endif
-{
- ASSERT(m_downloadID);
-
- m_downloadManager.didCreateDownload();
-}
-
-Download::~Download()
-{
- platformInvalidate();
-
- m_downloadManager.didDestroyDownload();
-}
-
-void Download::didStart()
-{
- send(Messages::DownloadProxy::DidStart(m_request));
-}
-
-void Download::didReceiveAuthenticationChallenge(const AuthenticationChallenge& authenticationChallenge)
-{
- m_downloadManager.downloadsAuthenticationManager().didReceiveAuthenticationChallenge(this, authenticationChallenge);
-}
-
-void Download::didReceiveResponse(const ResourceResponse& response)
-{
- send(Messages::DownloadProxy::DidReceiveResponse(response));
-}
-
-void Download::didReceiveData(uint64_t length)
-{
- send(Messages::DownloadProxy::DidReceiveData(length));
-}
-
-bool Download::shouldDecodeSourceDataOfMIMEType(const String& mimeType)
-{
- bool result;
- if (!sendSync(Messages::DownloadProxy::ShouldDecodeSourceDataOfMIMEType(mimeType), Messages::DownloadProxy::ShouldDecodeSourceDataOfMIMEType::Reply(result)))
- return true;
-
- return result;
-}
-
-String Download::retrieveDestinationWithSuggestedFilename(const String& filename, bool& allowOverwrite)
-{
- String destination;
- SandboxExtension::Handle sandboxExtensionHandle;
- if (!sendSync(Messages::DownloadProxy::DecideDestinationWithSuggestedFilename(filename), Messages::DownloadProxy::DecideDestinationWithSuggestedFilename::Reply(destination, allowOverwrite, sandboxExtensionHandle)))
- return String();
-
- m_sandboxExtension = SandboxExtension::create(sandboxExtensionHandle);
- if (m_sandboxExtension)
- m_sandboxExtension->consume();
-
- return destination;
-}
-
-String Download::decideDestinationWithSuggestedFilename(const String& filename, bool& allowOverwrite)
-{
- String destination = retrieveDestinationWithSuggestedFilename(filename, allowOverwrite);
-
- didDecideDestination(destination, allowOverwrite);
-
- return destination;
-}
-
-void Download::didCreateDestination(const String& path)
-{
- send(Messages::DownloadProxy::DidCreateDestination(path));
-}
-
-void Download::didFinish()
-{
- platformDidFinish();
-
- send(Messages::DownloadProxy::DidFinish());
-
- if (m_sandboxExtension) {
- m_sandboxExtension->revoke();
- m_sandboxExtension = nullptr;
- }
-
- m_downloadManager.downloadFinished(this);
-}
-
-void Download::didFail(const ResourceError& error, const IPC::DataReference& resumeData)
-{
- send(Messages::DownloadProxy::DidFail(error, resumeData));
-
- if (m_sandboxExtension) {
- m_sandboxExtension->revoke();
- m_sandboxExtension = nullptr;
- }
- m_downloadManager.downloadFinished(this);
-}
-
-void Download::didCancel(const IPC::DataReference& resumeData)
-{
- send(Messages::DownloadProxy::DidCancel(resumeData));
-
- if (m_sandboxExtension) {
- m_sandboxExtension->revoke();
- m_sandboxExtension = nullptr;
- }
- m_downloadManager.downloadFinished(this);
-}
-
-IPC::Connection* Download::messageSenderConnection()
-{
- return m_downloadManager.downloadProxyConnection();
-}
-
-uint64_t Download::messageSenderDestinationID()
-{
- return m_downloadID;
-}
-
-} // namespace WebKit
diff --git a/Source/WebKit2/Shared/Downloads/Download.h b/Source/WebKit2/Shared/Downloads/Download.h
deleted file mode 100644
index d67a04aed..000000000
--- a/Source/WebKit2/Shared/Downloads/Download.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright (C) 2010, 2011 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.
- */
-
-#ifndef Download_h
-#define Download_h
-
-#include "MessageSender.h"
-#include <WebCore/ResourceRequest.h>
-#include <wtf/Noncopyable.h>
-
-#if PLATFORM(MAC)
-#include <wtf/RetainPtr.h>
-
-OBJC_CLASS NSURLDownload;
-OBJC_CLASS WKDownloadAsDelegate;
-#endif
-
-#if PLATFORM(GTK) || PLATFORM(EFL)
-#include <WebCore/ResourceHandle.h>
-#include <WebCore/ResourceHandleClient.h>
-#endif
-
-#if USE(CFNETWORK)
-#include <CFNetwork/CFURLDownloadPriv.h>
-#endif
-
-namespace IPC {
- class DataReference;
-}
-
-namespace WebCore {
- class AuthenticationChallenge;
- class Credential;
- class ResourceError;
- class ResourceHandle;
- class ResourceResponse;
-}
-
-namespace WebKit {
-
-class DownloadAuthenticationClient;
-class DownloadManager;
-class SandboxExtension;
-class WebPage;
-
-class Download : public IPC::MessageSender {
- WTF_MAKE_NONCOPYABLE(Download);
-public:
- Download(DownloadManager&, uint64_t downloadID, const WebCore::ResourceRequest&);
- ~Download();
-
- void start();
- void startWithHandle(WebCore::ResourceHandle*, const WebCore::ResourceResponse&);
- void cancel();
-
- uint64_t downloadID() const { return m_downloadID; }
-
- void didStart();
- void didReceiveAuthenticationChallenge(const WebCore::AuthenticationChallenge&);
- void didReceiveResponse(const WebCore::ResourceResponse&);
- void didReceiveData(uint64_t length);
- bool shouldDecodeSourceDataOfMIMEType(const String& mimeType);
- String decideDestinationWithSuggestedFilename(const String& filename, bool& allowOverwrite);
- void didCreateDestination(const String& path);
- void didFinish();
- void platformDidFinish();
- void didFail(const WebCore::ResourceError&, const IPC::DataReference& resumeData);
- void didCancel(const IPC::DataReference& resumeData);
- void didDecideDestination(const String&, bool allowOverwrite);
-
-#if USE(CFNETWORK)
- const String& destination() const { return m_destination; }
- DownloadAuthenticationClient* authenticationClient();
-#endif
-
- // Authentication
- static void receivedCredential(const WebCore::AuthenticationChallenge&, const WebCore::Credential&);
- static void receivedRequestToContinueWithoutCredential(const WebCore::AuthenticationChallenge&);
- static void receivedCancellation(const WebCore::AuthenticationChallenge&);
-
- void useCredential(const WebCore::AuthenticationChallenge&, const WebCore::Credential&);
- void continueWithoutCredential(const WebCore::AuthenticationChallenge&);
- void cancelAuthenticationChallenge(const WebCore::AuthenticationChallenge&);
-
-private:
- // IPC::MessageSender
- virtual IPC::Connection* messageSenderConnection() override;
- virtual uint64_t messageSenderDestinationID() override;
-
- void platformInvalidate();
-
- String retrieveDestinationWithSuggestedFilename(const String& filename, bool& allowOverwrite);
-
- DownloadManager& m_downloadManager;
- uint64_t m_downloadID;
- WebCore::ResourceRequest m_request;
-
- RefPtr<SandboxExtension> m_sandboxExtension;
-
-#if PLATFORM(MAC)
- RetainPtr<NSURLDownload> m_nsURLDownload;
- RetainPtr<WKDownloadAsDelegate> m_delegate;
-#endif
- bool m_allowOverwrite;
- String m_destination;
- String m_bundlePath;
-#if USE(CFNETWORK)
- RetainPtr<CFURLDownloadRef> m_download;
- RefPtr<DownloadAuthenticationClient> m_authenticationClient;
-#endif
-#if PLATFORM(GTK) || PLATFORM(EFL)
- OwnPtr<WebCore::ResourceHandleClient> m_downloadClient;
- RefPtr<WebCore::ResourceHandle> m_resourceHandle;
-#endif
-};
-
-} // namespace WebKit
-
-#endif // Download_h
diff --git a/Source/WebKit2/Shared/Downloads/DownloadAuthenticationClient.h b/Source/WebKit2/Shared/Downloads/DownloadAuthenticationClient.h
deleted file mode 100644
index 76321ae6d..000000000
--- a/Source/WebKit2/Shared/Downloads/DownloadAuthenticationClient.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#ifndef DownloadAuthenticationClient_h
-#define DownloadAuthenticationClient_h
-
-#include <WebCore/AuthenticationClient.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-
-namespace WebCore {
- class AuthenticationChallenge;
- class Credential;
-}
-
-namespace WebKit {
-
-class Download;
-
-class DownloadAuthenticationClient : public RefCounted<DownloadAuthenticationClient>, public WebCore::AuthenticationClient {
-public:
- static PassRefPtr<DownloadAuthenticationClient> create(Download* download) { return adoptRef(new DownloadAuthenticationClient(download)); }
-
- void detach() { m_download = 0; }
-
- using RefCounted<DownloadAuthenticationClient>::ref;
- using RefCounted<DownloadAuthenticationClient>::deref;
-
-private:
- DownloadAuthenticationClient(Download*);
-
- virtual void receivedCredential(const WebCore::AuthenticationChallenge&, const WebCore::Credential&);
- virtual void receivedRequestToContinueWithoutCredential(const WebCore::AuthenticationChallenge&);
- virtual void receivedCancellation(const WebCore::AuthenticationChallenge&);
-
- virtual void refAuthenticationClient() { ref(); }
- virtual void derefAuthenticationClient() { deref(); }
-
- Download* m_download;
-};
-
-} // namespace WebKit
-
-#endif // DownloadAuthenticationClient_h
diff --git a/Source/WebKit2/Shared/Downloads/DownloadManager.cpp b/Source/WebKit2/Shared/Downloads/DownloadManager.cpp
deleted file mode 100644
index a1d6506eb..000000000
--- a/Source/WebKit2/Shared/Downloads/DownloadManager.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-
-#include "config.h"
-#include "DownloadManager.h"
-
-#include "Download.h"
-#include <wtf/StdLibExtras.h>
-
-using namespace WebCore;
-
-namespace WebKit {
-
-DownloadManager::DownloadManager(Client* client)
- : m_client(client)
-{
-}
-
-void DownloadManager::startDownload(uint64_t downloadID, const ResourceRequest& request)
-{
- auto download = std::make_unique<Download>(*this, downloadID, request);
- download->start();
-
- ASSERT(!m_downloads.contains(downloadID));
- m_downloads.add(downloadID, std::move(download));
-}
-
-void DownloadManager::convertHandleToDownload(uint64_t downloadID, ResourceHandle* handle, const ResourceRequest& request, const ResourceResponse& response)
-{
- auto download = std::make_unique<Download>(*this, downloadID, request);
-
- download->startWithHandle(handle, response);
- ASSERT(!m_downloads.contains(downloadID));
- m_downloads.add(downloadID, std::move(download));
-}
-
-void DownloadManager::cancelDownload(uint64_t downloadID)
-{
- Download* download = m_downloads.get(downloadID);
- if (!download)
- return;
-
- download->cancel();
-}
-
-void DownloadManager::downloadFinished(Download* download)
-{
- ASSERT(m_downloads.contains(download->downloadID()));
- m_downloads.remove(download->downloadID());
-}
-
-void DownloadManager::didCreateDownload()
-{
- m_client->didCreateDownload();
-}
-
-void DownloadManager::didDestroyDownload()
-{
- m_client->didDestroyDownload();
-}
-
-IPC::Connection* DownloadManager::downloadProxyConnection()
-{
- return m_client->downloadProxyConnection();
-}
-
-AuthenticationManager& DownloadManager::downloadsAuthenticationManager()
-{
- return m_client->downloadsAuthenticationManager();
-}
-
-} // namespace WebKit
diff --git a/Source/WebKit2/Shared/Downloads/DownloadManager.h b/Source/WebKit2/Shared/Downloads/DownloadManager.h
deleted file mode 100644
index 2a1694e92..000000000
--- a/Source/WebKit2/Shared/Downloads/DownloadManager.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-
-#ifndef DownloadManager_h
-#define DownloadManager_h
-
-#include <wtf/Forward.h>
-#include <wtf/HashMap.h>
-#include <wtf/Noncopyable.h>
-
-namespace WebCore {
-class ResourceHandle;
-class ResourceRequest;
-class ResourceResponse;
-}
-
-namespace IPC {
-class Connection;
-}
-
-namespace WebKit {
-
-class AuthenticationManager;
-class Download;
-class WebPage;
-
-class DownloadManager {
- WTF_MAKE_NONCOPYABLE(DownloadManager);
-
-public:
- class Client {
- public:
- virtual ~Client() { }
-
- virtual void didCreateDownload() = 0;
- virtual void didDestroyDownload() = 0;
- virtual IPC::Connection* downloadProxyConnection() = 0;
- virtual AuthenticationManager& downloadsAuthenticationManager() = 0;
- };
-
- explicit DownloadManager(Client*);
-
- void startDownload(uint64_t downloadID, const WebCore::ResourceRequest&);
- void convertHandleToDownload(uint64_t downloadID, WebCore::ResourceHandle*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&);
-
- void cancelDownload(uint64_t downloadID);
-
- void downloadFinished(Download*);
- bool isDownloading() const { return !m_downloads.isEmpty(); }
- uint64_t activeDownloadCount() const { return m_downloads.size(); }
-
- void didCreateDownload();
- void didDestroyDownload();
-
- IPC::Connection* downloadProxyConnection();
- AuthenticationManager& downloadsAuthenticationManager();
-
-private:
- Client* m_client;
- HashMap<uint64_t, std::unique_ptr<Download>> m_downloads;
-};
-
-} // namespace WebKit
-
-#endif // DownloadManager_h
diff --git a/Source/WebKit2/Shared/Downloads/soup/DownloadSoup.cpp b/Source/WebKit2/Shared/Downloads/soup/DownloadSoup.cpp
deleted file mode 100644
index 1c44dd7d4..000000000
--- a/Source/WebKit2/Shared/Downloads/soup/DownloadSoup.cpp
+++ /dev/null
@@ -1,310 +0,0 @@
-/*
- * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
- * Copyright (C) 2010 Brent Fulgham <bfulgham@webkit.org>
- *
- * 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 "Download.h"
-
-#include "DataReference.h"
-#include "DownloadSoupErrors.h"
-#include <WebCore/NotImplemented.h>
-#include <WebCore/ResourceHandleInternal.h>
-#include <gio/gio.h>
-#include <wtf/gobject/GRefPtr.h>
-#include <wtf/gobject/GUniquePtr.h>
-#include <wtf/text/CString.h>
-
-#if PLATFORM(GTK)
-#include <glib/gi18n-lib.h>
-#endif
-
-using namespace WebCore;
-
-namespace WebKit {
-
-class DownloadClient : public ResourceHandleClient {
- WTF_MAKE_NONCOPYABLE(DownloadClient);
-public:
- DownloadClient(Download* download)
- : m_download(download)
- , m_handleResponseLaterID(0)
- , m_allowOverwrite(false)
- {
- }
-
- ~DownloadClient()
- {
- if (m_handleResponseLaterID)
- g_source_remove(m_handleResponseLaterID);
- }
-
- void deleteFilesIfNeeded()
- {
- if (m_destinationFile)
- g_file_delete(m_destinationFile.get(), nullptr, nullptr);
-
- if (m_intermediateFile) {
- ASSERT(m_destinationFile);
- g_file_delete(m_intermediateFile.get(), nullptr, nullptr);
- }
- }
-
- void downloadFailed(const ResourceError& error)
- {
- deleteFilesIfNeeded();
- m_download->didFail(error, IPC::DataReference());
- }
-
- void didReceiveResponse(ResourceHandle*, const ResourceResponse& response)
- {
- m_response = response;
- m_download->didReceiveResponse(response);
-
- if (response.httpStatusCode() >= 400) {
- downloadFailed(platformDownloadNetworkError(response.httpStatusCode(), response.url().string(), response.httpStatusText()));
- return;
- }
-
- String suggestedFilename = response.suggestedFilename();
- if (suggestedFilename.isEmpty()) {
- URL url = response.url();
- url.setQuery(String());
- url.removeFragmentIdentifier();
- suggestedFilename = decodeURLEscapeSequences(url.lastPathComponent());
- }
-
- String destinationURI = m_download->decideDestinationWithSuggestedFilename(suggestedFilename, m_allowOverwrite);
- if (destinationURI.isEmpty()) {
-#if PLATFORM(GTK)
- GUniquePtr<char> buffer(g_strdup_printf(_("Cannot determine destination URI for download with suggested filename %s"), suggestedFilename.utf8().data()));
- String errorMessage = String::fromUTF8(buffer.get());
-#else
- String errorMessage = makeString("Cannot determine destination URI for download with suggested filename ", suggestedFilename);
-#endif
- downloadFailed(platformDownloadDestinationError(response, errorMessage));
- return;
- }
-
- m_destinationFile = adoptGRef(g_file_new_for_uri(destinationURI.utf8().data()));
- GRefPtr<GFileOutputStream> outputStream;
- GUniqueOutPtr<GError> error;
- if (m_allowOverwrite)
- outputStream = adoptGRef(g_file_replace(m_destinationFile.get(), nullptr, FALSE, G_FILE_CREATE_NONE, nullptr, &error.outPtr()));
- else
- outputStream = adoptGRef(g_file_create(m_destinationFile.get(), G_FILE_CREATE_NONE, nullptr, &error.outPtr()));
- if (!outputStream) {
- m_destinationFile.clear();
- downloadFailed(platformDownloadDestinationError(response, error->message));
- return;
- }
-
- String intermediateURI = destinationURI + ".wkdownload";
- m_intermediateFile = adoptGRef(g_file_new_for_uri(intermediateURI.utf8().data()));
- m_outputStream = adoptGRef(g_file_replace(m_intermediateFile.get(), 0, TRUE, G_FILE_CREATE_NONE, 0, &error.outPtr()));
- if (!m_outputStream) {
- downloadFailed(platformDownloadDestinationError(response, error->message));
- return;
- }
-
- m_download->didCreateDestination(destinationURI);
- }
-
- void didReceiveData(ResourceHandle*, const char* data, unsigned length, int /*encodedDataLength*/)
- {
- if (m_handleResponseLaterID) {
- g_source_remove(m_handleResponseLaterID);
- handleResponse();
- }
-
- gsize bytesWritten;
- GUniqueOutPtr<GError> error;
- g_output_stream_write_all(G_OUTPUT_STREAM(m_outputStream.get()), data, length, &bytesWritten, 0, &error.outPtr());
- if (error) {
- downloadFailed(platformDownloadDestinationError(m_response, error->message));
- return;
- }
- m_download->didReceiveData(bytesWritten);
- }
-
- void didFinishLoading(ResourceHandle*, double)
- {
- m_outputStream = 0;
-
- ASSERT(m_destinationFile);
- ASSERT(m_intermediateFile);
- GUniqueOutPtr<GError> error;
- if (!g_file_move(m_intermediateFile.get(), m_destinationFile.get(), G_FILE_COPY_OVERWRITE, nullptr, nullptr, nullptr, &error.outPtr())) {
- downloadFailed(platformDownloadDestinationError(m_response, error->message));
- return;
- }
-
- GRefPtr<GFileInfo> info = adoptGRef(g_file_info_new());
- CString uri = m_response.url().string().utf8();
- g_file_info_set_attribute_string(info.get(), "metadata::download-uri", uri.data());
- g_file_info_set_attribute_string(info.get(), "xattr::xdg.origin.url", uri.data());
- g_file_set_attributes_async(m_destinationFile.get(), info.get(), G_FILE_QUERY_INFO_NONE, G_PRIORITY_DEFAULT, nullptr, nullptr, nullptr);
-
- m_download->didFinish();
- }
-
- void didFail(ResourceHandle*, const ResourceError& error)
- {
- downloadFailed(platformDownloadNetworkError(error.errorCode(), error.failingURL(), error.localizedDescription()));
- }
-
- void wasBlocked(ResourceHandle*)
- {
- notImplemented();
- }
-
- void cannotShowURL(ResourceHandle*)
- {
- notImplemented();
- }
-
- void cancel(ResourceHandle* handle)
- {
- handle->cancel();
- deleteFilesIfNeeded();
- m_download->didCancel(IPC::DataReference());
- }
-
- void handleResponse()
- {
- m_handleResponseLaterID = 0;
- didReceiveResponse(0, m_delayedResponse);
- }
-
- static gboolean handleResponseLaterCallback(DownloadClient* downloadClient)
- {
- downloadClient->handleResponse();
- return FALSE;
- }
-
- void handleResponseLater(const ResourceResponse& response)
- {
- ASSERT(m_response.isNull());
- ASSERT(!m_handleResponseLaterID);
-
- m_delayedResponse = response;
-
- // Call didReceiveResponse in an idle to make sure the download is added
- // to the DownloadManager downloads map.
- m_handleResponseLaterID = g_idle_add_full(G_PRIORITY_DEFAULT, reinterpret_cast<GSourceFunc>(handleResponseLaterCallback), this, 0);
- }
-
- Download* m_download;
- GRefPtr<GFileOutputStream> m_outputStream;
- ResourceResponse m_response;
- GRefPtr<GFile> m_destinationFile;
- GRefPtr<GFile> m_intermediateFile;
- ResourceResponse m_delayedResponse;
- unsigned m_handleResponseLaterID;
- bool m_allowOverwrite;
-};
-
-void Download::start()
-{
- ASSERT(!m_downloadClient);
- ASSERT(!m_resourceHandle);
- m_downloadClient = adoptPtr(new DownloadClient(this));
- m_resourceHandle = ResourceHandle::create(0, m_request, m_downloadClient.get(), false, false);
- didStart();
-}
-
-void Download::startWithHandle(ResourceHandle* resourceHandle, const ResourceResponse& response)
-{
- ASSERT(!m_downloadClient);
- ASSERT(!m_resourceHandle);
- m_downloadClient = adoptPtr(new DownloadClient(this));
- resourceHandle->setClient(m_downloadClient.get());
- m_resourceHandle = resourceHandle;
- didStart();
- static_cast<DownloadClient*>(m_downloadClient.get())->handleResponseLater(response);
-}
-
-void Download::cancel()
-{
- if (!m_resourceHandle)
- return;
-
- // Cancelling the download will delete it and platformInvalidate() will be called by the destructor.
- // So, we need to set m_resourceHandle to nullptr before actually cancelling the download to make sure
- // it won't be cancelled again by platformInvalidate. See https://bugs.webkit.org/show_bug.cgi?id=127650.
- RefPtr<ResourceHandle> resourceHandle = m_resourceHandle.release();
- static_cast<DownloadClient*>(m_downloadClient.get())->cancel(resourceHandle.get());
-}
-
-void Download::platformInvalidate()
-{
- if (m_resourceHandle) {
- m_resourceHandle->setClient(0);
- m_resourceHandle->cancel();
- m_resourceHandle = 0;
- }
- m_downloadClient.release();
-}
-
-void Download::didDecideDestination(const String& /*destination*/, bool /*allowOverwrite*/)
-{
- notImplemented();
-}
-
-void Download::platformDidFinish()
-{
- m_resourceHandle = 0;
-}
-
-void Download::receivedCredential(const AuthenticationChallenge&, const Credential&)
-{
- notImplemented();
-}
-
-void Download::receivedRequestToContinueWithoutCredential(const AuthenticationChallenge&)
-{
- notImplemented();
-}
-
-void Download::receivedCancellation(const AuthenticationChallenge&)
-{
- notImplemented();
-}
-
-void Download::continueWithoutCredential(const AuthenticationChallenge &)
-{
- notImplemented();
-}
-
-void Download::useCredential(const AuthenticationChallenge&, const Credential&)
-{
- notImplemented();
-}
-
-void Download::cancelAuthenticationChallenge(const AuthenticationChallenge&)
-{
- notImplemented();
-}
-
-} // namespace WebKit
diff --git a/Source/WebKit2/Shared/DragControllerAction.h b/Source/WebKit2/Shared/DragControllerAction.h
index b37e8113b..90970c158 100644
--- a/Source/WebKit2/Shared/DragControllerAction.h
+++ b/Source/WebKit2/Shared/DragControllerAction.h
@@ -32,7 +32,7 @@ enum DragControllerAction {
DragControllerActionEntered,
DragControllerActionUpdated,
DragControllerActionExited,
- DragControllerActionPerformDrag
+ DragControllerActionPerformDragOperation
};
} // namespace WebKit
diff --git a/Source/WebKit2/Shared/DrawingAreaInfo.h b/Source/WebKit2/Shared/DrawingAreaInfo.h
index 16a3bd519..7fc4d7c4b 100644
--- a/Source/WebKit2/Shared/DrawingAreaInfo.h
+++ b/Source/WebKit2/Shared/DrawingAreaInfo.h
@@ -29,17 +29,13 @@
namespace WebKit {
enum DrawingAreaType {
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
#if !PLATFORM(IOS)
DrawingAreaTypeTiledCoreAnimation,
#endif
DrawingAreaTypeRemoteLayerTree,
#else
-#if USE(COORDINATED_GRAPHICS)
- DrawingAreaTypeCoordinated
-#else
- DrawingAreaTypeImpl,
-#endif
+ DrawingAreaTypeImpl
#endif
};
diff --git a/Source/WebKit2/Shared/EditingRange.h b/Source/WebKit2/Shared/EditingRange.h
new file mode 100644
index 000000000..485415c6c
--- /dev/null
+++ b/Source/WebKit2/Shared/EditingRange.h
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+#ifndef EditingRange_h
+#define EditingRange_h
+
+#include "ArgumentCoders.h"
+
+namespace WebKit {
+
+enum class EditingRangeIsRelativeTo : uint8_t {
+ EditableRoot,
+ Paragraph,
+};
+
+struct EditingRange {
+ EditingRange()
+ : location(notFound)
+ , length(0)
+ {
+ }
+
+ EditingRange(uint64_t location, uint64_t length)
+ : location(location)
+ , length(length)
+ {
+ }
+
+ // (notFound, 0) is notably valid.
+ bool isValid() const { return location + length >= location; }
+
+#if defined(__OBJC__)
+ EditingRange(NSRange range)
+ {
+ if (range.location != NSNotFound) {
+ location = range.location;
+ length = range.length;
+ } else {
+ location = notFound;
+ length = 0;
+ }
+ }
+
+ operator NSRange() const
+ {
+ if (location == notFound)
+ return NSMakeRange(NSNotFound, 0);
+ return NSMakeRange(location, length);
+ }
+#endif
+
+ uint64_t location;
+ uint64_t length;
+};
+
+}
+
+namespace IPC {
+template<> struct ArgumentCoder<WebKit::EditingRange> : SimpleArgumentCoder<WebKit::EditingRange> { };
+}
+
+#endif // EditingRange_h
diff --git a/Source/WebKit2/Shared/EditorState.cpp b/Source/WebKit2/Shared/EditorState.cpp
index 3593d7b99..ae7ede905 100644
--- a/Source/WebKit2/Shared/EditorState.cpp
+++ b/Source/WebKit2/Shared/EditorState.cpp
@@ -26,16 +26,11 @@
#include "config.h"
#include "EditorState.h"
-#include "Arguments.h"
#include "WebCoreArgumentCoders.h"
-#if PLATFORM(IOS)
-#include <WebCore/SelectionRect.h>
-#endif
-
namespace WebKit {
-void EditorState::encode(IPC::ArgumentEncoder& encoder) const
+void EditorState::encode(IPC::Encoder& encoder) const
{
encoder << shouldIgnoreCompositionSelectionChange;
encoder << selectionIsNone;
@@ -45,24 +40,21 @@ void EditorState::encode(IPC::ArgumentEncoder& encoder) const
encoder << isInPasswordField;
encoder << isInPlugin;
encoder << hasComposition;
+ encoder << isMissingPostLayoutData;
+
+#if PLATFORM(IOS) || PLATFORM(GTK) || PLATFORM(MAC)
+ if (!isMissingPostLayoutData)
+ m_postLayoutData.encode(encoder);
+#endif
#if PLATFORM(IOS)
- encoder << caretRectAtStart;
- encoder << caretRectAtEnd;
- encoder << selectionRects;
- encoder << selectedTextLength;
- encoder << wordAtSelection;
encoder << firstMarkedRect;
encoder << lastMarkedRect;
encoder << markedText;
#endif
-
-#if PLATFORM(GTK)
- encoder << cursorRect;
-#endif
}
-bool EditorState::decode(IPC::ArgumentDecoder& decoder, EditorState& result)
+bool EditorState::decode(IPC::Decoder& decoder, EditorState& result)
{
if (!decoder.decode(result.shouldIgnoreCompositionSelectionChange))
return false;
@@ -88,31 +80,116 @@ bool EditorState::decode(IPC::ArgumentDecoder& decoder, EditorState& result)
if (!decoder.decode(result.hasComposition))
return false;
+ if (!decoder.decode(result.isMissingPostLayoutData))
+ return false;
+
+#if PLATFORM(IOS) || PLATFORM(GTK) || PLATFORM(MAC)
+ if (!result.isMissingPostLayoutData) {
+ if (!PostLayoutData::decode(decoder, result.postLayoutData()))
+ return false;
+ }
+#endif
+
#if PLATFORM(IOS)
+ if (!decoder.decode(result.firstMarkedRect))
+ return false;
+ if (!decoder.decode(result.lastMarkedRect))
+ return false;
+ if (!decoder.decode(result.markedText))
+ return false;
+#endif
+
+ return true;
+}
+
+#if PLATFORM(IOS) || PLATFORM(GTK) || PLATFORM(MAC)
+void EditorState::PostLayoutData::encode(IPC::Encoder& encoder) const
+{
+ encoder << typingAttributes;
+#if PLATFORM(IOS) || PLATFORM(GTK)
+ encoder << caretRectAtStart;
+#endif
+#if PLATFORM(IOS) || PLATFORM(MAC)
+ encoder << selectionClipRect;
+ encoder << selectedTextLength;
+ encoder << textAlignment;
+ encoder << textColor;
+ encoder << enclosingListType;
+#endif
+#if PLATFORM(IOS)
+ encoder << caretRectAtEnd;
+ encoder << selectionRects;
+ encoder << wordAtSelection;
+ encoder << characterAfterSelection;
+ encoder << characterBeforeSelection;
+ encoder << twoCharacterBeforeSelection;
+ encoder << isReplaceAllowed;
+ encoder << hasContent;
+ encoder << isStableStateUpdate;
+ encoder << insideFixedPosition;
+#endif
+#if PLATFORM(MAC)
+ encoder << candidateRequestStartPosition;
+ encoder << paragraphContextForCandidateRequest;
+ encoder << stringForCandidateRequest;
+#endif
+}
+
+bool EditorState::PostLayoutData::decode(IPC::Decoder& decoder, PostLayoutData& result)
+{
+ if (!decoder.decode(result.typingAttributes))
+ return false;
+#if PLATFORM(IOS) || PLATFORM(GTK)
if (!decoder.decode(result.caretRectAtStart))
return false;
+#endif
+#if PLATFORM(IOS) || PLATFORM(MAC)
+ if (!decoder.decode(result.selectionClipRect))
+ return false;
+ if (!decoder.decode(result.selectedTextLength))
+ return false;
+ if (!decoder.decode(result.textAlignment))
+ return false;
+ if (!decoder.decode(result.textColor))
+ return false;
+ if (!decoder.decode(result.enclosingListType))
+ return false;
+#endif
+#if PLATFORM(IOS)
if (!decoder.decode(result.caretRectAtEnd))
return false;
if (!decoder.decode(result.selectionRects))
return false;
- if (!decoder.decode(result.selectedTextLength))
- return false;
if (!decoder.decode(result.wordAtSelection))
return false;
- if (!decoder.decode(result.firstMarkedRect))
+ if (!decoder.decode(result.characterAfterSelection))
return false;
- if (!decoder.decode(result.lastMarkedRect))
+ if (!decoder.decode(result.characterBeforeSelection))
return false;
- if (!decoder.decode(result.markedText))
+ if (!decoder.decode(result.twoCharacterBeforeSelection))
+ return false;
+ if (!decoder.decode(result.isReplaceAllowed))
+ return false;
+ if (!decoder.decode(result.hasContent))
+ return false;
+ if (!decoder.decode(result.isStableStateUpdate))
+ return false;
+ if (!decoder.decode(result.insideFixedPosition))
return false;
#endif
+#if PLATFORM(MAC)
+ if (!decoder.decode(result.candidateRequestStartPosition))
+ return false;
+
+ if (!decoder.decode(result.paragraphContextForCandidateRequest))
+ return false;
-#if PLATFORM(GTK)
- if (!decoder.decode(result.cursorRect))
+ if (!decoder.decode(result.stringForCandidateRequest))
return false;
#endif
return true;
}
+#endif // PLATFORM(IOS) || PLATFORM(GTK) || PLATFORM(MAC)
}
diff --git a/Source/WebKit2/Shared/EditorState.h b/Source/WebKit2/Shared/EditorState.h
index 61b501429..3dd039ad8 100644
--- a/Source/WebKit2/Shared/EditorState.h
+++ b/Source/WebKit2/Shared/EditorState.h
@@ -27,6 +27,7 @@
#define EditorState_h
#include "ArgumentCoders.h"
+#include <WebCore/Color.h>
#include <WebCore/IntRect.h>
#include <wtf/text/WTFString.h>
@@ -36,51 +37,108 @@
namespace WebKit {
-struct EditorState {
- EditorState()
- : shouldIgnoreCompositionSelectionChange(false)
- , selectionIsNone(true)
- , selectionIsRange(false)
- , isContentEditable(false)
- , isContentRichlyEditable(false)
- , isInPasswordField(false)
- , isInPlugin(false)
- , hasComposition(false)
-#if PLATFORM(IOS)
- , selectedTextLength(0)
-#endif
- {
- }
+enum TypingAttributes {
+ AttributeNone = 0,
+ AttributeBold = 1,
+ AttributeItalics = 2,
+ AttributeUnderline = 4,
+ AttributeStrikeThrough = 8
+};
- bool shouldIgnoreCompositionSelectionChange;
+enum TextAlignment {
+ NoAlignment = 0,
+ LeftAlignment = 1,
+ RightAlignment = 2,
+ CenterAlignment = 3,
+ JustifiedAlignment = 4,
+};
- bool selectionIsNone; // This will be false when there is a caret selection.
- bool selectionIsRange;
- bool isContentEditable;
- bool isContentRichlyEditable;
- bool isInPasswordField;
- bool isInPlugin;
- bool hasComposition;
+enum ListType {
+ NoList = 0,
+ OrderedList,
+ UnorderedList
+};
+
+struct EditorState {
+ bool shouldIgnoreCompositionSelectionChange { false };
+
+ bool selectionIsNone { true }; // This will be false when there is a caret selection.
+ bool selectionIsRange { false };
+ bool isContentEditable { false };
+ bool isContentRichlyEditable { false };
+ bool isInPasswordField { false };
+ bool isInPlugin { false };
+ bool hasComposition { false };
+ bool isMissingPostLayoutData { false };
#if PLATFORM(IOS)
- WebCore::IntRect caretRectAtStart;
- WebCore::IntRect caretRectAtEnd;
- Vector<WebCore::SelectionRect> selectionRects;
- uint64_t selectedTextLength;
- String wordAtSelection;
WebCore::IntRect firstMarkedRect;
WebCore::IntRect lastMarkedRect;
String markedText;
#endif
-#if PLATFORM(GTK)
- WebCore::IntRect cursorRect;
+#if PLATFORM(IOS) || PLATFORM(GTK) || PLATFORM(MAC)
+ struct PostLayoutData {
+ uint32_t typingAttributes { AttributeNone };
+#if PLATFORM(IOS) || PLATFORM(GTK)
+ WebCore::IntRect caretRectAtStart;
+#endif
+#if PLATFORM(IOS) || PLATFORM(MAC)
+ WebCore::IntRect selectionClipRect;
+ uint64_t selectedTextLength { 0 };
+ uint32_t textAlignment { NoAlignment };
+ WebCore::Color textColor { WebCore::Color::black };
+ uint32_t enclosingListType { NoList };
+#endif
+#if PLATFORM(IOS)
+ WebCore::IntRect caretRectAtEnd;
+ Vector<WebCore::SelectionRect> selectionRects;
+ String wordAtSelection;
+ UChar32 characterAfterSelection { 0 };
+ UChar32 characterBeforeSelection { 0 };
+ UChar32 twoCharacterBeforeSelection { 0 };
+ bool isReplaceAllowed { false };
+ bool hasContent { false };
+ bool isStableStateUpdate { false };
+ bool insideFixedPosition { false };
+#endif
+#if PLATFORM(MAC)
+ uint64_t candidateRequestStartPosition { 0 };
+ String paragraphContextForCandidateRequest;
+ String stringForCandidateRequest;
#endif
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, EditorState&);
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, PostLayoutData&);
+ };
+
+ const PostLayoutData& postLayoutData() const;
+ PostLayoutData& postLayoutData();
+#endif // PLATFORM(IOS) || PLATFORM(GTK) || PLATFORM(MAC)
+
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, EditorState&);
+
+#if PLATFORM(IOS) || PLATFORM(GTK) || PLATFORM(MAC)
+private:
+ PostLayoutData m_postLayoutData;
+#endif
};
+#if PLATFORM(IOS) || PLATFORM(GTK) || PLATFORM(MAC)
+inline auto EditorState::postLayoutData() -> PostLayoutData&
+{
+ ASSERT_WITH_MESSAGE(!isMissingPostLayoutData, "Attempt to access post layout data before receiving it");
+ return m_postLayoutData;
+}
+
+inline auto EditorState::postLayoutData() const -> const PostLayoutData&
+{
+ ASSERT_WITH_MESSAGE(!isMissingPostLayoutData, "Attempt to access post layout data before receiving it");
+ return m_postLayoutData;
+}
+#endif
+
}
#endif // EditorState_h
diff --git a/Source/WebKit2/Shared/FileAPI/BlobRegistrationData.cpp b/Source/WebKit2/Shared/FileAPI/BlobRegistrationData.cpp
deleted file mode 100644
index 24939a964..000000000
--- a/Source/WebKit2/Shared/FileAPI/BlobRegistrationData.cpp
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Copyright (C) 2013 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.
- */
-
-#include "config.h"
-#include "BlobRegistrationData.h"
-
-#if ENABLE(BLOB) && ENABLE(NETWORK_PROCESS)
-
-#include "ArgumentCoders.h"
-#include "DataReference.h"
-#include "WebCoreArgumentCoders.h"
-#include <WebCore/BlobData.h>
-
-using namespace WebCore;
-
-namespace WebKit {
-
-BlobRegistrationData::BlobRegistrationData()
-{
-}
-
-BlobRegistrationData::BlobRegistrationData(std::unique_ptr<BlobData> data)
- : m_data(std::move(data))
-{
- const BlobDataItemList& items = m_data->items();
- size_t fileCount = 0;
- for (size_t i = 0, count = items.size(); i < count; ++i) {
- // File path can be empty when submitting a form file input without a file, see bug 111778.
- if (items[i].type == BlobDataItem::File && !items[i].path.isEmpty())
- ++fileCount;
- }
-
- m_sandboxExtensions.allocate(fileCount);
- size_t extensionIndex = 0;
- for (size_t i = 0, count = items.size(); i < count; ++i) {
- const BlobDataItem& item = items[i];
- if (item.type == BlobDataItem::File && !items[i].path.isEmpty())
- SandboxExtension::createHandle(item.path, SandboxExtension::ReadOnly, m_sandboxExtensions[extensionIndex++]);
- }
-}
-
-BlobRegistrationData::~BlobRegistrationData()
-{
-}
-
-std::unique_ptr<BlobData> BlobRegistrationData::releaseData() const
-{
- return std::move(m_data);
-}
-
-void BlobRegistrationData::encode(IPC::ArgumentEncoder& encoder) const
-{
- encoder << m_data->contentType();
- encoder << m_data->contentDisposition();
-
- const BlobDataItemList& items = m_data->items();
- encoder << static_cast<uint64_t>(items.size());
- for (size_t i = 0, count = items.size(); i < count; ++i) {
- const BlobDataItem& item = items[i];
- encoder << static_cast<uint32_t>(item.type);
- switch (item.type) {
- case BlobDataItem::Data:
- // There is no way to create a partial data item.
- ASSERT(!item.offset);
- ASSERT(item.length == BlobDataItem::toEndOfFile);
- encoder << IPC::DataReference(reinterpret_cast<const uint8_t*>(item.data->data()), item.data->length());
- break;
- case BlobDataItem::File:
- encoder << static_cast<int64_t>(item.offset);
- encoder << static_cast<int64_t>(item.length);
- encoder << item.expectedModificationTime;
- encoder << item.path;
- break;
- case BlobDataItem::Blob:
- encoder << static_cast<int64_t>(item.offset);
- encoder << static_cast<int64_t>(item.length);
- encoder << item.url;
- break;
- }
- }
-
- encoder << m_sandboxExtensions;
-}
-
-bool BlobRegistrationData::decode(IPC::ArgumentDecoder& decoder, BlobRegistrationData& result)
-{
- ASSERT(!result.m_data);
- result.m_data = std::make_unique<BlobData>();
-
- String contentType;
- if (!decoder.decode(contentType))
- return false;
- result.m_data->setContentType(contentType);
-
- String contentDisposition;
- if (!decoder.decode(contentDisposition))
- return false;
- result.m_data->setContentDisposition(contentDisposition);
-
- uint64_t itemCount;
- if (!decoder.decode(itemCount))
- return false;
-
- for (uint64_t i = 0; i < itemCount; ++i) {
- uint32_t type;
- if (!decoder.decode(type))
- return false;
- switch (type) {
- case BlobDataItem::Data: {
- IPC::DataReference data;
- if (!decoder.decode(data))
- return false;
- RefPtr<RawData> rawData = RawData::create();
- rawData->mutableData()->append(data.data(), data.size());
- result.m_data->appendData(rawData.release(), 0, BlobDataItem::toEndOfFile);
- break;
- }
- case BlobDataItem::File: {
- int64_t offset;
- if (!decoder.decode(offset))
- return false;
- int64_t length;
- if (!decoder.decode(length))
- return false;
- double expectedModificationTime;
- if (!decoder.decode(expectedModificationTime))
- return false;
- String path;
- if (!decoder.decode(path))
- return false;
- result.m_data->appendFile(path, offset, length, expectedModificationTime);
- break;
- }
- case BlobDataItem::Blob: {
- int64_t offset;
- if (!decoder.decode(offset))
- return false;
- int64_t length;
- if (!decoder.decode(length))
- return false;
- String url;
- if (!decoder.decode(url))
- return false;
- result.m_data->appendBlob(URL(URL(), url), offset, length);
- break;
- }
- default:
- return false;
- }
- }
-
- if (!decoder.decode(result.m_sandboxExtensions))
- return false;
-
- return true;
-}
-
-}
-
-#endif // ENABLE(BLOB) && ENABLE(NETWORK_PROCESS)
diff --git a/Source/WebKit2/Shared/OriginAndDatabases.cpp b/Source/WebKit2/Shared/FontInfo.cpp
index 94f49b8d9..2eb9af437 100644
--- a/Source/WebKit2/Shared/OriginAndDatabases.cpp
+++ b/Source/WebKit2/Shared/FontInfo.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -24,38 +24,45 @@
*/
#include "config.h"
-#include "OriginAndDatabases.h"
-
-#if ENABLE(SQL_DATABASE)
+#include "FontInfo.h"
#include "WebCoreArgumentCoders.h"
-using namespace WebCore;
+#if PLATFORM(COCOA)
+#include "ArgumentCodersCF.h"
+#endif
namespace WebKit {
-void OriginAndDatabases::encode(IPC::ArgumentEncoder& encoder) const
+void FontInfo::encode(IPC::Encoder& encoder) const
{
- encoder << originIdentifier;
- encoder << originQuota;
- encoder << originUsage;
- encoder << databases;
+#if PLATFORM(COCOA)
+ encoder << static_cast<bool>(fontAttributeDictionary);
+ if (fontAttributeDictionary)
+ IPC::encode(encoder, fontAttributeDictionary.get());
+#else
+ UNUSED_PARAM(encoder);
+#endif
}
-bool OriginAndDatabases::decode(IPC::ArgumentDecoder& decoder, OriginAndDatabases& originAndDatabases)
-{
- if (!decoder.decode(originAndDatabases.originIdentifier))
- return false;
- if (!decoder.decode(originAndDatabases.originQuota))
- return false;
- if (!decoder.decode(originAndDatabases.originUsage))
- return false;
- if (!decoder.decode(originAndDatabases.databases))
+bool FontInfo::decode(IPC::Decoder& decoder, FontInfo& fontInfo)
+{
+#if PLATFORM(COCOA)
+ bool hasFontAttributeDictionary;
+ if (!decoder.decode(hasFontAttributeDictionary))
return false;
+ if (!hasFontAttributeDictionary)
+ return true;
+
+ if (!IPC::decode(decoder, fontInfo.fontAttributeDictionary))
+ return false;
+#else
+ UNUSED_PARAM(decoder);
+ UNUSED_PARAM(fontInfo);
+#endif
+
return true;
}
} // namespace WebKit
-
-#endif // ENABLE(SQL_DATABASE)
diff --git a/Source/WebKit2/Shared/FontInfo.h b/Source/WebKit2/Shared/FontInfo.h
index 8f15635fd..3a697671b 100644
--- a/Source/WebKit2/Shared/FontInfo.h
+++ b/Source/WebKit2/Shared/FontInfo.h
@@ -26,22 +26,22 @@
#ifndef FontInfo_h
#define FontInfo_h
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
#include <wtf/RetainPtr.h>
#endif
namespace IPC {
- class ArgumentDecoder;
- class ArgumentEncoder;
+class Decoder;
+class Encoder;
}
namespace WebKit {
struct FontInfo {
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, FontInfo&);
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, FontInfo&);
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
RetainPtr<CFDictionaryRef> fontAttributeDictionary;
#endif
};
diff --git a/Source/WebKit2/Shared/FrameInfoData.cpp b/Source/WebKit2/Shared/FrameInfoData.cpp
new file mode 100644
index 000000000..4002b81c2
--- /dev/null
+++ b/Source/WebKit2/Shared/FrameInfoData.cpp
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#include "config.h"
+#include "FrameInfoData.h"
+
+#include "WebCoreArgumentCoders.h"
+
+namespace WebKit {
+
+void FrameInfoData::encode(IPC::Encoder& encoder) const
+{
+ encoder << isMainFrame;
+ encoder << request;
+ encoder << securityOrigin;
+ encoder << frameID;
+}
+
+bool FrameInfoData::decode(IPC::Decoder& decoder, FrameInfoData& result)
+{
+ if (!decoder.decode(result.isMainFrame))
+ return false;
+ if (!decoder.decode(result.request))
+ return false;
+ if (!decoder.decode(result.securityOrigin))
+ return false;
+ if (!decoder.decode(result.frameID))
+ return false;
+
+ return true;
+}
+
+}
diff --git a/Source/WebKit2/Shared/APIPageHandle.cpp b/Source/WebKit2/Shared/FrameInfoData.h
index 01a878d6e..a8283686f 100644
--- a/Source/WebKit2/Shared/APIPageHandle.cpp
+++ b/Source/WebKit2/Shared/FrameInfoData.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -23,23 +23,26 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "config.h"
-#include "APIPageHandle.h"
+#pragma once
-namespace API {
+#include <WebCore/ResourceRequest.h>
+#include <WebCore/SecurityOriginData.h>
-RefPtr<PageHandle> PageHandle::create(uint64_t pageID)
-{
- return adoptRef(new PageHandle(pageID));
+namespace IPC {
+class Decoder;
+class Encoder;
}
-PageHandle::PageHandle(uint64_t pageID)
- : m_pageID(pageID)
-{
-}
+namespace WebKit {
-PageHandle::~PageHandle()
-{
-}
+struct FrameInfoData {
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, FrameInfoData&);
-} // namespace API
+ bool isMainFrame { false };
+ WebCore::ResourceRequest request;
+ WebCore::SecurityOriginData securityOrigin;
+ uint64_t frameID { 0 };
+};
+
+}
diff --git a/Source/WebKit2/Shared/Gamepad/GamepadData.cpp b/Source/WebKit2/Shared/Gamepad/GamepadData.cpp
new file mode 100644
index 000000000..7dbce7eeb
--- /dev/null
+++ b/Source/WebKit2/Shared/Gamepad/GamepadData.cpp
@@ -0,0 +1,119 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#include "config.h"
+#include "GamepadData.h"
+
+#if ENABLE(GAMEPAD)
+
+#include "ArgumentCoders.h"
+#include <wtf/text/StringBuilder.h>
+
+namespace WebKit {
+
+GamepadData::GamepadData(unsigned index, const Vector<double>& axisValues, const Vector<double>& buttonValues, double lastUpdateTime)
+ : m_index(index)
+ , m_axisValues(axisValues)
+ , m_buttonValues(buttonValues)
+ , m_lastUpdateTime(lastUpdateTime)
+{
+}
+
+GamepadData::GamepadData(unsigned index, const String& id, const Vector<double>& axisValues, const Vector<double>& buttonValues, double lastUpdateTime)
+ : m_index(index)
+ , m_id(id)
+ , m_axisValues(axisValues)
+ , m_buttonValues(buttonValues)
+ , m_lastUpdateTime(lastUpdateTime)
+{
+}
+
+void GamepadData::encode(IPC::Encoder& encoder) const
+{
+ encoder << m_isNull;
+ if (m_isNull)
+ return;
+
+ encoder << m_index << m_id << m_axisValues << m_buttonValues << m_lastUpdateTime;
+}
+
+bool GamepadData::decode(IPC::Decoder& decoder, GamepadData& data)
+{
+ if (!decoder.decode(data.m_isNull))
+ return false;
+
+ if (data.m_isNull)
+ return true;
+
+ if (!decoder.decode(data.m_index))
+ return false;
+
+ if (!decoder.decode(data.m_id))
+ return false;
+
+ if (!decoder.decode(data.m_axisValues))
+ return false;
+
+ if (!decoder.decode(data.m_buttonValues))
+ return false;
+
+ if (!decoder.decode(data.m_lastUpdateTime))
+ return false;
+
+ return true;
+}
+
+#if !LOG_DISABLED
+String GamepadData::loggingString() const
+{
+ StringBuilder builder;
+
+ builder.appendNumber(m_axisValues.size());
+ builder.appendLiteral(" axes, ");
+ builder.appendNumber(m_buttonValues.size());
+ builder.appendLiteral(" buttons\n");
+
+ for (size_t i = 0; i < m_axisValues.size(); ++i) {
+ builder.appendLiteral(" Axis ");
+ builder.appendNumber(i);
+ builder.appendLiteral(": ");
+ builder.appendNumber(m_axisValues[i]);
+ }
+
+ builder.append('\n');
+ for (size_t i = 0; i < m_buttonValues.size(); ++i) {
+ builder.appendLiteral(" Button ");
+ builder.appendNumber(i);
+ builder.appendLiteral(": ");
+ builder.appendNumber(m_buttonValues[i]);
+ }
+
+ return builder.toString();
+}
+#endif
+
+} // namespace WebKit
+
+#endif // ENABLE(GAMEPAD)
diff --git a/Source/WebKit2/Shared/Gamepad/GamepadData.h b/Source/WebKit2/Shared/Gamepad/GamepadData.h
new file mode 100644
index 000000000..ce43dcf81
--- /dev/null
+++ b/Source/WebKit2/Shared/Gamepad/GamepadData.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#pragma once
+
+#if ENABLE(GAMEPAD)
+
+#include <wtf/Vector.h>
+#include <wtf/text/WTFString.h>
+
+namespace IPC {
+class Decoder;
+class Encoder;
+}
+
+namespace WebKit {
+
+class GamepadData {
+public:
+ GamepadData()
+ : m_isNull(true)
+ {
+ }
+
+ GamepadData(unsigned index, const Vector<double>& axisValues, const Vector<double>& buttonValues, double lastUpdateTime);
+ GamepadData(unsigned index, const String& id, const Vector<double>& axisValues, const Vector<double>& buttonValues, double lastUpdateTime);
+
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, GamepadData&);
+
+ bool isNull() const { return m_isNull; }
+
+ double lastUpdateTime() const { return m_lastUpdateTime; }
+ unsigned index() const { return m_index; }
+ const String& id() const { return m_id; }
+ const Vector<double>& axisValues() const { return m_axisValues; }
+ const Vector<double>& buttonValues() const { return m_buttonValues; }
+
+private:
+ unsigned m_index;
+ String m_id;
+ Vector<double> m_axisValues;
+ Vector<double> m_buttonValues;
+ double m_lastUpdateTime { 0.0 };
+
+ bool m_isNull { false };
+
+#if !LOG_DISABLED
+ String loggingString() const;
+#endif
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(GAMEPAD)
diff --git a/Source/WebKit2/Shared/Network/NetworkProcessSupplement.h b/Source/WebKit2/Shared/HangDetectionDisabler.h
index d6fbe5bfd..ae8b701c6 100644
--- a/Source/WebKit2/Shared/Network/NetworkProcessSupplement.h
+++ b/Source/WebKit2/Shared/HangDetectionDisabler.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
+ * 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
@@ -23,24 +23,32 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef NetworkProcessSupplement_h
-#define NetworkProcessSupplement_h
-
-#include "ChildProcessSupplement.h"
+#ifndef HangDetectionDisabler_h
+#define HangDetectionDisabler_h
namespace WebKit {
-struct NetworkProcessCreationParameters;
-
-class NetworkProcessSupplement : public ChildProcessSupplement {
-#if ENABLE(NETWORK_PROCESS)
+class HangDetectionDisabler {
public:
- virtual void initialize(const NetworkProcessCreationParameters&)
- {
- }
+ HangDetectionDisabler();
+ ~HangDetectionDisabler();
+
+private:
+#if PLATFORM(MAC)
+ bool m_clientsMayIgnoreEvents;
#endif
};
-} // namespace WebKit
+#if !PLATFORM(MAC)
+inline HangDetectionDisabler::HangDetectionDisabler()
+{
+}
+
+inline HangDetectionDisabler::~HangDetectionDisabler()
+{
+}
+#endif
+
+}
-#endif // NetworkProcessSupplement_h
+#endif // HangDetectionDisabler_h
diff --git a/Source/WebKit2/Shared/ImageOptions.h b/Source/WebKit2/Shared/ImageOptions.h
index 73d2c0ebc..312ca6da6 100644
--- a/Source/WebKit2/Shared/ImageOptions.h
+++ b/Source/WebKit2/Shared/ImageOptions.h
@@ -36,7 +36,11 @@ enum {
SnapshotOptionsShareable = 1 << 0,
SnapshotOptionsExcludeSelectionHighlighting = 1 << 1,
SnapshotOptionsInViewCoordinates = 1 << 2,
- SnapshotOptionsPaintSelectionRectangle = 1 << 3
+ SnapshotOptionsPaintSelectionRectangle = 1 << 3,
+ SnapshotOptionsExcludeDeviceScaleFactor = 1 << 5,
+ SnapshotOptionsForceBlackText = 1 << 6,
+ SnapshotOptionsForceWhiteText = 1 << 7,
+ SnapshotOptionsPrinting = 1 << 8,
};
typedef uint32_t SnapshotOptions;
diff --git a/Source/WebKit2/Shared/gtk/LayerTreeContextGtk.cpp b/Source/WebKit2/Shared/LayerTreeContext.cpp
index 5ba79d337..c3174dc4c 100644
--- a/Source/WebKit2/Shared/gtk/LayerTreeContextGtk.cpp
+++ b/Source/WebKit2/Shared/LayerTreeContext.cpp
@@ -26,13 +26,13 @@
#include "config.h"
#include "LayerTreeContext.h"
-#include "ArgumentDecoder.h"
-#include "ArgumentEncoder.h"
+#include "Decoder.h"
+#include "Encoder.h"
namespace WebKit {
LayerTreeContext::LayerTreeContext()
- : windowHandle(0)
+ : contextID(0)
{
}
@@ -40,25 +40,27 @@ LayerTreeContext::~LayerTreeContext()
{
}
-void LayerTreeContext::encode(IPC::ArgumentEncoder& encoder) const
+void LayerTreeContext::encode(IPC::Encoder& encoder) const
{
- encoder << windowHandle;
+ encoder << contextID;
}
-bool LayerTreeContext::decode(IPC::ArgumentDecoder& decoder, LayerTreeContext& context)
+bool LayerTreeContext::decode(IPC::Decoder& decoder, LayerTreeContext& result)
{
- return decoder.decode(context.windowHandle);
+ if (!decoder.decode(result.contextID))
+ return false;
+
+ return true;
}
bool LayerTreeContext::isEmpty() const
{
- return !windowHandle;
+ return !contextID;
}
bool operator==(const LayerTreeContext& a, const LayerTreeContext& b)
{
- return a.windowHandle == b.windowHandle;
+ return a.contextID == b.contextID;
}
} // namespace WebKit
-
diff --git a/Source/WebKit2/Shared/LayerTreeContext.h b/Source/WebKit2/Shared/LayerTreeContext.h
index 94296fb9f..4756f605b 100644
--- a/Source/WebKit2/Shared/LayerTreeContext.h
+++ b/Source/WebKit2/Shared/LayerTreeContext.h
@@ -23,22 +23,22 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef LayerTreeContext_h
-#define LayerTreeContext_h
+#pragma once
#include <stdint.h>
+#include <wtf/EnumTraits.h>
namespace IPC {
- class ArgumentDecoder;
- class ArgumentEncoder;
+class Decoder;
+class Encoder;
}
namespace WebKit {
-enum LayerHostingMode {
- LayerHostingModeDefault,
-#if HAVE(LAYER_HOSTING_IN_WINDOW_SERVER)
- LayerHostingModeInWindowServer
+enum class LayerHostingMode {
+ InProcess,
+#if HAVE(OUT_OF_PROCESS_LAYER_HOSTING)
+ OutOfProcess
#endif
};
@@ -47,18 +47,12 @@ public:
LayerTreeContext();
~LayerTreeContext();
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, LayerTreeContext&);
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, LayerTreeContext&);
bool isEmpty() const;
-#if PLATFORM(MAC)
- uint32_t contextID;
-#elif PLATFORM(GTK)
- uint64_t windowHandle;
-#elif PLATFORM(EFL)
- uint32_t coordinatedLayerID;
-#endif
+ uint64_t contextID;
};
bool operator==(const LayerTreeContext&, const LayerTreeContext&);
@@ -68,6 +62,16 @@ inline bool operator!=(const LayerTreeContext& a, const LayerTreeContext& b)
return !(a == b);
}
-};
+}
-#endif // LayerTreeContext_h
+namespace WTF {
+template<> struct EnumTraits<WebKit::LayerHostingMode> {
+ using values = EnumValues<
+ WebKit::LayerHostingMode,
+#if HAVE(OUT_OF_PROCESS_LAYER_HOSTING)
+ WebKit::LayerHostingMode::OutOfProcess,
+#endif
+ WebKit::LayerHostingMode::InProcess
+ >;
+};
+}
diff --git a/Source/WebKit2/Shared/LoadParameters.cpp b/Source/WebKit2/Shared/LoadParameters.cpp
new file mode 100644
index 000000000..85f6c5b50
--- /dev/null
+++ b/Source/WebKit2/Shared/LoadParameters.cpp
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#include "config.h"
+#include "LoadParameters.h"
+
+#include "WebCoreArgumentCoders.h"
+
+namespace WebKit {
+
+void LoadParameters::encode(IPC::Encoder& encoder) const
+{
+ encoder << navigationID;
+ encoder << request;
+
+ encoder << static_cast<bool>(request.httpBody());
+ if (request.httpBody())
+ request.httpBody()->encode(encoder);
+
+ encoder << sandboxExtensionHandle;
+ encoder << data;
+ encoder << string;
+ encoder << MIMEType;
+ encoder << encodingName;
+ encoder << baseURLString;
+ encoder << unreachableURLString;
+ encoder << provisionalLoadErrorURLString;
+ encoder << shouldOpenExternalURLsPolicy;
+ encoder << userData;
+
+ platformEncode(encoder);
+}
+
+bool LoadParameters::decode(IPC::Decoder& decoder, LoadParameters& data)
+{
+ if (!decoder.decode(data.navigationID))
+ return false;
+
+ if (!decoder.decode(data.request))
+ return false;
+
+ bool hasHTTPBody;
+ if (!decoder.decode(hasHTTPBody))
+ return false;
+
+ if (hasHTTPBody) {
+ RefPtr<WebCore::FormData> formData = WebCore::FormData::decode(decoder);
+ if (!formData)
+ return false;
+ data.request.setHTTPBody(WTFMove(formData));
+ }
+
+ if (!decoder.decode(data.sandboxExtensionHandle))
+ return false;
+
+ if (!decoder.decode(data.data))
+ return false;
+
+ if (!decoder.decode(data.string))
+ return false;
+
+ if (!decoder.decode(data.MIMEType))
+ return false;
+
+ if (!decoder.decode(data.encodingName))
+ return false;
+
+ if (!decoder.decode(data.baseURLString))
+ return false;
+
+ if (!decoder.decode(data.unreachableURLString))
+ return false;
+
+ if (!decoder.decode(data.provisionalLoadErrorURLString))
+ return false;
+
+ if (!decoder.decode(data.shouldOpenExternalURLsPolicy))
+ return false;
+
+ if (!decoder.decode(data.userData))
+ return false;
+
+ if (!platformDecode(decoder, data))
+ return false;
+
+ return true;
+}
+
+#if !PLATFORM(COCOA)
+
+void LoadParameters::platformEncode(IPC::Encoder&) const
+{
+}
+
+bool LoadParameters::platformDecode(IPC::Decoder&, LoadParameters&)
+{
+ return true;
+}
+
+#endif // !PLATFORM(COCOA)
+
+
+} // namespace WebKit
diff --git a/Source/WebKit2/Shared/LoadParameters.h b/Source/WebKit2/Shared/LoadParameters.h
new file mode 100644
index 000000000..d926175fd
--- /dev/null
+++ b/Source/WebKit2/Shared/LoadParameters.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#ifndef LoadParameters_h
+#define LoadParameters_h
+
+#include "DataReference.h"
+#include "SandboxExtension.h"
+#include "UserData.h"
+#include <WebCore/ResourceRequest.h>
+
+OBJC_CLASS NSDictionary;
+
+namespace IPC {
+class Decoder;
+class Encoder;
+}
+
+namespace WebKit {
+
+struct LoadParameters {
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, LoadParameters&);
+
+ void platformEncode(IPC::Encoder&) const;
+ static bool platformDecode(IPC::Decoder&, LoadParameters&);
+
+ uint64_t navigationID;
+
+ WebCore::ResourceRequest request;
+ SandboxExtension::Handle sandboxExtensionHandle;
+
+ IPC::DataReference data;
+ String string;
+ String MIMEType;
+ String encodingName;
+
+ String baseURLString;
+ String unreachableURLString;
+ String provisionalLoadErrorURLString;
+
+ uint64_t shouldOpenExternalURLsPolicy;
+ UserData userData;
+
+#if PLATFORM(COCOA)
+ RetainPtr<NSDictionary> dataDetectionContext;
+#endif
+};
+
+} // namespace WebKit
+
+#endif // LoadParameters_h
diff --git a/Source/WebKit2/Shared/Downloads/soup/DownloadSoupErrors.h b/Source/WebKit2/Shared/NativeWebGestureEvent.h
index 89e23e083..b98b75837 100644
--- a/Source/WebKit2/Shared/Downloads/soup/DownloadSoupErrors.h
+++ b/Source/WebKit2/Shared/NativeWebGestureEvent.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ * 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
@@ -23,17 +23,30 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef DownloadSoupErrors_h
-#define DownloadSoupErrors_h
+#ifndef NativeWebGestureEvent_h
+#define NativeWebGestureEvent_h
-#include <WebCore/ResourceHandle.h>
-#include <wtf/text/WTFString.h>
+#if ENABLE(MAC_GESTURE_EVENTS)
+
+#include "WebEvent.h"
+#include "WebGestureEvent.h"
+
+OBJC_CLASS NSEvent;
namespace WebKit {
-WebCore::ResourceError platformDownloadNetworkError(int errorCode, const String& failingURL, const String& localizedDescription);
-WebCore::ResourceError platformDownloadDestinationError(const WebCore::ResourceResponse&, const String& message);
+class NativeWebGestureEvent final : public WebGestureEvent {
+public:
+ explicit NativeWebGestureEvent(NSEvent *, NSView *);
+
+ NSEvent *nativeEvent() const { return m_nativeEvent.get(); }
+
+private:
+ RetainPtr<NSEvent> m_nativeEvent;
+};
} // namespace WebKit
-#endif // DownloadSoupErrors_h
+#endif // ENABLE(MAC_GESTURE_EVENTS)
+
+#endif // NativeWebGestureEvent_h
diff --git a/Source/WebKit2/Shared/NativeWebKeyboardEvent.h b/Source/WebKit2/Shared/NativeWebKeyboardEvent.h
index dfc83e3bf..cb1f118c8 100644
--- a/Source/WebKit2/Shared/NativeWebKeyboardEvent.h
+++ b/Source/WebKit2/Shared/NativeWebKeyboardEvent.h
@@ -30,20 +30,25 @@
#include "WebEvent.h"
-#if PLATFORM(MAC)
+#if USE(APPKIT)
#include <wtf/RetainPtr.h>
OBJC_CLASS NSView;
-#elif PLATFORM(GTK)
+
+namespace WebCore {
+struct KeypressCommand;
+}
+#endif
+
+#if PLATFORM(GTK)
+#include "InputMethodFilter.h"
#include <WebCore/CompositionResults.h>
#include <WebCore/GUniquePtrGtk.h>
-#include <WebCore/GtkInputMethodFilter.h>
typedef union _GdkEvent GdkEvent;
-#elif PLATFORM(EFL)
-#include <Evas.h>
#endif
#if PLATFORM(IOS)
-OBJC_CLASS WebIOSEvent;
+#include <wtf/RetainPtr.h>
+OBJC_CLASS WebEvent;
#endif
namespace WebKit {
@@ -51,15 +56,12 @@ namespace WebKit {
class NativeWebKeyboardEvent : public WebKeyboardEvent {
public:
#if USE(APPKIT)
- NativeWebKeyboardEvent(NSEvent *, NSView *);
+ NativeWebKeyboardEvent(NSEvent *, bool handledByInputMethod, bool replacesSoftSpace, const Vector<WebCore::KeypressCommand>&);
#elif PLATFORM(GTK)
NativeWebKeyboardEvent(const NativeWebKeyboardEvent&);
- NativeWebKeyboardEvent(GdkEvent*, const WebCore::CompositionResults&, WebCore::GtkInputMethodFilter::EventFakedForComposition);
-#elif PLATFORM(EFL)
- NativeWebKeyboardEvent(const Evas_Event_Key_Down*, bool);
- NativeWebKeyboardEvent(const Evas_Event_Key_Up*);
+ NativeWebKeyboardEvent(GdkEvent*, const WebCore::CompositionResults&, InputMethodFilter::EventFakedForComposition, Vector<String>&& commands);
#elif PLATFORM(IOS)
- NativeWebKeyboardEvent(WebIOSEvent *);
+ NativeWebKeyboardEvent(::WebEvent *);
#endif
#if USE(APPKIT)
@@ -68,11 +70,8 @@ public:
GdkEvent* nativeEvent() const { return m_nativeEvent.get(); }
const WebCore::CompositionResults& compositionResults() const { return m_compositionResults; }
bool isFakeEventForComposition() const { return m_fakeEventForComposition; }
-#elif PLATFORM(EFL)
- const void* nativeEvent() const { return m_nativeEvent; }
- bool isFiltered() const { return m_isFiltered; }
#elif PLATFORM(IOS)
- WebIOSEvent* nativeEvent() const { return m_nativeEvent.get(); }
+ ::WebEvent* nativeEvent() const { return m_nativeEvent.get(); }
#endif
private:
@@ -82,11 +81,8 @@ private:
GUniquePtr<GdkEvent> m_nativeEvent;
WebCore::CompositionResults m_compositionResults;
bool m_fakeEventForComposition;
-#elif PLATFORM(EFL)
- const void* m_nativeEvent;
- bool m_isFiltered;
#elif PLATFORM(IOS)
- RetainPtr<WebIOSEvent> m_nativeEvent;
+ RetainPtr<::WebEvent> m_nativeEvent;
#endif
};
diff --git a/Source/WebKit2/Shared/NativeWebMouseEvent.h b/Source/WebKit2/Shared/NativeWebMouseEvent.h
index 2b77ffe4a..88cd14109 100644
--- a/Source/WebKit2/Shared/NativeWebMouseEvent.h
+++ b/Source/WebKit2/Shared/NativeWebMouseEvent.h
@@ -28,15 +28,14 @@
#include "WebEvent.h"
-#if PLATFORM(MAC)
+#if USE(APPKIT)
#include <wtf/RetainPtr.h>
OBJC_CLASS NSView;
-#elif PLATFORM(GTK)
+#endif
+
+#if PLATFORM(GTK)
#include <WebCore/GUniquePtrGtk.h>
typedef union _GdkEvent GdkEvent;
-#elif PLATFORM(EFL)
-#include <Evas.h>
-#include <WebCore/AffineTransform.h>
#endif
namespace WebKit {
@@ -44,22 +43,16 @@ namespace WebKit {
class NativeWebMouseEvent : public WebMouseEvent {
public:
#if USE(APPKIT)
- NativeWebMouseEvent(NSEvent *, NSView *);
+ NativeWebMouseEvent(NSEvent *, NSEvent *lastPressureEvent, NSView *);
#elif PLATFORM(GTK)
NativeWebMouseEvent(const NativeWebMouseEvent&);
NativeWebMouseEvent(GdkEvent*, int);
-#elif PLATFORM(EFL)
- NativeWebMouseEvent(const Evas_Event_Mouse_Down*, const WebCore::AffineTransform&, const WebCore::AffineTransform&);
- NativeWebMouseEvent(const Evas_Event_Mouse_Up*, const WebCore::AffineTransform&, const WebCore::AffineTransform&);
- NativeWebMouseEvent(const Evas_Event_Mouse_Move*, const WebCore::AffineTransform&, const WebCore::AffineTransform&);
#endif
#if USE(APPKIT)
NSEvent* nativeEvent() const { return m_nativeEvent.get(); }
#elif PLATFORM(GTK)
const GdkEvent* nativeEvent() const { return m_nativeEvent.get(); }
-#elif PLATFORM(EFL)
- const void* nativeEvent() const { return m_nativeEvent; }
#elif PLATFORM(IOS)
const void* nativeEvent() const { return 0; }
#endif
@@ -69,8 +62,6 @@ private:
RetainPtr<NSEvent> m_nativeEvent;
#elif PLATFORM(GTK)
GUniquePtr<GdkEvent> m_nativeEvent;
-#elif PLATFORM(EFL)
- const void* m_nativeEvent;
#endif
};
diff --git a/Source/WebKit2/Shared/NativeWebTouchEvent.h b/Source/WebKit2/Shared/NativeWebTouchEvent.h
index ef5bf65ae..118124cde 100644
--- a/Source/WebKit2/Shared/NativeWebTouchEvent.h
+++ b/Source/WebKit2/Shared/NativeWebTouchEvent.h
@@ -26,18 +26,14 @@
#ifndef NativeWebTouchEvent_h
#define NativeWebTouchEvent_h
+#if ENABLE(TOUCH_EVENTS)
+
#include "WebEvent.h"
#if PLATFORM(IOS)
-#include <wtf/RetainPtr.h>
-OBJC_CLASS UIWebTouchEventsGestureRecognizer;
+struct _UIWebTouchEvent;
#elif PLATFORM(GTK)
#include <WebCore/GUniquePtrGtk.h>
-#include <WebCore/GtkTouchContextHelper.h>
-#elif PLATFORM(EFL)
-#include "EwkTouchEvent.h"
-#include <WebCore/AffineTransform.h>
-#include <wtf/RefPtr.h>
#endif
namespace WebKit {
@@ -45,29 +41,25 @@ namespace WebKit {
class NativeWebTouchEvent : public WebTouchEvent {
public:
#if PLATFORM(IOS)
- explicit NativeWebTouchEvent(UIWebTouchEventsGestureRecognizer *);
- const UIWebTouchEventsGestureRecognizer* nativeEvent() const { return m_nativeEvent.get(); }
+ explicit NativeWebTouchEvent(const _UIWebTouchEvent*);
#elif PLATFORM(GTK)
+ NativeWebTouchEvent(GdkEvent*, Vector<WebPlatformTouchPoint>&&);
NativeWebTouchEvent(const NativeWebTouchEvent&);
- NativeWebTouchEvent(GdkEvent*, WebCore::GtkTouchContextHelper&);
const GdkEvent* nativeEvent() const { return m_nativeEvent.get(); }
- const WebCore::GtkTouchContextHelper& touchContext() const { return m_touchContext; }
-#elif PLATFORM(EFL)
- NativeWebTouchEvent(EwkTouchEvent*, const WebCore::AffineTransform&);
- const EwkTouchEvent* nativeEvent() const { return m_nativeEvent.get(); }
#endif
private:
#if PLATFORM(IOS)
- RetainPtr<UIWebTouchEventsGestureRecognizer> m_nativeEvent;
-#elif PLATFORM(GTK)
+ Vector<WebPlatformTouchPoint> extractWebTouchPoint(const _UIWebTouchEvent*);
+#endif
+
+#if PLATFORM(GTK)
GUniquePtr<GdkEvent> m_nativeEvent;
- const WebCore::GtkTouchContextHelper& m_touchContext;
-#elif PLATFORM(EFL)
- RefPtr<EwkTouchEvent> m_nativeEvent;
#endif
};
} // namespace WebKit
+#endif // ENABLE(TOUCH_EVENTS)
+
#endif // NativeWebTouchEvent_h
diff --git a/Source/WebKit2/Shared/NativeWebWheelEvent.h b/Source/WebKit2/Shared/NativeWebWheelEvent.h
index aed301cbb..5db0bce8f 100644
--- a/Source/WebKit2/Shared/NativeWebWheelEvent.h
+++ b/Source/WebKit2/Shared/NativeWebWheelEvent.h
@@ -28,15 +28,14 @@
#include "WebEvent.h"
-#if PLATFORM(MAC)
+#if USE(APPKIT)
#include <wtf/RetainPtr.h>
OBJC_CLASS NSView;
-#elif PLATFORM(GTK)
+#endif
+
+#if PLATFORM(GTK)
#include <WebCore/GUniquePtrGtk.h>
typedef union _GdkEvent GdkEvent;
-#elif PLATFORM(EFL)
-#include <Evas.h>
-#include <WebCore/AffineTransform.h>
#endif
namespace WebKit {
@@ -48,16 +47,12 @@ public:
#elif PLATFORM(GTK)
NativeWebWheelEvent(const NativeWebWheelEvent&);
NativeWebWheelEvent(GdkEvent*);
-#elif PLATFORM(EFL)
- NativeWebWheelEvent(const Evas_Event_Mouse_Wheel*, const WebCore::AffineTransform& toWebContent, const WebCore::AffineTransform& toDeviceScreen);
#endif
#if USE(APPKIT)
NSEvent* nativeEvent() const { return m_nativeEvent.get(); }
#elif PLATFORM(GTK)
- const GdkEvent* nativeEvent() const { return m_nativeEvent.get(); }
-#elif PLATFORM(EFL)
- const Evas_Event_Mouse_Wheel* nativeEvent() const { return m_nativeEvent; }
+ GdkEvent* nativeEvent() const { return m_nativeEvent.get(); }
#elif PLATFORM(IOS)
const void* nativeEvent() const { return 0; }
#endif
@@ -67,8 +62,6 @@ private:
RetainPtr<NSEvent> m_nativeEvent;
#elif PLATFORM(GTK)
GUniquePtr<GdkEvent> m_nativeEvent;
-#elif PLATFORM(EFL)
- const Evas_Event_Mouse_Wheel* m_nativeEvent;
#endif
};
diff --git a/Source/WebKit2/Shared/NavigationActionData.cpp b/Source/WebKit2/Shared/NavigationActionData.cpp
index 2c37e63a0..e31286d8a 100644
--- a/Source/WebKit2/Shared/NavigationActionData.cpp
+++ b/Source/WebKit2/Shared/NavigationActionData.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,26 +26,27 @@
#include "config.h"
#include "NavigationActionData.h"
-#include "ArgumentDecoder.h"
-#include "ArgumentEncoder.h"
+#include "ArgumentCoders.h"
+#include "Decoder.h"
+#include "Encoder.h"
using namespace WebCore;
namespace WebKit {
-NavigationActionData::NavigationActionData()
- : navigationType(NavigationTypeOther)
-{
-}
-
-void NavigationActionData::encode(IPC::ArgumentEncoder& encoder) const
+void NavigationActionData::encode(IPC::Encoder& encoder) const
{
encoder.encodeEnum(navigationType);
encoder.encodeEnum(modifiers);
encoder.encodeEnum(mouseButton);
+ encoder.encodeEnum(syntheticClickType);
+ encoder << userGestureTokenIdentifier;
+ encoder << canHandleRequest;
+ encoder.encodeEnum(shouldOpenExternalURLsPolicy);
+ encoder << downloadAttribute;
}
-bool NavigationActionData::decode(IPC::ArgumentDecoder& decoder, NavigationActionData& result)
+bool NavigationActionData::decode(IPC::Decoder& decoder, NavigationActionData& result)
{
if (!decoder.decodeEnum(result.navigationType))
return false;
@@ -53,6 +54,16 @@ bool NavigationActionData::decode(IPC::ArgumentDecoder& decoder, NavigationActio
return false;
if (!decoder.decodeEnum(result.mouseButton))
return false;
+ if (!decoder.decodeEnum(result.syntheticClickType))
+ return false;
+ if (!decoder.decode(result.userGestureTokenIdentifier))
+ return false;
+ if (!decoder.decode(result.canHandleRequest))
+ return false;
+ if (!decoder.decodeEnum(result.shouldOpenExternalURLsPolicy))
+ return false;
+ if (!decoder.decode(result.downloadAttribute))
+ return false;
return true;
}
diff --git a/Source/WebKit2/Shared/NavigationActionData.h b/Source/WebKit2/Shared/NavigationActionData.h
index 61cb5c2ae..10db63c4a 100644
--- a/Source/WebKit2/Shared/NavigationActionData.h
+++ b/Source/WebKit2/Shared/NavigationActionData.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -30,21 +30,24 @@
#include <WebCore/FrameLoaderTypes.h>
namespace IPC {
-class ArgumentDecoder;
-class ArgumentEncoder;
+class Decoder;
+class Encoder;
}
namespace WebKit {
struct NavigationActionData {
- NavigationActionData();
-
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, NavigationActionData&);
-
- WebCore::NavigationType navigationType;
- WebEvent::Modifiers modifiers;
- WebMouseEvent::Button mouseButton;
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, NavigationActionData&);
+
+ WebCore::NavigationType navigationType { WebCore::NavigationType::Other };
+ WebEvent::Modifiers modifiers { };
+ WebMouseEvent::Button mouseButton { WebMouseEvent::NoButton };
+ WebMouseEvent::SyntheticClickType syntheticClickType { WebMouseEvent::NoTap };
+ uint64_t userGestureTokenIdentifier;
+ bool canHandleRequest { false };
+ WebCore::ShouldOpenExternalURLsPolicy shouldOpenExternalURLsPolicy { WebCore::ShouldOpenExternalURLsPolicy::ShouldNotAllow };
+ WTF::String downloadAttribute;
};
}
diff --git a/Source/WebKit2/Shared/Network/CustomProtocols/CustomProtocolManager.h b/Source/WebKit2/Shared/Network/CustomProtocols/CustomProtocolManager.h
deleted file mode 100644
index fda8107e1..000000000
--- a/Source/WebKit2/Shared/Network/CustomProtocols/CustomProtocolManager.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (C) 2012, 2013 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.
- */
-
-#ifndef CustomProtocolManager_h
-#define CustomProtocolManager_h
-
-#if ENABLE(CUSTOM_PROTOCOLS)
-
-#include "Connection.h"
-#include "NetworkProcessSupplement.h"
-#include "WebProcessSupplement.h"
-#include "WorkQueue.h"
-#include <wtf/text/WTFString.h>
-
-#if PLATFORM(MAC)
-#include <wtf/HashMap.h>
-#include <wtf/HashSet.h>
-#include <wtf/RetainPtr.h>
-#include <wtf/Threading.h>
-OBJC_CLASS WKCustomProtocol;
-#endif
-
-
-namespace IPC {
-class DataReference;
-} // namespace IPC
-
-namespace WebCore {
-class ResourceError;
-class ResourceResponse;
-} // namespace WebCore
-
-namespace WebKit {
-
-class ChildProcess;
-class CustomProtocolManagerImpl;
-struct NetworkProcessCreationParameters;
-
-class CustomProtocolManager : public WebProcessSupplement, public NetworkProcessSupplement, public IPC::Connection::WorkQueueMessageReceiver {
- WTF_MAKE_NONCOPYABLE(CustomProtocolManager);
-public:
- explicit CustomProtocolManager(ChildProcess*);
-
- static const char* supplementName();
-
- ChildProcess* childProcess() const { return m_childProcess; }
-
- void registerScheme(const String&);
- void unregisterScheme(const String&);
- bool supportsScheme(const String&);
-
-#if PLATFORM(MAC)
- void addCustomProtocol(WKCustomProtocol *);
- void removeCustomProtocol(WKCustomProtocol *);
-#endif
-
-private:
- // ChildProcessSupplement
- void initializeConnection(IPC::Connection*) override;
-
- // WebProcessSupplement
- void initialize(const WebProcessCreationParameters&) override;
-
-#if ENABLE(NETWORK_PROCESS)
- // NetworkProcessSupplement
- void initialize(const NetworkProcessCreationParameters&) override;
-#endif
-
- // IPC::MessageReceiver
- virtual void didReceiveMessage(IPC::Connection*, IPC::MessageDecoder&) override;
-
- void didFailWithError(uint64_t customProtocolID, const WebCore::ResourceError&);
- void didLoadData(uint64_t customProtocolID, const IPC::DataReference&);
- void didReceiveResponse(uint64_t customProtocolID, const WebCore::ResourceResponse&, uint32_t cacheStoragePolicy);
- void didFinishLoading(uint64_t customProtocolID);
-
- ChildProcess* m_childProcess;
- RefPtr<WorkQueue> m_messageQueue;
-
-#if PLATFORM(MAC)
- HashSet<String> m_registeredSchemes;
- Mutex m_registeredSchemesMutex;
-
- typedef HashMap<uint64_t, RetainPtr<WKCustomProtocol>> CustomProtocolMap;
- CustomProtocolMap m_customProtocolMap;
- Mutex m_customProtocolMapMutex;
-
- // WKCustomProtocol objects can be removed from the m_customProtocolMap from multiple threads.
- // We return a RetainPtr here because it is unsafe to return a raw pointer since the object might immediately be destroyed from a different thread.
- RetainPtr<WKCustomProtocol> protocolForID(uint64_t customProtocolID);
-#else
- // FIXME: Move mac specific code to CustomProtocolManagerImpl.
- std::unique_ptr<CustomProtocolManagerImpl> m_impl;
-#endif
-};
-
-} // namespace WebKit
-
-#endif // ENABLE(CUSTOM_PROTOCOLS)
-
-#endif // CustomProtocolManager_h
diff --git a/Source/WebKit2/Shared/Network/CustomProtocols/soup/CustomProtocolManagerImpl.cpp b/Source/WebKit2/Shared/Network/CustomProtocols/soup/CustomProtocolManagerImpl.cpp
deleted file mode 100644
index 98c55e1ba..000000000
--- a/Source/WebKit2/Shared/Network/CustomProtocols/soup/CustomProtocolManagerImpl.cpp
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * Copyright (C) 2014 Igalia S.L.
- *
- * 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 "CustomProtocolManagerImpl.h"
-
-#if ENABLE(CUSTOM_PROTOCOLS)
-
-#include "ChildProcess.h"
-#include "CustomProtocolManagerProxyMessages.h"
-#include "DataReference.h"
-#include "WebCoreArgumentCoders.h"
-#include "WebKitSoupRequestGeneric.h"
-#include "WebKitSoupRequestInputStream.h"
-#include <WebCore/ResourceError.h>
-#include <WebCore/ResourceRequest.h>
-#include <WebCore/ResourceResponse.h>
-#include <WebCore/SoupNetworkSession.h>
-
-namespace WebKit {
-
-static uint64_t generateCustomProtocolID()
-{
- static uint64_t uniqueCustomProtocolID = 0;
- return ++uniqueCustomProtocolID;
-}
-
-struct WebSoupRequestAsyncData {
- WebSoupRequestAsyncData(GTask* task, WebKitSoupRequestGeneric* requestGeneric)
- : task(task)
- , request(requestGeneric)
- , cancellable(g_task_get_cancellable(task))
- {
- // If the struct contains a null request, it is because the request failed.
- g_object_add_weak_pointer(G_OBJECT(request), reinterpret_cast<void**>(&request));
- }
-
- ~WebSoupRequestAsyncData()
- {
- if (request)
- g_object_remove_weak_pointer(G_OBJECT(request), reinterpret_cast<void**>(&request));
- }
-
- bool requestFailed()
- {
- return g_cancellable_is_cancelled(cancellable.get()) || !request;
- }
-
- GRefPtr<GTask> releaseTask()
- {
- GTask* returnValue = task;
- task = nullptr;
- return adoptGRef(returnValue);
- }
-
- GTask* task;
- WebKitSoupRequestGeneric* request;
- GRefPtr<GCancellable> cancellable;
- GRefPtr<GInputStream> stream;
-};
-
-CustomProtocolManagerImpl::CustomProtocolManagerImpl(ChildProcess* childProcess)
- : m_childProcess(childProcess)
- , m_schemes(adoptGRef(g_ptr_array_new_with_free_func(g_free)))
-{
-}
-
-CustomProtocolManagerImpl::~CustomProtocolManagerImpl()
-{
-}
-
-void CustomProtocolManagerImpl::registerScheme(const String& scheme)
-{
- if (m_schemes->len)
- g_ptr_array_remove_index_fast(m_schemes.get(), m_schemes->len - 1);
- g_ptr_array_add(m_schemes.get(), g_strdup(scheme.utf8().data()));
- g_ptr_array_add(m_schemes.get(), nullptr);
-
- SoupSession* session = WebCore::SoupNetworkSession::defaultSession().soupSession();
- SoupRequestClass* genericRequestClass = static_cast<SoupRequestClass*>(g_type_class_ref(WEBKIT_TYPE_SOUP_REQUEST_GENERIC));
- genericRequestClass->schemes = const_cast<const char**>(reinterpret_cast<char**>(m_schemes->pdata));
- static_cast<WebKitSoupRequestGenericClass*>(g_type_class_ref(WEBKIT_TYPE_SOUP_REQUEST_GENERIC))->customProtocolManager = this;
- soup_session_add_feature_by_type(session, WEBKIT_TYPE_SOUP_REQUEST_GENERIC);
-}
-
-bool CustomProtocolManagerImpl::supportsScheme(const String& scheme)
-{
- if (scheme.isNull())
- return false;
-
- CString cScheme = scheme.utf8();
- for (unsigned i = 0; i < m_schemes->len; ++i) {
- if (cScheme == static_cast<char*>(g_ptr_array_index(m_schemes.get(), i)))
- return true;
- }
-
- return false;
-}
-
-void CustomProtocolManagerImpl::didFailWithError(uint64_t customProtocolID, const WebCore::ResourceError& error)
-{
- WebSoupRequestAsyncData* data = m_customProtocolMap.get(customProtocolID);
- ASSERT(data);
-
- GRefPtr<GTask> task = data->releaseTask();
- ASSERT(task.get());
- g_task_return_new_error(task.get(), g_quark_from_string(error.domain().utf8().data()),
- error.errorCode(), "%s", error.localizedDescription().utf8().data());
-
- m_customProtocolMap.remove(customProtocolID);
-}
-
-void CustomProtocolManagerImpl::didLoadData(uint64_t customProtocolID, const IPC::DataReference& dataReference)
-{
- WebSoupRequestAsyncData* data = m_customProtocolMap.get(customProtocolID);
- // The data might have been removed from the request map if a previous chunk failed
- // and a new message was sent by the UI process before being notified about the failure.
- if (!data)
- return;
-
- if (!data->stream) {
- GRefPtr<GTask> task = data->releaseTask();
- ASSERT(task.get());
-
- goffset soupContentLength = soup_request_get_content_length(SOUP_REQUEST(g_task_get_source_object(task.get())));
- uint64_t contentLength = soupContentLength == -1 ? 0 : static_cast<uint64_t>(soupContentLength);
- if (!dataReference.size()) {
- // Empty reply, just create and empty GMemoryInputStream.
- data->stream = g_memory_input_stream_new();
- } else if (dataReference.size() == contentLength) {
- // We don't expect more data, so we can just create a GMemoryInputStream with all the data.
- data->stream = g_memory_input_stream_new_from_data(g_memdup(dataReference.data(), dataReference.size()), contentLength, g_free);
- } else {
- // We expect more data chunks from the UI process.
- data->stream = webkitSoupRequestInputStreamNew(contentLength);
- webkitSoupRequestInputStreamAddData(WEBKIT_SOUP_REQUEST_INPUT_STREAM(data->stream.get()), dataReference.data(), dataReference.size());
- }
- g_task_return_pointer(task.get(), data->stream.get(), g_object_unref);
- return;
- }
-
- if (data->requestFailed()) {
- // ResourceRequest failed or it was cancelled. It doesn't matter here the error or if it was cancelled,
- // because that's already handled by the resource handle client, we just want to notify the UI process
- // to stop reading data from the user input stream. If UI process already sent all the data we simply
- // finish silently.
- if (!webkitSoupRequestInputStreamFinished(WEBKIT_SOUP_REQUEST_INPUT_STREAM(data->stream.get())))
- m_childProcess->send(Messages::CustomProtocolManagerProxy::StopLoading(customProtocolID), 0);
-
- return;
- }
-
- webkitSoupRequestInputStreamAddData(WEBKIT_SOUP_REQUEST_INPUT_STREAM(data->stream.get()), dataReference.data(), dataReference.size());
-}
-
-void CustomProtocolManagerImpl::didReceiveResponse(uint64_t customProtocolID, const WebCore::ResourceResponse& response)
-{
- WebSoupRequestAsyncData* data = m_customProtocolMap.get(customProtocolID);
- ASSERT(data);
- ASSERT(data->task);
-
- WebKitSoupRequestGeneric* request = WEBKIT_SOUP_REQUEST_GENERIC(g_task_get_source_object(data->task));
- webkitSoupRequestGenericSetContentLength(request, response.expectedContentLength() ? response.expectedContentLength() : -1);
- webkitSoupRequestGenericSetContentType(request, !response.mimeType().isEmpty() ? response.mimeType().utf8().data() : 0);
-}
-
-void CustomProtocolManagerImpl::didFinishLoading(uint64_t customProtocolID)
-{
- ASSERT(m_customProtocolMap.contains(customProtocolID));
- m_customProtocolMap.remove(customProtocolID);
-}
-
-void CustomProtocolManagerImpl::send(GTask* task)
-{
- uint64_t customProtocolID = generateCustomProtocolID();
- WebKitSoupRequestGeneric* request = WEBKIT_SOUP_REQUEST_GENERIC(g_task_get_source_object(task));
- m_customProtocolMap.set(customProtocolID, std::make_unique<WebSoupRequestAsyncData>(task, request));
-
- WebCore::ResourceRequest resourceRequest(SOUP_REQUEST(request));
- m_childProcess->send(Messages::CustomProtocolManagerProxy::StartLoading(customProtocolID, resourceRequest), 0);
-}
-
-GInputStream* CustomProtocolManagerImpl::finish(GTask* task, GError** error)
-{
- gpointer inputStream = g_task_propagate_pointer(task, error);
- return inputStream ? G_INPUT_STREAM(inputStream) : 0;
-}
-
-} // namespace WebKit
-
-#endif // ENABLE(CUSTOM_PROTOCOLS)
diff --git a/Source/WebKit2/Shared/Network/CustomProtocols/soup/CustomProtocolManagerImpl.h b/Source/WebKit2/Shared/Network/CustomProtocols/soup/CustomProtocolManagerImpl.h
deleted file mode 100644
index 1d44241d6..000000000
--- a/Source/WebKit2/Shared/Network/CustomProtocols/soup/CustomProtocolManagerImpl.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2014 Igalia S.L.
- *
- * 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.
- */
-
-#ifndef CustomProtocolManagerImpl_h
-#define CustomProtocolManagerImpl_h
-
-#if ENABLE(CUSTOM_PROTOCOLS)
-
-#include <wtf/HashMap.h>
-#include <wtf/gobject/GRefPtr.h>
-#include <wtf/text/WTFString.h>
-
-typedef struct _GTask GTask;
-typedef struct _GInputStream GInputStream;
-
-namespace IPC {
-class DataReference;
-} // namespace IPC
-
-namespace WebCore {
-class ResourceError;
-class ResourceResponse;
-} // namespace WebCore
-
-namespace WebKit {
-
-class ChildProcess;
-struct WebSoupRequestAsyncData;
-
-class CustomProtocolManagerImpl {
- WTF_MAKE_NONCOPYABLE(CustomProtocolManagerImpl);
-public:
- explicit CustomProtocolManagerImpl(ChildProcess*);
- ~CustomProtocolManagerImpl();
-
- void registerScheme(const String&);
- bool supportsScheme(const String&);
-
- void didFailWithError(uint64_t customProtocolID, const WebCore::ResourceError&);
- void didLoadData(uint64_t customProtocolID, const IPC::DataReference&);
- void didReceiveResponse(uint64_t customProtocolID, const WebCore::ResourceResponse&);
- void didFinishLoading(uint64_t customProtocolID);
-
- // SoupRequest implementation.
- void send(GTask*);
- GInputStream* finish(GTask*, GError**);
-
-private:
- ChildProcess* m_childProcess;
- GRefPtr<GPtrArray> m_schemes;
- HashMap<uint64_t, std::unique_ptr<WebSoupRequestAsyncData>> m_customProtocolMap;
-};
-
-} // namespace WebKit
-
-#endif // ENABLE(CUSTOM_PROTOCOLS)
-
-#endif // CustomProtocolManagerImpl_h
diff --git a/Source/WebKit2/Shared/Network/CustomProtocols/soup/CustomProtocolManagerSoup.cpp b/Source/WebKit2/Shared/Network/CustomProtocols/soup/CustomProtocolManagerSoup.cpp
deleted file mode 100644
index 6b71ac06f..000000000
--- a/Source/WebKit2/Shared/Network/CustomProtocols/soup/CustomProtocolManagerSoup.cpp
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (C) 2013 Igalia S.L.
- *
- * 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 "CustomProtocolManager.h"
-
-#if ENABLE(CUSTOM_PROTOCOLS)
-
-#include "ChildProcess.h"
-#include "CustomProtocolManagerImpl.h"
-#include "CustomProtocolManagerMessages.h"
-#include "WebProcessCreationParameters.h"
-#include <WebCore/NotImplemented.h>
-
-#if ENABLE(NETWORK_PROCESS)
-#include "NetworkProcessCreationParameters.h"
-#endif
-
-namespace WebKit {
-
-const char* CustomProtocolManager::supplementName()
-{
- return "CustomProtocolManager";
-}
-
-CustomProtocolManager::CustomProtocolManager(ChildProcess* childProcess)
- : m_childProcess(childProcess)
- , m_messageQueue(WorkQueue::create("com.apple.WebKit.CustomProtocolManager"))
- , m_impl(std::make_unique<CustomProtocolManagerImpl>(childProcess))
-{
-}
-
-void CustomProtocolManager::initializeConnection(IPC::Connection* connection)
-{
- connection->addWorkQueueMessageReceiver(Messages::CustomProtocolManager::messageReceiverName(), m_messageQueue.get(), this);
-}
-
-void CustomProtocolManager::initialize(const WebProcessCreationParameters& parameters)
-{
-#if ENABLE(NETWORK_PROCESS)
- ASSERT(parameters.urlSchemesRegisteredForCustomProtocols.isEmpty() || !parameters.usesNetworkProcess);
- if (parameters.usesNetworkProcess) {
- m_childProcess->parentProcessConnection()->removeWorkQueueMessageReceiver(Messages::CustomProtocolManager::messageReceiverName());
- m_messageQueue = nullptr;
- return;
- }
-#endif
- for (size_t i = 0; i < parameters.urlSchemesRegisteredForCustomProtocols.size(); ++i)
- registerScheme(parameters.urlSchemesRegisteredForCustomProtocols[i]);
-}
-
-#if ENABLE(NETWORK_PROCESS)
-void CustomProtocolManager::initialize(const NetworkProcessCreationParameters& parameters)
-{
- for (size_t i = 0; i < parameters.urlSchemesRegisteredForCustomProtocols.size(); ++i)
- registerScheme(parameters.urlSchemesRegisteredForCustomProtocols[i]);
-}
-#endif
-
-void CustomProtocolManager::registerScheme(const String& scheme)
-{
- m_impl->registerScheme(scheme);
-}
-
-void CustomProtocolManager::unregisterScheme(const String&)
-{
- notImplemented();
-}
-
-bool CustomProtocolManager::supportsScheme(const String& scheme)
-{
- return m_impl->supportsScheme(scheme);
-}
-
-void CustomProtocolManager::didFailWithError(uint64_t customProtocolID, const WebCore::ResourceError& error)
-{
- m_impl->didFailWithError(customProtocolID, error);
-}
-
-void CustomProtocolManager::didLoadData(uint64_t customProtocolID, const IPC::DataReference& dataReference)
-{
- m_impl->didLoadData(customProtocolID, dataReference);
-}
-
-void CustomProtocolManager::didReceiveResponse(uint64_t customProtocolID, const WebCore::ResourceResponse& response, uint32_t)
-{
- m_impl->didReceiveResponse(customProtocolID, response);
-}
-
-void CustomProtocolManager::didFinishLoading(uint64_t customProtocolID)
-{
- m_impl->didFinishLoading(customProtocolID);
-}
-
-} // namespace WebKit
-
-#endif // ENABLE(CUSTOM_PROTOCOLS)
diff --git a/Source/WebKit2/Shared/Network/NetworkProcessCreationParameters.cpp b/Source/WebKit2/Shared/Network/NetworkProcessCreationParameters.cpp
deleted file mode 100644
index a26a5a1f5..000000000
--- a/Source/WebKit2/Shared/Network/NetworkProcessCreationParameters.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "config.h"
-#include "NetworkProcessCreationParameters.h"
-
-#if ENABLE(NETWORK_PROCESS)
-
-#include "ArgumentCoders.h"
-
-namespace WebKit {
-
-NetworkProcessCreationParameters::NetworkProcessCreationParameters()
-{
-}
-
-void NetworkProcessCreationParameters::encode(IPC::ArgumentEncoder& encoder) const
-{
- encoder << privateBrowsingEnabled;
- encoder.encodeEnum(cacheModel);
- encoder << diskCacheDirectory;
- encoder << diskCacheDirectoryExtensionHandle;
- encoder << shouldUseTestingNetworkSession;
-#if ENABLE(CUSTOM_PROTOCOLS)
- encoder << urlSchemesRegisteredForCustomProtocols;
-#endif
-#if PLATFORM(MAC)
- encoder << parentProcessName;
- encoder << uiProcessBundleIdentifier;
- encoder << nsURLCacheMemoryCapacity;
- encoder << nsURLCacheDiskCapacity;
- encoder << httpProxy;
- encoder << httpsProxy;
-#endif
-#if USE(SOUP)
- encoder << cookiePersistentStoragePath;
- encoder << cookiePersistentStorageType;
- encoder.encodeEnum(cookieAcceptPolicy);
- encoder << ignoreTLSErrors;
- encoder << languages;
-#endif
-}
-
-bool NetworkProcessCreationParameters::decode(IPC::ArgumentDecoder& decoder, NetworkProcessCreationParameters& result)
-{
- if (!decoder.decode(result.privateBrowsingEnabled))
- return false;
- if (!decoder.decodeEnum(result.cacheModel))
- return false;
- if (!decoder.decode(result.diskCacheDirectory))
- return false;
- if (!decoder.decode(result.diskCacheDirectoryExtensionHandle))
- return false;
- if (!decoder.decode(result.shouldUseTestingNetworkSession))
- return false;
-#if ENABLE(CUSTOM_PROTOCOLS)
- if (!decoder.decode(result.urlSchemesRegisteredForCustomProtocols))
- return false;
-#endif
-#if PLATFORM(MAC)
- if (!decoder.decode(result.parentProcessName))
- return false;
- if (!decoder.decode(result.uiProcessBundleIdentifier))
- return false;
- if (!decoder.decode(result.nsURLCacheMemoryCapacity))
- return false;
- if (!decoder.decode(result.nsURLCacheDiskCapacity))
- return false;
- if (!decoder.decode(result.httpProxy))
- return false;
- if (!decoder.decode(result.httpsProxy))
- return false;
-#endif
-
-#if USE(SOUP)
- if (!decoder.decode(result.cookiePersistentStoragePath))
- return false;
- if (!decoder.decode(result.cookiePersistentStorageType))
- return false;
- if (!decoder.decodeEnum(result.cookieAcceptPolicy))
- return false;
- if (!decoder.decode(result.ignoreTLSErrors))
- return false;
- if (!decoder.decode(result.languages))
- return false;
-#endif
-
- return true;
-}
-
-} // namespace WebKit
-
-#endif // ENABLE(NETWORK_PROCESS)
diff --git a/Source/WebKit2/Shared/Network/NetworkProcessCreationParameters.h b/Source/WebKit2/Shared/Network/NetworkProcessCreationParameters.h
deleted file mode 100644
index 1ba8d8ec4..000000000
--- a/Source/WebKit2/Shared/Network/NetworkProcessCreationParameters.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#ifndef NetworkProcessCreationParameters_h
-#define NetworkProcessCreationParameters_h
-
-#if ENABLE(NETWORK_PROCESS)
-
-#include "CacheModel.h"
-#include "SandboxExtension.h"
-#include <wtf/Vector.h>
-#include <wtf/text/WTFString.h>
-
-#if USE(SOUP)
-#include "HTTPCookieAcceptPolicy.h"
-#endif
-
-namespace IPC {
- class ArgumentDecoder;
- class ArgumentEncoder;
-}
-
-namespace WebKit {
-
-struct NetworkProcessCreationParameters {
- NetworkProcessCreationParameters();
-
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, NetworkProcessCreationParameters&);
-
- bool privateBrowsingEnabled;
- CacheModel cacheModel;
-
- String diskCacheDirectory;
- SandboxExtension::Handle diskCacheDirectoryExtensionHandle;
-
- bool shouldUseTestingNetworkSession;
-
-#if ENABLE(CUSTOM_PROTOCOLS)
- Vector<String> urlSchemesRegisteredForCustomProtocols;
-#endif
-
-#if PLATFORM(MAC)
- String parentProcessName;
- String uiProcessBundleIdentifier;
- uint64_t nsURLCacheMemoryCapacity;
- uint64_t nsURLCacheDiskCapacity;
-
- String httpProxy;
- String httpsProxy;
-#endif
-
-#if USE(SOUP)
- String cookiePersistentStoragePath;
- uint32_t cookiePersistentStorageType;
- HTTPCookieAcceptPolicy cookieAcceptPolicy;
- bool ignoreTLSErrors;
- Vector<String> languages;
-#endif
-};
-
-} // namespace WebKit
-
-#endif // ENABLE(NETWORK_PROCESS)
-
-#endif // NetworkProcessCreationParameters_h
diff --git a/Source/WebKit2/Shared/Network/NetworkResourceLoadParameters.cpp b/Source/WebKit2/Shared/Network/NetworkResourceLoadParameters.cpp
deleted file mode 100644
index 54cabf40f..000000000
--- a/Source/WebKit2/Shared/Network/NetworkResourceLoadParameters.cpp
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#include "config.h"
-#include "NetworkResourceLoadParameters.h"
-
-#include "ArgumentCoders.h"
-#include "DataReference.h"
-#include "DecoderAdapter.h"
-#include "EncoderAdapter.h"
-#include "WebCoreArgumentCoders.h"
-
-#if ENABLE(NETWORK_PROCESS)
-
-using namespace WebCore;
-
-namespace WebKit {
-NetworkResourceLoadParameters::NetworkResourceLoadParameters()
- : identifier(0)
- , webPageID(0)
- , webFrameID(0)
- , sessionID(0)
- , priority(ResourceLoadPriorityVeryLow)
- , contentSniffingPolicy(SniffContent)
- , allowStoredCredentials(DoNotAllowStoredCredentials)
- , clientCredentialPolicy(DoNotAskClientForAnyCredentials)
- , shouldClearReferrerOnHTTPSToHTTPRedirect(true)
- , isMainResource(false)
-{
-}
-
-void NetworkResourceLoadParameters::encode(IPC::ArgumentEncoder& encoder) const
-{
- encoder << identifier;
- encoder << webPageID;
- encoder << webFrameID;
- encoder << sessionID;
- encoder << request;
-
- encoder << static_cast<bool>(request.httpBody());
- if (request.httpBody()) {
- EncoderAdapter httpBodyEncoderAdapter;
- request.httpBody()->encode(httpBodyEncoderAdapter);
- encoder << httpBodyEncoderAdapter.dataReference();
-
- const Vector<FormDataElement>& elements = request.httpBody()->elements();
- size_t fileCount = 0;
- for (size_t i = 0, count = elements.size(); i < count; ++i) {
- if (elements[i].m_type == FormDataElement::encodedFile)
- ++fileCount;
- }
-
- SandboxExtension::HandleArray requestBodySandboxExtensions;
- requestBodySandboxExtensions.allocate(fileCount);
- size_t extensionIndex = 0;
- for (size_t i = 0, count = elements.size(); i < count; ++i) {
- const FormDataElement& element = elements[i];
- if (element.m_type == FormDataElement::encodedFile) {
- const String& path = element.m_shouldGenerateFile ? element.m_generatedFilename : element.m_filename;
- SandboxExtension::createHandle(path, SandboxExtension::ReadOnly, requestBodySandboxExtensions[extensionIndex++]);
- }
- }
- encoder << requestBodySandboxExtensions;
- }
-
- if (request.url().isLocalFile()) {
- SandboxExtension::Handle requestSandboxExtension;
- SandboxExtension::createHandle(request.url().fileSystemPath(), SandboxExtension::ReadOnly, requestSandboxExtension);
- encoder << requestSandboxExtension;
- }
-
- encoder.encodeEnum(priority);
- encoder.encodeEnum(contentSniffingPolicy);
- encoder.encodeEnum(allowStoredCredentials);
- encoder.encodeEnum(clientCredentialPolicy);
- encoder << shouldClearReferrerOnHTTPSToHTTPRedirect;
- encoder << isMainResource;
-}
-
-bool NetworkResourceLoadParameters::decode(IPC::ArgumentDecoder& decoder, NetworkResourceLoadParameters& result)
-{
- if (!decoder.decode(result.identifier))
- return false;
-
- if (!decoder.decode(result.webPageID))
- return false;
-
- if (!decoder.decode(result.webFrameID))
- return false;
-
- if (!decoder.decode(result.sessionID))
- return false;
-
- if (!decoder.decode(result.request))
- return false;
-
- bool hasHTTPBody;
- if (!decoder.decode(hasHTTPBody))
- return false;
-
- if (hasHTTPBody) {
- IPC::DataReference formData;
- if (!decoder.decode(formData))
- return false;
- DecoderAdapter httpBodyDecoderAdapter(formData.data(), formData.size());
- result.request.setHTTPBody(FormData::decode(httpBodyDecoderAdapter));
-
- if (!decoder.decode(result.requestBodySandboxExtensions))
- return false;
- }
-
- if (result.request.url().isLocalFile()) {
- if (!decoder.decode(result.resourceSandboxExtension))
- return false;
- }
-
- if (!decoder.decodeEnum(result.priority))
- return false;
- if (!decoder.decodeEnum(result.contentSniffingPolicy))
- return false;
- if (!decoder.decodeEnum(result.allowStoredCredentials))
- return false;
- if (!decoder.decodeEnum(result.clientCredentialPolicy))
- return false;
- if (!decoder.decode(result.shouldClearReferrerOnHTTPSToHTTPRedirect))
- return false;
- if (!decoder.decode(result.isMainResource))
- return false;
-
- return true;
-}
-
-} // namespace WebKit
-
-#endif // ENABLE(NETWORK_PROCESS)
diff --git a/Source/WebKit2/Shared/Network/NetworkResourceLoadParameters.h b/Source/WebKit2/Shared/Network/NetworkResourceLoadParameters.h
deleted file mode 100644
index cbf4531db..000000000
--- a/Source/WebKit2/Shared/Network/NetworkResourceLoadParameters.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2012, 2013 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.
- */
-
-#ifndef NetworkResourceLoadParameters_h
-#define NetworkResourceLoadParameters_h
-
-#include "SandboxExtension.h"
-#include <WebCore/ResourceHandle.h>
-#include <WebCore/ResourceLoaderOptions.h>
-#include <WebCore/ResourceRequest.h>
-
-#if ENABLE(NETWORK_PROCESS)
-
-namespace IPC {
- class ArgumentDecoder;
- class ArgumentEncoder;
-}
-
-namespace WebKit {
-
-typedef uint64_t ResourceLoadIdentifier;
-
-class NetworkResourceLoadParameters {
-public:
- NetworkResourceLoadParameters();
-
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, NetworkResourceLoadParameters&);
-
- ResourceLoadIdentifier identifier;
- uint64_t webPageID;
- uint64_t webFrameID;
- uint64_t sessionID;
- WebCore::ResourceRequest request;
- SandboxExtension::HandleArray requestBodySandboxExtensions; // Created automatically for the sender.
- SandboxExtension::Handle resourceSandboxExtension; // Created automatically for the sender.
- WebCore::ResourceLoadPriority priority;
- WebCore::ContentSniffingPolicy contentSniffingPolicy;
- WebCore::StoredCredentials allowStoredCredentials;
- WebCore::ClientCredentialPolicy clientCredentialPolicy;
- bool shouldClearReferrerOnHTTPSToHTTPRedirect;
- bool isMainResource;
-};
-
-} // namespace WebKit
-
-#endif // ENABLE(NETWORK_PROCESS)
-
-#endif // NetworkResourceLoadParameters_h
diff --git a/Source/WebKit2/Shared/PlatformPopupMenuData.cpp b/Source/WebKit2/Shared/PlatformPopupMenuData.cpp
index 49da13012..efa7976b1 100644
--- a/Source/WebKit2/Shared/PlatformPopupMenuData.cpp
+++ b/Source/WebKit2/Shared/PlatformPopupMenuData.cpp
@@ -34,23 +34,29 @@ PlatformPopupMenuData::PlatformPopupMenuData()
{
}
-void PlatformPopupMenuData::encode(IPC::ArgumentEncoder& encoder) const
+void PlatformPopupMenuData::encode(IPC::Encoder& encoder) const
{
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
encoder << fontInfo;
encoder << shouldPopOver;
+ encoder << hideArrows;
+ encoder.encodeEnum(menuSize);
#else
UNUSED_PARAM(encoder);
#endif
}
-bool PlatformPopupMenuData::decode(IPC::ArgumentDecoder& decoder, PlatformPopupMenuData& data)
+bool PlatformPopupMenuData::decode(IPC::Decoder& decoder, PlatformPopupMenuData& data)
{
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
if (!decoder.decode(data.fontInfo))
return false;
if (!decoder.decode(data.shouldPopOver))
return false;
+ if (!decoder.decode(data.hideArrows))
+ return false;
+ if (!decoder.decodeEnum(data.menuSize))
+ return false;
#else
UNUSED_PARAM(decoder);
UNUSED_PARAM(data);
diff --git a/Source/WebKit2/Shared/PlatformPopupMenuData.h b/Source/WebKit2/Shared/PlatformPopupMenuData.h
index 10207fe1c..a156963ec 100644
--- a/Source/WebKit2/Shared/PlatformPopupMenuData.h
+++ b/Source/WebKit2/Shared/PlatformPopupMenuData.h
@@ -28,11 +28,12 @@
#include "FontInfo.h"
#include "ShareableBitmap.h"
+#include <WebCore/PopupMenuStyle.h>
#include <wtf/text/WTFString.h>
namespace IPC {
- class ArgumentDecoder;
- class ArgumentEncoder;
+class Decoder;
+class Encoder;
}
namespace WebKit {
@@ -40,12 +41,14 @@ namespace WebKit {
struct PlatformPopupMenuData {
PlatformPopupMenuData();
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, PlatformPopupMenuData&);
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, PlatformPopupMenuData&);
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
FontInfo fontInfo;
bool shouldPopOver;
+ bool hideArrows;
+ WebCore::PopupMenuStyle::PopupMenuSize menuSize;
#endif
};
diff --git a/Source/WebKit2/Shared/Plugins/NPIdentifierData.cpp b/Source/WebKit2/Shared/Plugins/NPIdentifierData.cpp
index 029e6abd8..93c3ce925 100644
--- a/Source/WebKit2/Shared/Plugins/NPIdentifierData.cpp
+++ b/Source/WebKit2/Shared/Plugins/NPIdentifierData.cpp
@@ -28,8 +28,8 @@
#if ENABLE(NETSCAPE_PLUGIN_API)
-#include "ArgumentDecoder.h"
-#include "ArgumentEncoder.h"
+#include "Decoder.h"
+#include "Encoder.h"
#include "WebCoreArgumentCoders.h"
#include <WebCore/IdentifierRep.h>
@@ -67,7 +67,7 @@ NPIdentifier NPIdentifierData::createNPIdentifier() const
return static_cast<NPIdentifier>(IdentifierRep::get(m_number));
}
-void NPIdentifierData::encode(IPC::ArgumentEncoder& encoder) const
+void NPIdentifierData::encode(IPC::Encoder& encoder) const
{
encoder << m_isString;
if (m_isString)
@@ -76,7 +76,7 @@ void NPIdentifierData::encode(IPC::ArgumentEncoder& encoder) const
encoder << m_number;
}
-bool NPIdentifierData::decode(IPC::ArgumentDecoder& decoder, NPIdentifierData& result)
+bool NPIdentifierData::decode(IPC::Decoder& decoder, NPIdentifierData& result)
{
if (!decoder.decode(result.m_isString))
return false;
diff --git a/Source/WebKit2/Shared/Plugins/NPIdentifierData.h b/Source/WebKit2/Shared/Plugins/NPIdentifierData.h
index 5b5179337..4f678a445 100644
--- a/Source/WebKit2/Shared/Plugins/NPIdentifierData.h
+++ b/Source/WebKit2/Shared/Plugins/NPIdentifierData.h
@@ -32,8 +32,8 @@
#include <wtf/text/CString.h>
namespace IPC {
- class ArgumentDecoder;
- class ArgumentEncoder;
+class Decoder;
+class Encoder;
}
namespace WebKit {
@@ -45,8 +45,8 @@ public:
static NPIdentifierData fromNPIdentifier(NPIdentifier);
NPIdentifier createNPIdentifier() const;
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, NPIdentifierData&);
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, NPIdentifierData&);
private:
bool m_isString;
diff --git a/Source/WebKit2/Shared/Plugins/NPObjectMessageReceiver.cpp b/Source/WebKit2/Shared/Plugins/NPObjectMessageReceiver.cpp
index e5567cfff..328ef7b20 100644
--- a/Source/WebKit2/Shared/Plugins/NPObjectMessageReceiver.cpp
+++ b/Source/WebKit2/Shared/Plugins/NPObjectMessageReceiver.cpp
@@ -32,6 +32,8 @@
#include "NPRemoteObjectMap.h"
#include "NPRuntimeUtilities.h"
#include "NPVariantData.h"
+#include "Plugin.h"
+#include "PluginController.h"
namespace WebKit {
@@ -80,6 +82,8 @@ void NPObjectMessageReceiver::invoke(const NPIdentifierData& methodNameData, con
NPVariant result;
VOID_TO_NPVARIANT(result);
+ PluginController::PluginDestructionProtector protector(m_plugin->controller());
+
returnValue = m_npObject->_class->invoke(m_npObject, methodNameData.createNPIdentifier(), arguments.data(), arguments.size(), &result);
if (returnValue) {
// Convert the NPVariant to an NPVariantData.
@@ -108,6 +112,8 @@ void NPObjectMessageReceiver::invokeDefault(const Vector<NPVariantData>& argumen
NPVariant result;
VOID_TO_NPVARIANT(result);
+ PluginController::PluginDestructionProtector protector(m_plugin->controller());
+
returnValue = m_npObject->_class->invokeDefault(m_npObject, arguments.data(), arguments.size(), &result);
if (returnValue) {
// Convert the NPVariant to an NPVariantData.
@@ -142,14 +148,15 @@ void NPObjectMessageReceiver::getProperty(const NPIdentifierData& propertyNameDa
NPVariant result;
VOID_TO_NPVARIANT(result);
+ PluginController::PluginDestructionProtector protector(m_plugin->controller());
+
returnValue = m_npObject->_class->getProperty(m_npObject, propertyNameData.createNPIdentifier(), &result);
if (!returnValue)
return;
- // Convert the NPVariant to an NPVariantData.
+
resultData = m_npRemoteObjectMap->npVariantToNPVariantData(result, m_plugin);
- // And release the result.
releaseNPVariantValue(&result);
}
@@ -162,10 +169,10 @@ void NPObjectMessageReceiver::setProperty(const NPIdentifierData& propertyNameDa
NPVariant propertyValue = m_npRemoteObjectMap->npVariantDataToNPVariant(propertyValueData, m_plugin);
- // Set the property.
+ PluginController::PluginDestructionProtector protector(m_plugin->controller());
+
returnValue = m_npObject->_class->setProperty(m_npObject, propertyNameData.createNPIdentifier(), &propertyValue);
- // And release the value.
releaseNPVariantValue(&propertyValue);
}
@@ -213,17 +220,15 @@ void NPObjectMessageReceiver::construct(const Vector<NPVariantData>& argumentsDa
NPVariant result;
VOID_TO_NPVARIANT(result);
+ PluginController::PluginDestructionProtector protector(m_plugin->controller());
+
returnValue = m_npObject->_class->construct(m_npObject, arguments.data(), arguments.size(), &result);
- if (returnValue) {
- // Convert the NPVariant to an NPVariantData.
+ if (returnValue)
resultData = m_npRemoteObjectMap->npVariantToNPVariantData(result, m_plugin);
- }
- // Release all arguments.
for (size_t i = 0; i < argumentsData.size(); ++i)
releaseNPVariantValue(&arguments[i]);
- // And release the result.
releaseNPVariantValue(&result);
}
diff --git a/Source/WebKit2/Shared/Plugins/NPObjectMessageReceiver.h b/Source/WebKit2/Shared/Plugins/NPObjectMessageReceiver.h
index ee14d6da7..2759893fa 100644
--- a/Source/WebKit2/Shared/Plugins/NPObjectMessageReceiver.h
+++ b/Source/WebKit2/Shared/Plugins/NPObjectMessageReceiver.h
@@ -46,7 +46,7 @@ public:
NPObjectMessageReceiver(NPRemoteObjectMap*, Plugin*, uint64_t npObjectID, NPObject*);
~NPObjectMessageReceiver();
- void didReceiveSyncNPObjectMessageReceiverMessage(IPC::Connection*, IPC::MessageDecoder&, std::unique_ptr<IPC::MessageEncoder>&);
+ void didReceiveSyncNPObjectMessageReceiverMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&);
Plugin* plugin() const { return m_plugin; }
NPObject* npObject() const { return m_npObject; }
diff --git a/Source/WebKit2/Shared/Plugins/NPObjectProxy.cpp b/Source/WebKit2/Shared/Plugins/NPObjectProxy.cpp
index a34f19dc5..ef6c79130 100644
--- a/Source/WebKit2/Shared/Plugins/NPObjectProxy.cpp
+++ b/Source/WebKit2/Shared/Plugins/NPObjectProxy.cpp
@@ -57,7 +57,7 @@ NPObjectProxy::NPObjectProxy()
NPObjectProxy::~NPObjectProxy()
{
- ASSERT(isMainThread());
+ ASSERT(RunLoop::isMain());
if (!m_npRemoteObjectMap)
return;
@@ -303,7 +303,9 @@ void NPObjectProxy::NP_Deallocate(NPObject* npObject)
// that is known to be misused during plugin teardown, and to not be concerned about change in behavior if this
// occured at any other time.
if (!isMainThread()) {
- RunLoop::main()->dispatch(bind(&NPObjectProxy::NP_Deallocate, npObject));
+ RunLoop::main().dispatch([npObject] {
+ NP_Deallocate(npObject);
+ });
return;
}
diff --git a/Source/WebKit2/Shared/Plugins/NPRemoteObjectMap.cpp b/Source/WebKit2/Shared/Plugins/NPRemoteObjectMap.cpp
index 8138c2ff7..61e1f9402 100644
--- a/Source/WebKit2/Shared/Plugins/NPRemoteObjectMap.cpp
+++ b/Source/WebKit2/Shared/Plugins/NPRemoteObjectMap.cpp
@@ -32,7 +32,6 @@
#include "NPObjectProxy.h"
#include "NPRuntimeUtilities.h"
#include "NPVariantData.h"
-#include <wtf/OwnPtr.h>
namespace WebKit {
@@ -42,9 +41,9 @@ static uint64_t generateNPObjectID()
return ++generateNPObjectID;
}
-PassRefPtr<NPRemoteObjectMap> NPRemoteObjectMap::create(IPC::Connection* connection)
+Ref<NPRemoteObjectMap> NPRemoteObjectMap::create(IPC::Connection* connection)
{
- return adoptRef(new NPRemoteObjectMap(connection));
+ return adoptRef(*new NPRemoteObjectMap(connection));
}
NPRemoteObjectMap::NPRemoteObjectMap(IPC::Connection* connection)
@@ -196,38 +195,29 @@ NPVariant NPRemoteObjectMap::npVariantDataToNPVariant(const NPVariantData& npVar
void NPRemoteObjectMap::pluginDestroyed(Plugin* plugin)
{
- Vector<NPObjectMessageReceiver*> messageReceivers;
-
- // Gather the receivers associated with this plug-in.
- for (HashMap<uint64_t, NPObjectMessageReceiver*>::const_iterator it = m_registeredNPObjects.begin(), end = m_registeredNPObjects.end(); it != end; ++it) {
- NPObjectMessageReceiver* npObjectMessageReceiver = it->value;
- if (npObjectMessageReceiver->plugin() == plugin)
- messageReceivers.append(npObjectMessageReceiver);
- }
-
- // Now delete all the receivers.
- deprecatedDeleteAllValues(messageReceivers);
-
- Vector<NPObjectProxy*> objectProxies;
- for (HashSet<NPObjectProxy*>::const_iterator it = m_npObjectProxies.begin(), end = m_npObjectProxies.end(); it != end; ++it) {
- NPObjectProxy* npObjectProxy = *it;
-
- if (npObjectProxy->plugin() == plugin)
- objectProxies.append(npObjectProxy);
+ // Gather and delete the receivers associated with this plug-in.
+ Vector<NPObjectMessageReceiver*> receivers;
+ for (auto* receiver : m_registeredNPObjects.values()) {
+ if (receiver->plugin() == plugin)
+ receivers.append(receiver);
}
+ for (auto* receiver : receivers)
+ delete receiver;
// Invalidate and remove all proxies associated with this plug-in.
- for (size_t i = 0; i < objectProxies.size(); ++i) {
- NPObjectProxy* npObjectProxy = objectProxies[i];
-
- npObjectProxy->invalidate();
-
- ASSERT(m_npObjectProxies.contains(npObjectProxy));
- m_npObjectProxies.remove(npObjectProxy);
+ Vector<NPObjectProxy*> proxies;
+ for (auto* proxy : m_npObjectProxies) {
+ if (proxy->plugin() == plugin)
+ proxies.append(proxy);
+ }
+ for (auto* proxy : proxies) {
+ proxy->invalidate();
+ ASSERT(m_npObjectProxies.contains(proxy));
+ m_npObjectProxies.remove(proxy);
}
}
-void NPRemoteObjectMap::didReceiveSyncMessage(IPC::Connection* connection, IPC::MessageDecoder& decoder, std::unique_ptr<IPC::MessageEncoder>& replyEncoder)
+void NPRemoteObjectMap::didReceiveSyncMessage(IPC::Connection& connection, IPC::Decoder& decoder, std::unique_ptr<IPC::Encoder>& replyEncoder)
{
NPObjectMessageReceiver* messageReceiver = m_registeredNPObjects.get(decoder.destinationID());
if (!messageReceiver)
diff --git a/Source/WebKit2/Shared/Plugins/NPRemoteObjectMap.h b/Source/WebKit2/Shared/Plugins/NPRemoteObjectMap.h
index cd075f810..ed105a73c 100644
--- a/Source/WebKit2/Shared/Plugins/NPRemoteObjectMap.h
+++ b/Source/WebKit2/Shared/Plugins/NPRemoteObjectMap.h
@@ -43,7 +43,7 @@ class Plugin;
class NPRemoteObjectMap : public RefCounted<NPRemoteObjectMap> {
public:
- static PassRefPtr<NPRemoteObjectMap> create(IPC::Connection*);
+ static Ref<NPRemoteObjectMap> create(IPC::Connection*);
~NPRemoteObjectMap();
// Creates an NPObjectProxy wrapper for the remote object with the given remote object ID.
@@ -61,7 +61,7 @@ public:
void pluginDestroyed(Plugin*);
- void didReceiveSyncMessage(IPC::Connection*, IPC::MessageDecoder&, std::unique_ptr<IPC::MessageEncoder>&);
+ void didReceiveSyncMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&);
private:
explicit NPRemoteObjectMap(IPC::Connection*);
diff --git a/Source/WebKit2/Shared/Plugins/NPVariantData.cpp b/Source/WebKit2/Shared/Plugins/NPVariantData.cpp
index b460d0972..d2e671bcb 100644
--- a/Source/WebKit2/Shared/Plugins/NPVariantData.cpp
+++ b/Source/WebKit2/Shared/Plugins/NPVariantData.cpp
@@ -28,8 +28,8 @@
#if ENABLE(NETSCAPE_PLUGIN_API)
-#include "ArgumentDecoder.h"
-#include "ArgumentEncoder.h"
+#include "Decoder.h"
+#include "Encoder.h"
#include "WebCoreArgumentCoders.h"
namespace WebKit {
@@ -118,7 +118,7 @@ NPVariantData NPVariantData::makeRemoteNPObjectID(uint64_t value)
return npVariantData;
}
-void NPVariantData::encode(IPC::ArgumentEncoder& encoder) const
+void NPVariantData::encode(IPC::Encoder& encoder) const
{
encoder << m_type;
@@ -147,7 +147,7 @@ void NPVariantData::encode(IPC::ArgumentEncoder& encoder) const
}
}
-bool NPVariantData::decode(IPC::ArgumentDecoder& decoder, NPVariantData& result)
+bool NPVariantData::decode(IPC::Decoder& decoder, NPVariantData& result)
{
uint32_t type;
if (!decoder.decode(type))
diff --git a/Source/WebKit2/Shared/Plugins/NPVariantData.h b/Source/WebKit2/Shared/Plugins/NPVariantData.h
index da056a94c..2c5f2c9f6 100644
--- a/Source/WebKit2/Shared/Plugins/NPVariantData.h
+++ b/Source/WebKit2/Shared/Plugins/NPVariantData.h
@@ -31,8 +31,8 @@
#include <wtf/text/CString.h>
namespace IPC {
- class ArgumentDecoder;
- class ArgumentEncoder;
+class Decoder;
+class Encoder;
}
namespace WebKit {
@@ -98,8 +98,8 @@ public:
return m_remoteNPObjectIDValue;
}
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, NPVariantData&);
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, NPVariantData&);
private:
uint32_t m_type;
diff --git a/Source/WebKit2/Shared/Plugins/Netscape/NetscapePluginModule.cpp b/Source/WebKit2/Shared/Plugins/Netscape/NetscapePluginModule.cpp
index 10b4f1952..ad7063b24 100644
--- a/Source/WebKit2/Shared/Plugins/Netscape/NetscapePluginModule.cpp
+++ b/Source/WebKit2/Shared/Plugins/Netscape/NetscapePluginModule.cpp
@@ -131,7 +131,7 @@ void NetscapePluginModule::shutdown()
size_t pluginModuleIndex = initializedNetscapePluginModules().find(this);
ASSERT(pluginModuleIndex != notFound);
-
+
initializedNetscapePluginModules().remove(pluginModuleIndex);
}
@@ -145,13 +145,13 @@ PassRefPtr<NetscapePluginModule> NetscapePluginModule::getOrCreate(const String&
return pluginModule;
}
- RefPtr<NetscapePluginModule> pluginModule(adoptRef(new NetscapePluginModule(pluginPath)));
+ auto pluginModule(adoptRef(*new NetscapePluginModule(pluginPath)));
// Try to load and initialize the plug-in module.
if (!pluginModule->load())
- return 0;
+ return nullptr;
- return pluginModule.release();
+ return WTFMove(pluginModule);
}
void NetscapePluginModule::incrementLoadCount()
@@ -169,7 +169,7 @@ void NetscapePluginModule::decrementLoadCount()
ASSERT(m_loadCount > 0);
m_loadCount--;
- if (!m_loadCount) {
+ if (!m_loadCount && m_isInitialized) {
shutdown();
unload();
}
@@ -263,9 +263,6 @@ bool NetscapePluginModule::tryLoad()
#endif
return result;
-#elif PLUGIN_ARCHITECTURE(WIN)
- if (getEntryPointsFuncPtr(&m_pluginFuncs) != NPERR_NO_ERROR || initializeFuncPtr(netscapeBrowserFuncs()) != NPERR_NO_ERROR)
- return false;
#elif PLUGIN_ARCHITECTURE(X11)
if (initializeFuncPtr(netscapeBrowserFuncs(), &m_pluginFuncs) != NPERR_NO_ERROR)
return false;
diff --git a/Source/WebKit2/Shared/Plugins/Netscape/NetscapePluginModule.h b/Source/WebKit2/Shared/Plugins/Netscape/NetscapePluginModule.h
index fb5e88b8c..f19f94161 100644
--- a/Source/WebKit2/Shared/Plugins/Netscape/NetscapePluginModule.h
+++ b/Source/WebKit2/Shared/Plugins/Netscape/NetscapePluginModule.h
@@ -41,7 +41,7 @@ struct MimeClassInfo;
namespace WebKit {
-class RawPluginMetaData;
+struct RawPluginMetaData;
class NetscapePluginModule : public RefCounted<NetscapePluginModule> {
public:
@@ -65,10 +65,6 @@ public:
Module* module() const { return m_module.get(); }
-#if PLUGIN_ARCHITECTURE(MAC)
- static bool createPluginMIMETypesPreferences(const String& pluginPath);
-#endif
-
#if PLUGIN_ARCHITECTURE(X11)
static bool scanPlugin(const String& pluginPath);
static void parseMIMEDescription(const String& mimeDescription, Vector<WebCore::MimeClassInfo>& result);
diff --git a/Source/WebKit2/Shared/Plugins/Netscape/PluginInformation.cpp b/Source/WebKit2/Shared/Plugins/Netscape/PluginInformation.cpp
index ec15420bd..cc39e559c 100644
--- a/Source/WebKit2/Shared/Plugins/Netscape/PluginInformation.cpp
+++ b/Source/WebKit2/Shared/Plugins/Netscape/PluginInformation.cpp
@@ -108,7 +108,7 @@ String plugInInformationReplacementObscuredKey()
return ASCIILiteral("PlugInInformationReplacementObscured");
}
-void getPluginModuleInformation(const PluginModuleInfo& plugin, ImmutableDictionary::MapType& map)
+void getPluginModuleInformation(const PluginModuleInfo& plugin, API::Dictionary::MapType& map)
{
#if ENABLE(NETSCAPE_PLUGIN_API)
map.set(pluginInformationPathKey(), API::String::create(plugin.path));
@@ -122,17 +122,17 @@ void getPluginModuleInformation(const PluginModuleInfo& plugin, ImmutableDiction
#endif
}
-PassRefPtr<ImmutableDictionary> createPluginInformationDictionary(const PluginModuleInfo& plugin)
+Ref<API::Dictionary> createPluginInformationDictionary(const PluginModuleInfo& plugin)
{
- ImmutableDictionary::MapType map;
+ API::Dictionary::MapType map;
getPluginModuleInformation(plugin, map);
- return ImmutableDictionary::create(std::move(map));
+ return API::Dictionary::create(WTFMove(map));
}
-PassRefPtr<ImmutableDictionary> createPluginInformationDictionary(const PluginModuleInfo& plugin, const String& frameURLString, const String& mimeType, const String& pageURLString, const String& pluginspageAttributeURLString, const String& pluginURLString, bool replacementObscured)
+Ref<API::Dictionary> createPluginInformationDictionary(const PluginModuleInfo& plugin, const String& frameURLString, const String& mimeType, const String& pageURLString, const String& pluginspageAttributeURLString, const String& pluginURLString, bool replacementObscured)
{
- ImmutableDictionary::MapType map;
+ API::Dictionary::MapType map;
getPluginModuleInformation(plugin, map);
if (!frameURLString.isEmpty())
@@ -147,12 +147,12 @@ PassRefPtr<ImmutableDictionary> createPluginInformationDictionary(const PluginMo
map.set(pluginInformationPluginURLKey(), API::URL::create(pluginURLString));
map.set(plugInInformationReplacementObscuredKey(), API::Boolean::create(replacementObscured));
- return ImmutableDictionary::create(std::move(map));
+ return API::Dictionary::create(WTFMove(map));
}
-PassRefPtr<ImmutableDictionary> createPluginInformationDictionary(const String& mimeType, const String& frameURLString, const String& pageURLString)
+Ref<API::Dictionary> createPluginInformationDictionary(const String& mimeType, const String& frameURLString, const String& pageURLString)
{
- ImmutableDictionary::MapType map;
+ API::Dictionary::MapType map;
if (!frameURLString.isEmpty())
map.set(pluginInformationFrameURLKey(), API::URL::create(frameURLString));
@@ -161,11 +161,11 @@ PassRefPtr<ImmutableDictionary> createPluginInformationDictionary(const String&
if (!pageURLString.isEmpty())
map.set(pluginInformationPageURLKey(), API::URL::create(pageURLString));
- return ImmutableDictionary::create(std::move(map));
+ return API::Dictionary::create(WTFMove(map));
}
-#if !PLATFORM(MAC)
-void getPlatformPluginModuleInformation(const PluginModuleInfo&, ImmutableDictionary::MapType&)
+#if !PLATFORM(COCOA)
+void getPlatformPluginModuleInformation(const PluginModuleInfo&, API::Dictionary::MapType&)
{
}
#endif
diff --git a/Source/WebKit2/Shared/Plugins/Netscape/PluginInformation.h b/Source/WebKit2/Shared/Plugins/Netscape/PluginInformation.h
index 7f6e19986..969e85a0a 100644
--- a/Source/WebKit2/Shared/Plugins/Netscape/PluginInformation.h
+++ b/Source/WebKit2/Shared/Plugins/Netscape/PluginInformation.h
@@ -26,7 +26,7 @@
#ifndef PluginInformation_h
#define PluginInformation_h
-#include "ImmutableDictionary.h"
+#include "APIDictionary.h"
#include <wtf/Forward.h>
namespace WebKit {
@@ -51,12 +51,12 @@ String pluginInformationPluginspageAttributeURLKey();
String pluginInformationPluginURLKey();
String plugInInformationReplacementObscuredKey();
-PassRefPtr<ImmutableDictionary> createPluginInformationDictionary(const PluginModuleInfo&);
-PassRefPtr<ImmutableDictionary> createPluginInformationDictionary(const PluginModuleInfo&, const String& frameURLString, const String& mimeType, const String& pageURLString, const String& pluginspageAttributeURLString, const String& pluginURLString, bool replacementObscured = false);
-PassRefPtr<ImmutableDictionary> createPluginInformationDictionary(const String& mimeType, const String& frameURLString, const String& pageURLString);
+Ref<API::Dictionary> createPluginInformationDictionary(const PluginModuleInfo&);
+Ref<API::Dictionary> createPluginInformationDictionary(const PluginModuleInfo&, const String& frameURLString, const String& mimeType, const String& pageURLString, const String& pluginspageAttributeURLString, const String& pluginURLString, bool replacementObscured = false);
+Ref<API::Dictionary> createPluginInformationDictionary(const String& mimeType, const String& frameURLString, const String& pageURLString);
-void getPluginModuleInformation(const PluginModuleInfo&, ImmutableDictionary::MapType&);
-void getPlatformPluginModuleInformation(const PluginModuleInfo&, ImmutableDictionary::MapType&);
+void getPluginModuleInformation(const PluginModuleInfo&, API::Dictionary::MapType&);
+void getPlatformPluginModuleInformation(const PluginModuleInfo&, API::Dictionary::MapType&);
} // namespace WebKit
diff --git a/Source/WebKit2/Shared/Plugins/Netscape/x11/NetscapePluginModuleX11.cpp b/Source/WebKit2/Shared/Plugins/Netscape/x11/NetscapePluginModuleX11.cpp
index 368e9d00a..a1a0ed9ec 100644
--- a/Source/WebKit2/Shared/Plugins/Netscape/x11/NetscapePluginModuleX11.cpp
+++ b/Source/WebKit2/Shared/Plugins/Netscape/x11/NetscapePluginModuleX11.cpp
@@ -59,12 +59,15 @@ StdoutDevNullRedirector::StdoutDevNullRedirector()
return;
m_savedStdout = dup(STDOUT_FILENO);
dup2(newStdout, STDOUT_FILENO);
+ close(newStdout);
}
StdoutDevNullRedirector::~StdoutDevNullRedirector()
{
- if (m_savedStdout != -1)
+ if (m_savedStdout != -1) {
dup2(m_savedStdout, STDOUT_FILENO);
+ close(m_savedStdout);
+ }
}
@@ -73,7 +76,7 @@ void NetscapePluginModule::parseMIMEDescription(const String& mimeDescription, V
ASSERT_ARG(result, result.isEmpty());
Vector<String> types;
- mimeDescription.lower().split(UChar(';'), false, types);
+ mimeDescription.convertToASCIILowercase().split(UChar(';'), false, types);
result.reserveInitialCapacity(types.size());
size_t mimeInfoCount = 0;
@@ -163,13 +166,15 @@ bool NetscapePluginModule::getPluginInfo(const String& pluginPath, PluginModuleI
plugin.info.name = metaData.name;
plugin.info.desc = metaData.description;
parseMIMEDescription(metaData.mimeDescription, plugin.info.mimes);
+#if PLATFORM(GTK)
+ plugin.requiresGtk2 = metaData.requiresGtk2;
+#endif
return true;
}
void NetscapePluginModule::determineQuirks()
{
-#if CPU(X86_64)
RawPluginMetaData metaData;
if (!getPluginInfoForLoadedPlugin(metaData))
return;
@@ -178,12 +183,13 @@ void NetscapePluginModule::determineQuirks()
parseMIMEDescription(metaData.mimeDescription, mimeTypes);
for (size_t i = 0; i < mimeTypes.size(); ++i) {
if (mimeTypes[i].type == "application/x-shockwave-flash") {
+#if CPU(X86_64)
m_pluginQuirks.add(PluginQuirks::IgnoreRightClickInWindowlessMode);
+#endif
m_pluginQuirks.add(PluginQuirks::DoNotCancelSrcStreamInWindowedMode);
break;
}
}
-#endif
}
static void writeCharacter(char byte)
diff --git a/Source/WebKit2/Shared/Plugins/PluginModuleInfo.h b/Source/WebKit2/Shared/Plugins/PluginModuleInfo.h
index bc0302957..e5360f8d4 100644
--- a/Source/WebKit2/Shared/Plugins/PluginModuleInfo.h
+++ b/Source/WebKit2/Shared/Plugins/PluginModuleInfo.h
@@ -23,12 +23,11 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef PluginModuleInfo_h
-#define PluginModuleInfo_h
+#pragma once
#include <WebCore/PluginData.h>
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
#include <mach/machine.h>
#endif
@@ -43,22 +42,23 @@ enum PluginModuleLoadPolicy {
// The plug-in should be blocked from being instantiated.
// Note that the plug-in will still be seen by e.g. navigator.plugins
- PluginModuleBlocked,
+ PluginModuleBlockedForSecurity,
+ PluginModuleBlockedForCompatibility,
};
struct PluginModuleInfo {
String path;
WebCore::PluginInfo info;
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
cpu_type_t pluginArchitecture;
String bundleIdentifier;
String versionString;
String shortVersionString;
- String preferencePanePath;
+ bool hasSandboxProfile;
+#elif PLATFORM(GTK)
+ bool requiresGtk2;
#endif
};
} // namespace WebKit
-
-#endif // PluginModuleInfo_h
diff --git a/Source/WebKit2/Shared/Plugins/PluginProcessCreationParameters.cpp b/Source/WebKit2/Shared/Plugins/PluginProcessCreationParameters.cpp
index a53fdef00..3988e8ca9 100644
--- a/Source/WebKit2/Shared/Plugins/PluginProcessCreationParameters.cpp
+++ b/Source/WebKit2/Shared/Plugins/PluginProcessCreationParameters.cpp
@@ -27,8 +27,10 @@
#include "PluginProcessCreationParameters.h"
#if ENABLE(NETSCAPE_PLUGIN_API)
-
-#include "ArgumentCoders.h"
+#if PLATFORM(COCOA)
+#include "ArgumentCodersCF.h"
+#endif
+#include "WebCoreArgumentCoders.h"
namespace WebKit {
@@ -37,18 +39,24 @@ PluginProcessCreationParameters::PluginProcessCreationParameters()
{
}
-void PluginProcessCreationParameters::encode(IPC::ArgumentEncoder& encoder) const
+void PluginProcessCreationParameters::encode(IPC::Encoder& encoder) const
{
encoder.encodeEnum(processType);
encoder << supportsAsynchronousPluginInitialization;
encoder << minimumLifetime;
encoder << terminationTimeout;
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
encoder << acceleratedCompositingPort;
+#if TARGET_OS_IPHONE || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
+ IPC::encode(encoder, networkATSContext.get());
+#endif
+#endif
+#if OS(LINUX)
+ encoder << memoryPressureMonitorHandle;
#endif
}
-bool PluginProcessCreationParameters::decode(IPC::ArgumentDecoder& decoder, PluginProcessCreationParameters& result)
+bool PluginProcessCreationParameters::decode(IPC::Decoder& decoder, PluginProcessCreationParameters& result)
{
if (!decoder.decodeEnum(result.processType))
return false;
@@ -58,9 +66,17 @@ bool PluginProcessCreationParameters::decode(IPC::ArgumentDecoder& decoder, Plug
return false;
if (!decoder.decode(result.terminationTimeout))
return false;
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
if (!decoder.decode(result.acceleratedCompositingPort))
return false;
+#if TARGET_OS_IPHONE || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
+ if (!IPC::decode(decoder, result.networkATSContext))
+ return false;
+#endif
+#endif
+#if OS(LINUX)
+ if (!decoder.decode(result.memoryPressureMonitorHandle))
+ return false;
#endif
return true;
diff --git a/Source/WebKit2/Shared/Plugins/PluginProcessCreationParameters.h b/Source/WebKit2/Shared/Plugins/PluginProcessCreationParameters.h
index e0f9d6b2e..a12a4445b 100644
--- a/Source/WebKit2/Shared/Plugins/PluginProcessCreationParameters.h
+++ b/Source/WebKit2/Shared/Plugins/PluginProcessCreationParameters.h
@@ -28,15 +28,16 @@
#if ENABLE(NETSCAPE_PLUGIN_API)
+#include "Attachment.h"
#include "PluginProcessAttributes.h"
-#if PLATFORM(MAC)
-#include "MachPort.h"
+#if PLATFORM(COCOA)
+#include <WebCore/MachSendRight.h>
#endif
namespace IPC {
- class ArgumentDecoder;
- class ArgumentEncoder;
+class Decoder;
+class Encoder;
}
namespace WebKit {
@@ -44,8 +45,8 @@ namespace WebKit {
struct PluginProcessCreationParameters {
PluginProcessCreationParameters();
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, PluginProcessCreationParameters&);
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, PluginProcessCreationParameters&);
PluginProcessType processType;
bool supportsAsynchronousPluginInitialization;
@@ -53,8 +54,14 @@ struct PluginProcessCreationParameters {
double minimumLifetime;
double terminationTimeout;
-#if PLATFORM(MAC)
- IPC::MachPort acceleratedCompositingPort;
+#if PLATFORM(COCOA)
+ WebCore::MachSendRight acceleratedCompositingPort;
+#if TARGET_OS_IPHONE || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
+ RetainPtr<CFDataRef> networkATSContext;
+#endif
+#endif
+#if OS(LINUX)
+ IPC::Attachment memoryPressureMonitorHandle;
#endif
};
diff --git a/Source/WebKit2/Shared/Plugins/PluginQuirks.h b/Source/WebKit2/Shared/Plugins/PluginQuirks.h
index e48db58ad..1a0b74021 100644
--- a/Source/WebKit2/Shared/Plugins/PluginQuirks.h
+++ b/Source/WebKit2/Shared/Plugins/PluginQuirks.h
@@ -89,15 +89,11 @@ public:
// freeze when sending right click events to them in windowed mode.
IgnoreRightClickInWindowlessMode,
+ // Some ports don't support windowed plugins.
+ ForceFlashWindowlessMode,
+
// Flash crashes when NPP_GetValue is called for NPPVpluginCancelSrcStream in windowed mode.
DoNotCancelSrcStreamInWindowedMode,
-
- // Windows specific quirks:
-#elif PLUGIN_ARCHITECTURE(WIN)
- // Whether NPN_UserAgent should always return a Mozilla user agent.
- // Flash on Windows prior to version 10 only requests windowless plugins
- // if we return a Mozilla user agent.
- WantsMozillaUserAgent,
#endif
// This isn't really a quirk as much as the opposite of a quirk. By default, we don't send wheel events
diff --git a/Source/WebKit2/Shared/Plugins/unix/PluginSearchPath.cpp b/Source/WebKit2/Shared/Plugins/unix/PluginSearchPath.cpp
new file mode 100644
index 000000000..7e892f00c
--- /dev/null
+++ b/Source/WebKit2/Shared/Plugins/unix/PluginSearchPath.cpp
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2015 Igalia S.L.
+ *
+ * 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 "PluginSearchPath.h"
+
+#include <WebCore/FileSystem.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+Vector<String> pluginsDirectories()
+{
+ Vector<String> result;
+
+#if ENABLE(NETSCAPE_PLUGIN_API)
+ String mozillaPaths(getenv("MOZ_PLUGIN_PATH"));
+ if (!mozillaPaths.isEmpty()) {
+ Vector<String> paths;
+ mozillaPaths.split(UChar(':'), /* allowEmptyEntries */ false, paths);
+ result.appendVector(paths);
+ }
+
+ String mozillaHome(getenv("MOZILLA_HOME"));
+ if (!mozillaHome.isEmpty())
+ result.append(mozillaHome + "/plugins");
+
+ result.append(homeDirectoryPath() + "/.mozilla/plugins");
+ result.append(homeDirectoryPath() + "/.netscape/plugins");
+ result.append("/usr/lib/browser/plugins");
+ result.append("/usr/local/lib/mozilla/plugins");
+ result.append("/usr/lib/firefox/plugins");
+ result.append("/usr/lib64/browser-plugins");
+ result.append("/usr/lib/browser-plugins");
+ result.append("/usr/lib/mozilla/plugins");
+ result.append("/usr/local/netscape/plugins");
+ result.append("/opt/mozilla/plugins");
+ result.append("/opt/mozilla/lib/plugins");
+ result.append("/opt/netscape/plugins");
+ result.append("/opt/netscape/communicator/plugins");
+ result.append("/usr/lib/netscape/plugins");
+ result.append("/usr/lib/netscape/plugins-libc5");
+ result.append("/usr/lib/netscape/plugins-libc6");
+ result.append("/usr/lib64/netscape/plugins");
+ result.append("/usr/lib64/mozilla/plugins");
+ result.append("/usr/lib/nsbrowser/plugins");
+ result.append("/usr/lib64/nsbrowser/plugins");
+#endif
+
+ return result;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/Shared/ConnectionStack.cpp b/Source/WebKit2/Shared/Plugins/unix/PluginSearchPath.h
index 565adf599..25a13ec8e 100644
--- a/Source/WebKit2/Shared/ConnectionStack.cpp
+++ b/Source/WebKit2/Shared/Plugins/unix/PluginSearchPath.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2015 Igalia S.L.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -23,17 +23,16 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "config.h"
-#include "ConnectionStack.h"
+#ifndef PluginSearchPath_h
+#define PluginSearchPath_h
-#include <wtf/NeverDestroyed.h>
+#include <wtf/Forward.h>
+#include <wtf/Vector.h>
namespace WebKit {
-ConnectionStack& ConnectionStack::shared()
-{
- static NeverDestroyed<ConnectionStack> connectionStack;
- return connectionStack;
-}
+Vector<String> pluginsDirectories();
} // namespace WebKit
+
+#endif // PluginSandboxProfile_h
diff --git a/Source/WebKit2/Shared/PrintInfo.cpp b/Source/WebKit2/Shared/PrintInfo.cpp
index bbdcba76a..21b15a39a 100644
--- a/Source/WebKit2/Shared/PrintInfo.cpp
+++ b/Source/WebKit2/Shared/PrintInfo.cpp
@@ -26,9 +26,8 @@
#include "config.h"
#include "PrintInfo.h"
-#include "ArgumentDecoder.h"
-#include "ArgumentEncoder.h"
-#include "Arguments.h"
+#include "Decoder.h"
+#include "Encoder.h"
#if PLATFORM(GTK)
#include "ArgumentCodersGtk.h"
@@ -43,7 +42,7 @@ PrintInfo::PrintInfo()
{
}
-void PrintInfo::encode(IPC::ArgumentEncoder& encoder) const
+void PrintInfo::encode(IPC::Encoder& encoder) const
{
encoder << pageSetupScaleFactor;
encoder << availablePaperWidth;
@@ -56,7 +55,7 @@ void PrintInfo::encode(IPC::ArgumentEncoder& encoder) const
#endif
}
-bool PrintInfo::decode(IPC::ArgumentDecoder& decoder, PrintInfo& info)
+bool PrintInfo::decode(IPC::Decoder& decoder, PrintInfo& info)
{
if (!decoder.decode(info.pageSetupScaleFactor))
return false;
diff --git a/Source/WebKit2/Shared/PrintInfo.h b/Source/WebKit2/Shared/PrintInfo.h
index c037ccfba..0c862339a 100644
--- a/Source/WebKit2/Shared/PrintInfo.h
+++ b/Source/WebKit2/Shared/PrintInfo.h
@@ -26,20 +26,20 @@
#ifndef PrintInfo_h
#define PrintInfo_h
-#if PLATFORM(MAC)
+#if USE(APPKIT)
OBJC_CLASS NSPrintInfo;
#elif PLATFORM(GTK)
typedef struct _GtkPrintSettings GtkPrintSettings;
typedef struct _GtkPageSetup GtkPageSetup;
-#include <wtf/gobject/GRefPtr.h>
+#include <wtf/glib/GRefPtr.h>
#else
// FIXME: This should use the windows equivalent.
class NSPrintInfo;
#endif
namespace IPC {
- class ArgumentDecoder;
- class ArgumentEncoder;
+class Decoder;
+class Encoder;
}
namespace WebKit {
@@ -67,8 +67,8 @@ struct PrintInfo {
PrintMode printMode;
#endif
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, PrintInfo&);
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, PrintInfo&);
};
}
diff --git a/Source/WebKit2/Shared/ProcessExecutablePath.h b/Source/WebKit2/Shared/ProcessExecutablePath.h
index d78ebcdde..b00758410 100644
--- a/Source/WebKit2/Shared/ProcessExecutablePath.h
+++ b/Source/WebKit2/Shared/ProcessExecutablePath.h
@@ -32,10 +32,10 @@ namespace WebKit {
String executablePathOfWebProcess();
String executablePathOfPluginProcess();
-#if ENABLE(NETWORK_PROCESS)
String executablePathOfNetworkProcess();
+#if ENABLE(DATABASE_PROCESS)
+String executablePathOfDatabaseProcess();
#endif
-
}
#endif
diff --git a/Source/WebKit2/Shared/RTCNetwork.cpp b/Source/WebKit2/Shared/RTCNetwork.cpp
new file mode 100644
index 000000000..6cbcacbfa
--- /dev/null
+++ b/Source/WebKit2/Shared/RTCNetwork.cpp
@@ -0,0 +1,217 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#include "config.h"
+#include "RTCNetwork.h"
+
+#if USE(LIBWEBRTC)
+
+#include "DataReference.h"
+#include "WebCoreArgumentCoders.h"
+
+namespace WebKit {
+
+RTCNetwork::RTCNetwork(const rtc::Network& network)
+ : name(network.name())
+ , description(network.description())
+ , prefix { network.prefix() }
+ , prefixLength(network.prefix_length())
+ , type(network.type())
+ , id(network.id())
+ , preference(network.preference())
+ , active(network.active())
+ , ignored(network.ignored())
+ , scopeID(network.scope_id())
+ , ips(network.GetIPs())
+{
+}
+
+rtc::Network RTCNetwork::value() const
+{
+ rtc::Network network(name.data(), description.data(), prefix.value, prefixLength, rtc::AdapterType(type));
+ network.set_id(id);
+ network.set_preference(preference);
+ network.set_active(active);
+ network.set_ignored(ignored);
+ network.set_scope_id(scopeID);
+ network.SetIPs(ips, true);
+ return network;
+}
+
+bool RTCNetwork::IPAddress::decode(IPC::Decoder& decoder, IPAddress& result)
+{
+ int family;
+ if (!decoder.decode(family))
+ return false;
+ IPC::DataReference data;
+ if (!decoder.decode(data))
+ return false;
+ if (family == AF_INET) {
+ if (data.size() != sizeof(in_addr))
+ return false;
+ result.value = rtc::IPAddress(*reinterpret_cast<const in_addr*>(data.data()));
+ return true;
+ }
+ if (data.size() != sizeof(in6_addr))
+ return false;
+ result.value = rtc::IPAddress(*reinterpret_cast<const in6_addr*>(data.data()));
+ return true;
+}
+
+void RTCNetwork::IPAddress::encode(IPC::Encoder& encoder) const
+{
+ encoder << value.family();
+ if (value.family() == AF_INET) {
+ auto address = value.ipv4_address();
+ encoder << IPC::DataReference(reinterpret_cast<const uint8_t*>(&address), sizeof(address));
+ return;
+ }
+ auto address = value.ipv6_address();
+ encoder << IPC::DataReference(reinterpret_cast<const uint8_t*>(&address), sizeof(address));
+}
+
+rtc::SocketAddress RTCNetwork::isolatedCopy(const rtc::SocketAddress& value)
+{
+ rtc::SocketAddress copy;
+ copy.SetPort(value.port());
+ copy.SetScopeID(value.scope_id());
+ copy.SetIP(std::string(value.hostname().data(), value.hostname().size()));
+ if (!value.IsUnresolvedIP())
+ copy.SetResolvedIP(value.ipaddr());
+ return rtc::SocketAddress(copy);
+}
+
+bool RTCNetwork::SocketAddress::decode(IPC::Decoder& decoder, SocketAddress& result)
+{
+ uint16_t port;
+ if (!decoder.decode(port))
+ return false;
+ int scopeId;
+ if (!decoder.decode(scopeId))
+ return false;
+ result.value.SetPort(port);
+ result.value.SetScopeID(scopeId);
+
+ IPC::DataReference hostname;
+ if (!decoder.decode(hostname))
+ return false;
+ result.value.SetIP(std::string(reinterpret_cast<const char*>(hostname.data()), hostname.size()));
+
+ bool isUnresolved;
+ if (!decoder.decode(isUnresolved))
+ return false;
+ if (isUnresolved)
+ return true;
+
+ RTCNetwork::IPAddress ipAddress;
+ if (!decoder.decode(ipAddress))
+ return false;
+ result.value.SetResolvedIP(ipAddress.value);
+ return true;
+}
+
+void RTCNetwork::SocketAddress::encode(IPC::Encoder& encoder) const
+{
+ encoder << value.port();
+ encoder << value.scope_id();
+
+ auto hostname = value.hostname();
+ encoder << IPC::DataReference(reinterpret_cast<const uint8_t*>(hostname.data()), hostname.length());
+
+ encoder << value.IsUnresolvedIP();
+ if (value.IsUnresolvedIP()) {
+ encoder << true;
+ return;
+ }
+ encoder << false;
+ encoder << RTCNetwork::IPAddress(value.ipaddr());
+}
+
+bool RTCNetwork::decode(IPC::Decoder& decoder, RTCNetwork& result)
+{
+ IPC::DataReference name, description;
+ if (!decoder.decode(name))
+ return false;
+ result.name = std::string(reinterpret_cast<const char*>(name.data()), name.size());
+ if (!decoder.decode(description))
+ return false;
+ result.description = std::string(reinterpret_cast<const char*>(description.data()), description.size());
+ if (!decoder.decode(result.prefix))
+ return false;
+ if (!decoder.decode(result.prefixLength))
+ return false;
+ if (!decoder.decode(result.type))
+ return false;
+ if (!decoder.decode(result.id))
+ return false;
+ if (!decoder.decode(result.preference))
+ return false;
+ if (!decoder.decode(result.active))
+ return false;
+ if (!decoder.decode(result.ignored))
+ return false;
+ if (!decoder.decode(result.scopeID))
+ return false;
+
+ uint64_t length;
+ if (!decoder.decode(length))
+ return false;
+ result.ips.reserve(length);
+ for (size_t index = 0; index < length; ++index) {
+ IPAddress address;
+ if (!decoder.decode(address))
+ return false;
+ int flags;
+ if (!decoder.decode(flags))
+ return false;
+ result.ips.push_back({ address.value, flags });
+ }
+ return true;
+}
+
+void RTCNetwork::encode(IPC::Encoder& encoder) const
+{
+ encoder << IPC::DataReference(reinterpret_cast<const uint8_t*>(name.data()), name.length());
+ encoder << IPC::DataReference(reinterpret_cast<const uint8_t*>(description.data()), description.length());
+ encoder << prefix;
+ encoder << prefixLength;
+ encoder << type;
+
+ encoder << id;
+ encoder << preference;
+ encoder << active;
+ encoder << ignored;
+ encoder << scopeID;
+
+ encoder << (uint64_t)ips.size();
+ for (auto& ip : ips) {
+ encoder << IPAddress { ip };
+ encoder << ip.ipv6_flags();
+ }
+}
+
+}
+
+#endif // USE(LIBWEBRTC)
diff --git a/Source/WebKit2/Shared/ConnectionStack.h b/Source/WebKit2/Shared/RTCNetwork.h
index bd753a0e8..a030a1aeb 100644
--- a/Source/WebKit2/Shared/ConnectionStack.h
+++ b/Source/WebKit2/Shared/RTCNetwork.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -23,57 +23,67 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef ConnectionStack_h
-#define ConnectionStack_h
+#pragma once
-#include <wtf/Vector.h>
+#if USE(LIBWEBRTC)
+
+#include <WebCore/LibWebRTCMacros.h>
+#include <webrtc/base/network.h>
+#include <wtf/Forward.h>
namespace IPC {
- class Connection;
+class Decoder;
+class Encoder;
}
namespace WebKit {
-class ConnectionStack {
-public:
- static ConnectionStack& shared();
-
- IPC::Connection* current()
- {
- return m_connectionStack.last();
- }
-
- class CurrentConnectionPusher {
- public:
- CurrentConnectionPusher(ConnectionStack& connectionStack, IPC::Connection* connection)
- : m_connectionStack(connectionStack)
-#if !ASSERT_DISABLED
- , m_connection(connection)
-#endif
- {
- m_connectionStack.m_connectionStack.append(connection);
- }
-
- ~CurrentConnectionPusher()
- {
- ASSERT(m_connectionStack.current() == m_connection);
- m_connectionStack.m_connectionStack.removeLast();
- }
-
- private:
- ConnectionStack& m_connectionStack;
-#if !ASSERT_DISABLED
- IPC::Connection* m_connection;
-#endif
+struct RTCNetwork {
+ RTCNetwork() = default;
+ explicit RTCNetwork(const rtc::Network&);
+
+ rtc::Network value() const;
+
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, RTCNetwork&);
+
+ struct IPAddress {
+ IPAddress() = default;
+ explicit IPAddress(const rtc::IPAddress& address): value(address) { }
+
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, IPAddress&);
+
+ rtc::IPAddress value;
};
-private:
- // It's OK for these to be weak pointers because we only push object on the stack
- // from within didReceiveMessage and didReceiveSyncMessage and the Connection objects are
- // already ref'd for the duration of those functions.
- Vector<IPC::Connection*, 4> m_connectionStack;
+ static rtc::SocketAddress isolatedCopy(const rtc::SocketAddress&);
+
+ struct SocketAddress {
+ SocketAddress() = default;
+ explicit SocketAddress(const rtc::SocketAddress& address): value(address) { }
+
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, SocketAddress&);
+
+ rtc::SocketAddress value;
+ };
+
+ std::string name;
+ std::string description;
+ IPAddress prefix;
+ int prefixLength;
+ int type;
+ uint16_t id;
+ int preference;
+ bool active;
+ bool ignored;
+ int scopeID;
+ std::string key;
+ size_t length;
+ std::vector<rtc::InterfaceAddress> ips;
};
-} // namespace WebKit
+}
-#endif // ConnectionStack_h
+#endif // USE(LIBWEBRTC)
diff --git a/Source/WebKit2/Shared/SandboxExtension.h b/Source/WebKit2/Shared/SandboxExtension.h
index 06c687304..51057e498 100644
--- a/Source/WebKit2/Shared/SandboxExtension.h
+++ b/Source/WebKit2/Shared/SandboxExtension.h
@@ -28,17 +28,17 @@
#include <wtf/Forward.h>
#include <wtf/Noncopyable.h>
-#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
#include <wtf/text/WTFString.h>
-#if ENABLE(WEB_PROCESS_SANDBOX)
+#if ENABLE(SANDBOX_EXTENSIONS)
typedef struct __WKSandboxExtension* WKSandboxExtensionRef;
#endif
namespace IPC {
- class ArgumentEncoder;
- class ArgumentDecoder;
+class Encoder;
+class Decoder;
}
namespace WebKit {
@@ -47,41 +47,42 @@ class SandboxExtension : public RefCounted<SandboxExtension> {
public:
enum Type {
ReadOnly,
- ReadWrite
+ ReadWrite,
+ Generic,
};
class Handle {
WTF_MAKE_NONCOPYABLE(Handle);
-
public:
Handle();
+ Handle(Handle&&) = default;
~Handle();
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, Handle&);
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, Handle&);
private:
friend class SandboxExtension;
-#if ENABLE(WEB_PROCESS_SANDBOX)
+#if ENABLE(SANDBOX_EXTENSIONS)
mutable WKSandboxExtensionRef m_sandboxExtension;
#endif
};
class HandleArray {
WTF_MAKE_NONCOPYABLE(HandleArray);
-
public:
HandleArray();
+ HandleArray(HandleArray&&) = default;
~HandleArray();
void allocate(size_t);
Handle& operator[](size_t i);
const Handle& operator[](size_t i) const;
size_t size() const;
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, HandleArray&);
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, HandleArray&);
private:
-#if ENABLE(WEB_PROCESS_SANDBOX)
+#if ENABLE(SANDBOX_EXTENSIONS)
std::unique_ptr<Handle[]> m_data;
size_t m_size;
#else
@@ -89,10 +90,12 @@ public:
#endif
};
- static PassRefPtr<SandboxExtension> create(const Handle&);
- static void createHandle(const String& path, Type type, Handle&);
- static void createHandleForReadWriteDirectory(const String& path, Handle&); // Will attempt to create the directory.
- static String createHandleForTemporaryFile(const String& prefix, Type type, Handle&);
+ static RefPtr<SandboxExtension> create(const Handle&);
+ static bool createHandle(const String& path, Type, Handle&);
+ static bool createHandleWithoutResolvingPath(const String& path, Type, Handle&);
+ static bool createHandleForReadWriteDirectory(const String& path, Handle&); // Will attempt to create the directory.
+ static String createHandleForTemporaryFile(const String& prefix, Type, Handle&);
+ static bool createHandleForGenericExtension(const String& extensionClass, Handle&);
~SandboxExtension();
bool consume();
@@ -104,34 +107,43 @@ public:
private:
explicit SandboxExtension(const Handle&);
-#if ENABLE(WEB_PROCESS_SANDBOX)
+#if ENABLE(SANDBOX_EXTENSIONS)
mutable WKSandboxExtensionRef m_sandboxExtension;
size_t m_useCount;
#endif
};
-#if !ENABLE(WEB_PROCESS_SANDBOX)
+#if !ENABLE(SANDBOX_EXTENSIONS)
inline SandboxExtension::Handle::Handle() { }
inline SandboxExtension::Handle::~Handle() { }
-inline void SandboxExtension::Handle::encode(IPC::ArgumentEncoder&) const { }
-inline bool SandboxExtension::Handle::decode(IPC::ArgumentDecoder&, Handle&) { return true; }
+inline void SandboxExtension::Handle::encode(IPC::Encoder&) const { }
+inline bool SandboxExtension::Handle::decode(IPC::Decoder&, Handle&) { return true; }
inline SandboxExtension::HandleArray::HandleArray() { }
inline SandboxExtension::HandleArray::~HandleArray() { }
inline void SandboxExtension::HandleArray::allocate(size_t) { }
inline size_t SandboxExtension::HandleArray::size() const { return 0; }
inline const SandboxExtension::Handle& SandboxExtension::HandleArray::operator[](size_t) const { return m_emptyHandle; }
inline SandboxExtension::Handle& SandboxExtension::HandleArray::operator[](size_t) { return m_emptyHandle; }
-inline void SandboxExtension::HandleArray::encode(IPC::ArgumentEncoder&) const { }
-inline bool SandboxExtension::HandleArray::decode(IPC::ArgumentDecoder&, HandleArray&) { return true; }
-inline PassRefPtr<SandboxExtension> SandboxExtension::create(const Handle&) { return 0; }
-inline void SandboxExtension::createHandle(const String&, Type, Handle&) { }
-inline void SandboxExtension::createHandleForReadWriteDirectory(const String&, Handle&) { }
+inline void SandboxExtension::HandleArray::encode(IPC::Encoder&) const { }
+inline bool SandboxExtension::HandleArray::decode(IPC::Decoder&, HandleArray&) { return true; }
+inline RefPtr<SandboxExtension> SandboxExtension::create(const Handle&) { return nullptr; }
+inline bool SandboxExtension::createHandle(const String&, Type, Handle&) { return true; }
+inline bool SandboxExtension::createHandleWithoutResolvingPath(const String&, Type, Handle&) { return true; }
+inline bool SandboxExtension::createHandleForReadWriteDirectory(const String&, Handle&) { return true; }
inline String SandboxExtension::createHandleForTemporaryFile(const String& /*prefix*/, Type, Handle&) {return String();}
+inline bool SandboxExtension::createHandleForGenericExtension(const String& /*extensionClass*/, Handle&) { return true; }
inline SandboxExtension::~SandboxExtension() { }
inline bool SandboxExtension::revoke() { return true; }
inline bool SandboxExtension::consume() { return true; }
inline bool SandboxExtension::consumePermanently() { return true; }
inline bool SandboxExtension::consumePermanently(const Handle&) { return true; }
+inline String stringByResolvingSymlinksInPath(const String& path) { return path; }
+inline String resolvePathForSandboxExtension(const String& path) { return path; }
+inline String resolveAndCreateReadWriteDirectoryForSandboxExtension(const String& path) { return path; }
+#else
+String stringByResolvingSymlinksInPath(const String& path);
+String resolvePathForSandboxExtension(const String& path);
+String resolveAndCreateReadWriteDirectoryForSandboxExtension(const String& path);
#endif
} // namespace WebKit
diff --git a/Source/WebKit2/Shared/SandboxInitializationParameters.h b/Source/WebKit2/Shared/SandboxInitializationParameters.h
index a6621c546..a619b7004 100644
--- a/Source/WebKit2/Shared/SandboxInitializationParameters.h
+++ b/Source/WebKit2/Shared/SandboxInitializationParameters.h
@@ -29,7 +29,7 @@
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
OBJC_CLASS NSString;
#endif
@@ -41,7 +41,7 @@ public:
SandboxInitializationParameters();
~SandboxInitializationParameters();
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
// Name must be a literal.
void addConfDirectoryParameter(const char* name, int confID);
void addPathParameter(const char* name, NSString *path);
@@ -86,23 +86,23 @@ public:
return m_overrideSandboxProfilePathOrSandboxProfile;
}
- void setSystemDirectorySuffix(const String& suffix) { m_systemDirectorySuffix = suffix; }
- const String& systemDirectorySuffix() const { return m_systemDirectorySuffix; }
+ void setUserDirectorySuffix(const String& suffix) { m_userDirectorySuffix = suffix; }
+ const String& userDirectorySuffix() const { return m_userDirectorySuffix; }
#endif
private:
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
void appendPathInternal(const char* name, const char* path);
mutable Vector<const char*> m_namedParameters;
- String m_systemDirectorySuffix;
+ String m_userDirectorySuffix;
ProfileSelectionMode m_profileSelectionMode;
String m_overrideSandboxProfilePathOrSandboxProfile;
#endif
};
-#if !PLATFORM(MAC)
+#if !PLATFORM(COCOA)
SandboxInitializationParameters::SandboxInitializationParameters()
{
}
diff --git a/Source/WebKit2/Shared/Scrolling/RemoteScrollingCoordinatorTransaction.cpp b/Source/WebKit2/Shared/Scrolling/RemoteScrollingCoordinatorTransaction.cpp
new file mode 100644
index 000000000..a055701a4
--- /dev/null
+++ b/Source/WebKit2/Shared/Scrolling/RemoteScrollingCoordinatorTransaction.cpp
@@ -0,0 +1,665 @@
+/*
+ * Copyright (C) 2014-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.
+ *
+ * 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 "RemoteScrollingCoordinatorTransaction.h"
+
+#include "ArgumentCoders.h"
+#include "WebCoreArgumentCoders.h"
+#include <WebCore/GraphicsLayer.h>
+#include <WebCore/ScrollingStateFixedNode.h>
+#include <WebCore/ScrollingStateFrameScrollingNode.h>
+#include <WebCore/ScrollingStateOverflowScrollingNode.h>
+#include <WebCore/ScrollingStateStickyNode.h>
+#include <WebCore/ScrollingStateTree.h>
+#include <WebCore/TextStream.h>
+#include <wtf/HashMap.h>
+#include <wtf/text/CString.h>
+
+using namespace WebCore;
+
+#if ENABLE(ASYNC_SCROLLING)
+
+namespace IPC {
+
+template<> struct ArgumentCoder<ScrollingStateNode> {
+ static void encode(Encoder&, const ScrollingStateNode&);
+ static bool decode(Decoder&, ScrollingStateNode&);
+};
+
+template<> struct ArgumentCoder<ScrollingStateScrollingNode> {
+ static void encode(Encoder&, const ScrollingStateScrollingNode&);
+ static bool decode(Decoder&, ScrollingStateScrollingNode&);
+};
+
+template<> struct ArgumentCoder<ScrollingStateFrameScrollingNode> {
+ static void encode(Encoder&, const ScrollingStateFrameScrollingNode&);
+ static bool decode(Decoder&, ScrollingStateFrameScrollingNode&);
+};
+
+template<> struct ArgumentCoder<ScrollingStateOverflowScrollingNode> {
+ static void encode(Encoder&, const ScrollingStateOverflowScrollingNode&);
+ static bool decode(Decoder&, ScrollingStateOverflowScrollingNode&);
+};
+
+template<> struct ArgumentCoder<ScrollingStateFixedNode> {
+ static void encode(Encoder&, const ScrollingStateFixedNode&);
+ static bool decode(Decoder&, ScrollingStateFixedNode&);
+};
+
+template<> struct ArgumentCoder<ScrollingStateStickyNode> {
+ static void encode(Encoder&, const ScrollingStateStickyNode&);
+ static bool decode(Decoder&, ScrollingStateStickyNode&);
+};
+
+} // namespace IPC
+
+using namespace IPC;
+
+void ArgumentCoder<ScrollingStateNode>::encode(Encoder& encoder, const ScrollingStateNode& node)
+{
+ encoder.encodeEnum(node.nodeType());
+ encoder << node.scrollingNodeID();
+ encoder << node.parentNodeID();
+ encoder << node.changedProperties();
+
+ if (node.hasChangedProperty(ScrollingStateNode::ScrollLayer))
+ encoder << static_cast<GraphicsLayer::PlatformLayerID>(node.layer());
+}
+
+bool ArgumentCoder<ScrollingStateNode>::decode(Decoder& decoder, ScrollingStateNode& node)
+{
+ // nodeType, scrollingNodeID and parentNodeID have already been decoded by the caller in order to create the node.
+ ScrollingStateNode::ChangedProperties changedProperties;
+ if (!decoder.decode(changedProperties))
+ return false;
+
+ node.setChangedProperties(changedProperties);
+ if (node.hasChangedProperty(ScrollingStateNode::ScrollLayer)) {
+ GraphicsLayer::PlatformLayerID layerID;
+ if (!decoder.decode(layerID))
+ return false;
+ node.setLayer(layerID);
+ }
+
+ return true;
+}
+
+#define SCROLLING_NODE_ENCODE(property, getter) \
+ if (node.hasChangedProperty(property)) \
+ encoder << node.getter();
+
+#define SCROLLING_NODE_ENCODE_ENUM(property, getter) \
+ if (node.hasChangedProperty(property)) \
+ encoder.encodeEnum(node.getter());
+
+void ArgumentCoder<ScrollingStateScrollingNode>::encode(Encoder& encoder, const ScrollingStateScrollingNode& node)
+{
+ encoder << static_cast<const ScrollingStateNode&>(node);
+
+ SCROLLING_NODE_ENCODE(ScrollingStateScrollingNode::ScrollableAreaSize, scrollableAreaSize)
+ SCROLLING_NODE_ENCODE(ScrollingStateScrollingNode::TotalContentsSize, totalContentsSize)
+ SCROLLING_NODE_ENCODE(ScrollingStateScrollingNode::ReachableContentsSize, reachableContentsSize)
+ SCROLLING_NODE_ENCODE(ScrollingStateScrollingNode::ScrollPosition, scrollPosition)
+ SCROLLING_NODE_ENCODE(ScrollingStateScrollingNode::ScrollOrigin, scrollOrigin)
+#if ENABLE(CSS_SCROLL_SNAP)
+ SCROLLING_NODE_ENCODE(ScrollingStateScrollingNode::HorizontalSnapOffsets, horizontalSnapOffsets)
+ SCROLLING_NODE_ENCODE(ScrollingStateScrollingNode::VerticalSnapOffsets, verticalSnapOffsets)
+ SCROLLING_NODE_ENCODE(ScrollingStateScrollingNode::HorizontalSnapOffsetRanges, horizontalSnapOffsetRanges)
+ SCROLLING_NODE_ENCODE(ScrollingStateScrollingNode::VerticalSnapOffsetRanges, verticalSnapOffsetRanges)
+ SCROLLING_NODE_ENCODE(ScrollingStateScrollingNode::CurrentHorizontalSnapOffsetIndex, currentHorizontalSnapPointIndex)
+ SCROLLING_NODE_ENCODE(ScrollingStateScrollingNode::CurrentVerticalSnapOffsetIndex, currentVerticalSnapPointIndex)
+#endif
+ SCROLLING_NODE_ENCODE(ScrollingStateScrollingNode::ScrollableAreaParams, scrollableAreaParameters)
+ SCROLLING_NODE_ENCODE(ScrollingStateScrollingNode::RequestedScrollPosition, requestedScrollPosition)
+ SCROLLING_NODE_ENCODE(ScrollingStateScrollingNode::RequestedScrollPosition, requestedScrollPositionRepresentsProgrammaticScroll)
+}
+
+void ArgumentCoder<ScrollingStateFrameScrollingNode>::encode(Encoder& encoder, const ScrollingStateFrameScrollingNode& node)
+{
+ encoder << static_cast<const ScrollingStateScrollingNode&>(node);
+
+ SCROLLING_NODE_ENCODE(ScrollingStateFrameScrollingNode::FrameScaleFactor, frameScaleFactor)
+ SCROLLING_NODE_ENCODE(ScrollingStateFrameScrollingNode::EventTrackingRegion, eventTrackingRegions)
+ SCROLLING_NODE_ENCODE(ScrollingStateFrameScrollingNode::ReasonsForSynchronousScrolling, synchronousScrollingReasons)
+ SCROLLING_NODE_ENCODE_ENUM(ScrollingStateFrameScrollingNode::BehaviorForFixedElements, scrollBehaviorForFixedElements)
+ SCROLLING_NODE_ENCODE(ScrollingStateFrameScrollingNode::HeaderHeight, headerHeight)
+ SCROLLING_NODE_ENCODE(ScrollingStateFrameScrollingNode::FooterHeight, footerHeight)
+ SCROLLING_NODE_ENCODE(ScrollingStateFrameScrollingNode::TopContentInset, topContentInset)
+ SCROLLING_NODE_ENCODE(ScrollingStateFrameScrollingNode::FixedElementsLayoutRelativeToFrame, fixedElementsLayoutRelativeToFrame)
+ SCROLLING_NODE_ENCODE(ScrollingStateFrameScrollingNode::VisualViewportEnabled, visualViewportEnabled)
+ SCROLLING_NODE_ENCODE(ScrollingStateFrameScrollingNode::LayoutViewport, layoutViewport)
+ SCROLLING_NODE_ENCODE(ScrollingStateFrameScrollingNode::MinLayoutViewportOrigin, minLayoutViewportOrigin)
+ SCROLLING_NODE_ENCODE(ScrollingStateFrameScrollingNode::MaxLayoutViewportOrigin, maxLayoutViewportOrigin)
+
+ if (node.hasChangedProperty(ScrollingStateFrameScrollingNode::ScrolledContentsLayer))
+ encoder << static_cast<GraphicsLayer::PlatformLayerID>(node.scrolledContentsLayer());
+
+ if (node.hasChangedProperty(ScrollingStateFrameScrollingNode::CounterScrollingLayer))
+ encoder << static_cast<GraphicsLayer::PlatformLayerID>(node.counterScrollingLayer());
+
+ if (node.hasChangedProperty(ScrollingStateFrameScrollingNode::InsetClipLayer))
+ encoder << static_cast<GraphicsLayer::PlatformLayerID>(node.insetClipLayer());
+
+ if (node.hasChangedProperty(ScrollingStateFrameScrollingNode::ContentShadowLayer))
+ encoder << static_cast<GraphicsLayer::PlatformLayerID>(node.contentShadowLayer());
+}
+
+void ArgumentCoder<ScrollingStateOverflowScrollingNode>::encode(Encoder& encoder, const ScrollingStateOverflowScrollingNode& node)
+{
+ encoder << static_cast<const ScrollingStateScrollingNode&>(node);
+
+ if (node.hasChangedProperty(ScrollingStateOverflowScrollingNode::ScrolledContentsLayer))
+ encoder << static_cast<GraphicsLayer::PlatformLayerID>(node.scrolledContentsLayer());
+}
+
+#define SCROLLING_NODE_DECODE(property, type, setter) \
+ if (node.hasChangedProperty(property)) { \
+ type decodedValue; \
+ if (!decoder.decode(decodedValue)) \
+ return false; \
+ node.setter(decodedValue); \
+ }
+
+#define SCROLLING_NODE_DECODE_ENUM(property, type, setter) \
+ if (node.hasChangedProperty(property)) { \
+ type decodedValue; \
+ if (!decoder.decodeEnum(decodedValue)) \
+ return false; \
+ node.setter(decodedValue); \
+ }
+
+bool ArgumentCoder<ScrollingStateScrollingNode>::decode(Decoder& decoder, ScrollingStateScrollingNode& node)
+{
+ if (!decoder.decode(static_cast<ScrollingStateNode&>(node)))
+ return false;
+
+ SCROLLING_NODE_DECODE(ScrollingStateScrollingNode::ScrollableAreaSize, FloatSize, setScrollableAreaSize);
+ SCROLLING_NODE_DECODE(ScrollingStateScrollingNode::TotalContentsSize, FloatSize, setTotalContentsSize);
+ SCROLLING_NODE_DECODE(ScrollingStateScrollingNode::ReachableContentsSize, FloatSize, setReachableContentsSize);
+ SCROLLING_NODE_DECODE(ScrollingStateScrollingNode::ScrollPosition, FloatPoint, setScrollPosition);
+ SCROLLING_NODE_DECODE(ScrollingStateScrollingNode::ScrollOrigin, IntPoint, setScrollOrigin);
+#if ENABLE(CSS_SCROLL_SNAP)
+ SCROLLING_NODE_DECODE(ScrollingStateScrollingNode::HorizontalSnapOffsets, Vector<float>, setHorizontalSnapOffsets);
+ SCROLLING_NODE_DECODE(ScrollingStateScrollingNode::VerticalSnapOffsets, Vector<float>, setVerticalSnapOffsets);
+ SCROLLING_NODE_DECODE(ScrollingStateScrollingNode::HorizontalSnapOffsetRanges, Vector<ScrollOffsetRange<float>>, setHorizontalSnapOffsetRanges)
+ SCROLLING_NODE_DECODE(ScrollingStateScrollingNode::VerticalSnapOffsetRanges, Vector<ScrollOffsetRange<float>>, setVerticalSnapOffsetRanges)
+ SCROLLING_NODE_DECODE(ScrollingStateScrollingNode::CurrentHorizontalSnapOffsetIndex, unsigned, setCurrentHorizontalSnapPointIndex);
+ SCROLLING_NODE_DECODE(ScrollingStateScrollingNode::CurrentVerticalSnapOffsetIndex, unsigned, setCurrentVerticalSnapPointIndex);
+#endif
+ SCROLLING_NODE_DECODE(ScrollingStateScrollingNode::ScrollableAreaParams, ScrollableAreaParameters, setScrollableAreaParameters);
+
+ if (node.hasChangedProperty(ScrollingStateScrollingNode::RequestedScrollPosition)) {
+ FloatPoint scrollPosition;
+ if (!decoder.decode(scrollPosition))
+ return false;
+
+ bool representsProgrammaticScroll;
+ if (!decoder.decode(representsProgrammaticScroll))
+ return false;
+
+ node.setRequestedScrollPosition(scrollPosition, representsProgrammaticScroll);
+ }
+
+ return true;
+}
+
+bool ArgumentCoder<ScrollingStateFrameScrollingNode>::decode(Decoder& decoder, ScrollingStateFrameScrollingNode& node)
+{
+ if (!decoder.decode(static_cast<ScrollingStateScrollingNode&>(node)))
+ return false;
+
+ SCROLLING_NODE_DECODE(ScrollingStateFrameScrollingNode::FrameScaleFactor, float, setFrameScaleFactor);
+ SCROLLING_NODE_DECODE(ScrollingStateFrameScrollingNode::EventTrackingRegion, EventTrackingRegions, setEventTrackingRegions);
+ SCROLLING_NODE_DECODE(ScrollingStateFrameScrollingNode::ReasonsForSynchronousScrolling, SynchronousScrollingReasons, setSynchronousScrollingReasons);
+ SCROLLING_NODE_DECODE_ENUM(ScrollingStateFrameScrollingNode::BehaviorForFixedElements, ScrollBehaviorForFixedElements, setScrollBehaviorForFixedElements);
+
+ SCROLLING_NODE_DECODE(ScrollingStateFrameScrollingNode::HeaderHeight, int, setHeaderHeight);
+ SCROLLING_NODE_DECODE(ScrollingStateFrameScrollingNode::FooterHeight, int, setFooterHeight);
+ SCROLLING_NODE_DECODE(ScrollingStateFrameScrollingNode::TopContentInset, float, setTopContentInset);
+ SCROLLING_NODE_DECODE(ScrollingStateFrameScrollingNode::FixedElementsLayoutRelativeToFrame, bool, setFixedElementsLayoutRelativeToFrame);
+ SCROLLING_NODE_DECODE(ScrollingStateFrameScrollingNode::VisualViewportEnabled, bool, setVisualViewportEnabled)
+ SCROLLING_NODE_DECODE(ScrollingStateFrameScrollingNode::LayoutViewport, FloatRect, setLayoutViewport)
+ SCROLLING_NODE_DECODE(ScrollingStateFrameScrollingNode::MinLayoutViewportOrigin, FloatPoint, setMinLayoutViewportOrigin)
+ SCROLLING_NODE_DECODE(ScrollingStateFrameScrollingNode::MaxLayoutViewportOrigin, FloatPoint, setMaxLayoutViewportOrigin)
+
+ if (node.hasChangedProperty(ScrollingStateFrameScrollingNode::ScrolledContentsLayer)) {
+ GraphicsLayer::PlatformLayerID layerID;
+ if (!decoder.decode(layerID))
+ return false;
+ node.setScrolledContentsLayer(layerID);
+ }
+
+ if (node.hasChangedProperty(ScrollingStateFrameScrollingNode::CounterScrollingLayer)) {
+ GraphicsLayer::PlatformLayerID layerID;
+ if (!decoder.decode(layerID))
+ return false;
+ node.setCounterScrollingLayer(layerID);
+ }
+
+ if (node.hasChangedProperty(ScrollingStateFrameScrollingNode::InsetClipLayer)) {
+ GraphicsLayer::PlatformLayerID layerID;
+ if (!decoder.decode(layerID))
+ return false;
+ node.setInsetClipLayer(layerID);
+ }
+
+ if (node.hasChangedProperty(ScrollingStateFrameScrollingNode::ContentShadowLayer)) {
+ GraphicsLayer::PlatformLayerID layerID;
+ if (!decoder.decode(layerID))
+ return false;
+ node.setContentShadowLayer(layerID);
+ }
+
+ return true;
+}
+
+bool ArgumentCoder<ScrollingStateOverflowScrollingNode>::decode(Decoder& decoder, ScrollingStateOverflowScrollingNode& node)
+{
+ if (!decoder.decode(static_cast<ScrollingStateScrollingNode&>(node)))
+ return false;
+
+ if (node.hasChangedProperty(ScrollingStateOverflowScrollingNode::ScrolledContentsLayer)) {
+ GraphicsLayer::PlatformLayerID layerID;
+ if (!decoder.decode(layerID))
+ return false;
+ node.setScrolledContentsLayer(layerID);
+ }
+
+ return true;
+}
+
+void ArgumentCoder<ScrollingStateFixedNode>::encode(Encoder& encoder, const ScrollingStateFixedNode& node)
+{
+ encoder << static_cast<const ScrollingStateNode&>(node);
+
+ if (node.hasChangedProperty(ScrollingStateFixedNode::ViewportConstraints))
+ encoder << node.viewportConstraints();
+}
+
+bool ArgumentCoder<ScrollingStateFixedNode>::decode(Decoder& decoder, ScrollingStateFixedNode& node)
+{
+ if (!decoder.decode(static_cast<ScrollingStateNode&>(node)))
+ return false;
+
+ if (node.hasChangedProperty(ScrollingStateFixedNode::ViewportConstraints)) {
+ FixedPositionViewportConstraints decodedValue;
+ if (!decoder.decode(decodedValue))
+ return false;
+ node.updateConstraints(decodedValue);
+ }
+
+ return true;
+}
+
+void ArgumentCoder<ScrollingStateStickyNode>::encode(Encoder& encoder, const ScrollingStateStickyNode& node)
+{
+ encoder << static_cast<const ScrollingStateNode&>(node);
+
+ if (node.hasChangedProperty(ScrollingStateStickyNode::ViewportConstraints))
+ encoder << node.viewportConstraints();
+}
+
+bool ArgumentCoder<ScrollingStateStickyNode>::decode(Decoder& decoder, ScrollingStateStickyNode& node)
+{
+ if (!decoder.decode(static_cast<ScrollingStateNode&>(node)))
+ return false;
+
+ if (node.hasChangedProperty(ScrollingStateStickyNode::ViewportConstraints)) {
+ StickyPositionViewportConstraints decodedValue;
+ if (!decoder.decode(decodedValue))
+ return false;
+ node.updateConstraints(decodedValue);
+ }
+
+ return true;
+}
+
+namespace WebKit {
+
+static void encodeNodeAndDescendants(IPC::Encoder& encoder, const ScrollingStateNode& stateNode, int& encodedNodeCount)
+{
+ ++encodedNodeCount;
+
+ switch (stateNode.nodeType()) {
+ case FrameScrollingNode:
+ encoder << downcast<ScrollingStateFrameScrollingNode>(stateNode);
+ break;
+ case OverflowScrollingNode:
+ encoder << downcast<ScrollingStateOverflowScrollingNode>(stateNode);
+ break;
+ case FixedNode:
+ encoder << downcast<ScrollingStateFixedNode>(stateNode);
+ break;
+ case StickyNode:
+ encoder << downcast<ScrollingStateStickyNode>(stateNode);
+ break;
+ }
+
+ if (!stateNode.children())
+ return;
+
+ for (const auto& child : *stateNode.children())
+ encodeNodeAndDescendants(encoder, *child.get(), encodedNodeCount);
+}
+
+void RemoteScrollingCoordinatorTransaction::encode(IPC::Encoder& encoder) const
+{
+ int numNodes = m_scrollingStateTree ? m_scrollingStateTree->nodeCount() : 0;
+ encoder << numNodes;
+
+ bool hasNewRootNode = m_scrollingStateTree ? m_scrollingStateTree->hasNewRootStateNode() : false;
+ encoder << hasNewRootNode;
+
+ if (m_scrollingStateTree) {
+ encoder << m_scrollingStateTree->hasChangedProperties();
+
+ int numNodesEncoded = 0;
+ if (const ScrollingStateNode* rootNode = m_scrollingStateTree->rootStateNode())
+ encodeNodeAndDescendants(encoder, *rootNode, numNodesEncoded);
+
+ ASSERT_UNUSED(numNodesEncoded, numNodesEncoded == numNodes);
+ encoder << m_scrollingStateTree->removedNodes();
+ } else
+ encoder << Vector<ScrollingNodeID>();
+}
+
+bool RemoteScrollingCoordinatorTransaction::decode(IPC::Decoder& decoder, RemoteScrollingCoordinatorTransaction& transaction)
+{
+ return transaction.decode(decoder);
+}
+
+bool RemoteScrollingCoordinatorTransaction::decode(IPC::Decoder& decoder)
+{
+ int numNodes;
+ if (!decoder.decode(numNodes))
+ return false;
+
+ bool hasNewRootNode;
+ if (!decoder.decode(hasNewRootNode))
+ return false;
+
+ m_scrollingStateTree = std::make_unique<ScrollingStateTree>();
+
+ bool hasChangedProperties;
+ if (!decoder.decode(hasChangedProperties))
+ return false;
+
+ m_scrollingStateTree->setHasChangedProperties(hasChangedProperties);
+
+ for (int i = 0; i < numNodes; ++i) {
+ ScrollingNodeType nodeType;
+ if (!decoder.decodeEnum(nodeType))
+ return false;
+
+ ScrollingNodeID nodeID;
+ if (!decoder.decode(nodeID))
+ return false;
+
+ ScrollingNodeID parentNodeID;
+ if (!decoder.decode(parentNodeID))
+ return false;
+
+ m_scrollingStateTree->attachNode(nodeType, nodeID, parentNodeID);
+ ScrollingStateNode* newNode = m_scrollingStateTree->stateNodeForID(nodeID);
+ ASSERT(newNode);
+ ASSERT(!parentNodeID || newNode->parent());
+
+ switch (nodeType) {
+ case FrameScrollingNode:
+ if (!decoder.decode(downcast<ScrollingStateFrameScrollingNode>(*newNode)))
+ return false;
+ break;
+ case OverflowScrollingNode:
+ if (!decoder.decode(downcast<ScrollingStateOverflowScrollingNode>(*newNode)))
+ return false;
+ break;
+ case FixedNode:
+ if (!decoder.decode(downcast<ScrollingStateFixedNode>(*newNode)))
+ return false;
+ break;
+ case StickyNode:
+ if (!decoder.decode(downcast<ScrollingStateStickyNode>(*newNode)))
+ return false;
+ break;
+ }
+ }
+
+ m_scrollingStateTree->setHasNewRootStateNode(hasNewRootNode);
+
+ // Removed nodes
+ HashSet<ScrollingNodeID> removedNodes;
+ if (!decoder.decode(removedNodes))
+ return false;
+
+ if (removedNodes.size())
+ m_scrollingStateTree->setRemovedNodes(removedNodes);
+
+ return true;
+}
+
+#if !defined(NDEBUG) || !LOG_DISABLED
+
+static void dump(TextStream& ts, const ScrollingStateScrollingNode& node, bool changedPropertiesOnly)
+{
+ if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateScrollingNode::ScrollableAreaSize))
+ ts.dumpProperty("scrollable-area-size", node.scrollableAreaSize());
+
+ if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateScrollingNode::TotalContentsSize))
+ ts.dumpProperty("total-contents-size", node.totalContentsSize());
+
+ if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateScrollingNode::ReachableContentsSize))
+ ts.dumpProperty("reachable-contents-size", node.reachableContentsSize());
+
+ if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateScrollingNode::ScrollPosition))
+ ts.dumpProperty("scroll-position", node.scrollPosition());
+
+ if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateScrollingNode::ScrollOrigin))
+ ts.dumpProperty("scroll-origin", node.scrollOrigin());
+
+ if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateScrollingNode::RequestedScrollPosition)) {
+ ts.dumpProperty("requested-scroll-position", node.requestedScrollPosition());
+ ts.dumpProperty("requested-scroll-position-is-programatic", node.requestedScrollPositionRepresentsProgrammaticScroll());
+ }
+}
+
+static void dump(TextStream& ts, const ScrollingStateFrameScrollingNode& node, bool changedPropertiesOnly)
+{
+ dump(ts, static_cast<const ScrollingStateScrollingNode&>(node), changedPropertiesOnly);
+
+ if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateFrameScrollingNode::FrameScaleFactor))
+ ts.dumpProperty("frame-scale-factor", node.frameScaleFactor());
+
+ if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateFrameScrollingNode::EventTrackingRegion)) {
+ {
+ TextStream::GroupScope group(ts);
+ ts << "asynchronous-event-tracking-region";
+ for (auto rect : node.eventTrackingRegions().asynchronousDispatchRegion.rects()) {
+ ts << "\n";
+ ts.writeIndent();
+ ts << rect;
+ }
+ }
+ for (const auto& synchronousEventRegion : node.eventTrackingRegions().eventSpecificSynchronousDispatchRegions) {
+ TextStream::GroupScope group(ts);
+ ts << "synchronous-event-tracking-region for event " << synchronousEventRegion.key;
+
+ for (auto rect : synchronousEventRegion.value.rects()) {
+ ts << "\n";
+ ts.writeIndent();
+ ts << rect;
+ }
+ }
+ }
+
+ // FIXME: dump synchronousScrollingReasons
+ // FIXME: dump scrollableAreaParameters
+ // FIXME: dump scrollBehaviorForFixedElements
+
+ if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateFrameScrollingNode::HeaderHeight))
+ ts.dumpProperty("header-height", node.headerHeight());
+
+ if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateFrameScrollingNode::FooterHeight))
+ ts.dumpProperty("footer-height", node.footerHeight());
+
+ if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateFrameScrollingNode::TopContentInset))
+ ts.dumpProperty("top-content-inset", node.topContentInset());
+
+ if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateFrameScrollingNode::FrameScaleFactor))
+ ts.dumpProperty("frame-scale-factor", node.frameScaleFactor());
+
+ if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateFrameScrollingNode::ScrolledContentsLayer))
+ ts.dumpProperty("scrolled-contents-layer", static_cast<GraphicsLayer::PlatformLayerID>(node.scrolledContentsLayer()));
+
+ if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateFrameScrollingNode::InsetClipLayer))
+ ts.dumpProperty("clip-inset-layer", static_cast<GraphicsLayer::PlatformLayerID>(node.insetClipLayer()));
+
+ if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateFrameScrollingNode::ContentShadowLayer))
+ ts.dumpProperty("content-shadow-layer", static_cast<GraphicsLayer::PlatformLayerID>(node.contentShadowLayer()));
+
+ if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateFrameScrollingNode::HeaderLayer))
+ ts.dumpProperty("header-layer", static_cast<GraphicsLayer::PlatformLayerID>(node.headerLayer()));
+
+ if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateFrameScrollingNode::FooterLayer))
+ ts.dumpProperty("footer-layer", static_cast<GraphicsLayer::PlatformLayerID>(node.footerLayer()));
+}
+
+static void dump(TextStream& ts, const ScrollingStateOverflowScrollingNode& node, bool changedPropertiesOnly)
+{
+ dump(ts, static_cast<const ScrollingStateScrollingNode&>(node), changedPropertiesOnly);
+
+ if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateOverflowScrollingNode::ScrolledContentsLayer))
+ ts.dumpProperty("scrolled-contents-layer", static_cast<GraphicsLayer::PlatformLayerID>(node.scrolledContentsLayer()));
+}
+
+static void dump(TextStream& ts, const ScrollingStateFixedNode& node, bool changedPropertiesOnly)
+{
+ if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateFixedNode::ViewportConstraints))
+ ts << node.viewportConstraints();
+}
+
+static void dump(TextStream& ts, const ScrollingStateStickyNode& node, bool changedPropertiesOnly)
+{
+ if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateFixedNode::ViewportConstraints))
+ ts << node.viewportConstraints();
+}
+
+static void dump(TextStream& ts, const ScrollingStateNode& node, bool changedPropertiesOnly)
+{
+ ts.dumpProperty("type", node.nodeType());
+
+ if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateNode::ScrollLayer))
+ ts.dumpProperty("layer", static_cast<GraphicsLayer::PlatformLayerID>(node.layer()));
+
+ switch (node.nodeType()) {
+ case FrameScrollingNode:
+ dump(ts, downcast<ScrollingStateFrameScrollingNode>(node), changedPropertiesOnly);
+ break;
+ case OverflowScrollingNode:
+ dump(ts, downcast<ScrollingStateOverflowScrollingNode>(node), changedPropertiesOnly);
+ break;
+ case FixedNode:
+ dump(ts, downcast<ScrollingStateFixedNode>(node), changedPropertiesOnly);
+ break;
+ case StickyNode:
+ dump(ts, downcast<ScrollingStateStickyNode>(node), changedPropertiesOnly);
+ break;
+ }
+}
+
+static void recursiveDumpNodes(TextStream& ts, const ScrollingStateNode& node, bool changedPropertiesOnly)
+{
+ TextStream::GroupScope group(ts);
+ ts << "node " << node.scrollingNodeID();
+ dump(ts, node, changedPropertiesOnly);
+
+ if (node.children()) {
+ TextStream::GroupScope group(ts);
+ ts << "children";
+
+ for (auto& childNode : *node.children())
+ recursiveDumpNodes(ts, *childNode, changedPropertiesOnly);
+ }
+}
+
+static void dump(TextStream& ts, const ScrollingStateTree& stateTree, bool changedPropertiesOnly)
+{
+ ts.dumpProperty("has changed properties", stateTree.hasChangedProperties());
+ ts.dumpProperty("has new root node", stateTree.hasNewRootStateNode());
+
+ if (stateTree.rootStateNode())
+ recursiveDumpNodes(ts, *stateTree.rootStateNode(), changedPropertiesOnly);
+
+ if (!stateTree.removedNodes().isEmpty()) {
+ Vector<ScrollingNodeID> removedNodes;
+ copyToVector(stateTree.removedNodes(), removedNodes);
+ ts.dumpProperty<Vector<ScrollingNodeID>>("removed-nodes", removedNodes);
+ }
+}
+
+WTF::CString RemoteScrollingCoordinatorTransaction::description() const
+{
+ TextStream ts;
+
+ ts.startGroup();
+ ts << "scrolling state tree";
+
+ if (m_scrollingStateTree) {
+ if (!m_scrollingStateTree->hasChangedProperties())
+ ts << " - no changes";
+ else
+ WebKit::dump(ts, *m_scrollingStateTree.get(), true);
+ } else
+ ts << " - none";
+
+ ts.endGroup();
+
+ return ts.release().utf8();
+}
+
+void RemoteScrollingCoordinatorTransaction::dump() const
+{
+ fprintf(stderr, "%s", description().data());
+}
+#endif
+
+} // namespace WebKit
+
+#else // !ENABLE(ASYNC_SCROLLING)
+
+namespace WebKit {
+
+void RemoteScrollingCoordinatorTransaction::encode(IPC::Encoder&) const
+{
+}
+
+bool RemoteScrollingCoordinatorTransaction::decode(IPC::Decoder& decoder, RemoteScrollingCoordinatorTransaction& transaction)
+{
+ return true;
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(ASYNC_SCROLLING)
diff --git a/Source/WebKit2/Shared/SecurityOriginData.h b/Source/WebKit2/Shared/Scrolling/RemoteScrollingCoordinatorTransaction.h
index 96404e562..8b9b0bf87 100644
--- a/Source/WebKit2/Shared/SecurityOriginData.h
+++ b/Source/WebKit2/Shared/Scrolling/RemoteScrollingCoordinatorTransaction.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -23,43 +23,41 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SecurityOriginData_h
-#define SecurityOriginData_h
+#ifndef RemoteScrollingCoordinatorTransaction_h
+#define RemoteScrollingCoordinatorTransaction_h
-#include "APIObject.h"
-#include "GenericCallback.h"
-#include <wtf/text/WTFString.h>
+#include <WebCore/ScrollingStateTree.h>
namespace IPC {
- class ArgumentDecoder;
- class ArgumentEncoder;
+class Decoder;
+class Encoder;
}
namespace WebKit {
-typedef GenericCallback<WKArrayRef> ArrayCallback;
-
-struct SecurityOriginData {
- static SecurityOriginData fromSecurityOrigin(const WebCore::SecurityOrigin*);
- PassRefPtr<WebCore::SecurityOrigin> securityOrigin() const;
-
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, SecurityOriginData&);
-
- // FIXME <rdar://9018386>: We should be sending more state across the wire than just the protocol,
- // host, and port.
-
- String protocol;
- String host;
- int port;
-
- SecurityOriginData isolatedCopy() const;
+class RemoteScrollingCoordinatorTransaction {
+public:
+#if ENABLE(ASYNC_SCROLLING)
+ void setStateTreeToEncode(std::unique_ptr<WebCore::ScrollingStateTree> stateTree) { m_scrollingStateTree = WTFMove(stateTree); }
+ std::unique_ptr<WebCore::ScrollingStateTree>& scrollingStateTree() { return m_scrollingStateTree; }
+#endif // ENABLE(ASYNC_SCROLLING)
+
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, RemoteScrollingCoordinatorTransaction&);
+
+#if !defined(NDEBUG) || !LOG_DISABLED
+ WTF::CString description() const;
+ void dump() const;
+#endif
+
+private:
+#if ENABLE(ASYNC_SCROLLING)
+ bool decode(IPC::Decoder&);
+
+ std::unique_ptr<WebCore::ScrollingStateTree> m_scrollingStateTree;
+#endif // ENABLE(ASYNC_SCROLLING)
};
-void performAPICallbackWithSecurityOriginDataVector(const Vector<SecurityOriginData>&, ArrayCallback*);
-
-bool operator==(const SecurityOriginData&, const SecurityOriginData&);
-
} // namespace WebKit
-#endif // SecurityOriginData_h
+#endif // RemoteScrollingCoordinatorTransaction_h
diff --git a/Source/WebKit2/Shared/SecurityOriginData.cpp b/Source/WebKit2/Shared/SecurityOriginData.cpp
deleted file mode 100644
index b6b4a9ac4..000000000
--- a/Source/WebKit2/Shared/SecurityOriginData.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#include "config.h"
-#include "SecurityOriginData.h"
-
-#include "APIArray.h"
-#include "WebCoreArgumentCoders.h"
-#include "WebSecurityOrigin.h"
-#include <wtf/text/CString.h>
-
-using namespace WebCore;
-
-namespace WebKit {
-
-SecurityOriginData SecurityOriginData::fromSecurityOrigin(const SecurityOrigin* securityOrigin)
-{
- SecurityOriginData securityOriginData;
-
- securityOriginData.protocol = securityOrigin->protocol();
- securityOriginData.host = securityOrigin->host();
- securityOriginData.port = securityOrigin->port();
-
- return securityOriginData;
-}
-
-PassRefPtr<SecurityOrigin> SecurityOriginData::securityOrigin() const
-{
- return SecurityOrigin::create(protocol, host, port);
-}
-
-void SecurityOriginData::encode(IPC::ArgumentEncoder& encoder) const
-{
- encoder << protocol;
- encoder << host;
- encoder << port;
-}
-
-bool SecurityOriginData::decode(IPC::ArgumentDecoder& decoder, SecurityOriginData& securityOriginData)
-{
- if (!decoder.decode(securityOriginData.protocol))
- return false;
- if (!decoder.decode(securityOriginData.host))
- return false;
- if (!decoder.decode(securityOriginData.port))
- return false;
-
- return true;
-}
-
-SecurityOriginData SecurityOriginData::isolatedCopy() const
-{
- SecurityOriginData result;
-
- result.protocol = protocol.isolatedCopy();
- result.host = host.isolatedCopy();
- result.port = port;
-
- return result;
-}
-
-void performAPICallbackWithSecurityOriginDataVector(const Vector<SecurityOriginData>& originDatas, ArrayCallback* callback)
-{
- if (!callback) {
- // FIXME: Log error or assert.
- return;
- }
-
- Vector<RefPtr<API::Object>> securityOrigins;
- securityOrigins.reserveInitialCapacity(originDatas.size());
-
- for (const auto& originData : originDatas) {
- RefPtr<API::Object> origin = WebSecurityOrigin::create(originData.protocol, originData.host, originData.port);
- if (!origin)
- continue;
- securityOrigins.uncheckedAppend(std::move(origin));
- }
-
- callback->performCallbackWithReturnValue(API::Array::create(std::move(securityOrigins)).get());
-}
-
-bool operator==(const SecurityOriginData& a, const SecurityOriginData& b)
-{
- if (&a == &b)
- return true;
-
- return a.protocol == b.protocol
- && a.host == b.host
- && a.port == b.port;
-}
-
-} // namespace WebKit
diff --git a/Source/WebKit2/Shared/SessionState.cpp b/Source/WebKit2/Shared/SessionState.cpp
index 7ccbdc54d..0f048a4bd 100644
--- a/Source/WebKit2/Shared/SessionState.cpp
+++ b/Source/WebKit2/Shared/SessionState.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -25,59 +25,208 @@
#include "config.h"
#include "SessionState.h"
+
#include "WebCoreArgumentCoders.h"
-namespace IPC {
+namespace WebKit {
-// This assumes that when we encode a RefPtr we want to encode the object it points to and it is never null.
-template<typename T> struct ArgumentCoder<RefPtr<T>> {
- static void encode(ArgumentEncoder& encoder, const RefPtr<T>& item)
- {
- item->encode(encoder);
+bool isValidEnum(WebCore::ShouldOpenExternalURLsPolicy policy)
+{
+ switch (policy) {
+ case WebCore::ShouldOpenExternalURLsPolicy::ShouldAllow:
+ case WebCore::ShouldOpenExternalURLsPolicy::ShouldAllowExternalSchemes:
+ case WebCore::ShouldOpenExternalURLsPolicy::ShouldNotAllow:
+ return true;
}
+ return false;
+}
- static bool decode(ArgumentDecoder& decoder, RefPtr<T>& item)
- {
- item = T::decode(decoder);
- return item;
+void HTTPBody::Element::encode(IPC::Encoder& encoder) const
+{
+ encoder.encodeEnum(type);
+ encoder << data;
+ encoder << filePath;
+ encoder << fileStart;
+ encoder << fileLength;
+ encoder << expectedFileModificationTime;
+ encoder << blobURLString;
+}
+
+static bool isValidEnum(HTTPBody::Element::Type type)
+{
+ switch (type) {
+ case HTTPBody::Element::Type::Data:
+ case HTTPBody::Element::Type::File:
+ case HTTPBody::Element::Type::Blob:
+ return true;
}
-};
-} // namespace IPC
+ return false;
+}
-namespace WebKit {
+bool HTTPBody::Element::decode(IPC::Decoder& decoder, Element& result)
+{
+ if (!decoder.decodeEnum(result.type) || !isValidEnum(result.type))
+ return false;
+ if (!decoder.decode(result.data))
+ return false;
+ if (!decoder.decode(result.filePath))
+ return false;
+ if (!decoder.decode(result.fileStart))
+ return false;
+ if (!decoder.decode(result.fileLength))
+ return false;
+ if (!decoder.decode(result.expectedFileModificationTime))
+ return false;
+ if (!decoder.decode(result.blobURLString))
+ return false;
+
+ return true;
+}
+
+void HTTPBody::encode(IPC::Encoder& encoder) const
+{
+ encoder << contentType;
+ encoder << elements;
+}
+
+bool HTTPBody::decode(IPC::Decoder& decoder, HTTPBody& result)
+{
+ if (!decoder.decode(result.contentType))
+ return false;
+ if (!decoder.decode(result.elements))
+ return false;
+
+ return true;
+}
+
+void FrameState::encode(IPC::Encoder& encoder) const
+{
+ encoder << urlString;
+ encoder << originalURLString;
+ encoder << referrer;
+ encoder << target;
+
+ encoder << documentState;
+ encoder << stateObjectData;
+
+ encoder << documentSequenceNumber;
+ encoder << itemSequenceNumber;
+
+ encoder << scrollPosition;
+ encoder << pageScaleFactor;
+
+ encoder << httpBody;
+
+#if PLATFORM(IOS)
+ encoder << exposedContentRect;
+ encoder << unobscuredContentRect;
+ encoder << minimumLayoutSizeInScrollViewCoordinates;
+ encoder << contentSize;
+ encoder << scaleIsInitial;
+#endif
+
+ encoder << children;
+}
+
+bool FrameState::decode(IPC::Decoder& decoder, FrameState& result)
+{
+ if (!decoder.decode(result.urlString))
+ return false;
+ if (!decoder.decode(result.originalURLString))
+ return false;
+ if (!decoder.decode(result.referrer))
+ return false;
+ if (!decoder.decode(result.target))
+ return false;
+
+ if (!decoder.decode(result.documentState))
+ return false;
+ if (!decoder.decode(result.stateObjectData))
+ return false;
+
+ if (!decoder.decode(result.documentSequenceNumber))
+ return false;
+ if (!decoder.decode(result.itemSequenceNumber))
+ return false;
+
+ if (!decoder.decode(result.scrollPosition))
+ return false;
+ if (!decoder.decode(result.pageScaleFactor))
+ return false;
+
+ if (!decoder.decode(result.httpBody))
+ return false;
+
+#if PLATFORM(IOS)
+ if (!decoder.decode(result.exposedContentRect))
+ return false;
+ if (!decoder.decode(result.unobscuredContentRect))
+ return false;
+ if (!decoder.decode(result.minimumLayoutSizeInScrollViewCoordinates))
+ return false;
+ if (!decoder.decode(result.contentSize))
+ return false;
+ if (!decoder.decode(result.scaleIsInitial))
+ return false;
+#endif
-SessionState::SessionState()
- : m_currentIndex(0)
+ if (!decoder.decode(result.children))
+ return false;
+
+ return true;
+}
+
+void PageState::encode(IPC::Encoder& encoder) const
{
+ encoder << title;
+ encoder << mainFrameState;
+ encoder.encodeEnum(shouldOpenExternalURLsPolicy);
}
-SessionState::SessionState(const BackForwardListItemVector& list, uint32_t currentIndex)
- : m_list(list)
- , m_currentIndex(currentIndex)
+bool PageState::decode(IPC::Decoder& decoder, PageState& result)
{
+ if (!decoder.decode(result.title))
+ return false;
+ if (!decoder.decode(result.mainFrameState))
+ return false;
+ if (!decoder.decodeEnum(result.shouldOpenExternalURLsPolicy) || !isValidEnum(result.shouldOpenExternalURLsPolicy))
+ return false;
+
+ return true;
}
-bool SessionState::isEmpty() const
+void BackForwardListItemState::encode(IPC::Encoder& encoder) const
{
- // Because this might change later, callers should use this instead of
- // calling list().isEmpty() directly themselves.
- return m_list.isEmpty();
+ encoder << identifier;
+ encoder << pageState;
}
-
-void SessionState::encode(IPC::ArgumentEncoder& encoder) const
+
+bool BackForwardListItemState::decode(IPC::Decoder& decoder, BackForwardListItemState& result)
{
- encoder << m_list;
- encoder << m_currentIndex;
+ if (!decoder.decode(result.identifier))
+ return false;
+
+ if (!decoder.decode(result.pageState))
+ return false;
+
+ return true;
}
-bool SessionState::decode(IPC::ArgumentDecoder& decoder, SessionState& state)
+void BackForwardListState::encode(IPC::Encoder& encoder) const
{
- if (!decoder.decode(state.m_list))
+ encoder << items;
+ encoder << currentIndex;
+}
+
+bool BackForwardListState::decode(IPC::Decoder& decoder, BackForwardListState& result)
+{
+ if (!decoder.decode(result.items))
return false;
- if (!decoder.decode(state.m_currentIndex))
+ if (!decoder.decode(result.currentIndex))
return false;
+
return true;
}
-
+
} // namespace WebKit
diff --git a/Source/WebKit2/Shared/SessionState.h b/Source/WebKit2/Shared/SessionState.h
index ef827553c..0ff7bba01 100644
--- a/Source/WebKit2/Shared/SessionState.h
+++ b/Source/WebKit2/Shared/SessionState.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -22,35 +22,130 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-
+
#ifndef SessionState_h
#define SessionState_h
-#include "WebBackForwardListItem.h"
+#if PLATFORM(COCOA)
+#include "ViewSnapshotStore.h"
+#endif
+
+#include <WebCore/FloatRect.h>
+#include <WebCore/FrameLoaderTypes.h>
+#include <WebCore/IntRect.h>
+#include <WebCore/URL.h>
+#include <wtf/Optional.h>
+#include <wtf/Vector.h>
+#include <wtf/text/WTFString.h>
namespace IPC {
- class ArgumentDecoder;
- class ArgumentEncoder;
+class Decoder;
+class Encoder;
}
namespace WebKit {
-class SessionState {
-public:
- SessionState();
- SessionState(const BackForwardListItemVector&, uint32_t currentIndex);
+bool isValidEnum(WebCore::ShouldOpenExternalURLsPolicy);
+
+struct HTTPBody {
+ struct Element {
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, Element&);
+
+ enum class Type {
+ Data,
+ File,
+ Blob,
+ };
+
+ Type type = Type::Data;
+
+ // Data.
+ Vector<char> data;
+
+ // File.
+ String filePath;
+ int64_t fileStart;
+ std::optional<int64_t> fileLength;
+ std::optional<double> expectedFileModificationTime;
+
+ // Blob.
+ String blobURLString;
+ };
+
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, HTTPBody&);
+
+ String contentType;
+ Vector<Element> elements;
+};
+
+struct FrameState {
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, FrameState&);
+
+ String urlString;
+ String originalURLString;
+ String referrer;
+ String target;
+
+ Vector<String> documentState;
+ std::optional<Vector<uint8_t>> stateObjectData;
- const BackForwardListItemVector& list() const { return m_list; }
- uint32_t currentIndex() const { return m_currentIndex; }
+ int64_t documentSequenceNumber;
+ int64_t itemSequenceNumber;
- bool isEmpty() const;
+ WebCore::IntPoint scrollPosition;
+ float pageScaleFactor;
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, SessionState&);
+ std::optional<HTTPBody> httpBody;
+
+ // FIXME: These should not be per frame.
+#if PLATFORM(IOS)
+ WebCore::FloatRect exposedContentRect;
+ WebCore::IntRect unobscuredContentRect;
+ WebCore::FloatSize minimumLayoutSizeInScrollViewCoordinates;
+ WebCore::IntSize contentSize;
+ bool scaleIsInitial = false;
+#endif
+
+ Vector<FrameState> children;
+};
+
+struct PageState {
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, PageState&);
+
+ String title;
+ FrameState mainFrameState;
+ WebCore::ShouldOpenExternalURLsPolicy shouldOpenExternalURLsPolicy { WebCore::ShouldOpenExternalURLsPolicy::ShouldNotAllow };
+};
+
+struct BackForwardListItemState {
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, BackForwardListItemState&);
+
+ uint64_t identifier;
+
+ PageState pageState;
+#if PLATFORM(COCOA)
+ RefPtr<ViewSnapshot> snapshot;
+#endif
+
+};
+
+struct BackForwardListState {
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, BackForwardListState&);
+
+ Vector<BackForwardListItemState> items;
+ std::optional<uint32_t> currentIndex;
+};
-private:
- BackForwardListItemVector m_list;
- uint32_t m_currentIndex;
+struct SessionState {
+ BackForwardListState backForwardListState;
+ uint64_t renderTreeSize;
+ WebCore::URL provisionalURL;
};
} // namespace WebKit
diff --git a/Source/WebKit2/Shared/SessionTracker.cpp b/Source/WebKit2/Shared/SessionTracker.cpp
index 3ed596f97..48ae8a56a 100644
--- a/Source/WebKit2/Shared/SessionTracker.cpp
+++ b/Source/WebKit2/Shared/SessionTracker.cpp
@@ -26,67 +26,67 @@
#include "config.h"
#include "SessionTracker.h"
-#include <wtf/MainThread.h>
+#include "NetworkSession.h"
+#include <WebCore/NetworkStorageSession.h>
#include <wtf/NeverDestroyed.h>
+#include <wtf/RunLoop.h>
using namespace WebCore;
namespace WebKit {
-const uint64_t SessionTracker::defaultSessionID;
-const uint64_t SessionTracker::legacyPrivateSessionID;
-
-static HashMap<uint64_t, std::unique_ptr<NetworkStorageSession>>& staticSessionMap()
-{
- ASSERT(isMainThread());
-
- static NeverDestroyed<HashMap<uint64_t, std::unique_ptr<NetworkStorageSession>>> map;
- return map.get();
-}
-
static String& identifierBase()
{
- ASSERT(isMainThread());
+ ASSERT(RunLoop::isMain());
static NeverDestroyed<String> base;
return base;
}
-const HashMap<uint64_t, std::unique_ptr<NetworkStorageSession>>& SessionTracker::sessionMap()
-{
- return staticSessionMap();
-}
-
const String& SessionTracker::getIdentifierBase()
{
return identifierBase();
}
-NetworkStorageSession* SessionTracker::session(uint64_t sessionID)
+void SessionTracker::setIdentifierBase(const String& identifier)
{
- if (sessionID == defaultSessionID)
- return &NetworkStorageSession::defaultStorageSession();
- return staticSessionMap().add(sessionID, nullptr).iterator->value.get();
+ ASSERT(RunLoop::isMain());
+
+ identifierBase() = identifier;
}
-void SessionTracker::setSession(uint64_t sessionID, std::unique_ptr<NetworkStorageSession> session)
+#if USE(NETWORK_SESSION)
+static HashMap<SessionID, RefPtr<NetworkSession>>& staticSessionMap()
{
- ASSERT(sessionID != defaultSessionID);
- staticSessionMap().add(sessionID, nullptr).iterator->value = std::move(session);
+ ASSERT(RunLoop::isMain());
+
+ static NeverDestroyed<HashMap<SessionID, RefPtr<NetworkSession>>> map;
+ return map;
}
-void SessionTracker::destroySession(uint64_t sessionID)
+NetworkSession* SessionTracker::networkSession(SessionID sessionID)
{
- ASSERT(isMainThread());
-
- staticSessionMap().remove(sessionID);
+ if (sessionID == SessionID::defaultSessionID())
+ return &NetworkSession::defaultSession();
+ return staticSessionMap().get(sessionID);
}
-void SessionTracker::setIdentifierBase(const String& identifier)
+void SessionTracker::setSession(SessionID sessionID, Ref<NetworkSession>&& session)
{
- ASSERT(isMainThread());
+ ASSERT(sessionID != SessionID::defaultSessionID());
+ staticSessionMap().set(sessionID, WTFMove(session));
+}
+#endif
- identifierBase() = identifier;
+void SessionTracker::destroySession(SessionID sessionID)
+{
+ ASSERT(RunLoop::isMain());
+#if USE(NETWORK_SESSION)
+ auto session = staticSessionMap().take(sessionID);
+ if (session)
+ session->invalidateAndCancel();
+#endif
+ NetworkStorageSession::destroySession(sessionID);
}
} // namespace WebKit
diff --git a/Source/WebKit2/Shared/SessionTracker.h b/Source/WebKit2/Shared/SessionTracker.h
index 5d38f1038..9f7a6c070 100644
--- a/Source/WebKit2/Shared/SessionTracker.h
+++ b/Source/WebKit2/Shared/SessionTracker.h
@@ -26,26 +26,30 @@
#ifndef SessionTracker_h
#define SessionTracker_h
-#include <WebCore/NetworkStorageSession.h>
+namespace WebCore {
+class NetworkStorageSession;
+}
+
+#include <WebCore/SessionID.h>
#include <wtf/HashMap.h>
#include <wtf/Noncopyable.h>
-#include <wtf/text/CString.h>
+#include <wtf/text/WTFString.h>
namespace WebKit {
+class NetworkSession;
+
class SessionTracker {
WTF_MAKE_NONCOPYABLE(SessionTracker);
public:
- static const uint64_t defaultSessionID = 1;
- static const uint64_t legacyPrivateSessionID = 2;
- static bool isEphemeralID(uint64_t sessionID) { return sessionID != SessionTracker::defaultSessionID; }
- // FIXME: sessionMap()'s returned map does not include default session.
- static const HashMap<uint64_t, std::unique_ptr<WebCore::NetworkStorageSession>>& sessionMap();
static const String& getIdentifierBase();
- static WebCore::NetworkStorageSession* session(uint64_t sessionID);
- static void setSession(uint64_t sessionID, std::unique_ptr<WebCore::NetworkStorageSession>);
- static void destroySession(uint64_t sessionID);
static void setIdentifierBase(const String&);
+
+#if USE(NETWORK_SESSION)
+ static void setSession(WebCore::SessionID, Ref<NetworkSession>&&);
+ static NetworkSession* networkSession(WebCore::SessionID);
+#endif
+ static void destroySession(WebCore::SessionID);
};
} // namespace WebKit
diff --git a/Source/WebKit2/Shared/ShareableBitmap.cpp b/Source/WebKit2/Shared/ShareableBitmap.cpp
index 1971100ee..9942e7c26 100644
--- a/Source/WebKit2/Shared/ShareableBitmap.cpp
+++ b/Source/WebKit2/Shared/ShareableBitmap.cpp
@@ -33,20 +33,27 @@
using namespace WebCore;
namespace WebKit {
+
+static unsigned calculateBytesPerPixel(ShareableBitmap::Flags flags)
+{
+ if (flags & ShareableBitmap::SupportsExtendedColor)
+ return 8; // for extended color, we are using half-float representations
+ return 4;
+}
ShareableBitmap::Handle::Handle()
: m_flags(0)
{
}
-void ShareableBitmap::Handle::encode(IPC::ArgumentEncoder& encoder) const
+void ShareableBitmap::Handle::encode(IPC::Encoder& encoder) const
{
encoder << m_handle;
encoder << m_size;
encoder << m_flags;
}
-bool ShareableBitmap::Handle::decode(IPC::ArgumentDecoder& decoder, Handle& handle)
+bool ShareableBitmap::Handle::decode(IPC::Decoder& decoder, Handle& handle)
{
if (!decoder.decode(handle.m_handle))
return false;
@@ -54,52 +61,73 @@ bool ShareableBitmap::Handle::decode(IPC::ArgumentDecoder& decoder, Handle& hand
return false;
if (!decoder.decode(handle.m_flags))
return false;
+ handle.m_bytesPerPixel = calculateBytesPerPixel(handle.m_flags);
return true;
}
-PassRefPtr<ShareableBitmap> ShareableBitmap::create(const IntSize& size, Flags flags)
+void ShareableBitmap::Handle::clear()
{
- size_t numBytes = numBytesForSize(size);
-
+ m_handle.clear();
+ m_size = IntSize();
+ m_flags = Flag::NoFlags;
+ m_bytesPerPixel = calculateBytesPerPixel(m_flags);
+}
+
+RefPtr<ShareableBitmap> ShareableBitmap::create(const IntSize& size, Flags flags)
+{
+ unsigned bytesPerPixel = calculateBytesPerPixel(flags);
+ auto numBytes = numBytesForSize(size, bytesPerPixel);
+ if (numBytes.hasOverflowed())
+ return nullptr;
+
void* data = 0;
- if (!tryFastMalloc(numBytes).getValue(data))
- return 0;
+ if (!tryFastMalloc(numBytes.unsafeGet()).getValue(data))
+ return nullptr;
return adoptRef(new ShareableBitmap(size, flags, data));
}
-PassRefPtr<ShareableBitmap> ShareableBitmap::createShareable(const IntSize& size, Flags flags)
+RefPtr<ShareableBitmap> ShareableBitmap::createShareable(const IntSize& size, Flags flags)
{
- size_t numBytes = numBytesForSize(size);
+ unsigned bytesPerPixel = calculateBytesPerPixel(flags);
+ auto numBytes = numBytesForSize(size, bytesPerPixel);
+ if (numBytes.hasOverflowed())
+ return nullptr;
- RefPtr<SharedMemory> sharedMemory = SharedMemory::create(numBytes);
+ RefPtr<SharedMemory> sharedMemory = SharedMemory::allocate(numBytes.unsafeGet());
if (!sharedMemory)
- return 0;
+ return nullptr;
return adoptRef(new ShareableBitmap(size, flags, sharedMemory));
}
-PassRefPtr<ShareableBitmap> ShareableBitmap::create(const IntSize& size, Flags flags, PassRefPtr<SharedMemory> sharedMemory)
+RefPtr<ShareableBitmap> ShareableBitmap::create(const IntSize& size, Flags flags, RefPtr<SharedMemory> sharedMemory)
{
ASSERT(sharedMemory);
- size_t numBytes = numBytesForSize(size);
- ASSERT_UNUSED(numBytes, sharedMemory->size() >= numBytes);
+ unsigned bytesPerPixel = calculateBytesPerPixel(flags);
+ auto numBytes = numBytesForSize(size, bytesPerPixel);
+ if (numBytes.hasOverflowed())
+ return nullptr;
+ if (sharedMemory->size() < numBytes.unsafeGet()) {
+ ASSERT_NOT_REACHED();
+ return nullptr;
+ }
return adoptRef(new ShareableBitmap(size, flags, sharedMemory));
}
-PassRefPtr<ShareableBitmap> ShareableBitmap::create(const Handle& handle, SharedMemory::Protection protection)
+RefPtr<ShareableBitmap> ShareableBitmap::create(const Handle& handle, SharedMemory::Protection protection)
{
// Create the shared memory.
- RefPtr<SharedMemory> sharedMemory = SharedMemory::create(handle.m_handle, protection);
+ auto sharedMemory = SharedMemory::map(handle.m_handle, protection);
if (!sharedMemory)
- return 0;
+ return nullptr;
- return create(handle.m_size, handle.m_flags, sharedMemory.release());
+ return create(handle.m_size, handle.m_flags, WTFMove(sharedMemory));
}
-bool ShareableBitmap::createHandle(Handle& handle, SharedMemory::Protection protection)
+bool ShareableBitmap::createHandle(Handle& handle, SharedMemory::Protection protection) const
{
ASSERT(isBackedBySharedMemory());
@@ -107,6 +135,7 @@ bool ShareableBitmap::createHandle(Handle& handle, SharedMemory::Protection prot
return false;
handle.m_size = m_size;
handle.m_flags = m_flags;
+ handle.m_bytesPerPixel = m_bytesPerPixel;
return true;
}
@@ -115,14 +144,16 @@ ShareableBitmap::ShareableBitmap(const IntSize& size, Flags flags, void* data)
, m_flags(flags)
, m_data(data)
{
+ m_bytesPerPixel = calculateBytesPerPixel(flags);
}
-ShareableBitmap::ShareableBitmap(const IntSize& size, Flags flags, PassRefPtr<SharedMemory> sharedMemory)
+ShareableBitmap::ShareableBitmap(const IntSize& size, Flags flags, RefPtr<SharedMemory> sharedMemory)
: m_size(size)
, m_flags(flags)
, m_sharedMemory(sharedMemory)
, m_data(0)
{
+ m_bytesPerPixel = calculateBytesPerPixel(flags);
}
ShareableBitmap::~ShareableBitmap()
@@ -131,29 +162,6 @@ ShareableBitmap::~ShareableBitmap()
fastFree(m_data);
}
-bool ShareableBitmap::resize(const IntSize& size)
-{
- // We can't resize backing stores that are backed by shared memory.
- ASSERT(!isBackedBySharedMemory());
-
- if (size == m_size)
- return true;
-
- size_t newNumBytes = numBytesForSize(size);
-
- // Try to resize.
- char* newData = 0;
- if (!tryFastRealloc(m_data, newNumBytes).getValue(newData)) {
- // We failed, but the backing store is still kept in a consistent state.
- return false;
- }
-
- m_size = size;
- m_data = newData;
-
- return true;
-}
-
void* ShareableBitmap::data() const
{
if (isBackedBySharedMemory())
diff --git a/Source/WebKit2/Shared/ShareableBitmap.h b/Source/WebKit2/Shared/ShareableBitmap.h
index 47161f028..df6c45c1d 100644
--- a/Source/WebKit2/Shared/ShareableBitmap.h
+++ b/Source/WebKit2/Shared/ShareableBitmap.h
@@ -28,8 +28,6 @@
#include "SharedMemory.h"
#include <WebCore/IntRect.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
@@ -53,6 +51,7 @@ public:
enum Flag {
NoFlags = 0,
SupportsAlpha = 1 << 0,
+ SupportsExtendedColor = 1 << 1,
};
typedef unsigned Flags;
@@ -63,8 +62,10 @@ public:
bool isNull() const { return m_handle.isNull(); }
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, Handle&);
+ void clear();
+
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, Handle&);
private:
friend class ShareableBitmap;
@@ -72,30 +73,29 @@ public:
mutable SharedMemory::Handle m_handle;
WebCore::IntSize m_size;
Flags m_flags;
+ unsigned m_bytesPerPixel;
};
// Create a shareable bitmap that uses malloced memory.
- static PassRefPtr<ShareableBitmap> create(const WebCore::IntSize&, Flags);
+ static RefPtr<ShareableBitmap> create(const WebCore::IntSize&, Flags);
// Create a shareable bitmap whose backing memory can be shared with another process.
- static PassRefPtr<ShareableBitmap> createShareable(const WebCore::IntSize&, Flags);
+ static RefPtr<ShareableBitmap> createShareable(const WebCore::IntSize&, Flags);
// Create a shareable bitmap from an already existing shared memory block.
- static PassRefPtr<ShareableBitmap> create(const WebCore::IntSize&, Flags, PassRefPtr<SharedMemory>);
+ static RefPtr<ShareableBitmap> create(const WebCore::IntSize&, Flags, RefPtr<SharedMemory>);
// Create a shareable bitmap from a handle.
- static PassRefPtr<ShareableBitmap> create(const Handle&, SharedMemory::Protection = SharedMemory::ReadWrite);
+ static RefPtr<ShareableBitmap> create(const Handle&, SharedMemory::Protection = SharedMemory::Protection::ReadWrite);
// Create a handle.
- bool createHandle(Handle&, SharedMemory::Protection = SharedMemory::ReadWrite);
+ bool createHandle(Handle&, SharedMemory::Protection = SharedMemory::Protection::ReadWrite) const;
~ShareableBitmap();
const WebCore::IntSize& size() const { return m_size; }
WebCore::IntRect bounds() const { return WebCore::IntRect(WebCore::IntPoint(), size()); }
- bool resize(const WebCore::IntSize& size);
-
// Create a graphics context that can be used to paint into the backing store.
std::unique_ptr<WebCore::GraphicsContext> createGraphicsContext();
@@ -107,7 +107,7 @@ public:
// This creates a bitmap image that directly references the shared bitmap data.
// This is only safe to use when we know that the contents of the shareable bitmap won't change.
- PassRefPtr<WebCore::Image> createImage();
+ RefPtr<WebCore::Image> createImage();
#if USE(CG)
// This creates a copied CGImageRef (most likely a copy-on-write) of the shareable bitmap.
@@ -119,17 +119,18 @@ public:
#elif USE(CAIRO)
// This creates a BitmapImage that directly references the shared bitmap data.
// This is only safe to use when we know that the contents of the shareable bitmap won't change.
- PassRefPtr<cairo_surface_t> createCairoSurface();
+ RefPtr<cairo_surface_t> createCairoSurface();
#endif
private:
ShareableBitmap(const WebCore::IntSize&, Flags, void*);
- ShareableBitmap(const WebCore::IntSize&, Flags, PassRefPtr<SharedMemory>);
+ ShareableBitmap(const WebCore::IntSize&, Flags, RefPtr<SharedMemory>);
#if USE(CAIRO)
- static size_t numBytesForSize(const WebCore::IntSize&);
+ static Checked<unsigned, RecordOverflow> numBytesForSize(const WebCore::IntSize&);
+ static Checked<unsigned, RecordOverflow> numBytesForSize(const WebCore::IntSize& size, unsigned bytesPerPixel) { return numBytesForSize(size); }
#else
- static size_t numBytesForSize(const WebCore::IntSize& size) { return size.width() * size.height() * 4; }
+ static Checked<unsigned, RecordOverflow> numBytesForSize(const WebCore::IntSize& size, unsigned bytesPerPixel) { return size.area<RecordOverflow>() * bytesPerPixel; }
#endif
#if USE(CG)
@@ -143,10 +144,15 @@ private:
#endif
void* data() const;
- size_t sizeInBytes() const { return numBytesForSize(m_size); }
-
+#if USE(CAIRO)
+ size_t sizeInBytes() const { return numBytesForSize(m_size).unsafeGet(); }
+#else
+ size_t sizeInBytes() const { return numBytesForSize(m_size, m_bytesPerPixel).unsafeGet(); }
+#endif
+
WebCore::IntSize m_size;
Flags m_flags;
+ unsigned m_bytesPerPixel;
// If the shareable bitmap is backed by shared memory, this points to the shared memory object.
RefPtr<SharedMemory> m_sharedMemory;
diff --git a/Source/WebKit2/Shared/ShareableResource.cpp b/Source/WebKit2/Shared/ShareableResource.cpp
index 1658fcb2b..9e2eb0054 100644
--- a/Source/WebKit2/Shared/ShareableResource.cpp
+++ b/Source/WebKit2/Shared/ShareableResource.cpp
@@ -39,14 +39,14 @@ ShareableResource::Handle::Handle()
{
}
-void ShareableResource::Handle::encode(IPC::ArgumentEncoder& encoder) const
+void ShareableResource::Handle::encode(IPC::Encoder& encoder) const
{
encoder << m_handle;
encoder << m_offset;
encoder << m_size;
}
-bool ShareableResource::Handle::decode(IPC::ArgumentDecoder& decoder, Handle& handle)
+bool ShareableResource::Handle::decode(IPC::Decoder& decoder, Handle& handle)
{
if (!decoder.decode(handle.m_handle))
return false;
@@ -57,15 +57,14 @@ bool ShareableResource::Handle::decode(IPC::ArgumentDecoder& decoder, Handle& ha
return true;
}
+#if USE(CF)
static void shareableResourceDeallocate(void *ptr, void *info)
{
- (static_cast<ShareableResource*>(info))->deref(); // Balanced by ref() in createShareableResourceDeallocator()
+ static_cast<ShareableResource*>(info)->deref(); // Balanced by ref() in createShareableResourceDeallocator()
}
static CFAllocatorRef createShareableResourceDeallocator(ShareableResource* resource)
{
- resource->ref(); // Balanced by deref in shareableResourceDeallocate()
-
CFAllocatorContext context = { 0,
resource,
NULL, // retain
@@ -79,41 +78,54 @@ static CFAllocatorRef createShareableResourceDeallocator(ShareableResource* reso
return CFAllocatorCreate(kCFAllocatorDefault, &context);
}
+#endif
+
+RefPtr<SharedBuffer> ShareableResource::wrapInSharedBuffer()
+{
+ ref(); // Balanced by deref when SharedBuffer is deallocated.
+
+#if USE(CF)
+ RetainPtr<CFAllocatorRef> deallocator = adoptCF(createShareableResourceDeallocator(this));
+ RetainPtr<CFDataRef> cfData = adoptCF(CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, reinterpret_cast<const UInt8*>(data()), static_cast<CFIndex>(size()), deallocator.get()));
+ return SharedBuffer::wrapCFData(cfData.get());
+#elif USE(SOUP)
+ return SharedBuffer::wrapSoupBuffer(soup_buffer_new_with_owner(data(), size(), this, [](void* data) { static_cast<ShareableResource*>(data)->deref(); }));
+#else
+ ASSERT_NOT_REACHED();
+ return nullptr;
+#endif
+}
-PassRefPtr<SharedBuffer> ShareableResource::Handle::tryWrapInSharedBuffer() const
+RefPtr<SharedBuffer> ShareableResource::Handle::tryWrapInSharedBuffer() const
{
- RefPtr<ShareableResource> resource = ShareableResource::create(*this);
+ RefPtr<ShareableResource> resource = ShareableResource::map(*this);
if (!resource) {
LOG_ERROR("Failed to recreate ShareableResource from handle.");
- return 0;
+ return nullptr;
}
- RetainPtr<CFAllocatorRef> deallocator = adoptCF(createShareableResourceDeallocator(resource.get()));
- RetainPtr<CFDataRef> data = adoptCF(CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, reinterpret_cast<const UInt8*>(resource->data()), static_cast<CFIndex>(resource->size()), deallocator.get()));
-
- return SharedBuffer::wrapCFData(data.get());
+ return resource->wrapInSharedBuffer();
}
-
-PassRefPtr<ShareableResource> ShareableResource::create(PassRefPtr<SharedMemory> sharedMemory, unsigned offset, unsigned size)
+
+Ref<ShareableResource> ShareableResource::create(Ref<SharedMemory>&& sharedMemory, unsigned offset, unsigned size)
{
- return adoptRef(new ShareableResource(sharedMemory, offset, size));
+ return adoptRef(*new ShareableResource(WTFMove(sharedMemory), offset, size));
}
-PassRefPtr<ShareableResource> ShareableResource::create(const Handle& handle)
+RefPtr<ShareableResource> ShareableResource::map(const Handle& handle)
{
- RefPtr<SharedMemory> sharedMemory = SharedMemory::create(handle.m_handle, SharedMemory::ReadOnly);
+ auto sharedMemory = SharedMemory::map(handle.m_handle, SharedMemory::Protection::ReadOnly);
if (!sharedMemory)
- return 0;
+ return nullptr;
- return create(sharedMemory.release(), handle.m_offset, handle.m_size);
+ return create(sharedMemory.releaseNonNull(), handle.m_offset, handle.m_size);
}
-ShareableResource::ShareableResource(PassRefPtr<SharedMemory> sharedMemory, unsigned offset, unsigned size)
- : m_sharedMemory(sharedMemory)
+ShareableResource::ShareableResource(Ref<SharedMemory>&& sharedMemory, unsigned offset, unsigned size)
+ : m_sharedMemory(WTFMove(sharedMemory))
, m_offset(offset)
, m_size(size)
{
- ASSERT(m_sharedMemory);
ASSERT(m_offset + m_size <= m_sharedMemory->size());
// FIXME (NetworkProcess): This data was received from another process. If it is bogus, should we assume that process is compromised and we should kill it?
@@ -125,7 +137,7 @@ ShareableResource::~ShareableResource()
bool ShareableResource::createHandle(Handle& handle)
{
- if (!m_sharedMemory->createHandle(handle.m_handle, SharedMemory::ReadOnly))
+ if (!m_sharedMemory->createHandle(handle.m_handle, SharedMemory::Protection::ReadOnly))
return false;
handle.m_offset = m_offset;
diff --git a/Source/WebKit2/Shared/ShareableResource.h b/Source/WebKit2/Shared/ShareableResource.h
index 8f4993f3a..ca1d3f4e7 100644
--- a/Source/WebKit2/Shared/ShareableResource.h
+++ b/Source/WebKit2/Shared/ShareableResource.h
@@ -29,8 +29,6 @@
#if ENABLE(SHAREABLE_RESOURCE)
#include "SharedMemory.h"
-
-#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
@@ -51,10 +49,10 @@ public:
bool isNull() const { return m_handle.isNull(); }
unsigned size() const { return m_size; }
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, Handle&);
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, Handle&);
- PassRefPtr<WebCore::SharedBuffer> tryWrapInSharedBuffer() const;
+ RefPtr<WebCore::SharedBuffer> tryWrapInSharedBuffer() const;
private:
friend class ShareableResource;
@@ -65,10 +63,10 @@ public:
};
// Create a shareable resource that uses malloced memory.
- static PassRefPtr<ShareableResource> create(PassRefPtr<SharedMemory>, unsigned offset, unsigned size);
+ static Ref<ShareableResource> create(Ref<SharedMemory>&&, unsigned offset, unsigned size);
// Create a shareable resource from a handle.
- static PassRefPtr<ShareableResource> create(const Handle&);
+ static RefPtr<ShareableResource> map(const Handle&);
// Create a handle.
bool createHandle(Handle&);
@@ -79,9 +77,10 @@ public:
unsigned size() const;
private:
- ShareableResource(PassRefPtr<SharedMemory>, unsigned offset, unsigned size);
+ ShareableResource(Ref<SharedMemory>&&, unsigned offset, unsigned size);
+ RefPtr<WebCore::SharedBuffer> wrapInSharedBuffer();
- RefPtr<SharedMemory> m_sharedMemory;
+ Ref<SharedMemory> m_sharedMemory;
unsigned m_offset;
unsigned m_size;
diff --git a/Source/WebKit2/Shared/StatisticsData.cpp b/Source/WebKit2/Shared/StatisticsData.cpp
index 6199e8c89..8af6afa6d 100644
--- a/Source/WebKit2/Shared/StatisticsData.cpp
+++ b/Source/WebKit2/Shared/StatisticsData.cpp
@@ -30,7 +30,7 @@
namespace WebKit {
-void StatisticsData::encode(IPC::ArgumentEncoder& encoder) const
+void StatisticsData::encode(IPC::Encoder& encoder) const
{
encoder << statisticsNumbers;
encoder << javaScriptProtectedObjectTypeCounts;
@@ -38,7 +38,7 @@ void StatisticsData::encode(IPC::ArgumentEncoder& encoder) const
encoder << webCoreCacheStatistics;
}
-bool StatisticsData::decode(IPC::ArgumentDecoder& decoder, StatisticsData& statisticsData)
+bool StatisticsData::decode(IPC::Decoder& decoder, StatisticsData& statisticsData)
{
if (!decoder.decode(statisticsData.statisticsNumbers))
return false;
diff --git a/Source/WebKit2/Shared/StatisticsData.h b/Source/WebKit2/Shared/StatisticsData.h
index 1494b2a74..f8e24a82a 100644
--- a/Source/WebKit2/Shared/StatisticsData.h
+++ b/Source/WebKit2/Shared/StatisticsData.h
@@ -26,8 +26,8 @@
#ifndef StatisticsData_h
#define StatisticsData_h
-#include "ArgumentDecoder.h"
-#include "ArgumentEncoder.h"
+#include "Decoder.h"
+#include "Encoder.h"
#include <wtf/HashMap.h>
#include <wtf/Vector.h>
#include <wtf/text/StringHash.h>
@@ -36,8 +36,8 @@
namespace WebKit {
struct StatisticsData {
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, StatisticsData&);
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, StatisticsData&);
HashMap<String, uint64_t> statisticsNumbers;
HashMap<String, uint64_t> javaScriptProtectedObjectTypeCounts;
diff --git a/Source/WebKit2/Shared/TextCheckerState.h b/Source/WebKit2/Shared/TextCheckerState.h
index 0473032e6..ce66f1025 100644
--- a/Source/WebKit2/Shared/TextCheckerState.h
+++ b/Source/WebKit2/Shared/TextCheckerState.h
@@ -23,23 +23,22 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef TextCheckerState_h
-#define TextCheckerState_h
+#pragma once
#include "ArgumentCoders.h"
namespace WebKit {
struct TextCheckerState {
- bool isContinuousSpellCheckingEnabled;
- bool isGrammarCheckingEnabled;
-
-#if PLATFORM(MAC)
- bool isAutomaticSpellingCorrectionEnabled;
- bool isAutomaticQuoteSubstitutionEnabled;
- bool isAutomaticDashSubstitutionEnabled;
- bool isAutomaticLinkDetectionEnabled;
- bool isAutomaticTextReplacementEnabled;
+ bool isContinuousSpellCheckingEnabled { false };
+ bool isGrammarCheckingEnabled { false };
+
+#if USE(APPKIT)
+ bool isAutomaticSpellingCorrectionEnabled { false };
+ bool isAutomaticQuoteSubstitutionEnabled { false };
+ bool isAutomaticDashSubstitutionEnabled { false };
+ bool isAutomaticLinkDetectionEnabled { false };
+ bool isAutomaticTextReplacementEnabled { false };
#endif
};
@@ -48,5 +47,3 @@ struct TextCheckerState {
namespace IPC {
template<> struct ArgumentCoder<WebKit::TextCheckerState> : SimpleArgumentCoder<WebKit::TextCheckerState> { };
};
-
-#endif // TextCheckerState_h
diff --git a/Source/WebKit2/Shared/UpdateInfo.cpp b/Source/WebKit2/Shared/UpdateInfo.cpp
index 8a7985798..4502ce17a 100644
--- a/Source/WebKit2/Shared/UpdateInfo.cpp
+++ b/Source/WebKit2/Shared/UpdateInfo.cpp
@@ -30,7 +30,7 @@
namespace WebKit {
-void UpdateInfo::encode(IPC::ArgumentEncoder& encoder) const
+void UpdateInfo::encode(IPC::Encoder& encoder) const
{
encoder << viewSize;
encoder << deviceScaleFactor;
@@ -43,7 +43,7 @@ void UpdateInfo::encode(IPC::ArgumentEncoder& encoder) const
encoder << bitmapOffset;
}
-bool UpdateInfo::decode(IPC::ArgumentDecoder& decoder, UpdateInfo& result)
+bool UpdateInfo::decode(IPC::Decoder& decoder, UpdateInfo& result)
{
if (!decoder.decode(result.viewSize))
return false;
diff --git a/Source/WebKit2/Shared/UpdateInfo.h b/Source/WebKit2/Shared/UpdateInfo.h
index d4c110d0e..b1d4af9f7 100644
--- a/Source/WebKit2/Shared/UpdateInfo.h
+++ b/Source/WebKit2/Shared/UpdateInfo.h
@@ -29,10 +29,11 @@
#include "ShareableBitmap.h"
#include <WebCore/IntRect.h>
#include <wtf/Noncopyable.h>
+#include <wtf/Vector.h>
namespace IPC {
- class ArgumentDecoder;
- class ArgumentEncoder;
+class Decoder;
+class Encoder;
}
namespace WebKit {
@@ -43,8 +44,8 @@ class UpdateInfo {
public:
UpdateInfo() { }
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, UpdateInfo&);
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, UpdateInfo&);
// The size of the web view.
WebCore::IntSize viewSize;
diff --git a/Source/WebKit2/Shared/UserData.cpp b/Source/WebKit2/Shared/UserData.cpp
index 5e78b0950..533373c16 100644
--- a/Source/WebKit2/Shared/UserData.cpp
+++ b/Source/WebKit2/Shared/UserData.cpp
@@ -28,23 +28,39 @@
#include "APIArray.h"
#include "APIData.h"
+#include "APIDictionary.h"
#include "APIError.h"
#include "APIFrameHandle.h"
#include "APIGeometry.h"
#include "APINumber.h"
+#include "APIPageGroupHandle.h"
+#include "APIPageHandle.h"
+#include "APISerializedScriptValue.h"
#include "APIString.h"
#include "APIURL.h"
#include "APIURLRequest.h"
#include "APIURLResponse.h"
+#include "APIUserContentURLPattern.h"
#include "ArgumentCoders.h"
-#include "ArgumentEncoder.h"
-#include "MutableDictionary.h"
-#include "WebSerializedScriptValue.h"
+#include "Encoder.h"
+#include "ShareableBitmap.h"
+#include "WebCertificateInfo.h"
+#include "WebImage.h"
+#include "WebRenderLayer.h"
+#include "WebRenderObject.h"
+
+#if PLATFORM(COCOA)
+#include "ObjCObjectGraph.h"
+#endif
namespace WebKit {
-UserData::UserData(API::Object* object)
- : m_object(object)
+UserData::UserData()
+{
+}
+
+UserData::UserData(RefPtr<API::Object>&& object)
+ : m_object(WTFMove(object))
{
}
@@ -52,49 +68,90 @@ UserData::~UserData()
{
}
-RefPtr<API::Object> UserData::transform(API::Object* object, const std::function<RefPtr<API::Object> (const API::Object&)> transformer)
+static bool shouldTransform(const API::Object& object, const UserData::Transformer& transformer)
{
- if (!object)
- return nullptr;
+ if (object.type() == API::Object::Type::Array) {
+ const auto& array = static_cast<const API::Array&>(object);
- if (object->type() == API::Object::Type::Array) {
- auto& array = static_cast<API::Array&>(*object);
+ for (const auto& element : array.elements()) {
+ if (!element)
+ continue;
+
+ if (shouldTransform(*element, transformer))
+ return true;
+ }
+ }
+
+ if (object.type() == API::Object::Type::Dictionary) {
+ const auto& dictionary = static_cast<const API::Dictionary&>(object);
+
+ for (const auto& keyValuePair : dictionary.map()) {
+ if (!keyValuePair.value)
+ continue;
+
+ if (shouldTransform(*keyValuePair.value, transformer))
+ return true;
+ }
+ }
+
+ return transformer.shouldTransformObject(object);
+}
+
+static RefPtr<API::Object> transformGraph(API::Object& object, const UserData::Transformer& transformer)
+{
+ if (object.type() == API::Object::Type::Array) {
+ auto& array = static_cast<API::Array&>(object);
Vector<RefPtr<API::Object>> elements;
elements.reserveInitialCapacity(array.elements().size());
- for (const auto& element : array.elements())
- elements.uncheckedAppend(transform(element.get(), transformer));
+ for (const auto& element : array.elements()) {
+ if (!element)
+ elements.uncheckedAppend(nullptr);
+ else
+ elements.uncheckedAppend(transformGraph(*element, transformer));
+ }
- return API::Array::create(std::move(elements));
+ return API::Array::create(WTFMove(elements));
}
- if (object->type() == API::Object::Type::Dictionary) {
- auto& dictionary = static_cast<ImmutableDictionary&>(*object);
+ if (object.type() == API::Object::Type::Dictionary) {
+ auto& dictionary = static_cast<API::Dictionary&>(object);
- ImmutableDictionary::MapType map;
- for (const auto& keyValuePair : dictionary.map())
- map.add(keyValuePair.key, transform(keyValuePair.value.get(), transformer));
-
- return ImmutableDictionary::create(std::move(map));
+ API::Dictionary::MapType map;
+ for (const auto& keyValuePair : dictionary.map()) {
+ if (!keyValuePair.value)
+ map.add(keyValuePair.key, nullptr);
+ else
+ map.add(keyValuePair.key, transformGraph(*keyValuePair.value, transformer));
+ }
+ return API::Dictionary::create(WTFMove(map));
}
- if (auto transformedObject = transformer(*object))
- return transformedObject;
+ return transformer.transformObject(object);
+}
+
+RefPtr<API::Object> UserData::transform(API::Object* object, const Transformer& transformer)
+{
+ if (!object)
+ return nullptr;
- return object;
+ if (!shouldTransform(*object, transformer))
+ return object;
+
+ return transformGraph(*object, transformer);
}
-void UserData::encode(IPC::ArgumentEncoder& encoder) const
+void UserData::encode(IPC::Encoder& encoder) const
{
encode(encoder, m_object.get());
}
-bool UserData::decode(IPC::ArgumentDecoder& decoder, UserData& userData)
+bool UserData::decode(IPC::Decoder& decoder, UserData& userData)
{
return decode(decoder, userData.m_object);
}
-void UserData::encode(IPC::ArgumentEncoder& encoder, const API::Object* object) const
+void UserData::encode(IPC::Encoder& encoder, const API::Object* object)
{
if (!object) {
encoder.encodeEnum(API::Object::Type::Null);
@@ -104,7 +161,7 @@ void UserData::encode(IPC::ArgumentEncoder& encoder, const API::Object* object)
encode(encoder, *object);
}
-void UserData::encode(IPC::ArgumentEncoder& encoder, const API::Object& object) const
+void UserData::encode(IPC::Encoder& encoder, const API::Object& object)
{
API::Object::Type type = object.type();
encoder.encodeEnum(type);
@@ -122,12 +179,18 @@ void UserData::encode(IPC::ArgumentEncoder& encoder, const API::Object& object)
static_cast<const API::Boolean&>(object).encode(encoder);
break;
+ case API::Object::Type::CertificateInfo: {
+ const auto& certificateInfo = static_cast<const WebCertificateInfo&>(object);
+ encoder << certificateInfo.certificateInfo();
+ break;
+ }
+
case API::Object::Type::Data:
static_cast<const API::Data&>(object).encode(encoder);
break;
case API::Object::Type::Dictionary: {
- auto& dictionary = static_cast<const ImmutableDictionary&>(object);
+ auto& dictionary = static_cast<const API::Dictionary&>(object);
auto& map = dictionary.map();
encoder << static_cast<uint64_t>(map.size());
@@ -138,16 +201,43 @@ void UserData::encode(IPC::ArgumentEncoder& encoder, const API::Object& object)
break;
}
+ case API::Object::Type::Double:
+ static_cast<const API::Double&>(object).encode(encoder);
+ break;
+
case API::Object::Type::Error:
static_cast<const API::Error&>(object).encode(encoder);
break;
- case API::Object::Type::FrameHandle: {
- auto& frameHandle = static_cast<const API::FrameHandle&>(object);
- encoder << frameHandle.frameID();
+ case API::Object::Type::FrameHandle:
+ static_cast<const API::FrameHandle&>(object).encode(encoder);
+ break;
+
+ case API::Object::Type::Image: {
+ auto& image = static_cast<const WebImage&>(object);
+
+ ShareableBitmap::Handle handle;
+ ASSERT(image.bitmap().isBackedBySharedMemory());
+ if (!image.bitmap().isBackedBySharedMemory() || !image.bitmap().createHandle(handle)) {
+ // Initial false indicates no allocated bitmap or is not shareable.
+ encoder << false;
+ break;
+ }
+
+ // Initial true indicates a bitmap was allocated and is shareable.
+ encoder << true;
+ encoder << handle;
break;
}
+ case API::Object::Type::PageGroupHandle:
+ static_cast<const API::PageGroupHandle&>(object).encode(encoder);
+ break;
+
+ case API::Object::Type::PageHandle:
+ static_cast<const API::PageHandle&>(object).encode(encoder);
+ break;
+
case API::Object::Type::Point:
static_cast<const API::Point&>(object).encode(encoder);
break;
@@ -156,8 +246,40 @@ void UserData::encode(IPC::ArgumentEncoder& encoder, const API::Object& object)
static_cast<const API::Rect&>(object).encode(encoder);
break;
+ case API::Object::Type::RenderLayer: {
+ auto& renderLayer = static_cast<const WebRenderLayer&>(object);
+
+ encode(encoder, renderLayer.renderer());
+ encoder << renderLayer.isReflection();
+ encoder << renderLayer.isClipping();
+ encoder << renderLayer.isClipped();
+ encoder << static_cast<uint32_t>(renderLayer.compositingLayerType());
+ encoder << renderLayer.absoluteBoundingBox();
+ encoder << renderLayer.backingStoreMemoryEstimate();
+ encode(encoder, renderLayer.negativeZOrderList());
+ encode(encoder, renderLayer.normalFlowList());
+ encode(encoder, renderLayer.positiveZOrderList());
+ encode(encoder, renderLayer.frameContentsLayer());
+ break;
+ }
+
+ case API::Object::Type::RenderObject: {
+ auto& renderObject = static_cast<const WebRenderObject&>(object);
+
+ encoder << renderObject.name();
+ encoder << renderObject.elementTagName();
+ encoder << renderObject.elementID();
+ encode(encoder, renderObject.elementClassNames());
+ encoder << renderObject.absolutePosition();
+ encoder << renderObject.frameRect();
+ encoder << renderObject.textSnippet();
+ encoder << renderObject.textLength();
+ encode(encoder, renderObject.children());
+ break;
+ }
+
case API::Object::Type::SerializedScriptValue: {
- auto& serializedScriptValue = static_cast<const WebSerializedScriptValue&>(object);
+ auto& serializedScriptValue = static_cast<const API::SerializedScriptValue&>(object);
encoder << serializedScriptValue.dataReference();
break;
}
@@ -172,10 +294,9 @@ void UserData::encode(IPC::ArgumentEncoder& encoder, const API::Object& object)
break;
}
- case API::Object::Type::URL: {
+ case API::Object::Type::URL:
static_cast<const API::URL&>(object).encode(encoder);
break;
- }
case API::Object::Type::URLRequest:
static_cast<const API::URLRequest&>(object).encode(encoder);
@@ -189,12 +310,24 @@ void UserData::encode(IPC::ArgumentEncoder& encoder, const API::Object& object)
static_cast<const API::UInt64&>(object).encode(encoder);
break;
+ case API::Object::Type::UserContentURLPattern: {
+ auto& urlPattern = static_cast<const API::UserContentURLPattern&>(object);
+ encoder << urlPattern.patternString();
+ break;
+ }
+
+#if PLATFORM(COCOA)
+ case API::Object::Type::ObjCObjectGraph:
+ static_cast<const ObjCObjectGraph&>(object).encode(encoder);
+ break;
+#endif
+
default:
ASSERT_NOT_REACHED();
}
}
-bool UserData::decode(IPC::ArgumentDecoder& decoder, RefPtr<API::Object>& result)
+bool UserData::decode(IPC::Decoder& decoder, RefPtr<API::Object>& result)
{
API::Object::Type type;
if (!decoder.decodeEnum(type))
@@ -212,10 +345,10 @@ bool UserData::decode(IPC::ArgumentDecoder& decoder, RefPtr<API::Object>& result
if (!decode(decoder, element))
return false;
- elements.append(std::move(element));
+ elements.append(WTFMove(element));
}
- result = API::Array::create(std::move(elements));
+ result = API::Array::create(WTFMove(elements));
break;
}
@@ -224,6 +357,14 @@ bool UserData::decode(IPC::ArgumentDecoder& decoder, RefPtr<API::Object>& result
return false;
break;
+ case API::Object::Type::CertificateInfo: {
+ WebCore::CertificateInfo certificateInfo;
+ if (!decoder.decode(certificateInfo))
+ return false;
+ result = WebCertificateInfo::create(certificateInfo);
+ break;
+ }
+
case API::Object::Type::Data:
if (!API::Data::decode(decoder, result))
return false;
@@ -234,7 +375,7 @@ bool UserData::decode(IPC::ArgumentDecoder& decoder, RefPtr<API::Object>& result
if (!decoder.decode(size))
return false;
- ImmutableDictionary::MapType map;
+ API::Dictionary::MapType map;
for (size_t i = 0; i < size; ++i) {
String key;
if (!decoder.decode(key))
@@ -244,11 +385,11 @@ bool UserData::decode(IPC::ArgumentDecoder& decoder, RefPtr<API::Object>& result
if (!decode(decoder, value))
return false;
- if (!map.add(std::move(key), std::move(value)).isNewEntry)
+ if (!map.add(WTFMove(key), WTFMove(value)).isNewEntry)
return false;
}
- result = ImmutableDictionary::create(std::move(map));
+ result = API::Dictionary::create(WTFMove(map));
break;
}
@@ -262,19 +403,45 @@ bool UserData::decode(IPC::ArgumentDecoder& decoder, RefPtr<API::Object>& result
return false;
break;
- case API::Object::Type::FrameHandle: {
- uint64_t frameID;
- if (!decoder.decode(frameID))
+ case API::Object::Type::FrameHandle:
+ if (!API::FrameHandle::decode(decoder, result))
return false;
+ break;
+
+ case API::Object::Type::Image: {
+ bool didEncode = false;
+ if (!decoder.decode(didEncode))
+ return false;
+
+ if (!didEncode)
+ break;
- result = API::FrameHandle::create(frameID);
+ ShareableBitmap::Handle handle;
+ if (!decoder.decode(handle))
+ return false;
+
+ auto bitmap = ShareableBitmap::create(handle);
+ if (!bitmap)
+ return false;
+
+ result = WebImage::create(bitmap.releaseNonNull());
break;
}
case API::Object::Type::Null:
result = nullptr;
break;
-
+
+ case API::Object::Type::PageGroupHandle:
+ if (!API::PageGroupHandle::decode(decoder, result))
+ return false;
+ break;
+
+ case API::Object::Type::PageHandle:
+ if (!API::PageHandle::decode(decoder, result))
+ return false;
+ break;
+
case API::Object::Type::Point:
if (!API::Point::decode(decoder, result))
return false;
@@ -285,13 +452,89 @@ bool UserData::decode(IPC::ArgumentDecoder& decoder, RefPtr<API::Object>& result
return false;
break;
+ case API::Object::Type::RenderLayer: {
+ RefPtr<API::Object> renderer;
+ bool isReflection;
+ bool isClipping;
+ bool isClipped;
+ uint32_t compositingLayerTypeAsUInt32;
+ WebCore::IntRect absoluteBoundingBox;
+ double backingStoreMemoryEstimate;
+ RefPtr<API::Object> negativeZOrderList;
+ RefPtr<API::Object> normalFlowList;
+ RefPtr<API::Object> positiveZOrderList;
+ RefPtr<API::Object> frameContentsLayer;
+
+ if (!decode(decoder, renderer))
+ return false;
+ if (renderer->type() != API::Object::Type::RenderObject)
+ return false;
+ if (!decoder.decode(isReflection))
+ return false;
+ if (!decoder.decode(isClipping))
+ return false;
+ if (!decoder.decode(isClipped))
+ return false;
+ if (!decoder.decode(compositingLayerTypeAsUInt32))
+ return false;
+ if (!decoder.decode(absoluteBoundingBox))
+ return false;
+ if (!decoder.decode(backingStoreMemoryEstimate))
+ return false;
+ if (!decode(decoder, negativeZOrderList))
+ return false;
+ if (!decode(decoder, normalFlowList))
+ return false;
+ if (!decode(decoder, positiveZOrderList))
+ return false;
+ if (!decode(decoder, frameContentsLayer))
+ return false;
+
+ result = WebRenderLayer::create(static_pointer_cast<WebRenderObject>(renderer), isReflection, isClipping, isClipped, static_cast<WebRenderLayer::CompositingLayerType>(compositingLayerTypeAsUInt32), absoluteBoundingBox, backingStoreMemoryEstimate, static_pointer_cast<API::Array>(negativeZOrderList), static_pointer_cast<API::Array>(normalFlowList), static_pointer_cast<API::Array>(positiveZOrderList), static_pointer_cast<WebRenderLayer>(frameContentsLayer));
+ break;
+ }
+
+ case API::Object::Type::RenderObject: {
+ String name;
+ String textSnippet;
+ String elementTagName;
+ String elementID;
+ unsigned textLength;
+ RefPtr<API::Object> elementClassNames;
+ WebCore::IntPoint absolutePosition;
+ WebCore::IntRect frameRect;
+ RefPtr<API::Object> children;
+
+ if (!decoder.decode(name))
+ return false;
+ if (!decoder.decode(elementTagName))
+ return false;
+ if (!decoder.decode(elementID))
+ return false;
+ if (!decode(decoder, elementClassNames))
+ return false;
+ if (!decoder.decode(absolutePosition))
+ return false;
+ if (!decoder.decode(frameRect))
+ return false;
+ if (!decoder.decode(textSnippet))
+ return false;
+ if (!decoder.decode(textLength))
+ return false;
+ if (!decode(decoder, children))
+ return false;
+ if (children && children->type() != API::Object::Type::Array)
+ return false;
+ result = WebRenderObject::create(name, elementTagName, elementID, static_pointer_cast<API::Array>(elementClassNames), absolutePosition, frameRect, textSnippet, textLength, static_pointer_cast<API::Array>(children));
+ break;
+ }
+
case API::Object::Type::SerializedScriptValue: {
IPC::DataReference dataReference;
if (!decoder.decode(dataReference))
return false;
- auto vector = dataReference.vector();
- result = WebSerializedScriptValue::adopt(vector);
+ result = API::SerializedScriptValue::adopt(dataReference.vector());
break;
}
@@ -329,6 +572,21 @@ bool UserData::decode(IPC::ArgumentDecoder& decoder, RefPtr<API::Object>& result
return false;
break;
+ case API::Object::Type::UserContentURLPattern: {
+ String string;
+ if (!decoder.decode(string))
+ return false;
+ result = API::UserContentURLPattern::create(string);
+ break;
+ }
+
+#if PLATFORM(COCOA)
+ case API::Object::Type::ObjCObjectGraph:
+ if (!ObjCObjectGraph::decode(decoder, result))
+ return false;
+ break;
+#endif
+
default:
ASSERT_NOT_REACHED();
}
diff --git a/Source/WebKit2/Shared/UserData.h b/Source/WebKit2/Shared/UserData.h
index df69b5a02..4ee6092ad 100644
--- a/Source/WebKit2/Shared/UserData.h
+++ b/Source/WebKit2/Shared/UserData.h
@@ -26,37 +26,39 @@
#ifndef UserData_h
#define UserData_h
-#include <functional>
+#include "APIObject.h"
#include <wtf/RefPtr.h>
-namespace API {
-class Object;
-}
-
namespace IPC {
-class ArgumentEncoder;
-class ArgumentDecoder;
+class Encoder;
+class Decoder;
}
namespace WebKit {
class UserData {
public:
- explicit UserData(API::Object* = nullptr);
+ UserData();
+ explicit UserData(RefPtr<API::Object>&&);
~UserData();
- static RefPtr<API::Object> transform(API::Object*, const std::function<RefPtr<API::Object> (const API::Object&)> transformer);
+ struct Transformer {
+ virtual ~Transformer() { }
+ virtual bool shouldTransformObject(const API::Object&) const = 0;
+ virtual RefPtr<API::Object> transformObject(API::Object&) const = 0;
+ };
+ static RefPtr<API::Object> transform(API::Object*, const Transformer&);
API::Object* object() const { return m_object.get(); }
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, UserData&);
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, UserData&);
-private:
- void encode(IPC::ArgumentEncoder&, const API::Object*) const;
- void encode(IPC::ArgumentEncoder&, const API::Object&) const;
+ static void encode(IPC::Encoder&, const API::Object*);
+ static bool decode(IPC::Decoder&, RefPtr<API::Object>&);
- static bool decode(IPC::ArgumentDecoder&, RefPtr<API::Object>&);
+private:
+ static void encode(IPC::Encoder&, const API::Object&);
RefPtr<API::Object> m_object;
};
diff --git a/Source/WebKit2/Shared/UserMessageCoders.h b/Source/WebKit2/Shared/UserMessageCoders.h
deleted file mode 100644
index 8f4f57688..000000000
--- a/Source/WebKit2/Shared/UserMessageCoders.h
+++ /dev/null
@@ -1,538 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-
-#ifndef UserMessageCoders_h
-#define UserMessageCoders_h
-
-#include "APIArray.h"
-#include "APIData.h"
-#include "APIError.h"
-#include "APIGeometry.h"
-#include "APINumber.h"
-#include "APIString.h"
-#include "APIURL.h"
-#include "APIURLRequest.h"
-#include "APIURLResponse.h"
-#include "ArgumentDecoder.h"
-#include "ArgumentEncoder.h"
-#include "DataReference.h"
-#include "ImmutableDictionary.h"
-#include "ShareableBitmap.h"
-#include "WebCertificateInfo.h"
-#include "WebCoreArgumentCoders.h"
-#include "WebImage.h"
-#include "WebRenderLayer.h"
-#include "WebRenderObject.h"
-#include "WebSerializedScriptValue.h"
-#include "WebUserContentURLPattern.h"
-
-namespace WebKit {
-
-// - Null -> Null
-// - API::Array -> API::Array
-// - Dictionary -> Dictionary
-// - SerializedScriptValue -> SerializedScriptValue
-// - API::String -> API::String
-// - UserContentURLPattern -> UserContentURLPattern
-// - WebCertificateInfo -> WebCertificateInfo
-// - API::Data -> API::Data
-// - API::Double -> API::Double
-// - WebImage -> WebImage
-// - WebRenderLayer -> WebRenderLayer
-// - WebRenderObject -> WebRenderObject
-// - API::UInt64 -> API::UInt64
-// - API::URL -> API::URL
-// - API::URLRequest -> API::URLRequest
-// - API::URLResponse -> API::URLResponse
-// - API::Error -> API::Error
-
-template<typename Owner>
-class UserMessageEncoder {
-public:
- bool baseEncode(IPC::ArgumentEncoder& encoder, const Owner& coder, API::Object::Type& type) const
- {
- if (!m_root) {
- encoder << static_cast<uint32_t>(API::Object::Type::Null);
- return true;
- }
-
- type = m_root->type();
- encoder << static_cast<uint32_t>(type);
-
- switch (type) {
- case API::Object::Type::Array: {
- API::Array* array = static_cast<API::Array*>(m_root);
- encoder << static_cast<uint64_t>(array->size());
- for (size_t i = 0; i < array->size(); ++i)
- encoder << Owner(coder, array->at(i));
- return true;
- }
- case API::Object::Type::Dictionary: {
- ImmutableDictionary* dictionary = static_cast<ImmutableDictionary*>(m_root);
- const ImmutableDictionary::MapType& map = dictionary->map();
- encoder << static_cast<uint64_t>(map.size());
-
- ImmutableDictionary::MapType::const_iterator it = map.begin();
- ImmutableDictionary::MapType::const_iterator end = map.end();
- for (; it != end; ++it) {
- encoder << it->key;
- encoder << Owner(coder, it->value.get());
- }
- return true;
- }
- case API::Object::Type::String: {
- API::String* string = static_cast<API::String*>(m_root);
- encoder << string->string();
- return true;
- }
- case API::Object::Type::SerializedScriptValue: {
- WebSerializedScriptValue* scriptValue = static_cast<WebSerializedScriptValue*>(m_root);
- encoder << scriptValue->dataReference();
- return true;
- }
- case API::Object::Type::Boolean: {
- API::Boolean* booleanObject = static_cast<API::Boolean*>(m_root);
- encoder << booleanObject->value();
- return true;
- }
- case API::Object::Type::Double: {
- API::Double* doubleObject = static_cast<API::Double*>(m_root);
- encoder << doubleObject->value();
- return true;
- }
- case API::Object::Type::UInt64: {
- API::UInt64* uint64Object = static_cast<API::UInt64*>(m_root);
- encoder << uint64Object->value();
- return true;
- }
- case API::Object::Type::Point: {
- API::Point* pointObject = static_cast<API::Point*>(m_root);
- encoder << pointObject->point().x;
- encoder << pointObject->point().y;
- return true;
- }
- case API::Object::Type::Size: {
- API::Size* sizeObject = static_cast<API::Size*>(m_root);
- encoder << sizeObject->size().width;
- encoder << sizeObject->size().height;
- return true;
- }
- case API::Object::Type::Rect: {
- API::Rect* rectObject = static_cast<API::Rect*>(m_root);
- encoder << rectObject->rect().origin.x;
- encoder << rectObject->rect().origin.y;
- encoder << rectObject->rect().size.width;
- encoder << rectObject->rect().size.height;
- return true;
- }
- case API::Object::Type::RenderLayer: {
- WebRenderLayer* renderLayer = static_cast<WebRenderLayer*>(m_root);
- encoder << Owner(coder, renderLayer->renderer());
- encoder << renderLayer->isReflection();
- encoder << renderLayer->isClipping();
- encoder << renderLayer->isClipped();
- encoder << static_cast<uint32_t>(renderLayer->compositingLayerType());
- encoder << renderLayer->absoluteBoundingBox();
- encoder << Owner(coder, renderLayer->negativeZOrderList());
- encoder << Owner(coder, renderLayer->normalFlowList());
- encoder << Owner(coder, renderLayer->positiveZOrderList());
- return true;
- }
- case API::Object::Type::RenderObject: {
- WebRenderObject* renderObject = static_cast<WebRenderObject*>(m_root);
- encoder << renderObject->name();
- encoder << renderObject->elementTagName();
- encoder << renderObject->elementID();
- encoder << Owner(coder, renderObject->elementClassNames());
- encoder << renderObject->absolutePosition();
- encoder << renderObject->frameRect();
- encoder << Owner(coder, renderObject->children());
- return true;
- }
- case API::Object::Type::URL: {
- API::URL* urlObject = static_cast<API::URL*>(m_root);
- encoder << urlObject->string();
- return true;
- }
- case API::Object::Type::URLRequest: {
- API::URLRequest* urlRequestObject = static_cast<API::URLRequest*>(m_root);
- encoder << urlRequestObject->resourceRequest();
- return true;
- }
- case API::Object::Type::URLResponse: {
- API::URLResponse* urlResponseObject = static_cast<API::URLResponse*>(m_root);
- encoder << urlResponseObject->resourceResponse();
- return true;
- }
- case API::Object::Type::UserContentURLPattern: {
- WebUserContentURLPattern* urlPattern = static_cast<WebUserContentURLPattern*>(m_root);
- encoder << urlPattern->patternString();
- return true;
- }
- case API::Object::Type::Image: {
- WebImage* image = static_cast<WebImage*>(m_root);
-
- ShareableBitmap::Handle handle;
- ASSERT(!image->bitmap() || image->bitmap()->isBackedBySharedMemory());
- if (!image->bitmap() || !image->bitmap()->isBackedBySharedMemory() || !image->bitmap()->createHandle(handle)) {
- // Initial false indicates no allocated bitmap or is not shareable.
- encoder << false;
- return true;
- }
-
- // Initial true indicates a bitmap was allocated and is shareable.
- encoder << true;
-
- encoder << handle;
- return true;
- }
- case API::Object::Type::Data: {
- API::Data* data = static_cast<API::Data*>(m_root);
- encoder << data->dataReference();
- return true;
- }
- case API::Object::Type::CertificateInfo: {
- WebCertificateInfo* certificateInfo = static_cast<WebCertificateInfo*>(m_root);
- encoder << certificateInfo->certificateInfo();
- return true;
- }
- case API::Object::Type::Error: {
- API::Error* errorObject = static_cast<API::Error*>(m_root);
- encoder << errorObject->platformError();
- return true;
- }
- default:
- break;
- }
-
- return false;
- }
-
-protected:
- UserMessageEncoder(API::Object* root)
- : m_root(root)
- {
- }
-
- API::Object* m_root;
-};
-
-
-// Handles
-// - Null -> Null
-// - API::Array -> API::Array
-// - Dictionary -> Dictionary
-// - SerializedScriptValue -> SerializedScriptValue
-// - API::String -> API::String
-// - UserContentURLPattern -> UserContentURLPattern
-// - WebCertificateInfo -> WebCertificateInfo
-// - API::Data -> API::Data
-// - API::Double -> API::Double
-// - WebImage -> WebImage
-// - API::UInt64 -> API::UInt64
-// - API::URL -> API::URL
-// - API::URLRequest -> API::URLRequest
-// - API::URLResponse -> API::URLResponse
-// - API::Error -> API::Error
-
-template<typename Owner>
-class UserMessageDecoder {
-public:
- static bool baseDecode(IPC::ArgumentDecoder& decoder, Owner& coder, API::Object::Type& type)
- {
- uint32_t typeAsUInt32;
- if (!decoder.decode(typeAsUInt32))
- return false;
-
- type = static_cast<API::Object::Type>(typeAsUInt32);
-
- switch (type) {
- case API::Object::Type::Array: {
- uint64_t size;
- if (!decoder.decode(size))
- return false;
-
- Vector<RefPtr<API::Object>> vector;
- for (size_t i = 0; i < size; ++i) {
- RefPtr<API::Object> element;
- Owner messageCoder(coder, element);
- if (!decoder.decode(messageCoder))
- return false;
- vector.append(element.release());
- }
-
- coder.m_root = API::Array::create(std::move(vector));
- break;
- }
- case API::Object::Type::Dictionary: {
- uint64_t size;
- if (!decoder.decode(size))
- return false;
-
- ImmutableDictionary::MapType map;
- for (size_t i = 0; i < size; ++i) {
- String key;
- if (!decoder.decode(key))
- return false;
-
- RefPtr<API::Object> element;
- Owner messageCoder(coder, element);
- if (!decoder.decode(messageCoder))
- return false;
-
- ImmutableDictionary::MapType::AddResult result = map.set(key, element.release());
- if (!result.isNewEntry)
- return false;
- }
-
- coder.m_root = ImmutableDictionary::create(std::move(map));
- break;
- }
- case API::Object::Type::String: {
- String string;
- if (!decoder.decode(string))
- return false;
- coder.m_root = API::String::create(string);
- break;
- }
- case API::Object::Type::SerializedScriptValue: {
- IPC::DataReference dataReference;
- if (!decoder.decode(dataReference))
- return false;
-
- Vector<uint8_t> vector = dataReference.vector();
- coder.m_root = WebSerializedScriptValue::adopt(vector);
- break;
- }
- case API::Object::Type::Double: {
- double value;
- if (!decoder.decode(value))
- return false;
- coder.m_root = API::Double::create(value);
- break;
- }
- case API::Object::Type::UInt64: {
- uint64_t value;
- if (!decoder.decode(value))
- return false;
- coder.m_root = API::UInt64::create(value);
- break;
- }
- case API::Object::Type::Boolean: {
- bool value;
- if (!decoder.decode(value))
- return false;
- coder.m_root = API::Boolean::create(value);
- break;
- }
- case API::Object::Type::Size: {
- double width;
- double height;
- if (!decoder.decode(width))
- return false;
- if (!decoder.decode(height))
- return false;
- coder.m_root = API::Size::create(WKSizeMake(width, height));
- break;
- }
- case API::Object::Type::Point: {
- double x;
- double y;
- if (!decoder.decode(x))
- return false;
- if (!decoder.decode(y))
- return false;
- coder.m_root = API::Point::create(WKPointMake(x, y));
- break;
- }
- case API::Object::Type::Rect: {
- double x;
- double y;
- double width;
- double height;
- if (!decoder.decode(x))
- return false;
- if (!decoder.decode(y))
- return false;
- if (!decoder.decode(width))
- return false;
- if (!decoder.decode(height))
- return false;
- coder.m_root = API::Rect::create(WKRectMake(x, y, width, height));
- break;
- }
- case API::Object::Type::RenderLayer: {
- RefPtr<API::Object> renderer;
- bool isReflection;
- bool isClipping;
- bool isClipped;
- uint32_t compositingLayerTypeAsUInt32;
- WebCore::IntRect absoluteBoundingBox;
- RefPtr<API::Object> negativeZOrderList;
- RefPtr<API::Object> normalFlowList;
- RefPtr<API::Object> positiveZOrderList;
-
- Owner rendererCoder(coder, renderer);
- if (!decoder.decode(rendererCoder))
- return false;
- if (renderer->type() != API::Object::Type::RenderObject)
- return false;
- if (!decoder.decode(isReflection))
- return false;
- if (!decoder.decode(isClipping))
- return false;
- if (!decoder.decode(isClipped))
- return false;
- if (!decoder.decode(compositingLayerTypeAsUInt32))
- return false;
- if (!decoder.decode(absoluteBoundingBox))
- return false;
- Owner negativeZOrderListCoder(coder, negativeZOrderList);
- if (!decoder.decode(negativeZOrderListCoder))
- return false;
- Owner normalFlowListCoder(coder, normalFlowList);
- if (!decoder.decode(normalFlowListCoder))
- return false;
- Owner positiveZOrderListCoder(coder, positiveZOrderList);
- if (!decoder.decode(positiveZOrderListCoder))
- return false;
- coder.m_root = WebRenderLayer::create(static_pointer_cast<WebRenderObject>(renderer), isReflection, isClipping, isClipped, static_cast<WebRenderLayer::CompositingLayerType>(compositingLayerTypeAsUInt32),
- absoluteBoundingBox, static_pointer_cast<API::Array>(negativeZOrderList), static_pointer_cast<API::Array>(normalFlowList),
- static_pointer_cast<API::Array>(positiveZOrderList));
- break;
- }
- case API::Object::Type::RenderObject: {
- String name;
- String elementTagName;
- String elementID;
- RefPtr<API::Object> elementClassNames;
- WebCore::IntPoint absolutePosition;
- WebCore::IntRect frameRect;
- RefPtr<API::Object> children;
-
- if (!decoder.decode(name))
- return false;
- if (!decoder.decode(elementTagName))
- return false;
- if (!decoder.decode(elementID))
- return false;
- Owner classNamesCoder(coder, elementClassNames);
- if (!decoder.decode(classNamesCoder))
- return false;
- if (!decoder.decode(absolutePosition))
- return false;
- if (!decoder.decode(frameRect))
- return false;
- Owner messageCoder(coder, children);
- if (!decoder.decode(messageCoder))
- return false;
- if (children && children->type() != API::Object::Type::Array)
- return false;
- coder.m_root = WebRenderObject::create(name, elementTagName, elementID, static_pointer_cast<API::Array>(elementClassNames), absolutePosition, frameRect, static_pointer_cast<API::Array>(children));
- break;
- }
- case API::Object::Type::URL: {
- String string;
- if (!decoder.decode(string))
- return false;
- coder.m_root = API::URL::create(string);
- break;
- }
- case API::Object::Type::URLRequest: {
- WebCore::ResourceRequest request;
- if (!decoder.decode(request))
- return false;
- coder.m_root = API::URLRequest::create(request);
- break;
- }
- case API::Object::Type::URLResponse: {
- WebCore::ResourceResponse response;
- if (!decoder.decode(response))
- return false;
- coder.m_root = API::URLResponse::create(response);
- break;
- }
- case API::Object::Type::UserContentURLPattern: {
- String string;
- if (!decoder.decode(string))
- return false;
- coder.m_root = WebUserContentURLPattern::create(string);
- break;
- }
- case API::Object::Type::Image: {
- bool didEncode = false;
- if (!decoder.decode(didEncode))
- return false;
-
- if (!didEncode)
- break;
-
- ShareableBitmap::Handle handle;
- if (!decoder.decode(handle))
- return false;
-
- coder.m_root = WebImage::create(ShareableBitmap::create(handle));
- return true;
- }
- case API::Object::Type::Data: {
- IPC::DataReference dataReference;
- if (!decoder.decode(dataReference))
- return false;
- coder.m_root = API::Data::create(dataReference.data(), dataReference.size());
- break;
- }
- case API::Object::Type::CertificateInfo: {
- WebCore::CertificateInfo certificateInfo;
- if (!decoder.decode(certificateInfo))
- return false;
- coder.m_root = WebCertificateInfo::create(certificateInfo);
- break;
- }
- case API::Object::Type::Error: {
- WebCore::ResourceError resourceError;
- if (!decoder.decode(resourceError))
- return false;
- coder.m_root = API::Error::create(resourceError);
- break;
- }
- default:
- break;
- }
-
- return true;
- }
-
-protected:
- UserMessageDecoder(RefPtr<API::Object>& root)
- : m_root(root)
- {
- }
-
- RefPtr<API::Object>& m_root;
-};
-
-} // namespace WebKit
-
-#endif // UserMessageCoders_h
diff --git a/Source/WebKit2/Shared/VisibleContentRectUpdateInfo.cpp b/Source/WebKit2/Shared/VisibleContentRectUpdateInfo.cpp
new file mode 100644
index 000000000..277aead77
--- /dev/null
+++ b/Source/WebKit2/Shared/VisibleContentRectUpdateInfo.cpp
@@ -0,0 +1,135 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+#include "config.h"
+#include "VisibleContentRectUpdateInfo.h"
+
+#include "WebCoreArgumentCoders.h"
+#include <WebCore/TextStream.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void VisibleContentRectUpdateInfo::encode(IPC::Encoder& encoder) const
+{
+ encoder << m_exposedContentRect;
+ encoder << m_unobscuredContentRect;
+ encoder << m_unobscuredRectInScrollViewCoordinates;
+ encoder << m_customFixedPositionRect;
+ encoder << m_obscuredInset;
+ encoder << m_lastLayerTreeTransactionID;
+ encoder << m_scale;
+ encoder << m_timestamp;
+ encoder << m_horizontalVelocity;
+ encoder << m_verticalVelocity;
+ encoder << m_scaleChangeRate;
+ encoder << m_inStableState;
+ encoder << m_isFirstUpdateForNewViewSize;
+ encoder << m_isChangingObscuredInsetsInteractively;
+ encoder << m_allowShrinkToFit;
+ encoder << m_enclosedInScrollableAncestorView;
+}
+
+bool VisibleContentRectUpdateInfo::decode(IPC::Decoder& decoder, VisibleContentRectUpdateInfo& result)
+{
+ if (!decoder.decode(result.m_exposedContentRect))
+ return false;
+ if (!decoder.decode(result.m_unobscuredContentRect))
+ return false;
+ if (!decoder.decode(result.m_unobscuredRectInScrollViewCoordinates))
+ return false;
+ if (!decoder.decode(result.m_customFixedPositionRect))
+ return false;
+ if (!decoder.decode(result.m_obscuredInset))
+ return false;
+ if (!decoder.decode(result.m_lastLayerTreeTransactionID))
+ return false;
+ if (!decoder.decode(result.m_scale))
+ return false;
+ if (!decoder.decode(result.m_timestamp))
+ return false;
+ if (!decoder.decode(result.m_horizontalVelocity))
+ return false;
+ if (!decoder.decode(result.m_verticalVelocity))
+ return false;
+ if (!decoder.decode(result.m_scaleChangeRate))
+ return false;
+ if (!decoder.decode(result.m_inStableState))
+ return false;
+ if (!decoder.decode(result.m_isFirstUpdateForNewViewSize))
+ return false;
+ if (!decoder.decode(result.m_isChangingObscuredInsetsInteractively))
+ return false;
+ if (!decoder.decode(result.m_allowShrinkToFit))
+ return false;
+ if (!decoder.decode(result.m_enclosedInScrollableAncestorView))
+ return false;
+
+ return true;
+}
+
+String VisibleContentRectUpdateInfo::dump() const
+{
+ TextStream stream;
+ stream << *this;
+ return stream.release();
+}
+
+TextStream& operator<<(TextStream& ts, const VisibleContentRectUpdateInfo& info)
+{
+ TextStream::GroupScope scope(ts);
+
+ ts << "VisibleContentRectUpdateInfo";
+
+ ts.dumpProperty("lastLayerTreeTransactionID", info.lastLayerTreeTransactionID());
+
+ ts.dumpProperty("exposedContentRect", info.exposedContentRect());
+ ts.dumpProperty("unobscuredContentRect", info.unobscuredContentRect());
+ ts.dumpProperty("unobscuredRectInScrollViewCoordinates", info.unobscuredRectInScrollViewCoordinates());
+ ts.dumpProperty("unobscuredContentRectRespectingInputViewBounds", info.unobscuredContentRectRespectingInputViewBounds());
+ ts.dumpProperty("customFixedPositionRect", info.customFixedPositionRect());
+ ts.dumpProperty("obscuredInset", info.obscuredInset());
+
+ ts.dumpProperty("scale", info.scale());
+ ts.dumpProperty("inStableState", info.inStableState());
+ ts.dumpProperty("isFirstUpdateForNewViewSize", info.isFirstUpdateForNewViewSize());
+ if (info.isChangingObscuredInsetsInteractively())
+ ts.dumpProperty("isChangingObscuredInsetsInteractively", info.isChangingObscuredInsetsInteractively());
+ if (info.enclosedInScrollableAncestorView())
+ ts.dumpProperty("enclosedInScrollableAncestorView", info.enclosedInScrollableAncestorView());
+
+ ts.dumpProperty("timestamp", info.timestamp().secondsSinceEpoch().value());
+ if (info.horizontalVelocity())
+ ts.dumpProperty("horizontalVelocity", info.horizontalVelocity());
+ if (info.verticalVelocity())
+ ts.dumpProperty("verticalVelocity", info.verticalVelocity());
+ if (info.scaleChangeRate())
+ ts.dumpProperty("scaleChangeRate", info.scaleChangeRate());
+
+ return ts;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/Shared/VisibleContentRectUpdateInfo.h b/Source/WebKit2/Shared/VisibleContentRectUpdateInfo.h
new file mode 100644
index 000000000..8ea15358d
--- /dev/null
+++ b/Source/WebKit2/Shared/VisibleContentRectUpdateInfo.h
@@ -0,0 +1,136 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+#pragma once
+
+#include <WebCore/FloatRect.h>
+#include <wtf/MonotonicTime.h>
+#include <wtf/text/WTFString.h>
+
+namespace IPC {
+class Decoder;
+class Encoder;
+}
+
+namespace WebCore {
+class TextStream;
+}
+
+namespace WebKit {
+
+class VisibleContentRectUpdateInfo {
+public:
+ VisibleContentRectUpdateInfo() = default;
+
+ VisibleContentRectUpdateInfo(const WebCore::FloatRect& exposedContentRect, const WebCore::FloatRect& unobscuredContentRect,
+ const WebCore::FloatRect& unobscuredRectInScrollViewCoordinates, const WebCore::FloatRect& unobscuredContentRectRespectingInputViewBounds, const WebCore::FloatRect& customFixedPositionRect,
+ const WebCore::FloatSize& obscuredInset, double scale, bool inStableState, bool isFirstUpdateForNewViewSize, bool isChangingObscuredInsetsInteractively, bool allowShrinkToFit, bool enclosedInScrollableAncestorView,
+ MonotonicTime timestamp, double horizontalVelocity, double verticalVelocity, double scaleChangeRate, uint64_t lastLayerTreeTransactionId)
+ : m_exposedContentRect(exposedContentRect)
+ , m_unobscuredContentRect(unobscuredContentRect)
+ , m_unobscuredRectInScrollViewCoordinates(unobscuredRectInScrollViewCoordinates)
+ , m_unobscuredContentRectRespectingInputViewBounds(unobscuredContentRectRespectingInputViewBounds)
+ , m_customFixedPositionRect(customFixedPositionRect)
+ , m_obscuredInset(obscuredInset)
+ , m_lastLayerTreeTransactionID(lastLayerTreeTransactionId)
+ , m_scale(scale)
+ , m_timestamp(timestamp)
+ , m_horizontalVelocity(horizontalVelocity)
+ , m_verticalVelocity(verticalVelocity)
+ , m_scaleChangeRate(scaleChangeRate)
+ , m_inStableState(inStableState)
+ , m_isFirstUpdateForNewViewSize(isFirstUpdateForNewViewSize)
+ , m_isChangingObscuredInsetsInteractively(isChangingObscuredInsetsInteractively)
+ , m_allowShrinkToFit(allowShrinkToFit)
+ , m_enclosedInScrollableAncestorView(enclosedInScrollableAncestorView)
+ {
+ }
+
+ const WebCore::FloatRect& exposedContentRect() const { return m_exposedContentRect; }
+ const WebCore::FloatRect& unobscuredContentRect() const { return m_unobscuredContentRect; }
+ const WebCore::FloatRect& unobscuredRectInScrollViewCoordinates() const { return m_unobscuredRectInScrollViewCoordinates; }
+ const WebCore::FloatRect& unobscuredContentRectRespectingInputViewBounds() const { return m_unobscuredContentRectRespectingInputViewBounds; }
+ const WebCore::FloatRect& customFixedPositionRect() const { return m_customFixedPositionRect; }
+ const WebCore::FloatSize obscuredInset() const { return m_obscuredInset; }
+
+ double scale() const { return m_scale; }
+ bool inStableState() const { return m_inStableState; }
+ bool isFirstUpdateForNewViewSize() const { return m_isFirstUpdateForNewViewSize; }
+ bool isChangingObscuredInsetsInteractively() const { return m_isChangingObscuredInsetsInteractively; }
+ bool allowShrinkToFit() const { return m_allowShrinkToFit; }
+ bool enclosedInScrollableAncestorView() const { return m_enclosedInScrollableAncestorView; }
+
+ MonotonicTime timestamp() const { return m_timestamp; }
+ double horizontalVelocity() const { return m_horizontalVelocity; }
+ double verticalVelocity() const { return m_verticalVelocity; }
+ double scaleChangeRate() const { return m_scaleChangeRate; }
+
+ uint64_t lastLayerTreeTransactionID() const { return m_lastLayerTreeTransactionID; }
+
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, VisibleContentRectUpdateInfo&);
+
+ String dump() const;
+
+private:
+ WebCore::FloatRect m_exposedContentRect;
+ WebCore::FloatRect m_unobscuredContentRect;
+ WebCore::FloatRect m_unobscuredRectInScrollViewCoordinates;
+ WebCore::FloatRect m_unobscuredContentRectRespectingInputViewBounds;
+ WebCore::FloatRect m_customFixedPositionRect; // When visual viewports are enabled, this is the layout viewport.
+ WebCore::FloatSize m_obscuredInset;
+ uint64_t m_lastLayerTreeTransactionID { 0 };
+ double m_scale { -1 };
+ MonotonicTime m_timestamp;
+ double m_horizontalVelocity { 0 };
+ double m_verticalVelocity { 0 };
+ double m_scaleChangeRate { 0 };
+ bool m_inStableState { false };
+ bool m_isFirstUpdateForNewViewSize { false };
+ bool m_isChangingObscuredInsetsInteractively { false };
+ bool m_allowShrinkToFit { false };
+ bool m_enclosedInScrollableAncestorView { false };
+};
+
+inline bool operator==(const VisibleContentRectUpdateInfo& a, const VisibleContentRectUpdateInfo& b)
+{
+ // Note: the comparison doesn't include timestamp and velocity since we care about equality based on the other data.
+ return a.scale() == b.scale()
+ && a.exposedContentRect() == b.exposedContentRect()
+ && a.unobscuredContentRect() == b.unobscuredContentRect()
+ && a.customFixedPositionRect() == b.customFixedPositionRect()
+ && a.obscuredInset() == b.obscuredInset()
+ && a.horizontalVelocity() == b.horizontalVelocity()
+ && a.verticalVelocity() == b.verticalVelocity()
+ && a.scaleChangeRate() == b.scaleChangeRate()
+ && a.inStableState() == b.inStableState()
+ && a.isFirstUpdateForNewViewSize() == b.isFirstUpdateForNewViewSize()
+ && a.allowShrinkToFit() == b.allowShrinkToFit()
+ && a.enclosedInScrollableAncestorView() == b.enclosedInScrollableAncestorView();
+}
+
+WebCore::TextStream& operator<<(WebCore::TextStream&, const VisibleContentRectUpdateInfo&);
+
+} // namespace WebKit
diff --git a/Source/WebKit2/Shared/VisitedLinkTable.cpp b/Source/WebKit2/Shared/VisitedLinkTable.cpp
index 30df61996..59fe11882 100644
--- a/Source/WebKit2/Shared/VisitedLinkTable.cpp
+++ b/Source/WebKit2/Shared/VisitedLinkTable.cpp
@@ -34,7 +34,8 @@ namespace WebKit {
VisitedLinkTable::VisitedLinkTable()
: m_tableSize(0)
- , m_table(0)
+ , m_tableSizeMask(0)
+ , m_table(nullptr)
{
}
@@ -136,4 +137,11 @@ bool VisitedLinkTable::isLinkVisited(LinkHash linkHash) const
return false;
}
+void VisitedLinkTable::clear()
+{
+ m_tableSize = 0;
+ m_tableSizeMask = 0;
+ m_sharedMemory = nullptr;
+}
+
} // namespace WebKit
diff --git a/Source/WebKit2/Shared/VisitedLinkTable.h b/Source/WebKit2/Shared/VisitedLinkTable.h
index c7274c33f..861ce7a79 100644
--- a/Source/WebKit2/Shared/VisitedLinkTable.h
+++ b/Source/WebKit2/Shared/VisitedLinkTable.h
@@ -47,6 +47,7 @@ public:
bool isLinkVisited(WebCore::LinkHash) const;
SharedMemory* sharedMemory() const { return m_sharedMemory.get(); }
+ void clear();
private:
RefPtr<SharedMemory> m_sharedMemory;
diff --git a/Source/WebKit2/Shared/WebBackForwardListItem.cpp b/Source/WebKit2/Shared/WebBackForwardListItem.cpp
index 58e54ce64..431e3c14a 100644
--- a/Source/WebKit2/Shared/WebBackForwardListItem.cpp
+++ b/Source/WebKit2/Shared/WebBackForwardListItem.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2011, 2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,73 +26,81 @@
#include "config.h"
#include "WebBackForwardListItem.h"
-#include "DataReference.h"
-#include "WebCoreArgumentCoders.h"
+#include <WebCore/URL.h>
namespace WebKit {
-static uint64_t highestUsedItemID = 0;
+static uint64_t highestItemID = 0;
-WebBackForwardListItem::WebBackForwardListItem(const String& originalURL, const String& url, const String& title, const uint8_t* backForwardData, size_t backForwardDataSize, uint64_t itemID)
- : m_originalURL(originalURL)
- , m_url(url)
- , m_title(title)
- , m_itemID(itemID)
+Ref<WebBackForwardListItem> WebBackForwardListItem::create(BackForwardListItemState&& backForwardListItemState, uint64_t pageID)
{
- if (m_itemID > highestUsedItemID)
- highestUsedItemID = m_itemID;
+ return adoptRef(*new WebBackForwardListItem(WTFMove(backForwardListItemState), pageID));
+}
- setBackForwardData(backForwardData, backForwardDataSize);
+WebBackForwardListItem::WebBackForwardListItem(BackForwardListItemState&& backForwardListItemState, uint64_t pageID)
+ : m_itemState(WTFMove(backForwardListItemState))
+ , m_pageID(pageID)
+{
+ if (m_itemState.identifier > highestItemID)
+ highestItemID = m_itemState.identifier;
}
WebBackForwardListItem::~WebBackForwardListItem()
{
}
-uint64_t WebBackForwardListItem::highedUsedItemID()
+static const FrameState* childItemWithDocumentSequenceNumber(const FrameState& frameState, int64_t number)
{
- return highestUsedItemID;
+ for (const auto& child : frameState.children) {
+ if (child.documentSequenceNumber == number)
+ return &child;
+ }
+
+ return nullptr;
}
-void WebBackForwardListItem::setBackForwardData(const uint8_t* data, size_t size)
+static bool documentTreesAreEqual(const FrameState& a, const FrameState& b)
{
- m_backForwardData.clear();
- m_backForwardData.reserveCapacity(size);
- m_backForwardData.append(data, size);
+ if (a.documentSequenceNumber != b.documentSequenceNumber)
+ return false;
+
+ if (a.children.size() != b.children.size())
+ return false;
+
+ for (const auto& child : a.children) {
+ const FrameState* otherChild = childItemWithDocumentSequenceNumber(b, child.documentSequenceNumber);
+ if (!otherChild || !documentTreesAreEqual(child, *otherChild))
+ return false;
+ }
+
+ return true;
}
-void WebBackForwardListItem::encode(IPC::ArgumentEncoder& encoder) const
+bool WebBackForwardListItem::itemIsInSameDocument(const WebBackForwardListItem& other) const
{
- encoder << m_originalURL;
- encoder << m_url;
- encoder << m_title;
- encoder << m_itemID;
- encoder << IPC::DataReference(m_backForwardData);
+ if (m_pageID != other.m_pageID)
+ return false;
+
+ // The following logic must be kept in sync with WebCore::HistoryItem::shouldDoSameDocumentNavigationTo.
+
+ const FrameState& mainFrameState = m_itemState.pageState.mainFrameState;
+ const FrameState& otherMainFrameState = other.m_itemState.pageState.mainFrameState;
+
+ if (mainFrameState.stateObjectData || otherMainFrameState.stateObjectData)
+ return mainFrameState.documentSequenceNumber == otherMainFrameState.documentSequenceNumber;
+
+ WebCore::URL url = WebCore::URL(WebCore::ParsedURLString, mainFrameState.urlString);
+ WebCore::URL otherURL = WebCore::URL(WebCore::ParsedURLString, otherMainFrameState.urlString);
+
+ if ((url.hasFragmentIdentifier() || otherURL.hasFragmentIdentifier()) && equalIgnoringFragmentIdentifier(url, otherURL))
+ return mainFrameState.documentSequenceNumber == otherMainFrameState.documentSequenceNumber;
+
+ return documentTreesAreEqual(mainFrameState, otherMainFrameState);
}
-PassRefPtr<WebBackForwardListItem> WebBackForwardListItem::decode(IPC::ArgumentDecoder& decoder)
+uint64_t WebBackForwardListItem::highestUsedItemID()
{
- String originalURL;
- if (!decoder.decode(originalURL))
- return 0;
-
- String url;
- if (!decoder.decode(url))
- return 0;
-
- String title;
- if (!decoder.decode(title))
- return 0;
-
- uint64_t itemID;
- if (!decoder.decode(itemID))
- return 0;
-
- IPC::DataReference data;
- if (!decoder.decode(data))
- return 0;
-
- return create(originalURL, url, title, data.data(), data.size(), itemID);
+ return highestItemID;
}
} // namespace WebKit
diff --git a/Source/WebKit2/Shared/WebBackForwardListItem.h b/Source/WebKit2/Shared/WebBackForwardListItem.h
index 5abc95b54..df4573e6c 100644
--- a/Source/WebKit2/Shared/WebBackForwardListItem.h
+++ b/Source/WebKit2/Shared/WebBackForwardListItem.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2011, 2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,56 +27,50 @@
#define WebBackForwardListItem_h
#include "APIObject.h"
+#include "SessionState.h"
#include <wtf/PassRefPtr.h>
#include <wtf/text/WTFString.h>
+namespace API {
+class Data;
+}
+
namespace IPC {
- class ArgumentDecoder;
- class ArgumentEncoder;
+class Decoder;
+class Encoder;
}
namespace WebKit {
class WebBackForwardListItem : public API::ObjectImpl<API::Object::Type::BackForwardListItem> {
public:
- static PassRefPtr<WebBackForwardListItem> create(const String& originalURL, const String& url, const String& title, const uint8_t* backForwardData, size_t backForwardDataSize, uint64_t itemID)
- {
- return adoptRef(new WebBackForwardListItem(originalURL, url, title, backForwardData, backForwardDataSize, itemID));
- }
-
+ static Ref<WebBackForwardListItem> create(BackForwardListItemState&&, uint64_t pageID);
virtual ~WebBackForwardListItem();
- uint64_t itemID() const { return m_itemID; }
+ uint64_t itemID() const { return m_itemState.identifier; }
+ const BackForwardListItemState& itemState() { return m_itemState; }
+ uint64_t pageID() const { return m_pageID; }
- void setOriginalURL(const String& originalURL) { m_originalURL = originalURL; }
- const String& originalURL() const { return m_originalURL; }
+ void setPageState(PageState pageState) { m_itemState.pageState = WTFMove(pageState); }
- void setURL(const String& url) { m_url = url; }
- const String& url() const { return m_url; }
+ const String& originalURL() const { return m_itemState.pageState.mainFrameState.originalURLString; }
+ const String& url() const { return m_itemState.pageState.mainFrameState.urlString; }
+ const String& title() const { return m_itemState.pageState.title; }
- void setTitle(const String& title) { m_title = title; }
- const String& title() const { return m_title; }
-
- void setBackForwardData(const uint8_t* buffer, size_t size);
- const Vector<uint8_t>& backForwardData() const { return m_backForwardData; }
+ bool itemIsInSameDocument(const WebBackForwardListItem&) const;
- void setSnapshotUUID(const String& uuid) { m_snapshotUUID = uuid; }
- const String& snapshotUUID() const { return m_snapshotUUID; }
+#if PLATFORM(COCOA)
+ ViewSnapshot* snapshot() const { return m_itemState.snapshot.get(); }
+ void setSnapshot(PassRefPtr<ViewSnapshot> snapshot) { m_itemState.snapshot = snapshot; }
+#endif
- void encode(IPC::ArgumentEncoder&) const;
- static PassRefPtr<WebBackForwardListItem> decode(IPC::ArgumentDecoder&);
-
- static uint64_t highedUsedItemID();
+ static uint64_t highestUsedItemID();
private:
- WebBackForwardListItem(const String& originalURL, const String& url, const String& title, const uint8_t* backForwardData, size_t backForwardDataSize, uint64_t itemID);
-
- String m_originalURL;
- String m_url;
- String m_title;
- uint64_t m_itemID;
- Vector<uint8_t> m_backForwardData;
- String m_snapshotUUID;
+ explicit WebBackForwardListItem(BackForwardListItemState&&, uint64_t pageID);
+
+ BackForwardListItemState m_itemState;
+ uint64_t m_pageID;
};
typedef Vector<RefPtr<WebBackForwardListItem>> BackForwardListItemVector;
diff --git a/Source/WebKit2/Shared/WebCertificateInfo.h b/Source/WebKit2/Shared/WebCertificateInfo.h
index 1a1beea61..147b9a3f9 100644
--- a/Source/WebKit2/Shared/WebCertificateInfo.h
+++ b/Source/WebKit2/Shared/WebCertificateInfo.h
@@ -28,15 +28,15 @@
#include "APIObject.h"
#include <WebCore/CertificateInfo.h>
-#include <wtf/PassRefPtr.h>
+#include <wtf/Ref.h>
namespace WebKit {
class WebCertificateInfo : public API::ObjectImpl<API::Object::Type::CertificateInfo> {
public:
- static PassRefPtr<WebCertificateInfo> create(const WebCore::CertificateInfo& info)
+ static Ref<WebCertificateInfo> create(const WebCore::CertificateInfo& info)
{
- return adoptRef(new WebCertificateInfo(info));
+ return adoptRef(*new WebCertificateInfo(info));
}
const WebCore::CertificateInfo& certificateInfo() const { return m_certificateInfo; }
diff --git a/Source/WebKit2/Shared/WebCompiledContentExtension.cpp b/Source/WebKit2/Shared/WebCompiledContentExtension.cpp
new file mode 100644
index 000000000..8aa8ce925
--- /dev/null
+++ b/Source/WebKit2/Shared/WebCompiledContentExtension.cpp
@@ -0,0 +1,89 @@
+/*
+ * 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.
+ *
+ * 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 "WebCompiledContentExtension.h"
+
+#if ENABLE(CONTENT_EXTENSIONS)
+
+namespace WebKit {
+
+Ref<WebCompiledContentExtension> WebCompiledContentExtension::create(WebCompiledContentExtensionData&& data)
+{
+ return adoptRef(*new WebCompiledContentExtension(WTFMove(data)));
+}
+
+WebCompiledContentExtension::WebCompiledContentExtension(WebCompiledContentExtensionData&& data)
+ : m_data(WTFMove(data))
+{
+}
+
+WebCompiledContentExtension::~WebCompiledContentExtension()
+{
+}
+
+const WebCore::ContentExtensions::DFABytecode* WebCompiledContentExtension::filtersWithoutDomainsBytecode() const
+{
+ return static_cast<const WebCore::ContentExtensions::DFABytecode*>(m_data.data->data()) + m_data.filtersWithoutDomainsBytecodeOffset;
+}
+
+unsigned WebCompiledContentExtension::filtersWithoutDomainsBytecodeLength() const
+{
+ return m_data.filtersWithoutDomainsBytecodeSize;
+}
+
+const WebCore::ContentExtensions::DFABytecode* WebCompiledContentExtension::filtersWithDomainsBytecode() const
+{
+ return static_cast<const WebCore::ContentExtensions::DFABytecode*>(m_data.data->data()) + m_data.filtersWithDomainsBytecodeOffset;
+}
+
+unsigned WebCompiledContentExtension::filtersWithDomainsBytecodeLength() const
+{
+ return m_data.filtersWithDomainsBytecodeSize;
+}
+
+const WebCore::ContentExtensions::DFABytecode* WebCompiledContentExtension::domainFiltersBytecode() const
+{
+ return static_cast<const WebCore::ContentExtensions::DFABytecode*>(m_data.data->data()) + m_data.domainFiltersBytecodeOffset;
+}
+
+unsigned WebCompiledContentExtension::domainFiltersBytecodeLength() const
+{
+ return m_data.domainFiltersBytecodeSize;
+}
+
+const WebCore::ContentExtensions::SerializedActionByte* WebCompiledContentExtension::actions() const
+{
+ return static_cast<const WebCore::ContentExtensions::SerializedActionByte*>(m_data.data->data()) + m_data.actionsOffset;
+}
+
+unsigned WebCompiledContentExtension::actionsLength() const
+{
+ return m_data.actionsSize;
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(CONTENT_EXTENSIONS)
diff --git a/Source/WebKit2/Shared/WebCompiledContentExtension.h b/Source/WebKit2/Shared/WebCompiledContentExtension.h
new file mode 100644
index 000000000..53dd6fb47
--- /dev/null
+++ b/Source/WebKit2/Shared/WebCompiledContentExtension.h
@@ -0,0 +1,63 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+#ifndef WebCompiledContentExtension_h
+#define WebCompiledContentExtension_h
+
+#if ENABLE(CONTENT_EXTENSIONS)
+
+#include "WebCompiledContentExtensionData.h"
+#include <WebCore/ContentExtensionCompiler.h>
+#include <WebCore/CompiledContentExtension.h>
+
+namespace WebKit {
+
+class WebCompiledContentExtension final : public WebCore::ContentExtensions::CompiledContentExtension {
+public:
+ static Ref<WebCompiledContentExtension> create(WebCompiledContentExtensionData&&);
+ virtual ~WebCompiledContentExtension();
+
+ WebCompiledContentExtensionData data() const { return m_data; }
+
+private:
+ WebCompiledContentExtension(WebCompiledContentExtensionData&&);
+
+ const WebCore::ContentExtensions::DFABytecode* filtersWithoutDomainsBytecode() const override;
+ unsigned filtersWithoutDomainsBytecodeLength() const override;
+ const WebCore::ContentExtensions::DFABytecode* filtersWithDomainsBytecode() const override;
+ unsigned filtersWithDomainsBytecodeLength() const override;
+ const WebCore::ContentExtensions::DFABytecode* domainFiltersBytecode() const override;
+ unsigned domainFiltersBytecodeLength() const override;
+
+ const WebCore::ContentExtensions::SerializedActionByte* actions() const override;
+ unsigned actionsLength() const override;
+
+ WebCompiledContentExtensionData m_data;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(CONTENT_EXTENSIONS)
+#endif // WebCompiledContentExtension_h
diff --git a/Source/WebKit2/Shared/WebCompiledContentExtensionData.cpp b/Source/WebKit2/Shared/WebCompiledContentExtensionData.cpp
new file mode 100644
index 000000000..6c7d15692
--- /dev/null
+++ b/Source/WebKit2/Shared/WebCompiledContentExtensionData.cpp
@@ -0,0 +1,80 @@
+/*
+ * 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.
+ *
+ * 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 "WebCompiledContentExtensionData.h"
+
+#if ENABLE(CONTENT_EXTENSIONS)
+
+#include "ArgumentCoders.h"
+
+namespace WebKit {
+
+void WebCompiledContentExtensionData::encode(IPC::Encoder& encoder) const
+{
+ SharedMemory::Handle handle;
+ data->createHandle(handle, SharedMemory::Protection::ReadOnly);
+ encoder << handle;
+
+ encoder << actionsOffset;
+ encoder << actionsSize;
+ encoder << filtersWithoutDomainsBytecodeOffset;
+ encoder << filtersWithoutDomainsBytecodeSize;
+ encoder << filtersWithDomainsBytecodeOffset;
+ encoder << filtersWithDomainsBytecodeSize;
+ encoder << domainFiltersBytecodeOffset;
+ encoder << domainFiltersBytecodeSize;
+}
+
+bool WebCompiledContentExtensionData::decode(IPC::Decoder& decoder, WebCompiledContentExtensionData& compiledContentExtensionData)
+{
+ SharedMemory::Handle handle;
+ if (!decoder.decode(handle))
+ return false;
+ compiledContentExtensionData.data = SharedMemory::map(handle, SharedMemory::Protection::ReadOnly);
+
+ if (!decoder.decode(compiledContentExtensionData.actionsOffset))
+ return false;
+ if (!decoder.decode(compiledContentExtensionData.actionsSize))
+ return false;
+ if (!decoder.decode(compiledContentExtensionData.filtersWithoutDomainsBytecodeOffset))
+ return false;
+ if (!decoder.decode(compiledContentExtensionData.filtersWithoutDomainsBytecodeSize))
+ return false;
+ if (!decoder.decode(compiledContentExtensionData.filtersWithDomainsBytecodeOffset))
+ return false;
+ if (!decoder.decode(compiledContentExtensionData.filtersWithDomainsBytecodeSize))
+ return false;
+ if (!decoder.decode(compiledContentExtensionData.domainFiltersBytecodeOffset))
+ return false;
+ if (!decoder.decode(compiledContentExtensionData.domainFiltersBytecodeSize))
+ return false;
+
+ return true;
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(CONTENT_EXTENSIONS)
diff --git a/Source/WebKit2/Shared/WebCompiledContentExtensionData.h b/Source/WebKit2/Shared/WebCompiledContentExtensionData.h
new file mode 100644
index 000000000..f62cb32d7
--- /dev/null
+++ b/Source/WebKit2/Shared/WebCompiledContentExtensionData.h
@@ -0,0 +1,80 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+#ifndef WebCompiledContentExtensionData_h
+#define WebCompiledContentExtensionData_h
+
+#if ENABLE(CONTENT_EXTENSIONS)
+
+#include "NetworkCacheData.h"
+#include "SharedMemory.h"
+#include <wtf/RefPtr.h>
+
+namespace IPC {
+class Decoder;
+class Encoder;
+}
+
+namespace WebKit {
+
+class WebCompiledContentExtensionData {
+public:
+ WebCompiledContentExtensionData()
+ {
+ }
+
+ WebCompiledContentExtensionData(RefPtr<SharedMemory>&& data, NetworkCache::Data fileData, unsigned actionsOffset, unsigned actionsSize, unsigned filtersWithoutDomainsBytecodeOffset, unsigned filtersWithoutDomainsBytecodeSize, unsigned filtersWithDomainsBytecodeOffset, unsigned filtersWithDomainsBytecodeSize, unsigned domainFiltersBytecodeOffset, unsigned domainFiltersBytecodeSize)
+ : data(WTFMove(data))
+ , fileData(fileData)
+ , actionsOffset(actionsOffset)
+ , actionsSize(actionsSize)
+ , filtersWithoutDomainsBytecodeOffset(filtersWithoutDomainsBytecodeOffset)
+ , filtersWithoutDomainsBytecodeSize(filtersWithoutDomainsBytecodeSize)
+ , filtersWithDomainsBytecodeOffset(filtersWithDomainsBytecodeOffset)
+ , filtersWithDomainsBytecodeSize(filtersWithDomainsBytecodeSize)
+ , domainFiltersBytecodeOffset(domainFiltersBytecodeOffset)
+ , domainFiltersBytecodeSize(domainFiltersBytecodeSize)
+ {
+ }
+
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, WebCompiledContentExtensionData&);
+
+ RefPtr<SharedMemory> data;
+ NetworkCache::Data fileData;
+ unsigned actionsOffset { 0 };
+ unsigned actionsSize { 0 };
+ unsigned filtersWithoutDomainsBytecodeOffset { 0 };
+ unsigned filtersWithoutDomainsBytecodeSize { 0 };
+ unsigned filtersWithDomainsBytecodeOffset { 0 };
+ unsigned filtersWithDomainsBytecodeSize { 0 };
+ unsigned domainFiltersBytecodeOffset { 0 };
+ unsigned domainFiltersBytecodeSize { 0 };
+};
+
+}
+
+#endif // ENABLE(CONTENT_EXTENSIONS)
+#endif // WebCompiledContentExtensionData_h
diff --git a/Source/WebKit2/Shared/WebConnection.cpp b/Source/WebKit2/Shared/WebConnection.cpp
index 7180fc684..234ad60bf 100644
--- a/Source/WebKit2/Shared/WebConnection.cpp
+++ b/Source/WebKit2/Shared/WebConnection.cpp
@@ -28,6 +28,7 @@
#include "ArgumentCoders.h"
#include "DataReference.h"
+#include "UserData.h"
#include "WebConnectionMessages.h"
#include <wtf/text/WTFString.h>
@@ -51,11 +52,7 @@ void WebConnection::postMessage(const String& messageName, API::Object* messageB
if (!hasValidConnection())
return;
- auto encoder = std::make_unique<IPC::MessageEncoder>(Messages::WebConnection::HandleMessage::receiverName(), Messages::WebConnection::HandleMessage::name(), 0);
- encoder->encode(messageName);
- encodeMessageBody(*encoder, messageBody);
-
- sendMessage(std::move(encoder), 0);
+ send(Messages::WebConnection::HandleMessage(messageName, UserData(transformObjectsToHandles(messageBody))));
}
void WebConnection::didClose()
@@ -63,22 +60,9 @@ void WebConnection::didClose()
m_client.didClose(this);
}
-void WebConnection::didReceiveMessage(IPC::Connection* connection, IPC::MessageDecoder& decoder)
-{
- didReceiveWebConnectionMessage(connection, decoder);
-}
-
-void WebConnection::handleMessage(IPC::MessageDecoder& decoder)
+void WebConnection::handleMessage(const String& messageName, const UserData& messageBody)
{
- String messageName;
- if (!decoder.decode(messageName))
- return;
-
- RefPtr<API::Object> messageBody;
- if (!decodeMessageBody(decoder, messageBody))
- return;
-
- m_client.didReceiveMessage(this, messageName, messageBody.get());
+ m_client.didReceiveMessage(this, messageName, transformHandlesToObjects(messageBody.object()).get());
}
} // namespace WebKit
diff --git a/Source/WebKit2/Shared/WebConnection.h b/Source/WebKit2/Shared/WebConnection.h
index 787219cb9..fb260b4cd 100644
--- a/Source/WebKit2/Shared/WebConnection.h
+++ b/Source/WebKit2/Shared/WebConnection.h
@@ -29,11 +29,13 @@
#include "APIObject.h"
#include "MessageReceiver.h"
#include "MessageSender.h"
+#include "UserData.h"
#include "WebConnectionClient.h"
#include <wtf/RefPtr.h>
namespace WebKit {
+class UserData;
class WebConnection : public API::ObjectImpl<API::Object::Type::Connection>, public IPC::MessageReceiver, public IPC::MessageSender {
public:
virtual ~WebConnection();
@@ -45,17 +47,15 @@ public:
protected:
explicit WebConnection();
- virtual void encodeMessageBody(IPC::ArgumentEncoder&, API::Object*) = 0;
- virtual bool decodeMessageBody(IPC::ArgumentDecoder&, RefPtr<API::Object>&) = 0;
+ virtual RefPtr<API::Object> transformHandlesToObjects(API::Object*) = 0;
+ virtual RefPtr<API::Object> transformObjectsToHandles(API::Object*) = 0;
// IPC::MessageReceiver
- void didReceiveMessage(IPC::Connection*, IPC::MessageDecoder&) override;
-
// Implemented in generated WebConnectionMessageReceiver.cpp
- void didReceiveWebConnectionMessage(IPC::Connection*, IPC::MessageDecoder&);
+ void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
// Mesage handling implementation functions.
- void handleMessage(IPC::MessageDecoder&);
+ void handleMessage(const String& messageName, const UserData& messageBody);
virtual bool hasValidConnection() const = 0;
diff --git a/Source/WebKit2/Shared/WebConnection.messages.in b/Source/WebKit2/Shared/WebConnection.messages.in
index efc8ca6b0..c5e0dc257 100644
--- a/Source/WebKit2/Shared/WebConnection.messages.in
+++ b/Source/WebKit2/Shared/WebConnection.messages.in
@@ -20,6 +20,6 @@
# 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.
-messages -> WebConnection LegacyReceiver {
- HandleMessage() Variadic
+messages -> WebConnection {
+ HandleMessage(String messageName, WebKit::UserData messageBody)
}
diff --git a/Source/WebKit2/Shared/WebContextMenuItem.cpp b/Source/WebKit2/Shared/WebContextMenuItem.cpp
index ceb9a8659..ee21b46f1 100644
--- a/Source/WebKit2/Shared/WebContextMenuItem.cpp
+++ b/Source/WebKit2/Shared/WebContextMenuItem.cpp
@@ -31,7 +31,6 @@
#include "APIArray.h"
#include <WebCore/ContextMenuItem.h>
-#include <wtf/NeverDestroyed.h>
namespace WebKit {
@@ -50,7 +49,7 @@ PassRefPtr<WebContextMenuItem> WebContextMenuItem::create(const String& title, b
for (size_t i = 0; i < size; ++i) {
WebContextMenuItem* item = submenuItems->at<WebContextMenuItem>(i);
if (item)
- submenu.append(*item->data());
+ submenu.append(item->data());
}
return adoptRef(new WebContextMenuItem(WebContextMenuItemData(WebCore::ContextMenuItemTagNoAction, title, enabled, submenu))).leakRef();
@@ -62,7 +61,7 @@ WebContextMenuItem* WebContextMenuItem::separatorItem()
return separatorItem;
}
-PassRefPtr<API::Array> WebContextMenuItem::submenuItemsAsAPIArray() const
+Ref<API::Array> WebContextMenuItem::submenuItemsAsAPIArray() const
{
if (m_webContextMenuItemData.type() != WebCore::SubmenuType)
return API::Array::create();
@@ -73,7 +72,7 @@ PassRefPtr<API::Array> WebContextMenuItem::submenuItemsAsAPIArray() const
for (const auto& item : m_webContextMenuItemData.submenu())
submenuItems.uncheckedAppend(WebContextMenuItem::create(item));
- return API::Array::create(std::move(submenuItems));
+ return API::Array::create(WTFMove(submenuItems));
}
API::Object* WebContextMenuItem::userData() const
diff --git a/Source/WebKit2/Shared/WebContextMenuItem.h b/Source/WebKit2/Shared/WebContextMenuItem.h
index 0ccfd568e..98b9f01d3 100644
--- a/Source/WebKit2/Shared/WebContextMenuItem.h
+++ b/Source/WebKit2/Shared/WebContextMenuItem.h
@@ -35,23 +35,28 @@ namespace API {
class Array;
}
+namespace WebCore {
+class ContextMenuItem;
+}
+
namespace WebKit {
class WebContextMenuItem : public API::ObjectImpl<API::Object::Type::ContextMenuItem> {
public:
- static PassRefPtr<WebContextMenuItem> create(const WebContextMenuItemData& data)
+ static Ref<WebContextMenuItem> create(const WebContextMenuItemData& data)
{
- return adoptRef(new WebContextMenuItem(data));
+ return adoptRef(*new WebContextMenuItem(data));
}
+
static PassRefPtr<WebContextMenuItem> create(const String& title, bool enabled, API::Array* submenuItems);
static WebContextMenuItem* separatorItem();
- PassRefPtr<API::Array> submenuItemsAsAPIArray() const;
+ Ref<API::Array> submenuItemsAsAPIArray() const;
API::Object* userData() const;
void setUserData(API::Object*);
- WebContextMenuItemData* data() { return &m_webContextMenuItemData; }
+ const WebContextMenuItemData& data() { return m_webContextMenuItemData; }
private:
WebContextMenuItem(const WebContextMenuItemData&);
diff --git a/Source/WebKit2/Shared/WebContextMenuItemData.cpp b/Source/WebKit2/Shared/WebContextMenuItemData.cpp
index d659e9c6c..2ae8d1c01 100644
--- a/Source/WebKit2/Shared/WebContextMenuItemData.cpp
+++ b/Source/WebKit2/Shared/WebContextMenuItemData.cpp
@@ -31,7 +31,6 @@
#include "APIObject.h"
#include "ArgumentCoders.h"
-#include "Arguments.h"
#include <wtf/text/CString.h>
#include <WebCore/ContextMenu.h>
@@ -67,18 +66,14 @@ WebContextMenuItemData::WebContextMenuItemData(WebCore::ContextMenuAction action
{
}
-WebContextMenuItemData::WebContextMenuItemData(const WebCore::ContextMenuItem& item, WebCore::ContextMenu* menu)
+WebContextMenuItemData::WebContextMenuItemData(const WebCore::ContextMenuItem& item)
: m_type(item.type())
, m_action(item.action())
, m_title(item.title())
{
if (m_type == WebCore::SubmenuType) {
-#if USE(CROSS_PLATFORM_CONTEXT_MENUS)
const Vector<WebCore::ContextMenuItem>& coreSubmenu = item.subMenuItems();
-#else
- Vector<WebCore::ContextMenuItem> coreSubmenu = WebCore::contextMenuItemVector(item.platformSubMenu());
-#endif
- m_submenu = kitItems(coreSubmenu, menu);
+ m_submenu = kitItems(coreSubmenu);
}
m_enabled = item.enabled();
@@ -104,7 +99,7 @@ void WebContextMenuItemData::setUserData(API::Object* userData)
m_userData = userData;
}
-void WebContextMenuItemData::encode(IPC::ArgumentEncoder& encoder) const
+void WebContextMenuItemData::encode(IPC::Encoder& encoder) const
{
encoder.encodeEnum(m_type);
encoder.encodeEnum(m_action);
@@ -114,7 +109,7 @@ void WebContextMenuItemData::encode(IPC::ArgumentEncoder& encoder) const
encoder << m_submenu;
}
-bool WebContextMenuItemData::decode(IPC::ArgumentDecoder& decoder, WebContextMenuItemData& item)
+bool WebContextMenuItemData::decode(IPC::Decoder& decoder, WebContextMenuItemData& item)
{
WebCore::ContextMenuItemType type;
if (!decoder.decodeEnum(type))
@@ -157,12 +152,12 @@ bool WebContextMenuItemData::decode(IPC::ArgumentDecoder& decoder, WebContextMen
return true;
}
-Vector<WebContextMenuItemData> kitItems(const Vector<WebCore::ContextMenuItem>& coreItemVector, WebCore::ContextMenu* menu)
+Vector<WebContextMenuItemData> kitItems(const Vector<WebCore::ContextMenuItem>& coreItemVector)
{
Vector<WebContextMenuItemData> result;
result.reserveCapacity(coreItemVector.size());
for (unsigned i = 0; i < coreItemVector.size(); ++i)
- result.append(WebContextMenuItemData(coreItemVector[i], menu));
+ result.append(WebContextMenuItemData(coreItemVector[i]));
return result;
}
diff --git a/Source/WebKit2/Shared/WebContextMenuItemData.h b/Source/WebKit2/Shared/WebContextMenuItemData.h
index 59e6ee7f6..a361907cb 100644
--- a/Source/WebKit2/Shared/WebContextMenuItemData.h
+++ b/Source/WebKit2/Shared/WebContextMenuItemData.h
@@ -29,6 +29,7 @@
#if ENABLE(CONTEXT_MENUS)
#include <WebCore/ContextMenuItem.h>
+#include <functional>
#include <wtf/text/WTFString.h>
namespace API {
@@ -36,12 +37,8 @@ class Object;
}
namespace IPC {
- class ArgumentDecoder;
- class ArgumentEncoder;
-}
-
-namespace WebCore {
- class ContextMenu;
+class Decoder;
+class Encoder;
}
namespace WebKit {
@@ -49,7 +46,7 @@ namespace WebKit {
class WebContextMenuItemData {
public:
WebContextMenuItemData();
- WebContextMenuItemData(const WebCore::ContextMenuItem&, WebCore::ContextMenu* menu);
+ WebContextMenuItemData(const WebCore::ContextMenuItem&);
WebContextMenuItemData(WebCore::ContextMenuItemType, WebCore::ContextMenuAction, const String& title, bool enabled, bool checked);
WebContextMenuItemData(WebCore::ContextMenuAction, const String& title, bool enabled, const Vector<WebContextMenuItemData>& submenu);
@@ -65,8 +62,8 @@ public:
API::Object* userData() const;
void setUserData(API::Object*);
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, WebContextMenuItemData&);
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, WebContextMenuItemData&);
private:
WebCore::ContextMenuItemType m_type;
@@ -78,7 +75,7 @@ private:
RefPtr<API::Object> m_userData;
};
-Vector<WebContextMenuItemData> kitItems(const Vector<WebCore::ContextMenuItem>&, WebCore::ContextMenu*);
+Vector<WebContextMenuItemData> kitItems(const Vector<WebCore::ContextMenuItem>&);
Vector<WebCore::ContextMenuItem> coreItems(const Vector<WebContextMenuItemData>&);
} // namespace WebKit
diff --git a/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp b/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp
index 57e7b0370..6166ab6ea 100644
--- a/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp
+++ b/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2011-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
@@ -29,204 +29,665 @@
#include "DataReference.h"
#include "ShareableBitmap.h"
#include <WebCore/AuthenticationChallenge.h>
+#include <WebCore/BlobPart.h>
#include <WebCore/CertificateInfo.h>
#include <WebCore/Cookie.h>
#include <WebCore/Credential.h>
#include <WebCore/Cursor.h>
#include <WebCore/DatabaseDetails.h>
#include <WebCore/DictationAlternative.h>
-#include <WebCore/DragSession.h>
+#include <WebCore/DictionaryPopupInfo.h>
+#include <WebCore/DragData.h>
#include <WebCore/Editor.h>
+#include <WebCore/EventTrackingRegions.h>
#include <WebCore/FileChooser.h>
#include <WebCore/FilterOperation.h>
#include <WebCore/FilterOperations.h>
#include <WebCore/GraphicsContext.h>
#include <WebCore/GraphicsLayer.h>
-#include <WebCore/IDBDatabaseMetadata.h>
#include <WebCore/IDBGetResult.h>
-#include <WebCore/IDBKeyData.h>
-#include <WebCore/IDBKeyPath.h>
-#include <WebCore/IDBKeyRangeData.h>
#include <WebCore/Image.h>
+#include <WebCore/JSDOMExceptionHandling.h>
#include <WebCore/Length.h>
+#include <WebCore/Path.h>
#include <WebCore/PluginData.h>
#include <WebCore/ProtectionSpace.h>
+#include <WebCore/Region.h>
#include <WebCore/ResourceError.h>
+#include <WebCore/ResourceLoadStatistics.h>
#include <WebCore/ResourceRequest.h>
#include <WebCore/ResourceResponse.h>
#include <WebCore/ScrollingConstraints.h>
#include <WebCore/ScrollingCoordinator.h>
+#include <WebCore/SearchPopupMenu.h>
+#include <WebCore/SessionID.h>
#include <WebCore/TextCheckerClient.h>
+#include <WebCore/TextIndicator.h>
+#include <WebCore/TimingFunction.h>
#include <WebCore/TransformationMatrix.h>
#include <WebCore/URL.h>
#include <WebCore/UserScript.h>
#include <WebCore/UserStyleSheet.h>
#include <WebCore/ViewportArguments.h>
#include <WebCore/WindowFeatures.h>
+#include <wtf/MonotonicTime.h>
+#include <wtf/Seconds.h>
#include <wtf/text/CString.h>
#include <wtf/text/StringHash.h>
+#if PLATFORM(COCOA)
+#include "ArgumentCodersCF.h"
+#include "ArgumentCodersMac.h"
+#endif
+
#if PLATFORM(IOS)
#include <WebCore/FloatQuad.h>
+#include <WebCore/InspectorOverlay.h>
#include <WebCore/Pasteboard.h>
#include <WebCore/SelectionRect.h>
#include <WebCore/SharedBuffer.h>
#endif // PLATFORM(IOS)
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+#include <WebCore/MediaPlaybackTargetContext.h>
+#endif
+
+#if ENABLE(MEDIA_SESSION)
+#include <WebCore/MediaSessionMetadata.h>
+#endif
+
+#if ENABLE(MEDIA_STREAM)
+#include <WebCore/CaptureDevice.h>
+#include <WebCore/MediaConstraintsImpl.h>
+#endif
+
using namespace WebCore;
using namespace WebKit;
namespace IPC {
-void ArgumentCoder<AffineTransform>::encode(ArgumentEncoder& encoder, const AffineTransform& affineTransform)
+void ArgumentCoder<MonotonicTime>::encode(Encoder& encoder, const MonotonicTime& time)
+{
+ encoder << time.secondsSinceEpoch().value();
+}
+
+bool ArgumentCoder<MonotonicTime>::decode(Decoder& decoder, MonotonicTime& time)
+{
+ double value;
+ if (!decoder.decode(value))
+ return false;
+
+ time = MonotonicTime::fromRawSeconds(value);
+ return true;
+}
+
+void ArgumentCoder<Seconds>::encode(Encoder& encoder, const Seconds& seconds)
+{
+ encoder << seconds.value();
+}
+
+bool ArgumentCoder<Seconds>::decode(Decoder& decoder, Seconds& seconds)
+{
+ double value;
+ if (!decoder.decode(value))
+ return false;
+
+ seconds = Seconds(value);
+ return true;
+}
+
+void ArgumentCoder<AffineTransform>::encode(Encoder& encoder, const AffineTransform& affineTransform)
{
SimpleArgumentCoder<AffineTransform>::encode(encoder, affineTransform);
}
-bool ArgumentCoder<AffineTransform>::decode(ArgumentDecoder& decoder, AffineTransform& affineTransform)
+bool ArgumentCoder<AffineTransform>::decode(Decoder& decoder, AffineTransform& affineTransform)
{
return SimpleArgumentCoder<AffineTransform>::decode(decoder, affineTransform);
}
+void ArgumentCoder<EventTrackingRegions>::encode(Encoder& encoder, const EventTrackingRegions& eventTrackingRegions)
+{
+ encoder << eventTrackingRegions.asynchronousDispatchRegion;
+ encoder << eventTrackingRegions.eventSpecificSynchronousDispatchRegions;
+}
-void ArgumentCoder<TransformationMatrix>::encode(ArgumentEncoder& encoder, const TransformationMatrix& transformationMatrix)
+bool ArgumentCoder<EventTrackingRegions>::decode(Decoder& decoder, EventTrackingRegions& eventTrackingRegions)
{
- SimpleArgumentCoder<TransformationMatrix>::encode(encoder, transformationMatrix);
+ Region asynchronousDispatchRegion;
+ if (!decoder.decode(asynchronousDispatchRegion))
+ return false;
+ HashMap<String, Region> eventSpecificSynchronousDispatchRegions;
+ if (!decoder.decode(eventSpecificSynchronousDispatchRegions))
+ return false;
+ eventTrackingRegions.asynchronousDispatchRegion = WTFMove(asynchronousDispatchRegion);
+ eventTrackingRegions.eventSpecificSynchronousDispatchRegions = WTFMove(eventSpecificSynchronousDispatchRegions);
+ return true;
}
-bool ArgumentCoder<TransformationMatrix>::decode(ArgumentDecoder& decoder, TransformationMatrix& transformationMatrix)
+void ArgumentCoder<TransformationMatrix>::encode(Encoder& encoder, const TransformationMatrix& transformationMatrix)
{
- return SimpleArgumentCoder<TransformationMatrix>::decode(decoder, transformationMatrix);
+ encoder << transformationMatrix.m11();
+ encoder << transformationMatrix.m12();
+ encoder << transformationMatrix.m13();
+ encoder << transformationMatrix.m14();
+
+ encoder << transformationMatrix.m21();
+ encoder << transformationMatrix.m22();
+ encoder << transformationMatrix.m23();
+ encoder << transformationMatrix.m24();
+
+ encoder << transformationMatrix.m31();
+ encoder << transformationMatrix.m32();
+ encoder << transformationMatrix.m33();
+ encoder << transformationMatrix.m34();
+
+ encoder << transformationMatrix.m41();
+ encoder << transformationMatrix.m42();
+ encoder << transformationMatrix.m43();
+ encoder << transformationMatrix.m44();
}
-void ArgumentCoder<FloatPoint>::encode(ArgumentEncoder& encoder, const FloatPoint& floatPoint)
+bool ArgumentCoder<TransformationMatrix>::decode(Decoder& decoder, TransformationMatrix& transformationMatrix)
+{
+ double m11;
+ if (!decoder.decode(m11))
+ return false;
+ double m12;
+ if (!decoder.decode(m12))
+ return false;
+ double m13;
+ if (!decoder.decode(m13))
+ return false;
+ double m14;
+ if (!decoder.decode(m14))
+ return false;
+
+ double m21;
+ if (!decoder.decode(m21))
+ return false;
+ double m22;
+ if (!decoder.decode(m22))
+ return false;
+ double m23;
+ if (!decoder.decode(m23))
+ return false;
+ double m24;
+ if (!decoder.decode(m24))
+ return false;
+
+ double m31;
+ if (!decoder.decode(m31))
+ return false;
+ double m32;
+ if (!decoder.decode(m32))
+ return false;
+ double m33;
+ if (!decoder.decode(m33))
+ return false;
+ double m34;
+ if (!decoder.decode(m34))
+ return false;
+
+ double m41;
+ if (!decoder.decode(m41))
+ return false;
+ double m42;
+ if (!decoder.decode(m42))
+ return false;
+ double m43;
+ if (!decoder.decode(m43))
+ return false;
+ double m44;
+ if (!decoder.decode(m44))
+ return false;
+
+ transformationMatrix.setMatrix(m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44);
+ return true;
+}
+
+void ArgumentCoder<LinearTimingFunction>::encode(Encoder& encoder, const LinearTimingFunction& timingFunction)
+{
+ encoder.encodeEnum(timingFunction.type());
+}
+
+bool ArgumentCoder<LinearTimingFunction>::decode(Decoder&, LinearTimingFunction&)
+{
+ // Type is decoded by the caller. Nothing else to decode.
+ return true;
+}
+
+void ArgumentCoder<CubicBezierTimingFunction>::encode(Encoder& encoder, const CubicBezierTimingFunction& timingFunction)
+{
+ encoder.encodeEnum(timingFunction.type());
+
+ encoder << timingFunction.x1();
+ encoder << timingFunction.y1();
+ encoder << timingFunction.x2();
+ encoder << timingFunction.y2();
+
+ encoder.encodeEnum(timingFunction.timingFunctionPreset());
+}
+
+bool ArgumentCoder<CubicBezierTimingFunction>::decode(Decoder& decoder, CubicBezierTimingFunction& timingFunction)
+{
+ // Type is decoded by the caller.
+ double x1;
+ if (!decoder.decode(x1))
+ return false;
+
+ double y1;
+ if (!decoder.decode(y1))
+ return false;
+
+ double x2;
+ if (!decoder.decode(x2))
+ return false;
+
+ double y2;
+ if (!decoder.decode(y2))
+ return false;
+
+ CubicBezierTimingFunction::TimingFunctionPreset preset;
+ if (!decoder.decodeEnum(preset))
+ return false;
+
+ timingFunction.setValues(x1, y1, x2, y2);
+ timingFunction.setTimingFunctionPreset(preset);
+
+ return true;
+}
+
+void ArgumentCoder<StepsTimingFunction>::encode(Encoder& encoder, const StepsTimingFunction& timingFunction)
+{
+ encoder.encodeEnum(timingFunction.type());
+
+ encoder << timingFunction.numberOfSteps();
+ encoder << timingFunction.stepAtStart();
+}
+
+bool ArgumentCoder<StepsTimingFunction>::decode(Decoder& decoder, StepsTimingFunction& timingFunction)
+{
+ // Type is decoded by the caller.
+ int numSteps;
+ if (!decoder.decode(numSteps))
+ return false;
+
+ bool stepAtStart;
+ if (!decoder.decode(stepAtStart))
+ return false;
+
+ timingFunction.setNumberOfSteps(numSteps);
+ timingFunction.setStepAtStart(stepAtStart);
+
+ return true;
+}
+
+void ArgumentCoder<SpringTimingFunction>::encode(Encoder& encoder, const SpringTimingFunction& timingFunction)
+{
+ encoder.encodeEnum(timingFunction.type());
+
+ encoder << timingFunction.mass();
+ encoder << timingFunction.stiffness();
+ encoder << timingFunction.damping();
+ encoder << timingFunction.initialVelocity();
+}
+
+bool ArgumentCoder<SpringTimingFunction>::decode(Decoder& decoder, SpringTimingFunction& timingFunction)
+{
+ // Type is decoded by the caller.
+ double mass;
+ if (!decoder.decode(mass))
+ return false;
+
+ double stiffness;
+ if (!decoder.decode(stiffness))
+ return false;
+
+ double damping;
+ if (!decoder.decode(damping))
+ return false;
+
+ double initialVelocity;
+ if (!decoder.decode(initialVelocity))
+ return false;
+
+ timingFunction.setValues(mass, stiffness, damping, initialVelocity);
+
+ return true;
+}
+
+void ArgumentCoder<FloatPoint>::encode(Encoder& encoder, const FloatPoint& floatPoint)
{
SimpleArgumentCoder<FloatPoint>::encode(encoder, floatPoint);
}
-bool ArgumentCoder<FloatPoint>::decode(ArgumentDecoder& decoder, FloatPoint& floatPoint)
+bool ArgumentCoder<FloatPoint>::decode(Decoder& decoder, FloatPoint& floatPoint)
{
return SimpleArgumentCoder<FloatPoint>::decode(decoder, floatPoint);
}
-void ArgumentCoder<FloatPoint3D>::encode(ArgumentEncoder& encoder, const FloatPoint3D& floatPoint)
+void ArgumentCoder<FloatPoint3D>::encode(Encoder& encoder, const FloatPoint3D& floatPoint)
{
SimpleArgumentCoder<FloatPoint3D>::encode(encoder, floatPoint);
}
-bool ArgumentCoder<FloatPoint3D>::decode(ArgumentDecoder& decoder, FloatPoint3D& floatPoint)
+bool ArgumentCoder<FloatPoint3D>::decode(Decoder& decoder, FloatPoint3D& floatPoint)
{
return SimpleArgumentCoder<FloatPoint3D>::decode(decoder, floatPoint);
}
-void ArgumentCoder<FloatRect>::encode(ArgumentEncoder& encoder, const FloatRect& floatRect)
+void ArgumentCoder<FloatRect>::encode(Encoder& encoder, const FloatRect& floatRect)
{
SimpleArgumentCoder<FloatRect>::encode(encoder, floatRect);
}
-bool ArgumentCoder<FloatRect>::decode(ArgumentDecoder& decoder, FloatRect& floatRect)
+bool ArgumentCoder<FloatRect>::decode(Decoder& decoder, FloatRect& floatRect)
{
return SimpleArgumentCoder<FloatRect>::decode(decoder, floatRect);
}
-void ArgumentCoder<FloatSize>::encode(ArgumentEncoder& encoder, const FloatSize& floatSize)
+void ArgumentCoder<FloatSize>::encode(Encoder& encoder, const FloatSize& floatSize)
{
SimpleArgumentCoder<FloatSize>::encode(encoder, floatSize);
}
-bool ArgumentCoder<FloatSize>::decode(ArgumentDecoder& decoder, FloatSize& floatSize)
+bool ArgumentCoder<FloatSize>::decode(Decoder& decoder, FloatSize& floatSize)
{
return SimpleArgumentCoder<FloatSize>::decode(decoder, floatSize);
}
+void ArgumentCoder<FloatRoundedRect>::encode(Encoder& encoder, const FloatRoundedRect& roundedRect)
+{
+ SimpleArgumentCoder<FloatRoundedRect>::encode(encoder, roundedRect);
+}
+
+bool ArgumentCoder<FloatRoundedRect>::decode(Decoder& decoder, FloatRoundedRect& roundedRect)
+{
+ return SimpleArgumentCoder<FloatRoundedRect>::decode(decoder, roundedRect);
+}
+
#if PLATFORM(IOS)
-void ArgumentCoder<FloatQuad>::encode(ArgumentEncoder& encoder, const FloatQuad& floatQuad)
+void ArgumentCoder<FloatQuad>::encode(Encoder& encoder, const FloatQuad& floatQuad)
{
SimpleArgumentCoder<FloatQuad>::encode(encoder, floatQuad);
}
-bool ArgumentCoder<FloatQuad>::decode(ArgumentDecoder& decoder, FloatQuad& floatQuad)
+bool ArgumentCoder<FloatQuad>::decode(Decoder& decoder, FloatQuad& floatQuad)
{
return SimpleArgumentCoder<FloatQuad>::decode(decoder, floatQuad);
}
-void ArgumentCoder<ViewportArguments>::encode(ArgumentEncoder& encoder, const ViewportArguments& viewportArguments)
+void ArgumentCoder<ViewportArguments>::encode(Encoder& encoder, const ViewportArguments& viewportArguments)
{
SimpleArgumentCoder<ViewportArguments>::encode(encoder, viewportArguments);
}
-bool ArgumentCoder<ViewportArguments>::decode(ArgumentDecoder& decoder, ViewportArguments& viewportArguments)
+bool ArgumentCoder<ViewportArguments>::decode(Decoder& decoder, ViewportArguments& viewportArguments)
{
return SimpleArgumentCoder<ViewportArguments>::decode(decoder, viewportArguments);
}
#endif // PLATFORM(IOS)
-void ArgumentCoder<IntPoint>::encode(ArgumentEncoder& encoder, const IntPoint& intPoint)
+void ArgumentCoder<IntPoint>::encode(Encoder& encoder, const IntPoint& intPoint)
{
SimpleArgumentCoder<IntPoint>::encode(encoder, intPoint);
}
-bool ArgumentCoder<IntPoint>::decode(ArgumentDecoder& decoder, IntPoint& intPoint)
+bool ArgumentCoder<IntPoint>::decode(Decoder& decoder, IntPoint& intPoint)
{
return SimpleArgumentCoder<IntPoint>::decode(decoder, intPoint);
}
-void ArgumentCoder<IntRect>::encode(ArgumentEncoder& encoder, const IntRect& intRect)
+void ArgumentCoder<IntRect>::encode(Encoder& encoder, const IntRect& intRect)
{
SimpleArgumentCoder<IntRect>::encode(encoder, intRect);
}
-bool ArgumentCoder<IntRect>::decode(ArgumentDecoder& decoder, IntRect& intRect)
+bool ArgumentCoder<IntRect>::decode(Decoder& decoder, IntRect& intRect)
{
return SimpleArgumentCoder<IntRect>::decode(decoder, intRect);
}
-void ArgumentCoder<IntSize>::encode(ArgumentEncoder& encoder, const IntSize& intSize)
+void ArgumentCoder<IntSize>::encode(Encoder& encoder, const IntSize& intSize)
{
SimpleArgumentCoder<IntSize>::encode(encoder, intSize);
}
-bool ArgumentCoder<IntSize>::decode(ArgumentDecoder& decoder, IntSize& intSize)
+bool ArgumentCoder<IntSize>::decode(Decoder& decoder, IntSize& intSize)
{
return SimpleArgumentCoder<IntSize>::decode(decoder, intSize);
}
-void ArgumentCoder<Length>::encode(ArgumentEncoder& encoder, const Length& length)
+void ArgumentCoder<LayoutSize>::encode(Encoder& encoder, const LayoutSize& layoutSize)
+{
+ SimpleArgumentCoder<LayoutSize>::encode(encoder, layoutSize);
+}
+
+bool ArgumentCoder<LayoutSize>::decode(Decoder& decoder, LayoutSize& layoutSize)
+{
+ return SimpleArgumentCoder<LayoutSize>::decode(decoder, layoutSize);
+}
+
+
+void ArgumentCoder<LayoutPoint>::encode(Encoder& encoder, const LayoutPoint& layoutPoint)
+{
+ SimpleArgumentCoder<LayoutPoint>::encode(encoder, layoutPoint);
+}
+
+bool ArgumentCoder<LayoutPoint>::decode(Decoder& decoder, LayoutPoint& layoutPoint)
+{
+ return SimpleArgumentCoder<LayoutPoint>::decode(decoder, layoutPoint);
+}
+
+
+static void pathEncodeApplierFunction(Encoder& encoder, const PathElement& element)
+{
+ encoder.encodeEnum(element.type);
+
+ switch (element.type) {
+ case PathElementMoveToPoint: // The points member will contain 1 value.
+ encoder << element.points[0];
+ break;
+ case PathElementAddLineToPoint: // The points member will contain 1 value.
+ encoder << element.points[0];
+ break;
+ case PathElementAddQuadCurveToPoint: // The points member will contain 2 values.
+ encoder << element.points[0];
+ encoder << element.points[1];
+ break;
+ case PathElementAddCurveToPoint: // The points member will contain 3 values.
+ encoder << element.points[0];
+ encoder << element.points[1];
+ encoder << element.points[2];
+ break;
+ case PathElementCloseSubpath: // The points member will contain no values.
+ break;
+ }
+}
+
+void ArgumentCoder<Path>::encode(Encoder& encoder, const Path& path)
+{
+ uint64_t numPoints = 0;
+ path.apply([&numPoints](const PathElement&) {
+ ++numPoints;
+ });
+
+ encoder << numPoints;
+
+ path.apply([&encoder](const PathElement& pathElement) {
+ pathEncodeApplierFunction(encoder, pathElement);
+ });
+}
+
+bool ArgumentCoder<Path>::decode(Decoder& decoder, Path& path)
+{
+ uint64_t numPoints;
+ if (!decoder.decode(numPoints))
+ return false;
+
+ path.clear();
+
+ for (uint64_t i = 0; i < numPoints; ++i) {
+
+ PathElementType elementType;
+ if (!decoder.decodeEnum(elementType))
+ return false;
+
+ switch (elementType) {
+ case PathElementMoveToPoint: { // The points member will contain 1 value.
+ FloatPoint point;
+ if (!decoder.decode(point))
+ return false;
+ path.moveTo(point);
+ break;
+ }
+ case PathElementAddLineToPoint: { // The points member will contain 1 value.
+ FloatPoint point;
+ if (!decoder.decode(point))
+ return false;
+ path.addLineTo(point);
+ break;
+ }
+ case PathElementAddQuadCurveToPoint: { // The points member will contain 2 values.
+ FloatPoint controlPoint;
+ if (!decoder.decode(controlPoint))
+ return false;
+
+ FloatPoint endPoint;
+ if (!decoder.decode(endPoint))
+ return false;
+
+ path.addQuadCurveTo(controlPoint, endPoint);
+ break;
+ }
+ case PathElementAddCurveToPoint: { // The points member will contain 3 values.
+ FloatPoint controlPoint1;
+ if (!decoder.decode(controlPoint1))
+ return false;
+
+ FloatPoint controlPoint2;
+ if (!decoder.decode(controlPoint2))
+ return false;
+
+ FloatPoint endPoint;
+ if (!decoder.decode(endPoint))
+ return false;
+
+ path.addBezierCurveTo(controlPoint1, controlPoint2, endPoint);
+ break;
+ }
+ case PathElementCloseSubpath: // The points member will contain no values.
+ path.closeSubpath();
+ break;
+ }
+ }
+
+ return true;
+}
+
+void ArgumentCoder<RecentSearch>::encode(Encoder& encoder, const RecentSearch& recentSearch)
+{
+ encoder << recentSearch.string << recentSearch.time;
+}
+
+bool ArgumentCoder<RecentSearch>::decode(Decoder& decoder, RecentSearch& recentSearch)
+{
+ if (!decoder.decode(recentSearch.string))
+ return false;
+
+ if (!decoder.decode(recentSearch.time))
+ return false;
+
+ return true;
+}
+
+template<> struct ArgumentCoder<Region::Span> {
+ static void encode(Encoder&, const Region::Span&);
+ static bool decode(Decoder&, Region::Span&);
+};
+
+void ArgumentCoder<Region::Span>::encode(Encoder& encoder, const Region::Span& span)
+{
+ encoder << span.y;
+ encoder << (uint64_t)span.segmentIndex;
+}
+
+bool ArgumentCoder<Region::Span>::decode(Decoder& decoder, Region::Span& span)
+{
+ if (!decoder.decode(span.y))
+ return false;
+
+ uint64_t segmentIndex;
+ if (!decoder.decode(segmentIndex))
+ return false;
+
+ span.segmentIndex = segmentIndex;
+ return true;
+}
+
+void ArgumentCoder<Region>::encode(Encoder& encoder, const Region& region)
+{
+ encoder.encode(region.shapeSegments());
+ encoder.encode(region.shapeSpans());
+}
+
+bool ArgumentCoder<Region>::decode(Decoder& decoder, Region& region)
+{
+ Vector<int> segments;
+ if (!decoder.decode(segments))
+ return false;
+
+ Vector<Region::Span> spans;
+ if (!decoder.decode(spans))
+ return false;
+
+ region.setShapeSegments(segments);
+ region.setShapeSpans(spans);
+ region.updateBoundsFromShape();
+
+ if (!region.isValid())
+ return false;
+
+ return true;
+}
+
+void ArgumentCoder<Length>::encode(Encoder& encoder, const Length& length)
{
SimpleArgumentCoder<Length>::encode(encoder, length);
}
-bool ArgumentCoder<Length>::decode(ArgumentDecoder& decoder, Length& length)
+bool ArgumentCoder<Length>::decode(Decoder& decoder, Length& length)
{
return SimpleArgumentCoder<Length>::decode(decoder, length);
}
-void ArgumentCoder<ViewportAttributes>::encode(ArgumentEncoder& encoder, const ViewportAttributes& viewportAttributes)
+void ArgumentCoder<ViewportAttributes>::encode(Encoder& encoder, const ViewportAttributes& viewportAttributes)
{
SimpleArgumentCoder<ViewportAttributes>::encode(encoder, viewportAttributes);
}
-bool ArgumentCoder<ViewportAttributes>::decode(ArgumentDecoder& decoder, ViewportAttributes& viewportAttributes)
+bool ArgumentCoder<ViewportAttributes>::decode(Decoder& decoder, ViewportAttributes& viewportAttributes)
{
return SimpleArgumentCoder<ViewportAttributes>::decode(decoder, viewportAttributes);
}
-void ArgumentCoder<MimeClassInfo>::encode(ArgumentEncoder& encoder, const MimeClassInfo& mimeClassInfo)
+void ArgumentCoder<MimeClassInfo>::encode(Encoder& encoder, const MimeClassInfo& mimeClassInfo)
{
encoder << mimeClassInfo.type << mimeClassInfo.desc << mimeClassInfo.extensions;
}
-bool ArgumentCoder<MimeClassInfo>::decode(ArgumentDecoder& decoder, MimeClassInfo& mimeClassInfo)
+bool ArgumentCoder<MimeClassInfo>::decode(Decoder& decoder, MimeClassInfo& mimeClassInfo)
{
if (!decoder.decode(mimeClassInfo.type))
return false;
@@ -239,12 +700,21 @@ bool ArgumentCoder<MimeClassInfo>::decode(ArgumentDecoder& decoder, MimeClassInf
}
-void ArgumentCoder<PluginInfo>::encode(ArgumentEncoder& encoder, const PluginInfo& pluginInfo)
+void ArgumentCoder<PluginInfo>::encode(Encoder& encoder, const PluginInfo& pluginInfo)
{
- encoder << pluginInfo.name << pluginInfo.file << pluginInfo.desc << pluginInfo.mimes << pluginInfo.isApplicationPlugin;
+ encoder << pluginInfo.name;
+ encoder << pluginInfo.file;
+ encoder << pluginInfo.desc;
+ encoder << pluginInfo.mimes;
+ encoder << pluginInfo.isApplicationPlugin;
+ encoder.encodeEnum(pluginInfo.clientLoadPolicy);
+#if PLATFORM(MAC)
+ encoder << pluginInfo.bundleIdentifier;
+ encoder << pluginInfo.versionString;
+#endif
}
-
-bool ArgumentCoder<PluginInfo>::decode(ArgumentDecoder& decoder, PluginInfo& pluginInfo)
+
+bool ArgumentCoder<PluginInfo>::decode(Decoder& decoder, PluginInfo& pluginInfo)
{
if (!decoder.decode(pluginInfo.name))
return false;
@@ -256,28 +726,24 @@ bool ArgumentCoder<PluginInfo>::decode(ArgumentDecoder& decoder, PluginInfo& plu
return false;
if (!decoder.decode(pluginInfo.isApplicationPlugin))
return false;
+ if (!decoder.decodeEnum(pluginInfo.clientLoadPolicy))
+ return false;
+#if PLATFORM(MAC)
+ if (!decoder.decode(pluginInfo.bundleIdentifier))
+ return false;
+ if (!decoder.decode(pluginInfo.versionString))
+ return false;
+#endif
return true;
}
-
-void ArgumentCoder<HTTPHeaderMap>::encode(ArgumentEncoder& encoder, const HTTPHeaderMap& headerMap)
-{
- encoder << static_cast<const HashMap<AtomicString, String, CaseFoldingHash>&>(headerMap);
-}
-
-bool ArgumentCoder<HTTPHeaderMap>::decode(ArgumentDecoder& decoder, HTTPHeaderMap& headerMap)
-{
- return decoder.decode(static_cast<HashMap<AtomicString, String, CaseFoldingHash>&>(headerMap));
-}
-
-
-void ArgumentCoder<AuthenticationChallenge>::encode(ArgumentEncoder& encoder, const AuthenticationChallenge& challenge)
+void ArgumentCoder<AuthenticationChallenge>::encode(Encoder& encoder, const AuthenticationChallenge& challenge)
{
encoder << challenge.protectionSpace() << challenge.proposedCredential() << challenge.previousFailureCount() << challenge.failureResponse() << challenge.error();
}
-bool ArgumentCoder<AuthenticationChallenge>::decode(ArgumentDecoder& decoder, AuthenticationChallenge& challenge)
+bool ArgumentCoder<AuthenticationChallenge>::decode(Decoder& decoder, AuthenticationChallenge& challenge)
{
ProtectionSpace protectionSpace;
if (!decoder.decode(protectionSpace))
@@ -304,15 +770,29 @@ bool ArgumentCoder<AuthenticationChallenge>::decode(ArgumentDecoder& decoder, Au
}
-void ArgumentCoder<ProtectionSpace>::encode(ArgumentEncoder& encoder, const ProtectionSpace& space)
+void ArgumentCoder<ProtectionSpace>::encode(Encoder& encoder, const ProtectionSpace& space)
{
+ if (space.encodingRequiresPlatformData()) {
+ encoder << true;
+ encodePlatformData(encoder, space);
+ return;
+ }
+
+ encoder << false;
encoder << space.host() << space.port() << space.realm();
encoder.encodeEnum(space.authenticationScheme());
encoder.encodeEnum(space.serverType());
}
-bool ArgumentCoder<ProtectionSpace>::decode(ArgumentDecoder& decoder, ProtectionSpace& space)
+bool ArgumentCoder<ProtectionSpace>::decode(Decoder& decoder, ProtectionSpace& space)
{
+ bool hasPlatformData;
+ if (!decoder.decode(hasPlatformData))
+ return false;
+
+ if (hasPlatformData)
+ return decodePlatformData(decoder, space);
+
String host;
if (!decoder.decode(host))
return false;
@@ -337,14 +817,28 @@ bool ArgumentCoder<ProtectionSpace>::decode(ArgumentDecoder& decoder, Protection
return true;
}
-void ArgumentCoder<Credential>::encode(ArgumentEncoder& encoder, const Credential& credential)
+void ArgumentCoder<Credential>::encode(Encoder& encoder, const Credential& credential)
{
+ if (credential.encodingRequiresPlatformData()) {
+ encoder << true;
+ encodePlatformData(encoder, credential);
+ return;
+ }
+
+ encoder << false;
encoder << credential.user() << credential.password();
encoder.encodeEnum(credential.persistence());
}
-bool ArgumentCoder<Credential>::decode(ArgumentDecoder& decoder, Credential& credential)
+bool ArgumentCoder<Credential>::decode(Decoder& decoder, Credential& credential)
{
+ bool hasPlatformData;
+ if (!decoder.decode(hasPlatformData))
+ return false;
+
+ if (hasPlatformData)
+ return decodePlatformData(decoder, credential);
+
String user;
if (!decoder.decode(user))
return false;
@@ -361,10 +855,10 @@ bool ArgumentCoder<Credential>::decode(ArgumentDecoder& decoder, Credential& cre
return true;
}
-static void encodeImage(ArgumentEncoder& encoder, Image* image)
+static void encodeImage(Encoder& encoder, Image& image)
{
- RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(image->size(), ShareableBitmap::SupportsAlpha);
- bitmap->createGraphicsContext()->drawImage(image, ColorSpaceDeviceRGB, IntPoint());
+ RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(IntSize(image.size()), ShareableBitmap::SupportsAlpha);
+ bitmap->createGraphicsContext()->drawImage(image, IntPoint());
ShareableBitmap::Handle handle;
bitmap->createHandle(handle);
@@ -372,7 +866,7 @@ static void encodeImage(ArgumentEncoder& encoder, Image* image)
encoder << handle;
}
-static bool decodeImage(ArgumentDecoder& decoder, RefPtr<Image>& image)
+static bool decodeImage(Decoder& decoder, RefPtr<Image>& image)
{
ShareableBitmap::Handle handle;
if (!decoder.decode(handle))
@@ -387,8 +881,31 @@ static bool decodeImage(ArgumentDecoder& decoder, RefPtr<Image>& image)
return true;
}
+static void encodeOptionalImage(Encoder& encoder, Image* image)
+{
+ bool hasImage = !!image;
+ encoder << hasImage;
+
+ if (hasImage)
+ encodeImage(encoder, *image);
+}
+
+static bool decodeOptionalImage(Decoder& decoder, RefPtr<Image>& image)
+{
+ image = nullptr;
+
+ bool hasImage;
+ if (!decoder.decode(hasImage))
+ return false;
+
+ if (!hasImage)
+ return true;
+
+ return decodeImage(decoder, image);
+}
+
#if !PLATFORM(IOS)
-void ArgumentCoder<Cursor>::encode(ArgumentEncoder& encoder, const Cursor& cursor)
+void ArgumentCoder<Cursor>::encode(Encoder& encoder, const Cursor& cursor)
{
encoder.encodeEnum(cursor.type());
@@ -401,11 +918,14 @@ void ArgumentCoder<Cursor>::encode(ArgumentEncoder& encoder, const Cursor& curso
}
encoder << true;
- encodeImage(encoder, cursor.image());
+ encodeImage(encoder, *cursor.image());
encoder << cursor.hotSpot();
+#if ENABLE(MOUSE_CURSOR_SCALE)
+ encoder << cursor.imageScaleFactor();
+#endif
}
-bool ArgumentCoder<Cursor>::decode(ArgumentDecoder& decoder, Cursor& cursor)
+bool ArgumentCoder<Cursor>::decode(Decoder& decoder, Cursor& cursor)
{
Cursor::Type type;
if (!decoder.decodeEnum(type))
@@ -444,249 +964,67 @@ bool ArgumentCoder<Cursor>::decode(ArgumentDecoder& decoder, Cursor& cursor)
if (!image->rect().contains(hotSpot))
return false;
+#if ENABLE(MOUSE_CURSOR_SCALE)
+ float scale;
+ if (!decoder.decode(scale))
+ return false;
+
+ cursor = Cursor(image.get(), hotSpot, scale);
+#else
cursor = Cursor(image.get(), hotSpot);
+#endif
return true;
}
#endif
-void ArgumentCoder<ResourceRequest>::encode(ArgumentEncoder& encoder, const ResourceRequest& resourceRequest)
+void ArgumentCoder<ResourceRequest>::encode(Encoder& encoder, const ResourceRequest& resourceRequest)
{
- if (kShouldSerializeWebCoreData) {
- encoder << resourceRequest.url().string();
- encoder << resourceRequest.httpMethod();
- encoder << resourceRequest.httpHeaderFields();
-
- // FIXME: Do not encode HTTP message body.
- // 1. It can be large and thus costly to send across.
- // 2. It is misleading to provide a body with some requests, while others use body streams, which cannot be serialized at all.
- FormData* httpBody = resourceRequest.httpBody();
- encoder << static_cast<bool>(httpBody);
- if (httpBody)
- encoder << httpBody->flattenToString();
-
- encoder << resourceRequest.firstPartyForCookies().string();
- }
-
-#if ENABLE(CACHE_PARTITIONING)
encoder << resourceRequest.cachePartition();
-#endif
+ encoder << resourceRequest.hiddenFromInspector();
- encodePlatformData(encoder, resourceRequest);
+ if (resourceRequest.encodingRequiresPlatformData()) {
+ encoder << true;
+ encodePlatformData(encoder, resourceRequest);
+ return;
+ }
+ encoder << false;
+ resourceRequest.encodeWithoutPlatformData(encoder);
}
-bool ArgumentCoder<ResourceRequest>::decode(ArgumentDecoder& decoder, ResourceRequest& resourceRequest)
+bool ArgumentCoder<ResourceRequest>::decode(Decoder& decoder, ResourceRequest& resourceRequest)
{
- if (kShouldSerializeWebCoreData) {
- ResourceRequest request;
-
- String url;
- if (!decoder.decode(url))
- return false;
- request.setURL(URL(URL(), url));
-
- String httpMethod;
- if (!decoder.decode(httpMethod))
- return false;
- request.setHTTPMethod(httpMethod);
-
- HTTPHeaderMap headers;
- if (!decoder.decode(headers))
- return false;
- request.addHTTPHeaderFields(headers);
-
- bool hasHTTPBody;
- if (!decoder.decode(hasHTTPBody))
- return false;
- if (hasHTTPBody) {
- String httpBody;
- if (!decoder.decode(httpBody))
- return false;
- request.setHTTPBody(FormData::create(httpBody.utf8()));
- }
-
- String firstPartyForCookies;
- if (!decoder.decode(firstPartyForCookies))
- return false;
- request.setFirstPartyForCookies(URL(URL(), firstPartyForCookies));
-
- resourceRequest = request;
- }
-
-#if ENABLE(CACHE_PARTITIONING)
String cachePartition;
if (!decoder.decode(cachePartition))
return false;
resourceRequest.setCachePartition(cachePartition);
-#endif
-
- return decodePlatformData(decoder, resourceRequest);
-}
-
-void ArgumentCoder<ResourceResponse>::encode(ArgumentEncoder& encoder, const ResourceResponse& resourceResponse)
-{
-#if PLATFORM(MAC)
- bool shouldSerializeWebCoreData = !resourceResponse.platformResponseIsUpToDate();
- encoder << shouldSerializeWebCoreData;
-#else
- bool shouldSerializeWebCoreData = true;
-#endif
-
- encodePlatformData(encoder, resourceResponse);
-
- if (shouldSerializeWebCoreData) {
- bool responseIsNull = resourceResponse.isNull();
- encoder << responseIsNull;
- if (responseIsNull)
- return;
-
- encoder << resourceResponse.url().string();
- encoder << static_cast<int32_t>(resourceResponse.httpStatusCode());
- encoder << resourceResponse.httpHeaderFields();
- encoder << resourceResponse.mimeType();
- encoder << resourceResponse.textEncodingName();
- encoder << static_cast<int64_t>(resourceResponse.expectedContentLength());
- encoder << resourceResponse.httpStatusText();
- encoder << resourceResponse.suggestedFilename();
- }
-}
-
-bool ArgumentCoder<ResourceResponse>::decode(ArgumentDecoder& decoder, ResourceResponse& resourceResponse)
-{
-#if PLATFORM(MAC)
- bool hasSerializedWebCoreData;
- if (!decoder.decode(hasSerializedWebCoreData))
+ bool isHiddenFromInspector;
+ if (!decoder.decode(isHiddenFromInspector))
return false;
-#else
- bool hasSerializedWebCoreData = true;
-#endif
-
- ResourceResponse response;
+ resourceRequest.setHiddenFromInspector(isHiddenFromInspector);
- if (!decodePlatformData(decoder, response))
+ bool hasPlatformData;
+ if (!decoder.decode(hasPlatformData))
return false;
+ if (hasPlatformData)
+ return decodePlatformData(decoder, resourceRequest);
- if (hasSerializedWebCoreData) {
- bool responseIsNull;
- if (!decoder.decode(responseIsNull))
- return false;
- if (responseIsNull) {
- resourceResponse = ResourceResponse();
- return true;
- }
-
- String url;
- if (!decoder.decode(url))
- return false;
- response.setURL(URL(URL(), url));
-
- int32_t httpStatusCode;
- if (!decoder.decode(httpStatusCode))
- return false;
- response.setHTTPStatusCode(httpStatusCode);
-
- HTTPHeaderMap headers;
- if (!decoder.decode(headers))
- return false;
- for (HTTPHeaderMap::const_iterator it = headers.begin(), end = headers.end(); it != end; ++it)
- response.setHTTPHeaderField(it->key, it->value);
-
- String mimeType;
- if (!decoder.decode(mimeType))
- return false;
- response.setMimeType(mimeType);
-
- String textEncodingName;
- if (!decoder.decode(textEncodingName))
- return false;
- response.setTextEncodingName(textEncodingName);
-
- int64_t contentLength;
- if (!decoder.decode(contentLength))
- return false;
- response.setExpectedContentLength(contentLength);
-
- String httpStatusText;
- if (!decoder.decode(httpStatusText))
- return false;
- response.setHTTPStatusText(httpStatusText);
-
- String suggestedFilename;
- if (!decoder.decode(suggestedFilename))
- return false;
- response.setSuggestedFilename(suggestedFilename);
- }
-
- resourceResponse = response;
-
- return true;
+ return resourceRequest.decodeWithoutPlatformData(decoder);
}
-void ArgumentCoder<ResourceError>::encode(ArgumentEncoder& encoder, const ResourceError& resourceError)
+void ArgumentCoder<ResourceError>::encode(Encoder& encoder, const ResourceError& resourceError)
{
- if (kShouldSerializeWebCoreData) {
- bool errorIsNull = resourceError.isNull();
- encoder << errorIsNull;
- if (errorIsNull)
- return;
-
- encoder << resourceError.domain();
- encoder << resourceError.errorCode();
- encoder << resourceError.failingURL();
- encoder << resourceError.localizedDescription();
- encoder << resourceError.isCancellation();
- encoder << resourceError.isTimeout();
- }
-
encodePlatformData(encoder, resourceError);
}
-bool ArgumentCoder<ResourceError>::decode(ArgumentDecoder& decoder, ResourceError& resourceError)
+bool ArgumentCoder<ResourceError>::decode(Decoder& decoder, ResourceError& resourceError)
{
- if (kShouldSerializeWebCoreData) {
- bool errorIsNull;
- if (!decoder.decode(errorIsNull))
- return false;
- if (errorIsNull) {
- resourceError = ResourceError();
- return true;
- }
-
- String domain;
- if (!decoder.decode(domain))
- return false;
-
- int errorCode;
- if (!decoder.decode(errorCode))
- return false;
-
- String failingURL;
- if (!decoder.decode(failingURL))
- return false;
-
- String localizedDescription;
- if (!decoder.decode(localizedDescription))
- return false;
-
- bool isCancellation;
- if (!decoder.decode(isCancellation))
- return false;
-
- bool isTimeout;
- if (!decoder.decode(isTimeout))
- return false;
-
- resourceError = ResourceError(domain, errorCode, failingURL, localizedDescription);
- resourceError.setIsCancellation(isCancellation);
- resourceError.setIsTimeout(isTimeout);
- }
-
return decodePlatformData(decoder, resourceError);
}
#if PLATFORM(IOS)
-void ArgumentCoder<SelectionRect>::encode(ArgumentEncoder& encoder, const SelectionRect& selectionRect)
+void ArgumentCoder<SelectionRect>::encode(Encoder& encoder, const SelectionRect& selectionRect)
{
encoder << selectionRect.rect();
encoder << static_cast<uint32_t>(selectionRect.direction());
@@ -702,9 +1040,9 @@ void ArgumentCoder<SelectionRect>::encode(ArgumentEncoder& encoder, const Select
encoder << selectionRect.isHorizontal();
}
-bool ArgumentCoder<SelectionRect>::decode(ArgumentDecoder& decoder, SelectionRect& selectionRect)
+bool ArgumentCoder<SelectionRect>::decode(Decoder& decoder, SelectionRect& selectionRect)
{
- WebCore::IntRect rect;
+ IntRect rect;
if (!decoder.decode(rect))
return false;
selectionRect.setRect(rect);
@@ -712,7 +1050,7 @@ bool ArgumentCoder<SelectionRect>::decode(ArgumentDecoder& decoder, SelectionRec
uint32_t direction;
if (!decoder.decode(direction))
return false;
- selectionRect.setDirection((WebCore::TextDirection)direction);
+ selectionRect.setDirection((TextDirection)direction);
int intValue;
if (!decoder.decode(intValue))
@@ -761,16 +1099,12 @@ bool ArgumentCoder<SelectionRect>::decode(ArgumentDecoder& decoder, SelectionRec
#endif
-void ArgumentCoder<WindowFeatures>::encode(ArgumentEncoder& encoder, const WindowFeatures& windowFeatures)
+void ArgumentCoder<WindowFeatures>::encode(Encoder& encoder, const WindowFeatures& windowFeatures)
{
encoder << windowFeatures.x;
encoder << windowFeatures.y;
encoder << windowFeatures.width;
encoder << windowFeatures.height;
- encoder << windowFeatures.xSet;
- encoder << windowFeatures.ySet;
- encoder << windowFeatures.widthSet;
- encoder << windowFeatures.heightSet;
encoder << windowFeatures.menuBarVisible;
encoder << windowFeatures.statusBarVisible;
encoder << windowFeatures.toolBarVisible;
@@ -781,7 +1115,7 @@ void ArgumentCoder<WindowFeatures>::encode(ArgumentEncoder& encoder, const Windo
encoder << windowFeatures.dialog;
}
-bool ArgumentCoder<WindowFeatures>::decode(ArgumentDecoder& decoder, WindowFeatures& windowFeatures)
+bool ArgumentCoder<WindowFeatures>::decode(Decoder& decoder, WindowFeatures& windowFeatures)
{
if (!decoder.decode(windowFeatures.x))
return false;
@@ -791,14 +1125,6 @@ bool ArgumentCoder<WindowFeatures>::decode(ArgumentDecoder& decoder, WindowFeatu
return false;
if (!decoder.decode(windowFeatures.height))
return false;
- if (!decoder.decode(windowFeatures.xSet))
- return false;
- if (!decoder.decode(windowFeatures.ySet))
- return false;
- if (!decoder.decode(windowFeatures.widthSet))
- return false;
- if (!decoder.decode(windowFeatures.heightSet))
- return false;
if (!decoder.decode(windowFeatures.menuBarVisible))
return false;
if (!decoder.decode(windowFeatures.statusBarVisible))
@@ -819,8 +1145,20 @@ bool ArgumentCoder<WindowFeatures>::decode(ArgumentDecoder& decoder, WindowFeatu
}
-void ArgumentCoder<Color>::encode(ArgumentEncoder& encoder, const Color& color)
+void ArgumentCoder<Color>::encode(Encoder& encoder, const Color& color)
{
+ if (color.isExtended()) {
+ encoder << true;
+ encoder << color.asExtended().red();
+ encoder << color.asExtended().green();
+ encoder << color.asExtended().blue();
+ encoder << color.asExtended().alpha();
+ encoder << color.asExtended().colorSpace();
+ return;
+ }
+
+ encoder << false;
+
if (!color.isValid()) {
encoder << false;
return;
@@ -830,8 +1168,32 @@ void ArgumentCoder<Color>::encode(ArgumentEncoder& encoder, const Color& color)
encoder << color.rgb();
}
-bool ArgumentCoder<Color>::decode(ArgumentDecoder& decoder, Color& color)
+bool ArgumentCoder<Color>::decode(Decoder& decoder, Color& color)
{
+ bool isExtended;
+ if (!decoder.decode(isExtended))
+ return false;
+
+ if (isExtended) {
+ float red;
+ float green;
+ float blue;
+ float alpha;
+ ColorSpace colorSpace;
+ if (!decoder.decode(red))
+ return false;
+ if (!decoder.decode(green))
+ return false;
+ if (!decoder.decode(blue))
+ return false;
+ if (!decoder.decode(alpha))
+ return false;
+ if (!decoder.decode(colorSpace))
+ return false;
+ color = Color(red, green, blue, alpha, colorSpace);
+ return true;
+ }
+
bool isValid;
if (!decoder.decode(isValid))
return false;
@@ -849,8 +1211,58 @@ bool ArgumentCoder<Color>::decode(ArgumentDecoder& decoder, Color& color)
return true;
}
+#if ENABLE(DRAG_SUPPORT)
+void ArgumentCoder<DragData>::encode(Encoder& encoder, const DragData& dragData)
+{
+ encoder << dragData.clientPosition();
+ encoder << dragData.globalPosition();
+ encoder.encodeEnum(dragData.draggingSourceOperationMask());
+ encoder.encodeEnum(dragData.flags());
+#if PLATFORM(COCOA)
+ encoder << dragData.pasteboardName();
+#endif
+#if PLATFORM(MAC)
+ encoder << dragData.fileNames();
+#endif
+}
+
+bool ArgumentCoder<DragData>::decode(Decoder& decoder, DragData& dragData)
+{
+ IntPoint clientPosition;
+ if (!decoder.decode(clientPosition))
+ return false;
+
+ IntPoint globalPosition;
+ if (!decoder.decode(globalPosition))
+ return false;
+
+ DragOperation draggingSourceOperationMask;
+ if (!decoder.decodeEnum(draggingSourceOperationMask))
+ return false;
+
+ DragApplicationFlags applicationFlags;
+ if (!decoder.decodeEnum(applicationFlags))
+ return false;
+
+ String pasteboardName;
+#if PLATFORM(COCOA)
+ if (!decoder.decode(pasteboardName))
+ return false;
+#endif
+ Vector<String> fileNames;
+#if PLATFORM(MAC)
+ if (!decoder.decode(fileNames))
+ return false;
+#endif
+
+ dragData = DragData(pasteboardName, clientPosition, globalPosition, draggingSourceOperationMask, applicationFlags);
+ dragData.setFileNames(fileNames);
+
+ return true;
+}
+#endif
-void ArgumentCoder<CompositionUnderline>::encode(ArgumentEncoder& encoder, const CompositionUnderline& underline)
+void ArgumentCoder<CompositionUnderline>::encode(Encoder& encoder, const CompositionUnderline& underline)
{
encoder << underline.startOffset;
encoder << underline.endOffset;
@@ -858,7 +1270,7 @@ void ArgumentCoder<CompositionUnderline>::encode(ArgumentEncoder& encoder, const
encoder << underline.color;
}
-bool ArgumentCoder<CompositionUnderline>::decode(ArgumentDecoder& decoder, CompositionUnderline& underline)
+bool ArgumentCoder<CompositionUnderline>::decode(Decoder& decoder, CompositionUnderline& underline)
{
if (!decoder.decode(underline.startOffset))
return false;
@@ -873,7 +1285,7 @@ bool ArgumentCoder<CompositionUnderline>::decode(ArgumentDecoder& decoder, Compo
}
-void ArgumentCoder<Cookie>::encode(ArgumentEncoder& encoder, const Cookie& cookie)
+void ArgumentCoder<Cookie>::encode(Encoder& encoder, const Cookie& cookie)
{
encoder << cookie.name;
encoder << cookie.value;
@@ -885,7 +1297,7 @@ void ArgumentCoder<Cookie>::encode(ArgumentEncoder& encoder, const Cookie& cooki
encoder << cookie.session;
}
-bool ArgumentCoder<Cookie>::decode(ArgumentDecoder& decoder, Cookie& cookie)
+bool ArgumentCoder<Cookie>::decode(Decoder& decoder, Cookie& cookie)
{
if (!decoder.decode(cookie.name))
return false;
@@ -907,9 +1319,7 @@ bool ArgumentCoder<Cookie>::decode(ArgumentDecoder& decoder, Cookie& cookie)
return true;
}
-
-#if ENABLE(SQL_DATABASE)
-void ArgumentCoder<DatabaseDetails>::encode(ArgumentEncoder& encoder, const DatabaseDetails& details)
+void ArgumentCoder<DatabaseDetails>::encode(Encoder& encoder, const DatabaseDetails& details)
{
encoder << details.name();
encoder << details.displayName();
@@ -919,7 +1329,7 @@ void ArgumentCoder<DatabaseDetails>::encode(ArgumentEncoder& encoder, const Data
encoder << details.modificationTime();
}
-bool ArgumentCoder<DatabaseDetails>::decode(ArgumentDecoder& decoder, DatabaseDetails& details)
+bool ArgumentCoder<DatabaseDetails>::decode(Decoder& decoder, DatabaseDetails& details)
{
String name;
if (!decoder.decode(name))
@@ -949,23 +1359,57 @@ bool ArgumentCoder<DatabaseDetails>::decode(ArgumentDecoder& decoder, DatabaseDe
return true;
}
-#endif
-
#if PLATFORM(IOS)
-static void encodeSharedBuffer(ArgumentEncoder& encoder, SharedBuffer* buffer)
+void ArgumentCoder<Highlight>::encode(Encoder& encoder, const Highlight& highlight)
+{
+ encoder << static_cast<uint32_t>(highlight.type);
+ encoder << highlight.usePageCoordinates;
+ encoder << highlight.contentColor;
+ encoder << highlight.contentOutlineColor;
+ encoder << highlight.paddingColor;
+ encoder << highlight.borderColor;
+ encoder << highlight.marginColor;
+ encoder << highlight.quads;
+}
+
+bool ArgumentCoder<Highlight>::decode(Decoder& decoder, Highlight& highlight)
+{
+ uint32_t type;
+ if (!decoder.decode(type))
+ return false;
+ highlight.type = (HighlightType)type;
+
+ if (!decoder.decode(highlight.usePageCoordinates))
+ return false;
+ if (!decoder.decode(highlight.contentColor))
+ return false;
+ if (!decoder.decode(highlight.contentOutlineColor))
+ return false;
+ if (!decoder.decode(highlight.paddingColor))
+ return false;
+ if (!decoder.decode(highlight.borderColor))
+ return false;
+ if (!decoder.decode(highlight.marginColor))
+ return false;
+ if (!decoder.decode(highlight.quads))
+ return false;
+ return true;
+}
+
+static void encodeSharedBuffer(Encoder& encoder, SharedBuffer* buffer)
{
SharedMemory::Handle handle;
encoder << (buffer ? static_cast<uint64_t>(buffer->size()): 0);
if (buffer) {
- RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::create(buffer->size());
+ RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::allocate(buffer->size());
memcpy(sharedMemoryBuffer->data(), buffer->data(), buffer->size());
- sharedMemoryBuffer->createHandle(handle, SharedMemory::ReadOnly);
+ sharedMemoryBuffer->createHandle(handle, SharedMemory::Protection::ReadOnly);
encoder << handle;
}
}
-static bool decodeSharedBuffer(ArgumentDecoder& decoder, RefPtr<SharedBuffer>& buffer)
+static bool decodeSharedBuffer(Decoder& decoder, RefPtr<SharedBuffer>& buffer)
{
uint64_t bufferSize = 0;
if (!decoder.decode(bufferSize))
@@ -976,14 +1420,14 @@ static bool decodeSharedBuffer(ArgumentDecoder& decoder, RefPtr<SharedBuffer>& b
if (!decoder.decode(handle))
return false;
- RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::create(handle, SharedMemory::ReadOnly);
+ RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::map(handle, SharedMemory::Protection::ReadOnly);
buffer = SharedBuffer::create(static_cast<unsigned char*>(sharedMemoryBuffer->data()), bufferSize);
}
return true;
}
-void ArgumentCoder<PasteboardWebContent>::encode(ArgumentEncoder& encoder, const WebCore::PasteboardWebContent& content)
+void ArgumentCoder<PasteboardWebContent>::encode(Encoder& encoder, const PasteboardWebContent& content)
{
encoder << content.canSmartCopyOrDelete;
encoder << content.dataInStringFormat;
@@ -998,7 +1442,7 @@ void ArgumentCoder<PasteboardWebContent>::encode(ArgumentEncoder& encoder, const
encodeSharedBuffer(encoder, content.clientData[i].get());
}
-bool ArgumentCoder<PasteboardWebContent>::decode(ArgumentDecoder& decoder, WebCore::PasteboardWebContent& content)
+bool ArgumentCoder<PasteboardWebContent>::decode(Decoder& decoder, PasteboardWebContent& content)
{
if (!decoder.decode(content.canSmartCopyOrDelete))
return false;
@@ -1022,9 +1466,9 @@ bool ArgumentCoder<PasteboardWebContent>::decode(ArgumentDecoder& decoder, WebCo
return true;
}
-void ArgumentCoder<PasteboardImage>::encode(ArgumentEncoder& encoder, const WebCore::PasteboardImage& pasteboardImage)
+void ArgumentCoder<PasteboardImage>::encode(Encoder& encoder, const PasteboardImage& pasteboardImage)
{
- encodeImage(encoder, pasteboardImage.image.get());
+ encodeOptionalImage(encoder, pasteboardImage.image.get());
encoder << pasteboardImage.url.url;
encoder << pasteboardImage.url.title;
encoder << pasteboardImage.resourceMIMEType;
@@ -1032,9 +1476,9 @@ void ArgumentCoder<PasteboardImage>::encode(ArgumentEncoder& encoder, const WebC
encodeSharedBuffer(encoder, pasteboardImage.resourceData.get());
}
-bool ArgumentCoder<PasteboardImage>::decode(ArgumentDecoder& decoder, WebCore::PasteboardImage& pasteboardImage)
+bool ArgumentCoder<PasteboardImage>::decode(Decoder& decoder, PasteboardImage& pasteboardImage)
{
- if (!decodeImage(decoder, pasteboardImage.image))
+ if (!decodeOptionalImage(decoder, pasteboardImage.image))
return false;
if (!decoder.decode(pasteboardImage.url.url))
return false;
@@ -1049,14 +1493,14 @@ bool ArgumentCoder<PasteboardImage>::decode(ArgumentDecoder& decoder, WebCore::P
#endif
-void ArgumentCoder<DictationAlternative>::encode(ArgumentEncoder& encoder, const DictationAlternative& dictationAlternative)
+void ArgumentCoder<DictationAlternative>::encode(Encoder& encoder, const DictationAlternative& dictationAlternative)
{
encoder << dictationAlternative.rangeStart;
encoder << dictationAlternative.rangeLength;
encoder << dictationAlternative.dictationContext;
}
-bool ArgumentCoder<DictationAlternative>::decode(ArgumentDecoder& decoder, DictationAlternative& dictationAlternative)
+bool ArgumentCoder<DictationAlternative>::decode(Decoder& decoder, DictationAlternative& dictationAlternative)
{
if (!decoder.decode(dictationAlternative.rangeStart))
return false;
@@ -1068,33 +1512,26 @@ bool ArgumentCoder<DictationAlternative>::decode(ArgumentDecoder& decoder, Dicta
}
-void ArgumentCoder<FileChooserSettings>::encode(ArgumentEncoder& encoder, const FileChooserSettings& settings)
+void ArgumentCoder<FileChooserSettings>::encode(Encoder& encoder, const FileChooserSettings& settings)
{
encoder << settings.allowsMultipleFiles;
-#if ENABLE(DIRECTORY_UPLOAD)
- encoder << settings.allowsDirectoryUpload;
-#endif
encoder << settings.acceptMIMETypes;
encoder << settings.selectedFiles;
#if ENABLE(MEDIA_CAPTURE)
- encoder << settings.capture;
+ encoder.encodeEnum(settings.mediaCaptureType);
#endif
}
-bool ArgumentCoder<FileChooserSettings>::decode(ArgumentDecoder& decoder, FileChooserSettings& settings)
+bool ArgumentCoder<FileChooserSettings>::decode(Decoder& decoder, FileChooserSettings& settings)
{
if (!decoder.decode(settings.allowsMultipleFiles))
return false;
-#if ENABLE(DIRECTORY_UPLOAD)
- if (!decoder.decode(settings.allowsDirectoryUpload))
- return false;
-#endif
if (!decoder.decode(settings.acceptMIMETypes))
return false;
if (!decoder.decode(settings.selectedFiles))
return false;
#if ENABLE(MEDIA_CAPTURE)
- if (!decoder.decode(settings.capture))
+ if (!decoder.decodeEnum(settings.mediaCaptureType))
return false;
#endif
@@ -1102,7 +1539,7 @@ bool ArgumentCoder<FileChooserSettings>::decode(ArgumentDecoder& decoder, FileCh
}
-void ArgumentCoder<GrammarDetail>::encode(ArgumentEncoder& encoder, const GrammarDetail& detail)
+void ArgumentCoder<GrammarDetail>::encode(Encoder& encoder, const GrammarDetail& detail)
{
encoder << detail.location;
encoder << detail.length;
@@ -1110,7 +1547,7 @@ void ArgumentCoder<GrammarDetail>::encode(ArgumentEncoder& encoder, const Gramma
encoder << detail.userDescription;
}
-bool ArgumentCoder<GrammarDetail>::decode(ArgumentDecoder& decoder, GrammarDetail& detail)
+bool ArgumentCoder<GrammarDetail>::decode(Decoder& decoder, GrammarDetail& detail)
{
if (!decoder.decode(detail.location))
return false;
@@ -1124,7 +1561,7 @@ bool ArgumentCoder<GrammarDetail>::decode(ArgumentDecoder& decoder, GrammarDetai
return true;
}
-void ArgumentCoder<TextCheckingRequestData>::encode(ArgumentEncoder& encoder, const TextCheckingRequestData& request)
+void ArgumentCoder<TextCheckingRequestData>::encode(Encoder& encoder, const TextCheckingRequestData& request)
{
encoder << request.sequence();
encoder << request.text();
@@ -1132,7 +1569,7 @@ void ArgumentCoder<TextCheckingRequestData>::encode(ArgumentEncoder& encoder, co
encoder.encodeEnum(request.processType());
}
-bool ArgumentCoder<TextCheckingRequestData>::decode(ArgumentDecoder& decoder, TextCheckingRequestData& request)
+bool ArgumentCoder<TextCheckingRequestData>::decode(Decoder& decoder, TextCheckingRequestData& request)
{
int sequence;
if (!decoder.decode(sequence))
@@ -1154,7 +1591,7 @@ bool ArgumentCoder<TextCheckingRequestData>::decode(ArgumentDecoder& decoder, Te
return true;
}
-void ArgumentCoder<TextCheckingResult>::encode(ArgumentEncoder& encoder, const TextCheckingResult& result)
+void ArgumentCoder<TextCheckingResult>::encode(Encoder& encoder, const TextCheckingResult& result)
{
encoder.encodeEnum(result.type);
encoder << result.location;
@@ -1163,7 +1600,7 @@ void ArgumentCoder<TextCheckingResult>::encode(ArgumentEncoder& encoder, const T
encoder << result.replacement;
}
-bool ArgumentCoder<TextCheckingResult>::decode(ArgumentDecoder& decoder, TextCheckingResult& result)
+bool ArgumentCoder<TextCheckingResult>::decode(Decoder& decoder, TextCheckingResult& result)
{
if (!decoder.decodeEnum(result.type))
return false;
@@ -1178,39 +1615,21 @@ bool ArgumentCoder<TextCheckingResult>::decode(ArgumentDecoder& decoder, TextChe
return true;
}
-void ArgumentCoder<DragSession>::encode(ArgumentEncoder& encoder, const DragSession& result)
-{
- encoder.encodeEnum(result.operation);
- encoder << result.mouseIsOverFileInput;
- encoder << result.numberOfItemsToBeAccepted;
-}
-
-bool ArgumentCoder<DragSession>::decode(ArgumentDecoder& decoder, DragSession& result)
-{
- if (!decoder.decodeEnum(result.operation))
- return false;
- if (!decoder.decode(result.mouseIsOverFileInput))
- return false;
- if (!decoder.decode(result.numberOfItemsToBeAccepted))
- return false;
- return true;
-}
-
-void ArgumentCoder<URL>::encode(ArgumentEncoder& encoder, const URL& result)
+void ArgumentCoder<URL>::encode(Encoder& encoder, const URL& result)
{
encoder << result.string();
}
-bool ArgumentCoder<URL>::decode(ArgumentDecoder& decoder, URL& result)
+bool ArgumentCoder<URL>::decode(Decoder& decoder, URL& result)
{
String urlAsString;
if (!decoder.decode(urlAsString))
return false;
- result = URL(WebCore::ParsedURLString, urlAsString);
+ result = URL(ParsedURLString, urlAsString);
return true;
}
-void ArgumentCoder<WebCore::UserStyleSheet>::encode(ArgumentEncoder& encoder, const WebCore::UserStyleSheet& userStyleSheet)
+void ArgumentCoder<UserStyleSheet>::encode(Encoder& encoder, const UserStyleSheet& userStyleSheet)
{
encoder << userStyleSheet.source();
encoder << userStyleSheet.url();
@@ -1220,7 +1639,7 @@ void ArgumentCoder<WebCore::UserStyleSheet>::encode(ArgumentEncoder& encoder, co
encoder.encodeEnum(userStyleSheet.level());
}
-bool ArgumentCoder<WebCore::UserStyleSheet>::decode(ArgumentDecoder& decoder, WebCore::UserStyleSheet& userStyleSheet)
+bool ArgumentCoder<UserStyleSheet>::decode(Decoder& decoder, UserStyleSheet& userStyleSheet)
{
String source;
if (!decoder.decode(source))
@@ -1238,19 +1657,45 @@ bool ArgumentCoder<WebCore::UserStyleSheet>::decode(ArgumentDecoder& decoder, We
if (!decoder.decode(blacklist))
return false;
- WebCore::UserContentInjectedFrames injectedFrames;
+ UserContentInjectedFrames injectedFrames;
if (!decoder.decodeEnum(injectedFrames))
return false;
- WebCore::UserStyleLevel level;
+ UserStyleLevel level;
if (!decoder.decodeEnum(level))
return false;
- userStyleSheet = WebCore::UserStyleSheet(source, url, whitelist, blacklist, injectedFrames, level);
+ userStyleSheet = UserStyleSheet(source, url, WTFMove(whitelist), WTFMove(blacklist), injectedFrames, level);
return true;
}
-void ArgumentCoder<WebCore::UserScript>::encode(ArgumentEncoder& encoder, const WebCore::UserScript& userScript)
+#if ENABLE(MEDIA_SESSION)
+void ArgumentCoder<MediaSessionMetadata>::encode(Encoder& encoder, const MediaSessionMetadata& result)
+{
+ encoder << result.artist();
+ encoder << result.album();
+ encoder << result.title();
+ encoder << result.artworkURL();
+}
+
+bool ArgumentCoder<MediaSessionMetadata>::decode(Decoder& decoder, MediaSessionMetadata& result)
+{
+ String artist, album, title;
+ URL artworkURL;
+ if (!decoder.decode(artist))
+ return false;
+ if (!decoder.decode(album))
+ return false;
+ if (!decoder.decode(title))
+ return false;
+ if (!decoder.decode(artworkURL))
+ return false;
+ result = MediaSessionMetadata(title, artist, album, artworkURL);
+ return true;
+}
+#endif
+
+void ArgumentCoder<UserScript>::encode(Encoder& encoder, const UserScript& userScript)
{
encoder << userScript.source();
encoder << userScript.url();
@@ -1260,7 +1705,7 @@ void ArgumentCoder<WebCore::UserScript>::encode(ArgumentEncoder& encoder, const
encoder.encodeEnum(userScript.injectedFrames());
}
-bool ArgumentCoder<WebCore::UserScript>::decode(ArgumentDecoder& decoder, WebCore::UserScript& userScript)
+bool ArgumentCoder<UserScript>::decode(Decoder& decoder, UserScript& userScript)
{
String source;
if (!decoder.decode(source))
@@ -1278,19 +1723,19 @@ bool ArgumentCoder<WebCore::UserScript>::decode(ArgumentDecoder& decoder, WebCor
if (!decoder.decode(blacklist))
return false;
- WebCore::UserScriptInjectionTime injectionTime;
+ UserScriptInjectionTime injectionTime;
if (!decoder.decodeEnum(injectionTime))
return false;
- WebCore::UserContentInjectedFrames injectedFrames;
+ UserContentInjectedFrames injectedFrames;
if (!decoder.decodeEnum(injectedFrames))
return false;
- userScript = WebCore::UserScript(source, url, whitelist, blacklist, injectionTime, injectedFrames);
+ userScript = UserScript(source, url, WTFMove(whitelist), WTFMove(blacklist), injectionTime, injectedFrames);
return true;
}
-void ArgumentCoder<WebCore::ScrollableAreaParameters>::encode(ArgumentEncoder& encoder, const WebCore::ScrollableAreaParameters& parameters)
+void ArgumentCoder<ScrollableAreaParameters>::encode(Encoder& encoder, const ScrollableAreaParameters& parameters)
{
encoder.encodeEnum(parameters.horizontalScrollElasticity);
encoder.encodeEnum(parameters.verticalScrollElasticity);
@@ -1302,7 +1747,7 @@ void ArgumentCoder<WebCore::ScrollableAreaParameters>::encode(ArgumentEncoder& e
encoder << parameters.hasEnabledVerticalScrollbar;
}
-bool ArgumentCoder<WebCore::ScrollableAreaParameters>::decode(ArgumentDecoder& decoder, WebCore::ScrollableAreaParameters& params)
+bool ArgumentCoder<ScrollableAreaParameters>::decode(Decoder& decoder, ScrollableAreaParameters& params)
{
if (!decoder.decodeEnum(params.horizontalScrollElasticity))
return false;
@@ -1322,7 +1767,7 @@ bool ArgumentCoder<WebCore::ScrollableAreaParameters>::decode(ArgumentDecoder& d
return true;
}
-void ArgumentCoder<WebCore::FixedPositionViewportConstraints>::encode(ArgumentEncoder& encoder, const WebCore::FixedPositionViewportConstraints& viewportConstraints)
+void ArgumentCoder<FixedPositionViewportConstraints>::encode(Encoder& encoder, const FixedPositionViewportConstraints& viewportConstraints)
{
encoder << viewportConstraints.alignmentOffset();
encoder << viewportConstraints.anchorEdges();
@@ -1331,7 +1776,7 @@ void ArgumentCoder<WebCore::FixedPositionViewportConstraints>::encode(ArgumentEn
encoder << viewportConstraints.layerPositionAtLastLayout();
}
-bool ArgumentCoder<WebCore::FixedPositionViewportConstraints>::decode(ArgumentDecoder& decoder, WebCore::FixedPositionViewportConstraints& viewportConstraints)
+bool ArgumentCoder<FixedPositionViewportConstraints>::decode(Decoder& decoder, FixedPositionViewportConstraints& viewportConstraints)
{
FloatSize alignmentOffset;
if (!decoder.decode(alignmentOffset))
@@ -1349,7 +1794,7 @@ bool ArgumentCoder<WebCore::FixedPositionViewportConstraints>::decode(ArgumentDe
if (!decoder.decode(layerPositionAtLastLayout))
return false;
- viewportConstraints = WebCore::FixedPositionViewportConstraints();
+ viewportConstraints = FixedPositionViewportConstraints();
viewportConstraints.setAlignmentOffset(alignmentOffset);
viewportConstraints.setAnchorEdges(anchorEdges);
@@ -1359,7 +1804,7 @@ bool ArgumentCoder<WebCore::FixedPositionViewportConstraints>::decode(ArgumentDe
return true;
}
-void ArgumentCoder<WebCore::StickyPositionViewportConstraints>::encode(ArgumentEncoder& encoder, const WebCore::StickyPositionViewportConstraints& viewportConstraints)
+void ArgumentCoder<StickyPositionViewportConstraints>::encode(Encoder& encoder, const StickyPositionViewportConstraints& viewportConstraints)
{
encoder << viewportConstraints.alignmentOffset();
encoder << viewportConstraints.anchorEdges();
@@ -1377,7 +1822,7 @@ void ArgumentCoder<WebCore::StickyPositionViewportConstraints>::encode(ArgumentE
encoder << viewportConstraints.layerPositionAtLastLayout();
}
-bool ArgumentCoder<WebCore::StickyPositionViewportConstraints>::decode(ArgumentDecoder& decoder, WebCore::StickyPositionViewportConstraints& viewportConstraints)
+bool ArgumentCoder<StickyPositionViewportConstraints>::decode(Decoder& decoder, StickyPositionViewportConstraints& viewportConstraints)
{
FloatSize alignmentOffset;
if (!decoder.decode(alignmentOffset))
@@ -1423,7 +1868,7 @@ bool ArgumentCoder<WebCore::StickyPositionViewportConstraints>::decode(ArgumentD
if (!decoder.decode(layerPositionAtLastLayout))
return false;
- viewportConstraints = WebCore::StickyPositionViewportConstraints();
+ viewportConstraints = StickyPositionViewportConstraints();
viewportConstraints.setAlignmentOffset(alignmentOffset);
viewportConstraints.setAnchorEdges(anchorEdges);
@@ -1442,63 +1887,58 @@ bool ArgumentCoder<WebCore::StickyPositionViewportConstraints>::decode(ArgumentD
return true;
}
-#if ENABLE(CSS_FILTERS) && !USE(COORDINATED_GRAPHICS)
-static void encodeFilterOperation(ArgumentEncoder& encoder, const FilterOperation& filter)
+#if !USE(COORDINATED_GRAPHICS)
+void ArgumentCoder<FilterOperation>::encode(Encoder& encoder, const FilterOperation& filter)
{
encoder.encodeEnum(filter.type());
switch (filter.type()) {
- case FilterOperation::REFERENCE: {
- const auto& referenceFilter = static_cast<const ReferenceFilterOperation&>(filter);
- encoder << referenceFilter.url();
- encoder << referenceFilter.fragment();
+ case FilterOperation::NONE:
+ case FilterOperation::REFERENCE:
+ ASSERT_NOT_REACHED();
break;
- }
case FilterOperation::GRAYSCALE:
case FilterOperation::SEPIA:
case FilterOperation::SATURATE:
case FilterOperation::HUE_ROTATE:
- encoder << static_cast<const BasicColorMatrixFilterOperation&>(filter).amount();
+ encoder << downcast<BasicColorMatrixFilterOperation>(filter).amount();
break;
case FilterOperation::INVERT:
case FilterOperation::OPACITY:
case FilterOperation::BRIGHTNESS:
case FilterOperation::CONTRAST:
- encoder << static_cast<const BasicComponentTransferFilterOperation&>(filter).amount();
+ encoder << downcast<BasicComponentTransferFilterOperation>(filter).amount();
break;
case FilterOperation::BLUR:
- encoder << static_cast<const BlurFilterOperation&>(filter).stdDeviation();
+ encoder << downcast<BlurFilterOperation>(filter).stdDeviation();
break;
case FilterOperation::DROP_SHADOW: {
- const auto& dropShadowFilter = static_cast<const DropShadowFilterOperation&>(filter);
+ const auto& dropShadowFilter = downcast<DropShadowFilterOperation>(filter);
encoder << dropShadowFilter.location();
encoder << dropShadowFilter.stdDeviation();
encoder << dropShadowFilter.color();
break;
}
+ case FilterOperation::DEFAULT:
+ encoder.encodeEnum(downcast<DefaultFilterOperation>(filter).representedType());
+ break;
case FilterOperation::PASSTHROUGH:
- case FilterOperation::NONE:
break;
- };
+ }
}
-static bool decodeFilterOperation(ArgumentDecoder& decoder, RefPtr<FilterOperation>& filter)
+bool decodeFilterOperation(Decoder& decoder, RefPtr<FilterOperation>& filter)
{
FilterOperation::OperationType type;
if (!decoder.decodeEnum(type))
return false;
switch (type) {
- case FilterOperation::REFERENCE: {
- String url;
- String fragment;
- if (!decoder.decode(url))
- return false;
- if (!decoder.decode(fragment))
- return false;
- filter = ReferenceFilterOperation::create(url, fragment, type);
- break;
- }
+ case FilterOperation::NONE:
+ case FilterOperation::REFERENCE:
+ ASSERT_NOT_REACHED();
+ decoder.markInvalid();
+ return false;
case FilterOperation::GRAYSCALE:
case FilterOperation::SEPIA:
case FilterOperation::SATURATE:
@@ -1523,7 +1963,7 @@ static bool decodeFilterOperation(ArgumentDecoder& decoder, RefPtr<FilterOperati
Length stdDeviation;
if (!decoder.decode(stdDeviation))
return false;
- filter = BlurFilterOperation::create(stdDeviation, type);
+ filter = BlurFilterOperation::create(stdDeviation);
break;
}
case FilterOperation::DROP_SHADOW: {
@@ -1536,27 +1976,34 @@ static bool decodeFilterOperation(ArgumentDecoder& decoder, RefPtr<FilterOperati
return false;
if (!decoder.decode(color))
return false;
- filter = DropShadowFilterOperation::create(location, stdDeviation, color, type);
+ filter = DropShadowFilterOperation::create(location, stdDeviation, color);
+ break;
+ }
+ case FilterOperation::DEFAULT: {
+ FilterOperation::OperationType representedType;
+ if (!decoder.decodeEnum(representedType))
+ return false;
+ filter = DefaultFilterOperation::create(representedType);
break;
}
case FilterOperation::PASSTHROUGH:
- case FilterOperation::NONE:
+ filter = PassthroughFilterOperation::create();
break;
- };
-
+ }
+
return true;
}
-void ArgumentCoder<FilterOperations>::encode(ArgumentEncoder& encoder, const FilterOperations& filters)
+void ArgumentCoder<FilterOperations>::encode(Encoder& encoder, const FilterOperations& filters)
{
encoder << static_cast<uint64_t>(filters.size());
for (const auto& filter : filters.operations())
- encodeFilterOperation(encoder, *filter);
+ encoder << *filter;
}
-bool ArgumentCoder<FilterOperations>::decode(ArgumentDecoder& decoder, FilterOperations& filters)
+bool ArgumentCoder<FilterOperations>::decode(Decoder& decoder, FilterOperations& filters)
{
uint64_t filterCount;
if (!decoder.decode(filterCount))
@@ -1566,271 +2013,505 @@ bool ArgumentCoder<FilterOperations>::decode(ArgumentDecoder& decoder, FilterOpe
RefPtr<FilterOperation> filter;
if (!decodeFilterOperation(decoder, filter))
return false;
- filters.operations().append(std::move(filter));
+ filters.operations().append(WTFMove(filter));
}
return true;
}
-#endif // ENABLE(CSS_FILTERS) && !USE(COORDINATED_GRAPHICS)
+#endif // !USE(COORDINATED_GRAPHICS)
-#if ENABLE(INDEXED_DATABASE)
-void ArgumentCoder<IDBDatabaseMetadata>::encode(ArgumentEncoder& encoder, const IDBDatabaseMetadata& metadata)
+void ArgumentCoder<SessionID>::encode(Encoder& encoder, const SessionID& sessionID)
{
- encoder << metadata.name << metadata.id << metadata.version << metadata.maxObjectStoreId << metadata.objectStores;
+ encoder << sessionID.sessionID();
}
-bool ArgumentCoder<IDBDatabaseMetadata>::decode(ArgumentDecoder& decoder, IDBDatabaseMetadata& metadata)
+bool ArgumentCoder<SessionID>::decode(Decoder& decoder, SessionID& sessionID)
{
- if (!decoder.decode(metadata.name))
+ uint64_t session;
+ if (!decoder.decode(session))
return false;
- if (!decoder.decode(metadata.id))
- return false;
+ sessionID = SessionID(session);
- if (!decoder.decode(metadata.version))
- return false;
+ return true;
+}
+
+void ArgumentCoder<BlobPart>::encode(Encoder& encoder, const BlobPart& blobPart)
+{
+ encoder << static_cast<uint32_t>(blobPart.type());
+ switch (blobPart.type()) {
+ case BlobPart::Data:
+ encoder << blobPart.data();
+ break;
+ case BlobPart::Blob:
+ encoder << blobPart.url();
+ break;
+ }
+}
- if (!decoder.decode(metadata.maxObjectStoreId))
+bool ArgumentCoder<BlobPart>::decode(Decoder& decoder, BlobPart& blobPart)
+{
+ uint32_t type;
+ if (!decoder.decode(type))
return false;
- if (!decoder.decode(metadata.objectStores))
+ switch (type) {
+ case BlobPart::Data: {
+ Vector<uint8_t> data;
+ if (!decoder.decode(data))
+ return false;
+ blobPart = BlobPart(WTFMove(data));
+ break;
+ }
+ case BlobPart::Blob: {
+ URL url;
+ if (!decoder.decode(url))
+ return false;
+ blobPart = BlobPart(url);
+ break;
+ }
+ default:
return false;
+ }
return true;
}
-void ArgumentCoder<IDBIndexMetadata>::encode(ArgumentEncoder& encoder, const IDBIndexMetadata& metadata)
+void ArgumentCoder<TextIndicatorData>::encode(Encoder& encoder, const TextIndicatorData& textIndicatorData)
{
- encoder << metadata.name << metadata.id << metadata.keyPath << metadata.unique << metadata.multiEntry;
+ encoder << textIndicatorData.selectionRectInRootViewCoordinates;
+ encoder << textIndicatorData.textBoundingRectInRootViewCoordinates;
+ encoder << textIndicatorData.textRectsInBoundingRectCoordinates;
+ encoder << textIndicatorData.contentImageScaleFactor;
+ encoder.encodeEnum(textIndicatorData.presentationTransition);
+ encoder << static_cast<uint64_t>(textIndicatorData.options);
+
+ encodeOptionalImage(encoder, textIndicatorData.contentImage.get());
+ encodeOptionalImage(encoder, textIndicatorData.contentImageWithHighlight.get());
}
-bool ArgumentCoder<IDBIndexMetadata>::decode(ArgumentDecoder& decoder, IDBIndexMetadata& metadata)
+bool ArgumentCoder<TextIndicatorData>::decode(Decoder& decoder, TextIndicatorData& textIndicatorData)
{
- if (!decoder.decode(metadata.name))
+ if (!decoder.decode(textIndicatorData.selectionRectInRootViewCoordinates))
+ return false;
+
+ if (!decoder.decode(textIndicatorData.textBoundingRectInRootViewCoordinates))
+ return false;
+
+ if (!decoder.decode(textIndicatorData.textRectsInBoundingRectCoordinates))
return false;
- if (!decoder.decode(metadata.id))
+ if (!decoder.decode(textIndicatorData.contentImageScaleFactor))
return false;
- if (!decoder.decode(metadata.keyPath))
+ if (!decoder.decodeEnum(textIndicatorData.presentationTransition))
return false;
- if (!decoder.decode(metadata.unique))
+ uint64_t options;
+ if (!decoder.decode(options))
return false;
+ textIndicatorData.options = static_cast<TextIndicatorOptions>(options);
- if (!decoder.decode(metadata.multiEntry))
+ if (!decodeOptionalImage(decoder, textIndicatorData.contentImage))
+ return false;
+
+ if (!decodeOptionalImage(decoder, textIndicatorData.contentImageWithHighlight))
return false;
return true;
}
-void ArgumentCoder<IDBGetResult>::encode(ArgumentEncoder& encoder, const IDBGetResult& result)
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+void ArgumentCoder<MediaPlaybackTargetContext>::encode(Encoder& encoder, const MediaPlaybackTargetContext& target)
{
- bool nullData = !result.valueBuffer;
- encoder << nullData;
+ bool hasPlatformData = target.encodingRequiresPlatformData();
+ encoder << hasPlatformData;
+
+ int32_t targetType = target.type();
+ encoder << targetType;
- if (!nullData)
- encoder << DataReference(reinterpret_cast<const uint8_t*>(result.valueBuffer->data()), result.valueBuffer->size());
+ if (target.encodingRequiresPlatformData()) {
+ encodePlatformData(encoder, target);
+ return;
+ }
- encoder << result.keyData << result.keyPath;
+ ASSERT(targetType == MediaPlaybackTargetContext::MockType);
+ encoder << target.mockDeviceName();
+ encoder << static_cast<int32_t>(target.mockState());
}
-bool ArgumentCoder<IDBGetResult>::decode(ArgumentDecoder& decoder, IDBGetResult& result)
+bool ArgumentCoder<MediaPlaybackTargetContext>::decode(Decoder& decoder, MediaPlaybackTargetContext& target)
{
- bool nullData;
- if (!decoder.decode(nullData))
+ bool hasPlatformData;
+ if (!decoder.decode(hasPlatformData))
return false;
- if (nullData)
- result.valueBuffer = nullptr;
- else {
- DataReference data;
- if (!decoder.decode(data))
- return false;
+ int32_t targetType;
+ if (!decoder.decode(targetType))
+ return false;
- result.valueBuffer = SharedBuffer::create(data.data(), data.size());
- }
+ if (hasPlatformData)
+ return decodePlatformData(decoder, target);
+
+ ASSERT(targetType == MediaPlaybackTargetContext::MockType);
- if (!decoder.decode(result.keyData))
+ String mockDeviceName;
+ if (!decoder.decode(mockDeviceName))
return false;
- if (!decoder.decode(result.keyPath))
+ int32_t mockState;
+ if (!decoder.decode(mockState))
return false;
+ target = MediaPlaybackTargetContext(mockDeviceName, static_cast<MediaPlaybackTargetContext::State>(mockState));
return true;
}
+#endif
-void ArgumentCoder<IDBKeyData>::encode(ArgumentEncoder& encoder, const IDBKeyData& keyData)
+void ArgumentCoder<DictionaryPopupInfo>::encode(IPC::Encoder& encoder, const DictionaryPopupInfo& info)
{
- encoder << keyData.isNull;
- if (keyData.isNull)
- return;
+ encoder << info.origin;
+ encoder << info.textIndicator;
- encoder.encodeEnum(keyData.type);
+#if PLATFORM(COCOA)
+ bool hadOptions = info.options;
+ encoder << hadOptions;
+ if (hadOptions)
+ IPC::encode(encoder, info.options.get());
- switch (keyData.type) {
- case IDBKey::InvalidType:
- break;
- case IDBKey::ArrayType:
- encoder << keyData.arrayValue;
- break;
- case IDBKey::StringType:
- encoder << keyData.stringValue;
- break;
- case IDBKey::DateType:
- case IDBKey::NumberType:
- encoder << keyData.numberValue;
- break;
- case IDBKey::MinType:
- ASSERT_NOT_REACHED();
- break;
- }
+ bool hadAttributedString = info.attributedString;
+ encoder << hadAttributedString;
+ if (hadAttributedString)
+ IPC::encode(encoder, info.attributedString.get());
+#endif
}
-bool ArgumentCoder<IDBKeyData>::decode(ArgumentDecoder& decoder, IDBKeyData& keyData)
+bool ArgumentCoder<DictionaryPopupInfo>::decode(IPC::Decoder& decoder, DictionaryPopupInfo& result)
{
- if (!decoder.decode(keyData.isNull))
+ if (!decoder.decode(result.origin))
return false;
- if (keyData.isNull)
- return true;
-
- if (!decoder.decodeEnum(keyData.type))
+ if (!decoder.decode(result.textIndicator))
return false;
- switch (keyData.type) {
- case IDBKey::InvalidType:
- break;
- case IDBKey::ArrayType:
- if (!decoder.decode(keyData.arrayValue))
- return false;
- break;
- case IDBKey::StringType:
- if (!decoder.decode(keyData.stringValue))
+#if PLATFORM(COCOA)
+ bool hadOptions;
+ if (!decoder.decode(hadOptions))
+ return false;
+ if (hadOptions) {
+ if (!IPC::decode(decoder, result.options))
return false;
- break;
- case IDBKey::DateType:
- case IDBKey::NumberType:
- if (!decoder.decode(keyData.numberValue))
+ } else
+ result.options = nullptr;
+
+ bool hadAttributedString;
+ if (!decoder.decode(hadAttributedString))
+ return false;
+ if (hadAttributedString) {
+ if (!IPC::decode(decoder, result.attributedString))
return false;
- break;
- case IDBKey::MinType:
- ASSERT_NOT_REACHED();
+ } else
+ result.attributedString = nullptr;
+#endif
+ return true;
+}
+
+void ArgumentCoder<ExceptionDetails>::encode(IPC::Encoder& encoder, const ExceptionDetails& info)
+{
+ encoder << info.message;
+ encoder << info.lineNumber;
+ encoder << info.columnNumber;
+ encoder << info.sourceURL;
+}
+
+bool ArgumentCoder<ExceptionDetails>::decode(IPC::Decoder& decoder, ExceptionDetails& result)
+{
+ if (!decoder.decode(result.message))
+ return false;
+
+ if (!decoder.decode(result.lineNumber))
+ return false;
+
+ if (!decoder.decode(result.columnNumber))
+ return false;
+
+ if (!decoder.decode(result.sourceURL))
return false;
- }
return true;
}
-void ArgumentCoder<IDBKeyPath>::encode(ArgumentEncoder& encoder, const IDBKeyPath& keyPath)
+void ArgumentCoder<ResourceLoadStatistics>::encode(Encoder& encoder, const WebCore::ResourceLoadStatistics& statistics)
{
- encoder.encodeEnum(keyPath.type());
-
- switch (keyPath.type()) {
- case IDBKeyPath::NullType:
- break;
- case IDBKeyPath::StringType:
- encoder << keyPath.string();
- break;
- case IDBKeyPath::ArrayType:
- encoder << keyPath.array();
- break;
- default:
- ASSERT_NOT_REACHED();
- }
+ encoder << statistics.highLevelDomain;
+
+ // User interaction
+ encoder << statistics.hadUserInteraction;
+ encoder << statistics.mostRecentUserInteraction;
+ encoder << statistics.grandfathered;
+
+ // Top frame stats
+ encoder << statistics.topFrameHasBeenNavigatedToBefore;
+ encoder << statistics.topFrameHasBeenRedirectedTo;
+ encoder << statistics.topFrameHasBeenRedirectedFrom;
+ encoder << statistics.topFrameInitialLoadCount;
+ encoder << statistics.topFrameHasBeenNavigatedTo;
+ encoder << statistics.topFrameHasBeenNavigatedFrom;
+
+ // Subframe stats
+ encoder << statistics.subframeHasBeenLoadedBefore;
+ encoder << statistics.subframeHasBeenRedirectedTo;
+ encoder << statistics.subframeHasBeenRedirectedFrom;
+ encoder << statistics.subframeSubResourceCount;
+ encoder << statistics.subframeUnderTopFrameOrigins;
+ encoder << statistics.subframeUniqueRedirectsTo;
+ encoder << statistics.subframeHasBeenNavigatedTo;
+ encoder << statistics.subframeHasBeenNavigatedFrom;
+
+ // Subresource stats
+ encoder << statistics.subresourceHasBeenRedirectedFrom;
+ encoder << statistics.subresourceHasBeenRedirectedTo;
+ encoder << statistics.subresourceHasBeenSubresourceCount;
+ encoder << statistics.subresourceHasBeenSubresourceCountDividedByTotalNumberOfOriginsVisited;
+ encoder << statistics.subresourceUnderTopFrameOrigins;
+ encoder << statistics.subresourceUniqueRedirectsTo;
+
+ // Prevalent Resource
+ encoder << statistics.redirectedToOtherPrevalentResourceOrigins;
+ encoder << statistics.isPrevalentResource;
+ encoder << statistics.dataRecordsRemoved;
}
-bool ArgumentCoder<IDBKeyPath>::decode(ArgumentDecoder& decoder, IDBKeyPath& keyPath)
+bool ArgumentCoder<ResourceLoadStatistics>::decode(Decoder& decoder, WebCore::ResourceLoadStatistics& statistics)
{
- IDBKeyPath::Type type;
- if (!decoder.decodeEnum(type))
+ if (!decoder.decode(statistics.highLevelDomain))
+ return false;
+
+ // User interaction
+ if (!decoder.decode(statistics.hadUserInteraction))
return false;
- switch (type) {
- case IDBKeyPath::NullType:
- keyPath = IDBKeyPath();
- return true;
+ if (!decoder.decode(statistics.mostRecentUserInteraction))
+ return false;
- case IDBKeyPath::StringType: {
- String string;
- if (!decoder.decode(string))
- return false;
+ if (!decoder.decode(statistics.grandfathered))
+ return false;
+
+ // Top frame stats
+ if (!decoder.decode(statistics.topFrameHasBeenNavigatedToBefore))
+ return false;
+
+ if (!decoder.decode(statistics.topFrameHasBeenRedirectedTo))
+ return false;
+
+ if (!decoder.decode(statistics.topFrameHasBeenRedirectedFrom))
+ return false;
+
+ if (!decoder.decode(statistics.topFrameInitialLoadCount))
+ return false;
+
+ if (!decoder.decode(statistics.topFrameHasBeenNavigatedTo))
+ return false;
+
+ if (!decoder.decode(statistics.topFrameHasBeenNavigatedFrom))
+ return false;
+
+ // Subframe stats
+ if (!decoder.decode(statistics.subframeHasBeenLoadedBefore))
+ return false;
+
+ if (!decoder.decode(statistics.subframeHasBeenRedirectedTo))
+ return false;
+
+ if (!decoder.decode(statistics.subframeHasBeenRedirectedFrom))
+ return false;
+
+ if (!decoder.decode(statistics.subframeSubResourceCount))
+ return false;
+
+ if (!decoder.decode(statistics.subframeUnderTopFrameOrigins))
+ return false;
- keyPath = IDBKeyPath(string);
- return true;
- }
- case IDBKeyPath::ArrayType: {
- Vector<String> array;
- if (!decoder.decode(array))
- return false;
+ if (!decoder.decode(statistics.subframeUniqueRedirectsTo))
+ return false;
+
+ if (!decoder.decode(statistics.subframeHasBeenNavigatedTo))
+ return false;
+
+ if (!decoder.decode(statistics.subframeHasBeenNavigatedFrom))
+ return false;
+
+ // Subresource stats
+ if (!decoder.decode(statistics.subresourceHasBeenRedirectedFrom))
+ return false;
+
+ if (!decoder.decode(statistics.subresourceHasBeenRedirectedTo))
+ return false;
+
+ if (!decoder.decode(statistics.subresourceHasBeenSubresourceCount))
+ return false;
+
+ if (!decoder.decode(statistics.subresourceHasBeenSubresourceCountDividedByTotalNumberOfOriginsVisited))
+ return false;
+
+ if (!decoder.decode(statistics.subresourceUnderTopFrameOrigins))
+ return false;
- keyPath = IDBKeyPath(array);
- return true;
- }
- default:
+ if (!decoder.decode(statistics.subresourceUniqueRedirectsTo))
return false;
- }
+
+ // Prevalent Resource
+ if (!decoder.decode(statistics.redirectedToOtherPrevalentResourceOrigins))
+ return false;
+
+ if (!decoder.decode(statistics.isPrevalentResource))
+ return false;
+
+ if (!decoder.decode(statistics.dataRecordsRemoved))
+ return false;
+
+ return true;
}
-void ArgumentCoder<IDBKeyRangeData>::encode(ArgumentEncoder& encoder, const IDBKeyRangeData& keyRange)
+#if ENABLE(MEDIA_STREAM)
+void ArgumentCoder<MediaConstraintsData>::encode(Encoder& encoder, const WebCore::MediaConstraintsData& constraint)
{
- encoder << keyRange.isNull;
- if (keyRange.isNull)
- return;
+ encoder << constraint.mandatoryConstraints;
+
+ auto& advancedConstraints = constraint.advancedConstraints;
+ encoder << static_cast<uint64_t>(advancedConstraints.size());
+ for (const auto& advancedConstraint : advancedConstraints)
+ encoder << advancedConstraint;
- encoder << keyRange.upperKey << keyRange.lowerKey << keyRange.upperOpen << keyRange.lowerOpen;
+ encoder << constraint.isValid;
}
-bool ArgumentCoder<IDBKeyRangeData>::decode(ArgumentDecoder& decoder, IDBKeyRangeData& keyRange)
+bool ArgumentCoder<MediaConstraintsData>::decode(Decoder& decoder, WebCore::MediaConstraintsData& constraints)
{
- if (!decoder.decode(keyRange.isNull))
+ MediaTrackConstraintSetMap mandatoryConstraints;
+ if (!decoder.decode(mandatoryConstraints))
return false;
- if (keyRange.isNull)
- return true;
-
- if (!decoder.decode(keyRange.upperKey))
+ uint64_t advancedCount;
+ if (!decoder.decode(advancedCount))
return false;
- if (!decoder.decode(keyRange.lowerKey))
- return false;
+ Vector<MediaTrackConstraintSetMap> advancedConstraints;
+ advancedConstraints.reserveInitialCapacity(advancedCount);
+ for (size_t i = 0; i < advancedCount; ++i) {
+ MediaTrackConstraintSetMap map;
+ if (!decoder.decode(map))
+ return false;
- if (!decoder.decode(keyRange.upperOpen))
- return false;
+ advancedConstraints.uncheckedAppend(WTFMove(map));
+ }
- if (!decoder.decode(keyRange.lowerOpen))
+ bool isValid;
+ if (!decoder.decode(isValid))
return false;
+ constraints.mandatoryConstraints = WTFMove(mandatoryConstraints);
+ constraints.advancedConstraints = WTFMove(advancedConstraints);
+ constraints.isValid = isValid;
+
return true;
}
-void ArgumentCoder<IDBObjectStoreMetadata>::encode(ArgumentEncoder& encoder, const IDBObjectStoreMetadata& metadata)
+void ArgumentCoder<CaptureDevice>::encode(Encoder& encoder, const WebCore::CaptureDevice& device)
{
- encoder << metadata.name << metadata.id << metadata.keyPath << metadata.autoIncrement << metadata.maxIndexId << metadata.indexes;
+ encoder << device.persistentId();
+ encoder << device.label();
+ encoder << device.groupId();
+ encoder << device.enabled();
+ encoder.encodeEnum(device.type());
}
-bool ArgumentCoder<IDBObjectStoreMetadata>::decode(ArgumentDecoder& decoder, IDBObjectStoreMetadata& metadata)
+bool ArgumentCoder<CaptureDevice>::decode(Decoder& decoder, WebCore::CaptureDevice& device)
{
- if (!decoder.decode(metadata.name))
+ String persistentId;
+ if (!decoder.decode(persistentId))
+ return false;
+
+ String label;
+ if (!decoder.decode(label))
+ return false;
+
+ String groupId;
+ if (!decoder.decode(groupId))
return false;
- if (!decoder.decode(metadata.id))
+ bool enabled;
+ if (!decoder.decode(enabled))
return false;
- if (!decoder.decode(metadata.keyPath))
+ CaptureDevice::DeviceType type;
+ if (!decoder.decodeEnum(type))
return false;
- if (!decoder.decode(metadata.autoIncrement))
+ device.setPersistentId(persistentId);
+ device.setLabel(label);
+ device.setGroupId(groupId);
+ device.setType(type);
+ device.setEnabled(enabled);
+
+ return true;
+}
+#endif
+
+#if ENABLE(INDEXED_DATABASE)
+void ArgumentCoder<IDBKeyPath>::encode(Encoder& encoder, const IDBKeyPath& keyPath)
+{
+ bool isString = WTF::holds_alternative<String>(keyPath);
+ encoder << isString;
+ if (isString)
+ encoder << WTF::get<String>(keyPath);
+ else
+ encoder << WTF::get<Vector<String>>(keyPath);
+}
+
+bool ArgumentCoder<IDBKeyPath>::decode(Decoder& decoder, IDBKeyPath& keyPath)
+{
+ bool isString;
+ if (!decoder.decode(isString))
return false;
+ if (isString) {
+ String string;
+ if (!decoder.decode(string))
+ return false;
+ keyPath = string;
+ } else {
+ Vector<String> vector;
+ if (!decoder.decode(vector))
+ return false;
+ keyPath = vector;
+ }
+ return true;
+}
+#endif
+
+#if ENABLE(CSS_SCROLL_SNAP)
- if (!decoder.decode(metadata.maxIndexId))
+void ArgumentCoder<ScrollOffsetRange<float>>::encode(Encoder& encoder, const ScrollOffsetRange<float>& range)
+{
+ encoder << range.start;
+ encoder << range.end;
+}
+
+bool ArgumentCoder<ScrollOffsetRange<float>>::decode(Decoder& decoder, ScrollOffsetRange<float>& range)
+{
+ float start;
+ if (!decoder.decode(start))
return false;
- if (!decoder.decode(metadata.indexes))
+ float end;
+ if (!decoder.decode(end))
return false;
+ range.start = start;
+ range.end = end;
return true;
}
+
#endif
} // namespace IPC
diff --git a/Source/WebKit2/Shared/WebCoreArgumentCoders.h b/Source/WebKit2/Shared/WebCoreArgumentCoders.h
index a256e3b53..eab131c88 100644
--- a/Source/WebKit2/Shared/WebCoreArgumentCoders.h
+++ b/Source/WebKit2/Shared/WebCoreArgumentCoders.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -23,67 +23,89 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef WebCoreArgumentCoders_h
-#define WebCoreArgumentCoders_h
+#pragma once
#include "ArgumentCoders.h"
+#include <WebCore/ColorSpace.h>
+#include <WebCore/DiagnosticLoggingClient.h>
+#include <WebCore/FrameLoaderTypes.h>
+#include <WebCore/IndexedDB.h>
+#include <WebCore/PaymentHeaders.h>
+#include <WebCore/ScrollSnapOffsetsInfo.h>
+
+namespace WTF {
+class MonotonicTime;
+class Seconds;
+}
namespace WebCore {
class AffineTransform;
class AuthenticationChallenge;
+class BlobPart;
class CertificateInfo;
class Color;
class Credential;
+class CubicBezierTimingFunction;
class Cursor;
class DatabaseDetails;
+class DragData;
+class FilterOperation;
class FilterOperations;
class FloatPoint;
class FloatPoint3D;
class FloatRect;
+class FloatRoundedRect;
class FloatSize;
class FixedPositionViewportConstraints;
class HTTPHeaderMap;
-class IDBKeyPath;
class IntPoint;
class IntRect;
class IntSize;
class KeyframeValueList;
-class URL;
+class LayoutSize;
+class LayoutPoint;
+class LinearTimingFunction;
class Notification;
+class Path;
class ProtectionSpace;
+class Region;
class ResourceError;
class ResourceRequest;
class ResourceResponse;
+class SessionID;
+class SpringTimingFunction;
+class StepsTimingFunction;
class StickyPositionViewportConstraints;
class TextCheckingRequestData;
class TransformationMatrix;
class UserStyleSheet;
class UserScript;
+class URL;
struct CompositionUnderline;
struct Cookie;
struct DictationAlternative;
-struct DragSession;
+struct DictionaryPopupInfo;
+struct EventTrackingRegions;
+struct ExceptionDetails;
struct FileChooserSettings;
-struct IDBDatabaseMetadata;
-struct IDBGetResult;
-struct IDBIndexMetadata;
-struct IDBKeyData;
-struct IDBKeyRangeData;
-struct IDBObjectStoreMetadata;
struct Length;
struct GrammarDetail;
struct MimeClassInfo;
struct PasteboardImage;
struct PasteboardWebContent;
struct PluginInfo;
+struct RecentSearch;
+struct ResourceLoadStatistics;
struct ScrollableAreaParameters;
struct TextCheckingResult;
+struct TextIndicatorData;
struct ViewportAttributes;
struct WindowFeatures;
}
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
namespace WebCore {
+class MachSendRight;
struct KeypressCommand;
}
#endif
@@ -92,307 +114,553 @@ struct KeypressCommand;
namespace WebCore {
class FloatQuad;
class SelectionRect;
+struct Highlight;
struct PasteboardImage;
struct PasteboardWebContent;
struct ViewportArguments;
}
#endif
+#if USE(SOUP)
+namespace WebCore {
+struct SoupNetworkProxySettings;
+}
+#endif
+
+#if ENABLE(CONTENT_FILTERING)
+namespace WebCore {
+class ContentFilterUnblockHandler;
+}
+#endif
+
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+namespace WebCore {
+class MediaPlaybackTargetContext;
+}
+#endif
+
+#if ENABLE(MEDIA_SESSION)
+namespace WebCore {
+class MediaSessionMetadata;
+}
+#endif
+
+#if ENABLE(MEDIA_STREAM)
+namespace WebCore {
+class CaptureDevice;
+struct MediaConstraintsData;
+}
+#endif
+
+#if ENABLE(INDEXED_DATABASE)
+namespace WebCore {
+using IDBKeyPath = Variant<String, Vector<String>>;
+}
+#endif
+
namespace IPC {
+template<> struct ArgumentCoder<WTF::MonotonicTime> {
+ static void encode(Encoder&, const WTF::MonotonicTime&);
+ static bool decode(Decoder&, WTF::MonotonicTime&);
+};
+
+template<> struct ArgumentCoder<WTF::Seconds> {
+ static void encode(Encoder&, const WTF::Seconds&);
+ static bool decode(Decoder&, WTF::Seconds&);
+};
+
template<> struct ArgumentCoder<WebCore::AffineTransform> {
- static void encode(ArgumentEncoder&, const WebCore::AffineTransform&);
- static bool decode(ArgumentDecoder&, WebCore::AffineTransform&);
+ static void encode(Encoder&, const WebCore::AffineTransform&);
+ static bool decode(Decoder&, WebCore::AffineTransform&);
+};
+
+template<> struct ArgumentCoder<WebCore::EventTrackingRegions> {
+ static void encode(Encoder&, const WebCore::EventTrackingRegions&);
+ static bool decode(Decoder&, WebCore::EventTrackingRegions&);
};
template<> struct ArgumentCoder<WebCore::TransformationMatrix> {
- static void encode(ArgumentEncoder&, const WebCore::TransformationMatrix&);
- static bool decode(ArgumentDecoder&, WebCore::TransformationMatrix&);
+ static void encode(Encoder&, const WebCore::TransformationMatrix&);
+ static bool decode(Decoder&, WebCore::TransformationMatrix&);
+};
+
+template<> struct ArgumentCoder<WebCore::LinearTimingFunction> {
+ static void encode(Encoder&, const WebCore::LinearTimingFunction&);
+ static bool decode(Decoder&, WebCore::LinearTimingFunction&);
+};
+
+template<> struct ArgumentCoder<WebCore::CubicBezierTimingFunction> {
+ static void encode(Encoder&, const WebCore::CubicBezierTimingFunction&);
+ static bool decode(Decoder&, WebCore::CubicBezierTimingFunction&);
+};
+
+template<> struct ArgumentCoder<WebCore::StepsTimingFunction> {
+ static void encode(Encoder&, const WebCore::StepsTimingFunction&);
+ static bool decode(Decoder&, WebCore::StepsTimingFunction&);
+};
+
+template<> struct ArgumentCoder<WebCore::SpringTimingFunction> {
+ static void encode(Encoder&, const WebCore::SpringTimingFunction&);
+ static bool decode(Decoder&, WebCore::SpringTimingFunction&);
};
template<> struct ArgumentCoder<WebCore::CertificateInfo> {
- static void encode(ArgumentEncoder&, const WebCore::CertificateInfo&);
- static bool decode(ArgumentDecoder&, WebCore::CertificateInfo&);
+ static void encode(Encoder&, const WebCore::CertificateInfo&);
+ static bool decode(Decoder&, WebCore::CertificateInfo&);
};
template<> struct ArgumentCoder<WebCore::FloatPoint> {
- static void encode(ArgumentEncoder&, const WebCore::FloatPoint&);
- static bool decode(ArgumentDecoder&, WebCore::FloatPoint&);
+ static void encode(Encoder&, const WebCore::FloatPoint&);
+ static bool decode(Decoder&, WebCore::FloatPoint&);
};
template<> struct ArgumentCoder<WebCore::FloatPoint3D> {
- static void encode(ArgumentEncoder&, const WebCore::FloatPoint3D&);
- static bool decode(ArgumentDecoder&, WebCore::FloatPoint3D&);
+ static void encode(Encoder&, const WebCore::FloatPoint3D&);
+ static bool decode(Decoder&, WebCore::FloatPoint3D&);
};
template<> struct ArgumentCoder<WebCore::FloatRect> {
- static void encode(ArgumentEncoder&, const WebCore::FloatRect&);
- static bool decode(ArgumentDecoder&, WebCore::FloatRect&);
+ static void encode(Encoder&, const WebCore::FloatRect&);
+ static bool decode(Decoder&, WebCore::FloatRect&);
};
template<> struct ArgumentCoder<WebCore::FloatSize> {
- static void encode(ArgumentEncoder&, const WebCore::FloatSize&);
- static bool decode(ArgumentDecoder&, WebCore::FloatSize&);
+ static void encode(Encoder&, const WebCore::FloatSize&);
+ static bool decode(Decoder&, WebCore::FloatSize&);
+};
+
+template<> struct ArgumentCoder<WebCore::FloatRoundedRect> {
+ static void encode(Encoder&, const WebCore::FloatRoundedRect&);
+ static bool decode(Decoder&, WebCore::FloatRoundedRect&);
};
#if PLATFORM(IOS)
template<> struct ArgumentCoder<WebCore::FloatQuad> {
- static void encode(ArgumentEncoder&, const WebCore::FloatQuad&);
- static bool decode(ArgumentDecoder&, WebCore::FloatQuad&);
+ static void encode(Encoder&, const WebCore::FloatQuad&);
+ static bool decode(Decoder&, WebCore::FloatQuad&);
};
template<> struct ArgumentCoder<WebCore::ViewportArguments> {
- static void encode(ArgumentEncoder&, const WebCore::ViewportArguments&);
- static bool decode(ArgumentDecoder&, WebCore::ViewportArguments&);
+ static void encode(Encoder&, const WebCore::ViewportArguments&);
+ static bool decode(Decoder&, WebCore::ViewportArguments&);
};
#endif // PLATFORM(IOS)
template<> struct ArgumentCoder<WebCore::IntPoint> {
- static void encode(ArgumentEncoder&, const WebCore::IntPoint&);
- static bool decode(ArgumentDecoder&, WebCore::IntPoint&);
+ static void encode(Encoder&, const WebCore::IntPoint&);
+ static bool decode(Decoder&, WebCore::IntPoint&);
};
template<> struct ArgumentCoder<WebCore::IntRect> {
- static void encode(ArgumentEncoder&, const WebCore::IntRect&);
- static bool decode(ArgumentDecoder&, WebCore::IntRect&);
+ static void encode(Encoder&, const WebCore::IntRect&);
+ static bool decode(Decoder&, WebCore::IntRect&);
};
template<> struct ArgumentCoder<WebCore::IntSize> {
- static void encode(ArgumentEncoder&, const WebCore::IntSize&);
- static bool decode(ArgumentDecoder&, WebCore::IntSize&);
+ static void encode(Encoder&, const WebCore::IntSize&);
+ static bool decode(Decoder&, WebCore::IntSize&);
+};
+
+template<> struct ArgumentCoder<WebCore::LayoutSize> {
+ static void encode(Encoder&, const WebCore::LayoutSize&);
+ static bool decode(Decoder&, WebCore::LayoutSize&);
+};
+
+template<> struct ArgumentCoder<WebCore::LayoutPoint> {
+ static void encode(Encoder&, const WebCore::LayoutPoint&);
+ static bool decode(Decoder&, WebCore::LayoutPoint&);
+};
+
+template<> struct ArgumentCoder<WebCore::Path> {
+ static void encode(Encoder&, const WebCore::Path&);
+ static bool decode(Decoder&, WebCore::Path&);
+};
+
+template<> struct ArgumentCoder<WebCore::Region> {
+ static void encode(Encoder&, const WebCore::Region&);
+ static bool decode(Decoder&, WebCore::Region&);
};
template<> struct ArgumentCoder<WebCore::Length> {
- static void encode(ArgumentEncoder&, const WebCore::Length&);
- static bool decode(ArgumentDecoder&, WebCore::Length&);
+ static void encode(Encoder&, const WebCore::Length&);
+ static bool decode(Decoder&, WebCore::Length&);
};
template<> struct ArgumentCoder<WebCore::ViewportAttributes> {
- static void encode(ArgumentEncoder&, const WebCore::ViewportAttributes&);
- static bool decode(ArgumentDecoder&, WebCore::ViewportAttributes&);
+ static void encode(Encoder&, const WebCore::ViewportAttributes&);
+ static bool decode(Decoder&, WebCore::ViewportAttributes&);
};
template<> struct ArgumentCoder<WebCore::MimeClassInfo> {
- static void encode(ArgumentEncoder&, const WebCore::MimeClassInfo&);
- static bool decode(ArgumentDecoder&, WebCore::MimeClassInfo&);
+ static void encode(Encoder&, const WebCore::MimeClassInfo&);
+ static bool decode(Decoder&, WebCore::MimeClassInfo&);
};
template<> struct ArgumentCoder<WebCore::PluginInfo> {
- static void encode(ArgumentEncoder&, const WebCore::PluginInfo&);
- static bool decode(ArgumentDecoder&, WebCore::PluginInfo&);
-};
-
-template<> struct ArgumentCoder<WebCore::HTTPHeaderMap> {
- static void encode(ArgumentEncoder&, const WebCore::HTTPHeaderMap&);
- static bool decode(ArgumentDecoder&, WebCore::HTTPHeaderMap&);
+ static void encode(Encoder&, const WebCore::PluginInfo&);
+ static bool decode(Decoder&, WebCore::PluginInfo&);
};
template<> struct ArgumentCoder<WebCore::AuthenticationChallenge> {
- static void encode(ArgumentEncoder&, const WebCore::AuthenticationChallenge&);
- static bool decode(ArgumentDecoder&, WebCore::AuthenticationChallenge&);
+ static void encode(Encoder&, const WebCore::AuthenticationChallenge&);
+ static bool decode(Decoder&, WebCore::AuthenticationChallenge&);
};
template<> struct ArgumentCoder<WebCore::ProtectionSpace> {
- static void encode(ArgumentEncoder&, const WebCore::ProtectionSpace&);
- static bool decode(ArgumentDecoder&, WebCore::ProtectionSpace&);
+ static void encode(Encoder&, const WebCore::ProtectionSpace&);
+ static bool decode(Decoder&, WebCore::ProtectionSpace&);
+ static void encodePlatformData(Encoder&, const WebCore::ProtectionSpace&);
+ static bool decodePlatformData(Decoder&, WebCore::ProtectionSpace&);
};
template<> struct ArgumentCoder<WebCore::Credential> {
- static void encode(ArgumentEncoder&, const WebCore::Credential&);
- static bool decode(ArgumentDecoder&, WebCore::Credential&);
+ static void encode(Encoder&, const WebCore::Credential&);
+ static bool decode(Decoder&, WebCore::Credential&);
+ static void encodePlatformData(Encoder&, const WebCore::Credential&);
+ static bool decodePlatformData(Decoder&, WebCore::Credential&);
};
template<> struct ArgumentCoder<WebCore::Cursor> {
- static void encode(ArgumentEncoder&, const WebCore::Cursor&);
- static bool decode(ArgumentDecoder&, WebCore::Cursor&);
+ static void encode(Encoder&, const WebCore::Cursor&);
+ static bool decode(Decoder&, WebCore::Cursor&);
};
template<> struct ArgumentCoder<WebCore::ResourceRequest> {
-#if PLATFORM(MAC)
- static const bool kShouldSerializeWebCoreData = false;
-#else
- static const bool kShouldSerializeWebCoreData = true;
-#endif
-
- static void encode(ArgumentEncoder&, const WebCore::ResourceRequest&);
- static bool decode(ArgumentDecoder&, WebCore::ResourceRequest&);
- static void encodePlatformData(ArgumentEncoder&, const WebCore::ResourceRequest&);
- static bool decodePlatformData(ArgumentDecoder&, WebCore::ResourceRequest&);
-};
-
-template<> struct ArgumentCoder<WebCore::ResourceResponse> {
- static void encode(ArgumentEncoder&, const WebCore::ResourceResponse&);
- static bool decode(ArgumentDecoder&, WebCore::ResourceResponse&);
- static void encodePlatformData(ArgumentEncoder&, const WebCore::ResourceResponse&);
- static bool decodePlatformData(ArgumentDecoder&, WebCore::ResourceResponse&);
+ static void encode(Encoder&, const WebCore::ResourceRequest&);
+ static bool decode(Decoder&, WebCore::ResourceRequest&);
+ static void encodePlatformData(Encoder&, const WebCore::ResourceRequest&);
+ static bool decodePlatformData(Decoder&, WebCore::ResourceRequest&);
};
template<> struct ArgumentCoder<WebCore::ResourceError> {
-#if PLATFORM(MAC)
- static const bool kShouldSerializeWebCoreData = false;
-#else
- static const bool kShouldSerializeWebCoreData = true;
-#endif
-
- static void encode(ArgumentEncoder&, const WebCore::ResourceError&);
- static bool decode(ArgumentDecoder&, WebCore::ResourceError&);
- static void encodePlatformData(ArgumentEncoder&, const WebCore::ResourceError&);
- static bool decodePlatformData(ArgumentDecoder&, WebCore::ResourceError&);
+ static void encode(Encoder&, const WebCore::ResourceError&);
+ static bool decode(Decoder&, WebCore::ResourceError&);
+ static void encodePlatformData(Encoder&, const WebCore::ResourceError&);
+ static bool decodePlatformData(Decoder&, WebCore::ResourceError&);
};
template<> struct ArgumentCoder<WebCore::WindowFeatures> {
- static void encode(ArgumentEncoder&, const WebCore::WindowFeatures&);
- static bool decode(ArgumentDecoder&, WebCore::WindowFeatures&);
+ static void encode(Encoder&, const WebCore::WindowFeatures&);
+ static bool decode(Decoder&, WebCore::WindowFeatures&);
};
template<> struct ArgumentCoder<WebCore::Color> {
- static void encode(ArgumentEncoder&, const WebCore::Color&);
- static bool decode(ArgumentDecoder&, WebCore::Color&);
+ static void encode(Encoder&, const WebCore::Color&);
+ static bool decode(Decoder&, WebCore::Color&);
+};
+
+#if ENABLE(DRAG_SUPPORT)
+template<> struct ArgumentCoder<WebCore::DragData> {
+ static void encode(Encoder&, const WebCore::DragData&);
+ static bool decode(Decoder&, WebCore::DragData&);
+};
+#endif
+
+#if PLATFORM(COCOA)
+template<> struct ArgumentCoder<WebCore::MachSendRight> {
+ static void encode(Encoder&, const WebCore::MachSendRight&);
+ static void encode(Encoder&, WebCore::MachSendRight&&);
+ static bool decode(Decoder&, WebCore::MachSendRight&);
};
-#if PLATFORM(MAC)
template<> struct ArgumentCoder<WebCore::KeypressCommand> {
- static void encode(ArgumentEncoder&, const WebCore::KeypressCommand&);
- static bool decode(ArgumentDecoder&, WebCore::KeypressCommand&);
+ static void encode(Encoder&, const WebCore::KeypressCommand&);
+ static bool decode(Decoder&, WebCore::KeypressCommand&);
};
#endif
#if PLATFORM(IOS)
template<> struct ArgumentCoder<WebCore::SelectionRect> {
- static void encode(ArgumentEncoder&, const WebCore::SelectionRect&);
- static bool decode(ArgumentDecoder&, WebCore::SelectionRect&);
+ static void encode(Encoder&, const WebCore::SelectionRect&);
+ static bool decode(Decoder&, WebCore::SelectionRect&);
+};
+
+template<> struct ArgumentCoder<WebCore::Highlight> {
+ static void encode(Encoder&, const WebCore::Highlight&);
+ static bool decode(Decoder&, WebCore::Highlight&);
};
template<> struct ArgumentCoder<WebCore::PasteboardWebContent> {
- static void encode(ArgumentEncoder&, const WebCore::PasteboardWebContent&);
- static bool decode(ArgumentDecoder&, WebCore::PasteboardWebContent&);
+ static void encode(Encoder&, const WebCore::PasteboardWebContent&);
+ static bool decode(Decoder&, WebCore::PasteboardWebContent&);
};
template<> struct ArgumentCoder<WebCore::PasteboardImage> {
- static void encode(ArgumentEncoder&, const WebCore::PasteboardImage&);
- static bool decode(ArgumentDecoder&, WebCore::PasteboardImage&);
+ static void encode(Encoder&, const WebCore::PasteboardImage&);
+ static bool decode(Decoder&, WebCore::PasteboardImage&);
+};
+#endif
+
+#if USE(SOUP)
+template<> struct ArgumentCoder<WebCore::SoupNetworkProxySettings> {
+ static void encode(Encoder&, const WebCore::SoupNetworkProxySettings&);
+ static bool decode(Decoder&, WebCore::SoupNetworkProxySettings&);
};
#endif
template<> struct ArgumentCoder<WebCore::CompositionUnderline> {
- static void encode(ArgumentEncoder&, const WebCore::CompositionUnderline&);
- static bool decode(ArgumentDecoder&, WebCore::CompositionUnderline&);
+ static void encode(Encoder&, const WebCore::CompositionUnderline&);
+ static bool decode(Decoder&, WebCore::CompositionUnderline&);
};
template<> struct ArgumentCoder<WebCore::Cookie> {
- static void encode(ArgumentEncoder&, const WebCore::Cookie&);
- static bool decode(ArgumentDecoder&, WebCore::Cookie&);
+ static void encode(Encoder&, const WebCore::Cookie&);
+ static bool decode(Decoder&, WebCore::Cookie&);
};
template<> struct ArgumentCoder<WebCore::DatabaseDetails> {
- static void encode(ArgumentEncoder&, const WebCore::DatabaseDetails&);
- static bool decode(ArgumentDecoder&, WebCore::DatabaseDetails&);
+ static void encode(Encoder&, const WebCore::DatabaseDetails&);
+ static bool decode(Decoder&, WebCore::DatabaseDetails&);
};
template<> struct ArgumentCoder<WebCore::DictationAlternative> {
- static void encode(ArgumentEncoder&, const WebCore::DictationAlternative&);
- static bool decode(ArgumentDecoder&, WebCore::DictationAlternative&);
+ static void encode(Encoder&, const WebCore::DictationAlternative&);
+ static bool decode(Decoder&, WebCore::DictationAlternative&);
};
template<> struct ArgumentCoder<WebCore::FileChooserSettings> {
- static void encode(ArgumentEncoder&, const WebCore::FileChooserSettings&);
- static bool decode(ArgumentDecoder&, WebCore::FileChooserSettings&);
+ static void encode(Encoder&, const WebCore::FileChooserSettings&);
+ static bool decode(Decoder&, WebCore::FileChooserSettings&);
};
template<> struct ArgumentCoder<WebCore::GrammarDetail> {
- static void encode(ArgumentEncoder&, const WebCore::GrammarDetail&);
- static bool decode(ArgumentDecoder&, WebCore::GrammarDetail&);
+ static void encode(Encoder&, const WebCore::GrammarDetail&);
+ static bool decode(Decoder&, WebCore::GrammarDetail&);
};
template<> struct ArgumentCoder<WebCore::TextCheckingRequestData> {
- static void encode(ArgumentEncoder&, const WebCore::TextCheckingRequestData&);
- static bool decode(ArgumentDecoder&, WebCore::TextCheckingRequestData&);
+ static void encode(Encoder&, const WebCore::TextCheckingRequestData&);
+ static bool decode(Decoder&, WebCore::TextCheckingRequestData&);
};
template<> struct ArgumentCoder<WebCore::TextCheckingResult> {
- static void encode(ArgumentEncoder&, const WebCore::TextCheckingResult&);
- static bool decode(ArgumentDecoder&, WebCore::TextCheckingResult&);
+ static void encode(Encoder&, const WebCore::TextCheckingResult&);
+ static bool decode(Decoder&, WebCore::TextCheckingResult&);
};
-template<> struct ArgumentCoder<WebCore::DragSession> {
- static void encode(ArgumentEncoder&, const WebCore::DragSession&);
- static bool decode(ArgumentDecoder&, WebCore::DragSession&);
-};
-
template<> struct ArgumentCoder<WebCore::URL> {
- static void encode(ArgumentEncoder&, const WebCore::URL&);
- static bool decode(ArgumentDecoder&, WebCore::URL&);
+ static void encode(Encoder&, const WebCore::URL&);
+ static bool decode(Decoder&, WebCore::URL&);
};
template<> struct ArgumentCoder<WebCore::UserStyleSheet> {
- static void encode(ArgumentEncoder&, const WebCore::UserStyleSheet&);
- static bool decode(ArgumentDecoder&, WebCore::UserStyleSheet&);
+ static void encode(Encoder&, const WebCore::UserStyleSheet&);
+ static bool decode(Decoder&, WebCore::UserStyleSheet&);
};
template<> struct ArgumentCoder<WebCore::UserScript> {
- static void encode(ArgumentEncoder&, const WebCore::UserScript&);
- static bool decode(ArgumentDecoder&, WebCore::UserScript&);
+ static void encode(Encoder&, const WebCore::UserScript&);
+ static bool decode(Decoder&, WebCore::UserScript&);
};
template<> struct ArgumentCoder<WebCore::ScrollableAreaParameters> {
- static void encode(ArgumentEncoder&, const WebCore::ScrollableAreaParameters&);
- static bool decode(ArgumentDecoder&, WebCore::ScrollableAreaParameters&);
+ static void encode(Encoder&, const WebCore::ScrollableAreaParameters&);
+ static bool decode(Decoder&, WebCore::ScrollableAreaParameters&);
};
template<> struct ArgumentCoder<WebCore::FixedPositionViewportConstraints> {
- static void encode(ArgumentEncoder&, const WebCore::FixedPositionViewportConstraints&);
- static bool decode(ArgumentDecoder&, WebCore::FixedPositionViewportConstraints&);
+ static void encode(Encoder&, const WebCore::FixedPositionViewportConstraints&);
+ static bool decode(Decoder&, WebCore::FixedPositionViewportConstraints&);
};
template<> struct ArgumentCoder<WebCore::StickyPositionViewportConstraints> {
- static void encode(ArgumentEncoder&, const WebCore::StickyPositionViewportConstraints&);
- static bool decode(ArgumentDecoder&, WebCore::StickyPositionViewportConstraints&);
+ static void encode(Encoder&, const WebCore::StickyPositionViewportConstraints&);
+ static bool decode(Decoder&, WebCore::StickyPositionViewportConstraints&);
};
-#if ENABLE(CSS_FILTERS) && !USE(COORDINATED_GRAPHICS)
+#if !USE(COORDINATED_GRAPHICS)
template<> struct ArgumentCoder<WebCore::FilterOperations> {
- static void encode(ArgumentEncoder&, const WebCore::FilterOperations&);
- static bool decode(ArgumentDecoder&, WebCore::FilterOperations&);
+ static void encode(Encoder&, const WebCore::FilterOperations&);
+ static bool decode(Decoder&, WebCore::FilterOperations&);
};
+
+template<> struct ArgumentCoder<WebCore::FilterOperation> {
+ static void encode(Encoder&, const WebCore::FilterOperation&);
+};
+bool decodeFilterOperation(Decoder&, RefPtr<WebCore::FilterOperation>&);
#endif
-#if ENABLE(INDEXED_DATABASE)
-template<> struct ArgumentCoder<WebCore::IDBDatabaseMetadata> {
- static void encode(ArgumentEncoder&, const WebCore::IDBDatabaseMetadata&);
- static bool decode(ArgumentDecoder&, WebCore::IDBDatabaseMetadata&);
+template<> struct ArgumentCoder<WebCore::SessionID> {
+ static void encode(Encoder&, const WebCore::SessionID&);
+ static bool decode(Decoder&, WebCore::SessionID&);
};
-template<> struct ArgumentCoder<WebCore::IDBGetResult> {
- static void encode(ArgumentEncoder&, const WebCore::IDBGetResult&);
- static bool decode(ArgumentDecoder&, WebCore::IDBGetResult&);
+template<> struct ArgumentCoder<WebCore::BlobPart> {
+ static void encode(Encoder&, const WebCore::BlobPart&);
+ static bool decode(Decoder&, WebCore::BlobPart&);
};
-template<> struct ArgumentCoder<WebCore::IDBIndexMetadata> {
- static void encode(ArgumentEncoder&, const WebCore::IDBIndexMetadata&);
- static bool decode(ArgumentDecoder&, WebCore::IDBIndexMetadata&);
+#if ENABLE(CONTENT_FILTERING)
+template<> struct ArgumentCoder<WebCore::ContentFilterUnblockHandler> {
+ static void encode(Encoder&, const WebCore::ContentFilterUnblockHandler&);
+ static bool decode(Decoder&, WebCore::ContentFilterUnblockHandler&);
};
+#endif
-template<> struct ArgumentCoder<WebCore::IDBKeyData> {
- static void encode(ArgumentEncoder&, const WebCore::IDBKeyData&);
- static bool decode(ArgumentDecoder&, WebCore::IDBKeyData&);
+#if ENABLE(MEDIA_SESSION)
+template<> struct ArgumentCoder<WebCore::MediaSessionMetadata> {
+ static void encode(Encoder&, const WebCore::MediaSessionMetadata&);
+ static bool decode(Decoder&, WebCore::MediaSessionMetadata&);
};
+#endif
-template<> struct ArgumentCoder<WebCore::IDBKeyPath> {
- static void encode(ArgumentEncoder&, const WebCore::IDBKeyPath&);
- static bool decode(ArgumentDecoder&, WebCore::IDBKeyPath&);
+template<> struct ArgumentCoder<WebCore::TextIndicatorData> {
+ static void encode(Encoder&, const WebCore::TextIndicatorData&);
+ static bool decode(Decoder&, WebCore::TextIndicatorData&);
};
-template<> struct ArgumentCoder<WebCore::IDBKeyRangeData> {
- static void encode(ArgumentEncoder&, const WebCore::IDBKeyRangeData&);
- static bool decode(ArgumentDecoder&, WebCore::IDBKeyRangeData&);
+template<> struct ArgumentCoder<WebCore::DictionaryPopupInfo> {
+ static void encode(Encoder&, const WebCore::DictionaryPopupInfo&);
+ static bool decode(Decoder&, WebCore::DictionaryPopupInfo&);
};
-template<> struct ArgumentCoder<WebCore::IDBObjectStoreMetadata> {
- static void encode(ArgumentEncoder&, const WebCore::IDBObjectStoreMetadata&);
- static bool decode(ArgumentDecoder&, WebCore::IDBObjectStoreMetadata&);
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+template<> struct ArgumentCoder<WebCore::MediaPlaybackTargetContext> {
+ static void encode(Encoder&, const WebCore::MediaPlaybackTargetContext&);
+ static bool decode(Decoder&, WebCore::MediaPlaybackTargetContext&);
+ static void encodePlatformData(Encoder&, const WebCore::MediaPlaybackTargetContext&);
+ static bool decodePlatformData(Decoder&, WebCore::MediaPlaybackTargetContext&);
};
#endif
+template<> struct ArgumentCoder<WebCore::RecentSearch> {
+ static void encode(Encoder&, const WebCore::RecentSearch&);
+ static bool decode(Decoder&, WebCore::RecentSearch&);
+};
+
+template<> struct ArgumentCoder<WebCore::ExceptionDetails> {
+ static void encode(Encoder&, const WebCore::ExceptionDetails&);
+ static bool decode(Decoder&, WebCore::ExceptionDetails&);
+};
+
+template<> struct ArgumentCoder<WebCore::ResourceLoadStatistics> {
+ static void encode(Encoder&, const WebCore::ResourceLoadStatistics&);
+ static bool decode(Decoder&, WebCore::ResourceLoadStatistics&);
+};
+
+#if ENABLE(APPLE_PAY)
+
+template<> struct ArgumentCoder<WebCore::Payment> {
+ static void encode(Encoder&, const WebCore::Payment&);
+ static bool decode(Decoder&, WebCore::Payment&);
+};
+
+template<> struct ArgumentCoder<WebCore::PaymentContact> {
+ static void encode(Encoder&, const WebCore::PaymentContact&);
+ static bool decode(Decoder&, WebCore::PaymentContact&);
+};
+
+template<> struct ArgumentCoder<WebCore::PaymentMerchantSession> {
+ static void encode(Encoder&, const WebCore::PaymentMerchantSession&);
+ static bool decode(Decoder&, WebCore::PaymentMerchantSession&);
+};
+
+template<> struct ArgumentCoder<WebCore::PaymentMethod> {
+ static void encode(Encoder&, const WebCore::PaymentMethod&);
+ static bool decode(Decoder&, WebCore::PaymentMethod&);
+};
+
+template<> struct ArgumentCoder<WebCore::PaymentRequest> {
+ static void encode(Encoder&, const WebCore::PaymentRequest&);
+ static bool decode(Decoder&, WebCore::PaymentRequest&);
+};
+
+template<> struct ArgumentCoder<WebCore::PaymentRequest::ContactFields> {
+ static void encode(Encoder&, const WebCore::PaymentRequest::ContactFields&);
+ static bool decode(Decoder&, WebCore::PaymentRequest::ContactFields&);
+};
+
+template<> struct ArgumentCoder<WebCore::PaymentRequest::LineItem> {
+ static void encode(Encoder&, const WebCore::PaymentRequest::LineItem&);
+ static bool decode(Decoder&, WebCore::PaymentRequest::LineItem&);
+};
+
+template<> struct ArgumentCoder<WebCore::PaymentRequest::MerchantCapabilities> {
+ static void encode(Encoder&, const WebCore::PaymentRequest::MerchantCapabilities&);
+ static bool decode(Decoder&, WebCore::PaymentRequest::MerchantCapabilities&);
+};
+
+template<> struct ArgumentCoder<WebCore::PaymentRequest::ShippingMethod> {
+ static void encode(Encoder&, const WebCore::PaymentRequest::ShippingMethod&);
+ static bool decode(Decoder&, WebCore::PaymentRequest::ShippingMethod&);
+};
+
+template<> struct ArgumentCoder<WebCore::PaymentRequest::TotalAndLineItems> {
+ static void encode(Encoder&, const WebCore::PaymentRequest::TotalAndLineItems&);
+ static bool decode(Decoder&, WebCore::PaymentRequest::TotalAndLineItems&);
+};
+
+#endif
+
+#if ENABLE(MEDIA_STREAM)
+template<> struct ArgumentCoder<WebCore::MediaConstraintsData> {
+ static void encode(Encoder&, const WebCore::MediaConstraintsData&);
+ static bool decode(Decoder&, WebCore::MediaConstraintsData&);
+};
+
+template<> struct ArgumentCoder<WebCore::CaptureDevice> {
+ static void encode(Encoder&, const WebCore::CaptureDevice&);
+ static bool decode(Decoder&, WebCore::CaptureDevice&);
+};
+#endif
+
+#if ENABLE(INDEXED_DATABASE)
+
+template<> struct ArgumentCoder<WebCore::IDBKeyPath> {
+ static void encode(Encoder&, const WebCore::IDBKeyPath&);
+ static bool decode(Decoder&, WebCore::IDBKeyPath&);
+};
+
+#endif
+
+#if ENABLE(CSS_SCROLL_SNAP)
+
+template<> struct ArgumentCoder<WebCore::ScrollOffsetRange<float>> {
+ static void encode(Encoder&, const WebCore::ScrollOffsetRange<float>&);
+ static bool decode(Decoder&, WebCore::ScrollOffsetRange<float>&);
+};
+
+#endif
+
} // namespace IPC
-#endif // WebCoreArgumentCoders_h
+namespace WTF {
+
+template<> struct EnumTraits<WebCore::ColorSpace> {
+ using values = EnumValues<
+ WebCore::ColorSpace,
+ WebCore::ColorSpace::ColorSpaceDeviceRGB,
+ WebCore::ColorSpace::ColorSpaceSRGB,
+ WebCore::ColorSpace::ColorSpaceLinearRGB,
+ WebCore::ColorSpace::ColorSpaceDisplayP3
+ >;
+};
+
+template<> struct EnumTraits<WebCore::HasInsecureContent> {
+ using values = EnumValues<
+ WebCore::HasInsecureContent,
+ WebCore::HasInsecureContent::No,
+ WebCore::HasInsecureContent::Yes
+ >;
+};
+
+template<> struct EnumTraits<WebCore::ShouldSample> {
+ using values = EnumValues<
+ WebCore::ShouldSample,
+ WebCore::ShouldSample::No,
+ WebCore::ShouldSample::Yes
+ >;
+};
+
+#if ENABLE(INDEXED_DATABASE)
+template<> struct EnumTraits<WebCore::IndexedDB::GetAllType> {
+ using values = EnumValues<
+ WebCore::IndexedDB::GetAllType,
+ WebCore::IndexedDB::GetAllType::Keys,
+ WebCore::IndexedDB::GetAllType::Values
+ >;
+};
+#endif
+
+} // namespace WTF
diff --git a/Source/WebKit2/Shared/WebEvent.cpp b/Source/WebKit2/Shared/WebEvent.cpp
index 54f434b6e..507bc1662 100644
--- a/Source/WebKit2/Shared/WebEvent.cpp
+++ b/Source/WebKit2/Shared/WebEvent.cpp
@@ -26,9 +26,8 @@
#include "config.h"
#include "WebEvent.h"
-#include "ArgumentDecoder.h"
-#include "ArgumentEncoder.h"
-#include "Arguments.h"
+#include "Decoder.h"
+#include "Encoder.h"
namespace WebKit {
@@ -46,14 +45,14 @@ WebEvent::WebEvent(Type type, Modifiers modifiers, double timestamp)
{
}
-void WebEvent::encode(IPC::ArgumentEncoder& encoder) const
+void WebEvent::encode(IPC::Encoder& encoder) const
{
encoder << m_type;
encoder << m_modifiers;
encoder << m_timestamp;
}
-bool WebEvent::decode(IPC::ArgumentDecoder& decoder, WebEvent& result)
+bool WebEvent::decode(IPC::Decoder& decoder, WebEvent& result)
{
if (!decoder.decode(result.m_type))
return false;
@@ -63,5 +62,17 @@ bool WebEvent::decode(IPC::ArgumentDecoder& decoder, WebEvent& result)
return false;
return true;
}
-
+
+#if ENABLE(TOUCH_EVENTS)
+bool WebTouchEvent::allTouchPointsAreReleased() const
+{
+ for (const auto& touchPoint : touchPoints()) {
+ if (touchPoint.state() != WebPlatformTouchPoint::TouchReleased && touchPoint.state() != WebPlatformTouchPoint::TouchCancelled)
+ return false;
+ }
+
+ return true;
+}
+#endif
+
} // namespace WebKit
diff --git a/Source/WebKit2/Shared/WebEvent.h b/Source/WebKit2/Shared/WebEvent.h
index b5bbb58d1..4eb51e397 100644
--- a/Source/WebKit2/Shared/WebEvent.h
+++ b/Source/WebKit2/Shared/WebEvent.h
@@ -37,10 +37,16 @@
#include <wtf/text/WTFString.h>
namespace IPC {
- class ArgumentDecoder;
- class ArgumentEncoder;
+class Decoder;
+class Encoder;
}
+#if USE(APPKIT)
+namespace WebCore {
+struct KeypressCommand;
+}
+#endif
+
namespace WebKit {
class WebEvent {
@@ -52,6 +58,9 @@ public:
MouseDown,
MouseUp,
MouseMove,
+ MouseForceChanged,
+ MouseForceDown,
+ MouseForceUp,
// WebWheelEvent
Wheel,
@@ -69,6 +78,12 @@ public:
TouchEnd,
TouchCancel,
#endif
+
+#if ENABLE(MAC_GESTURE_EVENTS)
+ GestureStart,
+ GestureChange,
+ GestureEnd,
+#endif
};
enum Modifiers {
@@ -96,8 +111,8 @@ protected:
WebEvent(Type, Modifiers, double timestamp);
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, WebEvent&);
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, WebEvent&);
private:
uint32_t m_type; // Type
@@ -115,9 +130,15 @@ public:
RightButton
};
+ enum SyntheticClickType { NoTap, OneFingerTap, TwoFingerTap };
+
WebMouseEvent();
- WebMouseEvent(Type, Button, const WebCore::IntPoint& position, const WebCore::IntPoint& globalPosition, float deltaX, float deltaY, float deltaZ, int clickCount, Modifiers, double timestamp);
+#if PLATFORM(MAC)
+ WebMouseEvent(Type, Button, const WebCore::IntPoint& position, const WebCore::IntPoint& globalPosition, float deltaX, float deltaY, float deltaZ, int clickCount, Modifiers, double timestamp, double force, SyntheticClickType = NoTap, int eventNumber = -1, int menuType = 0);
+#else
+ WebMouseEvent(Type, Button, const WebCore::IntPoint& position, const WebCore::IntPoint& globalPosition, float deltaX, float deltaY, float deltaZ, int clickCount, Modifiers, double timestamp, double force = 0, SyntheticClickType = NoTap);
+#endif
Button button() const { return static_cast<Button>(m_button); }
const WebCore::IntPoint& position() const { return m_position; }
@@ -126,9 +147,15 @@ public:
float deltaY() const { return m_deltaY; }
float deltaZ() const { return m_deltaZ; }
int32_t clickCount() const { return m_clickCount; }
+#if PLATFORM(MAC)
+ int32_t eventNumber() const { return m_eventNumber; }
+ int32_t menuTypeForEvent() const { return m_menuTypeForEvent; }
+#endif
+ double force() const { return m_force; }
+ SyntheticClickType syntheticClickType() const { return static_cast<SyntheticClickType>(m_syntheticClickType); }
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, WebMouseEvent&);
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, WebMouseEvent&);
private:
static bool isMouseEventType(Type);
@@ -140,6 +167,12 @@ private:
float m_deltaY;
float m_deltaZ;
int32_t m_clickCount;
+#if PLATFORM(MAC)
+ int32_t m_eventNumber;
+ int32_t m_menuTypeForEvent;
+#endif
+ double m_force { 0 };
+ uint32_t m_syntheticClickType { NoTap };
};
// FIXME: Move this class to its own header file.
@@ -150,7 +183,7 @@ public:
ScrollByPixelWheelEvent
};
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
enum Phase {
PhaseNone = 0,
PhaseBegan = 1 << 0,
@@ -165,7 +198,7 @@ public:
WebWheelEvent() { }
WebWheelEvent(Type, const WebCore::IntPoint& position, const WebCore::IntPoint& globalPosition, const WebCore::FloatSize& delta, const WebCore::FloatSize& wheelTicks, Granularity, Modifiers, double timestamp);
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
WebWheelEvent(Type, const WebCore::IntPoint& position, const WebCore::IntPoint& globalPosition, const WebCore::FloatSize& delta, const WebCore::FloatSize& wheelTicks, Granularity, bool directionInvertedFromDevice, Phase, Phase momentumPhase, bool hasPreciseScrollingDeltas, uint32_t scrollCount, const WebCore::FloatSize& unacceleratedScrollingDelta, Modifiers, double timestamp);
#endif
@@ -175,7 +208,7 @@ public:
const WebCore::FloatSize wheelTicks() const { return m_wheelTicks; }
Granularity granularity() const { return static_cast<Granularity>(m_granularity); }
bool directionInvertedFromDevice() const { return m_directionInvertedFromDevice; }
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
Phase phase() const { return static_cast<Phase>(m_phase); }
Phase momentumPhase() const { return static_cast<Phase>(m_momentumPhase); }
bool hasPreciseScrollingDeltas() const { return m_hasPreciseScrollingDeltas; }
@@ -183,8 +216,8 @@ public:
const WebCore::FloatSize& unacceleratedScrollingDelta() const { return m_unacceleratedScrollingDelta; }
#endif
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, WebWheelEvent&);
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, WebWheelEvent&);
private:
static bool isWheelEventType(Type);
@@ -195,7 +228,7 @@ private:
WebCore::FloatSize m_wheelTicks;
uint32_t m_granularity; // Granularity
bool m_directionInvertedFromDevice;
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
uint32_t m_phase; // Phase
uint32_t m_momentumPhase; // Phase
bool m_hasPreciseScrollingDeltas;
@@ -207,32 +240,69 @@ private:
// FIXME: Move this class to its own header file.
class WebKeyboardEvent : public WebEvent {
public:
- WebKeyboardEvent() { }
-
+ WebKeyboardEvent();
+ ~WebKeyboardEvent();
+
+#if USE(APPKIT)
+ WebKeyboardEvent(Type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool handledByInputMethod, const Vector<WebCore::KeypressCommand>&, bool isAutoRepeat, bool isKeypad, bool isSystemKey, Modifiers, double timestamp);
+#elif PLATFORM(GTK)
+ WebKeyboardEvent(Type, const String& text, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool handledByInputMethod, Vector<String>&& commands, bool isKeypad, Modifiers, double timestamp);
+#elif PLATFORM(IOS)
+ WebKeyboardEvent(Type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, Modifiers, double timestamp);
+#else
WebKeyboardEvent(Type, const String& text, const String& unmodifiedText, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, Modifiers, double timestamp);
+#endif
const String& text() const { return m_text; }
const String& unmodifiedText() const { return m_unmodifiedText; }
+#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
+ const String& key() const { return m_key; }
+#endif
+#if ENABLE(KEYBOARD_CODE_ATTRIBUTE)
+ const String& code() const { return m_code; }
+#endif
const String& keyIdentifier() const { return m_keyIdentifier; }
int32_t windowsVirtualKeyCode() const { return m_windowsVirtualKeyCode; }
int32_t nativeVirtualKeyCode() const { return m_nativeVirtualKeyCode; }
int32_t macCharCode() const { return m_macCharCode; }
+#if USE(APPKIT) || PLATFORM(GTK)
+ bool handledByInputMethod() const { return m_handledByInputMethod; }
+#endif
+#if USE(APPKIT)
+ const Vector<WebCore::KeypressCommand>& commands() const { return m_commands; }
+#elif PLATFORM(GTK)
+ const Vector<String>& commands() const { return m_commands; }
+#endif
bool isAutoRepeat() const { return m_isAutoRepeat; }
bool isKeypad() const { return m_isKeypad; }
bool isSystemKey() const { return m_isSystemKey; }
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, WebKeyboardEvent&);
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, WebKeyboardEvent&);
static bool isKeyboardEventType(Type);
private:
String m_text;
String m_unmodifiedText;
+#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
+ String m_key;
+#endif
+#if ENABLE(KEYBOARD_CODE_ATTRIBUTE)
+ String m_code;
+#endif
String m_keyIdentifier;
int32_t m_windowsVirtualKeyCode;
int32_t m_nativeVirtualKeyCode;
int32_t m_macCharCode;
+#if USE(APPKIT) || PLATFORM(GTK)
+ bool m_handledByInputMethod;
+#endif
+#if USE(APPKIT)
+ Vector<WebCore::KeypressCommand> m_commands;
+#elif PLATFORM(GTK)
+ Vector<String> m_commands;
+#endif
bool m_isAutoRepeat;
bool m_isKeypad;
bool m_isSystemKey;
@@ -250,6 +320,11 @@ public:
TouchCancelled
};
+ enum class TouchType {
+ Direct,
+ Stylus
+ };
+
WebPlatformTouchPoint() { }
WebPlatformTouchPoint(unsigned identifier, WebCore::IntPoint location, TouchPointState phase)
: m_identifier(identifier)
@@ -261,23 +336,52 @@ public:
unsigned identifier() const { return m_identifier; }
WebCore::IntPoint location() const { return m_location; }
TouchPointState phase() const { return static_cast<TouchPointState>(m_phase); }
+ TouchPointState state() const { return phase(); }
+
+#if ENABLE(IOS_TOUCH_EVENTS)
+ void setRadiusX(double radiusX) { m_radiusX = radiusX; }
+ double radiusX() const { return m_radiusX; }
+ void setRadiusY(double radiusY) { m_radiusY = radiusY; }
+ double radiusY() const { return m_radiusY; }
+ void setRotationAngle(double rotationAngle) { m_rotationAngle = rotationAngle; }
+ double rotationAngle() const { return m_rotationAngle; }
+ void setForce(double force) { m_force = force; }
+ double force() const { return m_force; }
+ void setAltitudeAngle(double altitudeAngle) { m_altitudeAngle = altitudeAngle; }
+ double altitudeAngle() const { return m_altitudeAngle; }
+ void setAzimuthAngle(double azimuthAngle) { m_azimuthAngle = azimuthAngle; }
+ double azimuthAngle() const { return m_azimuthAngle; }
+ void setTouchType(TouchType touchType) { m_touchType = static_cast<uint32_t>(touchType); }
+ TouchType touchType() const { return static_cast<TouchType>(m_touchType); }
+#endif
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, WebPlatformTouchPoint&);
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, WebPlatformTouchPoint&);
private:
unsigned m_identifier;
WebCore::IntPoint m_location;
uint32_t m_phase;
+#if ENABLE(IOS_TOUCH_EVENTS)
+ double m_radiusX { 0 };
+ double m_radiusY { 0 };
+ double m_rotationAngle { 0 };
+ double m_force { 0 };
+ double m_altitudeAngle { 0 };
+ double m_azimuthAngle { 0 };
+ uint32_t m_touchType { static_cast<uint32_t>(TouchType::Direct) };
+#endif
};
class WebTouchEvent : public WebEvent {
public:
WebTouchEvent() { }
- WebTouchEvent(WebEvent::Type type, Modifiers modifiers, double timestamp, const Vector<WebPlatformTouchPoint>& touchPoints, WebCore::IntPoint position, bool isGesture, float gestureScale, float gestureRotation)
+ WebTouchEvent(WebEvent::Type type, Modifiers modifiers, double timestamp, const Vector<WebPlatformTouchPoint>& touchPoints, WebCore::IntPoint position, bool isPotentialTap, bool isGesture, float gestureScale, float gestureRotation)
: WebEvent(type, modifiers, timestamp)
, m_touchPoints(touchPoints)
, m_position(position)
+ , m_canPreventNativeGestures(true)
+ , m_isPotentialTap(isPotentialTap)
, m_isGesture(isGesture)
, m_gestureScale(gestureScale)
, m_gestureRotation(gestureRotation)
@@ -289,17 +393,26 @@ public:
WebCore::IntPoint position() const { return m_position; }
+ bool isPotentialTap() const { return m_isPotentialTap; }
+
bool isGesture() const { return m_isGesture; }
float gestureScale() const { return m_gestureScale; }
float gestureRotation() const { return m_gestureRotation; }
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, WebTouchEvent&);
+ bool canPreventNativeGestures() const { return m_canPreventNativeGestures; }
+ void setCanPreventNativeGestures(bool canPreventNativeGestures) { m_canPreventNativeGestures = canPreventNativeGestures; }
+
+ bool allTouchPointsAreReleased() const;
+
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, WebTouchEvent&);
private:
Vector<WebPlatformTouchPoint> m_touchPoints;
WebCore::IntPoint m_position;
+ bool m_canPreventNativeGestures;
+ bool m_isPotentialTap;
bool m_isGesture;
float m_gestureScale;
float m_gestureRotation;
@@ -335,8 +448,8 @@ public:
void setState(TouchPointState state) { m_state = state; }
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, WebPlatformTouchPoint&);
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, WebPlatformTouchPoint&);
private:
uint32_t m_id;
@@ -352,14 +465,14 @@ private:
class WebTouchEvent : public WebEvent {
public:
WebTouchEvent() { }
-
- // FIXME: It would be nice not to have to copy the Vector here.
- WebTouchEvent(Type, Vector<WebPlatformTouchPoint>, Modifiers, double timestamp);
+ WebTouchEvent(Type, Vector<WebPlatformTouchPoint>&&, Modifiers, double timestamp);
const Vector<WebPlatformTouchPoint>& touchPoints() const { return m_touchPoints; }
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, WebTouchEvent&);
+ bool allTouchPointsAreReleased() const;
+
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, WebTouchEvent&);
private:
static bool isTouchEventType(Type);
diff --git a/Source/WebKit2/Shared/WebEventConversion.cpp b/Source/WebKit2/Shared/WebEventConversion.cpp
index 03fd0edb5..c46bf7431 100644
--- a/Source/WebKit2/Shared/WebEventConversion.cpp
+++ b/Source/WebKit2/Shared/WebEventConversion.cpp
@@ -28,6 +28,10 @@
#include "WebEvent.h"
+#if ENABLE(MAC_GESTURE_EVENTS)
+#include "WebGestureEvent.h"
+#endif
+
namespace WebKit {
class WebKit2PlatformMouseEvent : public WebCore::PlatformMouseEvent {
@@ -38,26 +42,42 @@ public:
switch (webEvent.type()) {
case WebEvent::MouseDown:
m_type = WebCore::PlatformEvent::MousePressed;
+ m_force = WebCore::ForceAtClick;
break;
case WebEvent::MouseUp:
m_type = WebCore::PlatformEvent::MouseReleased;
+ m_force = WebCore::ForceAtClick;
break;
case WebEvent::MouseMove:
m_type = WebCore::PlatformEvent::MouseMoved;
+ m_force = webEvent.force();
+ break;
+ case WebEvent::MouseForceChanged:
+ m_type = WebCore::PlatformEvent::MouseForceChanged;
+ m_force = webEvent.force();
+ break;
+ case WebEvent::MouseForceDown:
+ m_type = WebCore::PlatformEvent::MouseForceDown;
+ m_force = WebCore::ForceAtForceClick;
+ break;
+ case WebEvent::MouseForceUp:
+ m_type = WebCore::PlatformEvent::MouseForceUp;
+ m_force = WebCore::ForceAtForceClick;
break;
default:
ASSERT_NOT_REACHED();
}
- m_modifiers = 0;
if (webEvent.shiftKey())
- m_modifiers |= ShiftKey;
+ m_modifiers |= Modifier::ShiftKey;
if (webEvent.controlKey())
- m_modifiers |= CtrlKey;
+ m_modifiers |= Modifier::CtrlKey;
if (webEvent.altKey())
- m_modifiers |= AltKey;
+ m_modifiers |= Modifier::AltKey;
if (webEvent.metaKey())
- m_modifiers |= MetaKey;
+ m_modifiers |= Modifier::MetaKey;
+ if (webEvent.capsLockKey())
+ m_modifiers |= Modifier::CapsLockKey;
m_timestamp = webEvent.timestamp();
@@ -80,9 +100,15 @@ public:
}
m_position = webEvent.position();
+#if ENABLE(POINTER_LOCK)
+ m_movementDelta = WebCore::IntPoint(webEvent.deltaX(), webEvent.deltaY());
+#endif
m_globalPosition = webEvent.globalPosition();
m_clickCount = webEvent.clickCount();
-
+#if PLATFORM(MAC)
+ m_eventNumber = webEvent.eventNumber();
+ m_menuTypeForEvent = webEvent.menuTypeForEvent();
+#endif
m_modifierFlags = 0;
if (webEvent.shiftKey())
m_modifierFlags |= WebEvent::ShiftKey;
@@ -107,15 +133,16 @@ public:
// PlatformEvent
m_type = PlatformEvent::Wheel;
- m_modifiers = 0;
if (webEvent.shiftKey())
- m_modifiers |= ShiftKey;
+ m_modifiers |= Modifier::ShiftKey;
if (webEvent.controlKey())
- m_modifiers |= CtrlKey;
+ m_modifiers |= Modifier::CtrlKey;
if (webEvent.altKey())
- m_modifiers |= AltKey;
+ m_modifiers |= Modifier::AltKey;
if (webEvent.metaKey())
- m_modifiers |= MetaKey;
+ m_modifiers |= Modifier::MetaKey;
+ if (webEvent.capsLockKey())
+ m_modifiers |= Modifier::CapsLockKey;
m_timestamp = webEvent.timestamp();
@@ -128,7 +155,7 @@ public:
m_wheelTicksY = webEvent.wheelTicks().height();
m_granularity = (webEvent.granularity() == WebWheelEvent::ScrollByPageWheelEvent) ? WebCore::ScrollByPageWheelEvent : WebCore::ScrollByPixelWheelEvent;
m_directionInvertedFromDevice = webEvent.directionInvertedFromDevice();
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
m_phase = static_cast<WebCore::PlatformWheelEventPhase>(webEvent.phase());
m_momentumPhase = static_cast<WebCore::PlatformWheelEventPhase>(webEvent.momentumPhase());
m_hasPreciseScrollingDeltas = webEvent.hasPreciseScrollingDeltas();
@@ -166,25 +193,34 @@ public:
ASSERT_NOT_REACHED();
}
- m_modifiers = 0;
if (webEvent.shiftKey())
- m_modifiers |= ShiftKey;
+ m_modifiers |= Modifier::ShiftKey;
if (webEvent.controlKey())
- m_modifiers |= CtrlKey;
+ m_modifiers |= Modifier::CtrlKey;
if (webEvent.altKey())
- m_modifiers |= AltKey;
+ m_modifiers |= Modifier::AltKey;
if (webEvent.metaKey())
- m_modifiers |= MetaKey;
+ m_modifiers |= Modifier::MetaKey;
+ if (webEvent.capsLockKey())
+ m_modifiers |= Modifier::CapsLockKey;
m_timestamp = webEvent.timestamp();
// PlatformKeyboardEvent
m_text = webEvent.text();
m_unmodifiedText = webEvent.unmodifiedText();
+#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
+ m_key = webEvent.key();
+#endif
+#if ENABLE(KEYBOARD_CODE_ATTRIBUTE)
+ m_code = webEvent.code();
+#endif
m_keyIdentifier = webEvent.keyIdentifier();
m_windowsVirtualKeyCode = webEvent.windowsVirtualKeyCode();
- m_nativeVirtualKeyCode = webEvent.nativeVirtualKeyCode();
- m_macCharCode = webEvent.macCharCode();
+#if USE(APPKIT) || PLATFORM(GTK)
+ m_handledByInputMethod = webEvent.handledByInputMethod();
+ m_commands = webEvent.commands();
+#endif
m_autoRepeat = webEvent.isAutoRepeat();
m_isKeypad = webEvent.isKeypad();
m_isSystemKey = webEvent.isSystemKey();
@@ -199,6 +235,7 @@ WebCore::PlatformKeyboardEvent platform(const WebKeyboardEvent& webEvent)
#if ENABLE(TOUCH_EVENTS)
#if PLATFORM(IOS)
+
static WebCore::PlatformTouchPoint::TouchPhaseType touchEventType(const WebPlatformTouchPoint& webTouchPoint)
{
switch (webTouchPoint.phase()) {
@@ -215,13 +252,28 @@ static WebCore::PlatformTouchPoint::TouchPhaseType touchEventType(const WebPlatf
}
}
+static WebCore::PlatformTouchPoint::TouchType webPlatformTouchTypeToPlatform(const WebPlatformTouchPoint::TouchType& webTouchType)
+{
+ switch (webTouchType) {
+ case WebPlatformTouchPoint::TouchType::Direct:
+ return WebCore::PlatformTouchPoint::TouchType::Direct;
+ case WebPlatformTouchPoint::TouchType::Stylus:
+ return WebCore::PlatformTouchPoint::TouchType::Stylus;
+ }
+}
+
class WebKit2PlatformTouchPoint : public WebCore::PlatformTouchPoint {
public:
WebKit2PlatformTouchPoint(const WebPlatformTouchPoint& webTouchPoint)
- : PlatformTouchPoint(webTouchPoint.identifier(), webTouchPoint.location(), touchEventType(webTouchPoint))
+ : PlatformTouchPoint(webTouchPoint.identifier(), webTouchPoint.location(), touchEventType(webTouchPoint)
+#if ENABLE(IOS_TOUCH_EVENTS)
+ , webTouchPoint.radiusX(), webTouchPoint.radiusY(), webTouchPoint.rotationAngle(), webTouchPoint.force(), webTouchPoint.altitudeAngle(), webTouchPoint.azimuthAngle(), webPlatformTouchTypeToPlatform(webTouchPoint.touchType())
+#endif
+ )
{
}
};
+
#else
class WebKit2PlatformTouchPoint : public WebCore::PlatformTouchPoint {
@@ -282,15 +334,16 @@ public:
ASSERT_NOT_REACHED();
}
- m_modifiers = 0;
if (webEvent.shiftKey())
- m_modifiers |= ShiftKey;
+ m_modifiers |= Modifier::ShiftKey;
if (webEvent.controlKey())
- m_modifiers |= CtrlKey;
+ m_modifiers |= Modifier::CtrlKey;
if (webEvent.altKey())
- m_modifiers |= AltKey;
+ m_modifiers |= Modifier::AltKey;
if (webEvent.metaKey())
- m_modifiers |= MetaKey;
+ m_modifiers |= Modifier::MetaKey;
+ if (webEvent.capsLockKey())
+ m_modifiers |= Modifier::CapsLockKey;
m_timestamp = webEvent.timestamp();
@@ -302,7 +355,9 @@ public:
m_gestureScale = webEvent.gestureScale();
m_gestureRotation = webEvent.gestureRotation();
+ m_canPreventNativeGestures = webEvent.canPreventNativeGestures();
m_isGesture = webEvent.isGesture();
+ m_isPotentialTap = webEvent.isPotentialTap();
m_position = webEvent.position();
m_globalPosition = webEvent.position();
#else
@@ -319,4 +374,49 @@ WebCore::PlatformTouchEvent platform(const WebTouchEvent& webEvent)
}
#endif
+#if ENABLE(MAC_GESTURE_EVENTS)
+class WebKit2PlatformGestureEvent : public WebCore::PlatformGestureEvent {
+public:
+ WebKit2PlatformGestureEvent(const WebGestureEvent& webEvent)
+ {
+ switch (webEvent.type()) {
+ case WebEvent::GestureStart:
+ m_type = WebCore::PlatformEvent::GestureStart;
+ break;
+ case WebEvent::GestureChange:
+ m_type = WebCore::PlatformEvent::GestureChange;
+ break;
+ case WebEvent::GestureEnd:
+ m_type = WebCore::PlatformEvent::GestureEnd;
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+
+ if (webEvent.shiftKey())
+ m_modifiers |= Modifier::ShiftKey;
+ if (webEvent.controlKey())
+ m_modifiers |= Modifier::CtrlKey;
+ if (webEvent.altKey())
+ m_modifiers |= Modifier::AltKey;
+ if (webEvent.metaKey())
+ m_modifiers |= Modifier::MetaKey;
+ if (webEvent.capsLockKey())
+ m_modifiers |= Modifier::CapsLockKey;
+
+ m_timestamp = webEvent.timestamp();
+
+ m_gestureScale = webEvent.gestureScale();
+ m_gestureRotation = webEvent.gestureRotation();
+ m_position = webEvent.position();
+ m_globalPosition = webEvent.position();
+ }
+};
+
+WebCore::PlatformGestureEvent platform(const WebGestureEvent& webEvent)
+{
+ return WebKit2PlatformGestureEvent(webEvent);
+}
+#endif
+
} // namespace WebKit
diff --git a/Source/WebKit2/Shared/WebEventConversion.h b/Source/WebKit2/Shared/WebEventConversion.h
index 5c60e0283..827f4f7b2 100644
--- a/Source/WebKit2/Shared/WebEventConversion.h
+++ b/Source/WebKit2/Shared/WebEventConversion.h
@@ -30,13 +30,15 @@
#include <WebCore/PlatformMouseEvent.h>
#include <WebCore/PlatformWheelEvent.h>
-#if ENABLE(TOUCH_EVENTS)
-#if PLATFORM(IOS)
+#if ENABLE(IOS_TOUCH_EVENTS)
#include <WebKitAdditions/PlatformTouchEventIOS.h>
-#else
+#elif ENABLE(TOUCH_EVENTS)
#include <WebCore/PlatformTouchEvent.h>
#include <WebCore/PlatformTouchPoint.h>
#endif
+
+#if ENABLE(MAC_GESTURE_EVENTS)
+#include <WebKitAdditions/PlatformGestureEventMac.h>
#endif
namespace WebKit {
@@ -50,17 +52,25 @@ class WebTouchEvent;
class WebTouchPoint;
#endif
+#if ENABLE(MAC_GESTURE_EVENTS)
+class WebGestureEvent;
+#endif
+
WebCore::PlatformMouseEvent platform(const WebMouseEvent&);
WebCore::PlatformWheelEvent platform(const WebWheelEvent&);
WebCore::PlatformKeyboardEvent platform(const WebKeyboardEvent&);
#if ENABLE(TOUCH_EVENTS)
WebCore::PlatformTouchEvent platform(const WebTouchEvent&);
-#if !PLATFORM(IOS)
+#if !ENABLE(IOS_TOUCH_EVENTS)
WebCore::PlatformTouchPoint platform(const WebTouchPoint&);
#endif
#endif
+#if ENABLE(MAC_GESTURE_EVENTS)
+WebCore::PlatformGestureEvent platform(const WebGestureEvent&);
+#endif
+
} // namespace WebKit
#endif // WebEventConversion_h
diff --git a/Source/WebKit2/Shared/WebFindOptions.h b/Source/WebKit2/Shared/WebFindOptions.h
index 272b3d7d7..bda7c334f 100644
--- a/Source/WebKit2/Shared/WebFindOptions.h
+++ b/Source/WebKit2/Shared/WebFindOptions.h
@@ -36,7 +36,8 @@ enum FindOptions {
FindOptionsWrapAround = 1 << 4,
FindOptionsShowOverlay = 1 << 5,
FindOptionsShowFindIndicator = 1 << 6,
- FindOptionsShowHighlight = 1 << 7
+ FindOptionsShowHighlight = 1 << 7,
+ FindOptionsDetermineMatchIndex = 1 << 8,
};
} // namespace WebKit
diff --git a/Source/WebKit2/Shared/WebGeolocationPosition.cpp b/Source/WebKit2/Shared/WebGeolocationPosition.cpp
index 14b0345cf..bbf9fa54c 100644
--- a/Source/WebKit2/Shared/WebGeolocationPosition.cpp
+++ b/Source/WebKit2/Shared/WebGeolocationPosition.cpp
@@ -27,7 +27,6 @@
#include "WebGeolocationPosition.h"
#include "ArgumentCoders.h"
-#include "Arguments.h"
namespace WebKit {
@@ -51,12 +50,12 @@ WebGeolocationPosition::~WebGeolocationPosition()
{
}
-void WebGeolocationPosition::Data::encode(IPC::ArgumentEncoder& encoder) const
+void WebGeolocationPosition::Data::encode(IPC::Encoder& encoder) const
{
IPC::SimpleArgumentCoder<WebGeolocationPosition::Data>::encode(encoder, *this);
}
-bool WebGeolocationPosition::Data::decode(IPC::ArgumentDecoder& decoder, Data& data)
+bool WebGeolocationPosition::Data::decode(IPC::Decoder& decoder, Data& data)
{
return IPC::SimpleArgumentCoder<WebGeolocationPosition::Data>::decode(decoder, data);
}
diff --git a/Source/WebKit2/Shared/WebGeolocationPosition.h b/Source/WebKit2/Shared/WebGeolocationPosition.h
index 31105fb00..f4815e653 100644
--- a/Source/WebKit2/Shared/WebGeolocationPosition.h
+++ b/Source/WebKit2/Shared/WebGeolocationPosition.h
@@ -27,17 +27,20 @@
#define WebGeolocationPosition_h
#include "APIObject.h"
-#include "ArgumentEncoder.h"
-#include "ArgumentDecoder.h"
#include <wtf/PassRefPtr.h>
+namespace IPC {
+class Decoder;
+class Encoder;
+}
+
namespace WebKit {
class WebGeolocationPosition : public API::ObjectImpl<API::Object::Type::GeolocationPosition> {
public:
struct Data {
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, Data&);
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, Data&);
double timestamp;
double latitude;
diff --git a/Source/WebKit2/Shared/WebHitTestResult.cpp b/Source/WebKit2/Shared/WebHitTestResult.cpp
deleted file mode 100644
index 03c4d1e4c..000000000
--- a/Source/WebKit2/Shared/WebHitTestResult.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
- *
- * 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 "WebHitTestResult.h"
-
-#include "WebCoreArgumentCoders.h"
-#include <WebCore/Document.h>
-#include <WebCore/Frame.h>
-#include <WebCore/FrameView.h>
-#include <WebCore/HitTestResult.h>
-#include <WebCore/URL.h>
-#include <WebCore/Node.h>
-#include <wtf/text/WTFString.h>
-
-using namespace WebCore;
-
-namespace WebKit {
-
-PassRefPtr<WebHitTestResult> WebHitTestResult::create(const WebHitTestResult::Data& hitTestResultData)
-{
- return adoptRef(new WebHitTestResult(hitTestResultData));
-}
-
-WebHitTestResult::Data::Data()
-{
-}
-
-WebHitTestResult::Data::Data(const HitTestResult& hitTestResult)
- : absoluteImageURL(hitTestResult.absoluteImageURL().string())
- , absolutePDFURL(hitTestResult.absolutePDFURL().string())
- , absoluteLinkURL(hitTestResult.absoluteLinkURL().string())
- , absoluteMediaURL(hitTestResult.absoluteMediaURL().string())
- , linkLabel(hitTestResult.textContent())
- , linkTitle(hitTestResult.titleDisplayString())
- , isContentEditable(hitTestResult.isContentEditable())
- , elementBoundingBox(elementBoundingBoxInWindowCoordinates(hitTestResult))
- , isScrollbar(hitTestResult.scrollbar())
-{
-}
-
-WebHitTestResult::Data::~Data()
-{
-}
-
-void WebHitTestResult::Data::encode(IPC::ArgumentEncoder& encoder) const
-{
- encoder << absoluteImageURL;
- encoder << absolutePDFURL;
- encoder << absoluteLinkURL;
- encoder << absoluteMediaURL;
- encoder << linkLabel;
- encoder << linkTitle;
- encoder << isContentEditable;
- encoder << elementBoundingBox;
- encoder << isScrollbar;
-}
-
-bool WebHitTestResult::Data::decode(IPC::ArgumentDecoder& decoder, WebHitTestResult::Data& hitTestResultData)
-{
- if (!decoder.decode(hitTestResultData.absoluteImageURL)
- || !decoder.decode(hitTestResultData.absolutePDFURL)
- || !decoder.decode(hitTestResultData.absoluteLinkURL)
- || !decoder.decode(hitTestResultData.absoluteMediaURL)
- || !decoder.decode(hitTestResultData.linkLabel)
- || !decoder.decode(hitTestResultData.linkTitle)
- || !decoder.decode(hitTestResultData.isContentEditable)
- || !decoder.decode(hitTestResultData.elementBoundingBox)
- || !decoder.decode(hitTestResultData.isScrollbar))
- return false;
-
- return true;
-}
-
-IntRect WebHitTestResult::Data::elementBoundingBoxInWindowCoordinates(const HitTestResult& hitTestResult)
-{
- Node* node = hitTestResult.innerNonSharedNode();
- if (!node)
- return IntRect();
-
- Frame* frame = node->document().frame();
- if (!frame)
- return IntRect();
-
- FrameView* view = frame->view();
- if (!view)
- return IntRect();
-
- return view->contentsToWindow(node->pixelSnappedBoundingBox());
-}
-
-} // WebKit
diff --git a/Source/WebKit2/Shared/WebHitTestResult.h b/Source/WebKit2/Shared/WebHitTestResult.h
deleted file mode 100644
index a2075aa68..000000000
--- a/Source/WebKit2/Shared/WebHitTestResult.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
- *
- * 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.
- */
-
-#ifndef WebHitTestResult_h
-#define WebHitTestResult_h
-
-#include "APIObject.h"
-#include <WebCore/IntRect.h>
-#include <wtf/Forward.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefPtr.h>
-#include <wtf/text/WTFString.h>
-
-namespace IPC {
-class ArgumentDecoder;
-class ArgumentEncoder;
-}
-
-namespace WebCore {
-class HitTestResult;
-}
-
-namespace WebKit {
-
-class WebFrame;
-
-class WebHitTestResult : public API::ObjectImpl<API::Object::Type::HitTestResult> {
-public:
- struct Data {
- String absoluteImageURL;
- String absolutePDFURL;
- String absoluteLinkURL;
- String absoluteMediaURL;
- String linkLabel;
- String linkTitle;
- bool isContentEditable;
- WebCore::IntRect elementBoundingBox;
- bool isScrollbar;
-
- Data();
- explicit Data(const WebCore::HitTestResult&);
- ~Data();
-
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, WebHitTestResult::Data&);
-
- WebCore::IntRect elementBoundingBoxInWindowCoordinates(const WebCore::HitTestResult&);
- };
-
- static PassRefPtr<WebHitTestResult> create(const WebHitTestResult::Data&);
-
- String absoluteImageURL() const { return m_data.absoluteImageURL; }
- String absolutePDFURL() const { return m_data.absolutePDFURL; }
- String absoluteLinkURL() const { return m_data.absoluteLinkURL; }
- String absoluteMediaURL() const { return m_data.absoluteMediaURL; }
-
- String linkLabel() const { return m_data.linkLabel; }
- String linkTitle() const { return m_data.linkTitle; }
-
- bool isContentEditable() const { return m_data.isContentEditable; }
-
- WebCore::IntRect elementBoundingBox() const { return m_data.elementBoundingBox; }
-
- bool isScrollbar() const { return m_data.isScrollbar; }
-
-private:
- explicit WebHitTestResult(const WebHitTestResult::Data& hitTestResultData)
- : m_data(hitTestResultData)
- {
- }
-
- Data m_data;
-};
-
-} // namespace WebKit
-
-#endif // WebHitTestResult_h
diff --git a/Source/WebKit2/Shared/WebHitTestResultData.cpp b/Source/WebKit2/Shared/WebHitTestResultData.cpp
new file mode 100644
index 000000000..b7ce3e431
--- /dev/null
+++ b/Source/WebKit2/Shared/WebHitTestResultData.cpp
@@ -0,0 +1,209 @@
+/*
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * 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 "WebHitTestResultData.h"
+
+#include "WebCoreArgumentCoders.h"
+#include <WebCore/Document.h>
+#include <WebCore/Frame.h>
+#include <WebCore/FrameView.h>
+#include <WebCore/HitTestResult.h>
+#include <WebCore/Node.h>
+#include <WebCore/RenderObject.h>
+#include <WebCore/SharedBuffer.h>
+#include <WebCore/URL.h>
+#include <wtf/text/WTFString.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebHitTestResultData::WebHitTestResultData()
+{
+}
+
+WebHitTestResultData::WebHitTestResultData(const WebCore::HitTestResult& hitTestResult)
+ : absoluteImageURL(hitTestResult.absoluteImageURL().string())
+ , absolutePDFURL(hitTestResult.absolutePDFURL().string())
+ , absoluteLinkURL(hitTestResult.absoluteLinkURL().string())
+ , absoluteMediaURL(hitTestResult.absoluteMediaURL().string())
+ , linkLabel(hitTestResult.textContent())
+ , linkTitle(hitTestResult.titleDisplayString())
+ , linkSuggestedFilename(hitTestResult.URLElementDownloadAttribute().string())
+ , isContentEditable(hitTestResult.isContentEditable())
+ , elementBoundingBox(elementBoundingBoxInWindowCoordinates(hitTestResult))
+ , isScrollbar(hitTestResult.scrollbar())
+ , isSelected(hitTestResult.isSelected())
+ , isTextNode(hitTestResult.innerNode() && hitTestResult.innerNode()->isTextNode())
+ , isOverTextInsideFormControlElement(hitTestResult.isOverTextInsideFormControlElement())
+ , allowsCopy(hitTestResult.allowsCopy())
+ , isDownloadableMedia(hitTestResult.isDownloadableMedia())
+ , imageSize(0)
+{
+}
+
+WebHitTestResultData::WebHitTestResultData(const WebCore::HitTestResult& hitTestResult, bool includeImage)
+ : absoluteImageURL(hitTestResult.absoluteImageURL().string())
+ , absolutePDFURL(hitTestResult.absolutePDFURL().string())
+ , absoluteLinkURL(hitTestResult.absoluteLinkURL().string())
+ , absoluteMediaURL(hitTestResult.absoluteMediaURL().string())
+ , linkLabel(hitTestResult.textContent())
+ , linkTitle(hitTestResult.titleDisplayString())
+ , linkSuggestedFilename(hitTestResult.URLElementDownloadAttribute().string())
+ , isContentEditable(hitTestResult.isContentEditable())
+ , elementBoundingBox(elementBoundingBoxInWindowCoordinates(hitTestResult))
+ , isScrollbar(hitTestResult.scrollbar())
+ , isSelected(hitTestResult.isSelected())
+ , isTextNode(hitTestResult.innerNode() && hitTestResult.innerNode()->isTextNode())
+ , isOverTextInsideFormControlElement(hitTestResult.isOverTextInsideFormControlElement())
+ , allowsCopy(hitTestResult.allowsCopy())
+ , isDownloadableMedia(hitTestResult.isDownloadableMedia())
+ , imageSize(0)
+{
+ if (!includeImage)
+ return;
+
+ if (Image* image = hitTestResult.image()) {
+ RefPtr<SharedBuffer> buffer = image->data();
+ if (buffer) {
+ imageSharedMemory = WebKit::SharedMemory::allocate(buffer->size());
+ memcpy(imageSharedMemory->data(), buffer->data(), buffer->size());
+ imageSize = buffer->size();
+ }
+ }
+}
+
+WebHitTestResultData::~WebHitTestResultData()
+{
+}
+
+void WebHitTestResultData::encode(IPC::Encoder& encoder) const
+{
+ encoder << absoluteImageURL;
+ encoder << absolutePDFURL;
+ encoder << absoluteLinkURL;
+ encoder << absoluteMediaURL;
+ encoder << linkLabel;
+ encoder << linkTitle;
+ encoder << linkSuggestedFilename;
+ encoder << isContentEditable;
+ encoder << elementBoundingBox;
+ encoder << isScrollbar;
+ encoder << isSelected;
+ encoder << isTextNode;
+ encoder << isOverTextInsideFormControlElement;
+ encoder << allowsCopy;
+ encoder << isDownloadableMedia;
+ encoder << lookupText;
+ encoder << dictionaryPopupInfo;
+
+ WebKit::SharedMemory::Handle imageHandle;
+ if (imageSharedMemory && imageSharedMemory->data())
+ imageSharedMemory->createHandle(imageHandle, WebKit::SharedMemory::Protection::ReadOnly);
+ encoder << imageHandle;
+ encoder << imageSize;
+
+ bool hasLinkTextIndicator = linkTextIndicator;
+ encoder << hasLinkTextIndicator;
+ if (hasLinkTextIndicator)
+ encoder << linkTextIndicator->data();
+
+ platformEncode(encoder);
+}
+
+bool WebHitTestResultData::decode(IPC::Decoder& decoder, WebHitTestResultData& hitTestResultData)
+{
+ if (!decoder.decode(hitTestResultData.absoluteImageURL)
+ || !decoder.decode(hitTestResultData.absolutePDFURL)
+ || !decoder.decode(hitTestResultData.absoluteLinkURL)
+ || !decoder.decode(hitTestResultData.absoluteMediaURL)
+ || !decoder.decode(hitTestResultData.linkLabel)
+ || !decoder.decode(hitTestResultData.linkTitle)
+ || !decoder.decode(hitTestResultData.linkSuggestedFilename)
+ || !decoder.decode(hitTestResultData.isContentEditable)
+ || !decoder.decode(hitTestResultData.elementBoundingBox)
+ || !decoder.decode(hitTestResultData.isScrollbar)
+ || !decoder.decode(hitTestResultData.isSelected)
+ || !decoder.decode(hitTestResultData.isTextNode)
+ || !decoder.decode(hitTestResultData.isOverTextInsideFormControlElement)
+ || !decoder.decode(hitTestResultData.allowsCopy)
+ || !decoder.decode(hitTestResultData.isDownloadableMedia)
+ || !decoder.decode(hitTestResultData.lookupText)
+ || !decoder.decode(hitTestResultData.dictionaryPopupInfo))
+ return false;
+
+ WebKit::SharedMemory::Handle imageHandle;
+ if (!decoder.decode(imageHandle))
+ return false;
+
+ if (!imageHandle.isNull())
+ hitTestResultData.imageSharedMemory = WebKit::SharedMemory::map(imageHandle, WebKit::SharedMemory::Protection::ReadOnly);
+
+ if (!decoder.decode(hitTestResultData.imageSize))
+ return false;
+
+ bool hasLinkTextIndicator;
+ if (!decoder.decode(hasLinkTextIndicator))
+ return false;
+
+ if (hasLinkTextIndicator) {
+ WebCore::TextIndicatorData indicatorData;
+ if (!decoder.decode(indicatorData))
+ return false;
+
+ hitTestResultData.linkTextIndicator = WebCore::TextIndicator::create(indicatorData);
+ }
+
+ return platformDecode(decoder, hitTestResultData);
+}
+
+#if !PLATFORM(MAC)
+void WebHitTestResultData::platformEncode(IPC::Encoder& encoder) const
+{
+}
+
+bool WebHitTestResultData::platformDecode(IPC::Decoder& decoder, WebHitTestResultData& hitTestResultData)
+{
+ return true;
+}
+#endif // !PLATFORM(MAC)
+
+IntRect WebHitTestResultData::elementBoundingBoxInWindowCoordinates(const WebCore::HitTestResult& hitTestResult)
+{
+ Node* node = hitTestResult.innerNonSharedNode();
+ if (!node)
+ return IntRect();
+
+ Frame* frame = node->document().frame();
+ if (!frame)
+ return IntRect();
+
+ FrameView* view = frame->view();
+ if (!view)
+ return IntRect();
+
+ RenderObject* renderer = node->renderer();
+ if (!renderer)
+ return IntRect();
+
+ return view->contentsToWindow(renderer->absoluteBoundingBoxRect());
+}
+
+} // WebKit
diff --git a/Source/WebKit2/Shared/WebHitTestResultData.h b/Source/WebKit2/Shared/WebHitTestResultData.h
new file mode 100644
index 000000000..32468aba9
--- /dev/null
+++ b/Source/WebKit2/Shared/WebHitTestResultData.h
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * 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.
+ */
+
+#ifndef WebHitTestResultData_h
+#define WebHitTestResultData_h
+
+#include "APIObject.h"
+#include "SharedMemory.h"
+#include <WebCore/DictionaryPopupInfo.h>
+#include <WebCore/FloatPoint.h>
+#include <WebCore/IntRect.h>
+#include <WebCore/PageOverlay.h>
+#include <wtf/Forward.h>
+#include <wtf/RefPtr.h>
+#include <wtf/text/WTFString.h>
+
+OBJC_CLASS DDActionContext;
+
+namespace IPC {
+class Decoder;
+class Encoder;
+}
+
+namespace WebCore {
+class HitTestResult;
+}
+
+namespace WebKit {
+
+struct WebHitTestResultData {
+ String absoluteImageURL;
+ String absolutePDFURL;
+ String absoluteLinkURL;
+ String absoluteMediaURL;
+ String linkLabel;
+ String linkTitle;
+ String linkSuggestedFilename;
+ bool isContentEditable;
+ WebCore::IntRect elementBoundingBox;
+ bool isScrollbar;
+ bool isSelected;
+ bool isTextNode;
+ bool isOverTextInsideFormControlElement;
+ bool allowsCopy;
+ bool isDownloadableMedia;
+
+ String lookupText;
+ RefPtr<WebKit::SharedMemory> imageSharedMemory;
+ uint64_t imageSize;
+
+#if PLATFORM(MAC)
+ RetainPtr<DDActionContext> detectedDataActionContext;
+#endif
+ WebCore::FloatRect detectedDataBoundingBox;
+ RefPtr<WebCore::TextIndicator> detectedDataTextIndicator;
+ WebCore::PageOverlay::PageOverlayID detectedDataOriginatingPageOverlay;
+
+ WebCore::DictionaryPopupInfo dictionaryPopupInfo;
+
+ RefPtr<WebCore::TextIndicator> linkTextIndicator;
+
+ WebHitTestResultData();
+ explicit WebHitTestResultData(const WebCore::HitTestResult&);
+ WebHitTestResultData(const WebCore::HitTestResult&, bool includeImage);
+ ~WebHitTestResultData();
+
+ void encode(IPC::Encoder&) const;
+ void platformEncode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, WebHitTestResultData&);
+ static bool platformDecode(IPC::Decoder&, WebHitTestResultData&);
+
+ WebCore::IntRect elementBoundingBoxInWindowCoordinates(const WebCore::HitTestResult&);
+};
+
+} // namespace WebKit
+
+#endif // WebHitTestResultData_h
diff --git a/Source/WebKit2/Shared/WebImage.cpp b/Source/WebKit2/Shared/WebImage.cpp
index b0e4bff61..49bc87bab 100644
--- a/Source/WebKit2/Shared/WebImage.cpp
+++ b/Source/WebKit2/Shared/WebImage.cpp
@@ -32,22 +32,28 @@ using namespace WebCore;
namespace WebKit {
-PassRefPtr<WebImage> WebImage::create(const IntSize& size, ImageOptions options)
+RefPtr<WebImage> WebImage::create(const IntSize& size, ImageOptions options)
{
- if (options & ImageOptionsShareable)
- return WebImage::create(ShareableBitmap::createShareable(size, ShareableBitmap::SupportsAlpha));
- return WebImage::create(ShareableBitmap::create(size, ShareableBitmap::SupportsAlpha));
+ if (options & ImageOptionsShareable) {
+ auto bitmap = ShareableBitmap::createShareable(size, ShareableBitmap::SupportsAlpha);
+ if (!bitmap)
+ return nullptr;
+ return WebImage::create(bitmap.releaseNonNull());
+ }
+ auto bitmap = ShareableBitmap::create(size, ShareableBitmap::SupportsAlpha);
+ if (!bitmap)
+ return nullptr;
+ return WebImage::create(bitmap.releaseNonNull());
}
-PassRefPtr<WebImage> WebImage::create(PassRefPtr<ShareableBitmap> bitmap)
+Ref<WebImage> WebImage::create(Ref<ShareableBitmap>&& bitmap)
{
- return adoptRef(new WebImage(bitmap));
+ return adoptRef(*new WebImage(WTFMove(bitmap)));
}
-WebImage::WebImage(PassRefPtr<ShareableBitmap> bitmap)
- : m_bitmap(bitmap)
+WebImage::WebImage(Ref<ShareableBitmap>&& bitmap)
+ : m_bitmap(WTFMove(bitmap))
{
- ASSERT(m_bitmap);
}
WebImage::~WebImage()
diff --git a/Source/WebKit2/Shared/WebImage.h b/Source/WebKit2/Shared/WebImage.h
index 4bd07b00a..4574c9e49 100644
--- a/Source/WebKit2/Shared/WebImage.h
+++ b/Source/WebKit2/Shared/WebImage.h
@@ -23,15 +23,14 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef WebImage_h
-#define WebImage_h
+#pragma once
#include "APIObject.h"
#include "ImageOptions.h"
-#include <wtf/RefPtr.h>
+#include <wtf/Ref.h>
namespace WebCore {
- class IntSize;
+class IntSize;
}
namespace WebKit {
@@ -42,20 +41,19 @@ class ShareableBitmap;
class WebImage : public API::ObjectImpl<API::Object::Type::Image> {
public:
- static PassRefPtr<WebImage> create(const WebCore::IntSize&, ImageOptions);
- static PassRefPtr<WebImage> create(PassRefPtr<ShareableBitmap>);
+ static RefPtr<WebImage> create(const WebCore::IntSize&, ImageOptions);
+ static Ref<WebImage> create(Ref<ShareableBitmap>&&);
~WebImage();
const WebCore::IntSize& size() const;
- ShareableBitmap* bitmap() const { return m_bitmap.get(); }
+ ShareableBitmap& bitmap() { return m_bitmap.get(); }
+ const ShareableBitmap& bitmap() const { return m_bitmap.get(); }
private:
- WebImage(PassRefPtr<ShareableBitmap>);
+ WebImage(Ref<ShareableBitmap>&&);
- RefPtr<ShareableBitmap> m_bitmap;
+ Ref<ShareableBitmap> m_bitmap;
};
} // namespace WebKit
-
-#endif // WebImage_h
diff --git a/Source/WebKit2/Shared/WebKeyboardEvent.cpp b/Source/WebKit2/Shared/WebKeyboardEvent.cpp
index 8aef309e3..eb4771fda 100644
--- a/Source/WebKit2/Shared/WebKeyboardEvent.cpp
+++ b/Source/WebKit2/Shared/WebKeyboardEvent.cpp
@@ -27,9 +27,85 @@
#include "WebEvent.h"
#include "WebCoreArgumentCoders.h"
+#include <WebCore/KeypressCommand.h>
namespace WebKit {
+WebKeyboardEvent::WebKeyboardEvent()
+{
+}
+
+#if USE(APPKIT)
+
+WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool handledByInputMethod, const Vector<WebCore::KeypressCommand>& commands, bool isAutoRepeat, bool isKeypad, bool isSystemKey, Modifiers modifiers, double timestamp)
+ : WebEvent(type, modifiers, timestamp)
+ , m_text(text)
+ , m_unmodifiedText(unmodifiedText)
+#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
+ , m_key(key)
+#endif
+#if ENABLE(KEYBOARD_CODE_ATTRIBUTE)
+ , m_code(code)
+#endif
+ , m_keyIdentifier(keyIdentifier)
+ , m_windowsVirtualKeyCode(windowsVirtualKeyCode)
+ , m_nativeVirtualKeyCode(nativeVirtualKeyCode)
+ , m_macCharCode(macCharCode)
+ , m_handledByInputMethod(handledByInputMethod)
+ , m_commands(commands)
+ , m_isAutoRepeat(isAutoRepeat)
+ , m_isKeypad(isKeypad)
+ , m_isSystemKey(isSystemKey)
+{
+ ASSERT(isKeyboardEventType(type));
+}
+
+#elif PLATFORM(GTK)
+
+WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool handledByInputMethod, Vector<String>&& commands, bool isKeypad, Modifiers modifiers, double timestamp)
+ : WebEvent(type, modifiers, timestamp)
+ , m_text(text)
+ , m_unmodifiedText(text)
+ , m_key(key)
+ , m_code(code)
+ , m_keyIdentifier(keyIdentifier)
+ , m_windowsVirtualKeyCode(windowsVirtualKeyCode)
+ , m_nativeVirtualKeyCode(nativeVirtualKeyCode)
+ , m_macCharCode(0)
+ , m_handledByInputMethod(handledByInputMethod)
+ , m_commands(WTFMove(commands))
+ , m_isAutoRepeat(false)
+ , m_isKeypad(isKeypad)
+ , m_isSystemKey(false)
+{
+ ASSERT(isKeyboardEventType(type));
+}
+
+#elif PLATFORM(IOS)
+
+WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, Modifiers modifiers, double timestamp)
+ : WebEvent(type, modifiers, timestamp)
+ , m_text(text)
+ , m_unmodifiedText(unmodifiedText)
+#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
+ , m_key(key)
+#endif
+#if ENABLE(KEYBOARD_CODE_ATTRIBUTE)
+ , m_code(code)
+#endif
+ , m_keyIdentifier(keyIdentifier)
+ , m_windowsVirtualKeyCode(windowsVirtualKeyCode)
+ , m_nativeVirtualKeyCode(nativeVirtualKeyCode)
+ , m_macCharCode(macCharCode)
+ , m_isAutoRepeat(isAutoRepeat)
+ , m_isKeypad(isKeypad)
+ , m_isSystemKey(isSystemKey)
+{
+ ASSERT(isKeyboardEventType(type));
+}
+
+#else
+
WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String& unmodifiedText, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, Modifiers modifiers, double timestamp)
: WebEvent(type, modifiers, timestamp)
, m_text(text)
@@ -45,22 +121,38 @@ WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String&
ASSERT(isKeyboardEventType(type));
}
-void WebKeyboardEvent::encode(IPC::ArgumentEncoder& encoder) const
+#endif
+
+WebKeyboardEvent::~WebKeyboardEvent()
+{
+}
+
+void WebKeyboardEvent::encode(IPC::Encoder& encoder) const
{
WebEvent::encode(encoder);
encoder << m_text;
encoder << m_unmodifiedText;
+#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
+ encoder << m_key;
+#endif
+#if ENABLE(KEYBOARD_CODE_ATTRIBUTE)
+ encoder << m_code;
+#endif
encoder << m_keyIdentifier;
encoder << m_windowsVirtualKeyCode;
encoder << m_nativeVirtualKeyCode;
encoder << m_macCharCode;
+#if USE(APPKIT) || PLATFORM(GTK)
+ encoder << m_handledByInputMethod;
+ encoder << m_commands;
+#endif
encoder << m_isAutoRepeat;
encoder << m_isKeypad;
encoder << m_isSystemKey;
}
-bool WebKeyboardEvent::decode(IPC::ArgumentDecoder& decoder, WebKeyboardEvent& result)
+bool WebKeyboardEvent::decode(IPC::Decoder& decoder, WebKeyboardEvent& result)
{
if (!WebEvent::decode(decoder, result))
return false;
@@ -69,6 +161,14 @@ bool WebKeyboardEvent::decode(IPC::ArgumentDecoder& decoder, WebKeyboardEvent& r
return false;
if (!decoder.decode(result.m_unmodifiedText))
return false;
+#if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
+ if (!decoder.decode(result.m_key))
+ return false;
+#endif
+#if ENABLE(KEYBOARD_CODE_ATTRIBUTE)
+ if (!decoder.decode(result.m_code))
+ return false;
+#endif
if (!decoder.decode(result.m_keyIdentifier))
return false;
if (!decoder.decode(result.m_windowsVirtualKeyCode))
@@ -77,6 +177,12 @@ bool WebKeyboardEvent::decode(IPC::ArgumentDecoder& decoder, WebKeyboardEvent& r
return false;
if (!decoder.decode(result.m_macCharCode))
return false;
+#if USE(APPKIT) || PLATFORM(GTK)
+ if (!decoder.decode(result.m_handledByInputMethod))
+ return false;
+ if (!decoder.decode(result.m_commands))
+ return false;
+#endif
if (!decoder.decode(result.m_isAutoRepeat))
return false;
if (!decoder.decode(result.m_isKeypad))
diff --git a/Source/WebKit2/Shared/WebKit2Initialize.cpp b/Source/WebKit2/Shared/WebKit2Initialize.cpp
index ef3cd948d..c5637c74a 100644
--- a/Source/WebKit2/Shared/WebKit2Initialize.cpp
+++ b/Source/WebKit2/Shared/WebKit2Initialize.cpp
@@ -26,13 +26,13 @@
#include "config.h"
#include "WebKit2Initialize.h"
-#include "Logging.h"
-#include <WebCore/Logging.h>
+#include "LogInitialization.h"
+#include <WebCore/LogInitialization.h>
#include <runtime/InitializeThreading.h>
#include <wtf/MainThread.h>
#include <wtf/RunLoop.h>
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
#include "WebSystemInterface.h"
#endif
#if PLATFORM(IOS)
@@ -43,7 +43,7 @@ namespace WebKit {
void InitializeWebKit2()
{
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
InitWebCoreSystemInterface();
#endif
#if PLATFORM(IOS)
@@ -51,13 +51,12 @@ void InitializeWebKit2()
#endif
JSC::initializeThreading();
- WTF::initializeMainThread();
RunLoop::initializeMainRunLoop();
-#if !LOG_DISABLED
- WebCore::initializeLoggingChannelsIfNecessary();
+#if !LOG_DISABLED || !RELEASE_LOG_DISABLED
+ WebCore::initializeLogChannelsIfNecessary();
WebKit::initializeLogChannelsIfNecessary();
-#endif // !LOG_DISABLED
+#endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED
}
} // namespace WebKit
diff --git a/Source/WebKit2/Shared/WebKit2Initialize.h b/Source/WebKit2/Shared/WebKit2Initialize.h
index db91d0715..da4496646 100644
--- a/Source/WebKit2/Shared/WebKit2Initialize.h
+++ b/Source/WebKit2/Shared/WebKit2Initialize.h
@@ -23,13 +23,10 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef WebKit2Initialize_h
-#define WebKit2Initialize_h
+#pragma once
namespace WebKit {
void InitializeWebKit2();
};
-
-#endif // WebKit2Initialize_h
diff --git a/Source/WebKit2/Shared/Downloads/gtk/DownloadSoupErrorsGtk.cpp b/Source/WebKit2/Shared/WebMediaSessionMetadata.cpp
index 0d3f9d3ed..c03d1731b 100644
--- a/Source/WebKit2/Shared/Downloads/gtk/DownloadSoupErrorsGtk.cpp
+++ b/Source/WebKit2/Shared/WebMediaSessionMetadata.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ * 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
@@ -24,23 +24,28 @@
*/
#include "config.h"
-#include "DownloadSoupErrors.h"
+#include "WebMediaSessionMetadata.h"
-#include <WebCore/ErrorsGtk.h>
-#include <WebCore/ResourceError.h>
+#if ENABLE(MEDIA_SESSION)
using namespace WebCore;
namespace WebKit {
-ResourceError platformDownloadNetworkError(int errorCode, const String& failingURL, const String& localizedDescription)
+Ref<WebMediaSessionMetadata> WebMediaSessionMetadata::create(const MediaSessionMetadata& metadata)
{
- return downloadNetworkError(ResourceError(errorDomainDownload, errorCode, failingURL, localizedDescription));
+ return adoptRef(*new WebMediaSessionMetadata(metadata));
}
-ResourceError platformDownloadDestinationError(const ResourceResponse& response, const String& message)
+WebMediaSessionMetadata::WebMediaSessionMetadata(const MediaSessionMetadata& metadata)
+ : m_metadata(metadata)
+{
+}
+
+WebMediaSessionMetadata::~WebMediaSessionMetadata()
{
- return downloadDestinationError(response, message);
}
} // namespace WebKit
+
+#endif // ENABLE(MEDIA_SESSION)
diff --git a/Source/WebKit2/Shared/WebOpenPanelParameters.h b/Source/WebKit2/Shared/WebMediaSessionMetadata.h
index fec5c9b72..7c30dd683 100644
--- a/Source/WebKit2/Shared/WebOpenPanelParameters.h
+++ b/Source/WebKit2/Shared/WebMediaSessionMetadata.h
@@ -1,6 +1,5 @@
/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
- * Copyright (C) 2012 Samsung Electronics. All rights reserved.
+ * 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
@@ -24,38 +23,35 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef WebOpenPanelParameters_h
-#define WebOpenPanelParameters_h
+#ifndef WebMediaSessionMetadata_h
+#define WebMediaSessionMetadata_h
+
+#if ENABLE(MEDIA_SESSION)
#include "APIObject.h"
-#include <WebCore/FileChooser.h>
-#include <wtf/Vector.h>
+#include <WebCore/MediaSessionMetadata.h>
#include <wtf/text/WTFString.h>
-namespace API {
-class Array;
-}
-
namespace WebKit {
-class WebOpenPanelParameters : public API::ObjectImpl<API::Object::Type::OpenPanelParameters> {
+class WebMediaSessionMetadata : public API::ObjectImpl<API::Object::Type::MediaSessionMetadata> {
public:
- static PassRefPtr<WebOpenPanelParameters> create(const WebCore::FileChooserSettings&);
- ~WebOpenPanelParameters();
+ static Ref<WebMediaSessionMetadata> create(const WebCore::MediaSessionMetadata&);
+ ~WebMediaSessionMetadata();
- bool allowMultipleFiles() const { return m_settings.allowsMultipleFiles; }
- PassRefPtr<API::Array> acceptMIMETypes() const;
- PassRefPtr<API::Array> selectedFileNames() const;
-#if ENABLE(MEDIA_CAPTURE)
- String capture() const;
-#endif
+ String title() const { return m_metadata.title(); }
+ String artist() const { return m_metadata.artist(); }
+ String album() const { return m_metadata.album(); }
+ String artworkURL() const { return m_metadata.artworkURL().string(); }
private:
- explicit WebOpenPanelParameters(const WebCore::FileChooserSettings&);
+ explicit WebMediaSessionMetadata(const WebCore::MediaSessionMetadata&);
- WebCore::FileChooserSettings m_settings;
+ WebCore::MediaSessionMetadata m_metadata;
};
} // namespace WebKit
-#endif // WebOpenPanelParameters_h
+#endif // ENABLE(MEDIA_SESSION)
+
+#endif // WebMediaSessionMetadata_h
diff --git a/Source/WebKit2/Shared/WebMemorySampler.cpp b/Source/WebKit2/Shared/WebMemorySampler.cpp
new file mode 100644
index 000000000..053fa6ea2
--- /dev/null
+++ b/Source/WebKit2/Shared/WebMemorySampler.cpp
@@ -0,0 +1,190 @@
+/*
+ * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 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.
+ *
+ */
+
+#include "config.h"
+#include "WebMemorySampler.h"
+
+#if ENABLE(MEMORY_SAMPLER)
+
+#include <stdio.h>
+#include <unistd.h>
+#include <wtf/text/CString.h>
+#include <wtf/text/StringBuilder.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static const char separator = '\t';
+
+static void appendSpaces(StringBuilder& string, int count)
+{
+ for (int i = 0; i < count; ++i)
+ string.append(' ');
+}
+
+WebMemorySampler* WebMemorySampler::singleton()
+{
+ static WebMemorySampler* sharedMemorySampler;
+ if (!sharedMemorySampler)
+ sharedMemorySampler = new WebMemorySampler();
+ return sharedMemorySampler;
+}
+
+WebMemorySampler::WebMemorySampler()
+ : m_sampleTimer(*this, &WebMemorySampler::sampleTimerFired)
+ , m_stopTimer(*this, &WebMemorySampler::stopTimerFired)
+ , m_isRunning(false)
+ , m_runningTime(0)
+{
+}
+
+void WebMemorySampler::start(const double interval)
+{
+ if (m_isRunning)
+ return;
+
+ initializeTempLogFile();
+ initializeTimers(interval);
+}
+
+void WebMemorySampler::start(const SandboxExtension::Handle& sampleLogFileHandle, const String& sampleLogFilePath, const double interval)
+{
+ if (m_isRunning)
+ return;
+
+ // If we are on a system without SandboxExtension the handle and filename will be empty
+ if (sampleLogFilePath.isEmpty()) {
+ start(interval);
+ return;
+ }
+
+ initializeSandboxedLogFile(sampleLogFileHandle, sampleLogFilePath);
+ initializeTimers(interval);
+
+}
+
+void WebMemorySampler::initializeTimers(double interval)
+{
+ m_sampleTimer.startRepeating(1);
+ printf("Started memory sampler for process %s %d", processName().utf8().data(), getpid());
+ if (interval > 0) {
+ m_stopTimer.startOneShot(interval);
+ printf(" for a interval of %g seconds", interval);
+ }
+ printf("; Sampler log file stored at: %s\n", m_sampleLogFilePath.utf8().data());
+ m_runningTime = interval;
+ m_isRunning = true;
+}
+
+void WebMemorySampler::stop()
+{
+ if (!m_isRunning)
+ return;
+ m_sampleTimer.stop();
+ closeFile(m_sampleLogFile);
+
+ printf("Stopped memory sampler for process %s %d\n", processName().utf8().data(), getpid());
+ // Flush stdout buffer so python script can be guaranteed to read up to this point.
+ fflush(stdout);
+ m_isRunning = false;
+
+ if (m_stopTimer.isActive())
+ m_stopTimer.stop();
+
+ if (m_sampleLogSandboxExtension) {
+ m_sampleLogSandboxExtension->revoke();
+ m_sampleLogSandboxExtension = nullptr;
+ }
+}
+
+bool WebMemorySampler::isRunning() const
+{
+ return m_isRunning;
+}
+
+void WebMemorySampler::initializeTempLogFile()
+{
+ m_sampleLogFilePath = openTemporaryFile(processName(), m_sampleLogFile);
+ writeHeaders();
+}
+
+void WebMemorySampler::initializeSandboxedLogFile(const SandboxExtension::Handle& sampleLogSandboxHandle, const String& sampleLogFilePath)
+{
+ m_sampleLogSandboxExtension = SandboxExtension::create(sampleLogSandboxHandle);
+ if (m_sampleLogSandboxExtension)
+ m_sampleLogSandboxExtension->consume();
+ m_sampleLogFilePath = sampleLogFilePath;
+ m_sampleLogFile = openFile(m_sampleLogFilePath, OpenForWrite);
+ writeHeaders();
+}
+
+void WebMemorySampler::writeHeaders()
+{
+ String processDetails = String::format("Process: %s Pid: %d\n", processName().utf8().data(), getpid());
+
+ CString utf8String = processDetails.utf8();
+ writeToFile(m_sampleLogFile, utf8String.data(), utf8String.length());
+}
+
+void WebMemorySampler::sampleTimerFired()
+{
+ sendMemoryPressureEvent();
+ appendCurrentMemoryUsageToFile(m_sampleLogFile);
+}
+
+void WebMemorySampler::stopTimerFired()
+{
+ if (!m_isRunning)
+ return;
+ printf("%g seconds elapsed. Stopping memory sampler...\n", m_runningTime);
+ stop();
+}
+
+void WebMemorySampler::appendCurrentMemoryUsageToFile(PlatformFileHandle&)
+{
+ // Collect statistics from allocators and get RSIZE metric
+ StringBuilder statString;
+ WebMemoryStatistics memoryStats = sampleWebKit();
+
+ if (!memoryStats.values.isEmpty()) {
+ statString.append(separator);
+ for (size_t i = 0; i < memoryStats.values.size(); ++i) {
+ statString.append('\n');
+ statString.append(separator);
+ statString.append(memoryStats.keys[i]);
+ appendSpaces(statString, 35 - memoryStats.keys[i].length());
+ statString.appendNumber(memoryStats.values[i]);
+ }
+ }
+ statString.append('\n');
+
+ CString utf8String = statString.toString().utf8();
+ writeToFile(m_sampleLogFile, utf8String.data(), utf8String.length());
+}
+
+}
+
+#endif
diff --git a/Source/WebKit2/Shared/WebMemorySampler.h b/Source/WebKit2/Shared/WebMemorySampler.h
index 548e50759..2787b515d 100644
--- a/Source/WebKit2/Shared/WebMemorySampler.h
+++ b/Source/WebKit2/Shared/WebMemorySampler.h
@@ -71,7 +71,7 @@ struct WebMemoryStatistics {
class WebMemorySampler {
WTF_MAKE_NONCOPYABLE(WebMemorySampler);
public:
- static WebMemorySampler* shared();
+ static WebMemorySampler* singleton();
void start(const double interval = 0);
void start(const SandboxExtension::Handle&, const String&, const double interval = 0);
void stop();
@@ -85,8 +85,8 @@ private:
void initializeSandboxedLogFile(const SandboxExtension::Handle&, const String&);
void writeHeaders();
void initializeTimers(double);
- void sampleTimerFired(WebCore::Timer<WebMemorySampler>*);
- void stopTimerFired(WebCore::Timer<WebMemorySampler>*);
+ void sampleTimerFired();
+ void stopTimerFired();
void appendCurrentMemoryUsageToFile(WebCore::PlatformFileHandle&);
void sendMemoryPressureEvent();
@@ -95,10 +95,10 @@ private:
WebMemoryStatistics sampleWebKit() const;
String processName() const;
- WebCore::PlatformFileHandle m_sampleLogFile;
+ WebCore::PlatformFileHandle m_sampleLogFile { WebCore::invalidPlatformFileHandle };
String m_sampleLogFilePath;
- WebCore::Timer<WebMemorySampler> m_sampleTimer;
- WebCore::Timer<WebMemorySampler> m_stopTimer;
+ WebCore::Timer m_sampleTimer;
+ WebCore::Timer m_stopTimer;
bool m_isRunning;
double m_runningTime;
RefPtr<SandboxExtension> m_sampleLogSandboxExtension;
diff --git a/Source/WebKit2/Shared/WebMouseEvent.cpp b/Source/WebKit2/Shared/WebMouseEvent.cpp
index 2d400a4c0..8da8d3fe8 100644
--- a/Source/WebKit2/Shared/WebMouseEvent.cpp
+++ b/Source/WebKit2/Shared/WebMouseEvent.cpp
@@ -26,7 +26,6 @@
#include "config.h"
#include "WebEvent.h"
-#include "Arguments.h"
#include "WebCoreArgumentCoders.h"
using namespace WebCore;
@@ -40,10 +39,18 @@ WebMouseEvent::WebMouseEvent()
, m_deltaY(0)
, m_deltaZ(0)
, m_clickCount(0)
+#if PLATFORM(MAC)
+ , m_eventNumber(-1)
+ , m_menuTypeForEvent(0)
+#endif
{
}
-WebMouseEvent::WebMouseEvent(Type type, Button button, const IntPoint& position, const IntPoint& globalPosition, float deltaX, float deltaY, float deltaZ, int clickCount, Modifiers modifiers, double timestamp)
+#if PLATFORM(MAC)
+WebMouseEvent::WebMouseEvent(Type type, Button button, const IntPoint& position, const IntPoint& globalPosition, float deltaX, float deltaY, float deltaZ, int clickCount, Modifiers modifiers, double timestamp, double force, SyntheticClickType syntheticClickType, int eventNumber, int menuType)
+#else
+WebMouseEvent::WebMouseEvent(Type type, Button button, const IntPoint& position, const IntPoint& globalPosition, float deltaX, float deltaY, float deltaZ, int clickCount, Modifiers modifiers, double timestamp, double force, SyntheticClickType syntheticClickType)
+#endif
: WebEvent(type, modifiers, timestamp)
, m_button(button)
, m_position(position)
@@ -52,11 +59,17 @@ WebMouseEvent::WebMouseEvent(Type type, Button button, const IntPoint& position,
, m_deltaY(deltaY)
, m_deltaZ(deltaZ)
, m_clickCount(clickCount)
+#if PLATFORM(MAC)
+ , m_eventNumber(eventNumber)
+ , m_menuTypeForEvent(menuType)
+#endif
+ , m_force(force)
+ , m_syntheticClickType(syntheticClickType)
{
ASSERT(isMouseEventType(type));
}
-void WebMouseEvent::encode(IPC::ArgumentEncoder& encoder) const
+void WebMouseEvent::encode(IPC::Encoder& encoder) const
{
WebEvent::encode(encoder);
@@ -67,9 +80,15 @@ void WebMouseEvent::encode(IPC::ArgumentEncoder& encoder) const
encoder << m_deltaY;
encoder << m_deltaZ;
encoder << m_clickCount;
+#if PLATFORM(MAC)
+ encoder << m_eventNumber;
+ encoder << m_menuTypeForEvent;
+#endif
+ encoder << m_force;
+ encoder << m_syntheticClickType;
}
-bool WebMouseEvent::decode(IPC::ArgumentDecoder& decoder, WebMouseEvent& result)
+bool WebMouseEvent::decode(IPC::Decoder& decoder, WebMouseEvent& result)
{
if (!WebEvent::decode(decoder, result))
return false;
@@ -88,13 +107,24 @@ bool WebMouseEvent::decode(IPC::ArgumentDecoder& decoder, WebMouseEvent& result)
return false;
if (!decoder.decode(result.m_clickCount))
return false;
+#if PLATFORM(MAC)
+ if (!decoder.decode(result.m_eventNumber))
+ return false;
+ if (!decoder.decode(result.m_menuTypeForEvent))
+ return false;
+#endif
+ if (!decoder.decode(result.m_force))
+ return false;
+
+ if (!decoder.decode(result.m_syntheticClickType))
+ return false;
return true;
}
bool WebMouseEvent::isMouseEventType(Type type)
{
- return type == MouseDown || type == MouseUp || type == MouseMove;
+ return type == MouseDown || type == MouseUp || type == MouseMove || type == MouseForceUp || type == MouseForceDown || type == MouseForceChanged;
}
} // namespace WebKit
diff --git a/Source/WebKit2/Shared/WebNavigationDataStore.h b/Source/WebKit2/Shared/WebNavigationDataStore.h
index a331095aa..3b42d0215 100644
--- a/Source/WebKit2/Shared/WebNavigationDataStore.h
+++ b/Source/WebKit2/Shared/WebNavigationDataStore.h
@@ -26,8 +26,8 @@
#ifndef WebNavigationDataStore_h
#define WebNavigationDataStore_h
-#include "ArgumentDecoder.h"
-#include "ArgumentEncoder.h"
+#include "Decoder.h"
+#include "Encoder.h"
#include "WebCoreArgumentCoders.h"
#include <WebCore/ResourceRequest.h>
#include <WebCore/ResourceResponse.h>
@@ -36,7 +36,7 @@
namespace WebKit {
struct WebNavigationDataStore {
- void encode(IPC::ArgumentEncoder& encoder) const
+ void encode(IPC::Encoder& encoder) const
{
encoder << url;
encoder << title;
@@ -44,7 +44,7 @@ struct WebNavigationDataStore {
encoder << response;
}
- static bool decode(IPC::ArgumentDecoder& decoder, WebNavigationDataStore& store)
+ static bool decode(IPC::Decoder& decoder, WebNavigationDataStore& store)
{
if (!decoder.decode(store.url))
return false;
diff --git a/Source/WebKit2/Shared/WebOpenPanelParameters.cpp b/Source/WebKit2/Shared/WebOpenPanelParameters.cpp
deleted file mode 100644
index bf858565e..000000000
--- a/Source/WebKit2/Shared/WebOpenPanelParameters.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
- * Copyright (C) 2012 Samsung Electronics. 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 "WebOpenPanelParameters.h"
-
-#include "APIArray.h"
-#include "APIString.h"
-#include <wtf/Vector.h>
-
-using namespace WebCore;
-
-namespace WebKit {
-
-PassRefPtr<WebOpenPanelParameters> WebOpenPanelParameters::create(const FileChooserSettings& settings)
-{
- return adoptRef(new WebOpenPanelParameters(settings));
-}
-
-WebOpenPanelParameters::WebOpenPanelParameters(const FileChooserSettings& settings)
- : m_settings(settings)
-{
-}
-
-WebOpenPanelParameters::~WebOpenPanelParameters()
-{
-}
-
-PassRefPtr<API::Array> WebOpenPanelParameters::acceptMIMETypes() const
-{
- return API::Array::createStringArray(m_settings.acceptMIMETypes);
-}
-
-#if ENABLE(MEDIA_CAPTURE)
-String WebOpenPanelParameters::capture() const
-{
- return m_settings.capture;
-}
-#endif
-
-PassRefPtr<API::Array> WebOpenPanelParameters::selectedFileNames() const
-{
- return API::Array::createStringArray(m_settings.selectedFiles);
-}
-
-} // namespace WebCore
diff --git a/Source/WebKit2/Shared/WebPageCreationParameters.cpp b/Source/WebKit2/Shared/WebPageCreationParameters.cpp
index 0003489d7..d98d0ebd2 100644
--- a/Source/WebKit2/Shared/WebPageCreationParameters.cpp
+++ b/Source/WebKit2/Shared/WebPageCreationParameters.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2011, 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
@@ -30,48 +30,73 @@
namespace WebKit {
-void WebPageCreationParameters::encode(IPC::ArgumentEncoder& encoder) const
+void WebPageCreationParameters::encode(IPC::Encoder& encoder) const
{
encoder << viewSize;
- encoder << viewState;
+ encoder << activityState;
encoder << store;
encoder.encodeEnum(drawingAreaType);
encoder << pageGroupData;
encoder << drawsBackground;
- encoder << drawsTransparentBackground;
+ encoder << isEditable;
encoder << underlayColor;
- encoder << areMemoryCacheClientCallsEnabled;
encoder << useFixedLayout;
encoder << fixedLayoutSize;
encoder.encodeEnum(paginationMode);
encoder << paginationBehavesLikeColumns;
encoder << pageLength;
encoder << gapBetweenPages;
+ encoder << paginationLineGridEnabled;
encoder << userAgent;
- encoder << sessionState;
+ encoder << itemStates;
+ encoder << sessionID;
encoder << highestUsedBackForwardItemID;
+ encoder << userContentControllerID;
+ encoder << visitedLinkTableID;
+ encoder << websiteDataStoreID;
encoder << canRunBeforeUnloadConfirmPanel;
encoder << canRunModal;
encoder << deviceScaleFactor;
+ encoder << viewScaleFactor;
+ encoder << topContentInset;
encoder << mediaVolume;
+ encoder << muted;
encoder << mayStartMediaWhenInWindow;
encoder << minimumLayoutSize;
encoder << autoSizingShouldExpandToViewHeight;
encoder.encodeEnum(scrollPinningBehavior);
+ encoder << scrollbarOverlayStyle;
encoder << backgroundExtendsBeyondPage;
encoder.encodeEnum(layerHostingMode);
+ encoder << mimeTypesWithCustomContentProviders;
+ encoder << controlledByAutomation;
+#if ENABLE(REMOTE_INSPECTOR)
+ encoder << allowsRemoteInspection;
+ encoder << remoteInspectionNameOverride;
+#endif
#if PLATFORM(MAC)
encoder << colorSpace;
#endif
+#if PLATFORM(IOS)
+ encoder << screenSize;
+ encoder << availableScreenSize;
+ encoder << textAutosizingWidth;
+ encoder << ignoresViewportScaleLimits;
+#endif
+ encoder << appleMailPaginationQuirkEnabled;
+ encoder << shouldScaleViewToFitDocument;
+ encoder.encodeEnum(userInterfaceLayoutDirection);
+ encoder.encodeEnum(observedLayoutMilestones);
+ encoder << overrideContentSecurityPolicy;
}
-bool WebPageCreationParameters::decode(IPC::ArgumentDecoder& decoder, WebPageCreationParameters& parameters)
+bool WebPageCreationParameters::decode(IPC::Decoder& decoder, WebPageCreationParameters& parameters)
{
if (!decoder.decode(parameters.viewSize))
return false;
- if (!decoder.decode(parameters.viewState))
+ if (!decoder.decode(parameters.activityState))
return false;
if (!decoder.decode(parameters.store))
return false;
@@ -81,12 +106,10 @@ bool WebPageCreationParameters::decode(IPC::ArgumentDecoder& decoder, WebPageCre
return false;
if (!decoder.decode(parameters.drawsBackground))
return false;
- if (!decoder.decode(parameters.drawsTransparentBackground))
+ if (!decoder.decode(parameters.isEditable))
return false;
if (!decoder.decode(parameters.underlayColor))
return false;
- if (!decoder.decode(parameters.areMemoryCacheClientCallsEnabled))
- return false;
if (!decoder.decode(parameters.useFixedLayout))
return false;
if (!decoder.decode(parameters.fixedLayoutSize))
@@ -99,20 +122,36 @@ bool WebPageCreationParameters::decode(IPC::ArgumentDecoder& decoder, WebPageCre
return false;
if (!decoder.decode(parameters.gapBetweenPages))
return false;
+ if (!decoder.decode(parameters.paginationLineGridEnabled))
+ return false;
if (!decoder.decode(parameters.userAgent))
return false;
- if (!decoder.decode(parameters.sessionState))
+ if (!decoder.decode(parameters.itemStates))
+ return false;
+ if (!decoder.decode(parameters.sessionID))
return false;
if (!decoder.decode(parameters.highestUsedBackForwardItemID))
return false;
+ if (!decoder.decode(parameters.userContentControllerID))
+ return false;
+ if (!decoder.decode(parameters.visitedLinkTableID))
+ return false;
+ if (!decoder.decode(parameters.websiteDataStoreID))
+ return false;
if (!decoder.decode(parameters.canRunBeforeUnloadConfirmPanel))
return false;
if (!decoder.decode(parameters.canRunModal))
return false;
if (!decoder.decode(parameters.deviceScaleFactor))
return false;
+ if (!decoder.decode(parameters.viewScaleFactor))
+ return false;
+ if (!decoder.decode(parameters.topContentInset))
+ return false;
if (!decoder.decode(parameters.mediaVolume))
return false;
+ if (!decoder.decode(parameters.muted))
+ return false;
if (!decoder.decode(parameters.mayStartMediaWhenInWindow))
return false;
if (!decoder.decode(parameters.minimumLayoutSize))
@@ -121,16 +160,54 @@ bool WebPageCreationParameters::decode(IPC::ArgumentDecoder& decoder, WebPageCre
return false;
if (!decoder.decodeEnum(parameters.scrollPinningBehavior))
return false;
+ if (!decoder.decode(parameters.scrollbarOverlayStyle))
+ return false;
if (!decoder.decode(parameters.backgroundExtendsBeyondPage))
return false;
if (!decoder.decodeEnum(parameters.layerHostingMode))
return false;
-
+ if (!decoder.decode(parameters.mimeTypesWithCustomContentProviders))
+ return false;
+ if (!decoder.decode(parameters.controlledByAutomation))
+ return false;
+
+#if ENABLE(REMOTE_INSPECTOR)
+ if (!decoder.decode(parameters.allowsRemoteInspection))
+ return false;
+ if (!decoder.decode(parameters.remoteInspectionNameOverride))
+ return false;
+#endif
+
#if PLATFORM(MAC)
if (!decoder.decode(parameters.colorSpace))
return false;
#endif
+#if PLATFORM(IOS)
+ if (!decoder.decode(parameters.screenSize))
+ return false;
+ if (!decoder.decode(parameters.availableScreenSize))
+ return false;
+ if (!decoder.decode(parameters.textAutosizingWidth))
+ return false;
+ if (!decoder.decode(parameters.ignoresViewportScaleLimits))
+ return false;
+#endif
+
+ if (!decoder.decode(parameters.appleMailPaginationQuirkEnabled))
+ return false;
+
+ if (!decoder.decode(parameters.shouldScaleViewToFitDocument))
+ return false;
+
+ if (!decoder.decodeEnum(parameters.userInterfaceLayoutDirection))
+ return false;
+ if (!decoder.decodeEnum(parameters.observedLayoutMilestones))
+ return false;
+
+ if (!decoder.decode(parameters.overrideContentSecurityPolicy))
+ return false;
+
return true;
}
diff --git a/Source/WebKit2/Shared/WebPageCreationParameters.h b/Source/WebKit2/Shared/WebPageCreationParameters.h
index bdca723df..a6244b876 100644
--- a/Source/WebKit2/Shared/WebPageCreationParameters.h
+++ b/Source/WebKit2/Shared/WebPageCreationParameters.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2011, 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
@@ -32,11 +32,16 @@
#include "WebCoreArgumentCoders.h"
#include "WebPageGroupData.h"
#include "WebPreferencesStore.h"
+#include <WebCore/ActivityState.h>
#include <WebCore/Color.h>
+#include <WebCore/FloatSize.h>
#include <WebCore/IntSize.h>
+#include <WebCore/LayoutMilestones.h>
+#include <WebCore/MediaProducer.h>
#include <WebCore/Pagination.h>
#include <WebCore/ScrollTypes.h>
-#include <WebCore/ViewState.h>
+#include <WebCore/SessionID.h>
+#include <WebCore/UserInterfaceLayoutDirection.h>
#include <wtf/text/WTFString.h>
#if PLATFORM(MAC)
@@ -44,31 +49,29 @@
#endif
namespace IPC {
- class ArgumentDecoder;
- class ArgumentEncoder;
+class Decoder;
+class Encoder;
}
namespace WebKit {
struct WebPageCreationParameters {
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, WebPageCreationParameters&);
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, WebPageCreationParameters&);
WebCore::IntSize viewSize;
- WebCore::ViewState::Flags viewState;
+ WebCore::ActivityState::Flags activityState;
WebPreferencesStore store;
DrawingAreaType drawingAreaType;
WebPageGroupData pageGroupData;
bool drawsBackground;
- bool drawsTransparentBackground;
+ bool isEditable;
WebCore::Color underlayColor;
- bool areMemoryCacheClientCallsEnabled;
-
bool useFixedLayout;
WebCore::IntSize fixedLayoutSize;
@@ -78,18 +81,27 @@ struct WebPageCreationParameters {
bool paginationBehavesLikeColumns;
double pageLength;
double gapBetweenPages;
-
+ bool paginationLineGridEnabled;
+
String userAgent;
- SessionState sessionState;
+ Vector<BackForwardListItemState> itemStates;
+ WebCore::SessionID sessionID;
uint64_t highestUsedBackForwardItemID;
+ uint64_t userContentControllerID;
+ uint64_t visitedLinkTableID;
+ uint64_t websiteDataStoreID;
bool canRunBeforeUnloadConfirmPanel;
bool canRunModal;
float deviceScaleFactor;
+ float viewScaleFactor;
+
+ float topContentInset;
float mediaVolume;
+ WebCore::MediaProducer::MutedStateFlags muted;
bool mayStartMediaWhenInWindow;
WebCore::IntSize minimumLayoutSize;
@@ -97,13 +109,42 @@ struct WebPageCreationParameters {
WebCore::ScrollPinningBehavior scrollPinningBehavior;
+ // FIXME: This should be std::optional<WebCore::ScrollbarOverlayStyle>, but we would need to
+ // correctly handle enums inside Optionals when encoding and decoding.
+ std::optional<uint32_t> scrollbarOverlayStyle;
+
bool backgroundExtendsBeyondPage;
LayerHostingMode layerHostingMode;
+ Vector<String> mimeTypesWithCustomContentProviders;
+
+ bool controlledByAutomation;
+
+#if ENABLE(REMOTE_INSPECTOR)
+ bool allowsRemoteInspection;
+ String remoteInspectionNameOverride;
+#endif
+
#if PLATFORM(MAC)
ColorSpaceData colorSpace;
#endif
+#if PLATFORM(IOS)
+ WebCore::FloatSize screenSize;
+ WebCore::FloatSize availableScreenSize;
+ float textAutosizingWidth;
+ bool ignoresViewportScaleLimits;
+#endif
+#if PLATFORM(COCOA)
+ bool smartInsertDeleteEnabled;
+#endif
+ bool appleMailPaginationQuirkEnabled;
+ bool shouldScaleViewToFitDocument;
+
+ WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection;
+ WebCore::LayoutMilestones observedLayoutMilestones;
+
+ String overrideContentSecurityPolicy;
};
} // namespace WebKit
diff --git a/Source/WebKit2/Shared/WebPageGroupData.cpp b/Source/WebKit2/Shared/WebPageGroupData.cpp
index 28bace115..6321b0139 100644
--- a/Source/WebKit2/Shared/WebPageGroupData.cpp
+++ b/Source/WebKit2/Shared/WebPageGroupData.cpp
@@ -30,19 +30,18 @@
namespace WebKit {
-void WebPageGroupData::encode(IPC::ArgumentEncoder& encoder) const
+void WebPageGroupData::encode(IPC::Encoder& encoder) const
{
- encoder << identifer;
+ encoder << identifier;
encoder << pageGroupID;
encoder << visibleToInjectedBundle;
encoder << visibleToHistoryClient;
- encoder << userStyleSheets;
- encoder << userScripts;
+ encoder << userContentControllerIdentifier;
}
-bool WebPageGroupData::decode(IPC::ArgumentDecoder& decoder, WebPageGroupData& data)
+bool WebPageGroupData::decode(IPC::Decoder& decoder, WebPageGroupData& data)
{
- if (!decoder.decode(data.identifer))
+ if (!decoder.decode(data.identifier))
return false;
if (!decoder.decode(data.pageGroupID))
return false;
@@ -50,9 +49,7 @@ bool WebPageGroupData::decode(IPC::ArgumentDecoder& decoder, WebPageGroupData& d
return false;
if (!decoder.decode(data.visibleToHistoryClient))
return false;
- if (!decoder.decode(data.userStyleSheets))
- return false;
- if (!decoder.decode(data.userScripts))
+ if (!decoder.decode(data.userContentControllerIdentifier))
return false;
return true;
}
diff --git a/Source/WebKit2/Shared/WebPageGroupData.h b/Source/WebKit2/Shared/WebPageGroupData.h
index 7cbb1f8a6..b70936946 100644
--- a/Source/WebKit2/Shared/WebPageGroupData.h
+++ b/Source/WebKit2/Shared/WebPageGroupData.h
@@ -26,29 +26,25 @@
#ifndef WebPageGroupData_h
#define WebPageGroupData_h
-#include <WebCore/UserScript.h>
-#include <WebCore/UserStyleSheet.h>
-#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
namespace IPC {
-class ArgumentDecoder;
-class ArgumentEncoder;
+class Decoder;
+class Encoder;
}
namespace WebKit {
struct WebPageGroupData {
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, WebPageGroupData&);
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, WebPageGroupData&);
- String identifer;
+ String identifier;
uint64_t pageGroupID;
bool visibleToInjectedBundle;
bool visibleToHistoryClient;
- Vector<WebCore::UserStyleSheet> userStyleSheets;
- Vector<WebCore::UserScript> userScripts;
+ uint64_t userContentControllerIdentifier;
};
} // namespace WebKit
diff --git a/Source/WebKit2/Shared/WebPlatformTouchPoint.cpp b/Source/WebKit2/Shared/WebPlatformTouchPoint.cpp
index f5b5c6c34..c7e028711 100644
--- a/Source/WebKit2/Shared/WebPlatformTouchPoint.cpp
+++ b/Source/WebKit2/Shared/WebPlatformTouchPoint.cpp
@@ -27,9 +27,8 @@
#include "config.h"
#include "WebEvent.h"
-#if ENABLE(TOUCH_EVENTS)
+#if ENABLE(TOUCH_EVENTS) && !PLATFORM(IOS)
-#include "Arguments.h"
#include "WebCoreArgumentCoders.h"
using namespace WebCore;
@@ -57,7 +56,7 @@ WebPlatformTouchPoint::WebPlatformTouchPoint(unsigned id, TouchPointState state,
{
}
-void WebPlatformTouchPoint::encode(IPC::ArgumentEncoder& encoder) const
+void WebPlatformTouchPoint::encode(IPC::Encoder& encoder) const
{
encoder << m_id;
encoder << m_state;
@@ -68,7 +67,7 @@ void WebPlatformTouchPoint::encode(IPC::ArgumentEncoder& encoder) const
encoder << m_force;
}
-bool WebPlatformTouchPoint::decode(IPC::ArgumentDecoder& decoder, WebPlatformTouchPoint& result)
+bool WebPlatformTouchPoint::decode(IPC::Decoder& decoder, WebPlatformTouchPoint& result)
{
if (!decoder.decode(result.m_id))
return false;
@@ -90,4 +89,4 @@ bool WebPlatformTouchPoint::decode(IPC::ArgumentDecoder& decoder, WebPlatformTou
} // namespace WebKit
-#endif // ENABLE(TOUCH_EVENTS)
+#endif // ENABLE(TOUCH_EVENTS) && !PLATFORM(IOS)
diff --git a/Source/WebKit2/Shared/WebPopupItem.cpp b/Source/WebKit2/Shared/WebPopupItem.cpp
index 22c13c5e8..e80260eda 100644
--- a/Source/WebKit2/Shared/WebPopupItem.cpp
+++ b/Source/WebKit2/Shared/WebPopupItem.cpp
@@ -28,7 +28,6 @@
#include "WebPopupItem.h"
#include "ArgumentCoders.h"
-#include "Arguments.h"
using namespace WebCore;
@@ -66,7 +65,7 @@ WebPopupItem::WebPopupItem(Type type, const String& text, TextDirection textDire
{
}
-void WebPopupItem::encode(IPC::ArgumentEncoder& encoder) const
+void WebPopupItem::encode(IPC::Encoder& encoder) const
{
encoder.encodeEnum(m_type);
encoder << m_text;
@@ -79,7 +78,7 @@ void WebPopupItem::encode(IPC::ArgumentEncoder& encoder) const
encoder << m_isSelected;
}
-bool WebPopupItem::decode(IPC::ArgumentDecoder& decoder, WebPopupItem& item)
+bool WebPopupItem::decode(IPC::Decoder& decoder, WebPopupItem& item)
{
Type type;
if (!decoder.decodeEnum(type))
diff --git a/Source/WebKit2/Shared/WebPopupItem.h b/Source/WebKit2/Shared/WebPopupItem.h
index 58c276630..c18e7a966 100644
--- a/Source/WebKit2/Shared/WebPopupItem.h
+++ b/Source/WebKit2/Shared/WebPopupItem.h
@@ -26,12 +26,12 @@
#ifndef WebPopupItem_h
#define WebPopupItem_h
-#include <WebCore/TextDirection.h>
+#include <WebCore/WritingMode.h>
#include <wtf/text/WTFString.h>
namespace IPC {
- class ArgumentDecoder;
- class ArgumentEncoder;
+class Decoder;
+class Encoder;
}
namespace WebKit {
@@ -46,8 +46,8 @@ struct WebPopupItem {
WebPopupItem(Type);
WebPopupItem(Type, const String& text, WebCore::TextDirection, bool hasTextDirectionOverride, const String& toolTip, const String& accessibilityText, bool isEnabled, bool isLabel, bool isSelected);
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, WebPopupItem&);
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, WebPopupItem&);
Type m_type;
String m_text;
diff --git a/Source/WebKit2/Shared/WebPreferencesDefinitions.h b/Source/WebKit2/Shared/WebPreferencesDefinitions.h
new file mode 100644
index 000000000..4e3cc8db5
--- /dev/null
+++ b/Source/WebKit2/Shared/WebPreferencesDefinitions.h
@@ -0,0 +1,384 @@
+/*
+ * Copyright (C) 2010-2016 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.
+ */
+
+#pragma once
+
+#if PLATFORM(GTK)
+#define DEFAULT_WEBKIT_TABSTOLINKS_ENABLED true
+#else
+#define DEFAULT_WEBKIT_TABSTOLINKS_ENABLED false
+#endif
+
+#if ENABLE(SMOOTH_SCROLLING)
+#define DEFAULT_WEBKIT_SCROLL_ANIMATOR_ENABLED true
+#else
+#define DEFAULT_WEBKIT_SCROLL_ANIMATOR_ENABLED false
+#endif
+
+#if PLATFORM(COCOA)
+#define DEFAULT_HIDDEN_PAGE_DOM_TIMER_THROTTLING_ENABLED true
+#define DEFAULT_HIDDEN_PAGE_CSS_ANIMATION_SUSPENSION_ENABLED true
+#define DEFAULT_PDFPLUGIN_ENABLED true
+#else
+#define DEFAULT_HIDDEN_PAGE_DOM_TIMER_THROTTLING_ENABLED false
+#define DEFAULT_HIDDEN_PAGE_CSS_ANIMATION_SUSPENSION_ENABLED false
+#define DEFAULT_PDFPLUGIN_ENABLED false
+#endif
+
+#if PLATFORM(COCOA)
+#define DEFAULT_HTML_INTERACTIVE_FORM_VALIDATION_ENABLED true
+#else
+#define DEFAULT_HTML_INTERACTIVE_FORM_VALIDATION_ENABLED false
+#endif
+
+#if PLATFORM(IOS)
+#define DEFAULT_ALLOWS_PICTURE_IN_PICTURE_MEDIA_PLAYBACK true
+#define DEFAULT_BACKSPACE_KEY_NAVIGATION_ENABLED false
+#define DEFAULT_FRAME_FLATTENING_ENABLED true
+#define DEFAULT_SHOULD_PRINT_BACKGROUNDS true
+#define DEFAULT_TEXT_AREAS_ARE_RESIZABLE false
+#define DEFAULT_JAVASCRIPT_CAN_OPEN_WINDOWS_AUTOMATICALLY false
+#define DEFAULT_SHOULD_RESPECT_IMAGE_ORIENTATION true
+#define DEFAULT_PASSWORD_ECHO_ENABLED true
+#define DEFAULT_ALLOWS_INLINE_MEDIA_PLAYBACK false
+#define DEFAULT_ALLOWS_INLINE_MEDIA_PLAYBACK_AFTER_FULLSCREEN true
+#define DEFAULT_INLINE_MEDIA_PLAYBACK_REQUIRES_PLAYS_INLINE_ATTRIBUTE true
+#define DEFAULT_INVISIBLE_AUTOPLAY_NOT_PERMITTED true
+#define DEFAULT_MEDIA_DATA_LOADS_AUTOMATICALLY false
+#define DEFAULT_MEDIA_CONTROLS_SCALE_WITH_PAGE_ZOOM false
+#define DEFAULT_TEMPORARY_TILE_COHORT_RETENTION_ENABLED false
+#define DEFAULT_REQUIRES_USER_GESTURE_FOR_AUDIO_PLAYBACK true
+#else
+#define DEFAULT_ALLOWS_PICTURE_IN_PICTURE_MEDIA_PLAYBACK false
+#define DEFAULT_BACKSPACE_KEY_NAVIGATION_ENABLED true
+#define DEFAULT_FRAME_FLATTENING_ENABLED false
+#define DEFAULT_SHOULD_PRINT_BACKGROUNDS false
+#define DEFAULT_TEXT_AREAS_ARE_RESIZABLE true
+#define DEFAULT_JAVASCRIPT_CAN_OPEN_WINDOWS_AUTOMATICALLY true
+#define DEFAULT_SHOULD_RESPECT_IMAGE_ORIENTATION false
+#define DEFAULT_PASSWORD_ECHO_ENABLED false
+#define DEFAULT_ALLOWS_INLINE_MEDIA_PLAYBACK true
+#define DEFAULT_ALLOWS_INLINE_MEDIA_PLAYBACK_AFTER_FULLSCREEN false
+#define DEFAULT_INLINE_MEDIA_PLAYBACK_REQUIRES_PLAYS_INLINE_ATTRIBUTE false
+#define DEFAULT_INVISIBLE_AUTOPLAY_NOT_PERMITTED false
+#define DEFAULT_MEDIA_DATA_LOADS_AUTOMATICALLY true
+#define DEFAULT_MEDIA_CONTROLS_SCALE_WITH_PAGE_ZOOM true
+#define DEFAULT_TEMPORARY_TILE_COHORT_RETENTION_ENABLED true
+#define DEFAULT_REQUIRES_USER_GESTURE_FOR_AUDIO_PLAYBACK false
+#endif
+
+#if PLATFORM(IOS_SIMULATOR)
+#define DEFAULT_ACCELERATED_DRAWING_ENABLED false
+#define DEFAULT_CANVAS_USES_ACCELERATED_DRAWING false
+#else
+#define DEFAULT_ACCELERATED_DRAWING_ENABLED true
+#define DEFAULT_CANVAS_USES_ACCELERATED_DRAWING true
+#endif
+
+// macro(KeyUpper, KeyLower, TypeNameUpper, TypeName, DefaultValue, HumanReadableName, HumanReadableDescription)
+
+#define FOR_EACH_WEBKIT_BOOL_PREFERENCE(macro) \
+ macro(JavaScriptEnabled, javaScriptEnabled, Bool, bool, true, "", "") \
+ macro(JavaScriptMarkupEnabled, javaScriptMarkupEnabled, Bool, bool, true, "", "") \
+ macro(LoadsImagesAutomatically, loadsImagesAutomatically, Bool, bool, true, "", "") \
+ macro(LoadsSiteIconsIgnoringImageLoadingPreference, loadsSiteIconsIgnoringImageLoadingPreference, Bool, bool, false, "", "") \
+ macro(PluginsEnabled, pluginsEnabled, Bool, bool, false, "", "") \
+ macro(JavaEnabled, javaEnabled, Bool, bool, false, "", "") \
+ macro(JavaEnabledForLocalFiles, javaEnabledForLocalFiles, Bool, bool, false, "", "") \
+ macro(OfflineWebApplicationCacheEnabled, offlineWebApplicationCacheEnabled, Bool, bool, true, "", "") \
+ macro(LocalStorageEnabled, localStorageEnabled, Bool, bool, true, "", "") \
+ macro(DatabasesEnabled, databasesEnabled, Bool, bool, true, "", "") \
+ macro(XSSAuditorEnabled, xssAuditorEnabled, Bool, bool, true, "", "") \
+ macro(FrameFlatteningEnabled, frameFlatteningEnabled, Bool, bool, DEFAULT_FRAME_FLATTENING_ENABLED, "", "") \
+ macro(PrivateBrowsingEnabled, privateBrowsingEnabled, Bool, bool, false, "", "") \
+ macro(TextAreasAreResizable, textAreasAreResizable, Bool, bool, DEFAULT_TEXT_AREAS_ARE_RESIZABLE, "", "") \
+ macro(JavaScriptCanOpenWindowsAutomatically, javaScriptCanOpenWindowsAutomatically, Bool, bool, DEFAULT_JAVASCRIPT_CAN_OPEN_WINDOWS_AUTOMATICALLY, "", "") \
+ macro(HyperlinkAuditingEnabled, hyperlinkAuditingEnabled, Bool, bool, true, "", "") \
+ macro(NeedsSiteSpecificQuirks, needsSiteSpecificQuirks, Bool, bool, false, "", "") \
+ macro(AcceleratedCompositingEnabled, acceleratedCompositingEnabled, Bool, bool, true, "", "") \
+ macro(ForceCompositingMode, forceCompositingMode, Bool, bool, false, "", "") \
+ macro(CanvasUsesAcceleratedDrawing, canvasUsesAcceleratedDrawing, Bool, bool, DEFAULT_CANVAS_USES_ACCELERATED_DRAWING, "", "") \
+ macro(WebGLEnabled, webGLEnabled, Bool, bool, true, "", "") \
+ macro(ForceSoftwareWebGLRendering, forceSoftwareWebGLRendering, Bool, bool, false, "", "") \
+ macro(Accelerated2dCanvasEnabled, accelerated2dCanvasEnabled, Bool, bool, false, "", "") \
+ macro(CSSAnimationTriggersEnabled, cssAnimationTriggersEnabled, Bool, bool, true, "", "") \
+ macro(ForceFTPDirectoryListings, forceFTPDirectoryListings, Bool, bool, false, "", "") \
+ macro(TabsToLinks, tabsToLinks, Bool, bool, DEFAULT_WEBKIT_TABSTOLINKS_ENABLED, "", "") \
+ macro(DNSPrefetchingEnabled, dnsPrefetchingEnabled, Bool, bool, false, "", "") \
+ macro(DOMTimersThrottlingEnabled, domTimersThrottlingEnabled, Bool, bool, true, "", "") \
+ macro(WebArchiveDebugModeEnabled, webArchiveDebugModeEnabled, Bool, bool, false, "", "") \
+ macro(LocalFileContentSniffingEnabled, localFileContentSniffingEnabled, Bool, bool, false, "", "") \
+ macro(UsesPageCache, usesPageCache, Bool, bool, true, "", "") \
+ macro(PageCacheSupportsPlugins, pageCacheSupportsPlugins, Bool, bool, true, "", "") \
+ macro(AuthorAndUserStylesEnabled, authorAndUserStylesEnabled, Bool, bool, true, "", "") \
+ macro(PaginateDuringLayoutEnabled, paginateDuringLayoutEnabled, Bool, bool, false, "", "") \
+ macro(DOMPasteAllowed, domPasteAllowed, Bool, bool, false, "", "") \
+ macro(JavaScriptCanAccessClipboard, javaScriptCanAccessClipboard, Bool, bool, false, "", "") \
+ macro(ShouldPrintBackgrounds, shouldPrintBackgrounds, Bool, bool, DEFAULT_SHOULD_PRINT_BACKGROUNDS, "", "") \
+ macro(FullScreenEnabled, fullScreenEnabled, Bool, bool, false, "", "") \
+ macro(AsynchronousSpellCheckingEnabled, asynchronousSpellCheckingEnabled, Bool, bool, false, "", "") \
+ macro(WebSecurityEnabled, webSecurityEnabled, Bool, bool, true, "", "") \
+ macro(AllowUniversalAccessFromFileURLs, allowUniversalAccessFromFileURLs, Bool, bool, false, "", "") \
+ macro(AllowFileAccessFromFileURLs, allowFileAccessFromFileURLs, Bool, bool, false, "", "") \
+ macro(AVFoundationEnabled, isAVFoundationEnabled, Bool, bool, true, "", "") \
+ macro(AVFoundationNSURLSessionEnabled, isAVFoundationNSURLSessionEnabled, Bool, bool, true, "", "") \
+ macro(GStreamerEnabled, isGStreamerEnabled, Bool, bool, true, "", "") \
+ macro(RequiresUserGestureForMediaPlayback, requiresUserGestureForMediaPlayback, Bool, bool, false, "", "") \
+ macro(RequiresUserGestureForVideoPlayback, requiresUserGestureForVideoPlayback, Bool, bool, false, "", "") \
+ macro(RequiresUserGestureForAudioPlayback, requiresUserGestureForAudioPlayback, Bool, bool, DEFAULT_REQUIRES_USER_GESTURE_FOR_AUDIO_PLAYBACK, "", "") \
+ macro(RequiresUserGestureToLoadVideo, requiresUserGestureToLoadVideo, Bool, bool, false, "", "") \
+ macro(MainContentUserGestureOverrideEnabled, mainContentUserGestureOverrideEnabled, Bool, bool, false, "", "") \
+ macro(AllowsInlineMediaPlayback, allowsInlineMediaPlayback, Bool, bool, DEFAULT_ALLOWS_INLINE_MEDIA_PLAYBACK, "", "") \
+ macro(AllowsInlineMediaPlaybackAfterFullscreen, allowsInlineMediaPlaybackAfterFullscreen, Bool, bool, DEFAULT_ALLOWS_INLINE_MEDIA_PLAYBACK_AFTER_FULLSCREEN, "", "") \
+ macro(InlineMediaPlaybackRequiresPlaysInlineAttribute, inlineMediaPlaybackRequiresPlaysInlineAttribute, Bool, bool, DEFAULT_INLINE_MEDIA_PLAYBACK_REQUIRES_PLAYS_INLINE_ATTRIBUTE, "", "") \
+ macro(InvisibleAutoplayNotPermitted, invisibleAutoplayNotPermitted, Bool, bool, DEFAULT_INVISIBLE_AUTOPLAY_NOT_PERMITTED, "", "") \
+ macro(MediaDataLoadsAutomatically, mediaDataLoadsAutomatically, Bool, bool, DEFAULT_MEDIA_DATA_LOADS_AUTOMATICALLY, "", "") \
+ macro(AllowsPictureInPictureMediaPlayback, allowsPictureInPictureMediaPlayback, Bool, bool, DEFAULT_ALLOWS_PICTURE_IN_PICTURE_MEDIA_PLAYBACK, "", "") \
+ macro(AllowsAirPlayForMediaPlayback, allowsAirPlayForMediaPlayback, Bool, bool, true, "", "") \
+ macro(MediaControlsScaleWithPageZoom, mediaControlsScaleWithPageZoom, Bool, bool, DEFAULT_MEDIA_CONTROLS_SCALE_WITH_PAGE_ZOOM, "", "") \
+ macro(InspectorStartsAttached, inspectorStartsAttached, Bool, bool, true, "", "") \
+ macro(ShowsToolTipOverTruncatedText, showsToolTipOverTruncatedText, Bool, bool, false, "", "") \
+ macro(MockScrollbarsEnabled, mockScrollbarsEnabled, Bool, bool, false, "", "") \
+ macro(WebAudioEnabled, webAudioEnabled, Bool, bool, true, "", "") \
+ macro(AttachmentElementEnabled, attachmentElementEnabled, Bool, bool, false, "", "") \
+ macro(SuppressesIncrementalRendering, suppressesIncrementalRendering, Bool, bool, false, "", "") \
+ macro(BackspaceKeyNavigationEnabled, backspaceKeyNavigationEnabled, Bool, bool, DEFAULT_BACKSPACE_KEY_NAVIGATION_ENABLED, "", "") \
+ macro(CaretBrowsingEnabled, caretBrowsingEnabled, Bool, bool, false, "", "") \
+ macro(ShouldDisplaySubtitles, shouldDisplaySubtitles, Bool, bool, false, "", "") \
+ macro(ShouldDisplayCaptions, shouldDisplayCaptions, Bool, bool, false, "", "") \
+ macro(ShouldDisplayTextDescriptions, shouldDisplayTextDescriptions, Bool, bool, false, "", "") \
+ macro(NotificationsEnabled, notificationsEnabled, Bool, bool, true, "", "") \
+ macro(ShouldRespectImageOrientation, shouldRespectImageOrientation, Bool, bool, DEFAULT_SHOULD_RESPECT_IMAGE_ORIENTATION, "", "") \
+ macro(WantsBalancedSetDefersLoadingBehavior, wantsBalancedSetDefersLoadingBehavior, Bool, bool, false, "", "") \
+ macro(RequestAnimationFrameEnabled, requestAnimationFrameEnabled, Bool, bool, true, "", "") \
+ macro(DiagnosticLoggingEnabled, diagnosticLoggingEnabled, Bool, bool, false, "", "") \
+ macro(AsynchronousPluginInitializationEnabled, asynchronousPluginInitializationEnabled, Bool, bool, false, "", "") \
+ macro(AsynchronousPluginInitializationEnabledForAllPlugins, asynchronousPluginInitializationEnabledForAllPlugins, Bool, bool, false, "", "") \
+ macro(ArtificialPluginInitializationDelayEnabled, artificialPluginInitializationDelayEnabled, Bool, bool, false, "", "") \
+ macro(TabToLinksEnabled, tabToLinksEnabled, Bool, bool, false, "", "") \
+ macro(ScrollingPerformanceLoggingEnabled, scrollingPerformanceLoggingEnabled, Bool, bool, false, "", "") \
+ macro(ScrollAnimatorEnabled, scrollAnimatorEnabled, Bool, bool, DEFAULT_WEBKIT_SCROLL_ANIMATOR_ENABLED, "", "") \
+ macro(ForceUpdateScrollbarsOnMainThreadForPerformanceTesting, forceUpdateScrollbarsOnMainThreadForPerformanceTesting, Bool, bool, false, "", "") \
+ macro(CookieEnabled, cookieEnabled, Bool, bool, true, "", "") \
+ macro(PlugInSnapshottingEnabled, plugInSnapshottingEnabled, Bool, bool, false, "", "") \
+ macro(SnapshotAllPlugIns, snapshotAllPlugIns, Bool, bool, false, "", "") \
+ macro(AutostartOriginPlugInSnapshottingEnabled, autostartOriginPlugInSnapshottingEnabled, Bool, bool, true, "", "") \
+ macro(PrimaryPlugInSnapshotDetectionEnabled, primaryPlugInSnapshotDetectionEnabled, Bool, bool, true, "", "") \
+ macro(PDFPluginEnabled, pdfPluginEnabled, Bool, bool, DEFAULT_PDFPLUGIN_ENABLED, "", "") \
+ macro(UsesEncodingDetector, usesEncodingDetector, Bool, bool, false, "", "") \
+ macro(TextAutosizingEnabled, textAutosizingEnabled, Bool, bool, WebCore::Settings::defaultTextAutosizingEnabled(), "", "") \
+ macro(AggressiveTileRetentionEnabled, aggressiveTileRetentionEnabled, Bool, bool, false, "", "") \
+ macro(TemporaryTileCohortRetentionEnabled, temporaryTileCohortRetentionEnabled, Bool, bool, DEFAULT_TEMPORARY_TILE_COHORT_RETENTION_ENABLED, "", "") \
+ macro(QTKitEnabled, isQTKitEnabled, Bool, bool, WebCore::Settings::isQTKitEnabled(), "", "") \
+ macro(PageVisibilityBasedProcessSuppressionEnabled, pageVisibilityBasedProcessSuppressionEnabled, Bool, bool, true, "", "") \
+ macro(SmartInsertDeleteEnabled, smartInsertDeleteEnabled, Bool, bool, true, "", "") \
+ macro(SelectTrailingWhitespaceEnabled, selectTrailingWhitespaceEnabled, Bool, bool, false, "", "") \
+ macro(ShowsURLsInToolTipsEnabled, showsURLsInToolTipsEnabled, Bool, bool, false, "", "") \
+ macro(AcceleratedCompositingForOverflowScrollEnabled, acceleratedCompositingForOverflowScrollEnabled, Bool, bool, false, "", "") \
+ macro(HiddenPageDOMTimerThrottlingEnabled, hiddenPageDOMTimerThrottlingEnabled, Bool, bool, DEFAULT_HIDDEN_PAGE_DOM_TIMER_THROTTLING_ENABLED, "", "") \
+ macro(HiddenPageDOMTimerThrottlingAutoIncreases, hiddenPageDOMTimerThrottlingAutoIncreases, Bool, bool, false, "", "") \
+ macro(HiddenPageCSSAnimationSuspensionEnabled, hiddenPageCSSAnimationSuspensionEnabled, Bool, bool, DEFAULT_HIDDEN_PAGE_CSS_ANIMATION_SUSPENSION_ENABLED, "", "") \
+ macro(LowPowerVideoAudioBufferSizeEnabled, lowPowerVideoAudioBufferSizeEnabled, Bool, bool, false, "", "") \
+ macro(ThreadedScrollingEnabled, threadedScrollingEnabled, Bool, bool, true, "", "") \
+ macro(SimpleLineLayoutEnabled, simpleLineLayoutEnabled, Bool, bool, true, "", "") \
+ macro(SubpixelCSSOMElementMetricsEnabled, subpixelCSSOMElementMetricsEnabled, Bool, bool, false, "", "") \
+ macro(UseGiantTiles, useGiantTiles, Bool, bool, false, "", "") \
+ macro(MediaStreamEnabled, mediaStreamEnabled, Bool, bool, false, "", "") \
+ macro(UseLegacyTextAlignPositionedElementBehavior, useLegacyTextAlignPositionedElementBehavior, Bool, bool, false, "", "") \
+ macro(SpatialNavigationEnabled, spatialNavigationEnabled, Bool, bool, false, "", "") \
+ macro(MediaSourceEnabled, mediaSourceEnabled, Bool, bool, true, "", "") \
+ macro(ViewGestureDebuggingEnabled, viewGestureDebuggingEnabled, Bool, bool, false, "", "") \
+ macro(ShouldConvertPositionStyleOnCopy, shouldConvertPositionStyleOnCopy, Bool, bool, false, "", "") \
+ macro(Standalone, standalone, Bool, bool, false, "", "") \
+ macro(TelephoneNumberParsingEnabled, telephoneNumberParsingEnabled, Bool, bool, false, "", "") \
+ macro(AllowMultiElementImplicitSubmission, allowMultiElementImplicitSubmission, Bool, bool, false, "", "") \
+ macro(AlwaysUseAcceleratedOverflowScroll, alwaysUseAcceleratedOverflowScroll, Bool, bool, false, "", "") \
+ macro(PasswordEchoEnabled, passwordEchoEnabled, Bool, bool, DEFAULT_PASSWORD_ECHO_ENABLED, "", "") \
+ macro(ImageControlsEnabled, imageControlsEnabled, Bool, bool, false, "", "") \
+ macro(EnableInheritURIQueryComponent, enableInheritURIQueryComponent, Bool, bool, false, "", "") \
+ macro(ServiceControlsEnabled, serviceControlsEnabled, Bool, bool, false, "", "") \
+ macro(NewBlockInsideInlineModelEnabled, newBlockInsideInlineModelEnabled, Bool, bool, false, "", "") \
+ macro(DeferredCSSParserEnabled, deferredCSSParserEnabled, Bool, bool, false, "", "") \
+ macro(HTTPEquivEnabled, httpEquivEnabled, Bool, bool, true, "", "") \
+ macro(MockCaptureDevicesEnabled, mockCaptureDevicesEnabled, Bool, bool, false, "", "") \
+ macro(MediaCaptureRequiresSecureConnection, mediaCaptureRequiresSecureConnection, Bool, bool, true, "", "") \
+ macro(ShadowDOMEnabled, shadowDOMEnabled, Bool, bool, true, "Shadow DOM", "HTML Shadow DOM prototype") \
+ macro(FetchAPIEnabled, fetchAPIEnabled, Bool, bool, true, "", "") \
+ macro(DownloadAttributeEnabled, downloadAttributeEnabled, Bool, bool, true, "", "") \
+ macro(SelectionPaintingWithoutSelectionGapsEnabled, selectionPaintingWithoutSelectionGapsEnabled, Bool, bool, false, "", "") \
+ macro(ApplePayEnabled, applePayEnabled, Bool, bool, false, "", "") \
+ macro(ApplePayCapabilityDisclosureAllowed, applePayCapabilityDisclosureAllowed, Bool, bool, true, "", "") \
+ macro(VisualViewportEnabled, visualViewportEnabled, Bool, bool, true, "", "") \
+ macro(NeedsStorageAccessFromFileURLsQuirk, needsStorageAccessFromFileURLsQuirk, Bool, bool, true, "", "") \
+ macro(LargeImageAsyncDecodingEnabled, largeImageAsyncDecodingEnabled, Bool, bool, true, "", "") \
+ macro(AnimatedImageAsyncDecodingEnabled, animatedImageAsyncDecodingEnabled, Bool, bool, true, "", "") \
+ macro(CustomElementsEnabled, customElementsEnabled, Bool, bool, true, "", "") \
+ macro(EncryptedMediaAPIEnabled, encryptedMediaAPIEnabled, Bool, bool, false, "", "") \
+ macro(IntersectionObserverEnabled, intersectionObserverEnabled, Bool, bool, false, "Intersection Observer", "Enable Intersection Observer support") \
+ macro(InteractiveFormValidationEnabled, interactiveFormValidationEnabled, Bool, bool, DEFAULT_HTML_INTERACTIVE_FORM_VALIDATION_ENABLED, "HTML Interactive Form Validation", "HTML interactive form validation") \
+ macro(ShouldSuppressKeyboardInputDuringProvisionalNavigation, shouldSuppressKeyboardInputDuringProvisionalNavigation, Bool, bool, false, "", "") \
+ macro(CSSGridLayoutEnabled, cssGridLayoutEnabled, Bool, bool, true, "CSS Grid", "CSS Grid Layout Module support") \
+ macro(ResourceTimingEnabled, resourceTimingEnabled, Bool, bool, false, "Resource Timing", "Enable ResourceTiming API") \
+ \
+
+#define FOR_EACH_WEBKIT_DOUBLE_PREFERENCE(macro) \
+ macro(IncrementalRenderingSuppressionTimeout, incrementalRenderingSuppressionTimeout, Double, double, 5, "", "") \
+ macro(MinimumFontSize, minimumFontSize, Double, double, 0, "", "") \
+ macro(MinimumLogicalFontSize, minimumLogicalFontSize, Double, double, 9, "", "") \
+ macro(MinimumZoomFontSize, minimumZoomFontSize, Double, double, WebCore::Settings::defaultMinimumZoomFontSize(), "", "") \
+ macro(DefaultFontSize, defaultFontSize, Double, double, 16, "", "") \
+ macro(DefaultFixedFontSize, defaultFixedFontSize, Double, double, 13, "", "") \
+ macro(LayoutInterval, layoutInterval, Double, double, -1, "", "") \
+ macro(MaxParseDuration, maxParseDuration, Double, double, -1, "", "") \
+ macro(PasswordEchoDuration, passwordEchoDuration, Double, double, 2, "", "") \
+ \
+
+#define FOR_EACH_WEBKIT_UINT32_PREFERENCE(macro) \
+ macro(FontSmoothingLevel, fontSmoothingLevel, UInt32, uint32_t, FontSmoothingLevelMedium, "", "") \
+ macro(LayoutFallbackWidth, layoutFallbackWidth, UInt32, uint32_t, 980, "", "") \
+ macro(DeviceWidth, deviceWidth, UInt32, uint32_t, 0, "", "") \
+ macro(DeviceHeight, deviceHeight, UInt32, uint32_t, 0, "", "") \
+ macro(EditableLinkBehavior, editableLinkBehavior, UInt32, uint32_t, WebCore::EditableLinkNeverLive, "", "") \
+ macro(InspectorAttachedHeight, inspectorAttachedHeight, UInt32, uint32_t, 300, "", "") \
+ macro(InspectorAttachedWidth, inspectorAttachedWidth, UInt32, uint32_t, 750, "", "") \
+ macro(InspectorAttachmentSide, inspectorAttachmentSide, UInt32, uint32_t, 0, "", "") \
+ macro(StorageBlockingPolicy, storageBlockingPolicy, UInt32, uint32_t, WebCore::SecurityOrigin::BlockThirdPartyStorage, "", "") \
+ macro(JavaScriptRuntimeFlags, javaScriptRuntimeFlags, UInt32, uint32_t, 0, "", "") \
+ macro(DataDetectorTypes, dataDetectorTypes, UInt32, uint32_t, 0, "", "") \
+ macro(UserInterfaceDirectionPolicy, userInterfaceDirectionPolicy, UInt32, uint32_t, 0, "", "") \
+ macro(SystemLayoutDirection, systemLayoutDirection, UInt32, uint32_t, 0, "", "") \
+ \
+
+#define FOR_EACH_WEBKIT_DEBUG_BOOL_PREFERENCE(macro) \
+ macro(AcceleratedDrawingEnabled, acceleratedDrawingEnabled, Bool, bool, DEFAULT_ACCELERATED_DRAWING_ENABLED, "", "") \
+ macro(DisplayListDrawingEnabled, displayListDrawingEnabled, Bool, bool, false, "", "") \
+ macro(CompositingBordersVisible, compositingBordersVisible, Bool, bool, false, "", "") \
+ macro(CompositingRepaintCountersVisible, compositingRepaintCountersVisible, Bool, bool, false, "", "") \
+ macro(TiledScrollingIndicatorVisible, tiledScrollingIndicatorVisible, Bool, bool, false, "", "") \
+ macro(SimpleLineLayoutDebugBordersEnabled, simpleLineLayoutDebugBordersEnabled, Bool, bool, false, "", "") \
+ macro(DeveloperExtrasEnabled, developerExtrasEnabled, Bool, bool, false, "", "") \
+ macro(LogsPageMessagesToSystemConsoleEnabled, logsPageMessagesToSystemConsoleEnabled, Bool, bool, false, "", "") \
+ macro(IgnoreViewportScalingConstraints, ignoreViewportScalingConstraints, Bool, bool, true, "", "") \
+ macro(ForceAlwaysUserScalable, forceAlwaysUserScalable, Bool, bool, false, "", "") \
+ macro(ResourceUsageOverlayVisible, resourceUsageOverlayVisible, Bool, bool, false, "", "") \
+ \
+
+#define FOR_EACH_WEBKIT_DEBUG_UINT32_PREFERENCE(macro) \
+ macro(VisibleDebugOverlayRegions, visibleDebugOverlayRegions, UInt32, uint32_t, 0, "", "")
+
+// Our XCode build system does not currently have any concept of DEVELOPER_MODE.
+// Cocoa ports must disable experimental features on release branches for now.
+#if ENABLE(DEVELOPER_MODE) || PLATFORM(COCOA)
+#define DEFAULT_EXPERIMENTAL_FEATURES_ENABLED true
+#else
+#define DEFAULT_EXPERIMENTAL_FEATURES_ENABLED false
+#endif
+
+#if PLATFORM(COCOA)
+#define DEFAULT_MODERN_MEDIA_CONTROLS_ENABLED true
+#else
+#define DEFAULT_MODERN_MEDIA_CONTROLS_ENABLED false
+#endif
+
+// For experimental features:
+// - The type should be boolean.
+// - You must provide the last two parameters for all experimental features. They
+// are the text exposed to the user from the WebKit client.
+// - They should be alphabetically ordered by the human readable text.
+// - The default value may be either false (for very unstable features) or
+// DEFAULT_EXPERIMENTAL_FEATURE_ENABLED (for features that are ready for
+// wider testing).
+
+#define FOR_EACH_WEBKIT_EXPERIMENTAL_FEATURE_PREFERENCE(macro) \
+ macro(SpringTimingFunctionEnabled, springTimingFunctionEnabled, Bool, bool, DEFAULT_EXPERIMENTAL_FEATURES_ENABLED, "CSS Spring Animations", "CSS Spring Animation prototype") \
+ macro(GamepadsEnabled, gamepadsEnabled, Bool, bool, DEFAULT_EXPERIMENTAL_FEATURES_ENABLED, "Gamepads", "Web Gamepad API support") \
+ macro(LinkPreloadEnabled, linkPreloadEnabled, Bool, bool, DEFAULT_EXPERIMENTAL_FEATURES_ENABLED, "Link Preload", "Link preload support") \
+ macro(ModernMediaControlsEnabled, modernMediaControlsEnabled, Bool, bool, DEFAULT_MODERN_MEDIA_CONTROLS_ENABLED, "Modern Media Controls", "Use modern media controls look") \
+ macro(InputEventsEnabled, inputEventsEnabled, Bool, bool, DEFAULT_EXPERIMENTAL_FEATURES_ENABLED, "Input Events", "Enable InputEvents support") \
+ macro(PeerConnectionEnabled, peerConnectionEnabled, Bool, bool, false, "WebRTC", "Enable WebRTC API") \
+ macro(SubtleCryptoEnabled, subtleCryptoEnabled, Bool, bool, DEFAULT_EXPERIMENTAL_FEATURES_ENABLED, "SubtleCrypto", "Enable SubtleCrypto support") \
+ macro(UserTimingEnabled, userTimingEnabled, Bool, bool, false, "User Timing", "Enable UserTiming API") \
+ macro(WebAnimationsEnabled, webAnimationsEnabled, Bool, bool, false, "Web Animations", "Web Animations prototype") \
+ macro(WebGL2Enabled, webGL2Enabled, Bool, bool, DEFAULT_EXPERIMENTAL_FEATURES_ENABLED, "WebGL 2.0", "WebGL 2 prototype") \
+ \
+
+#if PLATFORM(COCOA)
+
+#if PLATFORM(IOS)
+#define DEFAULT_CURSIVE_FONT_FAMILY "Snell Roundhand"
+#define DEFAULT_PICTOGRAPH_FONT_FAMILY "AppleColorEmoji"
+#else
+#define DEFAULT_CURSIVE_FONT_FAMILY "Apple Chancery"
+#define DEFAULT_PICTOGRAPH_FONT_FAMILY "Apple Color Emoji"
+#endif
+
+
+#define FOR_EACH_WEBKIT_FONT_FAMILY_PREFERENCE(macro) \
+ macro(StandardFontFamily, standardFontFamily, String, String, "Times", "", "") \
+ macro(CursiveFontFamily, cursiveFontFamily, String, String, DEFAULT_CURSIVE_FONT_FAMILY, "", "") \
+ macro(FantasyFontFamily, fantasyFontFamily, String, String, "Papyrus", "", "") \
+ macro(FixedFontFamily, fixedFontFamily, String, String, "Courier", "", "") \
+ macro(SansSerifFontFamily, sansSerifFontFamily, String, String, "Helvetica", "", "") \
+ macro(SerifFontFamily, serifFontFamily, String, String, "Times", "", "") \
+ macro(PictographFontFamily, pictographFontFamily, String, String, "Apple Color Emoji", "", "") \
+ \
+
+#elif PLATFORM(GTK)
+
+#define FOR_EACH_WEBKIT_FONT_FAMILY_PREFERENCE(macro) \
+ macro(StandardFontFamily, standardFontFamily, String, String, "Times", "", "") \
+ macro(CursiveFontFamily, cursiveFontFamily, String, String, "Comic Sans MS", "", "") \
+ macro(FantasyFontFamily, fantasyFontFamily, String, String, "Impact", "", "") \
+ macro(FixedFontFamily, fixedFontFamily, String, String, "Courier New", "", "") \
+ macro(SansSerifFontFamily, sansSerifFontFamily, String, String, "Helvetica", "", "") \
+ macro(SerifFontFamily, serifFontFamily, String, String, "Times", "", "") \
+ macro(PictographFontFamily, pictographFontFamily, String, String, "Times", "", "") \
+ \
+
+#endif
+
+#define FOR_EACH_WEBKIT_STRING_PREFERENCE(macro) \
+ FOR_EACH_WEBKIT_FONT_FAMILY_PREFERENCE(macro) \
+ macro(DefaultTextEncodingName, defaultTextEncodingName, String, String, defaultTextEncodingNameForSystemLanguage(), "", "") \
+ macro(FTPDirectoryTemplatePath, ftpDirectoryTemplatePath, String, String, "", "", "") \
+ \
+
+#define FOR_EACH_WEBKIT_STRING_PREFERENCE_NOT_IN_WEBCORE(macro) \
+ macro(InspectorWindowFrame, inspectorWindowFrame, String, String, "", "", "") \
+ \
+
+#define FOR_EACH_WEBKIT_DEBUG_PREFERENCE(macro) \
+ FOR_EACH_WEBKIT_DEBUG_BOOL_PREFERENCE(macro) \
+ FOR_EACH_WEBKIT_DEBUG_UINT32_PREFERENCE(macro) \
+ \
+
+#define FOR_EACH_WEBKIT_PREFERENCE(macro) \
+ FOR_EACH_WEBKIT_BOOL_PREFERENCE(macro) \
+ FOR_EACH_WEBKIT_DOUBLE_PREFERENCE(macro) \
+ FOR_EACH_WEBKIT_UINT32_PREFERENCE(macro) \
+ FOR_EACH_WEBKIT_STRING_PREFERENCE(macro) \
+ FOR_EACH_WEBKIT_STRING_PREFERENCE_NOT_IN_WEBCORE(macro) \
+ \
+
diff --git a/Source/WebKit2/Shared/WebPreferencesKeys.cpp b/Source/WebKit2/Shared/WebPreferencesKeys.cpp
new file mode 100644
index 000000000..8467cd3d1
--- /dev/null
+++ b/Source/WebKit2/Shared/WebPreferencesKeys.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2010, 2011 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.
+ */
+
+#include "config.h"
+#include "WebPreferencesKeys.h"
+
+#include <wtf/NeverDestroyed.h>
+
+namespace WebKit {
+namespace WebPreferencesKey {
+
+#define DEFINE_KEY_GETTERS(KeyUpper, KeyLower, TypeName, Type, DefaultValue, HumanReadableName, HumanReadableDescription) \
+ const String& KeyLower##Key() \
+ { \
+ static NeverDestroyed<String> key(ASCIILiteral(#KeyUpper)); \
+ return key; \
+ }
+
+FOR_EACH_WEBKIT_PREFERENCE(DEFINE_KEY_GETTERS)
+FOR_EACH_WEBKIT_DEBUG_PREFERENCE(DEFINE_KEY_GETTERS)
+FOR_EACH_WEBKIT_EXPERIMENTAL_FEATURE_PREFERENCE(DEFINE_KEY_GETTERS)
+
+#undef DEFINE_KEY_GETTERS
+
+} // namespace WebPreferencesKey
+} // namespace WebKit
diff --git a/Source/WebKit2/Shared/OriginAndDatabases.h b/Source/WebKit2/Shared/WebPreferencesKeys.h
index 487338f95..dffc3755c 100644
--- a/Source/WebKit2/Shared/OriginAndDatabases.h
+++ b/Source/WebKit2/Shared/WebPreferencesKeys.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2011, 2012 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -23,34 +23,24 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef OriginAndDatabases_h
-#define OriginAndDatabases_h
+#ifndef WebPreferencesKeys_h
+#define WebPreferencesKeys_h
-#if ENABLE(SQL_DATABASE)
-
-#include <WebCore/DatabaseDetails.h>
-#include <wtf/Vector.h>
+#include "WebPreferencesDefinitions.h"
#include <wtf/text/WTFString.h>
-namespace IPC {
- class ArgumentDecoder;
- class ArgumentEncoder;
-}
-
namespace WebKit {
+namespace WebPreferencesKey {
-struct OriginAndDatabases {
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, OriginAndDatabases&);
+#define DECLARE_KEY_GETTERS(KeyUpper, KeyLower, TypeName, Type, DefaultValue, HumanReadableName, HumanReadableDescription) const String& KeyLower##Key();
- String originIdentifier;
- uint64_t originQuota;
- uint64_t originUsage;
- Vector<WebCore::DatabaseDetails> databases;
-};
+FOR_EACH_WEBKIT_PREFERENCE(DECLARE_KEY_GETTERS)
+FOR_EACH_WEBKIT_DEBUG_PREFERENCE(DECLARE_KEY_GETTERS)
+FOR_EACH_WEBKIT_EXPERIMENTAL_FEATURE_PREFERENCE(DECLARE_KEY_GETTERS)
-} // namespace WebKit
+#undef DECLARE_KEY_GETTERS
-#endif // ENABLE(SQL_DATABASE)
+} // namespace WebPreferencesKey
+} // namespace WebKit
-#endif // OriginAndDatabases_h
+#endif // WebPreferencesKeys_h
diff --git a/Source/WebKit2/Shared/WebPreferencesStore.cpp b/Source/WebKit2/Shared/WebPreferencesStore.cpp
index 60c2e0df3..458578394 100644
--- a/Source/WebKit2/Shared/WebPreferencesStore.cpp
+++ b/Source/WebKit2/Shared/WebPreferencesStore.cpp
@@ -28,25 +28,14 @@
#include "FontSmoothingLevel.h"
#include "WebCoreArgumentCoders.h"
+#include "WebPreferencesKeys.h"
#include <WebCore/Settings.h>
+#include <WebCore/TextEncodingRegistry.h>
#include <wtf/NeverDestroyed.h>
-namespace WebKit {
-
-namespace WebPreferencesKey {
-
-#define DEFINE_KEY_GETTERS(KeyUpper, KeyLower, TypeName, Type, DefaultValue) \
- const String& KeyLower##Key() \
- { \
- static NeverDestroyed<String> key(ASCIILiteral(#KeyUpper)); \
- return key; \
- }
-
- FOR_EACH_WEBKIT_PREFERENCE(DEFINE_KEY_GETTERS)
+using namespace WebCore;
-#undef DEFINE_KEY_GETTERS
-
-} // namespace WebPreferencesKey
+namespace WebKit {
typedef HashMap<String, bool> BoolOverridesMap;
@@ -56,30 +45,87 @@ static BoolOverridesMap& boolTestRunnerOverridesMap()
return map;
}
+void WebPreferencesStore::Value::encode(IPC::Encoder& encoder) const
+{
+ encoder.encodeEnum(m_type);
+
+ switch (m_type) {
+ case Type::None:
+ break;
+ case Type::String:
+ encoder << m_string;
+ break;
+ case Type::Bool:
+ encoder << m_bool;
+ break;
+ case Type::UInt32:
+ encoder << m_uint32;
+ break;
+ case Type::Double:
+ encoder << m_double;
+ break;
+ }
+}
+
+bool WebPreferencesStore::Value::decode(IPC::Decoder& decoder, Value& result)
+{
+ Value::Type type;
+ if (!decoder.decodeEnum(type))
+ return false;
+
+ switch (type) {
+ case Type::None:
+ break;
+ case Type::String: {
+ String value;
+ if (!decoder.decode(value))
+ return false;
+ result = Value(value);
+ break;
+ }
+ case Type::Bool: {
+ bool value;
+ if (!decoder.decode(value))
+ return false;
+ result = Value(value);
+ break;
+ }
+ case Type::UInt32: {
+ uint32_t value;
+ if (!decoder.decode(value))
+ return false;
+ result = Value(value);
+ break;
+ }
+ case Type::Double: {
+ double value;
+ if (!decoder.decode(value))
+ return false;
+ result = Value(value);
+ break;
+ }
+ default:
+ return false;
+ }
+
+ return true;
+}
+
WebPreferencesStore::WebPreferencesStore()
{
}
-void WebPreferencesStore::encode(IPC::ArgumentEncoder& encoder) const
+void WebPreferencesStore::encode(IPC::Encoder& encoder) const
{
- encoder << m_stringValues;
- encoder << m_boolValues;
- encoder << m_uint32Values;
- encoder << m_doubleValues;
- encoder << m_floatValues;
+ encoder << m_values;
+ encoder << m_overridenDefaults;
}
-bool WebPreferencesStore::decode(IPC::ArgumentDecoder& decoder, WebPreferencesStore& result)
+bool WebPreferencesStore::decode(IPC::Decoder& decoder, WebPreferencesStore& result)
{
- if (!decoder.decode(result.m_stringValues))
- return false;
- if (!decoder.decode(result.m_boolValues))
+ if (!decoder.decode(result.m_values))
return false;
- if (!decoder.decode(result.m_uint32Values))
- return false;
- if (!decoder.decode(result.m_doubleValues))
- return false;
- if (!decoder.decode(result.m_floatValues))
+ if (!decoder.decode(result.m_overridenDefaults))
return false;
return true;
}
@@ -94,149 +140,131 @@ void WebPreferencesStore::removeTestRunnerOverrides()
boolTestRunnerOverridesMap().clear();
}
+template <typename T> struct ToType { };
-template<typename MappedType>
-MappedType defaultValueForKey(const String&);
+template<> struct ToType<String> { static const auto value = WebPreferencesStore::Value::Type::String; };
+template<> struct ToType<bool> { static const auto value = WebPreferencesStore::Value::Type::Bool; };
+template<> struct ToType<uint32_t> { static const auto value = WebPreferencesStore::Value::Type::UInt32; };
+template<> struct ToType<double> { static const auto value = WebPreferencesStore::Value::Type::Double; };
-template<>
-String defaultValueForKey(const String& key)
-{
- static HashMap<String, String>& defaults = *new HashMap<String, String>;
- if (defaults.isEmpty()) {
-#define DEFINE_STRING_DEFAULTS(KeyUpper, KeyLower, TypeName, Type, DefaultValue) defaults.set(WebPreferencesKey::KeyLower##Key(), DefaultValue);
- FOR_EACH_WEBKIT_STRING_PREFERENCE(DEFINE_STRING_DEFAULTS)
- FOR_EACH_WEBKIT_STRING_PREFERENCE_NOT_IN_WEBCORE(DEFINE_STRING_DEFAULTS)
-#undef DEFINE_STRING_DEFAULTS
- }
- return defaults.get(key);
-}
+template<typename MappedType> MappedType as(const WebPreferencesStore::Value&);
-template<>
-bool defaultValueForKey(const String& key)
-{
- static HashMap<String, bool>& defaults = *new HashMap<String, bool>;
- if (defaults.isEmpty()) {
-#define DEFINE_BOOL_DEFAULTS(KeyUpper, KeyLower, TypeName, Type, DefaultValue) defaults.set(WebPreferencesKey::KeyLower##Key(), DefaultValue);
- FOR_EACH_WEBKIT_BOOL_PREFERENCE(DEFINE_BOOL_DEFAULTS)
-#undef DEFINE_BOOL_DEFAULTS
- }
+template<> String as<String>(const WebPreferencesStore::Value& value) { return value.asString(); }
+template<> bool as<bool>(const WebPreferencesStore::Value& value) { return value.asBool(); }
+template<> uint32_t as<uint32_t>(const WebPreferencesStore::Value& value) { return value.asUInt32(); }
+template<> double as<double>(const WebPreferencesStore::Value& value) { return value.asDouble(); }
- return defaults.get(key);
-}
-template<>
-uint32_t defaultValueForKey(const String& key)
+static WebPreferencesStore::ValueMap& defaults()
{
- static HashMap<String, uint32_t>& defaults = *new HashMap<String, uint32_t>;
- if (defaults.isEmpty()) {
-#define DEFINE_UINT32_DEFAULTS(KeyUpper, KeyLower, TypeName, Type, DefaultValue) defaults.set(WebPreferencesKey::KeyLower##Key(), DefaultValue);
- FOR_EACH_WEBKIT_UINT32_PREFERENCE(DEFINE_UINT32_DEFAULTS)
-#undef DEFINE_UINT32_DEFAULTS
+ static NeverDestroyed<WebPreferencesStore::ValueMap> defaults;
+ if (defaults.get().isEmpty()) {
+#define DEFINE_DEFAULTS(KeyUpper, KeyLower, TypeName, Type, DefaultValue, HumanReadableName, HumanReadableDescription) defaults.get().set(WebPreferencesKey::KeyLower##Key(), WebPreferencesStore::Value((Type)DefaultValue));
+ FOR_EACH_WEBKIT_PREFERENCE(DEFINE_DEFAULTS)
+ FOR_EACH_WEBKIT_DEBUG_PREFERENCE(DEFINE_DEFAULTS)
+ FOR_EACH_WEBKIT_EXPERIMENTAL_FEATURE_PREFERENCE(DEFINE_DEFAULTS)
+#undef DEFINE_DEFAULTS
}
- return defaults.get(key);
+ return defaults;
}
-template<>
-double defaultValueForKey(const String& key)
+template<typename MappedType>
+static MappedType valueForKey(const WebPreferencesStore::ValueMap& values, const WebPreferencesStore::ValueMap& overridenDefaults, const String& key)
{
- static HashMap<String, double>& defaults = *new HashMap<String, double>;
- if (defaults.isEmpty()) {
-#define DEFINE_DOUBLE_DEFAULTS(KeyUpper, KeyLower, TypeName, Type, DefaultValue) defaults.set(WebPreferencesKey::KeyLower##Key(), DefaultValue);
- FOR_EACH_WEBKIT_DOUBLE_PREFERENCE(DEFINE_DOUBLE_DEFAULTS)
-#undef DEFINE_DOUBLE_DEFAULTS
- }
+ auto valuesIt = values.find(key);
+ if (valuesIt != values.end() && valuesIt->value.type() == ToType<MappedType>::value)
+ return as<MappedType>(valuesIt->value);
- return defaults.get(key);
-}
+ auto overridenDefaultsIt = overridenDefaults.find(key);
+ if (overridenDefaultsIt != overridenDefaults.end() && overridenDefaultsIt->value.type() == ToType<MappedType>::value)
+ return as<MappedType>(overridenDefaultsIt->value);
-template<>
-float defaultValueForKey(const String& key)
-{
- static HashMap<String, float>& defaults = *new HashMap<String, float>;
- if (defaults.isEmpty()) {
-#define DEFINE_FLOAT_DEFAULTS(KeyUpper, KeyLower, TypeName, Type, DefaultValue) defaults.set(WebPreferencesKey::KeyLower##Key(), DefaultValue);
- FOR_EACH_WEBKIT_FLOAT_PREFERENCE(DEFINE_FLOAT_DEFAULTS)
-#undef DEFINE_FLOAT_DEFAULTS
- }
+ auto& defaultsMap = defaults();
+ auto defaultsIt = defaultsMap.find(key);
+ if (defaultsIt != defaultsMap.end() && defaultsIt->value.type() == ToType<MappedType>::value)
+ return as<MappedType>(defaultsIt->value);
- return defaults.get(key);
+ return MappedType();
}
-template<typename MapType>
-static typename MapType::MappedType valueForKey(const MapType& map, const typename MapType::KeyType& key)
-{
- typename MapType::const_iterator it = map.find(key);
- if (it != map.end())
- return it->value;
-
- return defaultValueForKey<typename MapType::MappedType>(key);
-}
-
-template<typename MapType>
-static bool setValueForKey(MapType& map, const typename MapType::KeyType& key, const typename MapType::MappedType& value)
+template<typename MappedType>
+static bool setValueForKey(WebPreferencesStore::ValueMap& map, const WebPreferencesStore::ValueMap& overridenDefaults, const String& key, const MappedType& value)
{
- typename MapType::MappedType existingValue = valueForKey(map, key);
+ MappedType existingValue = valueForKey<MappedType>(map, overridenDefaults, key);
if (existingValue == value)
return false;
-
- map.set(key, value);
+
+ map.set(key, WebPreferencesStore::Value(value));
return true;
}
bool WebPreferencesStore::setStringValueForKey(const String& key, const String& value)
{
- return setValueForKey(m_stringValues, key, value);
+ return setValueForKey<String>(m_values, m_overridenDefaults, key, value);
}
String WebPreferencesStore::getStringValueForKey(const String& key) const
{
- return valueForKey(m_stringValues, key);
+ return valueForKey<String>(m_values, m_overridenDefaults, key);
}
bool WebPreferencesStore::setBoolValueForKey(const String& key, bool value)
{
- return setValueForKey(m_boolValues, key, value);
+ return setValueForKey<bool>(m_values, m_overridenDefaults, key, value);
}
bool WebPreferencesStore::getBoolValueForKey(const String& key) const
{
// FIXME: Extend overriding to other key types used from TestRunner.
- BoolOverridesMap::const_iterator it = boolTestRunnerOverridesMap().find(key);
+ auto it = boolTestRunnerOverridesMap().find(key);
if (it != boolTestRunnerOverridesMap().end())
return it->value;
- return valueForKey(m_boolValues, key);
+
+ return valueForKey<bool>(m_values, m_overridenDefaults, key);
}
bool WebPreferencesStore::setUInt32ValueForKey(const String& key, uint32_t value)
{
- return setValueForKey(m_uint32Values, key, value);
+ return setValueForKey<uint32_t>(m_values, m_overridenDefaults, key, value);
}
uint32_t WebPreferencesStore::getUInt32ValueForKey(const String& key) const
{
- return valueForKey(m_uint32Values, key);
+ return valueForKey<uint32_t>(m_values, m_overridenDefaults, key);
}
bool WebPreferencesStore::setDoubleValueForKey(const String& key, double value)
{
- return setValueForKey(m_doubleValues, key, value);
+ return setValueForKey<double>(m_values, m_overridenDefaults, key, value);
}
double WebPreferencesStore::getDoubleValueForKey(const String& key) const
{
- return valueForKey(m_doubleValues, key);
+ return valueForKey<double>(m_values, m_overridenDefaults, key);
+}
+
+// Overriden Defaults
+
+void WebPreferencesStore::setOverrideDefaultsStringValueForKey(const String& key, String value)
+{
+ m_overridenDefaults.set(key, Value(value));
+}
+
+void WebPreferencesStore::setOverrideDefaultsBoolValueForKey(const String& key, bool value)
+{
+ m_overridenDefaults.set(key, Value(value));
}
-bool WebPreferencesStore::setFloatValueForKey(const String& key, float value)
+void WebPreferencesStore::setOverrideDefaultsUInt32ValueForKey(const String& key, uint32_t value)
{
- return setValueForKey(m_floatValues, key, value);
+ m_overridenDefaults.set(key, Value(value));
}
-float WebPreferencesStore::getFloatValueForKey(const String& key) const
+void WebPreferencesStore::setOverrideDefaultsDoubleValueForKey(const String& key, double value)
{
- return valueForKey(m_floatValues, key);
+ m_overridenDefaults.set(key, Value(value));
}
} // namespace WebKit
diff --git a/Source/WebKit2/Shared/WebPreferencesStore.h b/Source/WebKit2/Shared/WebPreferencesStore.h
index d3457f539..5c90138a6 100644
--- a/Source/WebKit2/Shared/WebPreferencesStore.h
+++ b/Source/WebKit2/Shared/WebPreferencesStore.h
@@ -26,245 +26,19 @@
#ifndef WebPreferencesStore_h
#define WebPreferencesStore_h
-#include "ArgumentDecoder.h"
-#include "ArgumentEncoder.h"
+#include "Decoder.h"
+#include "Encoder.h"
#include <wtf/HashMap.h>
#include <wtf/text/StringHash.h>
#include <wtf/text/WTFString.h>
namespace WebKit {
-// macro(KeyUpper, KeyLower, TypeNameUpper, TypeName, DefaultValue)
-
-#if PLATFORM(GTK)
-#define DEFAULT_WEBKIT_TABSTOLINKS_ENABLED true
-#else
-#define DEFAULT_WEBKIT_TABSTOLINKS_ENABLED false
-#endif
-
-#if ENABLE(SMOOTH_SCROLLING)
-#define DEFAULT_WEBKIT_SCROLL_ANIMATOR_ENABLED true
-#else
-#define DEFAULT_WEBKIT_SCROLL_ANIMATOR_ENABLED false
-#endif
-
-#if !PLATFORM(IOS) && PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
-#define DEFAULT_SCREEN_FONT_SUBSTITUTION_ENABLED false
-#else
-#define DEFAULT_SCREEN_FONT_SUBSTITUTION_ENABLED true
-#endif
-
-#if PLATFORM(MAC)
-#define DEFAULT_HIDDEN_PAGE_DOM_TIMER_THROTTLING_ENABLED true
-#define DEFAULT_HIDDEN_PAGE_CSS_ANIMATION_SUSPENSION_ENABLED true
-#define DEFAULT_PDFPLUGIN_ENABLED true
-#else
-#define DEFAULT_HIDDEN_PAGE_DOM_TIMER_THROTTLING_ENABLED false
-#define DEFAULT_HIDDEN_PAGE_CSS_ANIMATION_SUSPENSION_ENABLED false
-#define DEFAULT_PDFPLUGIN_ENABLED false
-#endif
-
-#if PLATFORM(IOS)
-#define DEFAULT_VIDEO_PLUGIN_PROXY_ENABLED true
-#else
-#define DEFAULT_VIDEO_PLUGIN_PROXY_ENABLED false
-#endif
-
-#define FOR_EACH_WEBKIT_BOOL_PREFERENCE(macro) \
- macro(JavaScriptEnabled, javaScriptEnabled, Bool, bool, true) \
- macro(JavaScriptMarkupEnabled, javaScriptMarkupEnabled, Bool, bool, true) \
- macro(LoadsImagesAutomatically, loadsImagesAutomatically, Bool, bool, true) \
- macro(LoadsSiteIconsIgnoringImageLoadingPreference, loadsSiteIconsIgnoringImageLoadingPreference, Bool, bool, false) \
- macro(PluginsEnabled, pluginsEnabled, Bool, bool, true) \
- macro(JavaEnabled, javaEnabled, Bool, bool, true) \
- macro(JavaEnabledForLocalFiles, javaEnabledForLocalFiles, Bool, bool, true) \
- macro(OfflineWebApplicationCacheEnabled, offlineWebApplicationCacheEnabled, Bool, bool, false) \
- macro(LocalStorageEnabled, localStorageEnabled, Bool, bool, true) \
- macro(DatabasesEnabled, databasesEnabled, Bool, bool, true) \
- macro(XSSAuditorEnabled, xssAuditorEnabled, Bool, bool, true) \
- macro(FrameFlatteningEnabled, frameFlatteningEnabled, Bool, bool, false) \
- macro(DeveloperExtrasEnabled, developerExtrasEnabled, Bool, bool, false) \
- macro(JavaScriptExperimentsEnabled, javaScriptExperimentsEnabled, Bool, bool, false) \
- macro(PrivateBrowsingEnabled, privateBrowsingEnabled, Bool, bool, false) \
- macro(TextAreasAreResizable, textAreasAreResizable, Bool, bool, true) \
- macro(JavaScriptCanOpenWindowsAutomatically, javaScriptCanOpenWindowsAutomatically, Bool, bool, true) \
- macro(HyperlinkAuditingEnabled, hyperlinkAuditingEnabled, Bool, bool, true) \
- macro(NeedsSiteSpecificQuirks, needsSiteSpecificQuirks, Bool, bool, false) \
- macro(AcceleratedCompositingEnabled, acceleratedCompositingEnabled, Bool, bool, true) \
- macro(ForceCompositingMode, forceCompositingMode, Bool, bool, false) \
- macro(AcceleratedDrawingEnabled, acceleratedDrawingEnabled, Bool, bool, false) \
- macro(CanvasUsesAcceleratedDrawing, canvasUsesAcceleratedDrawing, Bool, bool, true) \
- macro(CompositingBordersVisible, compositingBordersVisible, Bool, bool, false) \
- macro(CompositingRepaintCountersVisible, compositingRepaintCountersVisible, Bool, bool, false) \
- macro(TiledScrollingIndicatorVisible, tiledScrollingIndicatorVisible, Bool, bool, false) \
- macro(WebGLEnabled, webGLEnabled, Bool, bool, true) \
- macro(MultithreadedWebGLEnabled, multithreadedWebGLEnabled, Bool, bool, false) \
- macro(ForceSoftwareWebGLRendering, forceSoftwareWebGLRendering, Bool, bool, false) \
- macro(Accelerated2dCanvasEnabled, accelerated2dCanvasEnabled, Bool, bool, false) \
- macro(CSSRegionsEnabled, cssRegionsEnabled, Bool, bool, true) \
- macro(CSSCompositingEnabled, cssCompositingEnabled, Bool, bool, true) \
- macro(CSSGridLayoutEnabled, cssGridLayoutEnabled, Bool, bool, false) \
- macro(RegionBasedColumnsEnabled, regionBasedColumnsEnabled, Bool, bool, false) \
- macro(ForceFTPDirectoryListings, forceFTPDirectoryListings, Bool, bool, false) \
- macro(TabsToLinks, tabsToLinks, Bool, bool, DEFAULT_WEBKIT_TABSTOLINKS_ENABLED) \
- macro(DNSPrefetchingEnabled, dnsPrefetchingEnabled, Bool, bool, false) \
- macro(WebArchiveDebugModeEnabled, webArchiveDebugModeEnabled, Bool, bool, false) \
- macro(LocalFileContentSniffingEnabled, localFileContentSniffingEnabled, Bool, bool, false) \
- macro(UsesPageCache, usesPageCache, Bool, bool, true) \
- macro(PageCacheSupportsPlugins, pageCacheSupportsPlugins, Bool, bool, true) \
- macro(AuthorAndUserStylesEnabled, authorAndUserStylesEnabled, Bool, bool, true) \
- macro(PaginateDuringLayoutEnabled, paginateDuringLayoutEnabled, Bool, bool, false) \
- macro(DOMPasteAllowed, domPasteAllowed, Bool, bool, false) \
- macro(JavaScriptCanAccessClipboard, javaScriptCanAccessClipboard, Bool, bool, false) \
- macro(ShouldPrintBackgrounds, shouldPrintBackgrounds, Bool, bool, false) \
- macro(FullScreenEnabled, fullScreenEnabled, Bool, bool, false) \
- macro(AsynchronousSpellCheckingEnabled, asynchronousSpellCheckingEnabled, Bool, bool, false) \
- macro(WebSecurityEnabled, webSecurityEnabled, Bool, bool, true) \
- macro(AllowUniversalAccessFromFileURLs, allowUniversalAccessFromFileURLs, Bool, bool, false) \
- macro(AllowFileAccessFromFileURLs, allowFileAccessFromFileURLs, Bool, bool, false) \
- macro(AVFoundationEnabled, isAVFoundationEnabled, Bool, bool, true) \
- macro(MediaPlaybackRequiresUserGesture, mediaPlaybackRequiresUserGesture, Bool, bool, false) \
- macro(MediaPlaybackAllowsInline, mediaPlaybackAllowsInline, Bool, bool, true) \
- macro(InspectorStartsAttached, inspectorStartsAttached, Bool, bool, true) \
- macro(ShowsToolTipOverTruncatedText, showsToolTipOverTruncatedText, Bool, bool, false) \
- macro(MockScrollbarsEnabled, mockScrollbarsEnabled, Bool, bool, false) \
- macro(WebAudioEnabled, webAudioEnabled, Bool, bool, false) \
- macro(ApplicationChromeModeEnabled, applicationChromeMode, Bool, bool, false) \
- macro(SuppressesIncrementalRendering, suppressesIncrementalRendering, Bool, bool, false) \
- macro(BackspaceKeyNavigationEnabled, backspaceKeyNavigationEnabled, Bool, bool, true) \
- macro(CaretBrowsingEnabled, caretBrowsingEnabled, Bool, bool, false) \
- macro(ShouldDisplaySubtitles, shouldDisplaySubtitles, Bool, bool, false) \
- macro(ShouldDisplayCaptions, shouldDisplayCaptions, Bool, bool, false) \
- macro(ShouldDisplayTextDescriptions, shouldDisplayTextDescriptions, Bool, bool, false) \
- macro(NotificationsEnabled, notificationsEnabled, Bool, bool, true) \
- macro(ShouldRespectImageOrientation, shouldRespectImageOrientation, Bool, bool, false) \
- macro(WantsBalancedSetDefersLoadingBehavior, wantsBalancedSetDefersLoadingBehavior, Bool, bool, false) \
- macro(RequestAnimationFrameEnabled, requestAnimationFrameEnabled, Bool, bool, true) \
- macro(DiagnosticLoggingEnabled, diagnosticLoggingEnabled, Bool, bool, false) \
- macro(AsynchronousPluginInitializationEnabled, asynchronousPluginInitializationEnabled, Bool, bool, false) \
- macro(AsynchronousPluginInitializationEnabledForAllPlugins, asynchronousPluginInitializationEnabledForAllPlugins, Bool, bool, false) \
- macro(ArtificialPluginInitializationDelayEnabled, artificialPluginInitializationDelayEnabled, Bool, bool, false) \
- macro(TabToLinksEnabled, tabToLinksEnabled, Bool, bool, false) \
- macro(InteractiveFormValidationEnabled, interactiveFormValidationEnabled, Bool, bool, false) \
- macro(ScrollingPerformanceLoggingEnabled, scrollingPerformanceLoggingEnabled, Bool, bool, false) \
- macro(StorageBlockingPolicy, storageBlockingPolicy, UInt32, uint32_t, 0) \
- macro(ScrollAnimatorEnabled, scrollAnimatorEnabled, Bool, bool, DEFAULT_WEBKIT_SCROLL_ANIMATOR_ENABLED) \
- macro(ScreenFontSubstitutionEnabled, screenFontSubstitutionEnabled, Bool, bool, DEFAULT_SCREEN_FONT_SUBSTITUTION_ENABLED) \
- macro(CookieEnabled, cookieEnabled, Bool, bool, true) \
- macro(PlugInSnapshottingEnabled, plugInSnapshottingEnabled, Bool, bool, false) \
- macro(SnapshotAllPlugIns, snapshotAllPlugIns, Bool, bool, false) \
- macro(AutostartOriginPlugInSnapshottingEnabled, autostartOriginPlugInSnapshottingEnabled, Bool, bool, true) \
- macro(PrimaryPlugInSnapshotDetectionEnabled, primaryPlugInSnapshotDetectionEnabled, Bool, bool, true) \
- macro(PDFPluginEnabled, pdfPluginEnabled, Bool, bool, DEFAULT_PDFPLUGIN_ENABLED) \
- macro(UsesEncodingDetector, usesEncodingDetector, Bool, bool, false) \
- macro(TextAutosizingEnabled, textAutosizingEnabled, Bool, bool, false) \
- macro(AggressiveTileRetentionEnabled, aggressiveTileRetentionEnabled, Bool, bool, false) \
- macro(QTKitEnabled, isQTKitEnabled, Bool, bool, true) \
- macro(LogsPageMessagesToSystemConsoleEnabled, logsPageMessagesToSystemConsoleEnabled, Bool, bool, false) \
- macro(PageVisibilityBasedProcessSuppressionEnabled, pageVisibilityBasedProcessSuppressionEnabled, Bool, bool, false) \
- macro(SmartInsertDeleteEnabled, smartInsertDeleteEnabled, Bool, bool, true) \
- macro(SelectTrailingWhitespaceEnabled, selectTrailingWhitespaceEnabled, Bool, bool, false) \
- macro(ShowsURLsInToolTipsEnabled, showsURLsInToolTipsEnabled, Bool, bool, false) \
- macro(AcceleratedCompositingForOverflowScrollEnabled, acceleratedCompositingForOverflowScrollEnabled, Bool, bool, false) \
- macro(HiddenPageDOMTimerThrottlingEnabled, hiddenPageDOMTimerThrottlingEnabled, Bool, bool, DEFAULT_HIDDEN_PAGE_DOM_TIMER_THROTTLING_ENABLED) \
- macro(HiddenPageCSSAnimationSuspensionEnabled, hiddenPageCSSAnimationSuspensionEnabled, Bool, bool, DEFAULT_HIDDEN_PAGE_CSS_ANIMATION_SUSPENSION_ENABLED) \
- macro(LowPowerVideoAudioBufferSizeEnabled, lowPowerVideoAudioBufferSizeEnabled, Bool, bool, false) \
- macro(ThreadedScrollingEnabled, threadedScrollingEnabled, Bool, bool, true) \
- macro(SimpleLineLayoutEnabled, simpleLineLayoutEnabled, Bool, bool, true) \
- macro(SimpleLineLayoutDebugBordersEnabled, simpleLineLayoutDebugBordersEnabled, Bool, bool, false) \
- macro(BackgroundShouldExtendBeyondPage, backgroundShouldExtendBeyondPage, Bool, bool, false) \
- macro(MediaStreamEnabled, mediaStreamEnabled, Bool, bool, false) \
- macro(VideoPluginProxyEnabled, isVideoPluginProxyEnabled, Bool, bool, DEFAULT_VIDEO_PLUGIN_PROXY_ENABLED) \
- macro(UseLegacyTextAlignPositionedElementBehavior, useLegacyTextAlignPositionedElementBehavior, Bool, bool, false) \
- macro(SpatialNavigationEnabled, spatialNavigationEnabled, Bool, bool, false) \
- macro(MediaSourceEnabled, mediaSourceEnabled, Bool, bool, false) \
- macro(ViewGestureDebuggingEnabled, viewGestureDebuggingEnabled, Bool, bool, false) \
- \
-
-#define FOR_EACH_WEBKIT_DOUBLE_PREFERENCE(macro) \
- macro(PDFScaleFactor, pdfScaleFactor, Double, double, 0) \
- macro(IncrementalRenderingSuppressionTimeout, incrementalRenderingSuppressionTimeout, Double, double, 5) \
- \
-
-#define FOR_EACH_WEBKIT_FLOAT_PREFERENCE(macro) \
- \
-
-#define FOR_EACH_WEBKIT_UINT32_PREFERENCE(macro) \
- macro(FontSmoothingLevel, fontSmoothingLevel, UInt32, uint32_t, FontSmoothingLevelMedium) \
- macro(MinimumFontSize, minimumFontSize, UInt32, uint32_t, 0) \
- macro(MinimumLogicalFontSize, minimumLogicalFontSize, UInt32, uint32_t, 9) \
- macro(DefaultFontSize, defaultFontSize, UInt32, uint32_t, 16) \
- macro(DefaultFixedFontSize, defaultFixedFontSize, UInt32, uint32_t, 13) \
- macro(LayoutFallbackWidth, layoutFallbackWidth, UInt32, uint32_t, 980) \
- macro(DeviceWidth, deviceWidth, UInt32, uint32_t, 0) \
- macro(DeviceHeight, deviceHeight, UInt32, uint32_t, 0) \
- macro(PDFDisplayMode, pdfDisplayMode, UInt32, uint32_t, 1) \
- macro(EditableLinkBehavior, editableLinkBehavior, UInt32, uint32_t, WebCore::EditableLinkNeverLive) \
- macro(InspectorAttachedHeight, inspectorAttachedHeight, UInt32, uint32_t, 300) \
- macro(InspectorAttachedWidth, inspectorAttachedWidth, UInt32, uint32_t, 750) \
- macro(InspectorAttachmentSide, inspectorAttachmentSide, UInt32, uint32_t, 0) \
- \
-
-#if PLATFORM(MAC)
-
-#define FOR_EACH_WEBKIT_FONT_FAMILY_PREFERENCE(macro) \
- macro(StandardFontFamily, standardFontFamily, String, String, "Times") \
- macro(CursiveFontFamily, cursiveFontFamily, String, String, "Apple Chancery") \
- macro(FantasyFontFamily, fantasyFontFamily, String, String, "Papyrus") \
- macro(FixedFontFamily, fixedFontFamily, String, String, "Courier") \
- macro(SansSerifFontFamily, sansSerifFontFamily, String, String, "Helvetica") \
- macro(SerifFontFamily, serifFontFamily, String, String, "Times") \
- macro(PictographFontFamily, pictographFontFamily, String, String, "Apple Color Emoji") \
- \
-
-#elif PLATFORM(GTK) || PLATFORM(EFL)
-
-#define FOR_EACH_WEBKIT_FONT_FAMILY_PREFERENCE(macro) \
- macro(StandardFontFamily, standardFontFamily, String, String, "Times") \
- macro(CursiveFontFamily, cursiveFontFamily, String, String, "Comic Sans MS") \
- macro(FantasyFontFamily, fantasyFontFamily, String, String, "Impact") \
- macro(FixedFontFamily, fixedFontFamily, String, String, "Courier New") \
- macro(SansSerifFontFamily, sansSerifFontFamily, String, String, "Helvetica") \
- macro(SerifFontFamily, serifFontFamily, String, String, "Times") \
- macro(PictographFontFamily, pictographFontFamily, String, String, "Times") \
- \
-
-#endif
-
-#define FOR_EACH_WEBKIT_STRING_PREFERENCE(macro) \
- FOR_EACH_WEBKIT_FONT_FAMILY_PREFERENCE(macro) \
- macro(DefaultTextEncodingName, defaultTextEncodingName, String, String, "ISO-8859-1") \
- macro(FTPDirectoryTemplatePath, ftpDirectoryTemplatePath, String, String, "") \
- \
-
-#define FOR_EACH_WEBKIT_STRING_PREFERENCE_NOT_IN_WEBCORE(macro) \
- macro(InspectorWindowFrame, inspectorWindowFrame, String, String, "") \
- \
-
-#define FOR_EACH_WEBKIT_PREFERENCE(macro) \
- FOR_EACH_WEBKIT_BOOL_PREFERENCE(macro) \
- FOR_EACH_WEBKIT_DOUBLE_PREFERENCE(macro) \
- FOR_EACH_WEBKIT_FLOAT_PREFERENCE(macro) \
- FOR_EACH_WEBKIT_UINT32_PREFERENCE(macro) \
- FOR_EACH_WEBKIT_STRING_PREFERENCE(macro) \
- FOR_EACH_WEBKIT_STRING_PREFERENCE_NOT_IN_WEBCORE(macro) \
- \
-
-namespace WebPreferencesKey {
-
-#define DECLARE_KEY_GETTERS(KeyUpper, KeyLower, TypeName, Type, DefaultValue) const String& KeyLower##Key();
-
-FOR_EACH_WEBKIT_PREFERENCE(DECLARE_KEY_GETTERS)
-
-#undef DECLARE_KEY_GETTERS
-
-} // namespace WebPreferencesKey
-
struct WebPreferencesStore {
WebPreferencesStore();
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, WebPreferencesStore&);
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, WebPreferencesStore&);
// NOTE: The getters in this class have non-standard names to aid in the use of the preference macros.
@@ -280,18 +54,132 @@ struct WebPreferencesStore {
bool setDoubleValueForKey(const String& key, double value);
double getDoubleValueForKey(const String& key) const;
- bool setFloatValueForKey(const String& key, float value);
- float getFloatValueForKey(const String& key) const;
+ void setOverrideDefaultsStringValueForKey(const String& key, String value);
+ void setOverrideDefaultsBoolValueForKey(const String& key, bool value);
+ void setOverrideDefaultsUInt32ValueForKey(const String& key, uint32_t value);
+ void setOverrideDefaultsDoubleValueForKey(const String& key, double value);
// For WebKitTestRunner usage.
static void overrideBoolValueForKey(const String& key, bool value);
static void removeTestRunnerOverrides();
- HashMap<String, String> m_stringValues;
- HashMap<String, bool> m_boolValues;
- HashMap<String, uint32_t> m_uint32Values;
- HashMap<String, double> m_doubleValues;
- HashMap<String, float> m_floatValues;
+ struct Value {
+ enum class Type {
+ None,
+ String,
+ Bool,
+ UInt32,
+ Double,
+ };
+
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, Value&);
+
+ explicit Value() : m_type(Type::None) { }
+ explicit Value(const String& value) : m_type(Type::String), m_string(value) { }
+ explicit Value(bool value) : m_type(Type::Bool), m_bool(value) { }
+ explicit Value(uint32_t value) : m_type(Type::UInt32), m_uint32(value) { }
+ explicit Value(double value) : m_type(Type::Double), m_double(value) { }
+
+ Value(Value&& value)
+ : m_type(value.m_type)
+ {
+ switch (m_type) {
+ case Type::None:
+ break;
+ case Type::String:
+ new (&m_string) String(WTFMove(value.m_string));
+ break;
+ case Type::Bool:
+ m_bool = value.m_bool;
+ break;
+ case Type::UInt32:
+ m_uint32 = value.m_uint32;
+ break;
+ case Type::Double:
+ m_double = value.m_double;
+ break;
+ }
+ }
+
+ Value& operator=(const Value& other)
+ {
+ if (this == &other)
+ return *this;
+
+ destroy();
+
+ m_type = other.m_type;
+ switch (m_type) {
+ case Type::None:
+ break;
+ case Type::String:
+ new (&m_string) String(other.m_string);
+ break;
+ case Type::Bool:
+ m_bool = other.m_bool;
+ break;
+ case Type::UInt32:
+ m_uint32 = other.m_uint32;
+ break;
+ case Type::Double:
+ m_double = other.m_double;
+ break;
+ }
+
+ return *this;
+ }
+
+ ~Value()
+ {
+ destroy();
+ }
+
+ Type type() const { return m_type; }
+
+ String asString() const
+ {
+ ASSERT(m_type == Type::String);
+ return m_string;
+ }
+
+ bool asBool() const
+ {
+ ASSERT(m_type == Type::Bool);
+ return m_bool;
+ }
+
+ uint32_t asUInt32() const
+ {
+ ASSERT(m_type == Type::UInt32);
+ return m_uint32;
+ }
+
+ double asDouble() const
+ {
+ ASSERT(m_type == Type::Double);
+ return m_double;
+ }
+
+ private:
+ void destroy()
+ {
+ if (m_type == Type::String)
+ m_string.~String();
+ }
+
+ Type m_type;
+ union {
+ String m_string;
+ bool m_bool;
+ uint32_t m_uint32;
+ double m_double;
+ };
+ };
+
+ typedef HashMap<String, Value> ValueMap;
+ ValueMap m_values;
+ ValueMap m_overridenDefaults;
};
} // namespace WebKit
diff --git a/Source/WebKit2/Shared/WebProcessCreationParameters.cpp b/Source/WebKit2/Shared/WebProcessCreationParameters.cpp
index eb27b9c0f..7326e7cd2 100644
--- a/Source/WebKit2/Shared/WebProcessCreationParameters.cpp
+++ b/Source/WebKit2/Shared/WebProcessCreationParameters.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010, 2011, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-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
@@ -26,132 +26,172 @@
#include "config.h"
#include "WebProcessCreationParameters.h"
-#include "ArgumentCoders.h"
+#include "APIData.h"
+#if PLATFORM(COCOA)
+#include "ArgumentCodersCF.h"
+#endif
+#include "WebCoreArgumentCoders.h"
namespace WebKit {
WebProcessCreationParameters::WebProcessCreationParameters()
- : shouldTrackVisitedLinks(false)
- , shouldAlwaysUseComplexTextCodePath(false)
- , shouldUseFontSmoothing(true)
- , defaultRequestTimeoutInterval(INT_MAX)
-#if PLATFORM(MAC)
- , nsURLCacheMemoryCapacity(0)
- , nsURLCacheDiskCapacity(0)
- , shouldForceScreenFontSubstitution(false)
- , shouldEnableKerningAndLigaturesByDefault(false)
-#endif
-#if ENABLE(NETWORK_PROCESS)
- , usesNetworkProcess(false)
-#endif
- , memoryCacheDisabled(false)
{
}
-void WebProcessCreationParameters::encode(IPC::ArgumentEncoder& encoder) const
+WebProcessCreationParameters::~WebProcessCreationParameters()
+{
+}
+
+void WebProcessCreationParameters::encode(IPC::Encoder& encoder) const
{
encoder << injectedBundlePath;
encoder << injectedBundlePathExtensionHandle;
+ encoder << initializationUserData;
encoder << applicationCacheDirectory;
+ encoder << applicationCacheFlatFileSubdirectoryName;
encoder << applicationCacheDirectoryExtensionHandle;
- encoder << databaseDirectory;
- encoder << databaseDirectoryExtensionHandle;
- encoder << localStorageDirectory;
- encoder << localStorageDirectoryExtensionHandle;
- encoder << diskCacheDirectory;
- encoder << diskCacheDirectoryExtensionHandle;
- encoder << cookieStorageDirectory;
+ encoder << webSQLDatabaseDirectory;
+ encoder << webSQLDatabaseDirectoryExtensionHandle;
+ encoder << mediaCacheDirectory;
+ encoder << mediaCacheDirectoryExtensionHandle;
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100
+ encoder << uiProcessCookieStorageIdentifier;
+#endif
+#if PLATFORM(IOS)
encoder << cookieStorageDirectoryExtensionHandle;
+ encoder << containerCachesDirectoryExtensionHandle;
+ encoder << containerTemporaryDirectoryExtensionHandle;
+#endif
+ encoder << mediaKeyStorageDirectory;
+ encoder << mediaKeyStorageDirectoryExtensionHandle;
+#if ENABLE(MEDIA_STREAM)
+ encoder << audioCaptureExtensionHandle;
+#endif
encoder << shouldUseTestingNetworkSession;
- encoder << urlSchemesRegistererdAsEmptyDocument;
+ encoder << urlSchemesRegisteredAsEmptyDocument;
encoder << urlSchemesRegisteredAsSecure;
+ encoder << urlSchemesRegisteredAsBypassingContentSecurityPolicy;
encoder << urlSchemesForWhichDomainRelaxationIsForbidden;
encoder << urlSchemesRegisteredAsLocal;
encoder << urlSchemesRegisteredAsNoAccess;
encoder << urlSchemesRegisteredAsDisplayIsolated;
encoder << urlSchemesRegisteredAsCORSEnabled;
-#if ENABLE(CUSTOM_PROTOCOLS)
- encoder << urlSchemesRegisteredForCustomProtocols;
-#endif
-#if USE(SOUP)
-#if !ENABLE(CUSTOM_PROTOCOLS)
- encoder << urlSchemesRegistered;
-#endif
- encoder << cookiePersistentStoragePath;
- encoder << cookiePersistentStorageType;
- encoder.encodeEnum(cookieAcceptPolicy);
- encoder << ignoreTLSErrors;
-#endif
+ encoder << urlSchemesRegisteredAsAlwaysRevalidated;
+ encoder << urlSchemesRegisteredAsCachePartitioned;
encoder.encodeEnum(cacheModel);
- encoder << shouldTrackVisitedLinks;
encoder << shouldAlwaysUseComplexTextCodePath;
+ encoder << shouldEnableMemoryPressureReliefLogging;
+ encoder << shouldSuppressMemoryPressureHandler;
encoder << shouldUseFontSmoothing;
+ encoder << resourceLoadStatisticsEnabled;
+ encoder << fontWhitelist;
encoder << iconDatabaseEnabled;
encoder << terminationTimeout;
encoder << languages;
encoder << textCheckerState;
encoder << fullKeyboardAccessEnabled;
encoder << defaultRequestTimeoutInterval;
-#if PLATFORM(MAC) || USE(CFNETWORK)
+#if PLATFORM(COCOA) || USE(CFURLCONNECTION)
encoder << uiProcessBundleIdentifier;
#endif
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
encoder << presenterApplicationPid;
encoder << accessibilityEnhancedUserInterfaceEnabled;
- encoder << nsURLCacheMemoryCapacity;
- encoder << nsURLCacheDiskCapacity;
encoder << acceleratedCompositingPort;
encoder << uiProcessBundleResourcePath;
encoder << uiProcessBundleResourcePathExtensionHandle;
- encoder << shouldForceScreenFontSubstitution;
- encoder << shouldEnableKerningAndLigaturesByDefault;
+ encoder << shouldEnableJIT;
+ encoder << shouldEnableFTLJIT;
+ encoder << !!bundleParameterData;
+ if (bundleParameterData)
+ encoder << bundleParameterData->dataReference();
#endif
#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
encoder << notificationPermissions;
#endif
-#if ENABLE(NETWORK_PROCESS)
- encoder << usesNetworkProcess;
-#endif
-
encoder << plugInAutoStartOriginHashes;
encoder << plugInAutoStartOrigins;
encoder << memoryCacheDisabled;
+
+#if ENABLE(SERVICE_CONTROLS)
+ encoder << hasImageServices;
+ encoder << hasSelectionServices;
+ encoder << hasRichContentServices;
+#endif
+
+#if ENABLE(NETSCAPE_PLUGIN_API)
+ encoder << pluginLoadClientPolicies;
+#endif
+
+#if TARGET_OS_IPHONE || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
+ IPC::encode(encoder, networkATSContext.get());
+#endif
+
+#if OS(LINUX)
+ encoder << memoryPressureMonitorHandle;
+#endif
+
+#if PLATFORM(WAYLAND)
+ encoder << waylandCompositorDisplayName;
+#endif
+
+#if USE(SOUP)
+ encoder << proxySettings;
+#endif
}
-bool WebProcessCreationParameters::decode(IPC::ArgumentDecoder& decoder, WebProcessCreationParameters& parameters)
+bool WebProcessCreationParameters::decode(IPC::Decoder& decoder, WebProcessCreationParameters& parameters)
{
if (!decoder.decode(parameters.injectedBundlePath))
return false;
if (!decoder.decode(parameters.injectedBundlePathExtensionHandle))
return false;
+ if (!decoder.decode(parameters.initializationUserData))
+ return false;
if (!decoder.decode(parameters.applicationCacheDirectory))
return false;
+ if (!decoder.decode(parameters.applicationCacheFlatFileSubdirectoryName))
+ return false;
if (!decoder.decode(parameters.applicationCacheDirectoryExtensionHandle))
return false;
- if (!decoder.decode(parameters.databaseDirectory))
+ if (!decoder.decode(parameters.webSQLDatabaseDirectory))
return false;
- if (!decoder.decode(parameters.databaseDirectoryExtensionHandle))
+ if (!decoder.decode(parameters.webSQLDatabaseDirectoryExtensionHandle))
return false;
- if (!decoder.decode(parameters.localStorageDirectory))
+ if (!decoder.decode(parameters.mediaCacheDirectory))
return false;
- if (!decoder.decode(parameters.localStorageDirectoryExtensionHandle))
+ if (!decoder.decode(parameters.mediaCacheDirectoryExtensionHandle))
return false;
- if (!decoder.decode(parameters.diskCacheDirectory))
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100
+ if (!decoder.decode(parameters.uiProcessCookieStorageIdentifier))
return false;
- if (!decoder.decode(parameters.diskCacheDirectoryExtensionHandle))
+#endif
+#if PLATFORM(IOS)
+ if (!decoder.decode(parameters.cookieStorageDirectoryExtensionHandle))
return false;
- if (!decoder.decode(parameters.cookieStorageDirectory))
+ if (!decoder.decode(parameters.containerCachesDirectoryExtensionHandle))
return false;
- if (!decoder.decode(parameters.cookieStorageDirectoryExtensionHandle))
+ if (!decoder.decode(parameters.containerTemporaryDirectoryExtensionHandle))
+ return false;
+#endif
+ if (!decoder.decode(parameters.mediaKeyStorageDirectory))
+ return false;
+ if (!decoder.decode(parameters.mediaKeyStorageDirectoryExtensionHandle))
+ return false;
+#if ENABLE(MEDIA_STREAM)
+ if (!decoder.decode(parameters.audioCaptureExtensionHandle))
return false;
+#endif
if (!decoder.decode(parameters.shouldUseTestingNetworkSession))
return false;
- if (!decoder.decode(parameters.urlSchemesRegistererdAsEmptyDocument))
+ if (!decoder.decode(parameters.urlSchemesRegisteredAsEmptyDocument))
return false;
if (!decoder.decode(parameters.urlSchemesRegisteredAsSecure))
return false;
+ if (!decoder.decode(parameters.urlSchemesRegisteredAsBypassingContentSecurityPolicy))
+ return false;
if (!decoder.decode(parameters.urlSchemesForWhichDomainRelaxationIsForbidden))
return false;
if (!decoder.decode(parameters.urlSchemesRegisteredAsLocal))
@@ -162,31 +202,23 @@ bool WebProcessCreationParameters::decode(IPC::ArgumentDecoder& decoder, WebProc
return false;
if (!decoder.decode(parameters.urlSchemesRegisteredAsCORSEnabled))
return false;
-#if ENABLE(CUSTOM_PROTOCOLS)
- if (!decoder.decode(parameters.urlSchemesRegisteredForCustomProtocols))
- return false;
-#endif
-#if USE(SOUP)
-#if !ENABLE(CUSTOM_PROTOCOLS)
- if (!decoder.decode(parameters.urlSchemesRegistered))
+ if (!decoder.decode(parameters.urlSchemesRegisteredAsAlwaysRevalidated))
return false;
-#endif
- if (!decoder.decode(parameters.cookiePersistentStoragePath))
+ if (!decoder.decode(parameters.urlSchemesRegisteredAsCachePartitioned))
return false;
- if (!decoder.decode(parameters.cookiePersistentStorageType))
+ if (!decoder.decodeEnum(parameters.cacheModel))
return false;
- if (!decoder.decodeEnum(parameters.cookieAcceptPolicy))
+ if (!decoder.decode(parameters.shouldAlwaysUseComplexTextCodePath))
return false;
- if (!decoder.decode(parameters.ignoreTLSErrors))
+ if (!decoder.decode(parameters.shouldEnableMemoryPressureReliefLogging))
return false;
-#endif
- if (!decoder.decodeEnum(parameters.cacheModel))
+ if (!decoder.decode(parameters.shouldSuppressMemoryPressureHandler))
return false;
- if (!decoder.decode(parameters.shouldTrackVisitedLinks))
+ if (!decoder.decode(parameters.shouldUseFontSmoothing))
return false;
- if (!decoder.decode(parameters.shouldAlwaysUseComplexTextCodePath))
+ if (!decoder.decode(parameters.resourceLoadStatisticsEnabled))
return false;
- if (!decoder.decode(parameters.shouldUseFontSmoothing))
+ if (!decoder.decode(parameters.fontWhitelist))
return false;
if (!decoder.decode(parameters.iconDatabaseEnabled))
return false;
@@ -200,39 +232,42 @@ bool WebProcessCreationParameters::decode(IPC::ArgumentDecoder& decoder, WebProc
return false;
if (!decoder.decode(parameters.defaultRequestTimeoutInterval))
return false;
-#if PLATFORM(MAC) || USE(CFNETWORK)
+#if PLATFORM(COCOA) || USE(CFURLCONNECTION)
if (!decoder.decode(parameters.uiProcessBundleIdentifier))
return false;
#endif
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
if (!decoder.decode(parameters.presenterApplicationPid))
return false;
if (!decoder.decode(parameters.accessibilityEnhancedUserInterfaceEnabled))
return false;
- if (!decoder.decode(parameters.nsURLCacheMemoryCapacity))
- return false;
- if (!decoder.decode(parameters.nsURLCacheDiskCapacity))
- return false;
if (!decoder.decode(parameters.acceleratedCompositingPort))
return false;
if (!decoder.decode(parameters.uiProcessBundleResourcePath))
return false;
if (!decoder.decode(parameters.uiProcessBundleResourcePathExtensionHandle))
return false;
- if (!decoder.decode(parameters.shouldForceScreenFontSubstitution))
+ if (!decoder.decode(parameters.shouldEnableJIT))
return false;
- if (!decoder.decode(parameters.shouldEnableKerningAndLigaturesByDefault))
+ if (!decoder.decode(parameters.shouldEnableFTLJIT))
return false;
-#endif
-#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
- if (!decoder.decode(parameters.notificationPermissions))
+ bool hasBundleParameterData;
+ if (!decoder.decode(hasBundleParameterData))
return false;
+
+ if (hasBundleParameterData) {
+ IPC::DataReference dataReference;
+ if (!decoder.decode(dataReference))
+ return false;
+
+ parameters.bundleParameterData = API::Data::create(dataReference.data(), dataReference.size());
+ }
#endif
-#if ENABLE(NETWORK_PROCESS)
- if (!decoder.decode(parameters.usesNetworkProcess))
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
+ if (!decoder.decode(parameters.notificationPermissions))
return false;
#endif
@@ -243,6 +278,40 @@ bool WebProcessCreationParameters::decode(IPC::ArgumentDecoder& decoder, WebProc
if (!decoder.decode(parameters.memoryCacheDisabled))
return false;
+#if ENABLE(SERVICE_CONTROLS)
+ if (!decoder.decode(parameters.hasImageServices))
+ return false;
+ if (!decoder.decode(parameters.hasSelectionServices))
+ return false;
+ if (!decoder.decode(parameters.hasRichContentServices))
+ return false;
+#endif
+
+#if ENABLE(NETSCAPE_PLUGIN_API)
+ if (!decoder.decode(parameters.pluginLoadClientPolicies))
+ return false;
+#endif
+
+#if TARGET_OS_IPHONE || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
+ if (!IPC::decode(decoder, parameters.networkATSContext))
+ return false;
+#endif
+
+#if OS(LINUX)
+ if (!decoder.decode(parameters.memoryPressureMonitorHandle))
+ return false;
+#endif
+
+#if PLATFORM(WAYLAND)
+ if (!decoder.decode(parameters.waylandCompositorDisplayName))
+ return false;
+#endif
+
+#if USE(SOUP)
+ if (!decoder.decode(parameters.proxySettings))
+ return false;
+#endif
+
return true;
}
diff --git a/Source/WebKit2/Shared/WebProcessCreationParameters.h b/Source/WebKit2/Shared/WebProcessCreationParameters.h
index 7a93b3b66..ac463e417 100644
--- a/Source/WebKit2/Shared/WebProcessCreationParameters.h
+++ b/Source/WebKit2/Shared/WebProcessCreationParameters.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010, 2011, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-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
@@ -23,127 +23,155 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef WebProcessCreationParameters_h
-#define WebProcessCreationParameters_h
+#pragma once
#include "CacheModel.h"
#include "SandboxExtension.h"
#include "TextCheckerState.h"
+#include "UserData.h"
+#include <WebCore/SessionID.h>
#include <wtf/RetainPtr.h>
#include <wtf/Vector.h>
#include <wtf/text/StringHash.h>
#include <wtf/text/WTFString.h>
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
#include "MachPort.h"
+#include <WebCore/MachSendRight.h>
#endif
#if USE(SOUP)
#include "HTTPCookieAcceptPolicy.h"
+#include <WebCore/SoupNetworkProxySettings.h>
#endif
+namespace API {
+class Data;
+}
+
namespace IPC {
- class ArgumentDecoder;
- class ArgumentEncoder;
+class Decoder;
+class Encoder;
}
namespace WebKit {
struct WebProcessCreationParameters {
WebProcessCreationParameters();
+ ~WebProcessCreationParameters();
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, WebProcessCreationParameters&);
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, WebProcessCreationParameters&);
String injectedBundlePath;
SandboxExtension::Handle injectedBundlePathExtensionHandle;
- String applicationCacheDirectory;
+ UserData initializationUserData;
+
+ String applicationCacheDirectory;
+ String applicationCacheFlatFileSubdirectoryName;
SandboxExtension::Handle applicationCacheDirectoryExtensionHandle;
- String databaseDirectory;
- SandboxExtension::Handle databaseDirectoryExtensionHandle;
- String localStorageDirectory;
- SandboxExtension::Handle localStorageDirectoryExtensionHandle;
- String diskCacheDirectory;
- SandboxExtension::Handle diskCacheDirectoryExtensionHandle;
- String cookieStorageDirectory;
+ String webSQLDatabaseDirectory;
+ SandboxExtension::Handle webSQLDatabaseDirectoryExtensionHandle;
+ String mediaCacheDirectory;
+ SandboxExtension::Handle mediaCacheDirectoryExtensionHandle;
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100
+ Vector<uint8_t> uiProcessCookieStorageIdentifier;
+#endif
+#if PLATFORM(IOS)
SandboxExtension::Handle cookieStorageDirectoryExtensionHandle;
+ SandboxExtension::Handle containerCachesDirectoryExtensionHandle;
+ SandboxExtension::Handle containerTemporaryDirectoryExtensionHandle;
+#endif
+ SandboxExtension::Handle mediaKeyStorageDirectoryExtensionHandle;
+#if ENABLE(MEDIA_STREAM)
+ SandboxExtension::Handle audioCaptureExtensionHandle;
+#endif
+ String mediaKeyStorageDirectory;
- bool shouldUseTestingNetworkSession;
-
- Vector<String> urlSchemesRegistererdAsEmptyDocument;
+ Vector<String> urlSchemesRegisteredAsEmptyDocument;
Vector<String> urlSchemesRegisteredAsSecure;
+ Vector<String> urlSchemesRegisteredAsBypassingContentSecurityPolicy;
Vector<String> urlSchemesForWhichDomainRelaxationIsForbidden;
Vector<String> urlSchemesRegisteredAsLocal;
Vector<String> urlSchemesRegisteredAsNoAccess;
Vector<String> urlSchemesRegisteredAsDisplayIsolated;
Vector<String> urlSchemesRegisteredAsCORSEnabled;
-#if ENABLE(CUSTOM_PROTOCOLS)
- Vector<String> urlSchemesRegisteredForCustomProtocols;
-#endif
-#if USE(SOUP)
-#if !ENABLE(CUSTOM_PROTOCOLS)
- Vector<String> urlSchemesRegistered;
-#endif
- String cookiePersistentStoragePath;
- uint32_t cookiePersistentStorageType;
- HTTPCookieAcceptPolicy cookieAcceptPolicy;
- bool ignoreTLSErrors;
-#endif
-
- CacheModel cacheModel;
- bool shouldTrackVisitedLinks;
+ Vector<String> urlSchemesRegisteredAsAlwaysRevalidated;
+ Vector<String> urlSchemesRegisteredAsCachePartitioned;
- bool shouldAlwaysUseComplexTextCodePath;
- bool shouldUseFontSmoothing;
+ Vector<String> fontWhitelist;
+ Vector<String> languages;
- bool iconDatabaseEnabled;
+ CacheModel cacheModel;
- double terminationTimeout;
+ double defaultRequestTimeoutInterval { INT_MAX };
+
+ bool shouldUseTestingNetworkSession { false };
+ bool shouldAlwaysUseComplexTextCodePath { false };
+ bool shouldEnableMemoryPressureReliefLogging { false };
+ bool shouldSuppressMemoryPressureHandler { false };
+ bool shouldUseFontSmoothing { true };
+ bool resourceLoadStatisticsEnabled { false };
+ bool iconDatabaseEnabled { false };
+ bool fullKeyboardAccessEnabled { false };
+ bool memoryCacheDisabled { false };
+
+#if ENABLE(SERVICE_CONTROLS)
+ bool hasImageServices { false };
+ bool hasSelectionServices { false };
+ bool hasRichContentServices { false };
+#endif
- Vector<String> languages;
+ double terminationTimeout { 0 };
TextCheckerState textCheckerState;
- bool fullKeyboardAccessEnabled;
-
- double defaultRequestTimeoutInterval;
-
-#if PLATFORM(MAC) || USE(CFNETWORK)
+#if PLATFORM(COCOA) || USE(CFURLCONNECTION)
String uiProcessBundleIdentifier;
#endif
-#if PLATFORM(MAC)
- pid_t presenterApplicationPid;
-
- bool accessibilityEnhancedUserInterfaceEnabled;
+#if PLATFORM(COCOA)
+ pid_t presenterApplicationPid { 0 };
- uint64_t nsURLCacheMemoryCapacity;
- uint64_t nsURLCacheDiskCapacity;
-
- IPC::MachPort acceleratedCompositingPort;
+ WebCore::MachSendRight acceleratedCompositingPort;
String uiProcessBundleResourcePath;
SandboxExtension::Handle uiProcessBundleResourcePathExtensionHandle;
- bool shouldForceScreenFontSubstitution;
- bool shouldEnableKerningAndLigaturesByDefault;
-#endif // PLATFORM(MAC)
+ bool shouldEnableJIT { false };
+ bool shouldEnableFTLJIT { false };
+ bool accessibilityEnhancedUserInterfaceEnabled { false };
+
+ RefPtr<API::Data> bundleParameterData;
+#endif // PLATFORM(COCOA)
#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
HashMap<String, bool> notificationPermissions;
#endif
-#if ENABLE(NETWORK_PROCESS)
- bool usesNetworkProcess;
+ HashMap<WebCore::SessionID, HashMap<unsigned, double>> plugInAutoStartOriginHashes;
+ Vector<String> plugInAutoStartOrigins;
+
+#if ENABLE(NETSCAPE_PLUGIN_API)
+ HashMap<String, HashMap<String, HashMap<String, uint8_t>>> pluginLoadClientPolicies;
#endif
- HashMap<unsigned, double> plugInAutoStartOriginHashes;
- Vector<String> plugInAutoStartOrigins;
+#if TARGET_OS_IPHONE || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
+ RetainPtr<CFDataRef> networkATSContext;
+#endif
+
+#if OS(LINUX)
+ IPC::Attachment memoryPressureMonitorHandle;
+#endif
+
+#if PLATFORM(WAYLAND)
+ String waylandCompositorDisplayName;
+#endif
- bool memoryCacheDisabled;
+#if USE(SOUP)
+ WebCore::SoupNetworkProxySettings proxySettings;
+#endif
};
} // namespace WebKit
-
-#endif // WebProcessCreationParameters_h
diff --git a/Source/WebKit2/Shared/WebRenderLayer.cpp b/Source/WebKit2/Shared/WebRenderLayer.cpp
index f4baad331..9cc10eca4 100644
--- a/Source/WebKit2/Shared/WebRenderLayer.cpp
+++ b/Source/WebKit2/Shared/WebRenderLayer.cpp
@@ -32,9 +32,11 @@
#include <WebCore/Frame.h>
#include <WebCore/FrameLoader.h>
#include <WebCore/FrameLoaderClient.h>
+#include <WebCore/MainFrame.h>
#include <WebCore/RenderLayer.h>
#include <WebCore/RenderLayerBacking.h>
#include <WebCore/RenderView.h>
+#include <WebCore/RenderWidget.h>
#include <WebCore/StyledElement.h>
using namespace WebCore;
@@ -45,25 +47,25 @@ PassRefPtr<WebRenderLayer> WebRenderLayer::create(WebPage* page)
{
Frame* mainFrame = page->mainFrame();
if (!mainFrame)
- return 0;
+ return nullptr;
if (!mainFrame->loader().client().hasHTMLView())
- return 0;
+ return nullptr;
RenderView* contentRenderer = mainFrame->contentRenderer();
if (!contentRenderer)
- return 0;
+ return nullptr;
RenderLayer* rootLayer = contentRenderer->layer();
if (!rootLayer)
- return 0;
+ return nullptr;
return adoptRef(new WebRenderLayer(rootLayer));
}
-PassRefPtr<WebRenderLayer> WebRenderLayer::create(PassRefPtr<WebRenderObject> renderer, bool isReflection, bool isClipping, bool isClipped, CompositingLayerType type, WebCore::IntRect absoluteBoundingBox, PassRefPtr<API::Array> negativeZOrderList, PassRefPtr<API::Array> normalFlowList, PassRefPtr<API::Array> positiveZOrderList)
+PassRefPtr<WebRenderLayer> WebRenderLayer::create(PassRefPtr<WebRenderObject> renderer, bool isReflection, bool isClipping, bool isClipped, CompositingLayerType type, WebCore::IntRect absoluteBoundingBox, double backingStoreMemoryEstimate, PassRefPtr<API::Array> negativeZOrderList, PassRefPtr<API::Array> normalFlowList, PassRefPtr<API::Array> positiveZOrderList, PassRefPtr<WebRenderLayer> frameContentsLayer)
{
- return adoptRef(new WebRenderLayer(renderer, isReflection, isClipping, isClipped, type, absoluteBoundingBox, negativeZOrderList, normalFlowList, positiveZOrderList));
+ return adoptRef(new WebRenderLayer(renderer, isReflection, isClipping, isClipped, type, absoluteBoundingBox, backingStoreMemoryEstimate, negativeZOrderList, normalFlowList, positiveZOrderList, frameContentsLayer));
}
PassRefPtr<API::Array> WebRenderLayer::createArrayFromLayerList(Vector<RenderLayer*>* list)
@@ -77,7 +79,7 @@ PassRefPtr<API::Array> WebRenderLayer::createArrayFromLayerList(Vector<RenderLay
for (const auto& layer : *list)
layers.uncheckedAppend(adoptRef(new WebRenderLayer(layer)));
- return API::Array::create(std::move(layers));
+ return API::Array::create(WTFMove(layers));
}
WebRenderLayer::WebRenderLayer(RenderLayer* layer)
@@ -85,7 +87,6 @@ WebRenderLayer::WebRenderLayer(RenderLayer* layer)
m_renderer = WebRenderObject::create(&layer->renderer());
m_isReflection = layer->isReflection();
-#if USE(ACCELERATED_COMPOSITING)
if (layer->isComposited()) {
RenderLayerBacking* backing = layer->backing();
m_isClipping = backing->hasClippingLayer();
@@ -104,32 +105,41 @@ WebRenderLayer::WebRenderLayer(RenderLayer* layer)
m_compositingLayerType = Container;
break;
}
+
+ m_backingStoreMemoryEstimate = backing->backingStoreMemoryEstimate();
} else {
-#endif
m_isClipping = false;
m_isClipped = false;
m_compositingLayerType = None;
-#if USE(ACCELERATED_COMPOSITING)
+ m_backingStoreMemoryEstimate = 0;
}
-#endif
m_absoluteBoundingBox = layer->absoluteBoundingBox();
m_negativeZOrderList = createArrayFromLayerList(layer->negZOrderList());
m_normalFlowList = createArrayFromLayerList(layer->normalFlowList());
m_positiveZOrderList = createArrayFromLayerList(layer->posZOrderList());
+
+ if (is<RenderWidget>(layer->renderer())) {
+ if (Document* contentDocument = downcast<RenderWidget>(layer->renderer()).frameOwnerElement().contentDocument()) {
+ if (RenderView* view = contentDocument->renderView())
+ m_frameContentsLayer = adoptRef(new WebRenderLayer(view->layer()));
+ }
+ }
}
-WebRenderLayer::WebRenderLayer(PassRefPtr<WebRenderObject> renderer, bool isReflection, bool isClipping, bool isClipped, CompositingLayerType type, WebCore::IntRect absoluteBoundingBox, PassRefPtr<API::Array> negativeZOrderList, PassRefPtr<API::Array> normalFlowList, PassRefPtr<API::Array> positiveZOrderList)
+WebRenderLayer::WebRenderLayer(PassRefPtr<WebRenderObject> renderer, bool isReflection, bool isClipping, bool isClipped, CompositingLayerType type, WebCore::IntRect absoluteBoundingBox, double backingStoreMemoryEstimate, PassRefPtr<API::Array> negativeZOrderList, PassRefPtr<API::Array> normalFlowList, PassRefPtr<API::Array> positiveZOrderList, PassRefPtr<WebRenderLayer> frameContentsLayer)
: m_renderer(renderer)
, m_isReflection(isReflection)
, m_isClipping(isClipping)
, m_isClipped(isClipped)
, m_compositingLayerType(type)
, m_absoluteBoundingBox(absoluteBoundingBox)
+ , m_backingStoreMemoryEstimate(backingStoreMemoryEstimate)
, m_negativeZOrderList(negativeZOrderList)
, m_normalFlowList(normalFlowList)
, m_positiveZOrderList(positiveZOrderList)
+ , m_frameContentsLayer(frameContentsLayer)
{
}
diff --git a/Source/WebKit2/Shared/WebRenderLayer.h b/Source/WebKit2/Shared/WebRenderLayer.h
index b4ffe9a83..5b6be0433 100644
--- a/Source/WebKit2/Shared/WebRenderLayer.h
+++ b/Source/WebKit2/Shared/WebRenderLayer.h
@@ -41,11 +41,12 @@ public:
enum CompositingLayerType { None, Normal, Tiled, Media, Container };
static PassRefPtr<WebRenderLayer> create(WebPage*);
- static PassRefPtr<WebRenderLayer> create(PassRefPtr<WebRenderObject> renderer, bool isReflection, bool isClipping, bool isClipped, CompositingLayerType, WebCore::IntRect absoluteBoundingBox, PassRefPtr<API::Array> negativeZOrderList, PassRefPtr<API::Array> normalFlowList, PassRefPtr<API::Array> positiveZOrderList);
+ static PassRefPtr<WebRenderLayer> create(PassRefPtr<WebRenderObject> renderer, bool isReflection, bool isClipping, bool isClipped, CompositingLayerType, WebCore::IntRect absoluteBoundingBox, double backingStoreMemoryEstimate, PassRefPtr<API::Array> negativeZOrderList, PassRefPtr<API::Array> normalFlowList, PassRefPtr<API::Array> positiveZOrderList, PassRefPtr<WebRenderLayer> frameContentsLayer);
API::Array* negativeZOrderList() const { return m_negativeZOrderList.get(); }
API::Array* normalFlowList() const { return m_normalFlowList.get(); }
API::Array* positiveZOrderList() const { return m_positiveZOrderList.get(); }
+ WebRenderLayer* frameContentsLayer() const { return m_frameContentsLayer.get(); }
WebRenderObject* renderer() const { return m_renderer.get(); }
bool isReflection() const { return m_isReflection; }
@@ -53,10 +54,11 @@ public:
bool isClipped() const { return m_isClipped; }
CompositingLayerType compositingLayerType() const { return m_compositingLayerType; }
WebCore::IntRect absoluteBoundingBox() const { return m_absoluteBoundingBox; }
+ double backingStoreMemoryEstimate() const { return m_backingStoreMemoryEstimate; }
private:
explicit WebRenderLayer(WebCore::RenderLayer*);
- WebRenderLayer(PassRefPtr<WebRenderObject> renderer, bool isReflection, bool isClipping, bool isClipped, CompositingLayerType, WebCore::IntRect absoluteBoundingBox, PassRefPtr<API::Array> negativeZOrderList, PassRefPtr<API::Array> normalFlowList, PassRefPtr<API::Array> positiveZOrderList);
+ WebRenderLayer(PassRefPtr<WebRenderObject> renderer, bool isReflection, bool isClipping, bool isClipped, CompositingLayerType, WebCore::IntRect absoluteBoundingBox, double backingStoreMemoryEstimate, PassRefPtr<API::Array> negativeZOrderList, PassRefPtr<API::Array> normalFlowList, PassRefPtr<API::Array> positiveZOrderList, PassRefPtr<WebRenderLayer> frameContentsLayer);
static PassRefPtr<API::Array> createArrayFromLayerList(Vector<WebCore::RenderLayer*>*);
@@ -66,10 +68,13 @@ private:
bool m_isClipped;
CompositingLayerType m_compositingLayerType;
WebCore::IntRect m_absoluteBoundingBox;
+ double m_backingStoreMemoryEstimate;
RefPtr<API::Array> m_negativeZOrderList;
RefPtr<API::Array> m_normalFlowList;
RefPtr<API::Array> m_positiveZOrderList;
+
+ RefPtr<WebRenderLayer> m_frameContentsLayer;
};
} // namespace WebKit
diff --git a/Source/WebKit2/Shared/WebRenderObject.cpp b/Source/WebKit2/Shared/WebRenderObject.cpp
index 3b44988a8..afc4336ed 100644
--- a/Source/WebKit2/Shared/WebRenderObject.cpp
+++ b/Source/WebKit2/Shared/WebRenderObject.cpp
@@ -32,6 +32,8 @@
#include <WebCore/Frame.h>
#include <WebCore/FrameLoader.h>
#include <WebCore/FrameLoaderClient.h>
+#include <WebCore/MainFrame.h>
+#include <WebCore/RenderInline.h>
#include <WebCore/RenderText.h>
#include <WebCore/RenderView.h>
#include <WebCore/RenderWidget.h>
@@ -40,95 +42,101 @@ using namespace WebCore;
namespace WebKit {
-PassRefPtr<WebRenderObject> WebRenderObject::create(WebPage* page)
+RefPtr<WebRenderObject> WebRenderObject::create(WebPage* page)
{
Frame* mainFrame = page->mainFrame();
if (!mainFrame)
- return 0;
+ return nullptr;
if (!mainFrame->loader().client().hasHTMLView())
- return 0;
+ return nullptr;
RenderView* contentRenderer = mainFrame->contentRenderer();
if (!contentRenderer)
- return 0;
+ return nullptr;
return adoptRef(new WebRenderObject(contentRenderer, true));
}
-PassRefPtr<WebRenderObject> WebRenderObject::create(const String& name, const String& elementTagName, const String& elementID, PassRefPtr<API::Array> elementClassNames, WebCore::IntPoint absolutePosition, WebCore::IntRect frameRect, PassRefPtr<API::Array> children)
+PassRefPtr<WebRenderObject> WebRenderObject::create(const String& name, const String& elementTagName, const String& elementID, PassRefPtr<API::Array> elementClassNames, WebCore::IntPoint absolutePosition, WebCore::IntRect frameRect, const String& textSnippet, unsigned textLength, PassRefPtr<API::Array> children)
{
- return adoptRef(new WebRenderObject(name, elementTagName, elementID, elementClassNames, absolutePosition, frameRect, children));
+ return adoptRef(new WebRenderObject(name, elementTagName, elementID, elementClassNames, absolutePosition, frameRect, textSnippet, textLength, children));
}
WebRenderObject::WebRenderObject(RenderObject* renderer, bool shouldIncludeDescendants)
{
m_name = renderer->renderName();
+ m_textLength = 0;
if (Node* node = renderer->node()) {
- if (node->isElementNode()) {
- Element* element = toElement(node);
- m_elementTagName = element->tagName();
- m_elementID = element->getIdAttribute();
+ if (is<Element>(*node)) {
+ Element& element = downcast<Element>(*node);
+ m_elementTagName = element.tagName();
+ m_elementID = element.getIdAttribute();
- if (element->isStyledElement() && element->hasClass()) {
+ if (element.isStyledElement() && element.hasClass()) {
Vector<RefPtr<API::Object>> classNames;
- classNames.reserveInitialCapacity(element->classNames().size());
+ classNames.reserveInitialCapacity(element.classNames().size());
- for (size_t i = 0, size = element->classNames().size(); i < size; ++i)
- classNames.append(API::String::create(element->classNames()[i]));
+ for (size_t i = 0, size = element.classNames().size(); i < size; ++i)
+ classNames.append(API::String::create(element.classNames()[i]));
- m_elementClassNames = API::Array::create(std::move(classNames));
+ m_elementClassNames = API::Array::create(WTFMove(classNames));
}
}
+
+ if (node->isTextNode()) {
+ String value = node->nodeValue();
+ m_textLength = value.length();
+
+ const int maxSnippetLength = 40;
+ if (value.length() > maxSnippetLength)
+ m_textSnippet = value.substring(0, maxSnippetLength);
+ else
+ m_textSnippet = value;
+ }
}
// FIXME: broken with transforms
m_absolutePosition = flooredIntPoint(renderer->localToAbsolute());
- if (renderer->isBox())
- m_frameRect = toRenderBox(renderer)->pixelSnappedFrameRect();
- else if (renderer->isText()) {
- m_frameRect = toRenderText(renderer)->linesBoundingBox();
- m_frameRect.setX(toRenderText(renderer)->firstRunX());
- m_frameRect.setY(toRenderText(renderer)->firstRunY());
- } else if (renderer->isRenderInline())
- m_frameRect = toRenderBoxModelObject(renderer)->borderBoundingBox();
+ if (is<RenderBox>(*renderer))
+ m_frameRect = snappedIntRect(downcast<RenderBox>(*renderer).frameRect());
+ else if (is<RenderText>(*renderer)) {
+ m_frameRect = downcast<RenderText>(*renderer).linesBoundingBox();
+ m_frameRect.setLocation(downcast<RenderText>(*renderer).firstRunLocation());
+ } else if (is<RenderInline>(*renderer))
+ m_frameRect = IntRect(downcast<RenderInline>(*renderer).borderBoundingBox());
if (!shouldIncludeDescendants)
return;
Vector<RefPtr<API::Object>> children;
- for (RenderObject* coreChild = renderer->firstChildSlow(); coreChild; coreChild = coreChild->nextSibling()) {
- RefPtr<WebRenderObject> child = adoptRef(new WebRenderObject(coreChild, shouldIncludeDescendants));
- children.append(std::move(child));
- }
-
- if (renderer->isWidget()) {
- if (Widget* widget = toRenderWidget(renderer)->widget()) {
- if (widget->isFrameView()) {
- FrameView* frameView = toFrameView(widget);
- if (RenderView* coreContentRenderer = frameView->frame().contentRenderer()) {
- RefPtr<WebRenderObject> contentRenderer = adoptRef(new WebRenderObject(coreContentRenderer, shouldIncludeDescendants));
+ for (auto* coreChild = renderer->firstChildSlow(); coreChild; coreChild = coreChild->nextSibling())
+ children.append(adoptRef(*new WebRenderObject(coreChild, shouldIncludeDescendants)));
- children.append(std::move(contentRenderer));
- }
- }
+ if (is<RenderWidget>(*renderer)) {
+ auto* widget = downcast<RenderWidget>(*renderer).widget();
+ if (is<FrameView>(widget)) {
+ if (auto* coreContentRenderer = downcast<FrameView>(*widget).frame().contentRenderer())
+ children.append(adoptRef(*new WebRenderObject(coreContentRenderer, shouldIncludeDescendants)));
}
}
- m_children = API::Array::create(std::move(children));
+ m_children = API::Array::create(WTFMove(children));
}
-WebRenderObject::WebRenderObject(const String& name, const String& elementTagName, const String& elementID, PassRefPtr<API::Array> elementClassNames, WebCore::IntPoint absolutePosition, WebCore::IntRect frameRect, PassRefPtr<API::Array> children)
+WebRenderObject::WebRenderObject(const String& name, const String& elementTagName, const String& elementID, PassRefPtr<API::Array> elementClassNames, WebCore::IntPoint absolutePosition, WebCore::IntRect frameRect, const String& textSnippet, unsigned textLength, PassRefPtr<API::Array> children)
: m_children(children)
, m_name(name)
, m_elementTagName(elementTagName)
, m_elementID(elementID)
+ , m_textSnippet(textSnippet)
, m_elementClassNames(elementClassNames)
, m_absolutePosition(absolutePosition)
, m_frameRect(frameRect)
+ , m_textLength(textLength)
{
}
diff --git a/Source/WebKit2/Shared/WebRenderObject.h b/Source/WebKit2/Shared/WebRenderObject.h
index deb208779..fc2558231 100644
--- a/Source/WebKit2/Shared/WebRenderObject.h
+++ b/Source/WebKit2/Shared/WebRenderObject.h
@@ -45,19 +45,24 @@ class WebPage;
class WebRenderObject : public API::ObjectImpl<API::Object::Type::RenderObject> {
public:
- static PassRefPtr<WebRenderObject> create(WebPage*);
- static PassRefPtr<WebRenderObject> create(WebCore::RenderObject* renderer)
+ static RefPtr<WebRenderObject> create(WebPage*);
+ static Ref<WebRenderObject> create(WebCore::RenderObject* renderer)
{
- return adoptRef(new WebRenderObject(renderer, false));
+ return adoptRef(*new WebRenderObject(renderer, false));
}
- static PassRefPtr<WebRenderObject> create(const String& name, const String& elementTagName, const String& elementID, PassRefPtr<API::Array> elementClassNames, WebCore::IntPoint absolutePosition, WebCore::IntRect frameRect, PassRefPtr<API::Array> children);
+ static PassRefPtr<WebRenderObject> create(const String& name, const String& elementTagName, const String& elementID, PassRefPtr<API::Array> elementClassNames, WebCore::IntPoint absolutePosition, WebCore::IntRect frameRect, const String& textSnippet, unsigned textLength, PassRefPtr<API::Array> children);
virtual ~WebRenderObject();
API::Array* children() const { return m_children.get(); }
const String& name() const { return m_name; }
+
+ // Only non-empty for RenderText objects.
+ const String& textSnippet() const { return m_textSnippet; }
+ unsigned textLength() const { return m_textLength; }
+
const String& elementTagName() const { return m_elementTagName; }
const String& elementID() const { return m_elementID; }
API::Array* elementClassNames() const { return m_elementClassNames.get(); }
@@ -66,16 +71,18 @@ public:
private:
WebRenderObject(WebCore::RenderObject*, bool shouldIncludeDescendants);
- WebRenderObject(const String& name, const String& elementTagName, const String& elementID, PassRefPtr<API::Array> elementClassNames, WebCore::IntPoint absolutePosition, WebCore::IntRect frameRect, PassRefPtr<API::Array> children);
+ WebRenderObject(const String& name, const String& elementTagName, const String& elementID, PassRefPtr<API::Array> elementClassNames, WebCore::IntPoint absolutePosition, WebCore::IntRect frameRect, const String& textSnippet, unsigned textLength, PassRefPtr<API::Array> children);
RefPtr<API::Array> m_children;
String m_name;
String m_elementTagName;
String m_elementID;
+ String m_textSnippet;
RefPtr<API::Array> m_elementClassNames;
WebCore::IntPoint m_absolutePosition;
WebCore::IntRect m_frameRect;
+ unsigned m_textLength;
};
} // namespace WebKit
diff --git a/Source/WebKit2/Shared/WebSQLiteDatabaseTracker.cpp b/Source/WebKit2/Shared/WebSQLiteDatabaseTracker.cpp
new file mode 100644
index 000000000..92a7f945c
--- /dev/null
+++ b/Source/WebKit2/Shared/WebSQLiteDatabaseTracker.cpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+#include "config.h"
+#include "WebSQLiteDatabaseTracker.h"
+
+#include "NetworkProcess.h"
+#include "NetworkProcessProxyMessages.h"
+#include "WebProcess.h"
+#include "WebProcessProxyMessages.h"
+#include <WebCore/SQLiteDatabaseTracker.h>
+#include <wtf/MainThread.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebSQLiteDatabaseTracker::WebSQLiteDatabaseTracker(NetworkProcess& process)
+ : m_process(process)
+ , m_hysteresis([this](HysteresisState state) { hysteresisUpdated(state); })
+ , m_childProcessType(ChildProcessType::Network)
+{
+ SQLiteDatabaseTracker::setClient(this);
+}
+
+WebSQLiteDatabaseTracker::WebSQLiteDatabaseTracker(WebProcess& process)
+ : m_process(process)
+ , m_hysteresis([this](HysteresisState state) { hysteresisUpdated(state); })
+ , m_childProcessType(ChildProcessType::WebContent)
+{
+ SQLiteDatabaseTracker::setClient(this);
+}
+
+void WebSQLiteDatabaseTracker::willBeginFirstTransaction()
+{
+ callOnMainThread([this] {
+ m_hysteresis.start();
+ });
+}
+
+void WebSQLiteDatabaseTracker::didFinishLastTransaction()
+{
+ callOnMainThread([this] {
+ m_hysteresis.stop();
+ });
+}
+
+void WebSQLiteDatabaseTracker::hysteresisUpdated(HysteresisState state)
+{
+ switch (m_childProcessType) {
+ case ChildProcessType::WebContent:
+ m_process.parentProcessConnection()->send(Messages::WebProcessProxy::SetIsHoldingLockedFiles(state == HysteresisState::Started), 0);
+ break;
+ case ChildProcessType::Network:
+ m_process.parentProcessConnection()->send(Messages::NetworkProcessProxy::SetIsHoldingLockedFiles(state == HysteresisState::Started), 0);
+ break;
+ }
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/Shared/WebResourceBuffer.h b/Source/WebKit2/Shared/WebSQLiteDatabaseTracker.h
index 69b4959d5..ea5cea17c 100644
--- a/Source/WebKit2/Shared/WebResourceBuffer.h
+++ b/Source/WebKit2/Shared/WebSQLiteDatabaseTracker.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -23,35 +23,38 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef WebResourceBuffer_h
-#define WebResourceBuffer_h
+#ifndef WebSQLiteDatabaseTracker_h
+#define WebSQLiteDatabaseTracker_h
-#if ENABLE(SHAREABLE_RESOURCE)
-
-#include <WebCore/ResourceBuffer.h>
+#include <WebCore/HysteresisActivity.h>
+#include <WebCore/SQLiteDatabaseTrackerClient.h>
+#include <wtf/Noncopyable.h>
namespace WebKit {
-class ShareableResource;
+class ChildProcess;
+class NetworkProcess;
+class WebProcess;
-class WebResourceBuffer : public WebCore::ResourceBuffer {
+class WebSQLiteDatabaseTracker : public WebCore::SQLiteDatabaseTrackerClient {
+ WTF_MAKE_NONCOPYABLE(WebSQLiteDatabaseTracker)
public:
- static PassRefPtr<WebResourceBuffer> create(PassRefPtr<ShareableResource> resource) { return adoptRef(new WebResourceBuffer(resource)); }
-
- virtual ~WebResourceBuffer() override;
+ explicit WebSQLiteDatabaseTracker(NetworkProcess&);
+ explicit WebSQLiteDatabaseTracker(WebProcess&);
- virtual const char* data() const override;
- virtual unsigned size() const override;
- virtual bool isEmpty() const override;
+ // WebCore::SQLiteDatabaseTrackerClient
+ void willBeginFirstTransaction() override;
+ void didFinishLastTransaction() override;
private:
- WebResourceBuffer(PassRefPtr<ShareableResource>);
+ void hysteresisUpdated(WebCore::HysteresisState);
- RefPtr<ShareableResource> m_resource;
+ ChildProcess& m_process;
+ WebCore::HysteresisActivity m_hysteresis;
+ enum class ChildProcessType { Network, WebContent };
+ ChildProcessType m_childProcessType;
};
} // namespace WebKit
-#endif // ENABLE(SHAREABLE_RESOURCE)
-
-#endif // WebResourceBuffer_h
+#endif // WebSQLiteDatabaseTracker_h
diff --git a/Source/WebKit2/Shared/WebSecurityOrigin.h b/Source/WebKit2/Shared/WebSecurityOrigin.h
deleted file mode 100644
index f52aa62c7..000000000
--- a/Source/WebKit2/Shared/WebSecurityOrigin.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-
-#ifndef WebSecurityOrigin_h
-#define WebSecurityOrigin_h
-
-#include "APIObject.h"
-#include <WebCore/SecurityOrigin.h>
-#include <wtf/PassRefPtr.h>
-
-namespace WebKit {
-
-class WebSecurityOrigin : public API::ObjectImpl<API::Object::Type::SecurityOrigin> {
-public:
- static PassRefPtr<WebSecurityOrigin> createFromString(const String& string)
- {
- return create(WebCore::SecurityOrigin::createFromString(string));
- }
-
- static PassRefPtr<WebSecurityOrigin> createFromDatabaseIdentifier(const String& identifier)
- {
- return create(WebCore::SecurityOrigin::createFromDatabaseIdentifier(identifier));
- }
-
- static PassRefPtr<WebSecurityOrigin> create(const String& protocol, const String& host, int port)
- {
- return create(WebCore::SecurityOrigin::create(protocol, host, port));
- }
-
- static PassRefPtr<WebSecurityOrigin> create(PassRefPtr<WebCore::SecurityOrigin> securityOrigin)
- {
- if (!securityOrigin)
- return 0;
- return adoptRef(new WebSecurityOrigin(securityOrigin));
- }
-
- String protocol() const { return m_securityOrigin->protocol(); }
- String host() const { return m_securityOrigin->host(); }
- unsigned short port() const { return m_securityOrigin->port(); }
-
- String databaseIdentifier() const { return m_securityOrigin->databaseIdentifier(); }
- String toString() const { return m_securityOrigin->toString(); }
-
- WebCore::SecurityOrigin* securityOrigin() const { return m_securityOrigin.get(); }
-
-#if PLATFORM(IOS)
- WebCore::SecurityOrigin* securityOrigin() { return m_securityOrigin.get(); }
-#endif // PLATFORM(IOS)
-
-private:
- WebSecurityOrigin(PassRefPtr<WebCore::SecurityOrigin> securityOrigin)
- : m_securityOrigin(securityOrigin)
- {
- }
-
- RefPtr<WebCore::SecurityOrigin> m_securityOrigin;
-};
-
-} // namespace WebKit
-
-#endif
diff --git a/Source/WebKit2/Shared/WebTouchEvent.cpp b/Source/WebKit2/Shared/WebTouchEvent.cpp
index 8ffd4baf7..b9aacbaf6 100644
--- a/Source/WebKit2/Shared/WebTouchEvent.cpp
+++ b/Source/WebKit2/Shared/WebTouchEvent.cpp
@@ -26,28 +26,27 @@
#include "config.h"
#include "WebEvent.h"
-#if ENABLE(TOUCH_EVENTS)
+#if ENABLE(TOUCH_EVENTS) && !PLATFORM(IOS)
#include "ArgumentCoders.h"
-#include "Arguments.h"
namespace WebKit {
-WebTouchEvent::WebTouchEvent(WebEvent::Type type, Vector<WebPlatformTouchPoint> touchPoints, Modifiers modifiers, double timestamp)
+WebTouchEvent::WebTouchEvent(WebEvent::Type type, Vector<WebPlatformTouchPoint>&& touchPoints, Modifiers modifiers, double timestamp)
: WebEvent(type, modifiers, timestamp)
- , m_touchPoints(touchPoints)
+ , m_touchPoints(WTFMove(touchPoints))
{
ASSERT(isTouchEventType(type));
}
-void WebTouchEvent::encode(IPC::ArgumentEncoder& encoder) const
+void WebTouchEvent::encode(IPC::Encoder& encoder) const
{
WebEvent::encode(encoder);
encoder << m_touchPoints;
}
-bool WebTouchEvent::decode(IPC::ArgumentDecoder& decoder, WebTouchEvent& result)
+bool WebTouchEvent::decode(IPC::Decoder& decoder, WebTouchEvent& result)
{
if (!WebEvent::decode(decoder, result))
return false;
@@ -65,4 +64,4 @@ bool WebTouchEvent::isTouchEventType(Type type)
} // namespace WebKit
-#endif // ENABLE(TOUCH_EVENTS)
+#endif // ENABLE(TOUCH_EVENTS) && !PLATFORM(IOS)
diff --git a/Source/WebKit2/Shared/WebUserContentControllerDataTypes.cpp b/Source/WebKit2/Shared/WebUserContentControllerDataTypes.cpp
new file mode 100644
index 000000000..71f3cf108
--- /dev/null
+++ b/Source/WebKit2/Shared/WebUserContentControllerDataTypes.cpp
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#include "config.h"
+#include "WebUserContentControllerDataTypes.h"
+
+#include "WebCoreArgumentCoders.h"
+
+namespace WebKit {
+
+void WebUserScriptData::encode(IPC::Encoder& encoder) const
+{
+ encoder << identifier;
+ encoder << worldIdentifier;
+ encoder << userScript;
+}
+
+bool WebUserScriptData::decode(IPC::Decoder& decoder, WebUserScriptData& data)
+{
+ if (!decoder.decode(data.identifier))
+ return false;
+ if (!decoder.decode(data.worldIdentifier))
+ return false;
+ if (!decoder.decode(data.userScript))
+ return false;
+ return true;
+}
+
+void WebUserStyleSheetData::encode(IPC::Encoder& encoder) const
+{
+ encoder << identifier;
+ encoder << worldIdentifier;
+ encoder << userStyleSheet;
+}
+
+bool WebUserStyleSheetData::decode(IPC::Decoder& decoder, WebUserStyleSheetData& data)
+{
+ if (!decoder.decode(data.identifier))
+ return false;
+ if (!decoder.decode(data.worldIdentifier))
+ return false;
+ if (!decoder.decode(data.userStyleSheet))
+ return false;
+ return true;
+}
+
+
+void WebScriptMessageHandlerData::encode(IPC::Encoder& encoder) const
+{
+ encoder << identifier;
+ encoder << worldIdentifier;
+ encoder << name;
+}
+
+bool WebScriptMessageHandlerData::decode(IPC::Decoder& decoder, WebScriptMessageHandlerData& data)
+{
+ if (!decoder.decode(data.identifier))
+ return false;
+ if (!decoder.decode(data.worldIdentifier))
+ return false;
+ if (!decoder.decode(data.name))
+ return false;
+
+ return true;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/Shared/WebUserContentControllerDataTypes.h b/Source/WebKit2/Shared/WebUserContentControllerDataTypes.h
new file mode 100644
index 000000000..e29593bac
--- /dev/null
+++ b/Source/WebKit2/Shared/WebUserContentControllerDataTypes.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#ifndef WebUserContentControllerDataTypes_h
+#define WebUserContentControllerDataTypes_h
+
+#include <WebCore/UserScript.h>
+#include <WebCore/UserStyleSheet.h>
+
+namespace IPC {
+class Decoder;
+class Encoder;
+}
+
+namespace WebKit {
+
+struct WebUserScriptData {
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, WebUserScriptData&);
+
+ uint64_t identifier;
+ uint64_t worldIdentifier;
+ WebCore::UserScript userScript;
+};
+
+struct WebUserStyleSheetData {
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, WebUserStyleSheetData&);
+
+ uint64_t identifier;
+ uint64_t worldIdentifier;
+ WebCore::UserStyleSheet userStyleSheet;
+};
+
+struct WebScriptMessageHandlerData {
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, WebScriptMessageHandlerData&);
+
+ uint64_t identifier;
+ uint64_t worldIdentifier;
+ String name;
+};
+
+} // namespace WebKit
+
+#endif // WebUserContentControllerDataTypes_h
diff --git a/Source/WebKit2/Shared/WebWheelEvent.cpp b/Source/WebKit2/Shared/WebWheelEvent.cpp
index fe3b97352..7ddce0cbb 100644
--- a/Source/WebKit2/Shared/WebWheelEvent.cpp
+++ b/Source/WebKit2/Shared/WebWheelEvent.cpp
@@ -26,7 +26,6 @@
#include "config.h"
#include "WebEvent.h"
-#include "Arguments.h"
#include "WebCoreArgumentCoders.h"
using namespace WebCore;
@@ -41,7 +40,7 @@ WebWheelEvent::WebWheelEvent(Type type, const IntPoint& position, const IntPoint
, m_wheelTicks(wheelTicks)
, m_granularity(granularity)
, m_directionInvertedFromDevice(false)
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
, m_phase(PhaseNone)
, m_hasPreciseScrollingDeltas(false)
, m_scrollCount(0)
@@ -50,7 +49,7 @@ WebWheelEvent::WebWheelEvent(Type type, const IntPoint& position, const IntPoint
ASSERT(isWheelEventType(type));
}
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
WebWheelEvent::WebWheelEvent(Type type, const IntPoint& position, const IntPoint& globalPosition, const FloatSize& delta, const FloatSize& wheelTicks, Granularity granularity, bool directionInvertedFromDevice, Phase phase, Phase momentumPhase, bool hasPreciseScrollingDeltas, uint32_t scrollCount, const WebCore::FloatSize& unacceleratedScrollingDelta, Modifiers modifiers, double timestamp)
: WebEvent(type, modifiers, timestamp)
, m_position(position)
@@ -69,7 +68,7 @@ WebWheelEvent::WebWheelEvent(Type type, const IntPoint& position, const IntPoint
}
#endif
-void WebWheelEvent::encode(IPC::ArgumentEncoder& encoder) const
+void WebWheelEvent::encode(IPC::Encoder& encoder) const
{
WebEvent::encode(encoder);
@@ -79,7 +78,7 @@ void WebWheelEvent::encode(IPC::ArgumentEncoder& encoder) const
encoder << m_wheelTicks;
encoder << m_granularity;
encoder << m_directionInvertedFromDevice;
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
encoder << m_phase;
encoder << m_momentumPhase;
encoder << m_hasPreciseScrollingDeltas;
@@ -88,7 +87,7 @@ void WebWheelEvent::encode(IPC::ArgumentEncoder& encoder) const
#endif
}
-bool WebWheelEvent::decode(IPC::ArgumentDecoder& decoder, WebWheelEvent& t)
+bool WebWheelEvent::decode(IPC::Decoder& decoder, WebWheelEvent& t)
{
if (!WebEvent::decode(decoder, t))
return false;
@@ -104,7 +103,7 @@ bool WebWheelEvent::decode(IPC::ArgumentDecoder& decoder, WebWheelEvent& t)
return false;
if (!decoder.decode(t.m_directionInvertedFromDevice))
return false;
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
if (!decoder.decode(t.m_phase))
return false;
if (!decoder.decode(t.m_momentumPhase))
diff --git a/Source/WebKit2/Shared/WebBatteryStatus.cpp b/Source/WebKit2/Shared/WebsiteData/WebsiteData.cpp
index d012d7063..404f129f0 100644
--- a/Source/WebKit2/Shared/WebBatteryStatus.cpp
+++ b/Source/WebKit2/Shared/WebsiteData/WebsiteData.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ * 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
@@ -24,49 +24,58 @@
*/
#include "config.h"
-#include "WebBatteryStatus.h"
-
-#if ENABLE(BATTERY_STATUS)
+#include "WebsiteData.h"
#include "ArgumentCoders.h"
-#include "Arguments.h"
+#include <WebCore/SecurityOriginData.h>
+#include <wtf/text/StringHash.h>
namespace WebKit {
-WebBatteryStatus::WebBatteryStatus(bool isCharging, double chargingTime, double dischargingTime, double level)
+void WebsiteData::Entry::encode(IPC::Encoder& encoder) const
{
- m_data.isCharging = isCharging;
- m_data.chargingTime = chargingTime;
- m_data.dischargingTime = dischargingTime;
- m_data.level = level;
+ encoder << origin;
+ encoder.encodeEnum(type);
+ encoder << size;
}
-WebBatteryStatus::~WebBatteryStatus()
+bool WebsiteData::Entry::decode(IPC::Decoder& decoder, WebsiteData::Entry& result)
{
+ WebCore::SecurityOriginData securityOriginData;
+ if (!decoder.decode(securityOriginData))
+ return false;
+
+ if (!decoder.decodeEnum(result.type))
+ return false;
+
+ if (!decoder.decode(result.size))
+ return false;
+
+ result.origin = securityOriginData;
+ return true;
}
-void WebBatteryStatus::Data::encode(IPC::ArgumentEncoder& encoder) const
+void WebsiteData::encode(IPC::Encoder& encoder) const
{
- encoder << isCharging;
- encoder << chargingTime;
- encoder << dischargingTime;
- encoder << level;
+ encoder << entries;
+ encoder << hostNamesWithCookies;
+#if ENABLE(NETSCAPE_PLUGIN_API)
+ encoder << hostNamesWithPluginData;
+#endif
}
-bool WebBatteryStatus::Data::decode(IPC::ArgumentDecoder& decoder, Data& result)
+bool WebsiteData::decode(IPC::Decoder& decoder, WebsiteData& result)
{
- if (!decoder.decode(result.isCharging))
- return false;
- if (!decoder.decode(result.chargingTime))
+ if (!decoder.decode(result.entries))
return false;
- if (!decoder.decode(result.dischargingTime))
+ if (!decoder.decode(result.hostNamesWithCookies))
return false;
- if (!decoder.decode(result.level))
+#if ENABLE(NETSCAPE_PLUGIN_API)
+ if (!decoder.decode(result.hostNamesWithPluginData))
return false;
+#endif
return true;
}
-} // namespace WebKit
-
-#endif // ENABLE(BATTERY_STATUS)
+}
diff --git a/Source/WebKit2/Shared/WebsiteData/WebsiteData.h b/Source/WebKit2/Shared/WebsiteData/WebsiteData.h
new file mode 100644
index 000000000..ae764d95b
--- /dev/null
+++ b/Source/WebKit2/Shared/WebsiteData/WebsiteData.h
@@ -0,0 +1,63 @@
+/*
+ * 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.
+ *
+ * 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 <WebCore/SecurityOriginData.h>
+#include <wtf/HashMap.h>
+#include <wtf/HashSet.h>
+#include <wtf/Vector.h>
+
+namespace IPC {
+class Decoder;
+class Encoder;
+}
+
+namespace WebKit {
+
+enum class WebsiteDataType;
+
+struct WebsiteData {
+ struct Entry {
+ WebCore::SecurityOriginData origin;
+ WebsiteDataType type;
+ uint64_t size;
+
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, WebsiteData::Entry&);
+ };
+
+ Vector<Entry> entries;
+ HashSet<String> hostNamesWithCookies;
+
+#if ENABLE(NETSCAPE_PLUGIN_API)
+ HashSet<String> hostNamesWithPluginData;
+#endif
+
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, WebsiteData&);
+};
+
+}
diff --git a/Source/WebKit2/Shared/Plugins/PluginModuleInfo.cpp b/Source/WebKit2/Shared/WebsiteData/WebsiteDataFetchOption.h
index bb60b5d46..b7c75b295 100644
--- a/Source/WebKit2/Shared/Plugins/PluginModuleInfo.cpp
+++ b/Source/WebKit2/Shared/WebsiteData/WebsiteDataFetchOption.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -23,10 +23,16 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "config.h"
-#include "PluginModuleInfo.h"
+#ifndef WebsiteDataFetchOption_h
+#define WebsiteDataFetchOption_h
namespace WebKit {
+enum class WebsiteDataFetchOption {
+ ComputeSizes = 1 << 0,
+};
}
+
+
+#endif // WebsiteDataFetchOption_h
diff --git a/Source/WebKit2/Shared/WebsiteData/WebsiteDataType.h b/Source/WebKit2/Shared/WebsiteData/WebsiteDataType.h
new file mode 100644
index 000000000..5ad5046cd
--- /dev/null
+++ b/Source/WebKit2/Shared/WebsiteData/WebsiteDataType.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+#ifndef WebsiteDataType_h
+#define WebsiteDataType_h
+
+namespace WebKit {
+
+enum class WebsiteDataType {
+ Cookies = 1 << 0,
+ DiskCache = 1 << 1,
+ MemoryCache = 1 << 2,
+ OfflineWebApplicationCache = 1 << 3,
+ SessionStorage = 1 << 4,
+ LocalStorage = 1 << 5,
+ WebSQLDatabases = 1 << 6,
+ IndexedDBDatabases = 1 << 7,
+ MediaKeys = 1 << 8,
+ HSTSCache = 1 << 9,
+ SearchFieldRecentSearches = 1 << 10,
+#if ENABLE(NETSCAPE_PLUGIN_API)
+ PlugInData = 1 << 11,
+#endif
+#if ENABLE(MEDIA_STREAM)
+ MediaDeviceIdentifier = 1 << 12,
+#endif
+ WebsiteDataTypeResourceLoadStatistics = 1 << 13,
+};
+
+};
+
+#endif // WebsiteDataType_h
diff --git a/Source/WebKit2/Shared/WebsitePolicies.h b/Source/WebKit2/Shared/WebsitePolicies.h
new file mode 100644
index 000000000..f79c3fbb7
--- /dev/null
+++ b/Source/WebKit2/Shared/WebsitePolicies.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#pragma once
+
+namespace WebKit {
+
+enum class WebsiteAutoplayPolicy {
+ Default,
+ Allow,
+ AllowWithoutSound,
+ Deny
+};
+
+struct WebsitePolicies {
+
+ bool contentBlockersEnabled { true };
+ WebsiteAutoplayPolicy autoplayPolicy { WebsiteAutoplayPolicy::Default };
+
+ template<class Encoder> void encode(Encoder&) const;
+ template<class Decoder> static bool decode(Decoder&, WebsitePolicies&);
+};
+
+template<class Encoder> void WebsitePolicies::encode(Encoder& encoder) const
+{
+ encoder << contentBlockersEnabled;
+ encoder.encodeEnum(autoplayPolicy);
+}
+
+template<class Decoder> bool WebsitePolicies::decode(Decoder& decoder, WebsitePolicies& result)
+{
+ if (!decoder.decode(result.contentBlockersEnabled))
+ return false;
+ if (!decoder.decodeEnum(result.autoplayPolicy))
+ return false;
+ return true;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/Shared/cairo/ShareableBitmapCairo.cpp b/Source/WebKit2/Shared/cairo/ShareableBitmapCairo.cpp
index 378bee722..31681e5fd 100644
--- a/Source/WebKit2/Shared/cairo/ShareableBitmapCairo.cpp
+++ b/Source/WebKit2/Shared/cairo/ShareableBitmapCairo.cpp
@@ -40,12 +40,12 @@ namespace WebKit {
static const cairo_format_t cairoFormat = CAIRO_FORMAT_ARGB32;
-size_t ShareableBitmap::numBytesForSize(const WebCore::IntSize& size)
+Checked<unsigned, RecordOverflow> ShareableBitmap::numBytesForSize(const WebCore::IntSize& size)
{
- return cairo_format_stride_for_width(cairoFormat, size.width()) * size.height();
+ return Checked<unsigned, RecordOverflow>(cairo_format_stride_for_width(cairoFormat, size.width())) * size.height();
}
-static inline PassRefPtr<cairo_surface_t> createSurfaceFromData(void* data, const WebCore::IntSize& size)
+static inline RefPtr<cairo_surface_t> createSurfaceFromData(void* data, const WebCore::IntSize& size)
{
const int stride = cairo_format_stride_for_width(cairoFormat, size.width());
return adoptRef(cairo_image_surface_create_for_data(static_cast<unsigned char*>(data), cairoFormat, size.width(), size.height(), stride));
@@ -69,10 +69,10 @@ void ShareableBitmap::paint(GraphicsContext& context, float scaleFactor, const I
FloatRect destRect(dstPoint, srcRect.size());
FloatRect srcRectScaled(srcRect);
srcRectScaled.scale(scaleFactor);
- context.platformContext()->drawSurfaceToContext(surface.get(), destRect, srcRectScaled, &context);
+ context.platformContext()->drawSurfaceToContext(surface.get(), destRect, srcRectScaled, context);
}
-PassRefPtr<cairo_surface_t> ShareableBitmap::createCairoSurface()
+RefPtr<cairo_surface_t> ShareableBitmap::createCairoSurface()
{
RefPtr<cairo_surface_t> image = createSurfaceFromData(data(), m_size);
@@ -87,13 +87,13 @@ void ShareableBitmap::releaseSurfaceData(void* typelessBitmap)
static_cast<ShareableBitmap*>(typelessBitmap)->deref(); // Balanced by ref in createCairoSurface.
}
-PassRefPtr<Image> ShareableBitmap::createImage()
+RefPtr<Image> ShareableBitmap::createImage()
{
RefPtr<cairo_surface_t> surface = createCairoSurface();
if (!surface)
- return 0;
+ return nullptr;
- return BitmapImage::create(surface.release());
+ return BitmapImage::create(WTFMove(surface));
}
} // namespace WebKit
diff --git a/Source/WebKit2/Shared/gtk/ArgumentCodersGtk.cpp b/Source/WebKit2/Shared/gtk/ArgumentCodersGtk.cpp
index ef1cb1acc..342626020 100644
--- a/Source/WebKit2/Shared/gtk/ArgumentCodersGtk.cpp
+++ b/Source/WebKit2/Shared/gtk/ArgumentCodersGtk.cpp
@@ -29,27 +29,21 @@
#include "DataReference.h"
#include "ShareableBitmap.h"
#include "WebCoreArgumentCoders.h"
-#include <WebCore/DataObjectGtk.h>
-#include <WebCore/DragData.h>
#include <WebCore/GraphicsContext.h>
-#include <WebCore/GtkVersioning.h>
-#include <WebCore/PlatformContextCairo.h>
-#include <wtf/gobject/GUniquePtr.h>
+#include <WebCore/Image.h>
+#include <WebCore/SelectionData.h>
+#include <gtk/gtk.h>
+#include <wtf/glib/GUniquePtr.h>
using namespace WebCore;
using namespace WebKit;
namespace IPC {
-static void encodeImage(ArgumentEncoder& encoder, const GdkPixbuf* pixbuf)
+static void encodeImage(Encoder& encoder, Image& image)
{
- IntSize imageSize(gdk_pixbuf_get_width(pixbuf), gdk_pixbuf_get_height(pixbuf));
- RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(imageSize, ShareableBitmap::SupportsAlpha);
- auto graphicsContext = bitmap->createGraphicsContext();
-
- cairo_t* cr = graphicsContext->platformContext()->cr();
- gdk_cairo_set_source_pixbuf(cr, pixbuf, 0, 0);
- cairo_paint(cr);
+ RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(IntSize(image.size()), ShareableBitmap::SupportsAlpha);
+ bitmap->createGraphicsContext()->drawImage(image, IntPoint());
ShareableBitmap::Handle handle;
bitmap->createHandle(handle);
@@ -57,7 +51,7 @@ static void encodeImage(ArgumentEncoder& encoder, const GdkPixbuf* pixbuf)
encoder << handle;
}
-static bool decodeImage(ArgumentDecoder& decoder, GRefPtr<GdkPixbuf>& pixbuf)
+static bool decodeImage(Decoder& decoder, RefPtr<Image>& image)
{
ShareableBitmap::Handle handle;
if (!decoder.decode(handle))
@@ -66,58 +60,51 @@ static bool decodeImage(ArgumentDecoder& decoder, GRefPtr<GdkPixbuf>& pixbuf)
RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(handle);
if (!bitmap)
return false;
-
- RefPtr<Image> image = bitmap->createImage();
+ image = bitmap->createImage();
if (!image)
return false;
-
- RefPtr<cairo_surface_t> surface = image->nativeImageForCurrentFrame();
- if (!surface)
- return false;
-
- pixbuf = adoptGRef(gdk_pixbuf_get_from_surface(surface.get(), 0, 0, cairo_image_surface_get_width(surface.get()), cairo_image_surface_get_height(surface.get())));
- if (!pixbuf)
- return false;
-
return true;
}
-static void encodeDataObject(ArgumentEncoder& encoder, const DataObjectGtk* dataObject)
+void ArgumentCoder<SelectionData>::encode(Encoder& encoder, const SelectionData& selection)
{
- bool hasText = dataObject->hasText();
+ bool hasText = selection.hasText();
encoder << hasText;
if (hasText)
- encoder << dataObject->text();
+ encoder << selection.text();
- bool hasMarkup = dataObject->hasMarkup();
+ bool hasMarkup = selection.hasMarkup();
encoder << hasMarkup;
if (hasMarkup)
- encoder << dataObject->markup();
+ encoder << selection.markup();
- bool hasURL = dataObject->hasURL();
+ bool hasURL = selection.hasURL();
encoder << hasURL;
if (hasURL)
- encoder << dataObject->url().string();
+ encoder << selection.url().string();
- bool hasURIList = dataObject->hasURIList();
+ bool hasURIList = selection.hasURIList();
encoder << hasURIList;
if (hasURIList)
- encoder << dataObject->uriList();
+ encoder << selection.uriList();
- bool hasImage = dataObject->hasImage();
+ bool hasImage = selection.hasImage();
encoder << hasImage;
if (hasImage)
- encodeImage(encoder, dataObject->image());
+ encodeImage(encoder, *selection.image());
- bool hasUnknownTypeData = dataObject->hasUnknownTypeData();
+ bool hasUnknownTypeData = selection.hasUnknownTypeData();
encoder << hasUnknownTypeData;
if (hasUnknownTypeData)
- encoder << dataObject->unknownTypes();
+ encoder << selection.unknownTypes();
+
+ bool canSmartReplace = selection.canSmartReplace();
+ encoder << canSmartReplace;
}
-static bool decodeDataObject(ArgumentDecoder& decoder, RefPtr<DataObjectGtk>& dataObject)
+bool ArgumentCoder<SelectionData>::decode(Decoder& decoder, SelectionData& selection)
{
- RefPtr<DataObjectGtk> data = DataObjectGtk::create();
+ selection.clearAll();
bool hasText;
if (!decoder.decode(hasText))
@@ -126,7 +113,7 @@ static bool decodeDataObject(ArgumentDecoder& decoder, RefPtr<DataObjectGtk>& da
String text;
if (!decoder.decode(text))
return false;
- data->setText(text);
+ selection.setText(text);
}
bool hasMarkup;
@@ -136,7 +123,7 @@ static bool decodeDataObject(ArgumentDecoder& decoder, RefPtr<DataObjectGtk>& da
String markup;
if (!decoder.decode(markup))
return false;
- data->setMarkup(markup);
+ selection.setMarkup(markup);
}
bool hasURL;
@@ -146,7 +133,7 @@ static bool decodeDataObject(ArgumentDecoder& decoder, RefPtr<DataObjectGtk>& da
String url;
if (!decoder.decode(url))
return false;
- data->setURL(URL(URL(), url), String());
+ selection.setURL(URL(URL(), url), String());
}
bool hasURIList;
@@ -156,17 +143,17 @@ static bool decodeDataObject(ArgumentDecoder& decoder, RefPtr<DataObjectGtk>& da
String uriList;
if (!decoder.decode(uriList))
return false;
- data->setURIList(uriList);
+ selection.setURIList(uriList);
}
bool hasImage;
if (!decoder.decode(hasImage))
return false;
if (hasImage) {
- GRefPtr<GdkPixbuf> image;
+ RefPtr<Image> image;
if (!decodeImage(decoder, image))
return false;
- data->setImage(image.get());
+ selection.setImage(image.get());
}
bool hasUnknownTypeData;
@@ -179,71 +166,25 @@ static bool decodeDataObject(ArgumentDecoder& decoder, RefPtr<DataObjectGtk>& da
auto end = unknownTypes.end();
for (auto it = unknownTypes.begin(); it != end; ++it)
- data->setUnknownTypeData(it->key, it->value);
+ selection.setUnknownTypeData(it->key, it->value);
}
- dataObject = data;
-
- return true;
-}
-
-#if ENABLE(DRAG_SUPPORT)
-void ArgumentCoder<DragData>::encode(ArgumentEncoder& encoder, const DragData& dragData)
-{
- encoder << dragData.clientPosition();
- encoder << dragData.globalPosition();
- encoder << static_cast<uint64_t>(dragData.draggingSourceOperationMask());
- encoder << static_cast<uint64_t>(dragData.flags());
-
- DataObjectGtk* platformData = dragData.platformData();
- encoder << static_cast<bool>(platformData);
- if (platformData)
- encodeDataObject(encoder, platformData);
-}
-
-bool ArgumentCoder<DragData>::decode(ArgumentDecoder& decoder, DragData& dragData)
-{
- IntPoint clientPosition;
- if (!decoder.decode(clientPosition))
- return false;
-
- IntPoint globalPosition;
- if (!decoder.decode(globalPosition))
- return false;
-
- uint64_t sourceOperationMask;
- if (!decoder.decode(sourceOperationMask))
- return false;
-
- uint64_t flags;
- if (!decoder.decode(flags))
- return false;
-
- bool hasPlatformData;
- if (!decoder.decode(hasPlatformData))
+ bool canSmartReplace;
+ if (!decoder.decode(canSmartReplace))
return false;
-
- RefPtr<DataObjectGtk> platformData;
- if (hasPlatformData) {
- if (!decodeDataObject(decoder, platformData))
- return false;
- }
-
- dragData = DragData(platformData.release().leakRef(), clientPosition, globalPosition, static_cast<DragOperation>(sourceOperationMask),
- static_cast<DragApplicationFlags>(flags));
+ selection.setCanSmartReplace(canSmartReplace);
return true;
}
-#endif // ENABLE(DRAG_SUPPORT)
-static void encodeGKeyFile(ArgumentEncoder& encoder, GKeyFile* keyFile)
+static void encodeGKeyFile(Encoder& encoder, GKeyFile* keyFile)
{
gsize dataSize;
GUniquePtr<char> data(g_key_file_to_data(keyFile, &dataSize, 0));
encoder << DataReference(reinterpret_cast<uint8_t*>(data.get()), dataSize);
}
-static bool decodeGKeyFile(ArgumentDecoder& decoder, GUniquePtr<GKeyFile>& keyFile)
+static bool decodeGKeyFile(Decoder& decoder, GUniquePtr<GKeyFile>& keyFile)
{
DataReference dataReference;
if (!decoder.decode(dataReference))
@@ -261,14 +202,14 @@ static bool decodeGKeyFile(ArgumentDecoder& decoder, GUniquePtr<GKeyFile>& keyFi
return true;
}
-void encode(ArgumentEncoder& encoder, GtkPrintSettings* printSettings)
+void encode(Encoder& encoder, GtkPrintSettings* printSettings)
{
GUniquePtr<GKeyFile> keyFile(g_key_file_new());
gtk_print_settings_to_key_file(printSettings, keyFile.get(), "Print Settings");
encodeGKeyFile(encoder, keyFile.get());
}
-bool decode(ArgumentDecoder& decoder, GRefPtr<GtkPrintSettings>& printSettings)
+bool decode(Decoder& decoder, GRefPtr<GtkPrintSettings>& printSettings)
{
GUniquePtr<GKeyFile> keyFile;
if (!decodeGKeyFile(decoder, keyFile))
@@ -284,14 +225,14 @@ bool decode(ArgumentDecoder& decoder, GRefPtr<GtkPrintSettings>& printSettings)
return printSettings;
}
-void encode(ArgumentEncoder& encoder, GtkPageSetup* pageSetup)
+void encode(Encoder& encoder, GtkPageSetup* pageSetup)
{
GUniquePtr<GKeyFile> keyFile(g_key_file_new());
gtk_page_setup_to_key_file(pageSetup, keyFile.get(), "Page Setup");
encodeGKeyFile(encoder, keyFile.get());
}
-bool decode(ArgumentDecoder& decoder, GRefPtr<GtkPageSetup>& pageSetup)
+bool decode(Decoder& decoder, GRefPtr<GtkPageSetup>& pageSetup)
{
GUniquePtr<GKeyFile> keyFile;
if (!decodeGKeyFile(decoder, keyFile))
diff --git a/Source/WebKit2/Shared/gtk/ArgumentCodersGtk.h b/Source/WebKit2/Shared/gtk/ArgumentCodersGtk.h
index 4aa55de74..f1e78502f 100644
--- a/Source/WebKit2/Shared/gtk/ArgumentCodersGtk.h
+++ b/Source/WebKit2/Shared/gtk/ArgumentCodersGtk.h
@@ -27,30 +27,27 @@
#define ArgumentCodersGtk_h
#include "ArgumentCoders.h"
-#include <wtf/gobject/GRefPtr.h>
+#include <wtf/glib/GRefPtr.h>
typedef struct _GtkPrintSettings GtkPrintSettings;
typedef struct _GtkPageSetup GtkPageSetup;
namespace WebCore {
-class DataObjectGtk;
-class DragData;
+class SelectionData;
}
namespace IPC {
-#if ENABLE(DRAG_SUPPORT)
-template<> struct ArgumentCoder<WebCore::DragData> {
- static void encode(ArgumentEncoder&, const WebCore::DragData&);
- static bool decode(ArgumentDecoder&, WebCore::DragData&);
-};
-#endif
+void encode(Encoder&, GtkPrintSettings*);
+bool decode(Decoder&, GRefPtr<GtkPrintSettings>&);
-void encode(ArgumentEncoder&, GtkPrintSettings*);
-bool decode(ArgumentDecoder&, GRefPtr<GtkPrintSettings>&);
+void encode(Encoder&, GtkPageSetup*);
+bool decode(Decoder&, GRefPtr<GtkPageSetup>&);
-void encode(ArgumentEncoder&, GtkPageSetup*);
-bool decode(ArgumentDecoder&, GRefPtr<GtkPageSetup>&);
+template<> struct ArgumentCoder<WebCore::SelectionData> {
+ static void encode(Encoder&, const WebCore::SelectionData&);
+ static bool decode(Decoder&, WebCore::SelectionData&);
+};
} // namespace IPC
diff --git a/Source/WebKit2/Shared/gtk/NativeWebKeyboardEventGtk.cpp b/Source/WebKit2/Shared/gtk/NativeWebKeyboardEventGtk.cpp
index 424e0b3f9..834a7e091 100644
--- a/Source/WebKit2/Shared/gtk/NativeWebKeyboardEventGtk.cpp
+++ b/Source/WebKit2/Shared/gtk/NativeWebKeyboardEventGtk.cpp
@@ -35,16 +35,16 @@ using namespace WebCore;
namespace WebKit {
-NativeWebKeyboardEvent::NativeWebKeyboardEvent(GdkEvent* event, const WebCore::CompositionResults& compositionResults, GtkInputMethodFilter::EventFakedForComposition faked)
- : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event, compositionResults))
+NativeWebKeyboardEvent::NativeWebKeyboardEvent(GdkEvent* event, const WebCore::CompositionResults& compositionResults, InputMethodFilter::EventFakedForComposition faked, Vector<String>&& commands)
+ : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event, compositionResults, WTFMove(commands)))
, m_nativeEvent(gdk_event_copy(event))
, m_compositionResults(compositionResults)
- , m_fakeEventForComposition(faked == GtkInputMethodFilter::EventFaked)
+ , m_fakeEventForComposition(faked == InputMethodFilter::EventFaked)
{
}
NativeWebKeyboardEvent::NativeWebKeyboardEvent(const NativeWebKeyboardEvent& event)
- : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event.nativeEvent(), event.compositionResults()))
+ : WebKeyboardEvent(WebEventFactory::createWebKeyboardEvent(event.nativeEvent(), event.compositionResults(), Vector<String>(event.commands())))
, m_nativeEvent(gdk_event_copy(event.nativeEvent()))
, m_compositionResults(event.compositionResults())
, m_fakeEventForComposition(event.isFakeEventForComposition())
diff --git a/Source/WebKit2/Shared/gtk/NativeWebTouchEventGtk.cpp b/Source/WebKit2/Shared/gtk/NativeWebTouchEventGtk.cpp
index b2cd4a536..5ec476b2d 100644
--- a/Source/WebKit2/Shared/gtk/NativeWebTouchEventGtk.cpp
+++ b/Source/WebKit2/Shared/gtk/NativeWebTouchEventGtk.cpp
@@ -26,23 +26,25 @@
#include "config.h"
#include "NativeWebTouchEvent.h"
+#if ENABLE(TOUCH_EVENTS)
+
#include "WebEventFactory.h"
#include <gdk/gdk.h>
namespace WebKit {
-NativeWebTouchEvent::NativeWebTouchEvent(GdkEvent* event, WebCore::GtkTouchContextHelper& context)
- : WebTouchEvent(WebEventFactory::createWebTouchEvent(event, context))
+NativeWebTouchEvent::NativeWebTouchEvent(GdkEvent* event, Vector<WebPlatformTouchPoint>&& touchPoints)
+ : WebTouchEvent(WebEventFactory::createWebTouchEvent(event, WTFMove(touchPoints)))
, m_nativeEvent(gdk_event_copy(event))
- , m_touchContext(context)
{
}
NativeWebTouchEvent::NativeWebTouchEvent(const NativeWebTouchEvent& event)
- : WebTouchEvent(WebEventFactory::createWebTouchEvent(event.nativeEvent(), event.touchContext()))
+ : WebTouchEvent(WebEventFactory::createWebTouchEvent(event.nativeEvent(), Vector<WebPlatformTouchPoint>(event.touchPoints())))
, m_nativeEvent(gdk_event_copy(event.nativeEvent()))
- , m_touchContext(event.touchContext())
{
}
} // namespace WebKit
+
+#endif // ENABLE(TOUCH_EVENTS)
diff --git a/Source/WebKit2/Shared/gtk/ProcessExecutablePathGtk.cpp b/Source/WebKit2/Shared/gtk/ProcessExecutablePathGtk.cpp
index e757cc2ea..f0aa966db 100644
--- a/Source/WebKit2/Shared/gtk/ProcessExecutablePathGtk.cpp
+++ b/Source/WebKit2/Shared/gtk/ProcessExecutablePathGtk.cpp
@@ -29,25 +29,31 @@
#include <WebCore/FileSystem.h>
#include <glib.h>
-#include <wtf/gobject/GlibUtilities.h>
+
+#if ENABLE(DEVELOPER_MODE)
+#include <wtf/glib/GLibUtilities.h>
+#endif
using namespace WebCore;
namespace WebKit {
+#if ENABLE(DEVELOPER_MODE)
static String getExecutablePath()
{
CString executablePath = getCurrentExecutablePath();
if (!executablePath.isNull())
- return directoryName(filenameToString(executablePath.data()));
+ return directoryName(stringFromFileSystemRepresentation(executablePath.data()));
return String();
}
+#endif
static String findWebKitProcess(const char* processName)
{
+#if ENABLE(DEVELOPER_MODE)
static const char* execDirectory = g_getenv("WEBKIT_EXEC_PATH");
if (execDirectory) {
- String processPath = pathByAppendingComponent(filenameToString(execDirectory), processName);
+ String processPath = pathByAppendingComponent(stringFromFileSystemRepresentation(execDirectory), processName);
if (fileExists(processPath))
return processPath;
}
@@ -58,8 +64,9 @@ static String findWebKitProcess(const char* processName)
if (fileExists(processPath))
return processPath;
}
+#endif
- return pathByAppendingComponent(filenameToString(LIBEXECDIR), processName);
+ return pathByAppendingComponent(stringFromFileSystemRepresentation(PKGLIBEXECDIR), processName);
}
String executablePathOfWebProcess()
@@ -72,11 +79,16 @@ String executablePathOfPluginProcess()
return findWebKitProcess("WebKitPluginProcess");
}
-#if ENABLE(NETWORK_PROCESS)
String executablePathOfNetworkProcess()
{
return findWebKitProcess("WebKitNetworkProcess");
}
+
+#if ENABLE(DATABASE_PROCESS)
+String executablePathOfDatabaseProcess()
+{
+ return findWebKitProcess("WebKitDatabaseProcess");
+}
#endif
} // namespace WebKit
diff --git a/Source/WebKit2/Shared/gtk/WebContextMenuItemGtk.cpp b/Source/WebKit2/Shared/gtk/WebContextMenuItemGtk.cpp
new file mode 100644
index 000000000..a93552991
--- /dev/null
+++ b/Source/WebKit2/Shared/gtk/WebContextMenuItemGtk.cpp
@@ -0,0 +1,181 @@
+/*
+ * Copyright (C) 2015 Igalia S.L.
+ *
+ * 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 "WebContextMenuItemGtk.h"
+
+#include <gtk/gtk.h>
+#include <wtf/glib/GUniquePtr.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static const char* gtkStockIDFromContextMenuAction(ContextMenuAction action)
+{
+ switch (action) {
+ case ContextMenuItemTagCopyLinkToClipboard:
+ case ContextMenuItemTagCopyImageToClipboard:
+ case ContextMenuItemTagCopyMediaLinkToClipboard:
+ case ContextMenuItemTagCopy:
+ return GTK_STOCK_COPY;
+ case ContextMenuItemTagOpenLinkInNewWindow:
+ case ContextMenuItemTagOpenImageInNewWindow:
+ case ContextMenuItemTagOpenFrameInNewWindow:
+ case ContextMenuItemTagOpenMediaInNewWindow:
+ return GTK_STOCK_OPEN;
+ case ContextMenuItemTagDownloadLinkToDisk:
+ case ContextMenuItemTagDownloadImageToDisk:
+ return GTK_STOCK_SAVE;
+ case ContextMenuItemTagGoBack:
+ return GTK_STOCK_GO_BACK;
+ case ContextMenuItemTagGoForward:
+ return GTK_STOCK_GO_FORWARD;
+ case ContextMenuItemTagStop:
+ return GTK_STOCK_STOP;
+ case ContextMenuItemTagReload:
+ return GTK_STOCK_REFRESH;
+ case ContextMenuItemTagCut:
+ return GTK_STOCK_CUT;
+ case ContextMenuItemTagPaste:
+ return GTK_STOCK_PASTE;
+ case ContextMenuItemTagDelete:
+ return GTK_STOCK_DELETE;
+ case ContextMenuItemTagSelectAll:
+ return GTK_STOCK_SELECT_ALL;
+ case ContextMenuItemTagSpellingGuess:
+ return 0;
+ case ContextMenuItemTagIgnoreSpelling:
+ return GTK_STOCK_NO;
+ case ContextMenuItemTagLearnSpelling:
+ return GTK_STOCK_OK;
+ case ContextMenuItemTagOther:
+ return GTK_STOCK_MISSING_IMAGE;
+ case ContextMenuItemTagSearchInSpotlight:
+ return GTK_STOCK_FIND;
+ case ContextMenuItemTagSearchWeb:
+ return GTK_STOCK_FIND;
+ case ContextMenuItemTagOpenWithDefaultApplication:
+ return GTK_STOCK_OPEN;
+ case ContextMenuItemPDFZoomIn:
+ return GTK_STOCK_ZOOM_IN;
+ case ContextMenuItemPDFZoomOut:
+ return GTK_STOCK_ZOOM_OUT;
+ case ContextMenuItemPDFAutoSize:
+ return GTK_STOCK_ZOOM_FIT;
+ case ContextMenuItemPDFNextPage:
+ return GTK_STOCK_GO_FORWARD;
+ case ContextMenuItemPDFPreviousPage:
+ return GTK_STOCK_GO_BACK;
+ // New tags, not part of API
+ case ContextMenuItemTagOpenLink:
+ return GTK_STOCK_OPEN;
+ case ContextMenuItemTagCheckSpelling:
+ return GTK_STOCK_SPELL_CHECK;
+ case ContextMenuItemTagFontMenu:
+ return GTK_STOCK_SELECT_FONT;
+ case ContextMenuItemTagShowFonts:
+ return GTK_STOCK_SELECT_FONT;
+ case ContextMenuItemTagBold:
+ return GTK_STOCK_BOLD;
+ case ContextMenuItemTagItalic:
+ return GTK_STOCK_ITALIC;
+ case ContextMenuItemTagUnderline:
+ return GTK_STOCK_UNDERLINE;
+ case ContextMenuItemTagShowColors:
+ return GTK_STOCK_SELECT_COLOR;
+ case ContextMenuItemTagToggleMediaControls:
+ case ContextMenuItemTagToggleMediaLoop:
+ case ContextMenuItemTagCopyImageUrlToClipboard:
+ // No icon for this.
+ return 0;
+ case ContextMenuItemTagEnterVideoFullscreen:
+ return GTK_STOCK_FULLSCREEN;
+ default:
+ return 0;
+ }
+}
+
+WebContextMenuItemGtk::WebContextMenuItemGtk(ContextMenuItemType type, ContextMenuAction action, const String& title, bool enabled, bool checked)
+ : WebContextMenuItemData(type, action, title, enabled, checked)
+{
+ ASSERT(type != SubmenuType);
+ createActionIfNeeded();
+}
+
+WebContextMenuItemGtk::WebContextMenuItemGtk(const WebContextMenuItemData& data)
+ : WebContextMenuItemData(data.type() == SubmenuType ? ActionType : data.type(), data.action(), data.title(), data.enabled(), data.checked())
+{
+ createActionIfNeeded();
+}
+
+WebContextMenuItemGtk::WebContextMenuItemGtk(const WebContextMenuItemGtk& data, Vector<WebContextMenuItemGtk>&& submenu)
+ : WebContextMenuItemData(ActionType, data.action(), data.title(), data.enabled(), false)
+{
+ m_gAction = G_SIMPLE_ACTION(data.gAction());
+ m_gtkAction = data.gtkAction();
+ m_submenuItems = WTFMove(submenu);
+}
+
+WebContextMenuItemGtk::WebContextMenuItemGtk(GtkAction* action)
+ : WebContextMenuItemData(GTK_IS_TOGGLE_ACTION(action) ? CheckableActionType : ActionType, ContextMenuItemBaseApplicationTag, String::fromUTF8(gtk_action_get_label(action)), gtk_action_get_sensitive(action), GTK_IS_TOGGLE_ACTION(action) ? gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)) : false)
+{
+ m_gtkAction = action;
+ createActionIfNeeded();
+ g_object_set_data_full(G_OBJECT(m_gAction.get()), "webkit-gtk-action", g_object_ref(m_gtkAction), g_object_unref);
+}
+
+WebContextMenuItemGtk::~WebContextMenuItemGtk()
+{
+}
+
+void WebContextMenuItemGtk::createActionIfNeeded()
+{
+ if (type() == SeparatorType)
+ return;
+
+ static uint64_t actionID = 0;
+ GUniquePtr<char> actionName(g_strdup_printf("action-%" PRIu64, ++actionID));
+ if (type() == CheckableActionType)
+ m_gAction = adoptGRef(g_simple_action_new_stateful(actionName.get(), nullptr, g_variant_new_boolean(checked())));
+ else
+ m_gAction = adoptGRef(g_simple_action_new(actionName.get(), nullptr));
+ g_simple_action_set_enabled(m_gAction.get(), enabled());
+
+ // Create the GtkAction for backwards compatibility only.
+ if (!m_gtkAction) {
+ if (type() == CheckableActionType) {
+ m_gtkAction = GTK_ACTION(gtk_toggle_action_new(actionName.get(), title().utf8().data(), nullptr, gtkStockIDFromContextMenuAction(action())));
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(m_gtkAction), checked());
+ } else
+ m_gtkAction = gtk_action_new(actionName.get(), title().utf8().data(), 0, gtkStockIDFromContextMenuAction(action()));
+ gtk_action_set_sensitive(m_gtkAction, enabled());
+ g_object_set_data_full(G_OBJECT(m_gAction.get()), "webkit-gtk-action", m_gtkAction, g_object_unref);
+ }
+
+ g_signal_connect_object(m_gAction.get(), "activate", G_CALLBACK(gtk_action_activate), m_gtkAction, G_CONNECT_SWAPPED);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/Shared/WebBatteryStatus.h b/Source/WebKit2/Shared/gtk/WebContextMenuItemGtk.h
index aa60b8fa7..1df8b08c6 100644
--- a/Source/WebKit2/Shared/WebBatteryStatus.h
+++ b/Source/WebKit2/Shared/gtk/WebContextMenuItemGtk.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ * Copyright (C) 2015 Igalia S.L.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -23,51 +23,42 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef WebBatteryStatus_h
-#define WebBatteryStatus_h
-
-#if ENABLE(BATTERY_STATUS)
+#ifndef WebContextMenuItemGtk_h
+#define WebContextMenuItemGtk_h
#include "APIObject.h"
-#include "ArgumentDecoder.h"
-#include "ArgumentEncoder.h"
-#include <wtf/PassRefPtr.h>
+#include "WebContextMenuItemData.h"
+#include <wtf/glib/GRefPtr.h>
+
+typedef struct _GtkAction GtkAction;
+typedef struct _GAction GAction;
+typedef struct _GSimpleAction GSimpleAction;
namespace WebKit {
-class WebBatteryStatus : public API::ObjectImpl<API::Object::Type::BatteryStatus> {
+class WebContextMenuItemGtk : public WebContextMenuItemData {
+ WTF_MAKE_FAST_ALLOCATED;
public:
- struct Data {
- void encode(IPC::ArgumentEncoder&) const;
- static bool decode(IPC::ArgumentDecoder&, Data&);
-
- bool isCharging;
- double chargingTime;
- double dischargingTime;
- double level;
- };
+ WebContextMenuItemGtk(WebCore::ContextMenuItemType, WebCore::ContextMenuAction, const String& title, bool enabled = true, bool checked = false);
+ WebContextMenuItemGtk(const WebContextMenuItemData&);
+ WebContextMenuItemGtk(const WebContextMenuItemGtk&, Vector<WebContextMenuItemGtk>&& submenu);
+ WebContextMenuItemGtk(GtkAction*);
+ ~WebContextMenuItemGtk();
- static PassRefPtr<WebBatteryStatus> create(bool isCharging, double chargingTime, double dischargingTime, double level)
- {
- return adoptRef(new WebBatteryStatus(isCharging, chargingTime, dischargingTime, level));
- }
-
- virtual ~WebBatteryStatus();
- double isCharging() const { return m_data.isCharging; }
- double chargingTime() const { return m_data.chargingTime; }
- double dischargingTime() const { return m_data.dischargingTime; }
- double level() const { return m_data.level; }
-
- const Data& data() const { return m_data; }
+ // We don't use the SubmenuType internally, so check if we have submenu items.
+ WebCore::ContextMenuItemType type() const { return m_submenuItems.isEmpty() ? WebContextMenuItemData::type() : WebCore::SubmenuType; }
+ GtkAction* gtkAction() const { return m_gtkAction; }
+ GAction* gAction() const { return reinterpret_cast<GAction*>(m_gAction.get()); }
+ const Vector<WebContextMenuItemGtk>& submenuItems() const { return m_submenuItems; }
private:
- WebBatteryStatus(bool isCharging, double chargingTime, double dischargingTime, double level);
+ void createActionIfNeeded();
- Data m_data;
+ GRefPtr<GSimpleAction> m_gAction;
+ GtkAction* m_gtkAction { nullptr };
+ Vector<WebContextMenuItemGtk> m_submenuItems;
};
} // namespace WebKit
-#endif // ENABLE(BATTERY_STATUS)
-
-#endif // WebBatteryStatus_h
+#endif // WebContextMenuItemGtk_h
diff --git a/Source/WebKit2/Shared/gtk/WebEventFactory.cpp b/Source/WebKit2/Shared/gtk/WebEventFactory.cpp
index 462b11b89..afb5f8451 100644
--- a/Source/WebKit2/Shared/gtk/WebEventFactory.cpp
+++ b/Source/WebKit2/Shared/gtk/WebEventFactory.cpp
@@ -63,6 +63,8 @@ static inline WebEvent::Modifiers modifiersForEvent(const GdkEvent* event)
modifiers |= WebEvent::AltKey;
if (state & GDK_META_MASK)
modifiers |= WebEvent::MetaKey;
+ if (PlatformKeyboardEvent::modifiersContainCapsLock(state))
+ modifiers |= WebEvent::CapsLockKey;
return static_cast<WebEvent::Modifiers>(modifiers);
}
@@ -72,15 +74,20 @@ static inline WebMouseEvent::Button buttonForEvent(const GdkEvent* event)
unsigned button = 0;
switch (event->type) {
- case GDK_MOTION_NOTIFY:
+ case GDK_ENTER_NOTIFY:
+ case GDK_LEAVE_NOTIFY:
+ case GDK_MOTION_NOTIFY: {
button = WebMouseEvent::NoButton;
- if (event->motion.state & GDK_BUTTON1_MASK)
+ GdkModifierType state;
+ gdk_event_get_state(event, &state);
+ if (state & GDK_BUTTON1_MASK)
button = WebMouseEvent::LeftButton;
- else if (event->motion.state & GDK_BUTTON2_MASK)
+ else if (state & GDK_BUTTON2_MASK)
button = WebMouseEvent::MiddleButton;
- else if (event->motion.state & GDK_BUTTON3_MASK)
+ else if (state & GDK_BUTTON3_MASK)
button = WebMouseEvent::RightButton;
break;
+ }
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
@@ -108,6 +115,8 @@ WebMouseEvent WebEventFactory::createWebMouseEvent(const GdkEvent* event, int cu
WebEvent::Type type = static_cast<WebEvent::Type>(0);
switch (event->type) {
case GDK_MOTION_NOTIFY:
+ case GDK_ENTER_NOTIFY:
+ case GDK_LEAVE_NOTIFY:
type = WebEvent::MouseMove;
break;
case GDK_BUTTON_PRESS:
@@ -181,69 +190,28 @@ WebWheelEvent WebEventFactory::createWebWheelEvent(const GdkEvent* event)
gdk_event_get_time(event));
}
-WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(const GdkEvent* event, const WebCore::CompositionResults& compositionResults)
-{
- unsigned int keyValue = event->key.keyval;
- String text = compositionResults.simpleString.length() ?
- compositionResults.simpleString : PlatformKeyboardEvent::singleCharacterString(keyValue);
-
- int windowsVirtualKeyCode = compositionResults.compositionUpdated() ?
- VK_PROCESSKEY : PlatformKeyboardEvent::windowsKeyCodeForGdkKeyCode(event->key.keyval);
-
- return WebKeyboardEvent((event->type == GDK_KEY_RELEASE) ? WebEvent::KeyUp : WebEvent::KeyDown,
- text,
- text,
- PlatformKeyboardEvent::keyIdentifierForGdkKeyCode(keyValue),
- windowsVirtualKeyCode,
- static_cast<int>(keyValue),
- 0 /* macCharCode */,
- false /* isAutoRepeat */,
- isGdkKeyCodeFromKeyPad(keyValue),
- false /* isSystemKey */,
- modifiersForEvent(event),
- gdk_event_get_time(event));
-}
-
-#ifndef GTK_API_VERSION_2
-static WebPlatformTouchPoint::TouchPointState touchPhaseFromEvents(const GdkEvent* current, const GdkEvent* event)
-{
- if (gdk_event_get_event_sequence(current) != gdk_event_get_event_sequence(event))
- return WebPlatformTouchPoint::TouchStationary;
-
- switch (current->type) {
- case GDK_TOUCH_UPDATE:
- return WebPlatformTouchPoint::TouchMoved;
- case GDK_TOUCH_BEGIN:
- return WebPlatformTouchPoint::TouchPressed;
- case GDK_TOUCH_END:
- return WebPlatformTouchPoint::TouchReleased;
- default:
- return WebPlatformTouchPoint::TouchStationary;
- }
-}
-
-static void appendTouchEvent(Vector<WebPlatformTouchPoint>& touchPointList, const GdkEvent* event, WebPlatformTouchPoint::TouchPointState state)
+WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(const GdkEvent* event, const WebCore::CompositionResults& compositionResults, Vector<String>&& commands)
{
- uint32_t identifier = GPOINTER_TO_UINT(gdk_event_get_event_sequence(event));
-
- gdouble x, y;
- gdk_event_get_coords(event, &x, &y);
-
- gdouble xRoot, yRoot;
- gdk_event_get_root_coords(event, &xRoot, &yRoot);
-
- WebPlatformTouchPoint touchPoint(identifier, state, IntPoint(xRoot, yRoot), IntPoint(x, y));
- touchPointList.uncheckedAppend(touchPoint);
+ return WebKeyboardEvent(
+ event->type == GDK_KEY_RELEASE ? WebEvent::KeyUp : WebEvent::KeyDown,
+ compositionResults.simpleString.length() ? compositionResults.simpleString : PlatformKeyboardEvent::singleCharacterString(event->key.keyval),
+ PlatformKeyboardEvent::keyValueForGdkKeyCode(event->key.keyval),
+ PlatformKeyboardEvent::keyCodeForHardwareKeyCode(event->key.hardware_keycode),
+ PlatformKeyboardEvent::keyIdentifierForGdkKeyCode(event->key.keyval),
+ PlatformKeyboardEvent::windowsKeyCodeForGdkKeyCode(event->key.keyval),
+ static_cast<int>(event->key.keyval),
+ compositionResults.compositionUpdated(),
+ WTFMove(commands),
+ isGdkKeyCodeFromKeyPad(event->key.keyval),
+ modifiersForEvent(event),
+ gdk_event_get_time(event));
}
-#endif // GTK_API_VERSION_2
-WebTouchEvent WebEventFactory::createWebTouchEvent(const GdkEvent* event, const WebCore::GtkTouchContextHelper& touchContext)
+#if ENABLE(TOUCH_EVENTS)
+WebTouchEvent WebEventFactory::createWebTouchEvent(const GdkEvent* event, Vector<WebPlatformTouchPoint>&& touchPoints)
{
#ifndef GTK_API_VERSION_2
WebEvent::Type type = WebEvent::NoType;
- const auto& touchEvents = touchContext.touchEvents();
- int numEvents = touchEvents.size();
-
switch (event->type) {
case GDK_TOUCH_BEGIN:
type = WebEvent::TouchStart;
@@ -253,26 +221,16 @@ WebTouchEvent WebEventFactory::createWebTouchEvent(const GdkEvent* event, const
break;
case GDK_TOUCH_END:
type = WebEvent::TouchEnd;
- ++numEvents;
break;
default:
ASSERT_NOT_REACHED();
}
- Vector<WebPlatformTouchPoint> touchPointList;
- touchPointList.reserveInitialCapacity(numEvents);
-
- for (auto it = touchEvents.begin(); it != touchEvents.end(); ++it)
- appendTouchEvent(touchPointList, it->value.get(), touchPhaseFromEvents(it->value.get(), event));
-
- // Touch was already removed from the GtkTouchContextHelper, add it here.
- if (event->type == GDK_TOUCH_END)
- appendTouchEvent(touchPointList, event, WebPlatformTouchPoint::TouchReleased);
-
- return WebTouchEvent(type, touchPointList, modifiersForEvent(event), gdk_event_get_time(event));
+ return WebTouchEvent(type, WTFMove(touchPoints), modifiersForEvent(event), gdk_event_get_time(event));
#else
return WebTouchEvent();
#endif // GTK_API_VERSION_2
}
+#endif
} // namespace WebKit
diff --git a/Source/WebKit2/Shared/gtk/WebEventFactory.h b/Source/WebKit2/Shared/gtk/WebEventFactory.h
index fc30296f4..28b69538e 100644
--- a/Source/WebKit2/Shared/gtk/WebEventFactory.h
+++ b/Source/WebKit2/Shared/gtk/WebEventFactory.h
@@ -29,7 +29,6 @@
#include "WebEvent.h"
#include <WebCore/CompositionResults.h>
-#include <WebCore/GtkTouchContextHelper.h>
typedef union _GdkEvent GdkEvent;
@@ -39,8 +38,10 @@ class WebEventFactory {
public:
static WebMouseEvent createWebMouseEvent(const GdkEvent*, int);
static WebWheelEvent createWebWheelEvent(const GdkEvent*);
- static WebKeyboardEvent createWebKeyboardEvent(const GdkEvent*, const WebCore::CompositionResults&);
- static WebTouchEvent createWebTouchEvent(const GdkEvent*, const WebCore::GtkTouchContextHelper&);
+ static WebKeyboardEvent createWebKeyboardEvent(const GdkEvent*, const WebCore::CompositionResults&, Vector<String>&& commands);
+#if ENABLE(TOUCH_EVENTS)
+ static WebTouchEvent createWebTouchEvent(const GdkEvent*, Vector<WebPlatformTouchPoint>&&);
+#endif
};
} // namespace WebKit
diff --git a/Source/WebKit2/Shared/gtk/WebKit2WaylandProtocol.xml b/Source/WebKit2/Shared/gtk/WebKit2WaylandProtocol.xml
new file mode 100644
index 000000000..1246132f9
--- /dev/null
+++ b/Source/WebKit2/Shared/gtk/WebKit2WaylandProtocol.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<protocol name="wl_webkitgtk">
+
+ <copyright>
+ Copyright © 2014 Igalia S.L.
+
+ Permission to use, copy, modify, distribute, and sell this
+ software and its documentation for any purpose is hereby granted
+ without fee, provided that the above copyright notice appear in
+ all copies and that both that copyright notice and this permission
+ notice appear in supporting documentation, and that the name of
+ the copyright holders not be used in advertising or publicity
+ pertaining to distribution of the software without specific,
+ written prior permission. The copyright holders make no
+ representations about the suitability of this software for any
+ purpose. It is provided "as is" without express or implied
+ warranty.
+
+ THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+ AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+ THIS SOFTWARE.
+ </copyright>
+
+ <interface name="wl_webkitgtk" version="1">
+ <request name="bind_surface_to_page">
+ <arg name="surface" type="object" interface="wl_surface"/>
+ <arg name="page_id" type="uint"/>
+ </request>
+
+ </interface>
+
+</protocol>
diff --git a/Source/WebKit2/Shared/gtk/WebSelectionData.cpp b/Source/WebKit2/Shared/gtk/WebSelectionData.cpp
new file mode 100644
index 000000000..19fc24ac6
--- /dev/null
+++ b/Source/WebKit2/Shared/gtk/WebSelectionData.cpp
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2016 Red Hat Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+#include "WebSelectionData.h"
+
+#include "ArgumentCodersGtk.h"
+#include "Decoder.h"
+#include "Encoder.h"
+#include <wtf/RetainPtr.h>
+
+namespace WebKit {
+
+WebSelectionData::WebSelectionData()
+ : selectionData(WebCore::SelectionData::create())
+{
+}
+
+WebSelectionData::WebSelectionData(const WebCore::SelectionData& data)
+ : selectionData(const_cast<WebCore::SelectionData&>(data))
+{
+}
+
+WebSelectionData::WebSelectionData(Ref<WebCore::SelectionData>&& data)
+ : selectionData(WTFMove(data))
+{
+}
+
+void WebSelectionData::encode(IPC::Encoder& encoder) const
+{
+ encoder << selectionData.get();
+}
+
+bool WebSelectionData::decode(IPC::Decoder& decoder, WebSelectionData& selection)
+{
+ return decoder.decode(selection.selectionData.get());
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/Shared/gtk/WebSelectionData.h b/Source/WebKit2/Shared/gtk/WebSelectionData.h
new file mode 100644
index 000000000..18d850304
--- /dev/null
+++ b/Source/WebKit2/Shared/gtk/WebSelectionData.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2016 Red Hat Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#pragma once
+
+#include <WebCore/SelectionData.h>
+
+namespace IPC {
+class Decoder;
+class Encoder;
+}
+
+namespace WebKit {
+
+struct WebSelectionData {
+ WebSelectionData();
+ explicit WebSelectionData(const WebCore::SelectionData&);
+ explicit WebSelectionData(Ref<WebCore::SelectionData>&&);
+
+ Ref<WebCore::SelectionData> selectionData;
+
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, WebSelectionData&);
+};
+
+} // namespace WebKit
+
diff --git a/Source/WebKit2/Shared/linux/WebMemorySamplerLinux.cpp b/Source/WebKit2/Shared/linux/WebMemorySamplerLinux.cpp
new file mode 100644
index 000000000..40c5e3946
--- /dev/null
+++ b/Source/WebKit2/Shared/linux/WebMemorySamplerLinux.cpp
@@ -0,0 +1,163 @@
+/*
+ * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2012 Samsung Electronics
+ *
+ * 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 "WebMemorySampler.h"
+
+#if ENABLE(MEMORY_SAMPLER)
+
+#include <JavaScriptCore/MemoryStatistics.h>
+#include <WebCore/CommonVM.h>
+#include <WebCore/CurrentProcessMemoryStatus.h>
+#include <WebCore/JSDOMWindow.h>
+#include <WebCore/NotImplemented.h>
+#include <runtime/JSCInlines.h>
+#include <runtime/JSLock.h>
+#include <string.h>
+#include <sys/sysinfo.h>
+#include <wtf/CurrentTime.h>
+#include <wtf/text/WTFString.h>
+
+using namespace WebCore;
+using namespace JSC;
+using namespace WTF;
+
+namespace WebKit {
+
+static const unsigned int maxBuffer = 128;
+static const unsigned int maxProcessPath = 35;
+
+static inline String nextToken(FILE* file)
+{
+ ASSERT(file);
+ if (!file)
+ return String();
+
+ char buffer[maxBuffer] = {0, };
+ unsigned int index = 0;
+ while (index < maxBuffer) {
+ int ch = fgetc(file);
+ if (ch == EOF || (isASCIISpace(ch) && index)) // Break on non-initial ASCII space.
+ break;
+ if (!isASCIISpace(ch)) {
+ buffer[index] = ch;
+ index++;
+ }
+ }
+
+ return String(buffer);
+}
+
+static inline void appendKeyValuePair(WebMemoryStatistics& stats, const String& key, size_t value)
+{
+ stats.keys.append(key);
+ stats.values.append(value);
+}
+
+String WebMemorySampler::processName() const
+{
+ char processPath[maxProcessPath];
+ snprintf(processPath, maxProcessPath, "/proc/self/status");
+ FILE* statusFileDescriptor = fopen(processPath, "r");
+ if (!statusFileDescriptor)
+ return String();
+
+ nextToken(statusFileDescriptor);
+ String processName = nextToken(statusFileDescriptor);
+
+ fclose(statusFileDescriptor);
+
+ return processName;
+}
+
+WebMemoryStatistics WebMemorySampler::sampleWebKit() const
+{
+ WebMemoryStatistics webKitMemoryStats;
+
+ double now = currentTime();
+
+ appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Timestamp"), now);
+
+ ProcessMemoryStatus processMemoryStatus;
+ currentProcessMemoryStatus(processMemoryStatus);
+
+ appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Total Program Bytes"), processMemoryStatus.size);
+ appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Resident Set Bytes"), processMemoryStatus.resident);
+ appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Resident Shared Bytes"), processMemoryStatus.shared);
+ appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Text Bytes"), processMemoryStatus.text);
+ appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Library Bytes"), processMemoryStatus.lib);
+ appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Data + Stack Bytes"), processMemoryStatus.data);
+ appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Dirty Bytes"), processMemoryStatus.dt);
+
+ size_t totalBytesInUse = 0;
+ size_t totalBytesCommitted = 0;
+
+ FastMallocStatistics fastMallocStatistics = WTF::fastMallocStatistics();
+ size_t fastMallocBytesInUse = fastMallocStatistics.committedVMBytes - fastMallocStatistics.freeListBytes;
+ size_t fastMallocBytesCommitted = fastMallocStatistics.committedVMBytes;
+ totalBytesInUse += fastMallocBytesInUse;
+ totalBytesCommitted += fastMallocBytesCommitted;
+
+ appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Fast Malloc In Use"), fastMallocBytesInUse);
+ appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Fast Malloc Committed Memory"), fastMallocBytesCommitted);
+
+ size_t jscHeapBytesInUse = commonVM().heap.size();
+ size_t jscHeapBytesCommitted = commonVM().heap.capacity();
+ totalBytesInUse += jscHeapBytesInUse;
+ totalBytesCommitted += jscHeapBytesCommitted;
+
+ GlobalMemoryStatistics globalMemoryStats = globalMemoryStatistics();
+ totalBytesInUse += globalMemoryStats.stackBytes + globalMemoryStats.JITBytes;
+ totalBytesCommitted += globalMemoryStats.stackBytes + globalMemoryStats.JITBytes;
+
+ appendKeyValuePair(webKitMemoryStats, ASCIILiteral("JavaScript Heap In Use"), jscHeapBytesInUse);
+ appendKeyValuePair(webKitMemoryStats, ASCIILiteral("JavaScript Heap Committed Memory"), jscHeapBytesCommitted);
+
+ appendKeyValuePair(webKitMemoryStats, ASCIILiteral("JavaScript Stack Bytes"), globalMemoryStats.stackBytes);
+ appendKeyValuePair(webKitMemoryStats, ASCIILiteral("JavaScript JIT Bytes"), globalMemoryStats.JITBytes);
+
+ appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Total Memory In Use"), totalBytesInUse);
+ appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Total Committed Memory"), totalBytesCommitted);
+
+ struct sysinfo systemInfo;
+ if (!sysinfo(&systemInfo)) {
+ appendKeyValuePair(webKitMemoryStats, ASCIILiteral("System Total Bytes"), systemInfo.totalram);
+ appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Available Bytes"), systemInfo.freeram);
+ appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Shared Bytes"), systemInfo.sharedram);
+ appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Buffer Bytes"), systemInfo.bufferram);
+ appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Total Swap Bytes"), systemInfo.totalswap);
+ appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Available Swap Bytes"), systemInfo.freeswap);
+ }
+
+ return webKitMemoryStats;
+}
+
+void WebMemorySampler::sendMemoryPressureEvent()
+{
+ notImplemented();
+}
+
+}
+#endif
diff --git a/Source/WebKit2/Shared/soup/WebCoreArgumentCodersSoup.cpp b/Source/WebKit2/Shared/soup/WebCoreArgumentCodersSoup.cpp
index 727895087..49f407175 100644
--- a/Source/WebKit2/Shared/soup/WebCoreArgumentCodersSoup.cpp
+++ b/Source/WebKit2/Shared/soup/WebCoreArgumentCodersSoup.cpp
@@ -33,49 +33,24 @@
#include <WebCore/ResourceError.h>
#include <WebCore/ResourceRequest.h>
#include <WebCore/ResourceResponse.h>
+#include <WebCore/SoupNetworkProxySettings.h>
#include <wtf/text/CString.h>
using namespace WebCore;
namespace IPC {
-void ArgumentCoder<ResourceRequest>::encodePlatformData(ArgumentEncoder& encoder, const ResourceRequest& resourceRequest)
+void ArgumentCoder<ResourceRequest>::encodePlatformData(Encoder& encoder, const ResourceRequest& resourceRequest)
{
- encoder << static_cast<uint32_t>(resourceRequest.soupMessageFlags());
- encoder << resourceRequest.initiatingPageID();
+ resourceRequest.encodeWithPlatformData(encoder);
}
-bool ArgumentCoder<ResourceRequest>::decodePlatformData(ArgumentDecoder& decoder, ResourceRequest& resourceRequest)
+bool ArgumentCoder<ResourceRequest>::decodePlatformData(Decoder& decoder, ResourceRequest& resourceRequest)
{
- uint32_t soupMessageFlags;
- if (!decoder.decode(soupMessageFlags))
- return false;
- resourceRequest.setSoupMessageFlags(static_cast<SoupMessageFlags>(soupMessageFlags));
-
- uint64_t initiatingPageID;
- if (!decoder.decode(initiatingPageID))
- return false;
- resourceRequest.setInitiatingPageID(initiatingPageID);
-
- return true;
-}
-
-
-void ArgumentCoder<ResourceResponse>::encodePlatformData(ArgumentEncoder& encoder, const ResourceResponse& resourceResponse)
-{
- encoder << static_cast<uint32_t>(resourceResponse.soupMessageFlags());
-}
-
-bool ArgumentCoder<ResourceResponse>::decodePlatformData(ArgumentDecoder& decoder, ResourceResponse& resourceResponse)
-{
- uint32_t soupMessageFlags;
- if (!decoder.decode(soupMessageFlags))
- return false;
- resourceResponse.setSoupMessageFlags(static_cast<SoupMessageFlags>(soupMessageFlags));
- return true;
+ return resourceRequest.decodeWithPlatformData(decoder);
}
-void ArgumentCoder<CertificateInfo>::encode(ArgumentEncoder& encoder, const CertificateInfo& certificateInfo)
+void ArgumentCoder<CertificateInfo>::encode(Encoder& encoder, const CertificateInfo& certificateInfo)
{
if (!certificateInfo.certificate()) {
encoder << false;
@@ -95,7 +70,7 @@ void ArgumentCoder<CertificateInfo>::encode(ArgumentEncoder& encoder, const Cert
encoder << static_cast<uint32_t>(certificateInfo.tlsErrors());
}
-bool ArgumentCoder<CertificateInfo>::decode(ArgumentDecoder& decoder, CertificateInfo& certificateInfo)
+bool ArgumentCoder<CertificateInfo>::decode(Decoder& decoder, CertificateInfo& certificateInfo)
{
bool hasCertificate;
if (!decoder.decode(hasCertificate))
@@ -125,13 +100,49 @@ bool ArgumentCoder<CertificateInfo>::decode(ArgumentDecoder& decoder, Certificat
return true;
}
-void ArgumentCoder<ResourceError>::encodePlatformData(ArgumentEncoder& encoder, const ResourceError& resourceError)
+void ArgumentCoder<ResourceError>::encodePlatformData(Encoder& encoder, const ResourceError& resourceError)
{
+ encoder.encodeEnum(resourceError.type());
+ if (resourceError.isNull())
+ return;
+
+ encoder << resourceError.domain();
+ encoder << resourceError.errorCode();
+ encoder << resourceError.failingURL().string();
+ encoder << resourceError.localizedDescription();
+
encoder << CertificateInfo(resourceError);
}
-bool ArgumentCoder<ResourceError>::decodePlatformData(ArgumentDecoder& decoder, ResourceError& resourceError)
+bool ArgumentCoder<ResourceError>::decodePlatformData(Decoder& decoder, ResourceError& resourceError)
{
+ ResourceErrorBase::Type errorType;
+ if (!decoder.decodeEnum(errorType))
+ return false;
+ if (errorType == ResourceErrorBase::Type::Null) {
+ resourceError = { };
+ return true;
+ }
+
+ String domain;
+ if (!decoder.decode(domain))
+ return false;
+
+ int errorCode;
+ if (!decoder.decode(errorCode))
+ return false;
+
+ String failingURL;
+ if (!decoder.decode(failingURL))
+ return false;
+
+ String localizedDescription;
+ if (!decoder.decode(localizedDescription))
+ return false;
+
+ resourceError = ResourceError(domain, errorCode, URL(URL(), failingURL), localizedDescription);
+ resourceError.setType(errorType);
+
CertificateInfo certificateInfo;
if (!decoder.decode(certificateInfo))
return false;
@@ -141,5 +152,76 @@ bool ArgumentCoder<ResourceError>::decodePlatformData(ArgumentDecoder& decoder,
return true;
}
+void ArgumentCoder<SoupNetworkProxySettings>::encode(Encoder& encoder, const SoupNetworkProxySettings& settings)
+{
+ ASSERT(!settings.isEmpty());
+ encoder.encodeEnum(settings.mode);
+ if (settings.mode != SoupNetworkProxySettings::Mode::Custom)
+ return;
+
+ encoder << settings.defaultProxyURL;
+ uint32_t ignoreHostsCount = settings.ignoreHosts ? g_strv_length(settings.ignoreHosts.get()) : 0;
+ encoder << ignoreHostsCount;
+ if (ignoreHostsCount) {
+ for (uint32_t i = 0; settings.ignoreHosts.get()[i]; ++i)
+ encoder << CString(settings.ignoreHosts.get()[i]);
+ }
+ encoder << settings.proxyMap;
+}
+
+bool ArgumentCoder<SoupNetworkProxySettings>::decode(Decoder& decoder, SoupNetworkProxySettings& settings)
+{
+ if (!decoder.decodeEnum(settings.mode))
+ return false;
+
+ if (settings.mode != SoupNetworkProxySettings::Mode::Custom)
+ return true;
+
+ if (!decoder.decode(settings.defaultProxyURL))
+ return false;
+
+ uint32_t ignoreHostsCount;
+ if (!decoder.decode(ignoreHostsCount))
+ return false;
+
+ if (ignoreHostsCount) {
+ settings.ignoreHosts.reset(g_new0(char*, ignoreHostsCount + 1));
+ for (uint32_t i = 0; i < ignoreHostsCount; ++i) {
+ CString host;
+ if (!decoder.decode(host))
+ return false;
+
+ settings.ignoreHosts.get()[i] = g_strdup(host.data());
+ }
+ }
+
+ if (!decoder.decode(settings.proxyMap))
+ return false;
+
+ return !settings.isEmpty();
+}
+
+void ArgumentCoder<ProtectionSpace>::encodePlatformData(Encoder&, const ProtectionSpace&)
+{
+ ASSERT_NOT_REACHED();
+}
+
+bool ArgumentCoder<ProtectionSpace>::decodePlatformData(Decoder&, ProtectionSpace&)
+{
+ ASSERT_NOT_REACHED();
+ return false;
+}
+
+void ArgumentCoder<Credential>::encodePlatformData(Encoder&, const Credential&)
+{
+ ASSERT_NOT_REACHED();
+}
+
+bool ArgumentCoder<Credential>::decodePlatformData(Decoder&, Credential&)
+{
+ ASSERT_NOT_REACHED();
+ return false;
+}
+
}
diff --git a/Source/WebKit2/Shared/APIFrameHandle.cpp b/Source/WebKit2/Shared/unix/ChildProcessMain.cpp
index b50c02349..628be687a 100644
--- a/Source/WebKit2/Shared/APIFrameHandle.cpp
+++ b/Source/WebKit2/Shared/unix/ChildProcessMain.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2014 Igalia S.L.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -24,22 +24,20 @@
*/
#include "config.h"
-#include "APIFrameHandle.h"
+#include "ChildProcessMain.h"
-namespace API {
+#include <stdlib.h>
-RefPtr<FrameHandle> FrameHandle::create(uint64_t frameID)
-{
- return adoptRef(new FrameHandle(frameID));
-}
+namespace WebKit {
-FrameHandle::FrameHandle(uint64_t frameID)
- : m_frameID(frameID)
+bool ChildProcessMainBase::parseCommandLine(int argc, char** argv)
{
-}
+ ASSERT(argc >= 2);
+ if (argc < 2)
+ return false;
-FrameHandle::~FrameHandle()
-{
+ m_parameters.connectionIdentifier = atoi(argv[1]);
+ return true;
}
-} // namespace API
+} // namespace WebKit
diff --git a/Source/WebKit2/Shared/unix/ChildProcessMain.h b/Source/WebKit2/Shared/unix/ChildProcessMain.h
new file mode 100644
index 000000000..7b9029420
--- /dev/null
+++ b/Source/WebKit2/Shared/unix/ChildProcessMain.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ * 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.
+ */
+
+#ifndef ChildProcessMain_h
+#define ChildProcessMain_h
+
+#include "ChildProcess.h"
+#include "WebKit2Initialize.h"
+#include <wtf/RunLoop.h>
+
+namespace WebKit {
+
+class ChildProcessMainBase {
+public:
+ virtual bool platformInitialize() { return true; }
+ virtual bool parseCommandLine(int argc, char** argv);
+ virtual void platformFinalize() { }
+
+ const ChildProcessInitializationParameters& initializationParameters() const { return m_parameters; }
+
+protected:
+ ChildProcessInitializationParameters m_parameters;
+};
+
+template<typename ChildProcessType, typename ChildProcessMainType>
+int ChildProcessMain(int argc, char** argv)
+{
+ ChildProcessMainType childMain;
+
+ if (!childMain.platformInitialize())
+ return EXIT_FAILURE;
+
+ InitializeWebKit2();
+
+ if (!childMain.parseCommandLine(argc, argv))
+ return EXIT_FAILURE;
+
+ ChildProcessType::singleton().initialize(childMain.initializationParameters());
+ RunLoop::run();
+ childMain.platformFinalize();
+
+ return EXIT_SUCCESS;
+}
+
+} // namespace WebKit
+
+#endif // ChildProcessMain_h