From 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Tue, 27 Jun 2017 06:07:23 +0000 Subject: webkitgtk-2.16.5 --- Source/WebKit2/Shared/API/APIArray.cpp | 85 + Source/WebKit2/Shared/API/APIArray.h | 112 ++ Source/WebKit2/Shared/API/APIClient.h | 85 + Source/WebKit2/Shared/API/APIData.cpp | 49 + Source/WebKit2/Shared/API/APIData.h | 110 ++ Source/WebKit2/Shared/API/APIDictionary.cpp | 84 + Source/WebKit2/Shared/API/APIDictionary.h | 90 + Source/WebKit2/Shared/API/APIError.cpp | 56 + Source/WebKit2/Shared/API/APIError.h | 78 + Source/WebKit2/Shared/API/APIFrameHandle.cpp | 74 + Source/WebKit2/Shared/API/APIFrameHandle.h | 60 + Source/WebKit2/Shared/API/APIGeometry.cpp | 96 ++ Source/WebKit2/Shared/API/APIGeometry.h | 104 ++ Source/WebKit2/Shared/API/APINumber.h | 75 + Source/WebKit2/Shared/API/APIObject.cpp | 43 + Source/WebKit2/Shared/API/APIObject.h | 276 +++ Source/WebKit2/Shared/API/APIPageGroupHandle.cpp | 63 + Source/WebKit2/Shared/API/APIPageGroupHandle.h | 59 + Source/WebKit2/Shared/API/APIPageHandle.cpp | 74 + Source/WebKit2/Shared/API/APIPageHandle.h | 60 + Source/WebKit2/Shared/API/APISecurityOrigin.h | 67 + .../WebKit2/Shared/API/APISerializedScriptValue.h | 81 + Source/WebKit2/Shared/API/APIString.h | 79 + Source/WebKit2/Shared/API/APIURL.h | 134 ++ Source/WebKit2/Shared/API/APIURLRequest.cpp | 71 + Source/WebKit2/Shared/API/APIURLRequest.h | 63 + Source/WebKit2/Shared/API/APIURLResponse.cpp | 55 + Source/WebKit2/Shared/API/APIURLResponse.h | 60 + .../WebKit2/Shared/API/APIUserContentURLPattern.h | 64 + .../WebKit2/Shared/API/c/WKActionMenuItemTypes.h | 59 + Source/WebKit2/Shared/API/c/WKActionMenuTypes.h | 55 + Source/WebKit2/Shared/API/c/WKArray.cpp | 10 +- Source/WebKit2/Shared/API/c/WKArray.h | 2 +- Source/WebKit2/Shared/API/c/WKBase.h | 52 +- Source/WebKit2/Shared/API/c/WKCertificateInfo.h | 2 +- Source/WebKit2/Shared/API/c/WKConnectionRef.h | 12 +- Source/WebKit2/Shared/API/c/WKContextMenuItem.cpp | 48 +- Source/WebKit2/Shared/API/c/WKContextMenuItem.h | 4 +- .../WebKit2/Shared/API/c/WKContextMenuItemTypes.h | 2 + Source/WebKit2/Shared/API/c/WKData.cpp | 2 +- Source/WebKit2/Shared/API/c/WKData.h | 2 +- .../WebKit2/Shared/API/c/WKDeclarationSpecifiers.h | 10 +- .../WebKit2/Shared/API/c/WKDeprecatedFunctions.cpp | 67 +- .../Shared/API/c/WKDiagnosticLoggingResultType.h | 45 + Source/WebKit2/Shared/API/c/WKDictionary.cpp | 13 +- Source/WebKit2/Shared/API/c/WKDictionary.h | 2 +- Source/WebKit2/Shared/API/c/WKError.cpp | 62 - Source/WebKit2/Shared/API/c/WKError.h | 63 - Source/WebKit2/Shared/API/c/WKErrorRef.cpp | 62 + Source/WebKit2/Shared/API/c/WKErrorRef.h | 64 + Source/WebKit2/Shared/API/c/WKEvent.h | 5 +- Source/WebKit2/Shared/API/c/WKGeometry.cpp | 6 +- Source/WebKit2/Shared/API/c/WKGeometry.h | 2 +- Source/WebKit2/Shared/API/c/WKImage.cpp | 4 +- Source/WebKit2/Shared/API/c/WKImage.h | 9 +- .../WebKit2/Shared/API/c/WKImmediateActionTypes.h | 52 + Source/WebKit2/Shared/API/c/WKMutableArray.cpp | 2 +- Source/WebKit2/Shared/API/c/WKMutableArray.h | 2 +- .../WebKit2/Shared/API/c/WKMutableDictionary.cpp | 5 +- Source/WebKit2/Shared/API/c/WKMutableDictionary.h | 2 +- Source/WebKit2/Shared/API/c/WKNumber.cpp | 12 +- Source/WebKit2/Shared/API/c/WKNumber.h | 2 +- .../WebKit2/Shared/API/c/WKPluginInformation.cpp | 56 +- Source/WebKit2/Shared/API/c/WKPluginInformation.h | 2 +- Source/WebKit2/Shared/API/c/WKRenderLayer.cpp | 14 +- Source/WebKit2/Shared/API/c/WKRenderLayer.h | 9 +- Source/WebKit2/Shared/API/c/WKRenderObject.cpp | 18 +- Source/WebKit2/Shared/API/c/WKRenderObject.h | 7 +- Source/WebKit2/Shared/API/c/WKSecurityOrigin.cpp | 94 - Source/WebKit2/Shared/API/c/WKSecurityOrigin.h | 51 - .../WebKit2/Shared/API/c/WKSecurityOriginRef.cpp | 96 ++ Source/WebKit2/Shared/API/c/WKSecurityOriginRef.h | 51 + .../Shared/API/c/WKSerializedScriptValue.cpp | 12 +- .../WebKit2/Shared/API/c/WKSerializedScriptValue.h | 2 +- .../Shared/API/c/WKSerializedScriptValuePrivate.h | 2 +- Source/WebKit2/Shared/API/c/WKSharedAPICast.h | 228 ++- Source/WebKit2/Shared/API/c/WKString.cpp | 74 +- Source/WebKit2/Shared/API/c/WKString.h | 3 +- Source/WebKit2/Shared/API/c/WKStringPrivate.h | 2 +- Source/WebKit2/Shared/API/c/WKType.cpp | 7 +- Source/WebKit2/Shared/API/c/WKType.h | 2 +- Source/WebKit2/Shared/API/c/WKURL.cpp | 6 +- Source/WebKit2/Shared/API/c/WKURL.h | 2 +- Source/WebKit2/Shared/API/c/WKURLRequest.cpp | 10 +- Source/WebKit2/Shared/API/c/WKURLRequest.h | 4 +- Source/WebKit2/Shared/API/c/WKURLResponse.h | 2 +- .../Shared/API/c/WKUserContentURLPattern.cpp | 7 +- .../WebKit2/Shared/API/c/WKUserContentURLPattern.h | 2 +- .../Shared/API/c/WKUserScriptInjectionTime.h | 4 +- Source/WebKit2/Shared/API/c/cairo/WKImageCairo.cpp | 8 +- Source/WebKit2/Shared/API/c/cairo/WKImageCairo.h | 4 +- Source/WebKit2/Shared/API/c/soup/WKBaseSoup.h | 36 - Source/WebKit2/Shared/APIArray.cpp | 77 - Source/WebKit2/Shared/APIArray.h | 93 - Source/WebKit2/Shared/APIClient.h | 85 - Source/WebKit2/Shared/APIData.cpp | 49 - Source/WebKit2/Shared/APIData.h | 104 -- Source/WebKit2/Shared/APIError.cpp | 56 - Source/WebKit2/Shared/APIError.h | 79 - Source/WebKit2/Shared/APIFrameHandle.cpp | 45 - Source/WebKit2/Shared/APIFrameHandle.h | 49 - Source/WebKit2/Shared/APIGeometry.cpp | 96 -- Source/WebKit2/Shared/APIGeometry.h | 105 -- Source/WebKit2/Shared/APINumber.h | 76 - Source/WebKit2/Shared/APIObject.cpp | 43 - Source/WebKit2/Shared/APIObject.h | 236 --- Source/WebKit2/Shared/APIPageHandle.cpp | 45 - Source/WebKit2/Shared/APIPageHandle.h | 49 - Source/WebKit2/Shared/APIString.h | 120 -- Source/WebKit2/Shared/APIURL.h | 125 -- Source/WebKit2/Shared/APIURLRequest.cpp | 72 - Source/WebKit2/Shared/APIURLRequest.h | 63 - Source/WebKit2/Shared/APIURLResponse.cpp | 55 - Source/WebKit2/Shared/APIURLResponse.h | 60 - Source/WebKit2/Shared/APIWebArchive.h | 80 + Source/WebKit2/Shared/APIWebArchiveResource.h | 72 + Source/WebKit2/Shared/ActivityAssertion.cpp | 10 +- Source/WebKit2/Shared/ActivityAssertion.h | 7 +- Source/WebKit2/Shared/AssistedNodeInformation.cpp | 169 ++ Source/WebKit2/Shared/AssistedNodeInformation.h | 119 ++ Source/WebKit2/Shared/AsyncRequest.cpp | 67 + Source/WebKit2/Shared/AsyncRequest.h | 153 ++ .../Authentication/AuthenticationManager.cpp | 273 ++- .../Shared/Authentication/AuthenticationManager.h | 59 +- .../AuthenticationManager.messages.in | 2 + .../soup/AuthenticationManagerSoup.cpp | 53 + .../BlobDataFileReferenceWithSandboxExtension.cpp | 55 + .../BlobDataFileReferenceWithSandboxExtension.h | 54 + Source/WebKit2/Shared/BlockingResponseMap.h | 21 +- Source/WebKit2/Shared/CacheModel.cpp | 146 +- Source/WebKit2/Shared/CacheModel.h | 6 +- Source/WebKit2/Shared/ChildProcess.cpp | 60 +- Source/WebKit2/Shared/ChildProcess.h | 34 +- Source/WebKit2/Shared/ChildProcess.messages.in | 25 + Source/WebKit2/Shared/ChildProcessProxy.cpp | 169 -- Source/WebKit2/Shared/ChildProcessProxy.h | 116 -- Source/WebKit2/Shared/CommandLine.h | 54 - Source/WebKit2/Shared/ConnectionStack.cpp | 39 - Source/WebKit2/Shared/ConnectionStack.h | 79 - Source/WebKit2/Shared/ContextMenuContextData.cpp | 143 ++ Source/WebKit2/Shared/ContextMenuContextData.h | 105 ++ .../CoordinatedBackingStore.cpp | 191 +++ .../CoordinatedGraphics/CoordinatedBackingStore.h | 93 + .../CoordinatedGraphicsArgumentCoders.cpp | 924 ++++++++++ .../CoordinatedGraphicsArgumentCoders.h | 101 ++ .../CoordinatedGraphicsScene.cpp | 682 ++++++++ .../CoordinatedGraphics/CoordinatedGraphicsScene.h | 194 +++ .../SimpleViewportController.cpp | 172 ++ .../CoordinatedGraphics/SimpleViewportController.h | 81 + .../CoordinatedGraphics/WebCoordinatedSurface.cpp | 131 ++ .../CoordinatedGraphics/WebCoordinatedSurface.h | 83 + .../threadedcompositor/CompositingRunLoop.cpp | 173 ++ .../threadedcompositor/CompositingRunLoop.h | 73 + .../ThreadSafeCoordinatedSurface.cpp | 87 + .../ThreadSafeCoordinatedSurface.h | 58 + .../threadedcompositor/ThreadedCompositor.cpp | 222 +++ .../threadedcompositor/ThreadedCompositor.h | 109 ++ .../Shared/CoreIPCSupport/WebContextMessageKinds.h | 52 - .../DatabaseProcessCreationParameters.cpp | 61 + .../Databases/DatabaseProcessCreationParameters.h | 57 + .../Shared/Databases/IndexedDB/IDBUtilities.cpp | 60 + .../Shared/Databases/IndexedDB/IDBUtilities.h | 47 + .../Shared/Databases/IndexedDB/WebIDBResult.cpp | 54 + .../Shared/Databases/IndexedDB/WebIDBResult.h | 67 + Source/WebKit2/Shared/Downloads/Download.cpp | 165 -- Source/WebKit2/Shared/Downloads/Download.h | 141 -- .../Downloads/DownloadAuthenticationClient.h | 66 - .../WebKit2/Shared/Downloads/DownloadManager.cpp | 94 - Source/WebKit2/Shared/Downloads/DownloadManager.h | 87 - .../Shared/Downloads/gtk/DownloadSoupErrorsGtk.cpp | 46 - .../WebKit2/Shared/Downloads/soup/DownloadSoup.cpp | 310 ---- .../Shared/Downloads/soup/DownloadSoupErrors.h | 39 - Source/WebKit2/Shared/DragControllerAction.h | 2 +- Source/WebKit2/Shared/DrawingAreaInfo.h | 8 +- Source/WebKit2/Shared/EditingRange.h | 84 + Source/WebKit2/Shared/EditorState.cpp | 123 +- Source/WebKit2/Shared/EditorState.h | 122 +- .../Shared/FileAPI/BlobRegistrationData.cpp | 182 -- .../WebKit2/Shared/FileAPI/BlobRegistrationData.h | 61 - Source/WebKit2/Shared/FontInfo.cpp | 68 + Source/WebKit2/Shared/FontInfo.h | 12 +- Source/WebKit2/Shared/FrameInfoData.cpp | 55 + Source/WebKit2/Shared/FrameInfoData.h | 48 + Source/WebKit2/Shared/Gamepad/GamepadData.cpp | 119 ++ Source/WebKit2/Shared/Gamepad/GamepadData.h | 77 + Source/WebKit2/Shared/HangDetectionDisabler.h | 54 + Source/WebKit2/Shared/ImageOptions.h | 6 +- Source/WebKit2/Shared/ImmutableDictionary.cpp | 67 - Source/WebKit2/Shared/ImmutableDictionary.h | 93 - .../Shared/InteractionInformationAtPosition.h | 59 - Source/WebKit2/Shared/LayerTreeContext.cpp | 66 + Source/WebKit2/Shared/LayerTreeContext.h | 42 +- Source/WebKit2/Shared/LoadParameters.cpp | 125 ++ Source/WebKit2/Shared/LoadParameters.h | 74 + Source/WebKit2/Shared/MutableDictionary.cpp | 57 - Source/WebKit2/Shared/MutableDictionary.h | 56 - Source/WebKit2/Shared/NativeWebGestureEvent.h | 52 + Source/WebKit2/Shared/NativeWebKeyboardEvent.h | 36 +- Source/WebKit2/Shared/NativeWebMouseEvent.h | 19 +- Source/WebKit2/Shared/NativeWebTouchEvent.h | 30 +- Source/WebKit2/Shared/NativeWebWheelEvent.h | 17 +- Source/WebKit2/Shared/NavigationActionData.cpp | 31 +- Source/WebKit2/Shared/NavigationActionData.h | 25 +- .../CustomProtocols/CustomProtocolManager.h | 123 -- .../CustomProtocolManager.messages.in | 35 - .../soup/CustomProtocolManagerImpl.cpp | 207 --- .../soup/CustomProtocolManagerImpl.h | 74 - .../soup/CustomProtocolManagerSoup.cpp | 113 -- .../Network/NetworkProcessCreationParameters.cpp | 115 -- .../Network/NetworkProcessCreationParameters.h | 88 - .../Shared/Network/NetworkProcessSupplement.h | 46 - .../Network/NetworkResourceLoadParameters.cpp | 157 -- .../Shared/Network/NetworkResourceLoadParameters.h | 71 - Source/WebKit2/Shared/OriginAndDatabases.cpp | 61 - Source/WebKit2/Shared/OriginAndDatabases.h | 56 - Source/WebKit2/Shared/PlatformPopupMenuData.cpp | 14 +- Source/WebKit2/Shared/PlatformPopupMenuData.h | 13 +- Source/WebKit2/Shared/Plugins/NPIdentifierData.cpp | 8 +- Source/WebKit2/Shared/Plugins/NPIdentifierData.h | 8 +- .../Shared/Plugins/NPObjectMessageReceiver.cpp | 23 +- .../Shared/Plugins/NPObjectMessageReceiver.h | 2 +- Source/WebKit2/Shared/Plugins/NPObjectProxy.cpp | 6 +- .../WebKit2/Shared/Plugins/NPRemoteObjectMap.cpp | 48 +- Source/WebKit2/Shared/Plugins/NPRemoteObjectMap.h | 4 +- Source/WebKit2/Shared/Plugins/NPVariantData.cpp | 8 +- Source/WebKit2/Shared/Plugins/NPVariantData.h | 8 +- .../Plugins/Netscape/NetscapePluginModule.cpp | 13 +- .../Shared/Plugins/Netscape/NetscapePluginModule.h | 6 +- .../Shared/Plugins/Netscape/PluginInformation.cpp | 24 +- .../Shared/Plugins/Netscape/PluginInformation.h | 12 +- .../Netscape/x11/NetscapePluginModuleX11.cpp | 14 +- Source/WebKit2/Shared/Plugins/PluginModuleInfo.cpp | 32 - Source/WebKit2/Shared/Plugins/PluginModuleInfo.h | 16 +- .../Plugins/PluginProcessCreationParameters.cpp | 28 +- .../Plugins/PluginProcessCreationParameters.h | 23 +- Source/WebKit2/Shared/Plugins/PluginQuirks.h | 10 +- .../Shared/Plugins/unix/PluginSearchPath.cpp | 76 + .../WebKit2/Shared/Plugins/unix/PluginSearchPath.h | 38 + Source/WebKit2/Shared/PrintInfo.cpp | 9 +- Source/WebKit2/Shared/PrintInfo.h | 12 +- Source/WebKit2/Shared/ProcessExecutablePath.h | 4 +- Source/WebKit2/Shared/RTCNetwork.cpp | 217 +++ Source/WebKit2/Shared/RTCNetwork.h | 89 + Source/WebKit2/Shared/SandboxExtension.h | 64 +- .../Shared/SandboxInitializationParameters.h | 14 +- .../RemoteScrollingCoordinatorTransaction.cpp | 665 ++++++++ .../RemoteScrollingCoordinatorTransaction.h | 63 + Source/WebKit2/Shared/SecurityOriginData.cpp | 114 -- Source/WebKit2/Shared/SecurityOriginData.h | 65 - Source/WebKit2/Shared/SessionState.cpp | 211 ++- Source/WebKit2/Shared/SessionState.h | 129 +- Source/WebKit2/Shared/SessionTracker.cpp | 64 +- Source/WebKit2/Shared/SessionTracker.h | 24 +- Source/WebKit2/Shared/ShareableBitmap.cpp | 94 +- Source/WebKit2/Shared/ShareableBitmap.h | 42 +- Source/WebKit2/Shared/ShareableResource.cpp | 58 +- Source/WebKit2/Shared/ShareableResource.h | 17 +- Source/WebKit2/Shared/StatisticsData.cpp | 4 +- Source/WebKit2/Shared/StatisticsData.h | 8 +- Source/WebKit2/Shared/TextCheckerState.h | 23 +- Source/WebKit2/Shared/UpdateInfo.cpp | 4 +- Source/WebKit2/Shared/UpdateInfo.h | 9 +- Source/WebKit2/Shared/UserData.cpp | 352 +++- Source/WebKit2/Shared/UserData.h | 32 +- Source/WebKit2/Shared/UserMessageCoders.h | 538 ------ .../Shared/VisibleContentRectUpdateInfo.cpp | 135 ++ .../WebKit2/Shared/VisibleContentRectUpdateInfo.h | 136 ++ Source/WebKit2/Shared/VisitedLinkTable.cpp | 10 +- Source/WebKit2/Shared/VisitedLinkTable.h | 1 + Source/WebKit2/Shared/WebBackForwardListItem.cpp | 100 +- Source/WebKit2/Shared/WebBackForwardListItem.h | 58 +- Source/WebKit2/Shared/WebBatteryStatus.cpp | 72 - Source/WebKit2/Shared/WebBatteryStatus.h | 73 - Source/WebKit2/Shared/WebCertificateInfo.h | 6 +- .../WebKit2/Shared/WebCompiledContentExtension.cpp | 89 + .../WebKit2/Shared/WebCompiledContentExtension.h | 63 + .../Shared/WebCompiledContentExtensionData.cpp | 80 + .../Shared/WebCompiledContentExtensionData.h | 80 + Source/WebKit2/Shared/WebConnection.cpp | 24 +- Source/WebKit2/Shared/WebConnection.h | 12 +- Source/WebKit2/Shared/WebConnection.messages.in | 4 +- Source/WebKit2/Shared/WebContextMenuItem.cpp | 7 +- Source/WebKit2/Shared/WebContextMenuItem.h | 13 +- Source/WebKit2/Shared/WebContextMenuItemData.cpp | 17 +- Source/WebKit2/Shared/WebContextMenuItemData.h | 17 +- Source/WebKit2/Shared/WebCoreArgumentCoders.cpp | 1793 ++++++++++++++------ Source/WebKit2/Shared/WebCoreArgumentCoders.h | 582 +++++-- Source/WebKit2/Shared/WebEvent.cpp | 23 +- Source/WebKit2/Shared/WebEvent.h | 171 +- Source/WebKit2/Shared/WebEventConversion.cpp | 150 +- Source/WebKit2/Shared/WebEventConversion.h | 18 +- Source/WebKit2/Shared/WebFindOptions.h | 3 +- Source/WebKit2/Shared/WebGeolocationPosition.cpp | 5 +- Source/WebKit2/Shared/WebGeolocationPosition.h | 11 +- Source/WebKit2/Shared/WebHitTestResult.cpp | 108 -- Source/WebKit2/Shared/WebHitTestResult.h | 93 - Source/WebKit2/Shared/WebHitTestResultData.cpp | 209 +++ Source/WebKit2/Shared/WebHitTestResultData.h | 93 + Source/WebKit2/Shared/WebImage.cpp | 24 +- Source/WebKit2/Shared/WebImage.h | 20 +- Source/WebKit2/Shared/WebKeyboardEvent.cpp | 110 +- Source/WebKit2/Shared/WebKit2Initialize.cpp | 15 +- Source/WebKit2/Shared/WebKit2Initialize.h | 5 +- Source/WebKit2/Shared/WebMediaSessionMetadata.cpp | 51 + Source/WebKit2/Shared/WebMediaSessionMetadata.h | 57 + Source/WebKit2/Shared/WebMemorySampler.cpp | 190 +++ Source/WebKit2/Shared/WebMemorySampler.h | 12 +- Source/WebKit2/Shared/WebMouseEvent.cpp | 40 +- Source/WebKit2/Shared/WebNavigationDataStore.h | 8 +- Source/WebKit2/Shared/WebNetworkInfo.h | 70 - Source/WebKit2/Shared/WebOpenPanelParameters.cpp | 69 - Source/WebKit2/Shared/WebOpenPanelParameters.h | 61 - .../WebKit2/Shared/WebPageCreationParameters.cpp | 103 +- Source/WebKit2/Shared/WebPageCreationParameters.h | 65 +- Source/WebKit2/Shared/WebPageGroupData.cpp | 15 +- Source/WebKit2/Shared/WebPageGroupData.h | 16 +- Source/WebKit2/Shared/WebPlatformTouchPoint.cpp | 9 +- Source/WebKit2/Shared/WebPopupItem.cpp | 5 +- Source/WebKit2/Shared/WebPopupItem.h | 10 +- Source/WebKit2/Shared/WebPreferencesDefinitions.h | 384 +++++ Source/WebKit2/Shared/WebPreferencesKeys.cpp | 48 + Source/WebKit2/Shared/WebPreferencesKeys.h | 46 + Source/WebKit2/Shared/WebPreferencesStore.cpp | 250 +-- Source/WebKit2/Shared/WebPreferencesStore.h | 362 ++-- .../Shared/WebProcessCreationParameters.cpp | 245 ++- .../WebKit2/Shared/WebProcessCreationParameters.h | 152 +- Source/WebKit2/Shared/WebRenderLayer.cpp | 34 +- Source/WebKit2/Shared/WebRenderLayer.h | 9 +- Source/WebKit2/Shared/WebRenderObject.cpp | 86 +- Source/WebKit2/Shared/WebRenderObject.h | 17 +- Source/WebKit2/Shared/WebResourceBuffer.cpp | 63 - Source/WebKit2/Shared/WebResourceBuffer.h | 57 - Source/WebKit2/Shared/WebSQLiteDatabaseTracker.cpp | 82 + Source/WebKit2/Shared/WebSQLiteDatabaseTracker.h | 60 + Source/WebKit2/Shared/WebSecurityOrigin.h | 83 - Source/WebKit2/Shared/WebSerializedScriptValue.h | 77 - Source/WebKit2/Shared/WebTouchEvent.cpp | 13 +- .../Shared/WebUserContentControllerDataTypes.cpp | 89 + .../Shared/WebUserContentControllerDataTypes.h | 68 + Source/WebKit2/Shared/WebUserContentURLPattern.h | 65 - Source/WebKit2/Shared/WebWheelEvent.cpp | 13 +- Source/WebKit2/Shared/WebsiteData/WebsiteData.cpp | 81 + Source/WebKit2/Shared/WebsiteData/WebsiteData.h | 63 + .../Shared/WebsiteData/WebsiteDataFetchOption.h | 38 + .../WebKit2/Shared/WebsiteData/WebsiteDataType.h | 54 + Source/WebKit2/Shared/WebsitePolicies.h | 61 + .../WebKit2/Shared/cairo/ShareableBitmapCairo.cpp | 16 +- Source/WebKit2/Shared/gtk/ArgumentCodersGtk.cpp | 145 +- Source/WebKit2/Shared/gtk/ArgumentCodersGtk.h | 23 +- Source/WebKit2/Shared/gtk/LayerTreeContextGtk.cpp | 64 - .../Shared/gtk/NativeWebKeyboardEventGtk.cpp | 8 +- .../WebKit2/Shared/gtk/NativeWebTouchEventGtk.cpp | 12 +- .../Shared/gtk/ProcessExecutablePathGtk.cpp | 22 +- .../WebKit2/Shared/gtk/WebContextMenuItemGtk.cpp | 181 ++ Source/WebKit2/Shared/gtk/WebContextMenuItemGtk.h | 64 + Source/WebKit2/Shared/gtk/WebEventFactory.cpp | 104 +- Source/WebKit2/Shared/gtk/WebEventFactory.h | 7 +- .../WebKit2/Shared/gtk/WebKit2WaylandProtocol.xml | 37 + Source/WebKit2/Shared/gtk/WebSelectionData.cpp | 54 + Source/WebKit2/Shared/gtk/WebSelectionData.h | 42 + .../WebKit2/Shared/linux/WebMemorySamplerLinux.cpp | 163 ++ .../Shared/soup/WebCoreArgumentCodersSoup.cpp | 150 +- Source/WebKit2/Shared/unix/ChildProcessMain.cpp | 43 + Source/WebKit2/Shared/unix/ChildProcessMain.h | 69 + 364 files changed, 18107 insertions(+), 9918 deletions(-) create mode 100644 Source/WebKit2/Shared/API/APIArray.cpp create mode 100644 Source/WebKit2/Shared/API/APIArray.h create mode 100644 Source/WebKit2/Shared/API/APIClient.h create mode 100644 Source/WebKit2/Shared/API/APIData.cpp create mode 100644 Source/WebKit2/Shared/API/APIData.h create mode 100644 Source/WebKit2/Shared/API/APIDictionary.cpp create mode 100644 Source/WebKit2/Shared/API/APIDictionary.h create mode 100644 Source/WebKit2/Shared/API/APIError.cpp create mode 100644 Source/WebKit2/Shared/API/APIError.h create mode 100644 Source/WebKit2/Shared/API/APIFrameHandle.cpp create mode 100644 Source/WebKit2/Shared/API/APIFrameHandle.h create mode 100644 Source/WebKit2/Shared/API/APIGeometry.cpp create mode 100644 Source/WebKit2/Shared/API/APIGeometry.h create mode 100644 Source/WebKit2/Shared/API/APINumber.h create mode 100644 Source/WebKit2/Shared/API/APIObject.cpp create mode 100644 Source/WebKit2/Shared/API/APIObject.h create mode 100644 Source/WebKit2/Shared/API/APIPageGroupHandle.cpp create mode 100644 Source/WebKit2/Shared/API/APIPageGroupHandle.h create mode 100644 Source/WebKit2/Shared/API/APIPageHandle.cpp create mode 100644 Source/WebKit2/Shared/API/APIPageHandle.h create mode 100644 Source/WebKit2/Shared/API/APISecurityOrigin.h create mode 100644 Source/WebKit2/Shared/API/APISerializedScriptValue.h create mode 100644 Source/WebKit2/Shared/API/APIString.h create mode 100644 Source/WebKit2/Shared/API/APIURL.h create mode 100644 Source/WebKit2/Shared/API/APIURLRequest.cpp create mode 100644 Source/WebKit2/Shared/API/APIURLRequest.h create mode 100644 Source/WebKit2/Shared/API/APIURLResponse.cpp create mode 100644 Source/WebKit2/Shared/API/APIURLResponse.h create mode 100644 Source/WebKit2/Shared/API/APIUserContentURLPattern.h create mode 100644 Source/WebKit2/Shared/API/c/WKActionMenuItemTypes.h create mode 100644 Source/WebKit2/Shared/API/c/WKActionMenuTypes.h create mode 100644 Source/WebKit2/Shared/API/c/WKDiagnosticLoggingResultType.h delete mode 100644 Source/WebKit2/Shared/API/c/WKError.cpp delete mode 100644 Source/WebKit2/Shared/API/c/WKError.h create mode 100644 Source/WebKit2/Shared/API/c/WKErrorRef.cpp create mode 100644 Source/WebKit2/Shared/API/c/WKErrorRef.h create mode 100644 Source/WebKit2/Shared/API/c/WKImmediateActionTypes.h delete mode 100644 Source/WebKit2/Shared/API/c/WKSecurityOrigin.cpp delete mode 100644 Source/WebKit2/Shared/API/c/WKSecurityOrigin.h create mode 100644 Source/WebKit2/Shared/API/c/WKSecurityOriginRef.cpp create mode 100644 Source/WebKit2/Shared/API/c/WKSecurityOriginRef.h delete mode 100644 Source/WebKit2/Shared/API/c/soup/WKBaseSoup.h delete mode 100644 Source/WebKit2/Shared/APIArray.cpp delete mode 100644 Source/WebKit2/Shared/APIArray.h delete mode 100644 Source/WebKit2/Shared/APIClient.h delete mode 100644 Source/WebKit2/Shared/APIData.cpp delete mode 100644 Source/WebKit2/Shared/APIData.h delete mode 100644 Source/WebKit2/Shared/APIError.cpp delete mode 100644 Source/WebKit2/Shared/APIError.h delete mode 100644 Source/WebKit2/Shared/APIFrameHandle.cpp delete mode 100644 Source/WebKit2/Shared/APIFrameHandle.h delete mode 100644 Source/WebKit2/Shared/APIGeometry.cpp delete mode 100644 Source/WebKit2/Shared/APIGeometry.h delete mode 100644 Source/WebKit2/Shared/APINumber.h delete mode 100644 Source/WebKit2/Shared/APIObject.cpp delete mode 100644 Source/WebKit2/Shared/APIObject.h delete mode 100644 Source/WebKit2/Shared/APIPageHandle.cpp delete mode 100644 Source/WebKit2/Shared/APIPageHandle.h delete mode 100644 Source/WebKit2/Shared/APIString.h delete mode 100644 Source/WebKit2/Shared/APIURL.h delete mode 100644 Source/WebKit2/Shared/APIURLRequest.cpp delete mode 100644 Source/WebKit2/Shared/APIURLRequest.h delete mode 100644 Source/WebKit2/Shared/APIURLResponse.cpp delete mode 100644 Source/WebKit2/Shared/APIURLResponse.h create mode 100644 Source/WebKit2/Shared/APIWebArchive.h create mode 100644 Source/WebKit2/Shared/APIWebArchiveResource.h create mode 100644 Source/WebKit2/Shared/AssistedNodeInformation.cpp create mode 100644 Source/WebKit2/Shared/AssistedNodeInformation.h create mode 100644 Source/WebKit2/Shared/AsyncRequest.cpp create mode 100644 Source/WebKit2/Shared/AsyncRequest.h create mode 100644 Source/WebKit2/Shared/Authentication/soup/AuthenticationManagerSoup.cpp create mode 100644 Source/WebKit2/Shared/BlobDataFileReferenceWithSandboxExtension.cpp create mode 100644 Source/WebKit2/Shared/BlobDataFileReferenceWithSandboxExtension.h create mode 100644 Source/WebKit2/Shared/ChildProcess.messages.in delete mode 100644 Source/WebKit2/Shared/ChildProcessProxy.cpp delete mode 100644 Source/WebKit2/Shared/ChildProcessProxy.h delete mode 100644 Source/WebKit2/Shared/CommandLine.h delete mode 100644 Source/WebKit2/Shared/ConnectionStack.cpp delete mode 100644 Source/WebKit2/Shared/ConnectionStack.h create mode 100644 Source/WebKit2/Shared/ContextMenuContextData.cpp create mode 100644 Source/WebKit2/Shared/ContextMenuContextData.h create mode 100644 Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedBackingStore.cpp create mode 100644 Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedBackingStore.h create mode 100644 Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp create mode 100644 Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.h create mode 100644 Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp create mode 100644 Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.h create mode 100644 Source/WebKit2/Shared/CoordinatedGraphics/SimpleViewportController.cpp create mode 100644 Source/WebKit2/Shared/CoordinatedGraphics/SimpleViewportController.h create mode 100644 Source/WebKit2/Shared/CoordinatedGraphics/WebCoordinatedSurface.cpp create mode 100644 Source/WebKit2/Shared/CoordinatedGraphics/WebCoordinatedSurface.h create mode 100644 Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.cpp create mode 100644 Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.h create mode 100644 Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadSafeCoordinatedSurface.cpp create mode 100644 Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadSafeCoordinatedSurface.h create mode 100644 Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp create mode 100644 Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h delete mode 100644 Source/WebKit2/Shared/CoreIPCSupport/WebContextMessageKinds.h create mode 100644 Source/WebKit2/Shared/Databases/DatabaseProcessCreationParameters.cpp create mode 100644 Source/WebKit2/Shared/Databases/DatabaseProcessCreationParameters.h create mode 100644 Source/WebKit2/Shared/Databases/IndexedDB/IDBUtilities.cpp create mode 100644 Source/WebKit2/Shared/Databases/IndexedDB/IDBUtilities.h create mode 100644 Source/WebKit2/Shared/Databases/IndexedDB/WebIDBResult.cpp create mode 100644 Source/WebKit2/Shared/Databases/IndexedDB/WebIDBResult.h delete mode 100644 Source/WebKit2/Shared/Downloads/Download.cpp delete mode 100644 Source/WebKit2/Shared/Downloads/Download.h delete mode 100644 Source/WebKit2/Shared/Downloads/DownloadAuthenticationClient.h delete mode 100644 Source/WebKit2/Shared/Downloads/DownloadManager.cpp delete mode 100644 Source/WebKit2/Shared/Downloads/DownloadManager.h delete mode 100644 Source/WebKit2/Shared/Downloads/gtk/DownloadSoupErrorsGtk.cpp delete mode 100644 Source/WebKit2/Shared/Downloads/soup/DownloadSoup.cpp delete mode 100644 Source/WebKit2/Shared/Downloads/soup/DownloadSoupErrors.h create mode 100644 Source/WebKit2/Shared/EditingRange.h delete mode 100644 Source/WebKit2/Shared/FileAPI/BlobRegistrationData.cpp delete mode 100644 Source/WebKit2/Shared/FileAPI/BlobRegistrationData.h create mode 100644 Source/WebKit2/Shared/FontInfo.cpp create mode 100644 Source/WebKit2/Shared/FrameInfoData.cpp create mode 100644 Source/WebKit2/Shared/FrameInfoData.h create mode 100644 Source/WebKit2/Shared/Gamepad/GamepadData.cpp create mode 100644 Source/WebKit2/Shared/Gamepad/GamepadData.h create mode 100644 Source/WebKit2/Shared/HangDetectionDisabler.h delete mode 100644 Source/WebKit2/Shared/ImmutableDictionary.cpp delete mode 100644 Source/WebKit2/Shared/ImmutableDictionary.h delete mode 100644 Source/WebKit2/Shared/InteractionInformationAtPosition.h create mode 100644 Source/WebKit2/Shared/LayerTreeContext.cpp create mode 100644 Source/WebKit2/Shared/LoadParameters.cpp create mode 100644 Source/WebKit2/Shared/LoadParameters.h delete mode 100644 Source/WebKit2/Shared/MutableDictionary.cpp delete mode 100644 Source/WebKit2/Shared/MutableDictionary.h create mode 100644 Source/WebKit2/Shared/NativeWebGestureEvent.h delete mode 100644 Source/WebKit2/Shared/Network/CustomProtocols/CustomProtocolManager.h delete mode 100644 Source/WebKit2/Shared/Network/CustomProtocols/CustomProtocolManager.messages.in delete mode 100644 Source/WebKit2/Shared/Network/CustomProtocols/soup/CustomProtocolManagerImpl.cpp delete mode 100644 Source/WebKit2/Shared/Network/CustomProtocols/soup/CustomProtocolManagerImpl.h delete mode 100644 Source/WebKit2/Shared/Network/CustomProtocols/soup/CustomProtocolManagerSoup.cpp delete mode 100644 Source/WebKit2/Shared/Network/NetworkProcessCreationParameters.cpp delete mode 100644 Source/WebKit2/Shared/Network/NetworkProcessCreationParameters.h delete mode 100644 Source/WebKit2/Shared/Network/NetworkProcessSupplement.h delete mode 100644 Source/WebKit2/Shared/Network/NetworkResourceLoadParameters.cpp delete mode 100644 Source/WebKit2/Shared/Network/NetworkResourceLoadParameters.h delete mode 100644 Source/WebKit2/Shared/OriginAndDatabases.cpp delete mode 100644 Source/WebKit2/Shared/OriginAndDatabases.h delete mode 100644 Source/WebKit2/Shared/Plugins/PluginModuleInfo.cpp create mode 100644 Source/WebKit2/Shared/Plugins/unix/PluginSearchPath.cpp create mode 100644 Source/WebKit2/Shared/Plugins/unix/PluginSearchPath.h create mode 100644 Source/WebKit2/Shared/RTCNetwork.cpp create mode 100644 Source/WebKit2/Shared/RTCNetwork.h create mode 100644 Source/WebKit2/Shared/Scrolling/RemoteScrollingCoordinatorTransaction.cpp create mode 100644 Source/WebKit2/Shared/Scrolling/RemoteScrollingCoordinatorTransaction.h delete mode 100644 Source/WebKit2/Shared/SecurityOriginData.cpp delete mode 100644 Source/WebKit2/Shared/SecurityOriginData.h delete mode 100644 Source/WebKit2/Shared/UserMessageCoders.h create mode 100644 Source/WebKit2/Shared/VisibleContentRectUpdateInfo.cpp create mode 100644 Source/WebKit2/Shared/VisibleContentRectUpdateInfo.h delete mode 100644 Source/WebKit2/Shared/WebBatteryStatus.cpp delete mode 100644 Source/WebKit2/Shared/WebBatteryStatus.h create mode 100644 Source/WebKit2/Shared/WebCompiledContentExtension.cpp create mode 100644 Source/WebKit2/Shared/WebCompiledContentExtension.h create mode 100644 Source/WebKit2/Shared/WebCompiledContentExtensionData.cpp create mode 100644 Source/WebKit2/Shared/WebCompiledContentExtensionData.h delete mode 100644 Source/WebKit2/Shared/WebHitTestResult.cpp delete mode 100644 Source/WebKit2/Shared/WebHitTestResult.h create mode 100644 Source/WebKit2/Shared/WebHitTestResultData.cpp create mode 100644 Source/WebKit2/Shared/WebHitTestResultData.h create mode 100644 Source/WebKit2/Shared/WebMediaSessionMetadata.cpp create mode 100644 Source/WebKit2/Shared/WebMediaSessionMetadata.h create mode 100644 Source/WebKit2/Shared/WebMemorySampler.cpp delete mode 100644 Source/WebKit2/Shared/WebNetworkInfo.h delete mode 100644 Source/WebKit2/Shared/WebOpenPanelParameters.cpp delete mode 100644 Source/WebKit2/Shared/WebOpenPanelParameters.h create mode 100644 Source/WebKit2/Shared/WebPreferencesDefinitions.h create mode 100644 Source/WebKit2/Shared/WebPreferencesKeys.cpp create mode 100644 Source/WebKit2/Shared/WebPreferencesKeys.h delete mode 100644 Source/WebKit2/Shared/WebResourceBuffer.cpp delete mode 100644 Source/WebKit2/Shared/WebResourceBuffer.h create mode 100644 Source/WebKit2/Shared/WebSQLiteDatabaseTracker.cpp create mode 100644 Source/WebKit2/Shared/WebSQLiteDatabaseTracker.h delete mode 100644 Source/WebKit2/Shared/WebSecurityOrigin.h delete mode 100644 Source/WebKit2/Shared/WebSerializedScriptValue.h create mode 100644 Source/WebKit2/Shared/WebUserContentControllerDataTypes.cpp create mode 100644 Source/WebKit2/Shared/WebUserContentControllerDataTypes.h delete mode 100644 Source/WebKit2/Shared/WebUserContentURLPattern.h create mode 100644 Source/WebKit2/Shared/WebsiteData/WebsiteData.cpp create mode 100644 Source/WebKit2/Shared/WebsiteData/WebsiteData.h create mode 100644 Source/WebKit2/Shared/WebsiteData/WebsiteDataFetchOption.h create mode 100644 Source/WebKit2/Shared/WebsiteData/WebsiteDataType.h create mode 100644 Source/WebKit2/Shared/WebsitePolicies.h delete mode 100644 Source/WebKit2/Shared/gtk/LayerTreeContextGtk.cpp create mode 100644 Source/WebKit2/Shared/gtk/WebContextMenuItemGtk.cpp create mode 100644 Source/WebKit2/Shared/gtk/WebContextMenuItemGtk.h create mode 100644 Source/WebKit2/Shared/gtk/WebKit2WaylandProtocol.xml create mode 100644 Source/WebKit2/Shared/gtk/WebSelectionData.cpp create mode 100644 Source/WebKit2/Shared/gtk/WebSelectionData.h create mode 100644 Source/WebKit2/Shared/linux/WebMemorySamplerLinux.cpp create mode 100644 Source/WebKit2/Shared/unix/ChildProcessMain.cpp create mode 100644 Source/WebKit2/Shared/unix/ChildProcessMain.h (limited to 'Source/WebKit2/Shared') diff --git a/Source/WebKit2/Shared/API/APIArray.cpp b/Source/WebKit2/Shared/API/APIArray.cpp new file mode 100644 index 000000000..9548ab724 --- /dev/null +++ b/Source/WebKit2/Shared/API/APIArray.cpp @@ -0,0 +1,85 @@ +/* + * 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 "APIArray.h" + +#include "APIString.h" + +namespace API { + +Ref Array::create() +{ + return create(Vector>()); +} + +Ref Array::create(Vector>&& elements) +{ + return adoptRef(*new Array(WTFMove(elements))); +} + +Ref Array::createStringArray(const Vector& strings) +{ + Vector> elements; + elements.reserveInitialCapacity(strings.size()); + + for (const auto& string : strings) + elements.uncheckedAppend(API::String::create(string)); + + return create(WTFMove(elements)); +} + +Vector Array::toStringVector() +{ + Vector patternsVector; + + size_t size = this->size(); + if (!size) + return patternsVector; + + patternsVector.reserveInitialCapacity(size); + for (const auto& entry : elementsOfType()) + patternsVector.uncheckedAppend(entry->string()); + return patternsVector; +} + +Ref Array::copy() +{ + size_t size = this->size(); + if (!size) + return Array::create(); + + Vector> elements; + elements.reserveInitialCapacity(size); + for (const auto& entry : this->elements()) + elements.uncheckedAppend(entry); + return Array::create(WTFMove(elements)); +} + +Array::~Array() +{ +} + +} // namespace API diff --git a/Source/WebKit2/Shared/API/APIArray.h b/Source/WebKit2/Shared/API/APIArray.h new file mode 100644 index 000000000..1fef06932 --- /dev/null +++ b/Source/WebKit2/Shared/API/APIArray.h @@ -0,0 +1,112 @@ +/* + * Copyright (C) 2010, 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 APIArray_h +#define APIArray_h + +#include "APIObject.h" +#include +#include +#include +#include + +namespace API { + +class Array final : public ObjectImpl { +private: + template + struct IsTypePredicate { + bool operator()(const RefPtr& object) const { return object->type() == T::APIType; } + }; + + template + struct GetObjectTransform { + const T* operator()(const RefPtr& object) const { return static_cast(object.get()); } + }; + + template + using ElementsOfTypeRange = WTF::IteratorRange, WTF::FilterIterator, Vector>::const_iterator>>>; + +public: + static Ref create(); + static Ref create(Vector>&&); + static Ref createStringArray(const Vector&); + Vector toStringVector(); + Ref copy(); + + virtual ~Array(); + + template + T* at(size_t i) const + { + if (!m_elements[i] || m_elements[i]->type() != T::APIType) + return nullptr; + + return static_cast(m_elements[i].get()); + } + + Object* at(size_t i) const { return m_elements[i].get(); } + size_t size() const { return m_elements.size(); } + + const Vector>& elements() const { return m_elements; } + Vector>& elements() { return m_elements; } + + template + ElementsOfTypeRange elementsOfType() const + { + return WTF::makeIteratorRange( + WTF::makeTransformIterator(GetObjectTransform(), WTF::makeFilterIterator(IsTypePredicate(), m_elements.begin(), m_elements.end())), + WTF::makeTransformIterator(GetObjectTransform(), WTF::makeFilterIterator(IsTypePredicate(), m_elements.end(), m_elements.end())) + ); + } + + template + unsigned removeAllMatching(const MatchFunction& matchFunction) + { + return m_elements.removeAllMatching(matchFunction); + } + + template + unsigned removeAllOfTypeMatching(const MatchFunction& matchFunction) + { + return m_elements.removeAllMatching([&] (const RefPtr& object) -> bool { + if (object->type() != T::APIType) + return false; + return matchFunction(static_pointer_cast(object)); + }); + } + +private: + explicit Array(Vector>&& elements) + : m_elements(WTFMove(elements)) + { + } + + Vector> m_elements; +}; + +} // namespace API + +#endif // APIArray_h diff --git a/Source/WebKit2/Shared/API/APIClient.h b/Source/WebKit2/Shared/API/APIClient.h new file mode 100644 index 000000000..2d2d89a5c --- /dev/null +++ b/Source/WebKit2/Shared/API/APIClient.h @@ -0,0 +1,85 @@ +/* + * 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 APIClient_h +#define APIClient_h + +#include +#include + +namespace API { + +template struct ClientTraits; + +template class Client { + typedef typename ClientTraits::Versions ClientVersions; + static const int latestClientVersion = std::tuple_size::value - 1; + typedef typename std::tuple_element::type LatestClientInterface; + + // Helper class that can return an std::array of element sizes in a tuple. + template struct InterfaceSizes; + template struct InterfaceSizes> { + static std::array sizes() + { + return { { sizeof(Interfaces)... } }; + } + }; + +public: + Client() + { +#if !ASSERT_DISABLED + auto interfaceSizes = InterfaceSizes::sizes(); + ASSERT(std::is_sorted(interfaceSizes.begin(), interfaceSizes.end())); +#endif + + initialize(nullptr); + } + + void initialize(const ClientInterface* client) + { + if (client && client->version == latestClientVersion) { + m_client = *reinterpret_cast(client); + return; + } + + memset(&m_client, 0, sizeof(m_client)); + + if (client && client->version < latestClientVersion) { + auto interfaceSizes = InterfaceSizes::sizes(); + + memcpy(&m_client, client, interfaceSizes[client->version]); + } + } + + const LatestClientInterface& client() const { return m_client; } + +protected: + LatestClientInterface m_client; +}; + +} // namespace API + +#endif // APIClient_h diff --git a/Source/WebKit2/Shared/API/APIData.cpp b/Source/WebKit2/Shared/API/APIData.cpp new file mode 100644 index 000000000..61343bd94 --- /dev/null +++ b/Source/WebKit2/Shared/API/APIData.cpp @@ -0,0 +1,49 @@ +/* + * 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 "APIData.h" + +#include "Decoder.h" +#include "Encoder.h" + +namespace API { + +void Data::encode(IPC::Encoder& encoder) const +{ + encoder << dataReference(); +} + +bool Data::decode(IPC::Decoder& decoder, RefPtr& result) +{ + IPC::DataReference dataReference; + if (!decoder.decode(dataReference)) + return false; + + result = create(dataReference.data(), dataReference.size()); + return true; +} + +} // namespace API diff --git a/Source/WebKit2/Shared/API/APIData.h b/Source/WebKit2/Shared/API/APIData.h new file mode 100644 index 000000000..066fa441f --- /dev/null +++ b/Source/WebKit2/Shared/API/APIData.h @@ -0,0 +1,110 @@ +/* + * 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 APIData_h +#define APIData_h + +#include "APIObject.h" +#include "DataReference.h" +#include +#include + +namespace IPC { +class Decoder; +class Encoder; +} + +OBJC_CLASS NSData; + +namespace API { + +class Data : public ObjectImpl { +public: + typedef void (*FreeDataFunction)(unsigned char*, const void* context); + + static Ref createWithoutCopying(const unsigned char* bytes, size_t size, FreeDataFunction freeDataFunction, const void* context) + { + return adoptRef(*new Data(bytes, size, freeDataFunction, context)); + } + + static Ref create(const unsigned char* bytes, size_t size) + { + unsigned char *copiedBytes = 0; + + if (size) { + copiedBytes = static_cast(fastMalloc(size)); + memcpy(copiedBytes, bytes, size); + } + + return createWithoutCopying(copiedBytes, size, fastFreeBytes, 0); + } + + static Ref create(const Vector& buffer) + { + return create(buffer.data(), buffer.size()); + } + +#if PLATFORM(COCOA) + static Ref createWithoutCopying(RetainPtr); +#endif + + ~Data() + { + m_freeDataFunction(const_cast(m_bytes), m_context); + } + + const unsigned char* bytes() const { return m_bytes; } + size_t size() const { return m_size; } + + IPC::DataReference dataReference() const { return IPC::DataReference(m_bytes, m_size); } + + void encode(IPC::Encoder&) const; + static bool decode(IPC::Decoder&, RefPtr&); + +private: + Data(const unsigned char* bytes, size_t size, FreeDataFunction freeDataFunction, const void* context) + : m_bytes(bytes) + , m_size(size) + , m_freeDataFunction(freeDataFunction) + , m_context(context) + { + } + + static void fastFreeBytes(unsigned char* bytes, const void*) + { + if (bytes) + fastFree(static_cast(bytes)); + } + + const unsigned char* m_bytes; + size_t m_size; + + FreeDataFunction m_freeDataFunction; + const void* m_context; +}; + +} // namespace API + +#endif // APIData_h diff --git a/Source/WebKit2/Shared/API/APIDictionary.cpp b/Source/WebKit2/Shared/API/APIDictionary.cpp new file mode 100644 index 000000000..894e98dd1 --- /dev/null +++ b/Source/WebKit2/Shared/API/APIDictionary.cpp @@ -0,0 +1,84 @@ +/* + * 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 "APIDictionary.h" + +#include "APIArray.h" +#include "APIString.h" + +namespace API { + +Ref Dictionary::create() +{ + return create({ }); +} + +Ref Dictionary::create(MapType map) +{ + return adoptRef(*new Dictionary(WTFMove(map))); +} + +Dictionary::Dictionary(MapType map) + : m_map(WTFMove(map)) +{ +} + +Dictionary::~Dictionary() +{ +} + +Ref Dictionary::keys() const +{ + if (m_map.isEmpty()) + return API::Array::create(); + + Vector> keys; + keys.reserveInitialCapacity(m_map.size()); + + for (const auto& key : m_map.keys()) + keys.uncheckedAppend(API::String::create(key)); + + return API::Array::create(WTFMove(keys)); +} + +bool Dictionary::add(const WTF::String& key, PassRefPtr item) +{ + MapType::AddResult result = m_map.add(key, item); + return result.isNewEntry; +} + +bool Dictionary::set(const WTF::String& key, PassRefPtr 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/API/APIDictionary.h b/Source/WebKit2/Shared/API/APIDictionary.h new file mode 100644 index 000000000..50599129a --- /dev/null +++ b/Source/WebKit2/Shared/API/APIDictionary.h @@ -0,0 +1,90 @@ +/* + * 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 APIDictionary_h +#define APIDictionary_h + +#include "APIObject.h" +#include +#include +#include + +namespace API { + +class Array; + +class Dictionary final : public ObjectImpl { +public: + typedef HashMap> MapType; + + static Ref create(); + static Ref create(MapType); + + virtual ~Dictionary(); + + template + T* get(const WTF::String& key) const + { + RefPtr item = m_map.get(key); + if (!item) + return 0; + + if (item->type() != T::APIType) + return 0; + + return static_cast(item.get()); + } + + Object* get(const WTF::String& key) const + { + return m_map.get(key); + } + + Object* get(const WTF::String& key, bool& exists) const + { + auto it = m_map.find(key); + exists = it != m_map.end(); + return it->value.get(); + } + + Ref keys() const; + + bool add(const WTF::String& key, PassRefPtr); + bool set(const WTF::String& key, PassRefPtr); + void remove(const WTF::String& key); + + size_t size() const { return m_map.size(); } + + const MapType& map() const { return m_map; } + +protected: + explicit Dictionary(MapType); + + MapType m_map; +}; + +} // namespace API + +#endif // APIDictionary_h diff --git a/Source/WebKit2/Shared/API/APIError.cpp b/Source/WebKit2/Shared/API/APIError.cpp new file mode 100644 index 000000000..839fb0f14 --- /dev/null +++ b/Source/WebKit2/Shared/API/APIError.cpp @@ -0,0 +1,56 @@ +/* + * 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 "APIError.h" + +#include "WebCoreArgumentCoders.h" +#include +#include + +namespace API { + +const WTF::String& Error::webKitErrorDomain() +{ + static NeverDestroyed webKitErrorDomainString(ASCIILiteral("WebKitErrorDomain")); + return webKitErrorDomainString; +} + +void Error::encode(IPC::Encoder& encoder) const +{ + encoder << platformError(); +} + +bool Error::decode(IPC::Decoder& decoder, RefPtr& result) +{ + WebCore::ResourceError error; + if (!decoder.decode(error)) + return false; + + result = create(error); + return true; +} + +} // namespace WebKit diff --git a/Source/WebKit2/Shared/API/APIError.h b/Source/WebKit2/Shared/API/APIError.h new file mode 100644 index 000000000..8c36027df --- /dev/null +++ b/Source/WebKit2/Shared/API/APIError.h @@ -0,0 +1,78 @@ +/* + * 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 APIError_h +#define APIError_h + +#include "APIObject.h" +#include + +namespace IPC { +class Decoder; +class Encoder; +} + +namespace API { + +class Error : public ObjectImpl { +public: + static Ref create() + { + return adoptRef(*new Error); + } + + static Ref create(const WebCore::ResourceError& error) + { + return adoptRef(*new Error(error)); + } + + static const WTF::String& webKitErrorDomain(); + + const WTF::String& domain() const { return m_platformError.domain(); } + int errorCode() const { return m_platformError.errorCode(); } + const WTF::String& failingURL() const { return m_platformError.failingURL(); } + const WTF::String& localizedDescription() const { return m_platformError.localizedDescription(); } + + const WebCore::ResourceError& platformError() const { return m_platformError; } + + void encode(IPC::Encoder&) const; + static bool decode(IPC::Decoder&, RefPtr&); + +private: + Error() + { + } + + Error(const WebCore::ResourceError& error) + : m_platformError(error) + { + } + + WebCore::ResourceError m_platformError; +}; + +} // namespace API + +#endif // APIError_h 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::create(uint64_t frameID) +{ + return adoptRef(*new FrameHandle(frameID, false)); +} + +Ref 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& 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/API/APIFrameHandle.h b/Source/WebKit2/Shared/API/APIFrameHandle.h new file mode 100644 index 000000000..b10e808a4 --- /dev/null +++ b/Source/WebKit2/Shared/API/APIFrameHandle.h @@ -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. 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 APIFrameHandle_h +#define APIFrameHandle_h + +#include "APIObject.h" +#include + +namespace IPC { +class Decoder; +class Encoder; +} + +namespace API { + +class FrameHandle : public ObjectImpl { +public: + static Ref create(uint64_t frameID); + static Ref 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; } + + void encode(IPC::Encoder&) const; + static bool decode(IPC::Decoder&, RefPtr&); + +private: + const uint64_t m_frameID; + const bool m_isAutoconverting; +}; + +} // namespace API + +#endif // APIFrameHandle_h diff --git a/Source/WebKit2/Shared/API/APIGeometry.cpp b/Source/WebKit2/Shared/API/APIGeometry.cpp new file mode 100644 index 000000000..3d8cb61a3 --- /dev/null +++ b/Source/WebKit2/Shared/API/APIGeometry.cpp @@ -0,0 +1,96 @@ +/* + * 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 "APIGeometry.h" + +#include "Decoder.h" +#include "Encoder.h" + +namespace API { + +void Point::encode(IPC::Encoder& encoder) const +{ + encoder << m_point.x; + encoder << m_point.y; +} + +bool Point::decode(IPC::Decoder& decoder, RefPtr& result) +{ + WKPoint point; + if (!decoder.decode(point.x)) + return false; + if (!decoder.decode(point.y)) + return false; + + result = Point::create(point); + return true; +} + + +void Size::encode(IPC::Encoder& encoder) const +{ + encoder << m_size.width; + encoder << m_size.height; +} + +bool Size::decode(IPC::Decoder& decoder, RefPtr& result) +{ + WKSize size; + if (!decoder.decode(size.width)) + return false; + if (!decoder.decode(size.height)) + return false; + + result = Size::create(size); + return true; +} + + +void Rect::encode(IPC::Encoder& encoder) const +{ + encoder << m_rect.origin.x; + encoder << m_rect.origin.y; + encoder << m_rect.size.width; + encoder << m_rect.size.height; +} + +bool Rect::decode(IPC::Decoder& decoder, RefPtr& result) +{ + WKRect rect; + if (!decoder.decode(rect.origin.x)) + return false; + if (!decoder.decode(rect.origin.y)) + return false; + if (!decoder.decode(rect.size.width)) + return false; + if (!decoder.decode(rect.size.height)) + return false; + + result = Rect::create(rect); + return true; +} + +} // namespace API diff --git a/Source/WebKit2/Shared/API/APIGeometry.h b/Source/WebKit2/Shared/API/APIGeometry.h new file mode 100644 index 000000000..0ff94cca9 --- /dev/null +++ b/Source/WebKit2/Shared/API/APIGeometry.h @@ -0,0 +1,104 @@ +/* + * 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 APIGeometry_h +#define APIGeometry_h + +#include "APIObject.h" +#include "WKGeometry.h" +#include + +namespace IPC { +class Decoder; +class Encoder; +} + +namespace API { + +class Size : public API::ObjectImpl { +public: + static Ref create(const WKSize& size) + { + return adoptRef(*new Size(size)); + } + + const WKSize& size() const { return m_size; } + + void encode(IPC::Encoder&) const; + static bool decode(IPC::Decoder&, RefPtr&); + +private: + explicit Size(const WKSize& size) + : m_size(size) + { + } + + WKSize m_size; +}; + +class Point : public API::ObjectImpl { +public: + static Ref create(const WKPoint& point) + { + return adoptRef(*new Point(point)); + } + + const WKPoint& point() const { return m_point; } + + void encode(IPC::Encoder&) const; + static bool decode(IPC::Decoder&, RefPtr&); + +private: + explicit Point(const WKPoint& point) + : m_point(point) + { } + + WKPoint m_point; +}; + +class Rect : public API::ObjectImpl { +public: + static Ref create(const WKRect& rect) + { + return adoptRef(*new Rect(rect)); + } + + const WKRect& rect() const { return m_rect; } + + void encode(IPC::Encoder&) const; + static bool decode(IPC::Decoder&, RefPtr&); + +private: + explicit Rect(const WKRect& rect) + : m_rect(rect) + { + } + + WKRect m_rect; +}; + +} // namespace API + +#endif // APIGeometry_h diff --git a/Source/WebKit2/Shared/API/APINumber.h b/Source/WebKit2/Shared/API/APINumber.h new file mode 100644 index 000000000..fe5734981 --- /dev/null +++ b/Source/WebKit2/Shared/API/APINumber.h @@ -0,0 +1,75 @@ +/* + * 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 APINumber_h +#define APINumber_h + +#include "APIObject.h" +#include "Decoder.h" +#include "Encoder.h" + +namespace API { + +template +class Number : public ObjectImpl { +public: + static Ref create(NumberType value) + { + return adoptRef(*new Number(value)); + } + + NumberType value() const { return m_value; } + + void encode(IPC::Encoder& encoder) const + { + encoder << m_value; + } + + static bool decode(IPC::Decoder& decoder, RefPtr& result) + { + NumberType value; + if (!decoder.decode(value)) + return false; + + result = Number::create(value); + return true; + } + +private: + explicit Number(NumberType value) + : m_value(value) + { + } + + const NumberType m_value; +}; + +typedef Number Boolean; +typedef Number Double; +typedef Number UInt64; + +} // namespace API + +#endif // APINumber_h diff --git a/Source/WebKit2/Shared/API/APIObject.cpp b/Source/WebKit2/Shared/API/APIObject.cpp new file mode 100644 index 000000000..26e38f008 --- /dev/null +++ b/Source/WebKit2/Shared/API/APIObject.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2011 Motorola Mobility, 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: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 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. + * + * Neither the name of Motorola Mobility, Inc. nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT HOLDER 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 "APIObject.h" + +#include "WebKit2Initialize.h" + +namespace API { + +Object::Object() +{ + WebKit::InitializeWebKit2(); +} + +} // namespace WebKit diff --git a/Source/WebKit2/Shared/API/APIObject.h b/Source/WebKit2/Shared/API/APIObject.h new file mode 100644 index 000000000..f2cb0540a --- /dev/null +++ b/Source/WebKit2/Shared/API/APIObject.h @@ -0,0 +1,276 @@ +/* + * 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 + * 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 APIObject_h +#define APIObject_h + +#include +#include +#include +#include + +#if PLATFORM(COCOA) +#include "WKFoundation.h" +#ifdef __OBJC__ +#include "WKObject.h" +#endif +#endif + +#define DELEGATE_REF_COUNTING_TO_COCOA (PLATFORM(COCOA) && WK_API_ENABLED) + +#if DELEGATE_REF_COUNTING_TO_COCOA +OBJC_CLASS NSObject; +#endif + +namespace API { + +class Object +#if !DELEGATE_REF_COUNTING_TO_COCOA + : public ThreadSafeRefCounted +#endif +{ +public: + enum class Type { + // Base types + Null = 0, + Array, + AuthenticationChallenge, + AuthenticationDecisionListener, + CertificateInfo, + Connection, + ContextMenuItem, + Credential, + Data, + Dictionary, + Error, + FrameHandle, + Image, + PageGroupData, + PageHandle, + PageGroupHandle, + ProtectionSpace, + RenderLayer, + RenderObject, + SecurityOrigin, + SessionState, + SerializedScriptValue, + String, + URL, + URLRequest, + URLResponse, + UserContentURLPattern, + UserScript, + UserStyleSheet, + WebArchive, + WebArchiveResource, + + // Base numeric types + Boolean, + Double, + UInt64, + + // Geometry types + Point, + Size, + Rect, + + // UIProcess types + ApplicationCacheManager, + AutomationSession, + BackForwardList, + BackForwardListItem, + CacheManager, + ColorPickerResultListener, + ContextMenuListener, + CookieManager, + Download, + ExperimentalFeature, + FormSubmissionListener, + Frame, + FrameInfo, + FramePolicyListener, + FullScreenManager, + GeolocationManager, + GeolocationPermissionRequest, + HitTestResult, + GeolocationPosition, + GrammarDetail, + IconDatabase, + Inspector, + KeyValueStorageManager, + MediaCacheManager, + Navigation, + NavigationAction, + NavigationData, + NavigationResponse, + Notification, + NotificationManager, + NotificationPermissionRequest, + OpenPanelParameters, + OpenPanelResultListener, + OriginDataManager, + Page, + PageConfiguration, + PageGroup, + ProcessPool, + ProcessPoolConfiguration, + PluginSiteDataManager, + Preferences, + 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, + BundleNavigationAction, + BundleNodeHandle, + BundlePage, + BundlePageBanner, + BundlePageGroup, + BundlePageOverlay, + BundleRangeHandle, + BundleScriptWorld, + + // Platform specific + EditCommandProxy, + ObjCObjectGraph, + View, +#if USE(SOUP) + SoupRequestManager, + SoupCustomProtocolRequestManager, +#endif + }; + + virtual ~Object() + { + } + + virtual Type type() const = 0; + +#if DELEGATE_REF_COUNTING_TO_COCOA +#ifdef __OBJC__ + template + static void constructInWrapper(NSObject *wrapper, Args&&... args) + { + Object* object = new (&wrapper._apiObject) T(std::forward(args)...); + object->m_wrapper = wrapper; + } +#endif + + NSObject *wrapper() { return m_wrapper; } + + void ref(); + void deref(); +#endif // DELEGATE_REF_COUNTING_TO_COCOA + + static void* wrap(API::Object*); + static API::Object* unwrap(void*); + +protected: + Object(); + +#if DELEGATE_REF_COUNTING_TO_COCOA + static void* newObject(size_t, Type); + +private: + // Derived classes must override operator new and call newObject(). + void* operator new(size_t) = delete; + + NSObject *m_wrapper; +#endif // DELEGATE_REF_COUNTING_TO_COCOA +}; + +template +class ObjectImpl : public Object { +public: + static const Type APIType = ArgumentType; + + virtual ~ObjectImpl() + { + } + +protected: + friend class Object; + + ObjectImpl() + { + } + + 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, void* value) { return value; } +#endif +}; + +#if !DELEGATE_REF_COUNTING_TO_COCOA +inline void* Object::wrap(API::Object* object) +{ + return static_cast(object); +} + +inline API::Object* Object::unwrap(void* object) +{ + return static_cast(object); +} +#endif + +} // namespace Object + +#undef DELEGATE_REF_COUNTING_TO_COCOA + +#endif // APIObject_h 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::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& result) +{ + WebKit::WebPageGroupData webPageGroupData; + if (!decoder.decode(webPageGroupData)) + return false; + + result = create(WTFMove(webPageGroupData)); + return true; +} + +} diff --git a/Source/WebKit2/Shared/API/APIPageGroupHandle.h b/Source/WebKit2/Shared/API/APIPageGroupHandle.h new file mode 100644 index 000000000..eaca5dfbd --- /dev/null +++ b/Source/WebKit2/Shared/API/APIPageGroupHandle.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 APIPageGroupHandle_h +#define APIPageGroupHandle_h + +#include "APIObject.h" +#include "WebPageGroupData.h" +#include + +namespace IPC { +class Decoder; +class Encoder; +} + +namespace API { + +class PageGroupHandle : public ObjectImpl { +public: + static Ref create(WebKit::WebPageGroupData&&); + virtual ~PageGroupHandle(); + + const WebKit::WebPageGroupData& webPageGroupData() const { return m_webPageGroupData; } + + void encode(IPC::Encoder&) const; + static bool decode(IPC::Decoder&, RefPtr&); + +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::create(uint64_t pageID) +{ + return adoptRef(*new PageHandle(pageID, false)); +} + +Ref 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& 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/API/APIPageHandle.h b/Source/WebKit2/Shared/API/APIPageHandle.h new file mode 100644 index 000000000..f30fafbdc --- /dev/null +++ b/Source/WebKit2/Shared/API/APIPageHandle.h @@ -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. 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 APIPageHandle_h +#define APIPageHandle_h + +#include "APIObject.h" +#include + +namespace IPC { +class Decoder; +class Encoder; +} + +namespace API { + +class PageHandle : public ObjectImpl { +public: + static Ref create(uint64_t pageID); + static Ref 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&); + +private: + explicit PageHandle(uint64_t pageID, bool isAutoconverting); + + const uint64_t m_pageID; + const bool m_isAutoconverting; +}; + +} // namespace API + +#endif // APIPageHandle_h 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 +#include + +namespace API { + +class SecurityOrigin : public API::ObjectImpl { +public: + static RefPtr createFromString(const WTF::String& string) + { + return create(WebCore::SecurityOrigin::createFromString(string)); + } + + static RefPtr create(const WTF::String& protocol, const WTF::String& host, std::optional port) + { + return create(WebCore::SecurityOrigin::create(protocol, host, port)); + } + + static RefPtr create(const WebCore::SecurityOrigin& securityOrigin) + { + return adoptRef(new SecurityOrigin(securityOrigin)); + } + + WebCore::SecurityOrigin& securityOrigin() const { return *m_securityOrigin; } + +private: + SecurityOrigin(PassRefPtr securityOrigin) + : m_securityOrigin(securityOrigin) + { + } + + SecurityOrigin(const WebCore::SecurityOrigin& securityOrigin) + : m_securityOrigin(securityOrigin.isolatedCopy()) + { + } + + RefPtr m_securityOrigin; +}; + +} diff --git a/Source/WebKit2/Shared/API/APISerializedScriptValue.h b/Source/WebKit2/Shared/API/APISerializedScriptValue.h new file mode 100644 index 000000000..6569d4d4c --- /dev/null +++ b/Source/WebKit2/Shared/API/APISerializedScriptValue.h @@ -0,0 +1,81 @@ +/* + * 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 APISerializedScriptValue_h +#define APISerializedScriptValue_h + +#include "APIObject.h" + +#include "DataReference.h" +#include +#include + +namespace API { + +class SerializedScriptValue : public API::ObjectImpl { +public: + static Ref create(PassRefPtr serializedValue) + { + return adoptRef(*new SerializedScriptValue(serializedValue)); + } + + static RefPtr create(JSContextRef context, JSValueRef value, JSValueRef* exception) + { + RefPtr serializedValue = WebCore::SerializedScriptValue::create(context, value, exception); + if (!serializedValue) + return nullptr; + return adoptRef(*new SerializedScriptValue(serializedValue.get())); + } + + static Ref adopt(Vector&& 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(); } + + WebCore::SerializedScriptValue* internalRepresentation() { return m_serializedScriptValue.get(); } + +private: + explicit SerializedScriptValue(PassRefPtr serializedScriptValue) + : m_serializedScriptValue(serializedScriptValue) + { + } + + RefPtr m_serializedScriptValue; +}; + +} + +#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 +#include +#include +#include + +namespace API { + +class String final : public ObjectImpl { +public: + static Ref createNull() + { + return adoptRef(*new String); + } + + static Ref create(WTF::String&& string) + { + return adoptRef(*new String(string.isNull() ? WTF::String(StringImpl::empty()) : string.isolatedCopy())); + } + + static Ref 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/API/APIURL.h b/Source/WebKit2/Shared/API/APIURL.h new file mode 100644 index 000000000..7e0fae174 --- /dev/null +++ b/Source/WebKit2/Shared/API/APIURL.h @@ -0,0 +1,134 @@ +/* + * 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 WebURL_h +#define WebURL_h + +#include "APIObject.h" +#include "WebCoreArgumentCoders.h" +#include +#include +#include + +namespace API { + +class URL : public ObjectImpl { +public: + static Ref create(const WTF::String& string) + { + return adoptRef(*new URL(string)); + } + + static Ref create(const URL* baseURL, const WTF::String& relativeURL) + { + ASSERT(baseURL); + baseURL->parseURLIfNecessary(); + auto absoluteURL = std::make_unique(*baseURL->m_parsedURL.get(), relativeURL); + const WTF::String& absoluteURLString = absoluteURL->string(); + + return adoptRef(*new URL(WTFMove(absoluteURL), absoluteURLString)); + } + + bool isNull() const { return m_string.isNull(); } + bool isEmpty() const { return m_string.isEmpty(); } + + 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(); + return m_parsedURL->isValid() ? m_parsedURL->host() : WTF::String(); + } + + WTF::String protocol() const + { + parseURLIfNecessary(); + return m_parsedURL->isValid() ? m_parsedURL->protocol().toString() : WTF::String(); + } + + WTF::String path() const + { + parseURLIfNecessary(); + return m_parsedURL->isValid() ? m_parsedURL->path() : WTF::String(); + } + + WTF::String lastPathComponent() const + { + parseURLIfNecessary(); + return m_parsedURL->isValid() ? m_parsedURL->lastPathComponent() : WTF::String(); + } + + void encode(IPC::Encoder& encoder) const + { + encoder << m_string; + } + + static bool decode(IPC::Decoder& decoder, RefPtr& result) + { + WTF::String string; + if (!decoder.decode(string)) + return false; + + result = create(string); + return true; + } + +private: + URL(const WTF::String& string) + : m_string(string) + { + } + + URL(std::unique_ptr parsedURL, const WTF::String& string) + : m_string(string) + , m_parsedURL(WTFMove(parsedURL)) + { + } + + const WebCore::URL& url() const + { + parseURLIfNecessary(); + return *m_parsedURL; + } + + void parseURLIfNecessary() const + { + if (m_parsedURL) + return; + m_parsedURL = std::make_unique(WebCore::URL(), m_string); + } + + WTF::String m_string; + mutable std::unique_ptr m_parsedURL; +}; + +} // namespace WebKit + +#endif // URL_h diff --git a/Source/WebKit2/Shared/API/APIURLRequest.cpp b/Source/WebKit2/Shared/API/APIURLRequest.cpp new file mode 100644 index 000000000..ac904d409 --- /dev/null +++ b/Source/WebKit2/Shared/API/APIURLRequest.cpp @@ -0,0 +1,71 @@ +/* + * 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 "APIURLRequest.h" + +#include "WebCoreArgumentCoders.h" +#include "WebProcessPool.h" + +using namespace WebCore; +using namespace WebKit; + +namespace API { + +URLRequest::URLRequest(const ResourceRequest& request) + : m_request(request) +{ +} + +double URLRequest::defaultTimeoutInterval() +{ + return ResourceRequest::defaultTimeoutInterval(); +} + +// FIXME: This function should really be on WebProcessPool or WebPageProxy. +void URLRequest::setDefaultTimeoutInterval(double timeoutInterval) +{ + ResourceRequest::setDefaultTimeoutInterval(timeoutInterval); + + for (auto* processPool : WebProcessPool::allProcessPools()) + processPool->setDefaultRequestTimeoutInterval(timeoutInterval); +} + +void URLRequest::encode(IPC::Encoder& encoder) const +{ + encoder << resourceRequest(); +} + +bool URLRequest::decode(IPC::Decoder& decoder, RefPtr& result) +{ + ResourceRequest request; + if (!decoder.decode(request)) + return false; + + result = create(request); + return true; +} + +} // namespace API diff --git a/Source/WebKit2/Shared/API/APIURLRequest.h b/Source/WebKit2/Shared/API/APIURLRequest.h new file mode 100644 index 000000000..2a01602de --- /dev/null +++ b/Source/WebKit2/Shared/API/APIURLRequest.h @@ -0,0 +1,63 @@ +/* + * 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 APIURLRequest_h +#define APIURLRequest_h + +#include "APIObject.h" +#include +#include + +namespace IPC { +class Decoder; +class Encoder; +} + +namespace API { + +class URLRequest : public ObjectImpl { +public: + static Ref create(const WebCore::ResourceRequest& request) + { + return adoptRef(*new URLRequest(request)); + } + + const WebCore::ResourceRequest& resourceRequest() const { return m_request; } + + static double defaultTimeoutInterval(); // May return 0 when using platform default. + static void setDefaultTimeoutInterval(double); + + void encode(IPC::Encoder&) const; + static bool decode(IPC::Decoder&, RefPtr&); + +private: + explicit URLRequest(const WebCore::ResourceRequest&); + + WebCore::ResourceRequest m_request; +}; + +} // namespace API + +#endif // APIURLRequest_h diff --git a/Source/WebKit2/Shared/API/APIURLResponse.cpp b/Source/WebKit2/Shared/API/APIURLResponse.cpp new file mode 100644 index 000000000..1d93b62d3 --- /dev/null +++ b/Source/WebKit2/Shared/API/APIURLResponse.cpp @@ -0,0 +1,55 @@ +/* + * 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 "APIURLResponse.h" + +#include "WebCoreArgumentCoders.h" + +using namespace WebCore; + +namespace API { + +URLResponse::URLResponse(const WebCore::ResourceResponse& response) + : m_response(response) +{ +} + +void URLResponse::encode(IPC::Encoder& encoder) const +{ + encoder << resourceResponse(); +} + +bool URLResponse::decode(IPC::Decoder& decoder, RefPtr& result) +{ + ResourceResponse response; + if (!decoder.decode(response)) + return false; + + result = create(response); + return true; +} + +} // namespace API diff --git a/Source/WebKit2/Shared/API/APIURLResponse.h b/Source/WebKit2/Shared/API/APIURLResponse.h new file mode 100644 index 000000000..125e03711 --- /dev/null +++ b/Source/WebKit2/Shared/API/APIURLResponse.h @@ -0,0 +1,60 @@ +/* + * 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 APIURLResponse_h +#define APIURLResponse_h + +#include "APIObject.h" +#include +#include + +namespace IPC { +class Decoder; +class Encoder; +} + +namespace API { + +class URLResponse : public ObjectImpl { +public: + static Ref create(const WebCore::ResourceResponse& response) + { + return adoptRef(*new URLResponse(response)); + } + + const WebCore::ResourceResponse& resourceResponse() const { return m_response; } + + void encode(IPC::Encoder&) const; + static bool decode(IPC::Decoder&, RefPtr&); + +private: + explicit URLResponse(const WebCore::ResourceResponse&); + + WebCore::ResourceResponse m_response; +}; + +} // namespace API + +#endif // APIURLResponse_h diff --git a/Source/WebKit2/Shared/API/APIUserContentURLPattern.h b/Source/WebKit2/Shared/API/APIUserContentURLPattern.h new file mode 100644 index 000000000..aff461310 --- /dev/null +++ b/Source/WebKit2/Shared/API/APIUserContentURLPattern.h @@ -0,0 +1,64 @@ +/* + * 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 APIUserContentURLPattern_h +#define APIUserContentURLPattern_h + +#include "APIObject.h" + +#include +#include + +namespace API { + +class UserContentURLPattern : public API::ObjectImpl { +public: + static Ref create(const WTF::String& pattern) + { + return adoptRef(*new UserContentURLPattern(pattern)); + } + + 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 WTF::String& url) const { return m_pattern.matches(WebCore::URL(WebCore::ParsedURLString, url)); } + bool matchesSubdomains() const { return m_pattern.matchSubdomains(); } + + const WTF::String& patternString() const { return m_patternString; } + +private: + explicit UserContentURLPattern(const WTF::String& pattern) + : m_pattern(WebCore::UserContentURLPattern(pattern)) + , m_patternString(pattern) + { + } + + WebCore::UserContentURLPattern m_pattern; + WTF::String m_patternString; +}; + +} + +#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 + +#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/API/c/WKActionMenuTypes.h b/Source/WebKit2/Shared/API/c/WKActionMenuTypes.h new file mode 100644 index 000000000..4769c390d --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKActionMenuTypes.h @@ -0,0 +1,55 @@ +/* + * 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 WKActionMenuTypes_h +#define WKActionMenuTypes_h + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +// 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 /* 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(static_cast(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(static_cast(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 +#include #include 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 +#include #include #if defined(BUILDING_GTK__) -#include +#include #endif -#if defined(WTF_USE_SOUP) -#include -#endif - -#if defined(BUILDING_EFL__) -#include -#endif - -#if defined(__APPLE__) -#include +#if defined(__APPLE__) && !defined(BUILDING_GTK__) +#include #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 +#include #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 +#include #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 -#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 -#include +#include +#include #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 +#include #include 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/WKDiagnosticLoggingResultType.h b/Source/WebKit2/Shared/API/c/WKDiagnosticLoggingResultType.h new file mode 100644 index 000000000..581c74f96 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKDiagnosticLoggingResultType.h @@ -0,0 +1,45 @@ +/* + * 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 + * 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 WKDiagnosticLoggingResultType_h +#define WKDiagnosticLoggingResultType_h + +#ifdef __cplusplus +extern "C" { +#endif + +enum { + kWKDiagnosticLoggingResultPass = 0, + kWKDiagnosticLoggingResultFail = 1, + kWKDiagnosticLoggingResultNoop = 2, +}; +typedef uint32_t WKDiagnosticLoggingResultType; + +#ifdef __cplusplus +} +#endif + +#endif /* WKDiagnosticLoggingResultType_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 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 +#include #include diff --git a/Source/WebKit2/Shared/API/c/WKError.cpp b/Source/WebKit2/Shared/API/c/WKError.cpp deleted file mode 100644 index 315f43e9f..000000000 --- a/Source/WebKit2/Shared/API/c/WKError.cpp +++ /dev/null @@ -1,62 +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 "WKError.h" - -#include "APIError.h" -#include "WKAPICast.h" - -using namespace WebKit; - -WKTypeID WKErrorGetTypeID() -{ - return toAPI(API::Error::APIType); -} - -WKStringRef WKErrorCopyWKErrorDomain() -{ - return toCopiedAPI(API::Error::webKitErrorDomain()); -} - -WKStringRef WKErrorCopyDomain(WKErrorRef errorRef) -{ - return toCopiedAPI(toImpl(errorRef)->domain()); -} - -int WKErrorGetErrorCode(WKErrorRef errorRef) -{ - return toImpl(errorRef)->errorCode(); -} - -WKURLRef WKErrorCopyFailingURL(WKErrorRef errorRef) -{ - return toCopiedURLAPI(toImpl(errorRef)->failingURL()); -} - -WKStringRef WKErrorCopyLocalizedDescription(WKErrorRef errorRef) -{ - return toCopiedAPI(toImpl(errorRef)->localizedDescription()); -} diff --git a/Source/WebKit2/Shared/API/c/WKError.h b/Source/WebKit2/Shared/API/c/WKError.h deleted file mode 100644 index b099b732c..000000000 --- a/Source/WebKit2/Shared/API/c/WKError.h +++ /dev/null @@ -1,63 +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 WKError_h -#define WKError_h - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -enum { - kWKErrorCodeCannotShowMIMEType = 100, - kWKErrorCodeCannotShowURL = 101, - kWKErrorCodeFrameLoadInterruptedByPolicyChange = 102, - kWKErrorCodeCannotUseRestrictedPort = 103, - kWKErrorCodeCannotFindPlugIn = 200, - kWKErrorCodeCannotLoadPlugIn = 201, - kWKErrorCodeJavaUnavailable = 202, - kWKErrorCodePlugInCancelledConnection = 203, - kWKErrorCodePlugInWillHandleLoad = 204, - kWKErrorCodeInsecurePlugInVersion = 205, - kWKErrorInternal = 300, -}; -typedef uint32_t WKErrorCode; - -WK_EXPORT WKTypeID WKErrorGetTypeID(); - -WK_EXPORT WKStringRef WKErrorCopyWKErrorDomain(); - -WK_EXPORT WKStringRef WKErrorCopyDomain(WKErrorRef error); -WK_EXPORT int WKErrorGetErrorCode(WKErrorRef error); -WK_EXPORT WKURLRef WKErrorCopyFailingURL(WKErrorRef error); -WK_EXPORT WKStringRef WKErrorCopyLocalizedDescription(WKErrorRef error); - -#ifdef __cplusplus -} -#endif - -#endif // WKError_h diff --git a/Source/WebKit2/Shared/API/c/WKErrorRef.cpp b/Source/WebKit2/Shared/API/c/WKErrorRef.cpp new file mode 100644 index 000000000..c1e75eb00 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKErrorRef.cpp @@ -0,0 +1,62 @@ +/* + * 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 "WKErrorRef.h" + +#include "APIError.h" +#include "WKAPICast.h" + +using namespace WebKit; + +WKTypeID WKErrorGetTypeID() +{ + return toAPI(API::Error::APIType); +} + +WKStringRef WKErrorCopyWKErrorDomain() +{ + return toCopiedAPI(API::Error::webKitErrorDomain()); +} + +WKStringRef WKErrorCopyDomain(WKErrorRef errorRef) +{ + return toCopiedAPI(toImpl(errorRef)->domain()); +} + +int WKErrorGetErrorCode(WKErrorRef errorRef) +{ + return toImpl(errorRef)->errorCode(); +} + +WKURLRef WKErrorCopyFailingURL(WKErrorRef errorRef) +{ + return toCopiedURLAPI(toImpl(errorRef)->failingURL()); +} + +WKStringRef WKErrorCopyLocalizedDescription(WKErrorRef errorRef) +{ + return toCopiedAPI(toImpl(errorRef)->localizedDescription()); +} diff --git a/Source/WebKit2/Shared/API/c/WKErrorRef.h b/Source/WebKit2/Shared/API/c/WKErrorRef.h new file mode 100644 index 000000000..0d76384d3 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKErrorRef.h @@ -0,0 +1,64 @@ +/* + * 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. + */ + +#ifndef WKErrorRef_h +#define WKErrorRef_h + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +enum { + kWKErrorCodeCannotShowMIMEType = 100, + kWKErrorCodeCannotShowURL = 101, + kWKErrorCodeFrameLoadInterruptedByPolicyChange = 102, + kWKErrorCodeCannotUseRestrictedPort = 103, + kWKErrorCodeFrameLoadBlockedByContentBlocker = 104, + kWKErrorCodeFrameLoadBlockedByContentFilter = 105, + kWKErrorCodeCannotFindPlugIn = 200, + kWKErrorCodeCannotLoadPlugIn = 201, + kWKErrorCodeJavaUnavailable = 202, + kWKErrorCodePlugInCancelledConnection = 203, + kWKErrorCodePlugInWillHandleLoad = 204, + kWKErrorCodeInsecurePlugInVersion = 205, + kWKErrorInternal = 300, +}; + +WK_EXPORT WKTypeID WKErrorGetTypeID(); + +WK_EXPORT WKStringRef WKErrorCopyWKErrorDomain(); + +WK_EXPORT WKStringRef WKErrorCopyDomain(WKErrorRef error); +WK_EXPORT int WKErrorGetErrorCode(WKErrorRef error); +WK_EXPORT WKURLRef WKErrorCopyFailingURL(WKErrorRef error); +WK_EXPORT WKStringRef WKErrorCopyLocalizedDescription(WKErrorRef error); + +#ifdef __cplusplus +} +#endif + +#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 +#include #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 +#include #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::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 -#include +#include +#include #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 + +#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(toAPI(API::Array::create().leakRef())); + return const_cast(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 +#include #include #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 dictionary = MutableDictionary::create(); - return toAPI(dictionary.release().leakRef()); + return const_cast(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 +#include #ifndef __cplusplus #include 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 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 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 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 +#include #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 +#include #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 -#include +#include +#include #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 -#include +#include +#include #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/WKSecurityOrigin.cpp deleted file mode 100644 index f7291065f..000000000 --- a/Source/WebKit2/Shared/API/c/WKSecurityOrigin.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 "WKSecurityOrigin.h" - -#include "WKAPICast.h" -#include "WebSecurityOrigin.h" - -using namespace WebKit; - -WKTypeID WKSecurityOriginGetTypeID() -{ - return toAPI(WebSecurityOrigin::APIType); -} - -WKSecurityOriginRef WKSecurityOriginCreateFromString(WKStringRef string) -{ - RefPtr securityOrigin = WebSecurityOrigin::createFromString(toImpl(string)->string()); - return toAPI(securityOrigin.release().leakRef()); -} - -WKSecurityOriginRef WKSecurityOriginCreateFromDatabaseIdentifier(WKStringRef identifier) -{ - RefPtr securityOrigin = WebSecurityOrigin::createFromDatabaseIdentifier(toImpl(identifier)->string()); - return toAPI(securityOrigin.release().leakRef()); -} - -WKSecurityOriginRef WKSecurityOriginCreate(WKStringRef protocol, WKStringRef host, int port) -{ - RefPtr securityOrigin = WebSecurityOrigin::create(toImpl(protocol)->string(), toImpl(host)->string(), port); - return toAPI(securityOrigin.release().leakRef()); -} - -WKStringRef WKSecurityOriginCopyDatabaseIdentifier(WKSecurityOriginRef securityOrigin) -{ - return toCopiedAPI(toImpl(securityOrigin)->databaseIdentifier()); -} - -WKStringRef WKSecurityOriginCopyToString(WKSecurityOriginRef securityOrigin) -{ - return toCopiedAPI(toImpl(securityOrigin)->toString()); -} - -WKStringRef WKSecurityOriginCopyProtocol(WKSecurityOriginRef securityOrigin) -{ - return toCopiedAPI(toImpl(securityOrigin)->protocol()); -} - -WKStringRef WKSecurityOriginCopyHost(WKSecurityOriginRef securityOrigin) -{ - return toCopiedAPI(toImpl(securityOrigin)->host()); -} - -unsigned short WKSecurityOriginGetPort(WKSecurityOriginRef securityOrigin) -{ - return toImpl(securityOrigin)->port(); -} - -// For backwards ABI compatibility. -extern "C" WK_EXPORT WKStringRef WKSecurityOriginGetHost(WKSecurityOriginRef securityOrigin); -extern "C" WK_EXPORT WKStringRef WKSecurityOriginGetProtocol(WKSecurityOriginRef securityOrigin); - -WKStringRef WKSecurityOriginGetHost(WKSecurityOriginRef securityOrigin) -{ - return WKSecurityOriginCopyHost(securityOrigin); -} - -WKStringRef WKSecurityOriginGetProtocol(WKSecurityOriginRef securityOrigin) -{ - return WKSecurityOriginCopyProtocol(securityOrigin); -} diff --git a/Source/WebKit2/Shared/API/c/WKSecurityOrigin.h b/Source/WebKit2/Shared/API/c/WKSecurityOrigin.h deleted file mode 100644 index d932e93a4..000000000 --- a/Source/WebKit2/Shared/API/c/WKSecurityOrigin.h +++ /dev/null @@ -1,51 +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 WKSecurityOrigin_h -#define WKSecurityOrigin_h - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -WK_EXPORT WKTypeID WKSecurityOriginGetTypeID(); - -WK_EXPORT WKSecurityOriginRef WKSecurityOriginCreateFromString(WKStringRef string); -WK_EXPORT WKSecurityOriginRef WKSecurityOriginCreateFromDatabaseIdentifier(WKStringRef identifier); -WK_EXPORT WKSecurityOriginRef WKSecurityOriginCreate(WKStringRef protocol, WKStringRef host, int port); - -WK_EXPORT WKStringRef WKSecurityOriginCopyDatabaseIdentifier(WKSecurityOriginRef securityOrigin); -WK_EXPORT WKStringRef WKSecurityOriginCopyToString(WKSecurityOriginRef securityOrigin); -WK_EXPORT WKStringRef WKSecurityOriginCopyProtocol(WKSecurityOriginRef securityOrigin); -WK_EXPORT WKStringRef WKSecurityOriginCopyHost(WKSecurityOriginRef securityOrigin); -WK_EXPORT unsigned short WKSecurityOriginGetPort(WKSecurityOriginRef securityOrigin); - -#ifdef __cplusplus -} -#endif - -#endif /* WKSecurityOrigin_h */ diff --git a/Source/WebKit2/Shared/API/c/WKSecurityOriginRef.cpp b/Source/WebKit2/Shared/API/c/WKSecurityOriginRef.cpp new file mode 100644 index 000000000..d1160740c --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKSecurityOriginRef.cpp @@ -0,0 +1,96 @@ +/* + * 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 "WKSecurityOriginRef.h" + +#include "APISecurityOrigin.h" +#include "WKAPICast.h" +#include + +using namespace WebKit; + +WKTypeID WKSecurityOriginGetTypeID() +{ + return toAPI(API::SecurityOrigin::APIType); +} + +WKSecurityOriginRef WKSecurityOriginCreateFromString(WKStringRef string) +{ + return toAPI(API::SecurityOrigin::create(WebCore::SecurityOrigin::createFromString(toImpl(string)->string())).leakRef()); +} + +WKSecurityOriginRef WKSecurityOriginCreateFromDatabaseIdentifier(WKStringRef identifier) +{ + 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) +{ + auto securityOrigin = API::SecurityOrigin::create(toImpl(protocol)->string(), toImpl(host)->string(), port); + return toAPI(securityOrigin.leakRef()); +} + +WKStringRef WKSecurityOriginCopyDatabaseIdentifier(WKSecurityOriginRef securityOrigin) +{ + return toCopiedAPI(WebCore::SecurityOriginData::fromSecurityOrigin(toImpl(securityOrigin)->securityOrigin()).databaseIdentifier()); +} + +WKStringRef WKSecurityOriginCopyToString(WKSecurityOriginRef securityOrigin) +{ + return toCopiedAPI(toImpl(securityOrigin)->securityOrigin().toString()); +} + +WKStringRef WKSecurityOriginCopyProtocol(WKSecurityOriginRef securityOrigin) +{ + return toCopiedAPI(toImpl(securityOrigin)->securityOrigin().protocol()); +} + +WKStringRef WKSecurityOriginCopyHost(WKSecurityOriginRef securityOrigin) +{ + return toCopiedAPI(toImpl(securityOrigin)->securityOrigin().host()); +} + +unsigned short WKSecurityOriginGetPort(WKSecurityOriginRef securityOrigin) +{ + return toImpl(securityOrigin)->securityOrigin().port().value_or(0); +} + +// For backwards ABI compatibility. +extern "C" WK_EXPORT WKStringRef WKSecurityOriginGetHost(WKSecurityOriginRef securityOrigin); +extern "C" WK_EXPORT WKStringRef WKSecurityOriginGetProtocol(WKSecurityOriginRef securityOrigin); + +WKStringRef WKSecurityOriginGetHost(WKSecurityOriginRef securityOrigin) +{ + return WKSecurityOriginCopyHost(securityOrigin); +} + +WKStringRef WKSecurityOriginGetProtocol(WKSecurityOriginRef securityOrigin) +{ + return WKSecurityOriginCopyProtocol(securityOrigin); +} diff --git a/Source/WebKit2/Shared/API/c/WKSecurityOriginRef.h b/Source/WebKit2/Shared/API/c/WKSecurityOriginRef.h new file mode 100644 index 000000000..3c3356b38 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKSecurityOriginRef.h @@ -0,0 +1,51 @@ +/* + * 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 WKSecurityOriginRef_h +#define WKSecurityOriginRef_h + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKTypeID WKSecurityOriginGetTypeID(); + +WK_EXPORT WKSecurityOriginRef WKSecurityOriginCreateFromString(WKStringRef string); +WK_EXPORT WKSecurityOriginRef WKSecurityOriginCreateFromDatabaseIdentifier(WKStringRef identifier); +WK_EXPORT WKSecurityOriginRef WKSecurityOriginCreate(WKStringRef protocol, WKStringRef host, int port); + +WK_EXPORT WKStringRef WKSecurityOriginCopyDatabaseIdentifier(WKSecurityOriginRef securityOrigin); +WK_EXPORT WKStringRef WKSecurityOriginCopyToString(WKSecurityOriginRef securityOrigin); +WK_EXPORT WKStringRef WKSecurityOriginCopyProtocol(WKSecurityOriginRef securityOrigin); +WK_EXPORT WKStringRef WKSecurityOriginCopyHost(WKSecurityOriginRef securityOrigin); +WK_EXPORT unsigned short WKSecurityOriginGetPort(WKSecurityOriginRef securityOrigin); + +#ifdef __cplusplus +} +#endif + +#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 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 serializedValue = WebSerializedScriptValue::create(static_cast(internalRepresentation)); - return toAPI(serializedValue.release().leakRef()); + auto serializedValue = API::SerializedScriptValue::create(static_cast(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 -#include +#include #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 +#include #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 +#include #include #include #include @@ -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 struct APITypeInfo { }; -template struct ImplTypeInfo { }; +template struct APITypeInfo; +template struct ImplTypeInfo; #define WK_ADD_API_MAPPING(TheAPIType, TheImplType) \ - template<> struct APITypeInfo { typedef TheImplType* ImplType; }; \ - template<> struct ImplTypeInfo { typedef TheAPIType APIType; }; + template<> struct APITypeInfo { typedef TheImplType ImplType; }; \ + template<> struct ImplTypeInfo { 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 { typedef API::Array* ImplType; }; +template<> struct APITypeInfo { typedef API::Array ImplType; }; +template<> struct APITypeInfo { 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 -inline typename ImplTypeInfo::APIType toAPI(T t) +template::APIType> +auto toAPI(T* t) -> APIType +{ + return reinterpret_cast(API::Object::wrap(t)); +} + +template::ImplType> +auto toImpl(T t) -> ImplType* { - return reinterpret_cast::APIType>(t); + return static_cast(API::Object::unwrap(static_cast(const_cast::type>::type*>(t)))); } -template::APIType> +template::APIType> class ProxyingRefPtr { public: ProxyingRefPtr(PassRefPtr impl) @@ -138,26 +141,17 @@ public: { } + ProxyingRefPtr(Ref&& impl) + : m_impl(WTFMove(impl)) + { + } + operator APIType() { return toAPI(m_impl.get()); } private: RefPtr m_impl; }; -/* Opaque typing convenience methods */ - -template -inline typename APITypeInfo::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::type PotentiallyConstValueType; - typedef typename std::remove_const::type NonConstValueType; - - return reinterpret_cast::ImplType>(const_cast(t)); -} - /* Special cases. */ inline ProxyingRefPtr toAPI(StringImpl* string) @@ -167,23 +161,21 @@ inline ProxyingRefPtr toAPI(StringImpl* string) inline WKStringRef toCopiedAPI(const String& string) { - RefPtr apiString = API::String::create(string); - return toAPI(apiString.release().leakRef()); + return toAPI(&API::String::create(string).leakRef()); } inline ProxyingRefPtr toURLRef(StringImpl* string) { if (!string) - return ProxyingRefPtr(0); + return ProxyingRefPtr(nullptr); return ProxyingRefPtr(API::URL::create(String(string))); } inline WKURLRef toCopiedURLAPI(const String& string) { if (!string) - return 0; - RefPtr 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(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(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 +#include +#include using namespace WebKit; @@ -38,58 +41,101 @@ WKTypeID WKStringGetTypeID() WKStringRef WKStringCreateWithUTF8CString(const char* string) { - RefPtr 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(buffer), bufferLength)); + static_assert(sizeof(WKChar) == sizeof(UChar), "Size of WKChar must match size of UChar"); + + unsigned unsignedBufferLength = std::min(bufferLength, std::numeric_limits::max()); + auto substring = toImpl(stringRef)->stringView().substring(0, unsignedBufferLength); + + substring.getCharactersWithUpconvert(reinterpret_cast(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 +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(stringRef, buffer, bufferSize); +} + +size_t WKStringGetUTF8CStringNonStrict(WKStringRef stringRef, char* buffer, size_t bufferSize) +{ + return WKStringGetUTF8CStringImpl(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 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 +#include #include #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 -#include +#include #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(const_cast(typeRef))->type()); + return toAPI(toImpl(typeRef)->type()); } WKTypeRef WKRetain(WKTypeRef typeRef) { - static_cast(const_cast(typeRef))->ref(); + toImpl(typeRef)->ref(); + return typeRef; } void WKRelease(WKTypeRef typeRef) { - static_cast(const_cast(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 +#include #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 +#include #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 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 +#include #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 +#include #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 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 -#include +#include #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::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 -#include +#include +#include typedef struct _cairo_surface cairo_surface_t; diff --git a/Source/WebKit2/Shared/API/c/soup/WKBaseSoup.h b/Source/WebKit2/Shared/API/c/soup/WKBaseSoup.h deleted file mode 100644 index 600f0857f..000000000 --- a/Source/WebKit2/Shared/API/c/soup/WKBaseSoup.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2012 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 WKBaseSoup_h -#define WKBaseSoup_h - -#ifndef WKBase_h -#error "Please #include \"WKBase.h\" instead of this file directly." -#endif - -typedef const struct OpaqueWKSoupRequestManager* WKSoupRequestManagerRef; -typedef const struct OpaqueWKSoupCustomProtocolRequestManager* WKSoupCustomProtocolRequestManagerRef; - -#endif /* WKBaseSoup_h */ diff --git a/Source/WebKit2/Shared/APIArray.cpp b/Source/WebKit2/Shared/APIArray.cpp deleted file mode 100644 index 9b7f63896..000000000 --- a/Source/WebKit2/Shared/APIArray.cpp +++ /dev/null @@ -1,77 +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 "APIArray.h" - -#include "APIString.h" - -namespace API { - -PassRefPtr Array::create() -{ - return create(Vector>()); -} - -PassRefPtr Array::create(Vector> elements) -{ - return adoptRef(new Array(std::move(elements))); -} - -PassRefPtr Array::createStringArray(const Vector& strings) -{ - Vector> elements; - elements.reserveInitialCapacity(strings.size()); - - for (const auto& string : strings) - elements.uncheckedAppend(API::String::create(string)); - - return create(std::move(elements)); -} - -Vector Array::toStringVector() -{ - Vector patternsVector; - - size_t size = this->size(); - if (!size) - return patternsVector; - - patternsVector.reserveInitialCapacity(size); - for (const auto& entry : elementsOfType()) - patternsVector.uncheckedAppend(entry->string()); - return patternsVector; -} - -Array::Array(Vector> elements) - : m_elements(std::move(elements)) -{ -} - -Array::~Array() -{ -} - -} // namespace API diff --git a/Source/WebKit2/Shared/APIArray.h b/Source/WebKit2/Shared/APIArray.h deleted file mode 100644 index addbae9c0..000000000 --- a/Source/WebKit2/Shared/APIArray.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2010, 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 APIArray_h -#define APIArray_h - -#include "APIObject.h" -#include -#include -#include -#include -#include - -namespace API { - -class Array final : public ObjectImpl { -private: - template - struct IsTypePredicate { - bool operator()(const RefPtr& object) const { return object->type() == T::APIType; } - }; - - template - struct GetObjectTransform { - const T* operator()(const RefPtr& object) const { return static_cast(object.get()); } - }; - - template - using ElementsOfTypeRange = WTF::IteratorRange, WTF::FilterIterator, Vector>::const_iterator>>>; - -public: - static PassRefPtr create(); - static PassRefPtr create(Vector> elements); - static PassRefPtr createStringArray(const Vector&); - Vector toStringVector(); - - virtual ~Array(); - - template - T* at(size_t i) const - { - if (m_elements[i]->type() != T::APIType) - return nullptr; - - return static_cast(m_elements[i].get()); - } - - Object* at(size_t i) const { return m_elements[i].get(); } - size_t size() const { return m_elements.size(); } - - const Vector>& elements() const { return m_elements; } - Vector>& elements() { return m_elements; } - - template - ElementsOfTypeRange elementsOfType() const - { - return WTF::makeIteratorRange( - WTF::makeTransformIterator(GetObjectTransform(), WTF::makeFilterIterator(IsTypePredicate(), m_elements.begin(), m_elements.end())), - WTF::makeTransformIterator(GetObjectTransform(), WTF::makeFilterIterator(IsTypePredicate(), m_elements.end(), m_elements.end())) - ); - } - -private: - explicit Array(Vector> elements); - - Vector> m_elements; -}; - -} // namespace API - -#endif // APIArray_h diff --git a/Source/WebKit2/Shared/APIClient.h b/Source/WebKit2/Shared/APIClient.h deleted file mode 100644 index 2d2d89a5c..000000000 --- a/Source/WebKit2/Shared/APIClient.h +++ /dev/null @@ -1,85 +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 APIClient_h -#define APIClient_h - -#include -#include - -namespace API { - -template struct ClientTraits; - -template class Client { - typedef typename ClientTraits::Versions ClientVersions; - static const int latestClientVersion = std::tuple_size::value - 1; - typedef typename std::tuple_element::type LatestClientInterface; - - // Helper class that can return an std::array of element sizes in a tuple. - template struct InterfaceSizes; - template struct InterfaceSizes> { - static std::array sizes() - { - return { { sizeof(Interfaces)... } }; - } - }; - -public: - Client() - { -#if !ASSERT_DISABLED - auto interfaceSizes = InterfaceSizes::sizes(); - ASSERT(std::is_sorted(interfaceSizes.begin(), interfaceSizes.end())); -#endif - - initialize(nullptr); - } - - void initialize(const ClientInterface* client) - { - if (client && client->version == latestClientVersion) { - m_client = *reinterpret_cast(client); - return; - } - - memset(&m_client, 0, sizeof(m_client)); - - if (client && client->version < latestClientVersion) { - auto interfaceSizes = InterfaceSizes::sizes(); - - memcpy(&m_client, client, interfaceSizes[client->version]); - } - } - - const LatestClientInterface& client() const { return m_client; } - -protected: - LatestClientInterface m_client; -}; - -} // namespace API - -#endif // APIClient_h diff --git a/Source/WebKit2/Shared/APIData.cpp b/Source/WebKit2/Shared/APIData.cpp deleted file mode 100644 index 57bf8c741..000000000 --- a/Source/WebKit2/Shared/APIData.cpp +++ /dev/null @@ -1,49 +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 "APIData.h" - -#include "ArgumentDecoder.h" -#include "ArgumentEncoder.h" - -namespace API { - -void Data::encode(IPC::ArgumentEncoder& encoder) const -{ - encoder << dataReference(); -} - -bool Data::decode(IPC::ArgumentDecoder& decoder, RefPtr& result) -{ - IPC::DataReference dataReference; - if (!decoder.decode(dataReference)) - return false; - - result = create(dataReference.data(), dataReference.size()); - return true; -} - -} // namespace API diff --git a/Source/WebKit2/Shared/APIData.h b/Source/WebKit2/Shared/APIData.h deleted file mode 100644 index bb0216bdd..000000000 --- a/Source/WebKit2/Shared/APIData.h +++ /dev/null @@ -1,104 +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 APIData_h -#define APIData_h - -#include "APIObject.h" -#include "DataReference.h" -#include -#include - -namespace IPC { -class ArgumentDecoder; -class ArgumentEncoder; -} - -namespace API { - -class Data : public ObjectImpl { -public: - typedef void (*FreeDataFunction)(unsigned char*, const void* context); - - static PassRefPtr createWithoutCopying(const unsigned char* bytes, size_t size, FreeDataFunction freeDataFunction, const void* context) - { - return adoptRef(new Data(bytes, size, freeDataFunction, context)); - } - - static PassRefPtr create(const unsigned char* bytes, size_t size) - { - unsigned char *copiedBytes = 0; - - if (size) { - copiedBytes = static_cast(fastMalloc(size)); - memcpy(copiedBytes, bytes, size); - } - - return createWithoutCopying(copiedBytes, size, fastFreeBytes, 0); - } - - static PassRefPtr create(const Vector& buffer) - { - return create(buffer.data(), buffer.size()); - } - - ~Data() - { - m_freeDataFunction(const_cast(m_bytes), m_context); - } - - const unsigned char* bytes() const { return m_bytes; } - size_t size() const { return m_size; } - - IPC::DataReference dataReference() const { return IPC::DataReference(m_bytes, m_size); } - - void encode(IPC::ArgumentEncoder&) const; - static bool decode(IPC::ArgumentDecoder&, RefPtr&); - -private: - Data(const unsigned char* bytes, size_t size, FreeDataFunction freeDataFunction, const void* context) - : m_bytes(bytes) - , m_size(size) - , m_freeDataFunction(freeDataFunction) - , m_context(context) - { - } - - static void fastFreeBytes(unsigned char* bytes, const void*) - { - if (bytes) - fastFree(static_cast(bytes)); - } - - const unsigned char* m_bytes; - size_t m_size; - - FreeDataFunction m_freeDataFunction; - const void* m_context; -}; - -} // namespace API - -#endif // APIData_h diff --git a/Source/WebKit2/Shared/APIError.cpp b/Source/WebKit2/Shared/APIError.cpp deleted file mode 100644 index 86a1db0b0..000000000 --- a/Source/WebKit2/Shared/APIError.cpp +++ /dev/null @@ -1,56 +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 "APIError.h" - -#include "WebCoreArgumentCoders.h" -#include -#include - -namespace API { - -const WTF::String& Error::webKitErrorDomain() -{ - static NeverDestroyed webKitErrorDomainString(ASCIILiteral("WebKitErrorDomain")); - return webKitErrorDomainString; -} - -void Error::encode(IPC::ArgumentEncoder& encoder) const -{ - encoder << platformError(); -} - -bool Error::decode(IPC::ArgumentDecoder& decoder, RefPtr& result) -{ - WebCore::ResourceError error; - if (!decoder.decode(error)) - return false; - - result = create(error); - return true; -} - -} // namespace WebKit diff --git a/Source/WebKit2/Shared/APIError.h b/Source/WebKit2/Shared/APIError.h deleted file mode 100644 index 8cb1cf419..000000000 --- a/Source/WebKit2/Shared/APIError.h +++ /dev/null @@ -1,79 +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 APIError_h -#define APIError_h - -#include "APIObject.h" -#include -#include - -namespace IPC { -class ArgumentDecoder; -class ArgumentEncoder; -} - -namespace API { - -class Error : public ObjectImpl { -public: - static PassRefPtr create() - { - return adoptRef(new Error); - } - - static PassRefPtr create(const WebCore::ResourceError& error) - { - return adoptRef(new Error(error)); - } - - static const WTF::String& webKitErrorDomain(); - - const WTF::String& domain() const { return m_platformError.domain(); } - int errorCode() const { return m_platformError.errorCode(); } - const WTF::String& failingURL() const { return m_platformError.failingURL(); } - const WTF::String& localizedDescription() const { return m_platformError.localizedDescription(); } - - const WebCore::ResourceError& platformError() const { return m_platformError; } - - void encode(IPC::ArgumentEncoder&) const; - static bool decode(IPC::ArgumentDecoder&, RefPtr&); - -private: - Error() - { - } - - Error(const WebCore::ResourceError& error) - : m_platformError(error) - { - } - - WebCore::ResourceError m_platformError; -}; - -} // namespace API - -#endif // APIError_h diff --git a/Source/WebKit2/Shared/APIFrameHandle.cpp b/Source/WebKit2/Shared/APIFrameHandle.cpp deleted file mode 100644 index b50c02349..000000000 --- a/Source/WebKit2/Shared/APIFrameHandle.cpp +++ /dev/null @@ -1,45 +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 "APIFrameHandle.h" - -namespace API { - -RefPtr FrameHandle::create(uint64_t frameID) -{ - return adoptRef(new FrameHandle(frameID)); -} - -FrameHandle::FrameHandle(uint64_t frameID) - : m_frameID(frameID) -{ -} - -FrameHandle::~FrameHandle() -{ -} - -} // namespace API diff --git a/Source/WebKit2/Shared/APIFrameHandle.h b/Source/WebKit2/Shared/APIFrameHandle.h deleted file mode 100644 index e69136649..000000000 --- a/Source/WebKit2/Shared/APIFrameHandle.h +++ /dev/null @@ -1,49 +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. - */ - -#ifndef APIFrameHandle_h -#define APIFrameHandle_h - -#include "APIObject.h" -#include - -namespace API { - -class FrameHandle : public ObjectImpl { -public: - static RefPtr create(uint64_t frameID); - virtual ~FrameHandle(); - - uint64_t frameID() const { return m_frameID; } - -private: - explicit FrameHandle(uint64_t frameID); - - uint64_t m_frameID; -}; - -} // namespace API - -#endif // APIFrameHandle_h diff --git a/Source/WebKit2/Shared/APIGeometry.cpp b/Source/WebKit2/Shared/APIGeometry.cpp deleted file mode 100644 index c59827b18..000000000 --- a/Source/WebKit2/Shared/APIGeometry.cpp +++ /dev/null @@ -1,96 +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 "APIGeometry.h" - -#include "ArgumentDecoder.h" -#include "ArgumentEncoder.h" - -namespace API { - -void Point::encode(IPC::ArgumentEncoder& encoder) const -{ - encoder << m_point.x; - encoder << m_point.y; -} - -bool Point::decode(IPC::ArgumentDecoder& decoder, RefPtr& result) -{ - WKPoint point; - if (!decoder.decode(point.x)) - return false; - if (!decoder.decode(point.y)) - return false; - - result = Point::create(point); - return true; -} - - -void Size::encode(IPC::ArgumentEncoder& encoder) const -{ - encoder << m_size.width; - encoder << m_size.height; -} - -bool Size::decode(IPC::ArgumentDecoder& decoder, RefPtr& result) -{ - WKSize size; - if (!decoder.decode(size.width)) - return false; - if (!decoder.decode(size.height)) - return false; - - result = Size::create(size); - return true; -} - - -void Rect::encode(IPC::ArgumentEncoder& encoder) const -{ - encoder << m_rect.origin.x; - encoder << m_rect.origin.y; - encoder << m_rect.size.width; - encoder << m_rect.size.height; -} - -bool Rect::decode(IPC::ArgumentDecoder& decoder, RefPtr& result) -{ - WKRect rect; - if (!decoder.decode(rect.origin.x)) - return false; - if (!decoder.decode(rect.origin.y)) - return false; - if (!decoder.decode(rect.size.width)) - return false; - if (!decoder.decode(rect.size.height)) - return false; - - result = Rect::create(rect); - return true; -} - -} // namespace API diff --git a/Source/WebKit2/Shared/APIGeometry.h b/Source/WebKit2/Shared/APIGeometry.h deleted file mode 100644 index 2efcb47c1..000000000 --- a/Source/WebKit2/Shared/APIGeometry.h +++ /dev/null @@ -1,105 +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 APIGeometry_h -#define APIGeometry_h - -#include "APIObject.h" -#include "WKGeometry.h" -#include -#include - -namespace IPC { -class ArgumentDecoder; -class ArgumentEncoder; -} - -namespace API { - -class Size : public API::ObjectImpl { -public: - static PassRefPtr create(const WKSize& size) - { - return adoptRef(new Size(size)); - } - - const WKSize& size() const { return m_size; } - - void encode(IPC::ArgumentEncoder&) const; - static bool decode(IPC::ArgumentDecoder&, RefPtr&); - -private: - explicit Size(const WKSize& size) - : m_size(size) - { - } - - WKSize m_size; -}; - -class Point : public API::ObjectImpl { -public: - static PassRefPtr create(const WKPoint& point) - { - return adoptRef(new Point(point)); - } - - const WKPoint& point() const { return m_point; } - - void encode(IPC::ArgumentEncoder&) const; - static bool decode(IPC::ArgumentDecoder&, RefPtr&); - -private: - explicit Point(const WKPoint& point) - : m_point(point) - { } - - WKPoint m_point; -}; - -class Rect : public API::ObjectImpl { -public: - static PassRefPtr create(const WKRect& rect) - { - return adoptRef(new Rect(rect)); - } - - const WKRect& rect() const { return m_rect; } - - void encode(IPC::ArgumentEncoder&) const; - static bool decode(IPC::ArgumentDecoder&, RefPtr&); - -private: - explicit Rect(const WKRect& rect) - : m_rect(rect) - { - } - - WKRect m_rect; -}; - -} // namespace API - -#endif // APIGeometry_h diff --git a/Source/WebKit2/Shared/APINumber.h b/Source/WebKit2/Shared/APINumber.h deleted file mode 100644 index 02a4da97f..000000000 --- a/Source/WebKit2/Shared/APINumber.h +++ /dev/null @@ -1,76 +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 APINumber_h -#define APINumber_h - -#include "APIObject.h" -#include "ArgumentDecoder.h" -#include "ArgumentEncoder.h" -#include - -namespace API { - -template -class Number : public ObjectImpl { -public: - static PassRefPtr create(NumberType value) - { - return adoptRef(new Number(value)); - } - - NumberType value() const { return m_value; } - - void encode(IPC::ArgumentEncoder& encoder) const - { - encoder << m_value; - } - - static bool decode(IPC::ArgumentDecoder& decoder, RefPtr& result) - { - NumberType value; - if (!decoder.decode(value)) - return false; - - result = Number::create(value); - return true; - } - -private: - explicit Number(NumberType value) - : m_value(value) - { - } - - const NumberType m_value; -}; - -typedef Number Boolean; -typedef Number Double; -typedef Number UInt64; - -} // namespace API - -#endif // APINumber_h diff --git a/Source/WebKit2/Shared/APIObject.cpp b/Source/WebKit2/Shared/APIObject.cpp deleted file mode 100644 index 26e38f008..000000000 --- a/Source/WebKit2/Shared/APIObject.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2011 Motorola Mobility, 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: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 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. - * - * Neither the name of Motorola Mobility, Inc. nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT HOLDER 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 "APIObject.h" - -#include "WebKit2Initialize.h" - -namespace API { - -Object::Object() -{ - WebKit::InitializeWebKit2(); -} - -} // namespace WebKit diff --git a/Source/WebKit2/Shared/APIObject.h b/Source/WebKit2/Shared/APIObject.h deleted file mode 100644 index 38155d1e6..000000000 --- a/Source/WebKit2/Shared/APIObject.h +++ /dev/null @@ -1,236 +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 APIObject_h -#define APIObject_h - -#include -#include -#include -#include - -#if PLATFORM(MAC) -#include "WKFoundation.h" -#ifdef __OBJC__ -#include "WKObject.h" -#endif -#endif - -#define DELEGATE_REF_COUNTING_TO_COCOA (PLATFORM(MAC) && WK_API_ENABLED) - -#if DELEGATE_REF_COUNTING_TO_COCOA -OBJC_CLASS NSObject; -#endif - -namespace API { - -class Object -#if !DELEGATE_REF_COUNTING_TO_COCOA - : public ThreadSafeRefCounted -#endif -{ -public: - enum class Type { - // Base types - Null = 0, - Array, - AuthenticationChallenge, - AuthenticationDecisionListener, - CertificateInfo, - Connection, - ContextMenuItem, - Credential, - Data, - Dictionary, - Error, - FrameHandle, - Image, - PageGroupData, - PageHandle, - ProtectionSpace, - RenderLayer, - RenderObject, - SecurityOrigin, - SerializedScriptValue, - String, - URL, - URLRequest, - URLResponse, - UserContentURLPattern, - WebArchive, - WebArchiveResource, - - // Base numeric types - Boolean, - Double, - UInt64, - - // Geometry types - Point, - Size, - Rect, - - // UIProcess types - ApplicationCacheManager, - BackForwardList, - BackForwardListItem, - BatteryManager, - BatteryStatus, - CacheManager, - ColorPickerResultListener, - Context, - CookieManager, - DatabaseManager, - Download, - FormSubmissionListener, - Frame, - FramePolicyListener, - FullScreenManager, - GeolocationManager, - GeolocationPermissionRequest, - HitTestResult, - GeolocationPosition, - GrammarDetail, - IconDatabase, - Inspector, - KeyValueStorageManager, - MediaCacheManager, - NavigationData, - NetworkInfo, - NetworkInfoManager, - Notification, - NotificationManager, - NotificationPermissionRequest, - OpenPanelParameters, - OpenPanelResultListener, - OriginDataManager, - Page, - PageGroup, - PluginSiteDataManager, - Preferences, - Session, - TextChecker, - Vibration, - ViewportAttributes, - - // Bundle types - Bundle, - BundleBackForwardList, - BundleBackForwardListItem, - BundleDOMWindowExtension, - BundleFrame, - BundleHitTestResult, - BundleInspector, - BundleNavigationAction, - BundleNodeHandle, - BundlePage, - BundlePageBanner, - BundlePageGroup, - BundlePageOverlay, - BundleRangeHandle, - BundleScriptWorld, - - // Platform specific - EditCommandProxy, - ObjCObjectGraph, - View, -#if USE(SOUP) - SoupRequestManager, - SoupCustomProtocolRequestManager, -#endif -#if PLATFORM(EFL) - PopupMenuItem, -#if ENABLE(TOUCH_EVENTS) - TouchPoint, - TouchEvent, -#endif -#endif - }; - - virtual ~Object() - { - } - - virtual Type type() const = 0; - -#if DELEGATE_REF_COUNTING_TO_COCOA -#ifdef __OBJC__ - template - static void constructInWrapper(NSObject *wrapper, Args&&... args) - { - Object* object = new (&wrapper._apiObject) T(std::forward(args)...); - object->m_wrapper = wrapper; - } -#endif - - NSObject *wrapper() { return m_wrapper; } - - void ref(); - void deref(); -#endif // DELEGATE_REF_COUNTING_TO_COCOA - -protected: - Object(); - -#if DELEGATE_REF_COUNTING_TO_COCOA - static void* newObject(size_t, Type); - -private: - // Derived classes must override operator new and call newObject(). - void* operator new(size_t) = delete; - - NSObject *m_wrapper; -#endif // DELEGATE_REF_COUNTING_TO_COCOA -}; - -template -class ObjectImpl : public Object { -public: - static const Type APIType = ArgumentType; - - virtual ~ObjectImpl() - { - } - -protected: - friend class Object; - - ObjectImpl() - { - } - - virtual 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; } -#endif -}; - -} // namespace Object - -#undef DELEGATE_REF_COUNTING_TO_COCOA - -#endif // APIObject_h diff --git a/Source/WebKit2/Shared/APIPageHandle.cpp b/Source/WebKit2/Shared/APIPageHandle.cpp deleted file mode 100644 index 01a878d6e..000000000 --- a/Source/WebKit2/Shared/APIPageHandle.cpp +++ /dev/null @@ -1,45 +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 "APIPageHandle.h" - -namespace API { - -RefPtr PageHandle::create(uint64_t pageID) -{ - return adoptRef(new PageHandle(pageID)); -} - -PageHandle::PageHandle(uint64_t pageID) - : m_pageID(pageID) -{ -} - -PageHandle::~PageHandle() -{ -} - -} // namespace API diff --git a/Source/WebKit2/Shared/APIPageHandle.h b/Source/WebKit2/Shared/APIPageHandle.h deleted file mode 100644 index 4e2df974e..000000000 --- a/Source/WebKit2/Shared/APIPageHandle.h +++ /dev/null @@ -1,49 +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. - */ - -#ifndef APIPageHandle_h -#define APIPageHandle_h - -#include "APIObject.h" -#include - -namespace API { - -class PageHandle : public ObjectImpl { -public: - static RefPtr create(uint64_t pageID); - virtual ~PageHandle(); - - uint64_t pageID() const { return m_pageID; } - -private: - explicit PageHandle(uint64_t pageID); - - uint64_t m_pageID; -}; - -} // namespace API - -#endif // APIPageHandle_h 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 -#include -#include -#include -#include -#include - -namespace API { - -class String final : public ObjectImpl { -public: - static PassRefPtr createNull() - { - return adoptRef(new String); - } - - static PassRefPtr create(const WTF::String& string) - { - return adoptRef(new String(string)); - } - - static PassRefPtr create(JSStringRef jsStringRef) - { - return adoptRef(new String(jsStringRef->string())); - } - - static PassRefPtr 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(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/APIURL.h b/Source/WebKit2/Shared/APIURL.h deleted file mode 100644 index 0e1e03c7b..000000000 --- a/Source/WebKit2/Shared/APIURL.h +++ /dev/null @@ -1,125 +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 WebURL_h -#define WebURL_h - -#include "APIObject.h" -#include "WebCoreArgumentCoders.h" -#include -#include -#include -#include -#include - -namespace API { - -class URL : public ObjectImpl { -public: - static PassRefPtr create(const WTF::String& string) - { - return adoptRef(new URL(string)); - } - - static PassRefPtr create(const URL* baseURL, const WTF::String& relativeURL) - { - ASSERT(baseURL); - baseURL->parseURLIfNecessary(); - auto absoluteURL = std::make_unique(*baseURL->m_parsedURL.get(), relativeURL); - const WTF::String& absoluteURLString = absoluteURL->string(); - - return adoptRef(new URL(std::move(absoluteURL), absoluteURLString)); - } - - bool isNull() const { return m_string.isNull(); } - bool isEmpty() const { return m_string.isEmpty(); } - - const WTF::String& string() const { return m_string; } - - WTF::String host() const - { - parseURLIfNecessary(); - return m_parsedURL->isValid() ? m_parsedURL->host() : WTF::String(); - } - - WTF::String protocol() const - { - parseURLIfNecessary(); - return m_parsedURL->isValid() ? m_parsedURL->protocol() : WTF::String(); - } - - WTF::String path() const - { - parseURLIfNecessary(); - return m_parsedURL->isValid() ? m_parsedURL->path() : WTF::String(); - } - - WTF::String lastPathComponent() const - { - parseURLIfNecessary(); - return m_parsedURL->isValid() ? m_parsedURL->lastPathComponent() : WTF::String(); - } - - void encode(IPC::ArgumentEncoder& encoder) const - { - encoder << m_string; - } - - static bool decode(IPC::ArgumentDecoder& decoder, RefPtr& result) - { - WTF::String string; - if (!decoder.decode(string)) - return false; - - result = create(string); - return true; - } - -private: - URL(const WTF::String& string) - : m_string(string) - { - } - - URL(std::unique_ptr parsedURL, const WTF::String& string) - : m_string(string) - , m_parsedURL(std::move(parsedURL)) - { - } - - void parseURLIfNecessary() const - { - if (m_parsedURL) - return; - m_parsedURL = std::make_unique(WebCore::URL(), m_string); - } - - WTF::String m_string; - mutable std::unique_ptr m_parsedURL; -}; - -} // namespace WebKit - -#endif // URL_h diff --git a/Source/WebKit2/Shared/APIURLRequest.cpp b/Source/WebKit2/Shared/APIURLRequest.cpp deleted file mode 100644 index b9165ea06..000000000 --- a/Source/WebKit2/Shared/APIURLRequest.cpp +++ /dev/null @@ -1,72 +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 "APIURLRequest.h" - -#include "WebContext.h" -#include "WebCoreArgumentCoders.h" - -using namespace WebCore; -using namespace WebKit; - -namespace API { - -URLRequest::URLRequest(const ResourceRequest& request) - : m_request(request) -{ -} - -double URLRequest::defaultTimeoutInterval() -{ - return ResourceRequest::defaultTimeoutInterval(); -} - -// FIXME: This function should really be on WebContext. -void URLRequest::setDefaultTimeoutInterval(double timeoutInterval) -{ - ResourceRequest::setDefaultTimeoutInterval(timeoutInterval); - - const Vector& contexts = WebContext::allContexts(); - for (size_t i = 0; i < contexts.size(); ++i) - contexts[i]->setDefaultRequestTimeoutInterval(timeoutInterval); -} - -void URLRequest::encode(IPC::ArgumentEncoder& encoder) const -{ - encoder << resourceRequest(); -} - -bool URLRequest::decode(IPC::ArgumentDecoder& decoder, RefPtr& result) -{ - ResourceRequest request; - if (!decoder.decode(request)) - return false; - - result = create(request); - return true; -} - -} // namespace API diff --git a/Source/WebKit2/Shared/APIURLRequest.h b/Source/WebKit2/Shared/APIURLRequest.h deleted file mode 100644 index d5e4d4a2e..000000000 --- a/Source/WebKit2/Shared/APIURLRequest.h +++ /dev/null @@ -1,63 +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 APIURLRequest_h -#define APIURLRequest_h - -#include "APIObject.h" -#include -#include - -namespace IPC { -class ArgumentDecoder; -class ArgumentEncoder; -} - -namespace API { - -class URLRequest : public ObjectImpl { -public: - static PassRefPtr create(const WebCore::ResourceRequest& request) - { - return adoptRef(new URLRequest(request)); - } - - const WebCore::ResourceRequest& resourceRequest() const { return m_request; } - - 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&); - -private: - explicit URLRequest(const WebCore::ResourceRequest&); - - WebCore::ResourceRequest m_request; -}; - -} // namespace API - -#endif // APIURLRequest_h diff --git a/Source/WebKit2/Shared/APIURLResponse.cpp b/Source/WebKit2/Shared/APIURLResponse.cpp deleted file mode 100644 index 226d624cb..000000000 --- a/Source/WebKit2/Shared/APIURLResponse.cpp +++ /dev/null @@ -1,55 +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 "APIURLResponse.h" - -#include "WebCoreArgumentCoders.h" - -using namespace WebCore; - -namespace API { - -URLResponse::URLResponse(const WebCore::ResourceResponse& response) - : m_response(response) -{ -} - -void URLResponse::encode(IPC::ArgumentEncoder& encoder) const -{ - encoder << resourceResponse(); -} - -bool URLResponse::decode(IPC::ArgumentDecoder& decoder, RefPtr& result) -{ - ResourceResponse response; - if (!decoder.decode(response)) - return false; - - result = create(response); - return true; -} - -} // namespace API diff --git a/Source/WebKit2/Shared/APIURLResponse.h b/Source/WebKit2/Shared/APIURLResponse.h deleted file mode 100644 index 2790b9fbe..000000000 --- a/Source/WebKit2/Shared/APIURLResponse.h +++ /dev/null @@ -1,60 +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 APIURLResponse_h -#define APIURLResponse_h - -#include "APIObject.h" -#include -#include - -namespace IPC { -class ArgumentDecoder; -class ArgumentEncoder; -} - -namespace API { - -class URLResponse : public ObjectImpl { -public: - static PassRefPtr create(const WebCore::ResourceResponse& 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&); - -private: - explicit URLResponse(const WebCore::ResourceResponse&); - - WebCore::ResourceResponse m_response; -}; - -} // namespace API - -#endif // APIURLResponse_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 + +namespace API { +class Array; +class Data; +} + +namespace WebCore { +class LegacyWebArchive; +class Range; +} + +namespace API { + +class WebArchiveResource; + +class WebArchive : public API::ObjectImpl { +public: + virtual ~WebArchive(); + + static Ref create(WebArchiveResource* mainResource, RefPtr&& subresources, RefPtr&& subframeArchives); + static Ref create(API::Data*); + static Ref create(RefPtr&&); + static Ref create(WebCore::Range*); + + WebArchiveResource* mainResource(); + API::Array* subresources(); + API::Array* subframeArchives(); + + Ref data(); + + WebCore::LegacyWebArchive* coreLegacyWebArchive(); + +private: + WebArchive(WebArchiveResource* mainResource, RefPtr&& subresources, RefPtr&& subframeArchives); + WebArchive(API::Data*); + WebArchive(RefPtr&&); + + RefPtr m_legacyWebArchive; + RefPtr m_cachedMainResource; + RefPtr m_cachedSubresources; + RefPtr 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 +#include +#include + +namespace API { +class Data; +class URL; +} + +namespace WebCore { +class ArchiveResource; +} + +namespace API { + +class WebArchiveResource : public API::ObjectImpl { +public: + virtual ~WebArchiveResource(); + + static Ref create(API::Data*, const String& URL, const String& MIMEType, const String& textEncoding); + static Ref create(PassRefPtr); + + Ref 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); + + RefPtr 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 #include 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 +#include +#include +#include + +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 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 + +namespace WebKit { + +static uint64_t generateRequestID() +{ + ASSERT(RunLoop::isMain()); + static uint64_t requestID = 0; + return ++requestID; +} + +AsyncRequest::AsyncRequest(std::function abortHandler) + : m_abortHandler(WTFMove(abortHandler)) + , m_requestID(generateRequestID()) +{ +} + +AsyncRequest::~AsyncRequest() +{ + ASSERT(!m_abortHandler); +} + +void AsyncRequest::setAbortHandler(std::function 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 +#include +#include +#include + +namespace WebKit { + +class AsyncRequest : public RefCounted { +public: + virtual ~AsyncRequest(); + + uint64_t requestID() { return m_requestID; } + + void setAbortHandler(std::function); + void requestAborted(); + template void completeRequest(Arguments&&... arguments); + +protected: + explicit AsyncRequest(std::function abortHandler); + + virtual void clearCompletionHandler() = 0; + + std::function m_abortHandler; + +private: + uint64_t m_requestID; +}; + +template +class AsyncRequestImpl final : public AsyncRequest { +public: + template using ArgumentType = typename std::conditional::value, T, const T&>::type; + + static Ref create(std::function...)> completionHandler) + { + return adoptRef(*new AsyncRequestImpl(WTFMove(completionHandler), nullptr)); + } + + static Ref create(std::function...)> completionHandler, std::function abortHandler) + { + return adoptRef(*new AsyncRequestImpl(WTFMove(completionHandler), WTFMove(abortHandler))); + } + + virtual ~AsyncRequestImpl() + { + ASSERT(!m_completionHandler); + } + + template + void completeRequest(RequestArguments&&... arguments) + { + m_completionHandler(std::forward(arguments)...); + m_completionHandler = nullptr; + } + +private: + AsyncRequestImpl(std::function...)> completionHandler, std::function abortHandler) + : AsyncRequest(WTFMove(abortHandler)) + , m_completionHandler(WTFMove(completionHandler)) + { + ASSERT(m_completionHandler); + } + + void clearCompletionHandler() override + { + m_completionHandler = nullptr; + } + + std::function...)> m_completionHandler; +}; + +template void AsyncRequest::completeRequest(Arguments&&... arguments) +{ + auto* request = static_cast::type...>*>(this); + request->completeRequest(std::forward(arguments)...); + m_abortHandler = nullptr; +} + +class AsyncRequestMap { +public: + AsyncRequestMap() +#ifndef NDEBUG + : m_lastRequestIDTaken(std::numeric_limits::max()) +#endif + { } + + Ref 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 request = m_requestMap.take(requestID); + RELEASE_ASSERT(request); + + return adoptRef(*request.leakRef()); + } + + void add(uint64_t requestID, PassRefPtr request) + { + m_requestMap.add(requestID, request); + } + + void clear() + { + m_requestMap.clear(); + } + + WTF::IteratorRange>::iterator::Values> values() + { + return m_requestMap.values(); + } + +private: + HashMap> 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 #include -#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 AuthenticationManager::coalesceChallengesMatching(uint64_t challengeID) const +{ + auto iterator = m_challenges.find(challengeID); + ASSERT(iterator != m_challenges.end()); + + auto& challenge = iterator->value; + + Vector 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 #include +#include #include 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 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 coalesceChallengesMatching(uint64_t challengeID) const; ChildProcess* m_process; - typedef HashMap AuthenticationChallengeMap; - AuthenticationChallengeMap m_challenges; + HashMap 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/Authentication/soup/AuthenticationManagerSoup.cpp b/Source/WebKit2/Shared/Authentication/soup/AuthenticationManagerSoup.cpp new file mode 100644 index 000000000..c26f2e5e7 --- /dev/null +++ b/Source/WebKit2/Shared/Authentication/soup/AuthenticationManagerSoup.cpp @@ -0,0 +1,53 @@ +/* + * 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 "AuthenticationManager.h" + +using namespace WebCore; + +namespace WebKit { + +void AuthenticationManager::receivedCredential(const AuthenticationChallenge&, const Credential&) +{ +} + +void AuthenticationManager::receivedRequestToContinueWithoutCredential(const AuthenticationChallenge&) +{ +} + +void AuthenticationManager::receivedCancellation(const AuthenticationChallenge&) +{ +} + +void AuthenticationManager::receivedRequestToPerformDefaultHandling(const AuthenticationChallenge&) +{ +} + +void AuthenticationManager::receivedChallengeRejection(const AuthenticationChallenge&) +{ +} + +} diff --git a/Source/WebKit2/Shared/BlobDataFileReferenceWithSandboxExtension.cpp b/Source/WebKit2/Shared/BlobDataFileReferenceWithSandboxExtension.cpp new file mode 100644 index 000000000..fb5e04f05 --- /dev/null +++ b/Source/WebKit2/Shared/BlobDataFileReferenceWithSandboxExtension.cpp @@ -0,0 +1,55 @@ +/* + * 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 "BlobDataFileReferenceWithSandboxExtension.h" + +#include "SandboxExtension.h" + +namespace WebKit { + +BlobDataFileReferenceWithSandboxExtension::BlobDataFileReferenceWithSandboxExtension(const String& path, PassRefPtr sandboxExtension) + : BlobDataFileReference(path) + , m_sandboxExtension(sandboxExtension) +{ +} + +BlobDataFileReferenceWithSandboxExtension::~BlobDataFileReferenceWithSandboxExtension() +{ +} + +void BlobDataFileReferenceWithSandboxExtension::prepareForFileAccess() +{ + if (m_sandboxExtension) + m_sandboxExtension->consume(); +} + +void BlobDataFileReferenceWithSandboxExtension::revokeFileAccess() +{ + if (m_sandboxExtension) + m_sandboxExtension->revoke(); +} + +} diff --git a/Source/WebKit2/Shared/BlobDataFileReferenceWithSandboxExtension.h b/Source/WebKit2/Shared/BlobDataFileReferenceWithSandboxExtension.h new file mode 100644 index 000000000..7ae8d2a6f --- /dev/null +++ b/Source/WebKit2/Shared/BlobDataFileReferenceWithSandboxExtension.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 BlobDataFileReferenceWithSandboxExtension_h +#define BlobDataFileReferenceWithSandboxExtension_h + +#include + +namespace WebKit { + +class SandboxExtension; + +class BlobDataFileReferenceWithSandboxExtension final : public WebCore::BlobDataFileReference { +public: + static Ref create(const String& path, PassRefPtr sandboxExtension) + { + return adoptRef(*new BlobDataFileReferenceWithSandboxExtension(path, sandboxExtension)); + } + +private: + BlobDataFileReferenceWithSandboxExtension(const String& path, PassRefPtr); + virtual ~BlobDataFileReferenceWithSandboxExtension(); + + void prepareForFileAccess() override; + void revokeFileAccess() override; + + RefPtr m_sandboxExtension; +}; + +} + +#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 +#include #include +#include #include template @@ -40,7 +41,7 @@ public: std::unique_ptr waitForResponse(uint64_t requestID) { while (true) { - std::unique_lock lock(m_mutex); + std::unique_lock lock(m_mutex); if (m_canceled) return nullptr; @@ -56,26 +57,26 @@ public: void didReceiveResponse(uint64_t requestID, std::unique_ptr response) { - std::lock_guard lock(m_mutex); + std::lock_guard 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> 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 +#include +#include 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 #include 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 @@ -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 #include -#include #include #include #include @@ -45,6 +44,9 @@ struct ChildProcessInitializationParameters { String clientIdentifier; IPC::Connection::Identifier connectionIdentifier; HashMap extraInitializationData; +#if PLATFORM(COCOA) + OSObjectPtr 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& 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 m_priorityBoostMessage; +#endif }; } // namespace WebKit diff --git a/Source/WebKit2/Shared/ChildProcess.messages.in b/Source/WebKit2/Shared/ChildProcess.messages.in new file mode 100644 index 000000000..49dfb050c --- /dev/null +++ b/Source/WebKit2/Shared/ChildProcess.messages.in @@ -0,0 +1,25 @@ +# 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. + +messages -> ChildProcess { + ShutDown() +} 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 - -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(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 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& 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 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 - -namespace WebKit { - -class ChildProcessProxy : ProcessLauncher::Client, public IPC::Connection::Client, public ThreadSafeRefCounted { - 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 bool send(T&& message, uint64_t destinationID, unsigned messageSendFlags = 0); - template 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, 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&); - -private: - virtual void getLaunchOptions(ProcessLauncher::LaunchOptions&) = 0; - virtual void connectionWillOpen(IPC::Connection*); - virtual void connectionWillClose(IPC::Connection*); - - Vector, unsigned>> m_pendingMessages; - RefPtr m_processLauncher; - RefPtr m_connection; - IPC::MessageReceiverMap m_messageReceiverMap; -}; - -template -bool ChildProcessProxy::send(T&& message, uint64_t destinationID, unsigned messageSendFlags) -{ - COMPILE_ASSERT(!T::isSync, AsyncMessageExpected); - - auto encoder = std::make_unique(T::receiverName(), T::name(), destinationID); - encoder->encode(message.arguments()); - - return sendMessage(std::move(encoder), messageSendFlags); -} - -template -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(message), std::move(reply), destinationID, timeout); -} - -} // namespace WebKit - -#endif // ChildProcessProxy_h diff --git a/Source/WebKit2/Shared/CommandLine.h b/Source/WebKit2/Shared/CommandLine.h deleted file mode 100644 index f5955e754..000000000 --- a/Source/WebKit2/Shared/CommandLine.h +++ /dev/null @@ -1,54 +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 CommandLine_h -#define CommandLine_h - -#include -#include -#include - -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); -#endif - String operator[](const String& key) const - { - return m_args.get(key); - } - -private: - HashMap m_args; -}; - -} - -#endif // CommandLine_h diff --git a/Source/WebKit2/Shared/ConnectionStack.cpp b/Source/WebKit2/Shared/ConnectionStack.cpp deleted file mode 100644 index 565adf599..000000000 --- a/Source/WebKit2/Shared/ConnectionStack.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 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 - * 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 "ConnectionStack.h" - -#include - -namespace WebKit { - -ConnectionStack& ConnectionStack::shared() -{ - static NeverDestroyed connectionStack; - return connectionStack; -} - -} // namespace WebKit diff --git a/Source/WebKit2/Shared/ConnectionStack.h b/Source/WebKit2/Shared/ConnectionStack.h deleted file mode 100644 index bd753a0e8..000000000 --- a/Source/WebKit2/Shared/ConnectionStack.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 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 - * 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 ConnectionStack_h -#define ConnectionStack_h - -#include - -namespace IPC { - class Connection; -} - -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 - }; - -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 m_connectionStack; -}; - -} // namespace WebKit - -#endif // ConnectionStack_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 +#include + +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& 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& menuItems, const WebCore::ContextMenuContext&); + + Type type() const { return m_type; } + const WebCore::IntPoint& menuLocation() const { return m_menuLocation; } + const Vector& 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& selectionData, const Vector& 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& controlledSelectionData() const { return m_controlledSelectionData; } + const Vector& 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 m_menuItems; + + WebHitTestResultData m_webHitTestResultData; + String m_selectedText; + +#if ENABLE(SERVICE_CONTROLS) + RefPtr m_controlledImage; + Vector m_controlledSelectionData; + Vector 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 +#include +#include +#include + +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 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 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 backBuffer, const IntPoint& offset) +{ + CoordinatedBackingStoreTileMap::iterator it = m_tiles.find(id); + ASSERT(it != m_tiles.end()); + it->value.setBackBuffer(tileRect, sourceRect, backBuffer, offset); +} + +RefPtr CoordinatedBackingStore::texture() const +{ + for (auto& tile : m_tiles.values()) { + RefPtr texture = tile.texture(); + if (texture) + return texture; + } + + return RefPtr(); +} + +void CoordinatedBackingStore::setSize(const FloatSize& size) +{ + m_pendingSize = size; +} + +void CoordinatedBackingStore::paintTilesToTextureMapper(Vector& 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 tilesToPaint; + Vector 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 +#include +#include +#include +#include + + +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 buffer, const WebCore::IntPoint&); + +private: + RefPtr 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, const WebCore::IntPoint&); + static Ref create() { return adoptRef(*new CoordinatedBackingStore); } + void commitTileOperations(WebCore::TextureMapper&); + RefPtr 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::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 CoordinatedBackingStoreTileMap; + CoordinatedBackingStoreTileMap m_tiles; + HashSet 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace WebCore; +using namespace WebKit; + +namespace IPC { + +void ArgumentCoder::encode(Encoder& encoder, const WebCore::FilterOperations& filters) +{ + encoder << static_cast(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(downcast(filter).amount()); + break; + case FilterOperation::INVERT: + case FilterOperation::BRIGHTNESS: + case FilterOperation::CONTRAST: + case FilterOperation::OPACITY: + encoder << static_cast(downcast(filter).amount()); + break; + case FilterOperation::BLUR: + ArgumentCoder::encode(encoder, downcast(filter).stdDeviation()); + break; + case FilterOperation::DROP_SHADOW: { + const DropShadowFilterOperation& shadow = downcast(filter); + ArgumentCoder::encode(encoder, shadow.location()); + encoder << static_cast(shadow.stdDeviation()); + ArgumentCoder::encode(encoder, shadow.color()); + break; + } + case FilterOperation::REFERENCE: + case FilterOperation::PASSTHROUGH: + case FilterOperation::DEFAULT: + case FilterOperation::NONE: + break; + } + } +} + +bool ArgumentCoder::decode(Decoder& decoder, WebCore::FilterOperations& filters) +{ + uint32_t size; + if (!decoder.decode(size)) + return false; + + Vector >& operations = filters.operations(); + + for (size_t i = 0; i < size; ++i) { + FilterOperation::OperationType type; + RefPtr 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::decode(decoder, length)) + return false; + filter = BlurFilterOperation::create(length); + break; + } + case FilterOperation::DROP_SHADOW: { + IntPoint location; + int32_t stdDeviation; + Color color; + if (!ArgumentCoder::decode(decoder, location)) + return false; + if (!decoder.decode(stdDeviation)) + return false; + if (!ArgumentCoder::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::encode(Encoder& encoder, const TransformOperations& transformOperations) +{ + encoder << static_cast(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(*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(*operation); + ArgumentCoder::encode(encoder, translateOperation.x()); + ArgumentCoder::encode(encoder, translateOperation.y()); + ArgumentCoder::encode(encoder, translateOperation.z()); + break; + } + case TransformOperation::ROTATE: + case TransformOperation::ROTATE_X: + case TransformOperation::ROTATE_Y: + case TransformOperation::ROTATE_3D: { + const auto& rotateOperation = downcast(*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(*operation); + encoder << skewOperation.angleX(); + encoder << skewOperation.angleY(); + break; + } + case TransformOperation::MATRIX: + ArgumentCoder::encode(encoder, downcast(*operation).matrix()); + break; + case TransformOperation::MATRIX_3D: + ArgumentCoder::encode(encoder, downcast(*operation).matrix()); + break; + case TransformOperation::PERSPECTIVE: + ArgumentCoder::encode(encoder, downcast(*operation).perspective()); + break; + case TransformOperation::IDENTITY: + break; + case TransformOperation::NONE: + ASSERT_NOT_REACHED(); + break; + } + } +} + +bool ArgumentCoder::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::decode(decoder, x)) + return false; + if (!ArgumentCoder::decode(decoder, y)) + return false; + if (!ArgumentCoder::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::decode(decoder, matrix)) + return false; + transformOperations.operations().append(MatrixTransformOperation::create(matrix)); + break; + } + case TransformOperation::MATRIX_3D: { + TransformationMatrix matrix; + if (!ArgumentCoder::decode(decoder, matrix)) + return false; + transformOperations.operations().append(Matrix3DTransformOperation::create(matrix)); + break; + } + case TransformOperation::PERSPECTIVE: { + Length perspective; + if (!ArgumentCoder::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(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(timingFunction); + encoder << static_cast(steps->numberOfSteps()); + encoder << steps->stepAtStart(); + break; + } + case TimingFunction::SpringFunction: { + const SpringTimingFunction* spring = static_cast(timingFunction); + encoder << spring->mass(); + encoder << spring->stiffness(); + encoder << spring->damping(); + encoder << spring->initialVelocity(); + break; + } + } +} + +bool decodeTimingFunction(Decoder& decoder, RefPtr& 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::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 animationObject = animation.animation(); + encoder.encodeEnum(animationObject->direction()); + encoder << static_cast(animationObject->fillMode()); + encoder << animationObject->duration(); + encoder << animationObject->iterationCount(); + encodeTimingFunction(encoder, animationObject->timingFunction()); + + const KeyframeValueList& keyframes = animation.keyframes(); + encoder.encodeEnum(keyframes.property()); + encoder << static_cast(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(value).value(); + break; + case AnimatedPropertyTransform: + encoder << static_cast(value).value(); + break; + case AnimatedPropertyFilter: + encoder << static_cast(value).value(); + break; + default: + break; + } + } +} + +bool ArgumentCoder::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; + RefPtr 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; + 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(keyTime, value, timingFunction.get())); + break; + } + case AnimatedPropertyTransform: { + TransformOperations transform; + if (!decoder.decode(transform)) + return false; + keyframes.insert(std::make_unique(keyTime, transform, timingFunction.get())); + break; + } + case AnimatedPropertyFilter: { + FilterOperations filter; + if (!decoder.decode(filter)) + return false; + keyframes.insert(std::make_unique(keyTime, filter, timingFunction.get())); + break; + } + default: + break; + } + } + + animation = TextureMapperAnimation(name, keyframes, boxSize, *animationObject, listsMatch, startTime, pauseTime, state); + return true; +} + +void ArgumentCoder::encode(Encoder& encoder, const TextureMapperAnimations& animations) +{ + encoder << animations.animations(); +} + +bool ArgumentCoder::decode(Decoder& decoder, TextureMapperAnimations& animations) +{ + return decoder.decode(animations.animations()); +} + +bool ArgumentCoder::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::encode(Encoder& encoder, const SurfaceUpdateInfo& surfaceUpdateInfo) +{ + SimpleArgumentCoder::encode(encoder, surfaceUpdateInfo); +} + +bool ArgumentCoder::decode(Decoder& decoder, SurfaceUpdateInfo& surfaceUpdateInfo) +{ + return SimpleArgumentCoder::decode(decoder, surfaceUpdateInfo); +} + +void ArgumentCoder::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::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::encode(Encoder& encoder, const TileUpdateInfo& updateInfo) +{ + SimpleArgumentCoder::encode(encoder, updateInfo); +} + +bool ArgumentCoder::decode(Decoder& decoder, TileUpdateInfo& updateInfo) +{ + return SimpleArgumentCoder::decode(decoder, updateInfo); +} + +void ArgumentCoder::encode(Encoder& encoder, const TileCreationInfo& updateInfo) +{ + SimpleArgumentCoder::encode(encoder, updateInfo); +} + +bool ArgumentCoder::decode(Decoder& decoder, TileCreationInfo& updateInfo) +{ + return SimpleArgumentCoder::decode(decoder, updateInfo); +} + +static void encodeCoordinatedSurface(Encoder& encoder, const RefPtr& surface) +{ + bool isValidSurface = false; + if (!surface) { + encoder << isValidSurface; + return; + } + + WebCoordinatedSurface* webCoordinatedSurface = static_cast(surface.get()); + WebCoordinatedSurface::Handle handle; + if (webCoordinatedSurface->createHandle(handle)) + isValidSurface = true; + + encoder << isValidSurface; + + if (isValidSurface) + encoder << handle; +} + +static bool decodeCoordinatedSurface(Decoder& decoder, RefPtr& 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::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(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(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::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 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 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 { + static void encode(Encoder&, const WebCore::FilterOperations&); + static bool decode(Decoder&, WebCore::FilterOperations&); +}; + +template<> struct ArgumentCoder { + static void encode(Encoder&, const WebCore::TransformOperations&); + static bool decode(Decoder&, WebCore::TransformOperations&); +}; + +template<> struct ArgumentCoder { + static void encode(Encoder&, const WebCore::TextureMapperAnimations&); + static bool decode(Decoder&, WebCore::TextureMapperAnimations&); +}; + +template<> struct ArgumentCoder { + static void encode(Encoder&, const WebCore::TextureMapperAnimation&); + static bool decode(Decoder&, WebCore::TextureMapperAnimation&); +}; + +template<> struct ArgumentCoder { + static void encode(Encoder&, const WebCore::SurfaceUpdateInfo&); + static bool decode(Decoder&, WebCore::SurfaceUpdateInfo&); +}; + +template<> struct ArgumentCoder { + static void encode(Encoder&, const WebCore::CoordinatedGraphicsLayerState&); + static bool decode(Decoder&, WebCore::CoordinatedGraphicsLayerState&); +}; + +template<> struct ArgumentCoder { + static void encode(Encoder&, const WebCore::TileUpdateInfo&); + static bool decode(Decoder&, WebCore::TileUpdateInfo&); +}; + +template<> struct ArgumentCoder { + static void encode(Encoder&, const WebCore::TileCreationInfo&); + static bool decode(Decoder&, WebCore::TileCreationInfo&); +}; + +template<> struct ArgumentCoder { + 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 +#include +#include +#include +#include + +using namespace WebCore; + +namespace WebKit { + +void CoordinatedGraphicsScene::dispatchOnMainThread(Function&& function) +{ + if (isMainThread()) { + function(); + return; + } + + RunLoop::main().dispatch([protectedThis = makeRef(*this), function = WTFMove(function)] { + function(); + }); +} + +void CoordinatedGraphicsScene::dispatchOnClientRunLoop(Function&& 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(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(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 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& layerIDs) +{ + for (auto& layerID : layerIDs) + createLayer(layerID); +} + +void CoordinatedGraphicsScene::createLayer(CoordinatedLayerID id) +{ + std::unique_ptr newLayer = std::make_unique(); + newLayer->setID(id); + newLayer->setScrollClient(this); + m_layers.add(id, WTFMove(newLayer)); +} + +void CoordinatedGraphicsScene::deleteLayers(const Vector& layerIDs) +{ + for (auto& layerID : layerIDs) + deleteLayer(layerID); +} + +void CoordinatedGraphicsScene::deleteLayer(CoordinatedLayerID layerID) +{ + std::unique_ptr 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 backingStore(CoordinatedBackingStore::create()); + m_backingStores.add(layer, backingStore); + layer->setBackingStore(backingStore); +} + +void CoordinatedGraphicsScene::removeBackingStoreIfNeeded(TextureMapperLayer* layer) +{ + RefPtr backingStore = m_backingStores.take(layer); + if (!backingStore) + return; + + layer->setBackingStore(0); +} + +void CoordinatedGraphicsScene::resetBackingStoreSizeToLayerSize(TextureMapperLayer* layer) +{ + RefPtr 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 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 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 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 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 backingStore(CoordinatedBackingStore::create()); + m_imageBackings.add(imageID, backingStore.release()); +} + +void CoordinatedGraphicsScene::updateImageBacking(CoordinatedImageBackingID imageID, PassRefPtr surface) +{ + ASSERT(m_imageBackings.contains(imageID)); + ImageBackingMap::iterator it = m_imageBackings.find(imageID); + RefPtr 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 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(); + 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> 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&& 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if USE(COORDINATED_GRAPHICS_THREADED) +#include +#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, 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&&); + + 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&); + void deleteLayers(const Vector&); + 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); + void removeUpdateAtlas(uint32_t atlasID); + + void syncImageBackings(const WebCore::CoordinatedGraphicsState&); + void createImageBacking(WebCore::CoordinatedImageBackingID); + void updateImageBacking(WebCore::CoordinatedImageBackingID, PassRefPtr); + 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 dispatchOnClientRunLoop(Function&&); + 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> m_renderQueue; + Lock m_renderQueueMutex; + + std::unique_ptr m_textureMapper; + + typedef HashMap> ImageBackingMap; + ImageBackingMap m_imageBackings; + Vector> m_releasedImageBackings; + + typedef HashMap> BackingStoreMap; + BackingStoreMap m_backingStores; + + HashSet> m_backingStoresWithPendingBuffers; + +#if USE(COORDINATED_GRAPHICS_THREADED) + typedef HashMap> PlatformLayerProxyMap; + PlatformLayerProxyMap m_platformLayerProxies; +#endif + + typedef HashMap> 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 m_rootLayer; + + typedef HashMap> LayerMap; + LayerMap m_layers; + typedef HashMap 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 + * 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 + * 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 +#include +#include +#include +#include +#include +#include + +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 + +#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::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 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::create(const IntSize& size, CoordinatedSurface::Flags flags, RefPtr bitmap) +{ + return adoptRef(*new WebCoordinatedSurface(size, flags, bitmap)); +} + +WebCoordinatedSurface::WebCoordinatedSurface(const IntSize& size, CoordinatedSurface::Flags flags, RefPtr bitmap) + : CoordinatedSurface(size, flags) + , m_bitmap(bitmap) +{ +} + +WebCoordinatedSurface::~WebCoordinatedSurface() +{ +} + +RefPtr WebCoordinatedSurface::create(const Handle& handle) +{ + RefPtr 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 passTexture, const IntRect& target, const IntPoint& sourceOffset) +{ + RefPtr texture(passTexture); + + ASSERT(m_bitmap); + RefPtr 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 + +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 create(const WebCore::IntSize&, Flags); + + // Create a shareable surface from a handle. + static RefPtr 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, const WebCore::IntRect& target, const WebCore::IntPoint& sourceOffset) override; +#endif + +private: + WebCoordinatedSurface(const WebCore::IntSize&, Flags, RefPtr); + + // Create a WebCoordinatedSurface referencing an existing ShareableBitmap. + static Ref create(const WebCore::IntSize&, Flags, RefPtr); + + std::unique_ptr createGraphicsContext(const WebCore::IntRect&); + + RefPtr 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 +#include +#include +#include + +#if USE(GLIB_EVENT_LOOP) +#include +#endif + +namespace WebKit { + +class WorkQueuePool { + WTF_MAKE_NONCOPYABLE(WorkQueuePool); + friend class NeverDestroyed; +public: + static WorkQueuePool& singleton() + { + ASSERT(isMainThread()); + static NeverDestroyed workQueuePool; + return workQueuePool; + } + + void dispatch(void* context, Function&& 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::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> m_workQueueMap; + RefPtr m_sharedWorkQueue; + unsigned m_threadCount { 0 }; + unsigned m_threadCountLimit; +}; + +CompositingRunLoop::CompositingRunLoop(std::function&& 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&& function) +{ + ASSERT(isMainThread()); + WorkQueuePool::singleton().dispatch(this, WTFMove(function)); +} + +void CompositingRunLoop::performTaskSync(Function&& 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/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.h b/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.h new file mode 100644 index 000000000..52b5d7d10 --- /dev/null +++ b/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.h @@ -0,0 +1,73 @@ +/* + * 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 CompositingRunLoop_h +#define CompositingRunLoop_h + +#if USE(COORDINATED_GRAPHICS_THREADED) + +#include +#include +#include +#include +#include +#include + +namespace WebKit { + +class CompositingRunLoop { + WTF_MAKE_NONCOPYABLE(CompositingRunLoop); + WTF_MAKE_FAST_ALLOCATED; +public: + enum UpdateTiming { + Immediate, + WaitUntilNextFrame, + }; + + CompositingRunLoop(std::function&&); + ~CompositingRunLoop(); + + void performTask(Function&&); + void performTaskSync(Function&&); + + void startUpdateTimer(UpdateTiming = Immediate); + void stopUpdateTimer(); + +private: + void updateTimerFired(); + + RunLoop::Timer m_updateTimer; + std::function m_updateFunction; + Lock m_dispatchSyncConditionMutex; + Condition m_dispatchSyncCondition; + + double m_lastUpdateTime { 0 }; +}; + +} // namespace WebKit + +#endif // USE(COORDINATED_GRAPHICS_THREADED) + +#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 +#include + +using namespace WebCore; + +namespace WebKit { + +Ref 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 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 texture, const IntRect& target, const IntPoint& sourceOffset) +{ + ASSERT(m_imageBuffer); + RefPtr 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 +#include + +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 create(const WebCore::IntSize&, WebCore::CoordinatedSurface::Flags); + + void paintToSurface(const WebCore::IntRect&, WebCore::CoordinatedSurface::Client&) override; + void copyToTexture(RefPtr, const WebCore::IntRect& target, const WebCore::IntPoint& sourceOffset) override; + +private: + ThreadSafeCoordinatedSurface(const WebCore::IntSize&, WebCore::CoordinatedSurface::Flags, std::unique_ptr); + + WebCore::GraphicsContext& beginPaint(const WebCore::IntRect&); + void endPaint(); + + std::unique_ptr 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 +#include + +#if USE(OPENGL_ES_2) +#include +#else +#include +#endif + +using namespace WebCore; + +namespace WebKit { + +Ref 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([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(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(*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 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 +#include +#include +#include +#include +#include + +namespace WebCore { +struct CoordinatedGraphicsState; +} + +namespace WebKit { + +class CoordinatedGraphicsScene; +class CoordinatedGraphicsSceneClient; + +class ThreadedCompositor : public CoordinatedGraphicsSceneClient, public ThreadSafeRefCounted { + 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 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 m_scene; + std::unique_ptr 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 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 + +#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 +#include + +#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 + +#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/Databases/IndexedDB/WebIDBResult.h b/Source/WebKit2/Shared/Databases/IndexedDB/WebIDBResult.h new file mode 100644 index 000000000..777b8e268 --- /dev/null +++ b/Source/WebKit2/Shared/Databases/IndexedDB/WebIDBResult.h @@ -0,0 +1,67 @@ +/* + * 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(INDEXED_DATABASE) + +#include "SandboxExtension.h" +#include +#include + +namespace WebKit { + +class WebIDBResult { + WTF_MAKE_NONCOPYABLE(WebIDBResult); +public: + WebIDBResult() + { + } + + WebIDBResult(const WebCore::IDBResultData& resultData) + : m_resultData(resultData) + { + } + + WebIDBResult(const WebCore::IDBResultData& resultData, SandboxExtension::HandleArray&& handles) + : m_resultData(resultData) + , m_handles(WTFMove(handles)) + { + } + + 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: + WebCore::IDBResultData m_resultData; + SandboxExtension::HandleArray m_handles; +}; + +} // namespace WebKit + +#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 -#include - -#if PLATFORM(MAC) -#include - -OBJC_CLASS NSURLDownload; -OBJC_CLASS WKDownloadAsDelegate; -#endif - -#if PLATFORM(GTK) || PLATFORM(EFL) -#include -#include -#endif - -#if USE(CFNETWORK) -#include -#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 m_sandboxExtension; - -#if PLATFORM(MAC) - RetainPtr m_nsURLDownload; - RetainPtr m_delegate; -#endif - bool m_allowOverwrite; - String m_destination; - String m_bundlePath; -#if USE(CFNETWORK) - RetainPtr m_download; - RefPtr m_authenticationClient; -#endif -#if PLATFORM(GTK) || PLATFORM(EFL) - OwnPtr m_downloadClient; - RefPtr 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 -#include -#include - -namespace WebCore { - class AuthenticationChallenge; - class Credential; -} - -namespace WebKit { - -class Download; - -class DownloadAuthenticationClient : public RefCounted, public WebCore::AuthenticationClient { -public: - static PassRefPtr create(Download* download) { return adoptRef(new DownloadAuthenticationClient(download)); } - - void detach() { m_download = 0; } - - using RefCounted::ref; - using RefCounted::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 - -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(*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(*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 -#include -#include - -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> m_downloads; -}; - -} // namespace WebKit - -#endif // DownloadManager_h diff --git a/Source/WebKit2/Shared/Downloads/gtk/DownloadSoupErrorsGtk.cpp b/Source/WebKit2/Shared/Downloads/gtk/DownloadSoupErrorsGtk.cpp deleted file mode 100644 index 0d3f9d3ed..000000000 --- a/Source/WebKit2/Shared/Downloads/gtk/DownloadSoupErrorsGtk.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2012 Intel Corporation. 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 "DownloadSoupErrors.h" - -#include -#include - -using namespace WebCore; - -namespace WebKit { - -ResourceError platformDownloadNetworkError(int errorCode, const String& failingURL, const String& localizedDescription) -{ - return downloadNetworkError(ResourceError(errorDomainDownload, errorCode, failingURL, localizedDescription)); -} - -ResourceError platformDownloadDestinationError(const ResourceResponse& response, const String& message) -{ - return downloadDestinationError(response, message); -} - -} // namespace WebKit 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 - * - * 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 -#include -#include -#include -#include -#include - -#if PLATFORM(GTK) -#include -#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 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 outputStream; - GUniqueOutPtr 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 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 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 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(handleResponseLaterCallback), this, 0); - } - - Download* m_download; - GRefPtr m_outputStream; - ResourceResponse m_response; - GRefPtr m_destinationFile; - GRefPtr 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(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 = m_resourceHandle.release(); - static_cast(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/Downloads/soup/DownloadSoupErrors.h b/Source/WebKit2/Shared/Downloads/soup/DownloadSoupErrors.h deleted file mode 100644 index 89e23e083..000000000 --- a/Source/WebKit2/Shared/Downloads/soup/DownloadSoupErrors.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2012 Intel Corporation. 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 DownloadSoupErrors_h -#define DownloadSoupErrors_h - -#include -#include - -namespace WebKit { - -WebCore::ResourceError platformDownloadNetworkError(int errorCode, const String& failingURL, const String& localizedDescription); -WebCore::ResourceError platformDownloadDestinationError(const WebCore::ResourceResponse&, const String& message); - -} // namespace WebKit - -#endif // DownloadSoupErrors_h 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 : SimpleArgumentCoder { }; +} + +#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 -#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 #include #include @@ -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 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 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 - -using namespace WebCore; - -namespace WebKit { - -BlobRegistrationData::BlobRegistrationData() -{ -} - -BlobRegistrationData::BlobRegistrationData(std::unique_ptr 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 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(items.size()); - for (size_t i = 0, count = items.size(); i < count; ++i) { - const BlobDataItem& item = items[i]; - encoder << static_cast(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(item.data->data()), item.data->length()); - break; - case BlobDataItem::File: - encoder << static_cast(item.offset); - encoder << static_cast(item.length); - encoder << item.expectedModificationTime; - encoder << item.path; - break; - case BlobDataItem::Blob: - encoder << static_cast(item.offset); - encoder << static_cast(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(); - - 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::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/FileAPI/BlobRegistrationData.h b/Source/WebKit2/Shared/FileAPI/BlobRegistrationData.h deleted file mode 100644 index 71f9c0920..000000000 --- a/Source/WebKit2/Shared/FileAPI/BlobRegistrationData.h +++ /dev/null @@ -1,61 +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. - */ - -#ifndef BlobRegistrationData_h -#define BlobRegistrationData_h - -#if ENABLE(BLOB) && ENABLE(NETWORK_PROCESS) - -#include "SandboxExtension.h" - -namespace WebCore { -class BlobData; -} - -namespace WebKit { - -class BlobRegistrationData { -WTF_MAKE_NONCOPYABLE(BlobRegistrationData); -public: - BlobRegistrationData(); - BlobRegistrationData(std::unique_ptr); - ~BlobRegistrationData(); - - void encode(IPC::ArgumentEncoder&) const; - static bool decode(IPC::ArgumentDecoder&, BlobRegistrationData&); - - std::unique_ptr releaseData() const; - const SandboxExtension::HandleArray& sandboxExtensions() const { return m_sandboxExtensions; } - -private: - mutable std::unique_ptr m_data; - SandboxExtension::HandleArray m_sandboxExtensions; -}; - -} - -#endif // ENABLE(BLOB) && ENABLE(NETWORK_PROCESS) - -#endif // BlobRegistrationData_h diff --git a/Source/WebKit2/Shared/FontInfo.cpp b/Source/WebKit2/Shared/FontInfo.cpp new file mode 100644 index 000000000..2eb9af437 --- /dev/null +++ b/Source/WebKit2/Shared/FontInfo.cpp @@ -0,0 +1,68 @@ +/* + * 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 "FontInfo.h" + +#include "WebCoreArgumentCoders.h" + +#if PLATFORM(COCOA) +#include "ArgumentCodersCF.h" +#endif + +namespace WebKit { + +void FontInfo::encode(IPC::Encoder& encoder) const +{ +#if PLATFORM(COCOA) + encoder << static_cast(fontAttributeDictionary); + if (fontAttributeDictionary) + IPC::encode(encoder, fontAttributeDictionary.get()); +#else + UNUSED_PARAM(encoder); +#endif +} + +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 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 #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 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/FrameInfoData.h b/Source/WebKit2/Shared/FrameInfoData.h new file mode 100644 index 000000000..a8283686f --- /dev/null +++ b/Source/WebKit2/Shared/FrameInfoData.h @@ -0,0 +1,48 @@ +/* + * 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 + +#include +#include + +namespace IPC { +class Decoder; +class Encoder; +} + +namespace WebKit { + +struct FrameInfoData { + void encode(IPC::Encoder&) const; + static bool decode(IPC::Decoder&, FrameInfoData&); + + 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 + +namespace WebKit { + +GamepadData::GamepadData(unsigned index, const Vector& axisValues, const Vector& buttonValues, double lastUpdateTime) + : m_index(index) + , m_axisValues(axisValues) + , m_buttonValues(buttonValues) + , m_lastUpdateTime(lastUpdateTime) +{ +} + +GamepadData::GamepadData(unsigned index, const String& id, const Vector& axisValues, const Vector& 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 +#include + +namespace IPC { +class Decoder; +class Encoder; +} + +namespace WebKit { + +class GamepadData { +public: + GamepadData() + : m_isNull(true) + { + } + + GamepadData(unsigned index, const Vector& axisValues, const Vector& buttonValues, double lastUpdateTime); + GamepadData(unsigned index, const String& id, const Vector& axisValues, const Vector& 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& axisValues() const { return m_axisValues; } + const Vector& buttonValues() const { return m_buttonValues; } + +private: + unsigned m_index; + String m_id; + Vector m_axisValues; + Vector 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/HangDetectionDisabler.h b/Source/WebKit2/Shared/HangDetectionDisabler.h new file mode 100644 index 000000000..ae8b701c6 --- /dev/null +++ b/Source/WebKit2/Shared/HangDetectionDisabler.h @@ -0,0 +1,54 @@ +/* + * 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 HangDetectionDisabler_h +#define HangDetectionDisabler_h + +namespace WebKit { + +class HangDetectionDisabler { +public: + HangDetectionDisabler(); + ~HangDetectionDisabler(); + +private: +#if PLATFORM(MAC) + bool m_clientsMayIgnoreEvents; +#endif +}; + +#if !PLATFORM(MAC) +inline HangDetectionDisabler::HangDetectionDisabler() +{ +} + +inline HangDetectionDisabler::~HangDetectionDisabler() +{ +} +#endif + +} + +#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/ImmutableDictionary.cpp b/Source/WebKit2/Shared/ImmutableDictionary.cpp deleted file mode 100644 index cac14035d..000000000 --- a/Source/WebKit2/Shared/ImmutableDictionary.cpp +++ /dev/null @@ -1,67 +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 "ImmutableDictionary.h" - -#include "APIArray.h" -#include "APIString.h" - -namespace WebKit { - -RefPtr ImmutableDictionary::create() -{ - return create({ }); -} - -RefPtr ImmutableDictionary::create(MapType map) -{ - return adoptRef(new ImmutableDictionary(std::move(map))); -} - -ImmutableDictionary::ImmutableDictionary(MapType map) - : m_map(std::move(map)) -{ -} - -ImmutableDictionary::~ImmutableDictionary() -{ -} - -PassRefPtr ImmutableDictionary::keys() const -{ - if (m_map.isEmpty()) - return API::Array::create(); - - Vector> keys; - keys.reserveInitialCapacity(m_map.size()); - - for (const auto& key : m_map.keys()) - keys.uncheckedAppend(API::String::create(key)); - - return API::Array::create(std::move(keys)); -} - -} // namespace WebKit diff --git a/Source/WebKit2/Shared/ImmutableDictionary.h b/Source/WebKit2/Shared/ImmutableDictionary.h deleted file mode 100644 index b04046842..000000000 --- a/Source/WebKit2/Shared/ImmutableDictionary.h +++ /dev/null @@ -1,93 +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 ImmutableDictionary_h -#define ImmutableDictionary_h - -#include "APIObject.h" -#include -#include -#include -#include - -namespace API { -class Array; -} - -namespace WebKit { - -// ImmutableDictionary - An immutable dictionary type suitable for vending to an API. - -class ImmutableDictionary : public API::ObjectImpl { -public: - typedef HashMap> MapType; - - static RefPtr create(); - static RefPtr create(MapType); - - virtual ~ImmutableDictionary(); - - virtual bool isMutable() { return false; } - - template - T* get(const String& key) const - { - RefPtr item = m_map.get(key); - if (!item) - return 0; - - if (item->type() != T::APIType) - return 0; - - return static_cast(item.get()); - } - - API::Object* get(const String& key) const - { - return m_map.get(key); - } - - API::Object* get(const String& key, bool& exists) const - { - auto it = m_map.find(key); - exists = it != m_map.end(); - return it->value.get(); - } - - PassRefPtr keys() const; - - size_t size() const { return m_map.size(); } - - const MapType& map() const { return m_map; } - -protected: - explicit ImmutableDictionary(MapType); - - MapType m_map; -}; - -} // namespace WebKit - -#endif // ImmutableDictionary_h diff --git a/Source/WebKit2/Shared/InteractionInformationAtPosition.h b/Source/WebKit2/Shared/InteractionInformationAtPosition.h deleted file mode 100644 index c2a0be461..000000000 --- a/Source/WebKit2/Shared/InteractionInformationAtPosition.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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 InteractionInformationAtPosition_h -#define InteractionInformationAtPosition_h - -#include "ArgumentCoders.h" -#include -#include - -#if PLATFORM(IOS) -#include -#endif - -namespace WebKit { - -#if PLATFORM(IOS) -struct InteractionInformationAtPosition { - InteractionInformationAtPosition() - : nodeAtPositionIsAssistedNode(false) - { - } - - WebCore::IntPoint point; - bool nodeAtPositionIsAssistedNode; - String clickableElementName; - String url; - Vector selectionRects; - - void encode(IPC::ArgumentEncoder&) const; - static bool decode(IPC::ArgumentDecoder&, InteractionInformationAtPosition&); -}; -#endif - -} - -#endif // InteractionInformationAtPosition_h diff --git a/Source/WebKit2/Shared/LayerTreeContext.cpp b/Source/WebKit2/Shared/LayerTreeContext.cpp new file mode 100644 index 000000000..c3174dc4c --- /dev/null +++ b/Source/WebKit2/Shared/LayerTreeContext.cpp @@ -0,0 +1,66 @@ +/* + * 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 "LayerTreeContext.h" + +#include "Decoder.h" +#include "Encoder.h" + +namespace WebKit { + +LayerTreeContext::LayerTreeContext() + : contextID(0) +{ +} + +LayerTreeContext::~LayerTreeContext() +{ +} + +void LayerTreeContext::encode(IPC::Encoder& encoder) const +{ + encoder << contextID; +} + +bool LayerTreeContext::decode(IPC::Decoder& decoder, LayerTreeContext& result) +{ + if (!decoder.decode(result.contextID)) + return false; + + return true; +} + +bool LayerTreeContext::isEmpty() const +{ + return !contextID; +} + +bool operator==(const LayerTreeContext& a, const LayerTreeContext& b) +{ + 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 +#include 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 { + 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(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 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 + +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 dataDetectionContext; +#endif +}; + +} // namespace WebKit + +#endif // LoadParameters_h diff --git a/Source/WebKit2/Shared/MutableDictionary.cpp b/Source/WebKit2/Shared/MutableDictionary.cpp deleted file mode 100644 index 2b3df7ed0..000000000 --- a/Source/WebKit2/Shared/MutableDictionary.cpp +++ /dev/null @@ -1,57 +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 "MutableDictionary.h" - -namespace WebKit { - -MutableDictionary::MutableDictionary() - : ImmutableDictionary({ }) -{ -} - -MutableDictionary::~MutableDictionary() -{ -} - -bool MutableDictionary::add(const String& key, PassRefPtr item) -{ - MapType::AddResult result = m_map.add(key, item); - return result.isNewEntry; -} - -bool MutableDictionary::set(const String& key, PassRefPtr item) -{ - MapType::AddResult result = m_map.set(key, item); - return result.isNewEntry; -} - -void MutableDictionary::remove(const String& key) -{ - m_map.remove(key); -} - -} // namespace WebKit diff --git a/Source/WebKit2/Shared/MutableDictionary.h b/Source/WebKit2/Shared/MutableDictionary.h deleted file mode 100644 index ec39e7050..000000000 --- a/Source/WebKit2/Shared/MutableDictionary.h +++ /dev/null @@ -1,56 +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 MutableDictionary_h -#define MutableDictionary_h - -#include "ImmutableDictionary.h" - -namespace WebKit { - -// MutableDictionary - A mutable dictionary type suitable for vending to an API. - -class MutableDictionary : public ImmutableDictionary { -public: - static PassRefPtr create() - { - return adoptRef(new MutableDictionary); - } - - ~MutableDictionary(); - - bool add(const String& key, PassRefPtr); - bool set(const String& key, PassRefPtr); - void remove(const String& key); - - virtual bool isMutable() { return true; } - -private: - MutableDictionary(); -}; - -} // namespace WebKit - -#endif // MutableDictionary_h diff --git a/Source/WebKit2/Shared/NativeWebGestureEvent.h b/Source/WebKit2/Shared/NativeWebGestureEvent.h new file mode 100644 index 000000000..b98b75837 --- /dev/null +++ b/Source/WebKit2/Shared/NativeWebGestureEvent.h @@ -0,0 +1,52 @@ +/* + * 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 NativeWebGestureEvent_h +#define NativeWebGestureEvent_h + +#if ENABLE(MAC_GESTURE_EVENTS) + +#include "WebEvent.h" +#include "WebGestureEvent.h" + +OBJC_CLASS NSEvent; + +namespace WebKit { + +class NativeWebGestureEvent final : public WebGestureEvent { +public: + explicit NativeWebGestureEvent(NSEvent *, NSView *); + + NSEvent *nativeEvent() const { return m_nativeEvent.get(); } + +private: + RetainPtr m_nativeEvent; +}; + +} // namespace WebKit + +#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 OBJC_CLASS NSView; -#elif PLATFORM(GTK) + +namespace WebCore { +struct KeypressCommand; +} +#endif + +#if PLATFORM(GTK) +#include "InputMethodFilter.h" #include #include -#include typedef union _GdkEvent GdkEvent; -#elif PLATFORM(EFL) -#include #endif #if PLATFORM(IOS) -OBJC_CLASS WebIOSEvent; +#include +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&); #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&& 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 m_nativeEvent; WebCore::CompositionResults m_compositionResults; bool m_fakeEventForComposition; -#elif PLATFORM(EFL) - const void* m_nativeEvent; - bool m_isFiltered; #elif PLATFORM(IOS) - RetainPtr 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 OBJC_CLASS NSView; -#elif PLATFORM(GTK) +#endif + +#if PLATFORM(GTK) #include typedef union _GdkEvent GdkEvent; -#elif PLATFORM(EFL) -#include -#include #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 m_nativeEvent; #elif PLATFORM(GTK) GUniquePtr 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 -OBJC_CLASS UIWebTouchEventsGestureRecognizer; +struct _UIWebTouchEvent; #elif PLATFORM(GTK) #include -#include -#elif PLATFORM(EFL) -#include "EwkTouchEvent.h" -#include -#include #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&&); 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 m_nativeEvent; -#elif PLATFORM(GTK) + Vector extractWebTouchPoint(const _UIWebTouchEvent*); +#endif + +#if PLATFORM(GTK) GUniquePtr m_nativeEvent; - const WebCore::GtkTouchContextHelper& m_touchContext; -#elif PLATFORM(EFL) - RefPtr 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 OBJC_CLASS NSView; -#elif PLATFORM(GTK) +#endif + +#if PLATFORM(GTK) #include typedef union _GdkEvent GdkEvent; -#elif PLATFORM(EFL) -#include -#include #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 m_nativeEvent; #elif PLATFORM(GTK) GUniquePtr 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 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 - -#if PLATFORM(MAC) -#include -#include -#include -#include -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 m_messageQueue; - -#if PLATFORM(MAC) - HashSet m_registeredSchemes; - Mutex m_registeredSchemesMutex; - - typedef HashMap> 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 protocolForID(uint64_t customProtocolID); -#else - // FIXME: Move mac specific code to CustomProtocolManagerImpl. - std::unique_ptr m_impl; -#endif -}; - -} // namespace WebKit - -#endif // ENABLE(CUSTOM_PROTOCOLS) - -#endif // CustomProtocolManager_h diff --git a/Source/WebKit2/Shared/Network/CustomProtocols/CustomProtocolManager.messages.in b/Source/WebKit2/Shared/Network/CustomProtocols/CustomProtocolManager.messages.in deleted file mode 100644 index 2376d929d..000000000 --- a/Source/WebKit2/Shared/Network/CustomProtocols/CustomProtocolManager.messages.in +++ /dev/null @@ -1,35 +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. - -#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) -} - -#endif // ENABLE(CUSTOM_PROTOCOLS) 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 -#include -#include -#include - -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(&request)); - } - - ~WebSoupRequestAsyncData() - { - if (request) - g_object_remove_weak_pointer(G_OBJECT(request), reinterpret_cast(&request)); - } - - bool requestFailed() - { - return g_cancellable_is_cancelled(cancellable.get()) || !request; - } - - GRefPtr releaseTask() - { - GTask* returnValue = task; - task = nullptr; - return adoptGRef(returnValue); - } - - GTask* task; - WebKitSoupRequestGeneric* request; - GRefPtr cancellable; - GRefPtr 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(g_type_class_ref(WEBKIT_TYPE_SOUP_REQUEST_GENERIC)); - genericRequestClass->schemes = const_cast(reinterpret_cast(m_schemes->pdata)); - static_cast(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(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 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 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(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(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 -#include -#include - -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 m_schemes; - HashMap> 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 - -#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(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 -#include - -#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 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 languages; -#endif -}; - -} // namespace WebKit - -#endif // ENABLE(NETWORK_PROCESS) - -#endif // NetworkProcessCreationParameters_h diff --git a/Source/WebKit2/Shared/Network/NetworkProcessSupplement.h b/Source/WebKit2/Shared/Network/NetworkProcessSupplement.h deleted file mode 100644 index d6fbe5bfd..000000000 --- a/Source/WebKit2/Shared/Network/NetworkProcessSupplement.h +++ /dev/null @@ -1,46 +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 NetworkProcessSupplement_h -#define NetworkProcessSupplement_h - -#include "ChildProcessSupplement.h" - -namespace WebKit { - -struct NetworkProcessCreationParameters; - -class NetworkProcessSupplement : public ChildProcessSupplement { -#if ENABLE(NETWORK_PROCESS) -public: - virtual void initialize(const NetworkProcessCreationParameters&) - { - } -#endif -}; - -} // namespace WebKit - -#endif // NetworkProcessSupplement_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(request.httpBody()); - if (request.httpBody()) { - EncoderAdapter httpBodyEncoderAdapter; - request.httpBody()->encode(httpBodyEncoderAdapter); - encoder << httpBodyEncoderAdapter.dataReference(); - - const Vector& 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 -#include -#include - -#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/OriginAndDatabases.cpp b/Source/WebKit2/Shared/OriginAndDatabases.cpp deleted file mode 100644 index 94f49b8d9..000000000 --- a/Source/WebKit2/Shared/OriginAndDatabases.cpp +++ /dev/null @@ -1,61 +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 "OriginAndDatabases.h" - -#if ENABLE(SQL_DATABASE) - -#include "WebCoreArgumentCoders.h" - -using namespace WebCore; - -namespace WebKit { - -void OriginAndDatabases::encode(IPC::ArgumentEncoder& encoder) const -{ - encoder << originIdentifier; - encoder << originQuota; - encoder << originUsage; - encoder << databases; -} - -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)) - return false; - - return true; -} - -} // namespace WebKit - -#endif // ENABLE(SQL_DATABASE) diff --git a/Source/WebKit2/Shared/OriginAndDatabases.h b/Source/WebKit2/Shared/OriginAndDatabases.h deleted file mode 100644 index 487338f95..000000000 --- a/Source/WebKit2/Shared/OriginAndDatabases.h +++ /dev/null @@ -1,56 +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 OriginAndDatabases_h -#define OriginAndDatabases_h - -#if ENABLE(SQL_DATABASE) - -#include -#include -#include - -namespace IPC { - class ArgumentDecoder; - class ArgumentEncoder; -} - -namespace WebKit { - -struct OriginAndDatabases { - void encode(IPC::ArgumentEncoder&) const; - static bool decode(IPC::ArgumentDecoder&, OriginAndDatabases&); - - String originIdentifier; - uint64_t originQuota; - uint64_t originUsage; - Vector databases; -}; - -} // namespace WebKit - -#endif // ENABLE(SQL_DATABASE) - -#endif // OriginAndDatabases_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 #include 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 @@ -67,7 +67,7 @@ NPIdentifier NPIdentifierData::createNPIdentifier() const return static_cast(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 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& 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& 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&); + void didReceiveSyncNPObjectMessageReceiverMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr&); 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 namespace WebKit { @@ -42,9 +41,9 @@ static uint64_t generateNPObjectID() return ++generateNPObjectID; } -PassRefPtr NPRemoteObjectMap::create(IPC::Connection* connection) +Ref 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 messageReceivers; - - // Gather the receivers associated with this plug-in. - for (HashMap::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 objectProxies; - for (HashSet::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 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 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& replyEncoder) +void NPRemoteObjectMap::didReceiveSyncMessage(IPC::Connection& connection, IPC::Decoder& decoder, std::unique_ptr& 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 { public: - static PassRefPtr create(IPC::Connection*); + static Ref 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&); + void didReceiveSyncMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr&); 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 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::getOrCreate(const String& return pluginModule; } - RefPtr 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 { 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& 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 createPluginInformationDictionary(const PluginModuleInfo& plugin) +Ref 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 createPluginInformationDictionary(const PluginModuleInfo& plugin, const String& frameURLString, const String& mimeType, const String& pageURLString, const String& pluginspageAttributeURLString, const String& pluginURLString, bool replacementObscured) +Ref 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 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 createPluginInformationDictionary(const String& mimeType, const String& frameURLString, const String& pageURLString) +Ref 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 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 namespace WebKit { @@ -51,12 +51,12 @@ String pluginInformationPluginspageAttributeURLKey(); String pluginInformationPluginURLKey(); String plugInInformationReplacementObscuredKey(); -PassRefPtr createPluginInformationDictionary(const PluginModuleInfo&); -PassRefPtr createPluginInformationDictionary(const PluginModuleInfo&, const String& frameURLString, const String& mimeType, const String& pageURLString, const String& pluginspageAttributeURLString, const String& pluginURLString, bool replacementObscured = false); -PassRefPtr createPluginInformationDictionary(const String& mimeType, const String& frameURLString, const String& pageURLString); +Ref createPluginInformationDictionary(const PluginModuleInfo&); +Ref createPluginInformationDictionary(const PluginModuleInfo&, const String& frameURLString, const String& mimeType, const String& pageURLString, const String& pluginspageAttributeURLString, const String& pluginURLString, bool replacementObscured = false); +Ref 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 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.cpp b/Source/WebKit2/Shared/Plugins/PluginModuleInfo.cpp deleted file mode 100644 index bb60b5d46..000000000 --- a/Source/WebKit2/Shared/Plugins/PluginModuleInfo.cpp +++ /dev/null @@ -1,32 +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 "PluginModuleInfo.h" - -namespace WebKit { - - -} 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 -#if PLATFORM(MAC) +#if PLATFORM(COCOA) #include #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 #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 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 + +using namespace WebCore; + +namespace WebKit { + +Vector pluginsDirectories() +{ + Vector result; + +#if ENABLE(NETSCAPE_PLUGIN_API) + String mozillaPaths(getenv("MOZ_PLUGIN_PATH")); + if (!mozillaPaths.isEmpty()) { + Vector 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/Plugins/unix/PluginSearchPath.h b/Source/WebKit2/Shared/Plugins/unix/PluginSearchPath.h new file mode 100644 index 000000000..25a13ec8e --- /dev/null +++ b/Source/WebKit2/Shared/Plugins/unix/PluginSearchPath.h @@ -0,0 +1,38 @@ +/* + * 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. + */ + +#ifndef PluginSearchPath_h +#define PluginSearchPath_h + +#include +#include + +namespace WebKit { + +Vector 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 +#include #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(data.data())); + return true; + } + if (data.size() != sizeof(in6_addr)) + return false; + result.value = rtc::IPAddress(*reinterpret_cast(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(&address), sizeof(address)); + return; + } + auto address = value.ipv6_address(); + encoder << IPC::DataReference(reinterpret_cast(&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(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(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(name.data()), name.size()); + if (!decoder.decode(description)) + return false; + result.description = std::string(reinterpret_cast(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(name.data()), name.length()); + encoder << IPC::DataReference(reinterpret_cast(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/RTCNetwork.h b/Source/WebKit2/Shared/RTCNetwork.h new file mode 100644 index 000000000..a030a1aeb --- /dev/null +++ b/Source/WebKit2/Shared/RTCNetwork.h @@ -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. + */ + +#pragma once + +#if USE(LIBWEBRTC) + +#include +#include +#include + +namespace IPC { +class Decoder; +class Encoder; +} + +namespace WebKit { + +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; + }; + + 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 ips; +}; + +} + +#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 #include -#include #include +#include #include -#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 { 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 m_data; size_t m_size; #else @@ -89,10 +90,12 @@ public: #endif }; - static PassRefPtr 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 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::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::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 #include -#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 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 +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace WebCore; + +#if ENABLE(ASYNC_SCROLLING) + +namespace IPC { + +template<> struct ArgumentCoder { + static void encode(Encoder&, const ScrollingStateNode&); + static bool decode(Decoder&, ScrollingStateNode&); +}; + +template<> struct ArgumentCoder { + static void encode(Encoder&, const ScrollingStateScrollingNode&); + static bool decode(Decoder&, ScrollingStateScrollingNode&); +}; + +template<> struct ArgumentCoder { + static void encode(Encoder&, const ScrollingStateFrameScrollingNode&); + static bool decode(Decoder&, ScrollingStateFrameScrollingNode&); +}; + +template<> struct ArgumentCoder { + static void encode(Encoder&, const ScrollingStateOverflowScrollingNode&); + static bool decode(Decoder&, ScrollingStateOverflowScrollingNode&); +}; + +template<> struct ArgumentCoder { + static void encode(Encoder&, const ScrollingStateFixedNode&); + static bool decode(Decoder&, ScrollingStateFixedNode&); +}; + +template<> struct ArgumentCoder { + static void encode(Encoder&, const ScrollingStateStickyNode&); + static bool decode(Decoder&, ScrollingStateStickyNode&); +}; + +} // namespace IPC + +using namespace IPC; + +void ArgumentCoder::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(node.layer()); +} + +bool ArgumentCoder::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::encode(Encoder& encoder, const ScrollingStateScrollingNode& node) +{ + encoder << static_cast(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::encode(Encoder& encoder, const ScrollingStateFrameScrollingNode& node) +{ + encoder << static_cast(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(node.scrolledContentsLayer()); + + if (node.hasChangedProperty(ScrollingStateFrameScrollingNode::CounterScrollingLayer)) + encoder << static_cast(node.counterScrollingLayer()); + + if (node.hasChangedProperty(ScrollingStateFrameScrollingNode::InsetClipLayer)) + encoder << static_cast(node.insetClipLayer()); + + if (node.hasChangedProperty(ScrollingStateFrameScrollingNode::ContentShadowLayer)) + encoder << static_cast(node.contentShadowLayer()); +} + +void ArgumentCoder::encode(Encoder& encoder, const ScrollingStateOverflowScrollingNode& node) +{ + encoder << static_cast(node); + + if (node.hasChangedProperty(ScrollingStateOverflowScrollingNode::ScrolledContentsLayer)) + encoder << static_cast(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::decode(Decoder& decoder, ScrollingStateScrollingNode& node) +{ + if (!decoder.decode(static_cast(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, setHorizontalSnapOffsets); + SCROLLING_NODE_DECODE(ScrollingStateScrollingNode::VerticalSnapOffsets, Vector, setVerticalSnapOffsets); + SCROLLING_NODE_DECODE(ScrollingStateScrollingNode::HorizontalSnapOffsetRanges, Vector>, setHorizontalSnapOffsetRanges) + SCROLLING_NODE_DECODE(ScrollingStateScrollingNode::VerticalSnapOffsetRanges, Vector>, 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::decode(Decoder& decoder, ScrollingStateFrameScrollingNode& node) +{ + if (!decoder.decode(static_cast(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::decode(Decoder& decoder, ScrollingStateOverflowScrollingNode& node) +{ + if (!decoder.decode(static_cast(node))) + return false; + + if (node.hasChangedProperty(ScrollingStateOverflowScrollingNode::ScrolledContentsLayer)) { + GraphicsLayer::PlatformLayerID layerID; + if (!decoder.decode(layerID)) + return false; + node.setScrolledContentsLayer(layerID); + } + + return true; +} + +void ArgumentCoder::encode(Encoder& encoder, const ScrollingStateFixedNode& node) +{ + encoder << static_cast(node); + + if (node.hasChangedProperty(ScrollingStateFixedNode::ViewportConstraints)) + encoder << node.viewportConstraints(); +} + +bool ArgumentCoder::decode(Decoder& decoder, ScrollingStateFixedNode& node) +{ + if (!decoder.decode(static_cast(node))) + return false; + + if (node.hasChangedProperty(ScrollingStateFixedNode::ViewportConstraints)) { + FixedPositionViewportConstraints decodedValue; + if (!decoder.decode(decodedValue)) + return false; + node.updateConstraints(decodedValue); + } + + return true; +} + +void ArgumentCoder::encode(Encoder& encoder, const ScrollingStateStickyNode& node) +{ + encoder << static_cast(node); + + if (node.hasChangedProperty(ScrollingStateStickyNode::ViewportConstraints)) + encoder << node.viewportConstraints(); +} + +bool ArgumentCoder::decode(Decoder& decoder, ScrollingStateStickyNode& node) +{ + if (!decoder.decode(static_cast(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(stateNode); + break; + case OverflowScrollingNode: + encoder << downcast(stateNode); + break; + case FixedNode: + encoder << downcast(stateNode); + break; + case StickyNode: + encoder << downcast(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(); +} + +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(); + + 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(*newNode))) + return false; + break; + case OverflowScrollingNode: + if (!decoder.decode(downcast(*newNode))) + return false; + break; + case FixedNode: + if (!decoder.decode(downcast(*newNode))) + return false; + break; + case StickyNode: + if (!decoder.decode(downcast(*newNode))) + return false; + break; + } + } + + m_scrollingStateTree->setHasNewRootStateNode(hasNewRootNode); + + // Removed nodes + HashSet 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(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(node.scrolledContentsLayer())); + + if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateFrameScrollingNode::InsetClipLayer)) + ts.dumpProperty("clip-inset-layer", static_cast(node.insetClipLayer())); + + if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateFrameScrollingNode::ContentShadowLayer)) + ts.dumpProperty("content-shadow-layer", static_cast(node.contentShadowLayer())); + + if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateFrameScrollingNode::HeaderLayer)) + ts.dumpProperty("header-layer", static_cast(node.headerLayer())); + + if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateFrameScrollingNode::FooterLayer)) + ts.dumpProperty("footer-layer", static_cast(node.footerLayer())); +} + +static void dump(TextStream& ts, const ScrollingStateOverflowScrollingNode& node, bool changedPropertiesOnly) +{ + dump(ts, static_cast(node), changedPropertiesOnly); + + if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateOverflowScrollingNode::ScrolledContentsLayer)) + ts.dumpProperty("scrolled-contents-layer", static_cast(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(node.layer())); + + switch (node.nodeType()) { + case FrameScrollingNode: + dump(ts, downcast(node), changedPropertiesOnly); + break; + case OverflowScrollingNode: + dump(ts, downcast(node), changedPropertiesOnly); + break; + case FixedNode: + dump(ts, downcast(node), changedPropertiesOnly); + break; + case StickyNode: + dump(ts, downcast(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 removedNodes; + copyToVector(stateTree.removedNodes(), removedNodes); + ts.dumpProperty>("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/Scrolling/RemoteScrollingCoordinatorTransaction.h b/Source/WebKit2/Shared/Scrolling/RemoteScrollingCoordinatorTransaction.h new file mode 100644 index 000000000..8b9b0bf87 --- /dev/null +++ b/Source/WebKit2/Shared/Scrolling/RemoteScrollingCoordinatorTransaction.h @@ -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. + */ + +#ifndef RemoteScrollingCoordinatorTransaction_h +#define RemoteScrollingCoordinatorTransaction_h + +#include + +namespace IPC { +class Decoder; +class Encoder; +} + +namespace WebKit { + +class RemoteScrollingCoordinatorTransaction { +public: +#if ENABLE(ASYNC_SCROLLING) + void setStateTreeToEncode(std::unique_ptr stateTree) { m_scrollingStateTree = WTFMove(stateTree); } + std::unique_ptr& 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 m_scrollingStateTree; +#endif // ENABLE(ASYNC_SCROLLING) +}; + +} // namespace WebKit + +#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 - -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 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& originDatas, ArrayCallback* callback) -{ - if (!callback) { - // FIXME: Log error or assert. - return; - } - - Vector> securityOrigins; - securityOrigins.reserveInitialCapacity(originDatas.size()); - - for (const auto& originData : originDatas) { - RefPtr 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/SecurityOriginData.h b/Source/WebKit2/Shared/SecurityOriginData.h deleted file mode 100644 index 96404e562..000000000 --- a/Source/WebKit2/Shared/SecurityOriginData.h +++ /dev/null @@ -1,65 +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 SecurityOriginData_h -#define SecurityOriginData_h - -#include "APIObject.h" -#include "GenericCallback.h" -#include - -namespace IPC { - class ArgumentDecoder; - class ArgumentEncoder; -} - -namespace WebKit { - -typedef GenericCallback ArrayCallback; - -struct SecurityOriginData { - static SecurityOriginData fromSecurityOrigin(const WebCore::SecurityOrigin*); - PassRefPtr securityOrigin() const; - - void encode(IPC::ArgumentEncoder&) const; - static bool decode(IPC::ArgumentDecoder&, SecurityOriginData&); - - // FIXME : 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; -}; - -void performAPICallbackWithSecurityOriginDataVector(const Vector&, ArrayCallback*); - -bool operator==(const SecurityOriginData&, const SecurityOriginData&); - -} // namespace WebKit - -#endif // SecurityOriginData_h 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 struct ArgumentCoder> { - static void encode(ArgumentEncoder& encoder, const RefPtr& 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& 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 +#include +#include +#include +#include +#include +#include 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 data; + + // File. + String filePath; + int64_t fileStart; + std::optional fileLength; + std::optional expectedFileModificationTime; + + // Blob. + String blobURLString; + }; + + void encode(IPC::Encoder&) const; + static bool decode(IPC::Decoder&, HTTPBody&); + + String contentType; + Vector elements; +}; + +struct FrameState { + void encode(IPC::Encoder&) const; + static bool decode(IPC::Decoder&, FrameState&); + + String urlString; + String originalURLString; + String referrer; + String target; + + Vector documentState; + std::optional> 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; + + // 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 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 snapshot; +#endif + +}; + +struct BackForwardListState { + void encode(IPC::Encoder&) const; + static bool decode(IPC::Decoder&, BackForwardListState&); + + Vector items; + std::optional 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 +#include "NetworkSession.h" +#include #include +#include using namespace WebCore; namespace WebKit { -const uint64_t SessionTracker::defaultSessionID; -const uint64_t SessionTracker::legacyPrivateSessionID; - -static HashMap>& staticSessionMap() -{ - ASSERT(isMainThread()); - - static NeverDestroyed>> map; - return map.get(); -} - static String& identifierBase() { - ASSERT(isMainThread()); + ASSERT(RunLoop::isMain()); static NeverDestroyed base; return base; } -const HashMap>& 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 session) +#if USE(NETWORK_SESSION) +static HashMap>& staticSessionMap() { - ASSERT(sessionID != defaultSessionID); - staticSessionMap().add(sessionID, nullptr).iterator->value = std::move(session); + ASSERT(RunLoop::isMain()); + + static NeverDestroyed>> 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&& 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 +namespace WebCore { +class NetworkStorageSession; +} + +#include #include #include -#include +#include 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>& sessionMap(); static const String& getIdentifierBase(); - static WebCore::NetworkStorageSession* session(uint64_t sessionID); - static void setSession(uint64_t sessionID, std::unique_ptr); - static void destroySession(uint64_t sessionID); static void setIdentifierBase(const String&); + +#if USE(NETWORK_SESSION) + static void setSession(WebCore::SessionID, Ref&&); + 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::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::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::createShareable(const IntSize& size, Flags flags) +RefPtr 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::create(numBytes); + RefPtr sharedMemory = SharedMemory::allocate(numBytes.unsafeGet()); if (!sharedMemory) - return 0; + return nullptr; return adoptRef(new ShareableBitmap(size, flags, sharedMemory)); } -PassRefPtr ShareableBitmap::create(const IntSize& size, Flags flags, PassRefPtr sharedMemory) +RefPtr ShareableBitmap::create(const IntSize& size, Flags flags, RefPtr 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::create(const Handle& handle, SharedMemory::Protection protection) +RefPtr ShareableBitmap::create(const Handle& handle, SharedMemory::Protection protection) { // Create the shared memory. - RefPtr 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) +ShareableBitmap::ShareableBitmap(const IntSize& size, Flags flags, RefPtr 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 -#include -#include #include #include @@ -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 create(const WebCore::IntSize&, Flags); + static RefPtr create(const WebCore::IntSize&, Flags); // Create a shareable bitmap whose backing memory can be shared with another process. - static PassRefPtr createShareable(const WebCore::IntSize&, Flags); + static RefPtr createShareable(const WebCore::IntSize&, Flags); // Create a shareable bitmap from an already existing shared memory block. - static PassRefPtr create(const WebCore::IntSize&, Flags, PassRefPtr); + static RefPtr create(const WebCore::IntSize&, Flags, RefPtr); // Create a shareable bitmap from a handle. - static PassRefPtr create(const Handle&, SharedMemory::Protection = SharedMemory::ReadWrite); + static RefPtr 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 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 createImage(); + RefPtr 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 createCairoSurface(); + RefPtr createCairoSurface(); #endif private: ShareableBitmap(const WebCore::IntSize&, Flags, void*); - ShareableBitmap(const WebCore::IntSize&, Flags, PassRefPtr); + ShareableBitmap(const WebCore::IntSize&, Flags, RefPtr); #if USE(CAIRO) - static size_t numBytesForSize(const WebCore::IntSize&); + static Checked numBytesForSize(const WebCore::IntSize&); + static Checked 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 numBytesForSize(const WebCore::IntSize& size, unsigned bytesPerPixel) { return size.area() * 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 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(info))->deref(); // Balanced by ref() in createShareableResourceDeallocator() + static_cast(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 ShareableResource::wrapInSharedBuffer() +{ + ref(); // Balanced by deref when SharedBuffer is deallocated. + +#if USE(CF) + RetainPtr deallocator = adoptCF(createShareableResourceDeallocator(this)); + RetainPtr cfData = adoptCF(CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, reinterpret_cast(data()), static_cast(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(data)->deref(); })); +#else + ASSERT_NOT_REACHED(); + return nullptr; +#endif +} -PassRefPtr ShareableResource::Handle::tryWrapInSharedBuffer() const +RefPtr ShareableResource::Handle::tryWrapInSharedBuffer() const { - RefPtr resource = ShareableResource::create(*this); + RefPtr resource = ShareableResource::map(*this); if (!resource) { LOG_ERROR("Failed to recreate ShareableResource from handle."); - return 0; + return nullptr; } - RetainPtr deallocator = adoptCF(createShareableResourceDeallocator(resource.get())); - RetainPtr data = adoptCF(CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, reinterpret_cast(resource->data()), static_cast(resource->size()), deallocator.get())); - - return SharedBuffer::wrapCFData(data.get()); + return resource->wrapInSharedBuffer(); } - -PassRefPtr ShareableResource::create(PassRefPtr sharedMemory, unsigned offset, unsigned size) + +Ref ShareableResource::create(Ref&& sharedMemory, unsigned offset, unsigned size) { - return adoptRef(new ShareableResource(sharedMemory, offset, size)); + return adoptRef(*new ShareableResource(WTFMove(sharedMemory), offset, size)); } -PassRefPtr ShareableResource::create(const Handle& handle) +RefPtr ShareableResource::map(const Handle& handle) { - RefPtr 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, unsigned offset, unsigned size) - : m_sharedMemory(sharedMemory) +ShareableResource::ShareableResource(Ref&& 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 #include #include @@ -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 tryWrapInSharedBuffer() const; + RefPtr tryWrapInSharedBuffer() const; private: friend class ShareableResource; @@ -65,10 +63,10 @@ public: }; // Create a shareable resource that uses malloced memory. - static PassRefPtr create(PassRefPtr, unsigned offset, unsigned size); + static Ref create(Ref&&, unsigned offset, unsigned size); // Create a shareable resource from a handle. - static PassRefPtr create(const Handle&); + static RefPtr map(const Handle&); // Create a handle. bool createHandle(Handle&); @@ -79,9 +77,10 @@ public: unsigned size() const; private: - ShareableResource(PassRefPtr, unsigned offset, unsigned size); + ShareableResource(Ref&&, unsigned offset, unsigned size); + RefPtr wrapInSharedBuffer(); - RefPtr m_sharedMemory; + Ref 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 #include #include @@ -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 statisticsNumbers; HashMap 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 : SimpleArgumentCoder { }; }; - -#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 #include +#include 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&& object) + : m_object(WTFMove(object)) { } @@ -52,49 +68,90 @@ UserData::~UserData() { } -RefPtr UserData::transform(API::Object* object, const std::function (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(object); - if (object->type() == API::Object::Type::Array) { - auto& array = static_cast(*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(object); + + for (const auto& keyValuePair : dictionary.map()) { + if (!keyValuePair.value) + continue; + + if (shouldTransform(*keyValuePair.value, transformer)) + return true; + } + } + + return transformer.shouldTransformObject(object); +} + +static RefPtr transformGraph(API::Object& object, const UserData::Transformer& transformer) +{ + if (object.type() == API::Object::Type::Array) { + auto& array = static_cast(object); Vector> 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(*object); + if (object.type() == API::Object::Type::Dictionary) { + auto& dictionary = static_cast(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 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(object).encode(encoder); break; + case API::Object::Type::CertificateInfo: { + const auto& certificateInfo = static_cast(object); + encoder << certificateInfo.certificateInfo(); + break; + } + case API::Object::Type::Data: static_cast(object).encode(encoder); break; case API::Object::Type::Dictionary: { - auto& dictionary = static_cast(object); + auto& dictionary = static_cast(object); auto& map = dictionary.map(); encoder << static_cast(map.size()); @@ -138,16 +201,43 @@ void UserData::encode(IPC::ArgumentEncoder& encoder, const API::Object& object) break; } + case API::Object::Type::Double: + static_cast(object).encode(encoder); + break; + case API::Object::Type::Error: static_cast(object).encode(encoder); break; - case API::Object::Type::FrameHandle: { - auto& frameHandle = static_cast(object); - encoder << frameHandle.frameID(); + case API::Object::Type::FrameHandle: + static_cast(object).encode(encoder); + break; + + case API::Object::Type::Image: { + auto& image = static_cast(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(object).encode(encoder); + break; + + case API::Object::Type::PageHandle: + static_cast(object).encode(encoder); + break; + case API::Object::Type::Point: static_cast(object).encode(encoder); break; @@ -156,8 +246,40 @@ void UserData::encode(IPC::ArgumentEncoder& encoder, const API::Object& object) static_cast(object).encode(encoder); break; + case API::Object::Type::RenderLayer: { + auto& renderLayer = static_cast(object); + + encode(encoder, renderLayer.renderer()); + encoder << renderLayer.isReflection(); + encoder << renderLayer.isClipping(); + encoder << renderLayer.isClipped(); + encoder << static_cast(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(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(object); + auto& serializedScriptValue = static_cast(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(object).encode(encoder); break; - } case API::Object::Type::URLRequest: static_cast(object).encode(encoder); @@ -189,12 +310,24 @@ void UserData::encode(IPC::ArgumentEncoder& encoder, const API::Object& object) static_cast(object).encode(encoder); break; + case API::Object::Type::UserContentURLPattern: { + auto& urlPattern = static_cast(object); + encoder << urlPattern.patternString(); + break; + } + +#if PLATFORM(COCOA) + case API::Object::Type::ObjCObjectGraph: + static_cast(object).encode(encoder); + break; +#endif + default: ASSERT_NOT_REACHED(); } } -bool UserData::decode(IPC::ArgumentDecoder& decoder, RefPtr& result) +bool UserData::decode(IPC::Decoder& decoder, RefPtr& result) { API::Object::Type type; if (!decoder.decodeEnum(type)) @@ -212,10 +345,10 @@ bool UserData::decode(IPC::ArgumentDecoder& decoder, RefPtr& 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& 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& 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& 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& 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& result return false; break; + case API::Object::Type::RenderLayer: { + RefPtr renderer; + bool isReflection; + bool isClipping; + bool isClipped; + uint32_t compositingLayerTypeAsUInt32; + WebCore::IntRect absoluteBoundingBox; + double backingStoreMemoryEstimate; + RefPtr negativeZOrderList; + RefPtr normalFlowList; + RefPtr positiveZOrderList; + RefPtr 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(renderer), isReflection, isClipping, isClipped, static_cast(compositingLayerTypeAsUInt32), absoluteBoundingBox, backingStoreMemoryEstimate, static_pointer_cast(negativeZOrderList), static_pointer_cast(normalFlowList), static_pointer_cast(positiveZOrderList), static_pointer_cast(frameContentsLayer)); + break; + } + + case API::Object::Type::RenderObject: { + String name; + String textSnippet; + String elementTagName; + String elementID; + unsigned textLength; + RefPtr elementClassNames; + WebCore::IntPoint absolutePosition; + WebCore::IntRect frameRect; + RefPtr 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(elementClassNames), absolutePosition, frameRect, textSnippet, textLength, static_pointer_cast(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& 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 +#include "APIObject.h" #include -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&&); ~UserData(); - static RefPtr transform(API::Object*, const std::function (const API::Object&)> transformer); + struct Transformer { + virtual ~Transformer() { } + virtual bool shouldTransformObject(const API::Object&) const = 0; + virtual RefPtr transformObject(API::Object&) const = 0; + }; + static RefPtr 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&); - static bool decode(IPC::ArgumentDecoder&, RefPtr&); +private: + static void encode(IPC::Encoder&, const API::Object&); RefPtr 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 -class UserMessageEncoder { -public: - bool baseEncode(IPC::ArgumentEncoder& encoder, const Owner& coder, API::Object::Type& type) const - { - if (!m_root) { - encoder << static_cast(API::Object::Type::Null); - return true; - } - - type = m_root->type(); - encoder << static_cast(type); - - switch (type) { - case API::Object::Type::Array: { - API::Array* array = static_cast(m_root); - encoder << static_cast(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(m_root); - const ImmutableDictionary::MapType& map = dictionary->map(); - encoder << static_cast(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(m_root); - encoder << string->string(); - return true; - } - case API::Object::Type::SerializedScriptValue: { - WebSerializedScriptValue* scriptValue = static_cast(m_root); - encoder << scriptValue->dataReference(); - return true; - } - case API::Object::Type::Boolean: { - API::Boolean* booleanObject = static_cast(m_root); - encoder << booleanObject->value(); - return true; - } - case API::Object::Type::Double: { - API::Double* doubleObject = static_cast(m_root); - encoder << doubleObject->value(); - return true; - } - case API::Object::Type::UInt64: { - API::UInt64* uint64Object = static_cast(m_root); - encoder << uint64Object->value(); - return true; - } - case API::Object::Type::Point: { - API::Point* pointObject = static_cast(m_root); - encoder << pointObject->point().x; - encoder << pointObject->point().y; - return true; - } - case API::Object::Type::Size: { - API::Size* sizeObject = static_cast(m_root); - encoder << sizeObject->size().width; - encoder << sizeObject->size().height; - return true; - } - case API::Object::Type::Rect: { - API::Rect* rectObject = static_cast(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(m_root); - encoder << Owner(coder, renderLayer->renderer()); - encoder << renderLayer->isReflection(); - encoder << renderLayer->isClipping(); - encoder << renderLayer->isClipped(); - encoder << static_cast(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(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(m_root); - encoder << urlObject->string(); - return true; - } - case API::Object::Type::URLRequest: { - API::URLRequest* urlRequestObject = static_cast(m_root); - encoder << urlRequestObject->resourceRequest(); - return true; - } - case API::Object::Type::URLResponse: { - API::URLResponse* urlResponseObject = static_cast(m_root); - encoder << urlResponseObject->resourceResponse(); - return true; - } - case API::Object::Type::UserContentURLPattern: { - WebUserContentURLPattern* urlPattern = static_cast(m_root); - encoder << urlPattern->patternString(); - return true; - } - case API::Object::Type::Image: { - WebImage* image = static_cast(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(m_root); - encoder << data->dataReference(); - return true; - } - case API::Object::Type::CertificateInfo: { - WebCertificateInfo* certificateInfo = static_cast(m_root); - encoder << certificateInfo->certificateInfo(); - return true; - } - case API::Object::Type::Error: { - API::Error* errorObject = static_cast(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 -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(typeAsUInt32); - - switch (type) { - case API::Object::Type::Array: { - uint64_t size; - if (!decoder.decode(size)) - return false; - - Vector> vector; - for (size_t i = 0; i < size; ++i) { - RefPtr 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 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 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 renderer; - bool isReflection; - bool isClipping; - bool isClipped; - uint32_t compositingLayerTypeAsUInt32; - WebCore::IntRect absoluteBoundingBox; - RefPtr negativeZOrderList; - RefPtr normalFlowList; - RefPtr 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(renderer), isReflection, isClipping, isClipped, static_cast(compositingLayerTypeAsUInt32), - absoluteBoundingBox, static_pointer_cast(negativeZOrderList), static_pointer_cast(normalFlowList), - static_pointer_cast(positiveZOrderList)); - break; - } - case API::Object::Type::RenderObject: { - String name; - String elementTagName; - String elementID; - RefPtr elementClassNames; - WebCore::IntPoint absolutePosition; - WebCore::IntRect frameRect; - RefPtr 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(elementClassNames), absolutePosition, frameRect, static_pointer_cast(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& root) - : m_root(root) - { - } - - RefPtr& 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 + +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 +#include +#include + +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 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 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::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::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 #include +namespace API { +class Data; +} + namespace IPC { - class ArgumentDecoder; - class ArgumentEncoder; +class Decoder; +class Encoder; } namespace WebKit { class WebBackForwardListItem : public API::ObjectImpl { public: - static PassRefPtr 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 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& 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 snapshot) { m_itemState.snapshot = snapshot; } +#endif - void encode(IPC::ArgumentEncoder&) const; - static PassRefPtr 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 m_backForwardData; - String m_snapshotUUID; + explicit WebBackForwardListItem(BackForwardListItemState&&, uint64_t pageID); + + BackForwardListItemState m_itemState; + uint64_t m_pageID; }; typedef Vector> BackForwardListItemVector; diff --git a/Source/WebKit2/Shared/WebBatteryStatus.cpp b/Source/WebKit2/Shared/WebBatteryStatus.cpp deleted file mode 100644 index d012d7063..000000000 --- a/Source/WebKit2/Shared/WebBatteryStatus.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2012 Intel Corporation. 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 "WebBatteryStatus.h" - -#if ENABLE(BATTERY_STATUS) - -#include "ArgumentCoders.h" -#include "Arguments.h" - -namespace WebKit { - -WebBatteryStatus::WebBatteryStatus(bool isCharging, double chargingTime, double dischargingTime, double level) -{ - m_data.isCharging = isCharging; - m_data.chargingTime = chargingTime; - m_data.dischargingTime = dischargingTime; - m_data.level = level; -} - -WebBatteryStatus::~WebBatteryStatus() -{ -} - -void WebBatteryStatus::Data::encode(IPC::ArgumentEncoder& encoder) const -{ - encoder << isCharging; - encoder << chargingTime; - encoder << dischargingTime; - encoder << level; -} - -bool WebBatteryStatus::Data::decode(IPC::ArgumentDecoder& decoder, Data& result) -{ - if (!decoder.decode(result.isCharging)) - return false; - if (!decoder.decode(result.chargingTime)) - return false; - if (!decoder.decode(result.dischargingTime)) - return false; - if (!decoder.decode(result.level)) - return false; - - return true; -} - -} // namespace WebKit - -#endif // ENABLE(BATTERY_STATUS) diff --git a/Source/WebKit2/Shared/WebBatteryStatus.h b/Source/WebKit2/Shared/WebBatteryStatus.h deleted file mode 100644 index aa60b8fa7..000000000 --- a/Source/WebKit2/Shared/WebBatteryStatus.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2012 Intel Corporation. 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 WebBatteryStatus_h -#define WebBatteryStatus_h - -#if ENABLE(BATTERY_STATUS) - -#include "APIObject.h" -#include "ArgumentDecoder.h" -#include "ArgumentEncoder.h" -#include - -namespace WebKit { - -class WebBatteryStatus : public API::ObjectImpl { -public: - struct Data { - void encode(IPC::ArgumentEncoder&) const; - static bool decode(IPC::ArgumentDecoder&, Data&); - - bool isCharging; - double chargingTime; - double dischargingTime; - double level; - }; - - static PassRefPtr 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; } - -private: - WebBatteryStatus(bool isCharging, double chargingTime, double dischargingTime, double level); - - Data m_data; -}; - -} // namespace WebKit - -#endif // ENABLE(BATTERY_STATUS) - -#endif // WebBatteryStatus_h 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 -#include +#include namespace WebKit { class WebCertificateInfo : public API::ObjectImpl { public: - static PassRefPtr create(const WebCore::CertificateInfo& info) + static Ref 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::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(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(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(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(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 +#include + +namespace WebKit { + +class WebCompiledContentExtension final : public WebCore::ContentExtensions::CompiledContentExtension { +public: + static Ref 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 + +namespace IPC { +class Decoder; +class Encoder; +} + +namespace WebKit { + +class WebCompiledContentExtensionData { +public: + WebCompiledContentExtensionData() + { + } + + WebCompiledContentExtensionData(RefPtr&& 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 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 @@ -51,11 +52,7 @@ void WebConnection::postMessage(const String& messageName, API::Object* messageB if (!hasValidConnection()) return; - auto encoder = std::make_unique(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 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 namespace WebKit { +class UserData; class WebConnection : public API::ObjectImpl, 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&) = 0; + virtual RefPtr transformHandlesToObjects(API::Object*) = 0; + virtual RefPtr 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 -#include namespace WebKit { @@ -50,7 +49,7 @@ PassRefPtr WebContextMenuItem::create(const String& title, b for (size_t i = 0; i < size; ++i) { WebContextMenuItem* item = submenuItems->at(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 WebContextMenuItem::submenuItemsAsAPIArray() const +Ref WebContextMenuItem::submenuItemsAsAPIArray() const { if (m_webContextMenuItemData.type() != WebCore::SubmenuType) return API::Array::create(); @@ -73,7 +72,7 @@ PassRefPtr 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 { public: - static PassRefPtr create(const WebContextMenuItemData& data) + static Ref create(const WebContextMenuItemData& data) { - return adoptRef(new WebContextMenuItem(data)); + return adoptRef(*new WebContextMenuItem(data)); } + static PassRefPtr create(const String& title, bool enabled, API::Array* submenuItems); static WebContextMenuItem* separatorItem(); - PassRefPtr submenuItemsAsAPIArray() const; + Ref 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 #include @@ -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& coreSubmenu = item.subMenuItems(); -#else - Vector 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 kitItems(const Vector& coreItemVector, WebCore::ContextMenu* menu) +Vector kitItems(const Vector& coreItemVector) { Vector 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 +#include #include 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& 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 m_userData; }; -Vector kitItems(const Vector&, WebCore::ContextMenu*); +Vector kitItems(const Vector&); Vector coreItems(const Vector&); } // 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 +#include #include #include #include #include #include #include -#include +#include +#include #include +#include #include #include #include #include #include -#include #include -#include -#include -#include #include +#include #include +#include #include #include +#include #include +#include #include #include #include #include +#include +#include #include +#include +#include #include #include #include #include #include #include +#include +#include #include #include +#if PLATFORM(COCOA) +#include "ArgumentCodersCF.h" +#include "ArgumentCodersMac.h" +#endif + #if PLATFORM(IOS) #include +#include #include #include #include #endif // PLATFORM(IOS) +#if ENABLE(WIRELESS_PLAYBACK_TARGET) +#include +#endif + +#if ENABLE(MEDIA_SESSION) +#include +#endif + +#if ENABLE(MEDIA_STREAM) +#include +#include +#endif + using namespace WebCore; using namespace WebKit; namespace IPC { -void ArgumentCoder::encode(ArgumentEncoder& encoder, const AffineTransform& affineTransform) +void ArgumentCoder::encode(Encoder& encoder, const MonotonicTime& time) +{ + encoder << time.secondsSinceEpoch().value(); +} + +bool ArgumentCoder::decode(Decoder& decoder, MonotonicTime& time) +{ + double value; + if (!decoder.decode(value)) + return false; + + time = MonotonicTime::fromRawSeconds(value); + return true; +} + +void ArgumentCoder::encode(Encoder& encoder, const Seconds& seconds) +{ + encoder << seconds.value(); +} + +bool ArgumentCoder::decode(Decoder& decoder, Seconds& seconds) +{ + double value; + if (!decoder.decode(value)) + return false; + + seconds = Seconds(value); + return true; +} + +void ArgumentCoder::encode(Encoder& encoder, const AffineTransform& affineTransform) { SimpleArgumentCoder::encode(encoder, affineTransform); } -bool ArgumentCoder::decode(ArgumentDecoder& decoder, AffineTransform& affineTransform) +bool ArgumentCoder::decode(Decoder& decoder, AffineTransform& affineTransform) { return SimpleArgumentCoder::decode(decoder, affineTransform); } +void ArgumentCoder::encode(Encoder& encoder, const EventTrackingRegions& eventTrackingRegions) +{ + encoder << eventTrackingRegions.asynchronousDispatchRegion; + encoder << eventTrackingRegions.eventSpecificSynchronousDispatchRegions; +} + +bool ArgumentCoder::decode(Decoder& decoder, EventTrackingRegions& eventTrackingRegions) +{ + Region asynchronousDispatchRegion; + if (!decoder.decode(asynchronousDispatchRegion)) + return false; + HashMap eventSpecificSynchronousDispatchRegions; + if (!decoder.decode(eventSpecificSynchronousDispatchRegions)) + return false; + eventTrackingRegions.asynchronousDispatchRegion = WTFMove(asynchronousDispatchRegion); + eventTrackingRegions.eventSpecificSynchronousDispatchRegions = WTFMove(eventSpecificSynchronousDispatchRegions); + return true; +} + +void ArgumentCoder::encode(Encoder& encoder, const TransformationMatrix& 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(); +} + +bool ArgumentCoder::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::encode(Encoder& encoder, const LinearTimingFunction& timingFunction) +{ + encoder.encodeEnum(timingFunction.type()); +} + +bool ArgumentCoder::decode(Decoder&, LinearTimingFunction&) +{ + // Type is decoded by the caller. Nothing else to decode. + return true; +} -void ArgumentCoder::encode(ArgumentEncoder& encoder, const TransformationMatrix& transformationMatrix) +void ArgumentCoder::encode(Encoder& encoder, const CubicBezierTimingFunction& timingFunction) { - SimpleArgumentCoder::encode(encoder, transformationMatrix); + encoder.encodeEnum(timingFunction.type()); + + encoder << timingFunction.x1(); + encoder << timingFunction.y1(); + encoder << timingFunction.x2(); + encoder << timingFunction.y2(); + + encoder.encodeEnum(timingFunction.timingFunctionPreset()); } -bool ArgumentCoder::decode(ArgumentDecoder& decoder, TransformationMatrix& transformationMatrix) +bool ArgumentCoder::decode(Decoder& decoder, CubicBezierTimingFunction& timingFunction) { - return SimpleArgumentCoder::decode(decoder, transformationMatrix); + // 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::encode(Encoder& encoder, const StepsTimingFunction& timingFunction) +{ + encoder.encodeEnum(timingFunction.type()); + + encoder << timingFunction.numberOfSteps(); + encoder << timingFunction.stepAtStart(); +} + +bool ArgumentCoder::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::encode(ArgumentEncoder& encoder, const FloatPoint& floatPoint) +void ArgumentCoder::encode(Encoder& encoder, const SpringTimingFunction& timingFunction) +{ + encoder.encodeEnum(timingFunction.type()); + + encoder << timingFunction.mass(); + encoder << timingFunction.stiffness(); + encoder << timingFunction.damping(); + encoder << timingFunction.initialVelocity(); +} + +bool ArgumentCoder::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::encode(Encoder& encoder, const FloatPoint& floatPoint) { SimpleArgumentCoder::encode(encoder, floatPoint); } -bool ArgumentCoder::decode(ArgumentDecoder& decoder, FloatPoint& floatPoint) +bool ArgumentCoder::decode(Decoder& decoder, FloatPoint& floatPoint) { return SimpleArgumentCoder::decode(decoder, floatPoint); } -void ArgumentCoder::encode(ArgumentEncoder& encoder, const FloatPoint3D& floatPoint) +void ArgumentCoder::encode(Encoder& encoder, const FloatPoint3D& floatPoint) { SimpleArgumentCoder::encode(encoder, floatPoint); } -bool ArgumentCoder::decode(ArgumentDecoder& decoder, FloatPoint3D& floatPoint) +bool ArgumentCoder::decode(Decoder& decoder, FloatPoint3D& floatPoint) { return SimpleArgumentCoder::decode(decoder, floatPoint); } -void ArgumentCoder::encode(ArgumentEncoder& encoder, const FloatRect& floatRect) +void ArgumentCoder::encode(Encoder& encoder, const FloatRect& floatRect) { SimpleArgumentCoder::encode(encoder, floatRect); } -bool ArgumentCoder::decode(ArgumentDecoder& decoder, FloatRect& floatRect) +bool ArgumentCoder::decode(Decoder& decoder, FloatRect& floatRect) { return SimpleArgumentCoder::decode(decoder, floatRect); } -void ArgumentCoder::encode(ArgumentEncoder& encoder, const FloatSize& floatSize) +void ArgumentCoder::encode(Encoder& encoder, const FloatSize& floatSize) { SimpleArgumentCoder::encode(encoder, floatSize); } -bool ArgumentCoder::decode(ArgumentDecoder& decoder, FloatSize& floatSize) +bool ArgumentCoder::decode(Decoder& decoder, FloatSize& floatSize) { return SimpleArgumentCoder::decode(decoder, floatSize); } +void ArgumentCoder::encode(Encoder& encoder, const FloatRoundedRect& roundedRect) +{ + SimpleArgumentCoder::encode(encoder, roundedRect); +} + +bool ArgumentCoder::decode(Decoder& decoder, FloatRoundedRect& roundedRect) +{ + return SimpleArgumentCoder::decode(decoder, roundedRect); +} + #if PLATFORM(IOS) -void ArgumentCoder::encode(ArgumentEncoder& encoder, const FloatQuad& floatQuad) +void ArgumentCoder::encode(Encoder& encoder, const FloatQuad& floatQuad) { SimpleArgumentCoder::encode(encoder, floatQuad); } -bool ArgumentCoder::decode(ArgumentDecoder& decoder, FloatQuad& floatQuad) +bool ArgumentCoder::decode(Decoder& decoder, FloatQuad& floatQuad) { return SimpleArgumentCoder::decode(decoder, floatQuad); } -void ArgumentCoder::encode(ArgumentEncoder& encoder, const ViewportArguments& viewportArguments) +void ArgumentCoder::encode(Encoder& encoder, const ViewportArguments& viewportArguments) { SimpleArgumentCoder::encode(encoder, viewportArguments); } -bool ArgumentCoder::decode(ArgumentDecoder& decoder, ViewportArguments& viewportArguments) +bool ArgumentCoder::decode(Decoder& decoder, ViewportArguments& viewportArguments) { return SimpleArgumentCoder::decode(decoder, viewportArguments); } #endif // PLATFORM(IOS) -void ArgumentCoder::encode(ArgumentEncoder& encoder, const IntPoint& intPoint) +void ArgumentCoder::encode(Encoder& encoder, const IntPoint& intPoint) { SimpleArgumentCoder::encode(encoder, intPoint); } -bool ArgumentCoder::decode(ArgumentDecoder& decoder, IntPoint& intPoint) +bool ArgumentCoder::decode(Decoder& decoder, IntPoint& intPoint) { return SimpleArgumentCoder::decode(decoder, intPoint); } -void ArgumentCoder::encode(ArgumentEncoder& encoder, const IntRect& intRect) +void ArgumentCoder::encode(Encoder& encoder, const IntRect& intRect) { SimpleArgumentCoder::encode(encoder, intRect); } -bool ArgumentCoder::decode(ArgumentDecoder& decoder, IntRect& intRect) +bool ArgumentCoder::decode(Decoder& decoder, IntRect& intRect) { return SimpleArgumentCoder::decode(decoder, intRect); } -void ArgumentCoder::encode(ArgumentEncoder& encoder, const IntSize& intSize) +void ArgumentCoder::encode(Encoder& encoder, const IntSize& intSize) { SimpleArgumentCoder::encode(encoder, intSize); } -bool ArgumentCoder::decode(ArgumentDecoder& decoder, IntSize& intSize) +bool ArgumentCoder::decode(Decoder& decoder, IntSize& intSize) { return SimpleArgumentCoder::decode(decoder, intSize); } -void ArgumentCoder::encode(ArgumentEncoder& encoder, const Length& length) +void ArgumentCoder::encode(Encoder& encoder, const LayoutSize& layoutSize) +{ + SimpleArgumentCoder::encode(encoder, layoutSize); +} + +bool ArgumentCoder::decode(Decoder& decoder, LayoutSize& layoutSize) +{ + return SimpleArgumentCoder::decode(decoder, layoutSize); +} + + +void ArgumentCoder::encode(Encoder& encoder, const LayoutPoint& layoutPoint) +{ + SimpleArgumentCoder::encode(encoder, layoutPoint); +} + +bool ArgumentCoder::decode(Decoder& decoder, LayoutPoint& layoutPoint) +{ + return SimpleArgumentCoder::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::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::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::encode(Encoder& encoder, const RecentSearch& recentSearch) +{ + encoder << recentSearch.string << recentSearch.time; +} + +bool ArgumentCoder::decode(Decoder& decoder, RecentSearch& recentSearch) +{ + if (!decoder.decode(recentSearch.string)) + return false; + + if (!decoder.decode(recentSearch.time)) + return false; + + return true; +} + +template<> struct ArgumentCoder { + static void encode(Encoder&, const Region::Span&); + static bool decode(Decoder&, Region::Span&); +}; + +void ArgumentCoder::encode(Encoder& encoder, const Region::Span& span) +{ + encoder << span.y; + encoder << (uint64_t)span.segmentIndex; +} + +bool ArgumentCoder::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::encode(Encoder& encoder, const Region& region) +{ + encoder.encode(region.shapeSegments()); + encoder.encode(region.shapeSpans()); +} + +bool ArgumentCoder::decode(Decoder& decoder, Region& region) +{ + Vector segments; + if (!decoder.decode(segments)) + return false; + + Vector spans; + if (!decoder.decode(spans)) + return false; + + region.setShapeSegments(segments); + region.setShapeSpans(spans); + region.updateBoundsFromShape(); + + if (!region.isValid()) + return false; + + return true; +} + +void ArgumentCoder::encode(Encoder& encoder, const Length& length) { SimpleArgumentCoder::encode(encoder, length); } -bool ArgumentCoder::decode(ArgumentDecoder& decoder, Length& length) +bool ArgumentCoder::decode(Decoder& decoder, Length& length) { return SimpleArgumentCoder::decode(decoder, length); } -void ArgumentCoder::encode(ArgumentEncoder& encoder, const ViewportAttributes& viewportAttributes) +void ArgumentCoder::encode(Encoder& encoder, const ViewportAttributes& viewportAttributes) { SimpleArgumentCoder::encode(encoder, viewportAttributes); } -bool ArgumentCoder::decode(ArgumentDecoder& decoder, ViewportAttributes& viewportAttributes) +bool ArgumentCoder::decode(Decoder& decoder, ViewportAttributes& viewportAttributes) { return SimpleArgumentCoder::decode(decoder, viewportAttributes); } -void ArgumentCoder::encode(ArgumentEncoder& encoder, const MimeClassInfo& mimeClassInfo) +void ArgumentCoder::encode(Encoder& encoder, const MimeClassInfo& mimeClassInfo) { encoder << mimeClassInfo.type << mimeClassInfo.desc << mimeClassInfo.extensions; } -bool ArgumentCoder::decode(ArgumentDecoder& decoder, MimeClassInfo& mimeClassInfo) +bool ArgumentCoder::decode(Decoder& decoder, MimeClassInfo& mimeClassInfo) { if (!decoder.decode(mimeClassInfo.type)) return false; @@ -239,12 +700,21 @@ bool ArgumentCoder::decode(ArgumentDecoder& decoder, MimeClassInf } -void ArgumentCoder::encode(ArgumentEncoder& encoder, const PluginInfo& pluginInfo) +void ArgumentCoder::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::decode(ArgumentDecoder& decoder, PluginInfo& pluginInfo) + +bool ArgumentCoder::decode(Decoder& decoder, PluginInfo& pluginInfo) { if (!decoder.decode(pluginInfo.name)) return false; @@ -256,28 +726,24 @@ bool ArgumentCoder::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::encode(ArgumentEncoder& encoder, const HTTPHeaderMap& headerMap) -{ - encoder << static_cast&>(headerMap); -} - -bool ArgumentCoder::decode(ArgumentDecoder& decoder, HTTPHeaderMap& headerMap) -{ - return decoder.decode(static_cast&>(headerMap)); -} - - -void ArgumentCoder::encode(ArgumentEncoder& encoder, const AuthenticationChallenge& challenge) +void ArgumentCoder::encode(Encoder& encoder, const AuthenticationChallenge& challenge) { encoder << challenge.protectionSpace() << challenge.proposedCredential() << challenge.previousFailureCount() << challenge.failureResponse() << challenge.error(); } -bool ArgumentCoder::decode(ArgumentDecoder& decoder, AuthenticationChallenge& challenge) +bool ArgumentCoder::decode(Decoder& decoder, AuthenticationChallenge& challenge) { ProtectionSpace protectionSpace; if (!decoder.decode(protectionSpace)) @@ -304,15 +770,29 @@ bool ArgumentCoder::decode(ArgumentDecoder& decoder, Au } -void ArgumentCoder::encode(ArgumentEncoder& encoder, const ProtectionSpace& space) +void ArgumentCoder::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::decode(ArgumentDecoder& decoder, ProtectionSpace& space) +bool ArgumentCoder::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::decode(ArgumentDecoder& decoder, Protection return true; } -void ArgumentCoder::encode(ArgumentEncoder& encoder, const Credential& credential) +void ArgumentCoder::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::decode(ArgumentDecoder& decoder, Credential& credential) +bool ArgumentCoder::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::decode(ArgumentDecoder& decoder, Credential& cre return true; } -static void encodeImage(ArgumentEncoder& encoder, Image* image) +static void encodeImage(Encoder& encoder, Image& image) { - RefPtr bitmap = ShareableBitmap::createShareable(image->size(), ShareableBitmap::SupportsAlpha); - bitmap->createGraphicsContext()->drawImage(image, ColorSpaceDeviceRGB, IntPoint()); + RefPtr 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) +static bool decodeImage(Decoder& decoder, RefPtr& image) { ShareableBitmap::Handle handle; if (!decoder.decode(handle)) @@ -387,8 +881,31 @@ static bool decodeImage(ArgumentDecoder& decoder, RefPtr& 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 = nullptr; + + bool hasImage; + if (!decoder.decode(hasImage)) + return false; + + if (!hasImage) + return true; + + return decodeImage(decoder, image); +} + #if !PLATFORM(IOS) -void ArgumentCoder::encode(ArgumentEncoder& encoder, const Cursor& cursor) +void ArgumentCoder::encode(Encoder& encoder, const Cursor& cursor) { encoder.encodeEnum(cursor.type()); @@ -401,11 +918,14 @@ void ArgumentCoder::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::decode(ArgumentDecoder& decoder, Cursor& cursor) +bool ArgumentCoder::decode(Decoder& decoder, Cursor& cursor) { Cursor::Type type; if (!decoder.decodeEnum(type)) @@ -444,249 +964,67 @@ bool ArgumentCoder::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::encode(ArgumentEncoder& encoder, const ResourceRequest& resourceRequest) +void ArgumentCoder::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(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::decode(ArgumentDecoder& decoder, ResourceRequest& resourceRequest) +bool ArgumentCoder::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::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(resourceResponse.httpStatusCode()); - encoder << resourceResponse.httpHeaderFields(); - - encoder << resourceResponse.mimeType(); - encoder << resourceResponse.textEncodingName(); - encoder << static_cast(resourceResponse.expectedContentLength()); - encoder << resourceResponse.httpStatusText(); - encoder << resourceResponse.suggestedFilename(); - } -} - -bool ArgumentCoder::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 + resourceRequest.setHiddenFromInspector(isHiddenFromInspector); - ResourceResponse response; - - 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::encode(ArgumentEncoder& encoder, const ResourceError& resourceError) +void ArgumentCoder::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::decode(ArgumentDecoder& decoder, ResourceError& resourceError) +bool ArgumentCoder::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::encode(ArgumentEncoder& encoder, const SelectionRect& selectionRect) +void ArgumentCoder::encode(Encoder& encoder, const SelectionRect& selectionRect) { encoder << selectionRect.rect(); encoder << static_cast(selectionRect.direction()); @@ -702,9 +1040,9 @@ void ArgumentCoder::encode(ArgumentEncoder& encoder, const Select encoder << selectionRect.isHorizontal(); } -bool ArgumentCoder::decode(ArgumentDecoder& decoder, SelectionRect& selectionRect) +bool ArgumentCoder::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::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::decode(ArgumentDecoder& decoder, SelectionRec #endif -void ArgumentCoder::encode(ArgumentEncoder& encoder, const WindowFeatures& windowFeatures) +void ArgumentCoder::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::encode(ArgumentEncoder& encoder, const Windo encoder << windowFeatures.dialog; } -bool ArgumentCoder::decode(ArgumentDecoder& decoder, WindowFeatures& windowFeatures) +bool ArgumentCoder::decode(Decoder& decoder, WindowFeatures& windowFeatures) { if (!decoder.decode(windowFeatures.x)) return false; @@ -791,14 +1125,6 @@ bool ArgumentCoder::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::decode(ArgumentDecoder& decoder, WindowFeatu } -void ArgumentCoder::encode(ArgumentEncoder& encoder, const Color& color) +void ArgumentCoder::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::encode(ArgumentEncoder& encoder, const Color& color) encoder << color.rgb(); } -bool ArgumentCoder::decode(ArgumentDecoder& decoder, Color& color) +bool ArgumentCoder::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; @@ -845,12 +1207,62 @@ bool ArgumentCoder::decode(ArgumentDecoder& decoder, Color& color) if (!decoder.decode(rgba)) return false; - color = Color(rgba); + color = Color(rgba); + return true; +} + +#if ENABLE(DRAG_SUPPORT) +void ArgumentCoder::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::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 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::encode(ArgumentEncoder& encoder, const CompositionUnderline& underline) +void ArgumentCoder::encode(Encoder& encoder, const CompositionUnderline& underline) { encoder << underline.startOffset; encoder << underline.endOffset; @@ -858,7 +1270,7 @@ void ArgumentCoder::encode(ArgumentEncoder& encoder, const encoder << underline.color; } -bool ArgumentCoder::decode(ArgumentDecoder& decoder, CompositionUnderline& underline) +bool ArgumentCoder::decode(Decoder& decoder, CompositionUnderline& underline) { if (!decoder.decode(underline.startOffset)) return false; @@ -873,7 +1285,7 @@ bool ArgumentCoder::decode(ArgumentDecoder& decoder, Compo } -void ArgumentCoder::encode(ArgumentEncoder& encoder, const Cookie& cookie) +void ArgumentCoder::encode(Encoder& encoder, const Cookie& cookie) { encoder << cookie.name; encoder << cookie.value; @@ -885,7 +1297,7 @@ void ArgumentCoder::encode(ArgumentEncoder& encoder, const Cookie& cooki encoder << cookie.session; } -bool ArgumentCoder::decode(ArgumentDecoder& decoder, Cookie& cookie) +bool ArgumentCoder::decode(Decoder& decoder, Cookie& cookie) { if (!decoder.decode(cookie.name)) return false; @@ -907,9 +1319,7 @@ bool ArgumentCoder::decode(ArgumentDecoder& decoder, Cookie& cookie) return true; } - -#if ENABLE(SQL_DATABASE) -void ArgumentCoder::encode(ArgumentEncoder& encoder, const DatabaseDetails& details) +void ArgumentCoder::encode(Encoder& encoder, const DatabaseDetails& details) { encoder << details.name(); encoder << details.displayName(); @@ -919,7 +1329,7 @@ void ArgumentCoder::encode(ArgumentEncoder& encoder, const Data encoder << details.modificationTime(); } -bool ArgumentCoder::decode(ArgumentDecoder& decoder, DatabaseDetails& details) +bool ArgumentCoder::decode(Decoder& decoder, DatabaseDetails& details) { String name; if (!decoder.decode(name)) @@ -949,23 +1359,57 @@ bool ArgumentCoder::decode(ArgumentDecoder& decoder, DatabaseDe return true; } -#endif - #if PLATFORM(IOS) -static void encodeSharedBuffer(ArgumentEncoder& encoder, SharedBuffer* buffer) +void ArgumentCoder::encode(Encoder& encoder, const Highlight& highlight) +{ + encoder << static_cast(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::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(buffer->size()): 0); if (buffer) { - RefPtr sharedMemoryBuffer = SharedMemory::create(buffer->size()); + RefPtr 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& buffer) +static bool decodeSharedBuffer(Decoder& decoder, RefPtr& buffer) { uint64_t bufferSize = 0; if (!decoder.decode(bufferSize)) @@ -976,14 +1420,14 @@ static bool decodeSharedBuffer(ArgumentDecoder& decoder, RefPtr& b if (!decoder.decode(handle)) return false; - RefPtr sharedMemoryBuffer = SharedMemory::create(handle, SharedMemory::ReadOnly); + RefPtr sharedMemoryBuffer = SharedMemory::map(handle, SharedMemory::Protection::ReadOnly); buffer = SharedBuffer::create(static_cast(sharedMemoryBuffer->data()), bufferSize); } return true; } -void ArgumentCoder::encode(ArgumentEncoder& encoder, const WebCore::PasteboardWebContent& content) +void ArgumentCoder::encode(Encoder& encoder, const PasteboardWebContent& content) { encoder << content.canSmartCopyOrDelete; encoder << content.dataInStringFormat; @@ -998,7 +1442,7 @@ void ArgumentCoder::encode(ArgumentEncoder& encoder, const encodeSharedBuffer(encoder, content.clientData[i].get()); } -bool ArgumentCoder::decode(ArgumentDecoder& decoder, WebCore::PasteboardWebContent& content) +bool ArgumentCoder::decode(Decoder& decoder, PasteboardWebContent& content) { if (!decoder.decode(content.canSmartCopyOrDelete)) return false; @@ -1022,9 +1466,9 @@ bool ArgumentCoder::decode(ArgumentDecoder& decoder, WebCo return true; } -void ArgumentCoder::encode(ArgumentEncoder& encoder, const WebCore::PasteboardImage& pasteboardImage) +void ArgumentCoder::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::encode(ArgumentEncoder& encoder, const WebC encodeSharedBuffer(encoder, pasteboardImage.resourceData.get()); } -bool ArgumentCoder::decode(ArgumentDecoder& decoder, WebCore::PasteboardImage& pasteboardImage) +bool ArgumentCoder::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::decode(ArgumentDecoder& decoder, WebCore::P #endif -void ArgumentCoder::encode(ArgumentEncoder& encoder, const DictationAlternative& dictationAlternative) +void ArgumentCoder::encode(Encoder& encoder, const DictationAlternative& dictationAlternative) { encoder << dictationAlternative.rangeStart; encoder << dictationAlternative.rangeLength; encoder << dictationAlternative.dictationContext; } -bool ArgumentCoder::decode(ArgumentDecoder& decoder, DictationAlternative& dictationAlternative) +bool ArgumentCoder::decode(Decoder& decoder, DictationAlternative& dictationAlternative) { if (!decoder.decode(dictationAlternative.rangeStart)) return false; @@ -1068,33 +1512,26 @@ bool ArgumentCoder::decode(ArgumentDecoder& decoder, Dicta } -void ArgumentCoder::encode(ArgumentEncoder& encoder, const FileChooserSettings& settings) +void ArgumentCoder::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::decode(ArgumentDecoder& decoder, FileChooserSettings& settings) +bool ArgumentCoder::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::decode(ArgumentDecoder& decoder, FileCh } -void ArgumentCoder::encode(ArgumentEncoder& encoder, const GrammarDetail& detail) +void ArgumentCoder::encode(Encoder& encoder, const GrammarDetail& detail) { encoder << detail.location; encoder << detail.length; @@ -1110,7 +1547,7 @@ void ArgumentCoder::encode(ArgumentEncoder& encoder, const Gramma encoder << detail.userDescription; } -bool ArgumentCoder::decode(ArgumentDecoder& decoder, GrammarDetail& detail) +bool ArgumentCoder::decode(Decoder& decoder, GrammarDetail& detail) { if (!decoder.decode(detail.location)) return false; @@ -1124,7 +1561,7 @@ bool ArgumentCoder::decode(ArgumentDecoder& decoder, GrammarDetai return true; } -void ArgumentCoder::encode(ArgumentEncoder& encoder, const TextCheckingRequestData& request) +void ArgumentCoder::encode(Encoder& encoder, const TextCheckingRequestData& request) { encoder << request.sequence(); encoder << request.text(); @@ -1132,7 +1569,7 @@ void ArgumentCoder::encode(ArgumentEncoder& encoder, co encoder.encodeEnum(request.processType()); } -bool ArgumentCoder::decode(ArgumentDecoder& decoder, TextCheckingRequestData& request) +bool ArgumentCoder::decode(Decoder& decoder, TextCheckingRequestData& request) { int sequence; if (!decoder.decode(sequence)) @@ -1154,7 +1591,7 @@ bool ArgumentCoder::decode(ArgumentDecoder& decoder, Te return true; } -void ArgumentCoder::encode(ArgumentEncoder& encoder, const TextCheckingResult& result) +void ArgumentCoder::encode(Encoder& encoder, const TextCheckingResult& result) { encoder.encodeEnum(result.type); encoder << result.location; @@ -1163,7 +1600,7 @@ void ArgumentCoder::encode(ArgumentEncoder& encoder, const T encoder << result.replacement; } -bool ArgumentCoder::decode(ArgumentDecoder& decoder, TextCheckingResult& result) +bool ArgumentCoder::decode(Decoder& decoder, TextCheckingResult& result) { if (!decoder.decodeEnum(result.type)) return false; @@ -1178,39 +1615,21 @@ bool ArgumentCoder::decode(ArgumentDecoder& decoder, TextChe return true; } -void ArgumentCoder::encode(ArgumentEncoder& encoder, const DragSession& result) -{ - encoder.encodeEnum(result.operation); - encoder << result.mouseIsOverFileInput; - encoder << result.numberOfItemsToBeAccepted; -} - -bool ArgumentCoder::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::encode(ArgumentEncoder& encoder, const URL& result) +void ArgumentCoder::encode(Encoder& encoder, const URL& result) { encoder << result.string(); } -bool ArgumentCoder::decode(ArgumentDecoder& decoder, URL& result) +bool ArgumentCoder::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::encode(ArgumentEncoder& encoder, const WebCore::UserStyleSheet& userStyleSheet) +void ArgumentCoder::encode(Encoder& encoder, const UserStyleSheet& userStyleSheet) { encoder << userStyleSheet.source(); encoder << userStyleSheet.url(); @@ -1220,7 +1639,7 @@ void ArgumentCoder::encode(ArgumentEncoder& encoder, co encoder.encodeEnum(userStyleSheet.level()); } -bool ArgumentCoder::decode(ArgumentDecoder& decoder, WebCore::UserStyleSheet& userStyleSheet) +bool ArgumentCoder::decode(Decoder& decoder, UserStyleSheet& userStyleSheet) { String source; if (!decoder.decode(source)) @@ -1238,19 +1657,45 @@ bool ArgumentCoder::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; +} + +#if ENABLE(MEDIA_SESSION) +void ArgumentCoder::encode(Encoder& encoder, const MediaSessionMetadata& result) +{ + encoder << result.artist(); + encoder << result.album(); + encoder << result.title(); + encoder << result.artworkURL(); +} + +bool ArgumentCoder::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::encode(ArgumentEncoder& encoder, const WebCore::UserScript& userScript) +void ArgumentCoder::encode(Encoder& encoder, const UserScript& userScript) { encoder << userScript.source(); encoder << userScript.url(); @@ -1260,7 +1705,7 @@ void ArgumentCoder::encode(ArgumentEncoder& encoder, const encoder.encodeEnum(userScript.injectedFrames()); } -bool ArgumentCoder::decode(ArgumentDecoder& decoder, WebCore::UserScript& userScript) +bool ArgumentCoder::decode(Decoder& decoder, UserScript& userScript) { String source; if (!decoder.decode(source)) @@ -1278,19 +1723,19 @@ bool ArgumentCoder::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::encode(ArgumentEncoder& encoder, const WebCore::ScrollableAreaParameters& parameters) +void ArgumentCoder::encode(Encoder& encoder, const ScrollableAreaParameters& parameters) { encoder.encodeEnum(parameters.horizontalScrollElasticity); encoder.encodeEnum(parameters.verticalScrollElasticity); @@ -1302,7 +1747,7 @@ void ArgumentCoder::encode(ArgumentEncoder& e encoder << parameters.hasEnabledVerticalScrollbar; } -bool ArgumentCoder::decode(ArgumentDecoder& decoder, WebCore::ScrollableAreaParameters& params) +bool ArgumentCoder::decode(Decoder& decoder, ScrollableAreaParameters& params) { if (!decoder.decodeEnum(params.horizontalScrollElasticity)) return false; @@ -1322,7 +1767,7 @@ bool ArgumentCoder::decode(ArgumentDecoder& d return true; } -void ArgumentCoder::encode(ArgumentEncoder& encoder, const WebCore::FixedPositionViewportConstraints& viewportConstraints) +void ArgumentCoder::encode(Encoder& encoder, const FixedPositionViewportConstraints& viewportConstraints) { encoder << viewportConstraints.alignmentOffset(); encoder << viewportConstraints.anchorEdges(); @@ -1331,7 +1776,7 @@ void ArgumentCoder::encode(ArgumentEn encoder << viewportConstraints.layerPositionAtLastLayout(); } -bool ArgumentCoder::decode(ArgumentDecoder& decoder, WebCore::FixedPositionViewportConstraints& viewportConstraints) +bool ArgumentCoder::decode(Decoder& decoder, FixedPositionViewportConstraints& viewportConstraints) { FloatSize alignmentOffset; if (!decoder.decode(alignmentOffset)) @@ -1349,7 +1794,7 @@ bool ArgumentCoder::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::decode(ArgumentDe return true; } -void ArgumentCoder::encode(ArgumentEncoder& encoder, const WebCore::StickyPositionViewportConstraints& viewportConstraints) +void ArgumentCoder::encode(Encoder& encoder, const StickyPositionViewportConstraints& viewportConstraints) { encoder << viewportConstraints.alignmentOffset(); encoder << viewportConstraints.anchorEdges(); @@ -1377,7 +1822,7 @@ void ArgumentCoder::encode(ArgumentE encoder << viewportConstraints.layerPositionAtLastLayout(); } -bool ArgumentCoder::decode(ArgumentDecoder& decoder, WebCore::StickyPositionViewportConstraints& viewportConstraints) +bool ArgumentCoder::decode(Decoder& decoder, StickyPositionViewportConstraints& viewportConstraints) { FloatSize alignmentOffset; if (!decoder.decode(alignmentOffset)) @@ -1423,7 +1868,7 @@ bool ArgumentCoder::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::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::encode(Encoder& encoder, const FilterOperation& filter) { encoder.encodeEnum(filter.type()); switch (filter.type()) { - case FilterOperation::REFERENCE: { - const auto& referenceFilter = static_cast(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(filter).amount(); + encoder << downcast(filter).amount(); break; case FilterOperation::INVERT: case FilterOperation::OPACITY: case FilterOperation::BRIGHTNESS: case FilterOperation::CONTRAST: - encoder << static_cast(filter).amount(); + encoder << downcast(filter).amount(); break; case FilterOperation::BLUR: - encoder << static_cast(filter).stdDeviation(); + encoder << downcast(filter).stdDeviation(); break; case FilterOperation::DROP_SHADOW: { - const auto& dropShadowFilter = static_cast(filter); + const auto& dropShadowFilter = downcast(filter); encoder << dropShadowFilter.location(); encoder << dropShadowFilter.stdDeviation(); encoder << dropShadowFilter.color(); break; } + case FilterOperation::DEFAULT: + encoder.encodeEnum(downcast(filter).representedType()); + break; case FilterOperation::PASSTHROUGH: - case FilterOperation::NONE: break; - }; + } } -static bool decodeFilterOperation(ArgumentDecoder& decoder, RefPtr& filter) +bool decodeFilterOperation(Decoder& decoder, RefPtr& 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::encode(ArgumentEncoder& encoder, const FilterOperations& filters) +void ArgumentCoder::encode(Encoder& encoder, const FilterOperations& filters) { encoder << static_cast(filters.size()); for (const auto& filter : filters.operations()) - encodeFilterOperation(encoder, *filter); + encoder << *filter; } -bool ArgumentCoder::decode(ArgumentDecoder& decoder, FilterOperations& filters) +bool ArgumentCoder::decode(Decoder& decoder, FilterOperations& filters) { uint64_t filterCount; if (!decoder.decode(filterCount)) @@ -1566,271 +2013,505 @@ bool ArgumentCoder::decode(ArgumentDecoder& decoder, FilterOpe RefPtr 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::encode(ArgumentEncoder& encoder, const IDBDatabaseMetadata& metadata) +void ArgumentCoder::encode(Encoder& encoder, const SessionID& sessionID) { - encoder << metadata.name << metadata.id << metadata.version << metadata.maxObjectStoreId << metadata.objectStores; + encoder << sessionID.sessionID(); } -bool ArgumentCoder::decode(ArgumentDecoder& decoder, IDBDatabaseMetadata& metadata) +bool ArgumentCoder::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::encode(Encoder& encoder, const BlobPart& blobPart) +{ + encoder << static_cast(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::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 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::encode(ArgumentEncoder& encoder, const IDBIndexMetadata& metadata) +void ArgumentCoder::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(textIndicatorData.options); + + encodeOptionalImage(encoder, textIndicatorData.contentImage.get()); + encodeOptionalImage(encoder, textIndicatorData.contentImageWithHighlight.get()); } -bool ArgumentCoder::decode(ArgumentDecoder& decoder, IDBIndexMetadata& metadata) +bool ArgumentCoder::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(options); - if (!decoder.decode(metadata.multiEntry)) + if (!decodeOptionalImage(decoder, textIndicatorData.contentImage)) + return false; + + if (!decodeOptionalImage(decoder, textIndicatorData.contentImageWithHighlight)) return false; return true; } -void ArgumentCoder::encode(ArgumentEncoder& encoder, const IDBGetResult& result) +#if ENABLE(WIRELESS_PLAYBACK_TARGET) +void ArgumentCoder::encode(Encoder& encoder, const MediaPlaybackTargetContext& target) { - bool nullData = !result.valueBuffer; - encoder << nullData; + bool hasPlatformData = target.encodingRequiresPlatformData(); + encoder << hasPlatformData; - if (!nullData) - encoder << DataReference(reinterpret_cast(result.valueBuffer->data()), result.valueBuffer->size()); + int32_t targetType = target.type(); + encoder << targetType; + + if (target.encodingRequiresPlatformData()) { + encodePlatformData(encoder, target); + return; + } - encoder << result.keyData << result.keyPath; + ASSERT(targetType == MediaPlaybackTargetContext::MockType); + encoder << target.mockDeviceName(); + encoder << static_cast(target.mockState()); } -bool ArgumentCoder::decode(ArgumentDecoder& decoder, IDBGetResult& result) +bool ArgumentCoder::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(mockState)); return true; } +#endif -void ArgumentCoder::encode(ArgumentEncoder& encoder, const IDBKeyData& keyData) +void ArgumentCoder::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::decode(ArgumentDecoder& decoder, IDBKeyData& keyData) +bool ArgumentCoder::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::encode(IPC::Encoder& encoder, const ExceptionDetails& info) +{ + encoder << info.message; + encoder << info.lineNumber; + encoder << info.columnNumber; + encoder << info.sourceURL; +} + +bool ArgumentCoder::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::encode(ArgumentEncoder& encoder, const IDBKeyPath& keyPath) +void ArgumentCoder::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::decode(ArgumentDecoder& decoder, IDBKeyPath& keyPath) +bool ArgumentCoder::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 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::encode(ArgumentEncoder& encoder, const IDBKeyRangeData& keyRange) +#if ENABLE(MEDIA_STREAM) +void ArgumentCoder::encode(Encoder& encoder, const WebCore::MediaConstraintsData& constraint) { - encoder << keyRange.isNull; - if (keyRange.isNull) - return; + encoder << constraint.mandatoryConstraints; + + auto& advancedConstraints = constraint.advancedConstraints; + encoder << static_cast(advancedConstraints.size()); + for (const auto& advancedConstraint : advancedConstraints) + encoder << advancedConstraint; - encoder << keyRange.upperKey << keyRange.lowerKey << keyRange.upperOpen << keyRange.lowerOpen; + encoder << constraint.isValid; } -bool ArgumentCoder::decode(ArgumentDecoder& decoder, IDBKeyRangeData& keyRange) +bool ArgumentCoder::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 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::encode(ArgumentEncoder& encoder, const IDBObjectStoreMetadata& metadata) +void ArgumentCoder::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::decode(ArgumentDecoder& decoder, IDBObjectStoreMetadata& metadata) +bool ArgumentCoder::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::encode(Encoder& encoder, const IDBKeyPath& keyPath) +{ + bool isString = WTF::holds_alternative(keyPath); + encoder << isString; + if (isString) + encoder << WTF::get(keyPath); + else + encoder << WTF::get>(keyPath); +} + +bool ArgumentCoder::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 vector; + if (!decoder.decode(vector)) + return false; + keyPath = vector; + } + return true; +} +#endif + +#if ENABLE(CSS_SCROLL_SNAP) + +void ArgumentCoder>::encode(Encoder& encoder, const ScrollOffsetRange& range) +{ + encoder << range.start; + encoder << range.end; +} - if (!decoder.decode(metadata.maxIndexId)) +bool ArgumentCoder>::decode(Decoder& decoder, ScrollOffsetRange& 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 +#include +#include +#include +#include +#include + +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>; +} +#endif + namespace IPC { +template<> struct ArgumentCoder { + static void encode(Encoder&, const WTF::MonotonicTime&); + static bool decode(Decoder&, WTF::MonotonicTime&); +}; + +template<> struct ArgumentCoder { + static void encode(Encoder&, const WTF::Seconds&); + static bool decode(Decoder&, WTF::Seconds&); +}; + template<> struct ArgumentCoder { - 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 { + static void encode(Encoder&, const WebCore::EventTrackingRegions&); + static bool decode(Decoder&, WebCore::EventTrackingRegions&); }; template<> struct ArgumentCoder { - 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 { + static void encode(Encoder&, const WebCore::LinearTimingFunction&); + static bool decode(Decoder&, WebCore::LinearTimingFunction&); +}; + +template<> struct ArgumentCoder { + static void encode(Encoder&, const WebCore::CubicBezierTimingFunction&); + static bool decode(Decoder&, WebCore::CubicBezierTimingFunction&); +}; + +template<> struct ArgumentCoder { + static void encode(Encoder&, const WebCore::StepsTimingFunction&); + static bool decode(Decoder&, WebCore::StepsTimingFunction&); +}; + +template<> struct ArgumentCoder { + static void encode(Encoder&, const WebCore::SpringTimingFunction&); + static bool decode(Decoder&, WebCore::SpringTimingFunction&); }; template<> struct ArgumentCoder { - 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 { - 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 { - 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 { - 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 { - 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 { + static void encode(Encoder&, const WebCore::FloatRoundedRect&); + static bool decode(Decoder&, WebCore::FloatRoundedRect&); }; #if PLATFORM(IOS) template<> struct ArgumentCoder { - 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 { - 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 { - 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 { - 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 { - 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 { + static void encode(Encoder&, const WebCore::LayoutSize&); + static bool decode(Decoder&, WebCore::LayoutSize&); +}; + +template<> struct ArgumentCoder { + static void encode(Encoder&, const WebCore::LayoutPoint&); + static bool decode(Decoder&, WebCore::LayoutPoint&); +}; + +template<> struct ArgumentCoder { + static void encode(Encoder&, const WebCore::Path&); + static bool decode(Decoder&, WebCore::Path&); +}; + +template<> struct ArgumentCoder { + static void encode(Encoder&, const WebCore::Region&); + static bool decode(Decoder&, WebCore::Region&); }; template<> struct ArgumentCoder { - 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 { - 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 { - 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 { - static void encode(ArgumentEncoder&, const WebCore::PluginInfo&); - static bool decode(ArgumentDecoder&, WebCore::PluginInfo&); -}; - -template<> struct ArgumentCoder { - 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 { - 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 { - 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 { - 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 { - 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 { -#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 { - 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 { -#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 { - 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 { - 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 { + static void encode(Encoder&, const WebCore::DragData&); + static bool decode(Decoder&, WebCore::DragData&); +}; +#endif + +#if PLATFORM(COCOA) +template<> struct ArgumentCoder { + 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 { - 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 { - 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 { + static void encode(Encoder&, const WebCore::Highlight&); + static bool decode(Decoder&, WebCore::Highlight&); }; template<> struct ArgumentCoder { - 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 { - 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 { + static void encode(Encoder&, const WebCore::SoupNetworkProxySettings&); + static bool decode(Decoder&, WebCore::SoupNetworkProxySettings&); }; #endif template<> struct ArgumentCoder { - 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 { - 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 { - 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 { - 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 { - 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 { - 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 { - 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 { - 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 { - static void encode(ArgumentEncoder&, const WebCore::DragSession&); - static bool decode(ArgumentDecoder&, WebCore::DragSession&); -}; - template<> struct ArgumentCoder { - 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 { - 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 { - 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 { - 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 { - 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 { - 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 { - 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 { + static void encode(Encoder&, const WebCore::FilterOperation&); +}; +bool decodeFilterOperation(Decoder&, RefPtr&); #endif -#if ENABLE(INDEXED_DATABASE) -template<> struct ArgumentCoder { - static void encode(ArgumentEncoder&, const WebCore::IDBDatabaseMetadata&); - static bool decode(ArgumentDecoder&, WebCore::IDBDatabaseMetadata&); +template<> struct ArgumentCoder { + static void encode(Encoder&, const WebCore::SessionID&); + static bool decode(Decoder&, WebCore::SessionID&); }; -template<> struct ArgumentCoder { - static void encode(ArgumentEncoder&, const WebCore::IDBGetResult&); - static bool decode(ArgumentDecoder&, WebCore::IDBGetResult&); +template<> struct ArgumentCoder { + static void encode(Encoder&, const WebCore::BlobPart&); + static bool decode(Decoder&, WebCore::BlobPart&); }; -template<> struct ArgumentCoder { - static void encode(ArgumentEncoder&, const WebCore::IDBIndexMetadata&); - static bool decode(ArgumentDecoder&, WebCore::IDBIndexMetadata&); +#if ENABLE(CONTENT_FILTERING) +template<> struct ArgumentCoder { + static void encode(Encoder&, const WebCore::ContentFilterUnblockHandler&); + static bool decode(Decoder&, WebCore::ContentFilterUnblockHandler&); }; +#endif -template<> struct ArgumentCoder { - static void encode(ArgumentEncoder&, const WebCore::IDBKeyData&); - static bool decode(ArgumentDecoder&, WebCore::IDBKeyData&); +#if ENABLE(MEDIA_SESSION) +template<> struct ArgumentCoder { + static void encode(Encoder&, const WebCore::MediaSessionMetadata&); + static bool decode(Decoder&, WebCore::MediaSessionMetadata&); }; +#endif -template<> struct ArgumentCoder { - static void encode(ArgumentEncoder&, const WebCore::IDBKeyPath&); - static bool decode(ArgumentDecoder&, WebCore::IDBKeyPath&); +template<> struct ArgumentCoder { + static void encode(Encoder&, const WebCore::TextIndicatorData&); + static bool decode(Decoder&, WebCore::TextIndicatorData&); }; -template<> struct ArgumentCoder { - static void encode(ArgumentEncoder&, const WebCore::IDBKeyRangeData&); - static bool decode(ArgumentDecoder&, WebCore::IDBKeyRangeData&); +template<> struct ArgumentCoder { + static void encode(Encoder&, const WebCore::DictionaryPopupInfo&); + static bool decode(Decoder&, WebCore::DictionaryPopupInfo&); }; -template<> struct ArgumentCoder { - static void encode(ArgumentEncoder&, const WebCore::IDBObjectStoreMetadata&); - static bool decode(ArgumentDecoder&, WebCore::IDBObjectStoreMetadata&); +#if ENABLE(WIRELESS_PLAYBACK_TARGET) +template<> struct ArgumentCoder { + 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 { + static void encode(Encoder&, const WebCore::RecentSearch&); + static bool decode(Decoder&, WebCore::RecentSearch&); +}; + +template<> struct ArgumentCoder { + static void encode(Encoder&, const WebCore::ExceptionDetails&); + static bool decode(Decoder&, WebCore::ExceptionDetails&); +}; + +template<> struct ArgumentCoder { + static void encode(Encoder&, const WebCore::ResourceLoadStatistics&); + static bool decode(Decoder&, WebCore::ResourceLoadStatistics&); +}; + +#if ENABLE(APPLE_PAY) + +template<> struct ArgumentCoder { + static void encode(Encoder&, const WebCore::Payment&); + static bool decode(Decoder&, WebCore::Payment&); +}; + +template<> struct ArgumentCoder { + static void encode(Encoder&, const WebCore::PaymentContact&); + static bool decode(Decoder&, WebCore::PaymentContact&); +}; + +template<> struct ArgumentCoder { + static void encode(Encoder&, const WebCore::PaymentMerchantSession&); + static bool decode(Decoder&, WebCore::PaymentMerchantSession&); +}; + +template<> struct ArgumentCoder { + static void encode(Encoder&, const WebCore::PaymentMethod&); + static bool decode(Decoder&, WebCore::PaymentMethod&); +}; + +template<> struct ArgumentCoder { + static void encode(Encoder&, const WebCore::PaymentRequest&); + static bool decode(Decoder&, WebCore::PaymentRequest&); +}; + +template<> struct ArgumentCoder { + static void encode(Encoder&, const WebCore::PaymentRequest::ContactFields&); + static bool decode(Decoder&, WebCore::PaymentRequest::ContactFields&); +}; + +template<> struct ArgumentCoder { + static void encode(Encoder&, const WebCore::PaymentRequest::LineItem&); + static bool decode(Decoder&, WebCore::PaymentRequest::LineItem&); +}; + +template<> struct ArgumentCoder { + static void encode(Encoder&, const WebCore::PaymentRequest::MerchantCapabilities&); + static bool decode(Decoder&, WebCore::PaymentRequest::MerchantCapabilities&); +}; + +template<> struct ArgumentCoder { + static void encode(Encoder&, const WebCore::PaymentRequest::ShippingMethod&); + static bool decode(Decoder&, WebCore::PaymentRequest::ShippingMethod&); +}; + +template<> struct ArgumentCoder { + static void encode(Encoder&, const WebCore::PaymentRequest::TotalAndLineItems&); + static bool decode(Decoder&, WebCore::PaymentRequest::TotalAndLineItems&); +}; + +#endif + +#if ENABLE(MEDIA_STREAM) +template<> struct ArgumentCoder { + static void encode(Encoder&, const WebCore::MediaConstraintsData&); + static bool decode(Decoder&, WebCore::MediaConstraintsData&); +}; + +template<> struct ArgumentCoder { + static void encode(Encoder&, const WebCore::CaptureDevice&); + static bool decode(Decoder&, WebCore::CaptureDevice&); +}; +#endif + +#if ENABLE(INDEXED_DATABASE) + +template<> struct ArgumentCoder { + static void encode(Encoder&, const WebCore::IDBKeyPath&); + static bool decode(Decoder&, WebCore::IDBKeyPath&); +}; + +#endif + +#if ENABLE(CSS_SCROLL_SNAP) + +template<> struct ArgumentCoder> { + static void encode(Encoder&, const WebCore::ScrollOffsetRange&); + static bool decode(Decoder&, WebCore::ScrollOffsetRange&); +}; + +#endif + } // namespace IPC -#endif // WebCoreArgumentCoders_h +namespace WTF { + +template<> struct EnumTraits { + using values = EnumValues< + WebCore::ColorSpace, + WebCore::ColorSpace::ColorSpaceDeviceRGB, + WebCore::ColorSpace::ColorSpaceSRGB, + WebCore::ColorSpace::ColorSpaceLinearRGB, + WebCore::ColorSpace::ColorSpaceDisplayP3 + >; +}; + +template<> struct EnumTraits { + using values = EnumValues< + WebCore::HasInsecureContent, + WebCore::HasInsecureContent::No, + WebCore::HasInsecureContent::Yes + >; +}; + +template<> struct EnumTraits { + using values = EnumValues< + WebCore::ShouldSample, + WebCore::ShouldSample::No, + WebCore::ShouldSample::Yes + >; +}; + +#if ENABLE(INDEXED_DATABASE) +template<> struct EnumTraits { + 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 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