From 4bd713d56aa9bb86bc96ea9cb0c64cbf94bf43d4 Mon Sep 17 00:00:00 2001 From: Konstantin Tokarev Date: Mon, 24 Apr 2017 22:40:03 +0300 Subject: Import WebKit commit 3040e0455efecd271f1aeef53cf287e75486a70d Change-Id: I7df106cef8ce93ce33e49ad6fb0d202cd066d87c Reviewed-by: Konstantin Tokarev --- Source/WTF/wtf/Compiler.h | 9 +- Source/WebCore/PlatformQt.cmake | 77 +-- Source/WebCore/page/FrameView.cpp | 2 + Source/WebCore/platform/PlatformTouchEvent.h | 6 - Source/WebCore/platform/ScrollView.cpp | 5 + .../graphics/texmap/GraphicsLayerTextureMapper.cpp | 2 +- .../graphics/texmap/GraphicsLayerTextureMapper.h | 2 +- .../graphics/texmap/TextureMapperLayer.cpp | 2 +- .../platform/graphics/texmap/TextureMapperLayer.h | 2 +- .../coordinated/CoordinatedGraphicsLayer.cpp | 2 + Source/WebCore/platform/network/ResourceHandle.cpp | 2 +- Source/WebCore/platform/network/qt/CookieJarQt.cpp | 29 +- Source/WebCore/platform/network/qt/CookieJarQt.h | 4 +- .../platform/network/qt/QNetworkReplyHandler.cpp | 60 +- .../platform/network/qt/QNetworkReplyHandler.h | 4 + .../platform/network/qt/ResourceHandleQt.cpp | 14 + Source/WebCore/plugins/qt/QtX11ImageConversion.cpp | 73 +++ Source/WebCore/plugins/qt/QtX11ImageConversion.h | 33 ++ Source/WebKit/CMakeLists.txt | 4 + Source/WebKit/PlatformQt.cmake | 64 +- Source/WebKit/qt/Plugins/QtX11ImageConversion.cpp | 73 --- Source/WebKit/qt/Plugins/QtX11ImageConversion.h | 33 -- Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp | 2 +- Source/WebKit/qt/WebCoreSupport/ChromeClientQt.h | 2 +- .../qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp | 6 +- .../NotificationPresenterClientQt.cpp | 65 +-- .../WebCoreSupport/NotificationPresenterClientQt.h | 14 +- .../WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp | 8 +- Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.h | 4 +- Source/WebKit/qt/WidgetApi/qwebpage.cpp | 8 +- Source/WebKit/qt/declarative/CMakeLists.txt | 54 ++ .../qt/declarative/experimental/CMakeLists.txt | 29 + .../WebKit/qt/declarative/experimental/plugin.cpp | 6 +- Source/WebKit/qt/declarative/plugin.cpp | 6 +- Source/WebKit/qt/tests/CMakeLists.txt | 28 +- Source/WebKit2/CMakeLists.txt | 21 +- .../EntryPoint/qt/DatabaseProcessMain.cpp | 35 ++ .../DatabaseProcess/qt/DatabaseProcessMainQt.cpp | 46 ++ .../CustomProtocols/qt/CustomProtocolManagerImpl.h | 36 ++ .../CustomProtocols/qt/CustomProtocolManagerQt.cpp | 78 +++ .../WebKit2/NetworkProcess/Downloads/Download.cpp | 3 - Source/WebKit2/NetworkProcess/Downloads/Download.h | 2 +- .../NetworkProcess/Downloads/DownloadManager.cpp | 2 +- .../NetworkProcess/Downloads/DownloadManager.h | 2 +- .../NetworkProcess/Downloads/qt/DownloadQt.cpp | 17 +- .../Downloads/qt/QtFileDownloader.cpp | 34 +- .../NetworkProcess/Downloads/qt/QtFileDownloader.h | 10 +- .../EntryPoint/qt/NetworkProcessMain.cpp | 35 ++ Source/WebKit2/NetworkProcess/NetworkProcess.cpp | 7 + Source/WebKit2/NetworkProcess/NetworkProcess.h | 15 + .../NetworkProcess/NetworkProcess.messages.in | 3 + .../NetworkProcessCreationParameters.cpp | 4 +- .../NetworkProcessCreationParameters.h | 4 +- .../NetworkProcess/RemoteNetworkingContext.h | 7 + .../NetworkProcess/qt/NetworkProcessMainQt.cpp | 125 ++++ .../WebKit2/NetworkProcess/qt/NetworkProcessQt.cpp | 77 +++ .../NetworkProcess/qt/QtNetworkAccessManager.cpp | 136 +++++ .../NetworkProcess/qt/QtNetworkAccessManager.h | 58 ++ .../qt/RemoteNetworkingContextQt.cpp | 65 +++ Source/WebKit2/Platform/IPC/mac/ConnectionMac.mm | 643 +++++++++++++++++++++ .../WebKit2/Platform/IPC/mac/ImportanceAssertion.h | 63 ++ Source/WebKit2/Platform/IPC/mac/MachPort.h | 75 +++ Source/WebKit2/Platform/IPC/win/ConnectionWin.cpp | 351 +++++++++++ Source/WebKit2/Platform/mac/LayerHostingContext.h | 85 +++ Source/WebKit2/Platform/mac/LayerHostingContext.mm | 145 +++++ Source/WebKit2/Platform/mac/MachUtilities.cpp | 69 +++ Source/WebKit2/Platform/mac/MachUtilities.h | 36 ++ Source/WebKit2/Platform/mac/MenuUtilities.h | 42 ++ Source/WebKit2/Platform/mac/MenuUtilities.mm | 117 ++++ Source/WebKit2/Platform/mac/SharedMemoryMac.cpp | 235 ++++++++ Source/WebKit2/Platform/mac/StringUtilities.h | 47 ++ Source/WebKit2/Platform/mac/StringUtilities.mm | 113 ++++ Source/WebKit2/Platform/win/SharedMemoryWin.cpp | 241 ++++++++ Source/WebKit2/PlatformQt.cmake | 81 ++- .../PluginProcess/qt/PluginProcessMainQt.cpp | 6 +- .../WebKit2/PluginProcess/qt/PluginProcessQt.cpp | 2 +- Source/WebKit2/Shared/API/APIObject.h | 1 + .../Authentication/qt/AuthenticationManagerQt.cpp | 53 ++ .../CoordinatedGraphicsScene.cpp | 11 + .../CoordinatedGraphics/CoordinatedGraphicsScene.h | 3 + Source/WebKit2/Shared/SessionTracker.cpp | 4 + .../WebKit2/Shared/WebPageCreationParameters.cpp | 4 + Source/WebKit2/Shared/WebPageCreationParameters.h | 3 + Source/WebKit2/Shared/qt/ChildProcessMainQt.cpp | 79 +++ .../WebKit2/Shared/qt/ProcessExecutablePathQt.cpp | 5 + .../WebKit2/Shared/qt/WebCoreArgumentCodersQt.cpp | 165 ++++++ Source/WebKit2/Shared/qt/WebEventFactoryQt.cpp | 4 +- .../UIProcess/API/APIURLSchemeHandlerTask.cpp | 44 ++ .../UIProcess/API/APIURLSchemeHandlerTask.h | 48 ++ .../WebKit2/UIProcess/API/APIWebsiteDataStore.cpp | 2 +- Source/WebKit2/UIProcess/API/cpp/qt/WKStringQt.cpp | 9 +- .../UIProcess/API/qt/APIWebsiteDataStoreQt.cpp | 90 +++ Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp | 6 +- .../WebKit2/UIProcess/API/qt/qquickwebpage_p_p.h | 6 +- Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp | 184 +++--- Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h | 13 +- .../WebKit2/UIProcess/API/qt/qquickwebview_p_p.h | 11 +- .../API/qt/qwebchannelwebkittransport.cpp | 21 +- .../API/qt/qwebchannelwebkittransport_p.h | 6 +- Source/WebKit2/UIProcess/API/qt/qwebkittest.cpp | 24 +- .../WebKit2/UIProcess/API/qt/qwebloadrequest.cpp | 2 + .../WebKit2/UIProcess/API/qt/qwebpreferences.cpp | 16 +- .../WebKit2/UIProcess/API/qt/tests/CMakeLists.txt | 93 +++ .../qmltests/WebView/tst_applicationScheme.qml | 4 + .../qmltests/WebView/tst_evaluateJavaScript.qml | 38 +- .../qt/tests/qmltests/WebView/tst_webchannel.qml | 2 +- .../API/qt/tests/qmltests/common/notification.html | 4 +- .../API/qt/tests/qmltests/tst_qmltests.cpp | 4 - .../CoordinatedLayerTreeHostProxy.cpp | 9 + .../CoordinatedGraphics/PageViewportController.cpp | 6 + .../WebKit2/UIProcess/Downloads/DownloadProxy.cpp | 6 +- .../InspectorServer/qt/WebInspectorServerQt.cpp | 2 +- .../UIProcess/Launcher/qt/ProcessLauncherQt.cpp | 12 +- .../qt/CustomProtocolManagerProxyQt.cpp | 44 ++ .../UIProcess/Plugins/qt/PluginProcessProxyQt.cpp | 26 +- Source/WebKit2/UIProcess/WebPageProxy.cpp | 66 ++- Source/WebKit2/UIProcess/WebPageProxy.h | 13 +- Source/WebKit2/UIProcess/WebPageProxy.messages.in | 7 +- Source/WebKit2/UIProcess/WebURLSchemeHandler.cpp | 72 +++ Source/WebKit2/UIProcess/WebURLSchemeHandler.h | 64 ++ .../WebKit2/UIProcess/WebURLSchemeHandlerTask.cpp | 112 ++++ Source/WebKit2/UIProcess/WebURLSchemeHandlerTask.h | 79 +++ .../qt/PageViewportControllerClientQt.cpp | 3 +- .../UIProcess/qt/PageViewportControllerClientQt.h | 2 +- Source/WebKit2/UIProcess/qt/QrcSchemeHandler.cpp | 96 +++ Source/WebKit2/UIProcess/qt/QrcSchemeHandler.h | 43 ++ Source/WebKit2/UIProcess/qt/QtDialogRunner.cpp | 2 +- Source/WebKit2/UIProcess/qt/QtDownloadManager.cpp | 10 +- Source/WebKit2/UIProcess/qt/QtPageClient.cpp | 127 +++- Source/WebKit2/UIProcess/qt/QtPageClient.h | 55 +- Source/WebKit2/UIProcess/qt/QtWebContext.cpp | 48 +- Source/WebKit2/UIProcess/qt/QtWebContext.h | 4 +- .../UIProcess/qt/QtWebIconDatabaseClient.cpp | 10 +- .../WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp | 15 +- .../WebKit2/UIProcess/qt/QtWebPagePolicyClient.cpp | 16 +- .../WebKit2/UIProcess/qt/QtWebPagePolicyClient.h | 4 +- Source/WebKit2/UIProcess/qt/QtWebPageSGNode.cpp | 12 +- Source/WebKit2/UIProcess/qt/QtWebPageSGNode.h | 5 +- Source/WebKit2/UIProcess/qt/QtWebPageUIClient.cpp | 10 +- Source/WebKit2/UIProcess/qt/TextCheckerQt.cpp | 4 +- Source/WebKit2/UIProcess/qt/WebColorPickerQt.cpp | 13 +- Source/WebKit2/UIProcess/qt/WebColorPickerQt.h | 1 + .../WebKit2/UIProcess/qt/WebContextMenuProxyQt.cpp | 6 +- .../WebKit2/UIProcess/qt/WebContextMenuProxyQt.h | 3 +- .../UIProcess/qt/WebGeolocationProviderQt.cpp | 10 +- .../UIProcess/qt/WebGeolocationProviderQt.h | 2 +- .../WebKit2/UIProcess/qt/WebInspectorProxyQt.cpp | 21 +- Source/WebKit2/UIProcess/qt/WebPageProxyQt.cpp | 40 +- .../WebKit2/UIProcess/qt/WebPopupMenuProxyQt.cpp | 2 +- Source/WebKit2/UIProcess/qt/WebPreferencesQt.cpp | 32 + Source/WebKit2/UIProcess/qt/WebProcessPoolQt.cpp | 46 +- .../InjectedBundle/qt/InjectedBundleQt.cpp | 14 +- .../WebProcess/Network/WebLoaderStrategy.cpp | 32 +- .../WebKit2/WebProcess/Network/WebLoaderStrategy.h | 2 + .../Plugins/Netscape/x11/NetscapePluginX11.cpp | 10 +- .../WebCoreSupport/WebFrameLoaderClient.cpp | 4 + .../qt/WebFrameNetworkingContext.cpp | 45 +- .../WebCoreSupport/qt/WebFrameNetworkingContext.h | 10 +- Source/WebKit2/WebProcess/WebPage/WebPage.cpp | 67 ++- Source/WebKit2/WebProcess/WebPage/WebPage.h | 28 +- .../WebKit2/WebProcess/WebPage/WebPage.messages.in | 11 +- .../WebPage/WebURLSchemeHandlerProxy.cpp | 83 +++ .../WebProcess/WebPage/WebURLSchemeHandlerProxy.h | 63 ++ .../WebPage/WebURLSchemeHandlerTaskProxy.cpp | 91 +++ .../WebPage/WebURLSchemeHandlerTaskProxy.h | 61 ++ .../WebProcess/WebPage/qt/WebInspectorUIQt.cpp | 4 - Source/WebKit2/WebProcess/WebPage/qt/WebPageQt.cpp | 38 +- Source/WebKit2/WebProcess/WebProcess.cpp | 10 - Source/WebKit2/WebProcess/WebProcess.h | 18 - Source/WebKit2/WebProcess/WebProcess.messages.in | 4 - Source/WebKit2/WebProcess/qt/QtBuiltinBundle.cpp | 19 +- Source/WebKit2/WebProcess/qt/QtBuiltinBundle.h | 2 +- .../WebKit2/WebProcess/qt/QtBuiltinBundlePage.cpp | 110 ++-- Source/WebKit2/WebProcess/qt/QtBuiltinBundlePage.h | 12 +- .../WebProcess/qt/QtNetworkAccessManager.cpp | 152 ----- .../WebKit2/WebProcess/qt/QtNetworkAccessManager.h | 64 -- Source/WebKit2/WebProcess/qt/QtNetworkReply.cpp | 100 ---- Source/WebKit2/WebProcess/qt/QtNetworkReply.h | 64 -- Source/WebKit2/WebProcess/qt/WebProcessMainQt.cpp | 77 +-- Source/WebKit2/WebProcess/qt/WebProcessQt.cpp | 22 +- Source/cmake/ECMGenerateHeaders.cmake | 16 +- Source/cmake/OptionsQt.cmake | 40 +- Source/cmake/WebKitFS.cmake | 2 + Tools/DumpRenderTree/PlatformQt.cmake | 4 +- Tools/MiniBrowser/qt/CMakeLists.txt | 64 ++ Tools/MiniBrowser/qt/MiniBrowserApplication.cpp | 3 +- Tools/PlatformQt.cmake | 9 +- Tools/QtTestBrowser/CMakeLists.txt | 6 +- Tools/WebKitTestRunner/CMakeLists.txt | 1 + Tools/qt/manifest.txt | 6 + 190 files changed, 6090 insertions(+), 1304 deletions(-) create mode 100644 Source/WebCore/plugins/qt/QtX11ImageConversion.cpp create mode 100644 Source/WebCore/plugins/qt/QtX11ImageConversion.h delete mode 100644 Source/WebKit/qt/Plugins/QtX11ImageConversion.cpp delete mode 100644 Source/WebKit/qt/Plugins/QtX11ImageConversion.h create mode 100644 Source/WebKit/qt/declarative/CMakeLists.txt create mode 100644 Source/WebKit/qt/declarative/experimental/CMakeLists.txt create mode 100644 Source/WebKit2/DatabaseProcess/EntryPoint/qt/DatabaseProcessMain.cpp create mode 100644 Source/WebKit2/DatabaseProcess/qt/DatabaseProcessMainQt.cpp create mode 100644 Source/WebKit2/NetworkProcess/CustomProtocols/qt/CustomProtocolManagerImpl.h create mode 100644 Source/WebKit2/NetworkProcess/CustomProtocols/qt/CustomProtocolManagerQt.cpp create mode 100644 Source/WebKit2/NetworkProcess/EntryPoint/qt/NetworkProcessMain.cpp create mode 100644 Source/WebKit2/NetworkProcess/qt/NetworkProcessMainQt.cpp create mode 100644 Source/WebKit2/NetworkProcess/qt/NetworkProcessQt.cpp create mode 100644 Source/WebKit2/NetworkProcess/qt/QtNetworkAccessManager.cpp create mode 100644 Source/WebKit2/NetworkProcess/qt/QtNetworkAccessManager.h create mode 100644 Source/WebKit2/NetworkProcess/qt/RemoteNetworkingContextQt.cpp create mode 100644 Source/WebKit2/Platform/IPC/mac/ConnectionMac.mm create mode 100644 Source/WebKit2/Platform/IPC/mac/ImportanceAssertion.h create mode 100644 Source/WebKit2/Platform/IPC/mac/MachPort.h create mode 100644 Source/WebKit2/Platform/IPC/win/ConnectionWin.cpp create mode 100644 Source/WebKit2/Platform/mac/LayerHostingContext.h create mode 100644 Source/WebKit2/Platform/mac/LayerHostingContext.mm create mode 100644 Source/WebKit2/Platform/mac/MachUtilities.cpp create mode 100644 Source/WebKit2/Platform/mac/MachUtilities.h create mode 100644 Source/WebKit2/Platform/mac/MenuUtilities.h create mode 100644 Source/WebKit2/Platform/mac/MenuUtilities.mm create mode 100644 Source/WebKit2/Platform/mac/SharedMemoryMac.cpp create mode 100644 Source/WebKit2/Platform/mac/StringUtilities.h create mode 100644 Source/WebKit2/Platform/mac/StringUtilities.mm create mode 100644 Source/WebKit2/Platform/win/SharedMemoryWin.cpp create mode 100644 Source/WebKit2/Shared/Authentication/qt/AuthenticationManagerQt.cpp create mode 100644 Source/WebKit2/Shared/qt/ChildProcessMainQt.cpp create mode 100644 Source/WebKit2/UIProcess/API/APIURLSchemeHandlerTask.cpp create mode 100644 Source/WebKit2/UIProcess/API/APIURLSchemeHandlerTask.h create mode 100644 Source/WebKit2/UIProcess/API/qt/APIWebsiteDataStoreQt.cpp create mode 100644 Source/WebKit2/UIProcess/API/qt/tests/CMakeLists.txt create mode 100644 Source/WebKit2/UIProcess/Network/CustomProtocols/qt/CustomProtocolManagerProxyQt.cpp create mode 100644 Source/WebKit2/UIProcess/WebURLSchemeHandler.cpp create mode 100644 Source/WebKit2/UIProcess/WebURLSchemeHandler.h create mode 100644 Source/WebKit2/UIProcess/WebURLSchemeHandlerTask.cpp create mode 100644 Source/WebKit2/UIProcess/WebURLSchemeHandlerTask.h create mode 100644 Source/WebKit2/UIProcess/qt/QrcSchemeHandler.cpp create mode 100644 Source/WebKit2/UIProcess/qt/QrcSchemeHandler.h create mode 100644 Source/WebKit2/WebProcess/WebPage/WebURLSchemeHandlerProxy.cpp create mode 100644 Source/WebKit2/WebProcess/WebPage/WebURLSchemeHandlerProxy.h create mode 100644 Source/WebKit2/WebProcess/WebPage/WebURLSchemeHandlerTaskProxy.cpp create mode 100644 Source/WebKit2/WebProcess/WebPage/WebURLSchemeHandlerTaskProxy.h delete mode 100644 Source/WebKit2/WebProcess/qt/QtNetworkAccessManager.cpp delete mode 100644 Source/WebKit2/WebProcess/qt/QtNetworkAccessManager.h delete mode 100644 Source/WebKit2/WebProcess/qt/QtNetworkReply.cpp delete mode 100644 Source/WebKit2/WebProcess/qt/QtNetworkReply.h create mode 100644 Tools/MiniBrowser/qt/CMakeLists.txt diff --git a/Source/WTF/wtf/Compiler.h b/Source/WTF/wtf/Compiler.h index c2b808283..89f4ca42e 100644 --- a/Source/WTF/wtf/Compiler.h +++ b/Source/WTF/wtf/Compiler.h @@ -100,16 +100,15 @@ /* COMPILER(MSVC) - Microsoft Visual C++ */ #if defined(_MSC_VER) -#define WTF_COMPILER_MSVC 1 -#if _MSC_VER >= 1900 +#define WTF_COMPILER_MSVC 1 #define WTF_COMPILER_SUPPORTS_CXX_REFERENCE_QUALIFIED_FUNCTIONS 1 -#endif +#define WTF_COMPILER_SUPPORTS_CXX_USER_LITERALS 1 +#if _MSC_VER < 1900 +#error "Please use a newer version of Visual Studio. WebKit requires VS2015 or newer to compile." #endif -#if defined(_MSC_VER) && _MSC_VER < 1800 -#error "Please use a newer version of Visual Studio. WebKit requires VS2013 or newer to compile." #endif /* COMPILER(SUNCC) */ diff --git a/Source/WebCore/PlatformQt.cmake b/Source/WebCore/PlatformQt.cmake index 3f839b0dd..a6a807fce 100644 --- a/Source/WebCore/PlatformQt.cmake +++ b/Source/WebCore/PlatformQt.cmake @@ -43,6 +43,7 @@ list(APPEND WebCore_INCLUDE_DIRECTORIES "${WEBCORE_DIR}/platform/network/qt" "${WEBCORE_DIR}/platform/text/qt" "${WEBCORE_DIR}/platform/win" + "${WEBCORE_DIR}/platform/graphics/x11" "${WTF_DIR}" ) @@ -69,6 +70,7 @@ list(APPEND WebCore_SOURCES platform/audio/qt/AudioBusQt.cpp platform/graphics/ImageSource.cpp + platform/graphics/PlatformDisplay.cpp platform/graphics/WOFFFileFormat.cpp platform/graphics/texmap/BitmapTextureImageBuffer.cpp @@ -102,6 +104,9 @@ list(APPEND WebCore_SOURCES platform/graphics/surfaces/qt/GraphicsSurfaceQt.cpp + platform/graphics/x11/PlatformDisplayX11.cpp + platform/graphics/x11/XUniqueResource.cpp + platform/network/NetworkStorageSessionStub.cpp platform/network/MIMESniffing.cpp @@ -186,21 +191,32 @@ if (ENABLE_GRAPHICS_CONTEXT_3D) ) endif () -if (ENABLE_NETSCAPE_PLUGIN_API AND WIN32) - set(WebCore_FORWARDING_HEADERS_FILES - platform/graphics/win/LocalWindowsContext.h - platform/win/BitmapInfo.h - platform/win/WebCoreInstanceHandle.h - ) - list(APPEND WebCore_SOURCES - platform/graphics/win/TransformationMatrixWin.cpp - platform/win/BitmapInfo.cpp - platform/win/WebCoreInstanceHandle.cpp - ) - list(APPEND WebCore_LIBRARIES - Shlwapi - version - ) +if (ENABLE_NETSCAPE_PLUGIN_API) + if (WIN32) + set(WebCore_FORWARDING_HEADERS_FILES + platform/graphics/win/LocalWindowsContext.h + + platform/win/BitmapInfo.h + platform/win/WebCoreInstanceHandle.h + ) + list(APPEND WebCore_SOURCES + platform/graphics/win/TransformationMatrixWin.cpp + + platform/win/BitmapInfo.cpp + platform/win/WebCoreInstanceHandle.cpp + ) + list(APPEND WebCore_LIBRARIES + Shlwapi + version + ) + elseif (PLUGIN_BACKEND_XLIB) + set(WebCore_FORWARDING_HEADERS_FILES + plugins/qt/QtX11ImageConversion.h + ) + list(APPEND WebCore_SOURCES + plugins/qt/QtX11ImageConversion.cpp + ) + endif () endif () if (ENABLE_SMOOTH_SCROLLING) @@ -247,6 +263,7 @@ list(APPEND WebCore_LIBRARIES ${Qt5Network_LIBRARIES} ${Qt5Sensors_LIBRARIES} ${SQLITE_LIBRARIES} + ${X11_X11_LIB} ${ZLIB_LIBRARIES} ) @@ -399,36 +416,6 @@ if (WIN32) ) endif () -if (MSVC) - list(APPEND WebCore_INCLUDE_DIRECTORIES - "${CMAKE_BINARY_DIR}/../include/private" - "${CMAKE_BINARY_DIR}/../include/private/JavaScriptCore" - "${DERIVED_SOURCES_DIR}/ForwardingHeaders/ANGLE" - "${DERIVED_SOURCES_DIR}/ForwardingHeaders/ANGLE/include/KHR" - "${DERIVED_SOURCES_DIR}/ForwardingHeaders/JavaScriptCore" - "${DERIVED_SOURCES_DIR}/ForwardingHeaders/JavaScriptCore/ForwardingHeaders" - "${DERIVED_SOURCES_DIR}/ForwardingHeaders/JavaScriptCore/API" - "${DERIVED_SOURCES_DIR}/ForwardingHeaders/JavaScriptCore/assembler" - "${DERIVED_SOURCES_DIR}/ForwardingHeaders/JavaScriptCore/builtins" - "${DERIVED_SOURCES_DIR}/ForwardingHeaders/JavaScriptCore/bytecode" - "${DERIVED_SOURCES_DIR}/ForwardingHeaders/JavaScriptCore/bytecompiler" - "${DERIVED_SOURCES_DIR}/ForwardingHeaders/JavaScriptCore/dfg" - "${DERIVED_SOURCES_DIR}/ForwardingHeaders/JavaScriptCore/disassembler" - "${DERIVED_SOURCES_DIR}/ForwardingHeaders/JavaScriptCore/heap" - "${DERIVED_SOURCES_DIR}/ForwardingHeaders/JavaScriptCore/debugger" - "${DERIVED_SOURCES_DIR}/ForwardingHeaders/JavaScriptCore/interpreter" - "${DERIVED_SOURCES_DIR}/ForwardingHeaders/JavaScriptCore/jit" - "${DERIVED_SOURCES_DIR}/ForwardingHeaders/JavaScriptCore/llint" - "${DERIVED_SOURCES_DIR}/ForwardingHeaders/JavaScriptCore/parser" - "${DERIVED_SOURCES_DIR}/ForwardingHeaders/JavaScriptCore/profiler" - "${DERIVED_SOURCES_DIR}/ForwardingHeaders/JavaScriptCore/runtime" - "${DERIVED_SOURCES_DIR}/ForwardingHeaders/JavaScriptCore/yarr" - "${DERIVED_SOURCES_DIR}/ForwardingHeaders/WTF" - "${WEBCORE_DIR}/ForwardingHeaders" - "${WEBCORE_DIR}/platform/win" - ) -endif () - if (APPLE) list(APPEND WebCore_SOURCES platform/VNodeTracker.cpp diff --git a/Source/WebCore/page/FrameView.cpp b/Source/WebCore/page/FrameView.cpp index 4bae77613..bf35cf8b2 100644 --- a/Source/WebCore/page/FrameView.cpp +++ b/Source/WebCore/page/FrameView.cpp @@ -4592,6 +4592,7 @@ void FrameView::removeChild(Widget& widget) bool FrameView::wheelEvent(const PlatformWheelEvent& wheelEvent) { +#if !PLATFORM(QT) // Note that to allow for rubber-band over-scroll behavior, even non-scrollable views // should handle wheel events. #if !ENABLE(RUBBER_BANDING) @@ -4609,6 +4610,7 @@ bool FrameView::wheelEvent(const PlatformWheelEvent& wheelEvent) } return true; } +#endif // We don't allow mouse wheeling to happen in a ScrollView that has had its scrollbars explicitly disabled. if (!canHaveScrollbars()) diff --git a/Source/WebCore/platform/PlatformTouchEvent.h b/Source/WebCore/platform/PlatformTouchEvent.h index 7af33d75d..21e306dd5 100644 --- a/Source/WebCore/platform/PlatformTouchEvent.h +++ b/Source/WebCore/platform/PlatformTouchEvent.h @@ -26,12 +26,6 @@ #if ENABLE(TOUCH_EVENTS) -#if PLATFORM(QT) -QT_BEGIN_NAMESPACE -class QTouchEvent; -QT_END_NAMESPACE -#endif - namespace WebCore { diff --git a/Source/WebCore/platform/ScrollView.cpp b/Source/WebCore/platform/ScrollView.cpp index c06450945..33792b6cc 100644 --- a/Source/WebCore/platform/ScrollView.cpp +++ b/Source/WebCore/platform/ScrollView.cpp @@ -574,8 +574,13 @@ void ScrollView::updateScrollbars(const ScrollPosition& desiredPosition) { LOG_WITH_STREAM(Scrolling, stream << "ScrollView::updateScrollbars " << desiredPosition); +#if PLATFORM(QT) + if (m_inUpdateScrollbars || prohibitsScrolling() || platformWidget()) + return; +#else if (m_inUpdateScrollbars || prohibitsScrolling() || platformWidget() || delegatesScrolling()) return; +#endif bool hasOverlayScrollbars = (!m_horizontalScrollbar || m_horizontalScrollbar->isOverlayScrollbar()) && (!m_verticalScrollbar || m_verticalScrollbar->isOverlayScrollbar()); diff --git a/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp b/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp index 812980a28..b6eccf711 100644 --- a/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp +++ b/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp @@ -26,7 +26,7 @@ #include "TextureMapperAnimation.h" #include -#if !USE(COORDINATED_GRAPHICS) +#if !USE(COORDINATED_GRAPHICS) || PLATFORM(QT) namespace WebCore { diff --git a/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h b/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h index 74f6cea8b..121a54600 100644 --- a/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h +++ b/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h @@ -20,7 +20,7 @@ #ifndef GraphicsLayerTextureMapper_h #define GraphicsLayerTextureMapper_h -#if !USE(COORDINATED_GRAPHICS) +#if !USE(COORDINATED_GRAPHICS) || PLATFORM(QT) #include "GraphicsLayer.h" #include "GraphicsLayerClient.h" diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp b/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp index 895d37f39..fc0dafab1 100644 --- a/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp +++ b/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp @@ -451,7 +451,7 @@ TextureMapperLayer::~TextureMapperLayer() } } -#if !USE(COORDINATED_GRAPHICS) +#if !USE(COORDINATED_GRAPHICS) || PLATFORM(QT) void TextureMapperLayer::setChildren(const Vector& newChildren) { removeAllChildren(); diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h b/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h index 34c399af2..4fdb55263 100644 --- a/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h +++ b/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h @@ -76,7 +76,7 @@ public: TextureMapper* textureMapper() const { return rootLayer().m_textureMapper; } void setTextureMapper(TextureMapper* texmap) { m_textureMapper = texmap; } -#if !USE(COORDINATED_GRAPHICS) +#if !USE(COORDINATED_GRAPHICS) || PLATFORM(QT) void setChildren(const Vector&); #endif void setChildren(const Vector&); diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp index 7de531692..67d9ceae5 100644 --- a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp +++ b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp @@ -42,6 +42,7 @@ namespace WebCore { +#if !PLATFORM(QT) std::unique_ptr GraphicsLayer::create(GraphicsLayerFactory* factory, GraphicsLayerClient& client, Type layerType) { if (!factory) @@ -49,6 +50,7 @@ std::unique_ptr GraphicsLayer::create(GraphicsLayerFactory* facto return factory->createGraphicsLayer(layerType, client); } +#endif static CoordinatedLayerID toCoordinatedLayerID(GraphicsLayer* layer) { diff --git a/Source/WebCore/platform/network/ResourceHandle.cpp b/Source/WebCore/platform/network/ResourceHandle.cpp index 44c007a66..4f1651294 100644 --- a/Source/WebCore/platform/network/ResourceHandle.cpp +++ b/Source/WebCore/platform/network/ResourceHandle.cpp @@ -153,7 +153,7 @@ void ResourceHandle::clearClient() d->m_client = nullptr; } -#if !PLATFORM(COCOA) && !USE(CFNETWORK) && !USE(SOUP) +#if !PLATFORM(COCOA) && !USE(CFNETWORK) && !USE(SOUP) && !PLATFORM(QT) // ResourceHandle never uses async client calls on these platforms yet. void ResourceHandle::continueWillSendRequest(const ResourceRequest&) { diff --git a/Source/WebCore/platform/network/qt/CookieJarQt.cpp b/Source/WebCore/platform/network/qt/CookieJarQt.cpp index 020727cc7..3b08c06cd 100644 --- a/Source/WebCore/platform/network/qt/CookieJarQt.cpp +++ b/Source/WebCore/platform/network/qt/CookieJarQt.cpp @@ -32,6 +32,7 @@ #include "Cookie.h" #include "URL.h" #include "NetworkingContext.h" +#include "NotImplemented.h" #include "PlatformCookieJar.h" #include "SQLiteStatement.h" #include "SQLiteTransaction.h" @@ -114,8 +115,7 @@ String cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const bool cookiesEnabled(const NetworkStorageSession& session, const URL& /*firstParty*/, const URL& /*url*/) { - QNetworkCookieJar* jar = session.context() ? session.context()->networkAccessManager()->cookieJar() : SharedCookieJarQt::shared(); - return !!jar; + return true; } bool getRawCookies(const NetworkStorageSession& session, const URL& /*firstParty*/, const URL& /*url*/, Vector& rawCookies) @@ -138,12 +138,12 @@ void getHostnamesWithCookies(const NetworkStorageSession& session, HashSetgetHostnamesWithCookies(hostnames); } -void deleteCookiesForHostname(const NetworkStorageSession& session, const String& hostname) +void deleteCookiesForHostnames(const NetworkStorageSession& session, const Vector& hostNames) { ASSERT_UNUSED(session, !session.context()); // Not yet implemented for cookie jars other than the shared one. SharedCookieJarQt* jar = SharedCookieJarQt::shared(); if (jar) - jar->deleteCookiesForHostname(hostname); + jar->deleteCookiesForHostnames(hostNames); } void deleteAllCookies(const NetworkStorageSession& session) @@ -154,6 +154,14 @@ void deleteAllCookies(const NetworkStorageSession& session) jar->deleteAllCookies(); } +void deleteAllCookiesModifiedSince(const NetworkStorageSession& session, std::chrono::system_clock::time_point time) +{ + ASSERT_UNUSED(session, !session.context()); // Not yet implemented for cookie jars other than the shared one. + SharedCookieJarQt* jar = SharedCookieJarQt::shared(); + if (jar) + jar->deleteAllCookiesModifiedSince(time); +} + SharedCookieJarQt* SharedCookieJarQt::shared() { return s_sharedCookieJarQt; @@ -203,6 +211,13 @@ bool SharedCookieJarQt::deleteCookie(const QNetworkCookie& cookie) return true; } +void SharedCookieJarQt::deleteCookiesForHostnames(const Vector& hostNames) +{ + // QTFIXME: Implement as one statement or transaction + for (auto& hostname : hostNames) + deleteCookiesForHostname(hostname); +} + void SharedCookieJarQt::deleteCookiesForHostname(const String& hostname) { if (!m_database.isOpen()) @@ -245,6 +260,12 @@ void SharedCookieJarQt::deleteAllCookies() setAllCookies(QList()); } +void SharedCookieJarQt::deleteAllCookiesModifiedSince(std::chrono::system_clock::time_point) +{ + // QTFIXME + notImplemented(); +} + SharedCookieJarQt::SharedCookieJarQt(const String& cookieStorageDirectory) { if (!m_database.open(cookieStorageDirectory + ASCIILiteral("/cookies.db"))) { diff --git a/Source/WebCore/platform/network/qt/CookieJarQt.h b/Source/WebCore/platform/network/qt/CookieJarQt.h index 0f7b6abef..fb0e1a7c8 100644 --- a/Source/WebCore/platform/network/qt/CookieJarQt.h +++ b/Source/WebCore/platform/network/qt/CookieJarQt.h @@ -40,8 +40,9 @@ public: void getHostnamesWithCookies(HashSet&); bool deleteCookie(const QNetworkCookie&) final; - void deleteCookiesForHostname(const String&); + void deleteCookiesForHostnames(const Vector&); void deleteAllCookies(); + void deleteAllCookiesModifiedSince(std::chrono::system_clock::time_point); bool setCookiesFromUrl(const QList&, const QUrl&) final; void loadCookies(); @@ -49,6 +50,7 @@ private: SharedCookieJarQt(const String&); ~SharedCookieJarQt(); bool ensureDatabaseTable(); + void deleteCookiesForHostname(const String&); SQLiteDatabase m_database; }; diff --git a/Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp b/Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp index 951873190..cd096bfe7 100644 --- a/Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp +++ b/Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp @@ -563,6 +563,7 @@ void QNetworkReplyHandler::timerEvent(QTimerEvent* timerEvent) void QNetworkReplyHandler::sendResponseIfNeeded() { ASSERT(m_replyWrapper && m_replyWrapper->reply() && !wasAborted()); + ASSERT(!m_queue.deferSignals()); if (m_replyWrapper->reply()->error() && m_replyWrapper->reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).isNull()) return; @@ -585,7 +586,11 @@ void QNetworkReplyHandler::sendResponseIfNeeded() m_replyWrapper->encoding()); if (url.isLocalFile()) { - client->didReceiveResponse(m_resourceHandle, response); + if (client->usesAsyncCallbacks()) { + setLoadingDeferred(true); + client->didReceiveResponseAsync(m_resourceHandle, response); + } else + client->didReceiveResponse(m_resourceHandle, response); return; } @@ -607,11 +612,41 @@ void QNetworkReplyHandler::sendResponseIfNeeded() return; } - client->didReceiveResponse(m_resourceHandle, response); + if (client->usesAsyncCallbacks()) { + setLoadingDeferred(true); + client->didReceiveResponseAsync(m_resourceHandle, response); + } else + client->didReceiveResponse(m_resourceHandle, response); +} + +void QNetworkReplyHandler::continueAfterWillSendRequest(const ResourceRequest& newRequest) +{ + if (wasAborted()) // Network error cancelled the request. + return; + + m_request = newRequest.toNetworkRequest(m_resourceHandle->getInternal()->m_context.get()); +} + +void QNetworkReplyHandler::continueWillSendRequest(const ResourceRequest& newRequest) +{ + ASSERT(!m_resourceHandle->client() || m_resourceHandle->client()->usesAsyncCallbacks()); + ASSERT(m_queue.deferSignals()); + setLoadingDeferred(false); + + continueAfterWillSendRequest(newRequest); +} + +void QNetworkReplyHandler::continueDidReceiveResponse() +{ + ASSERT(!m_resourceHandle->client() || m_resourceHandle->client()->usesAsyncCallbacks()); + ASSERT(m_queue.deferSignals()); + setLoadingDeferred(false); } void QNetworkReplyHandler::redirect(ResourceResponse& response, const QUrl& redirection) { + ASSERT(!m_queue.deferSignals()); + QUrl newUrl = m_replyWrapper->reply()->url().resolved(redirection); ResourceHandleClient* client = m_resourceHandle->client(); @@ -644,11 +679,13 @@ void QNetworkReplyHandler::redirect(ResourceResponse& response, const QUrl& redi if (!newRequest.url().protocolIs("https") && protocolIs(newRequest.httpReferrer(), "https") && m_resourceHandle->context()->shouldClearReferrerOnHTTPSToHTTPRedirect()) newRequest.clearHTTPReferrer(); - client->willSendRequest(m_resourceHandle, newRequest, response); - if (wasAborted()) // Network error cancelled the request. - return; - - m_request = newRequest.toNetworkRequest(m_resourceHandle->getInternal()->m_context.get()); + if (client->usesAsyncCallbacks()) { + setLoadingDeferred(true); + client->willSendRequestAsync(m_resourceHandle, newRequest, response); + } else { + client->willSendRequest(m_resourceHandle, newRequest, response); + continueAfterWillSendRequest(newRequest); + } } void QNetworkReplyHandler::forwardData() @@ -663,6 +700,15 @@ void QNetworkReplyHandler::forwardData() if (!client) return; + // We have to use didReceiveBuffer instead of didReceiveData + // See https://bugs.webkit.org/show_bug.cgi?id=118598 + // and https://bugs.webkit.org/show_bug.cgi?id=118448#c32 + // NetworkResourceLoader implements only didReceiveBuffer and sends it over IPC to WebProcess + + // See also https://codereview.qt-project.org/#/c/79565/ + // + // FIXME: We need API to get unflattened array of data segments to convert it to non-contiguous SharedBuffer + qint64 bytesAvailable = m_replyWrapper->reply()->bytesAvailable(); Vector buffer(8128); // smaller than 8192 to fit within 8k including overhead. while (bytesAvailable > 0 && !m_queue.deferSignals()) { diff --git a/Source/WebCore/platform/network/qt/QNetworkReplyHandler.h b/Source/WebCore/platform/network/qt/QNetworkReplyHandler.h index 4619e4857..22bf18ed8 100644 --- a/Source/WebCore/platform/network/qt/QNetworkReplyHandler.h +++ b/Source/WebCore/platform/network/qt/QNetworkReplyHandler.h @@ -137,6 +137,9 @@ public: void forwardData(); void sendResponseIfNeeded(); + void continueWillSendRequest(const ResourceRequest&); + void continueDidReceiveResponse(); + static ResourceError errorForReply(QNetworkReply*); private Q_SLOTS: @@ -145,6 +148,7 @@ private Q_SLOTS: private: void start(); String httpMethod() const; + void continueAfterWillSendRequest(const ResourceRequest&); void redirect(ResourceResponse&, const QUrl&); bool wasAborted() const { return !m_resourceHandle; } QNetworkReply* sendNetworkRequest(QNetworkAccessManager*, const ResourceRequest&); diff --git a/Source/WebCore/platform/network/qt/ResourceHandleQt.cpp b/Source/WebCore/platform/network/qt/ResourceHandleQt.cpp index 64c5e47e8..b850e2327 100644 --- a/Source/WebCore/platform/network/qt/ResourceHandleQt.cpp +++ b/Source/WebCore/platform/network/qt/ResourceHandleQt.cpp @@ -135,6 +135,20 @@ void ResourceHandle::cancel() } } +void ResourceHandle::continueWillSendRequest(const ResourceRequest& request) +{ + ASSERT(!client() || client()->usesAsyncCallbacks()); + ASSERT(d->m_job); + d->m_job->continueWillSendRequest(request); +} + +void ResourceHandle::continueDidReceiveResponse() +{ + ASSERT(!client() || client()->usesAsyncCallbacks()); + ASSERT(d->m_job); + d->m_job->continueDidReceiveResponse(); +} + void ResourceHandle::platformLoadResourceSynchronously(NetworkingContext* context, const ResourceRequest& request, StoredCredentials /*storedCredentials*/, ResourceError& error, ResourceResponse& response, Vector& data) { WebCoreSynchronousLoader syncLoader(error, response, data); diff --git a/Source/WebCore/plugins/qt/QtX11ImageConversion.cpp b/Source/WebCore/plugins/qt/QtX11ImageConversion.cpp new file mode 100644 index 000000000..0a76fe239 --- /dev/null +++ b/Source/WebCore/plugins/qt/QtX11ImageConversion.cpp @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This 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 "QtX11ImageConversion.h" + +namespace WebCore { + +QImage qimageFromXImage(XImage* xi) +{ + QImage::Format format = QImage::Format_ARGB32_Premultiplied; + if (xi->depth == 24) + format = QImage::Format_RGB32; + else if (xi->depth == 16) + format = QImage::Format_RGB16; + + QImage image = QImage(reinterpret_cast(xi->data), xi->width, xi->height, xi->bytes_per_line, format).copy(); + + // we may have to swap the byte order + if ((QSysInfo::ByteOrder == QSysInfo::LittleEndian && xi->byte_order == MSBFirst) + || (QSysInfo::ByteOrder == QSysInfo::BigEndian && xi->byte_order == LSBFirst)) { + + for (int i = 0; i < image.height(); i++) { + if (xi->depth == 16) { + ushort* p = reinterpret_cast(image.scanLine(i)); + ushort* end = p + image.width(); + while (p < end) { + *p = ((*p << 8) & 0xff00) | ((*p >> 8) & 0x00ff); + p++; + } + } else { + uint* p = reinterpret_cast(image.scanLine(i)); + uint* end = p + image.width(); + while (p < end) { + *p = ((*p << 24) & 0xff000000) | ((*p << 8) & 0x00ff0000) + | ((*p >> 8) & 0x0000ff00) | ((*p >> 24) & 0x000000ff); + p++; + } + } + } + } + + // fix-up alpha channel + if (format == QImage::Format_RGB32) { + QRgb* p = reinterpret_cast(image.bits()); + for (int y = 0; y < xi->height; ++y) { + for (int x = 0; x < xi->width; ++x) + p[x] |= 0xff000000; + p += xi->bytes_per_line / 4; + } + } + + return image; +} + +} // namespace WebKit diff --git a/Source/WebCore/plugins/qt/QtX11ImageConversion.h b/Source/WebCore/plugins/qt/QtX11ImageConversion.h new file mode 100644 index 000000000..1a999a4ca --- /dev/null +++ b/Source/WebCore/plugins/qt/QtX11ImageConversion.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This 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 QtX11ImageConversion_h +#define QtX11ImageConversion_h + +#include +#include + +namespace WebCore { + +QImage qimageFromXImage(XImage*); + +} + +#endif diff --git a/Source/WebKit/CMakeLists.txt b/Source/WebKit/CMakeLists.txt index ac9c295ec..edc22fee9 100644 --- a/Source/WebKit/CMakeLists.txt +++ b/Source/WebKit/CMakeLists.txt @@ -74,6 +74,10 @@ if (${PORT} STREQUAL "Qt") MACOSX_FRAMEWORK_IDENTIFIER org.qt-project.QtWebKit ) endif () + + if (ENABLE_WEBKIT2) + add_dependencies(WebKit WebKit2) + endif () endif () add_dependencies(WebKit WebCore) diff --git a/Source/WebKit/PlatformQt.cmake b/Source/WebKit/PlatformQt.cmake index 6b6e0562e..beee95a5d 100644 --- a/Source/WebKit/PlatformQt.cmake +++ b/Source/WebKit/PlatformQt.cmake @@ -18,6 +18,8 @@ list(APPEND WebKit_INCLUDE_DIRECTORIES "${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}" "${DERIVED_SOURCES_WEBCORE_DIR}" "${JAVASCRIPTCORE_DIR}" + "${THIRDPARTY_DIR}/ANGLE" + "${THIRDPARTY_DIR}/ANGLE/include/KHR" # Copied from WebCore/CMakeLists.txt "${WEBCORE_DIR}/Modules/airplay" @@ -145,6 +147,7 @@ list(APPEND WebKit_INCLUDE_DIRECTORIES "${WEBCORE_DIR}/platform/network" "${WEBCORE_DIR}/platform/network/qt" "${WEBCORE_DIR}/platform/text/qt" + "${WEBCORE_DIR}/plugins/qt" "${WEBCORE_DIR}/rendering" "${WEBCORE_DIR}/rendering/style" @@ -225,6 +228,26 @@ list(APPEND WebKit_SYSTEM_INCLUDE_DIRECTORIES # Build the include path with duplicates removed list(REMOVE_DUPLICATES WebKit_SYSTEM_INCLUDE_DIRECTORIES) +if (ENABLE_WEBKIT2) + if (APPLE) + set(WEBKIT2_LIBRARY -Wl,-force_load WebKit2) + elseif (MSVC) + set(WEBKIT2_LIBRARY "-WHOLEARCHIVE:WebKit2") + elseif (UNIX) + set(WEBKIT2_LIBRARY -Wl,--whole-archive WebKit2 -Wl,--no-whole-archive) + else () + message(WARNING "Unknown system, linking with WebKit2 may fail!") + set(WEBKIT2_LIBRARY WebKit2) + endif () +endif () + +list(APPEND WebKit_LIBRARIES + PRIVATE + ${WEBKIT2_LIBRARY} + ${Qt5Quick_LIBRARIES} + ${Qt5WebChannel_LIBRARIES} +) + list(APPEND WebKit_LIBRARIES PRIVATE ${ICU_LIBRARIES} @@ -279,12 +302,6 @@ if (ENABLE_NETSCAPE_PLUGIN_API) ) endif () - if (PLUGIN_BACKEND_XLIB) - list(APPEND WebKit_SOURCES - qt/Plugins/QtX11ImageConversion.cpp - ) - endif () - if (WIN32) list(APPEND WebKit_INCLUDE_DIRECTORIES ${WEBCORE_DIR}/platform/win @@ -335,10 +352,16 @@ ecm_generate_headers( QWebSettings COMMON_HEADER QtWebKit + COMMON_HEADER_EXTRAS + + \"qwebkitglobal.h\" + \"qtwebkitversion.h\" + COMMON_HEADER_GUARD_NAME + QT_QTWEBKIT_MODULE_H RELATIVE qt/Api OUTPUT_DIR - "${DERIVED_SOURCES_DIR}/ForwardingHeaders/QtWebKit" + "${FORWARDING_HEADERS_DIR}/QtWebKit" REQUIRED_HEADERS QtWebKit_HEADERS ) @@ -349,7 +372,7 @@ set(WebKit_PUBLIC_HEADERS ${QtWebKit_FORWARDING_HEADERS} ) -generate_header("${DERIVED_SOURCES_DIR}/ForwardingHeaders/QtWebKit/qtwebkitversion.h" +generate_header("${FORWARDING_HEADERS_DIR}/QtWebKit/qtwebkitversion.h" WebKit_PUBLIC_HEADERS "#ifndef QT_QTWEBKIT_VERSION_H #define QT_QTWEBKIT_VERSION_H @@ -360,11 +383,11 @@ generate_header("${DERIVED_SOURCES_DIR}/ForwardingHeaders/QtWebKit/qtwebkitversi #endif ") -generate_header("${DERIVED_SOURCES_DIR}/ForwardingHeaders/QtWebKit/QtWebKitVersion" +generate_header("${FORWARDING_HEADERS_DIR}/QtWebKit/QtWebKitVersion" WebKit_PUBLIC_HEADERS "#include \"qtwebkitversion.h\"") -generate_header("${DERIVED_SOURCES_DIR}/ForwardingHeaders/QtWebKit/QtWebKitDepends" +generate_header("${FORWARDING_HEADERS_DIR}/QtWebKit/QtWebKitDepends" WebKit_PUBLIC_HEADERS "#ifdef __cplusplus /* create empty PCH in C mode */ #include @@ -586,10 +609,15 @@ ecm_generate_headers( QWebView COMMON_HEADER QtWebKitWidgets + COMMON_HEADER_EXTRAS + + \"qtwebkitwidgetsversion.h\" + COMMON_HEADER_GUARD_NAME + QT_QTWEBKITWIDGETS_MODULE_H RELATIVE qt/WidgetApi OUTPUT_DIR - "${DERIVED_SOURCES_DIR}/ForwardingHeaders/QtWebKitWidgets" + "${FORWARDING_HEADERS_DIR}/QtWebKitWidgets" REQUIRED_HEADERS QtWebKitWidgets_HEADERS ) @@ -599,7 +627,7 @@ set(WebKitWidgets_PUBLIC_HEADERS ${QtWebKitWidgets_FORWARDING_HEADERS} ) -generate_header("${DERIVED_SOURCES_DIR}/ForwardingHeaders/QtWebKitWidgets/qtwebkitwidgetsversion.h" +generate_header("${FORWARDING_HEADERS_DIR}/QtWebKitWidgets/qtwebkitwidgetsversion.h" WebKitWidgets_PUBLIC_HEADERS "#ifndef QT_QTWEBKITWIDGETS_VERSION_H #define QT_QTWEBKITWIDGETS_VERSION_H @@ -610,11 +638,11 @@ generate_header("${DERIVED_SOURCES_DIR}/ForwardingHeaders/QtWebKitWidgets/qtwebk #endif ") -generate_header("${DERIVED_SOURCES_DIR}/ForwardingHeaders/QtWebKitWidgets/QtWebKitWidgetsVersion" +generate_header("${FORWARDING_HEADERS_DIR}/QtWebKitWidgets/QtWebKitWidgetsVersion" WebKitWidgets_PUBLIC_HEADERS "#include \"qtwebkitwidgetsversion.h\"") -generate_header("${DERIVED_SOURCES_DIR}/ForwardingHeaders/QtWebKitWidgets/QtWebKitWidgetsDepends" +generate_header("${FORWARDING_HEADERS_DIR}/QtWebKitWidgets/QtWebKitWidgetsDepends" WebKitWidgets_PUBLIC_HEADERS "#ifdef __cplusplus /* create empty PCH in C mode */ #include @@ -796,4 +824,10 @@ if (COMPILER_IS_GCC_OR_CLANG) ) endif () -add_subdirectory(qt/tests) +if (ENABLE_WEBKIT2) + add_subdirectory(qt/declarative) +endif () + +if (ENABLE_API_TESTS) + add_subdirectory(qt/tests) +endif () diff --git a/Source/WebKit/qt/Plugins/QtX11ImageConversion.cpp b/Source/WebKit/qt/Plugins/QtX11ImageConversion.cpp deleted file mode 100644 index 0a76fe239..000000000 --- a/Source/WebKit/qt/Plugins/QtX11ImageConversion.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This 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 "QtX11ImageConversion.h" - -namespace WebCore { - -QImage qimageFromXImage(XImage* xi) -{ - QImage::Format format = QImage::Format_ARGB32_Premultiplied; - if (xi->depth == 24) - format = QImage::Format_RGB32; - else if (xi->depth == 16) - format = QImage::Format_RGB16; - - QImage image = QImage(reinterpret_cast(xi->data), xi->width, xi->height, xi->bytes_per_line, format).copy(); - - // we may have to swap the byte order - if ((QSysInfo::ByteOrder == QSysInfo::LittleEndian && xi->byte_order == MSBFirst) - || (QSysInfo::ByteOrder == QSysInfo::BigEndian && xi->byte_order == LSBFirst)) { - - for (int i = 0; i < image.height(); i++) { - if (xi->depth == 16) { - ushort* p = reinterpret_cast(image.scanLine(i)); - ushort* end = p + image.width(); - while (p < end) { - *p = ((*p << 8) & 0xff00) | ((*p >> 8) & 0x00ff); - p++; - } - } else { - uint* p = reinterpret_cast(image.scanLine(i)); - uint* end = p + image.width(); - while (p < end) { - *p = ((*p << 24) & 0xff000000) | ((*p << 8) & 0x00ff0000) - | ((*p >> 8) & 0x0000ff00) | ((*p >> 24) & 0x000000ff); - p++; - } - } - } - } - - // fix-up alpha channel - if (format == QImage::Format_RGB32) { - QRgb* p = reinterpret_cast(image.bits()); - for (int y = 0; y < xi->height; ++y) { - for (int x = 0; x < xi->width; ++x) - p[x] |= 0xff000000; - p += xi->bytes_per_line / 4; - } - } - - return image; -} - -} // namespace WebKit diff --git a/Source/WebKit/qt/Plugins/QtX11ImageConversion.h b/Source/WebKit/qt/Plugins/QtX11ImageConversion.h deleted file mode 100644 index 1a999a4ca..000000000 --- a/Source/WebKit/qt/Plugins/QtX11ImageConversion.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This 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 QtX11ImageConversion_h -#define QtX11ImageConversion_h - -#include -#include - -namespace WebCore { - -QImage qimageFromXImage(XImage*); - -} - -#endif diff --git a/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp b/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp index 37e66a0ef..0200557c2 100644 --- a/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp +++ b/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp @@ -453,7 +453,7 @@ void ChromeClientQt::scroll(const IntSize& delta, const IntRect& scrollViewRect, QMetaObject::invokeMethod(m_webPage->handle(), "scrollRequested", Q_ARG(int, delta.width()), Q_ARG(int, delta.height()), Q_ARG(QRect, scrollViewRect)); } -#if USE(TILED_BACKING_STORE) +#if USE(COORDINATED_GRAPHICS) void ChromeClientQt::delegatedScrollRequested(const IntPoint& point) { diff --git a/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.h b/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.h index 11826d535..393da12ac 100644 --- a/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.h +++ b/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.h @@ -119,7 +119,7 @@ public: void invalidateContentsAndRootView(const IntRect&) final; void invalidateContentsForSlowScroll(const IntRect&) final; void scroll(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect) final; -#if USE(TILED_BACKING_STORE) +#if USE(COORDINATED_GRAPHICS) void delegatedScrollRequested(const IntPoint& scrollPoint) final; #endif diff --git a/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp b/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp index 24578ae38..42fbdf25f 100644 --- a/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp +++ b/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp @@ -467,7 +467,7 @@ void DumpRenderTreeSupportQt::dumpSetAcceptsEditing(bool b) void DumpRenderTreeSupportQt::dumpNotification(bool b) { -#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) +#if ENABLE(NOTIFICATIONS) NotificationPresenterClientQt::dumpNotification = b; #endif } @@ -633,7 +633,7 @@ void DumpRenderTreeSupportQt::removeUserStyleSheets(QWebPageAdapter* adapter) void DumpRenderTreeSupportQt::simulateDesktopNotificationClick(const QString& title) { -#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) +#if ENABLE(NOTIFICATIONS) NotificationPresenterClientQt::notificationPresenter()->notificationClicked(title); #endif } @@ -870,7 +870,7 @@ QString DumpRenderTreeSupportQt::frameRenderTreeDump(QWebFrameAdapter* adapter) void DumpRenderTreeSupportQt::clearNotificationPermissions() { -#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) +#if ENABLE(NOTIFICATIONS) WebCore::NotificationPresenterClientQt::notificationPresenter()->clearCachedPermissions(); #endif } diff --git a/Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp b/Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp index fa57dfe1a..ccd1afb3e 100644 --- a/Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp +++ b/Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp @@ -49,7 +49,7 @@ namespace WebCore { -#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) +#if ENABLE(NOTIFICATIONS) const double notificationTimeout = 10.0; @@ -72,28 +72,28 @@ NotificationWrapper::NotificationWrapper() : m_closeTimer(*this, &NotificationWrapper::close) , m_displayEventTimer(*this, &NotificationWrapper::sendDisplayEvent) { -#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) +#if ENABLE(NOTIFICATIONS) m_presenter = nullptr; #endif } void NotificationWrapper::close() { -#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) +#if ENABLE(NOTIFICATIONS) NotificationPresenterClientQt::notificationPresenter()->cancel(this); #endif } void NotificationWrapper::sendDisplayEvent() { -#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) +#if ENABLE(NOTIFICATIONS) NotificationPresenterClientQt::notificationPresenter()->sendDisplayEvent(this); #endif } const QString NotificationWrapper::title() const { -#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) +#if ENABLE(NOTIFICATIONS) Notification* notification = NotificationPresenterClientQt::notificationPresenter()->notificationForWrapper(this); if (notification) return notification->title(); @@ -103,7 +103,7 @@ const QString NotificationWrapper::title() const const QString NotificationWrapper::message() const { -#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) +#if ENABLE(NOTIFICATIONS) Notification* notification = NotificationPresenterClientQt::notificationPresenter()->notificationForWrapper(this); if (notification) return notification->body(); @@ -113,7 +113,7 @@ const QString NotificationWrapper::message() const const QUrl NotificationWrapper::iconUrl() const { -#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) +#if ENABLE(NOTIFICATIONS) Notification* notification = NotificationPresenterClientQt::notificationPresenter()->notificationForWrapper(this); if (notification) return notification->iconURL(); @@ -124,7 +124,7 @@ const QUrl NotificationWrapper::iconUrl() const const QUrl NotificationWrapper::openerPageUrl() const { QUrl url; -#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) +#if ENABLE(NOTIFICATIONS) Notification* notification = NotificationPresenterClientQt::notificationPresenter()->notificationForWrapper(this); if (notification) { if (notification->scriptExecutionContext()) @@ -136,19 +136,19 @@ const QUrl NotificationWrapper::openerPageUrl() const void NotificationWrapper::notificationClicked() { -#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) +#if ENABLE(NOTIFICATIONS) NotificationPresenterClientQt::notificationPresenter()->notificationClicked(this); #endif } void NotificationWrapper::notificationClosed() { -#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) +#if ENABLE(NOTIFICATIONS) NotificationPresenterClientQt::notificationPresenter()->cancel(this); #endif } -#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) +#if ENABLE(NOTIFICATIONS) NotificationPresenterClientQt::NotificationPresenterClientQt() : m_clientCount(0) { @@ -292,37 +292,6 @@ void NotificationPresenterClientQt::notificationControllerDestroyed() { } -#if ENABLE(LEGACY_NOTIFICATIONS) -void NotificationPresenterClientQt::requestPermission(ScriptExecutionContext* context, PassRefPtr callback) -{ - if (dumpNotification) - printf("DESKTOP NOTIFICATION PERMISSION REQUESTED: %s\n", QString(context->securityOrigin()->toString()).toUtf8().constData()); - - NotificationClient::Permission permission = checkPermission(context); - if (permission != NotificationClient::PermissionNotAllowed) { - if (callback) - callback->handleEvent(); - return; - } - - QHash::iterator iter = m_pendingPermissionRequests.find(context); - if (iter != m_pendingPermissionRequests.end()) - iter.value().m_voidCallbacks.append(callback); - else { - RefPtr cb = callback; - CallbacksInfo info; - info.m_frame = toFrame(context); - info.m_voidCallbacks.append(cb); - - if (toPage(context) && toFrame(context)) { - m_pendingPermissionRequests.insert(context, info); - toPage(context)->notificationsPermissionRequested(toFrame(context)); - } - } -} -#endif - -#if ENABLE(NOTIFICATIONS) void NotificationPresenterClientQt::requestPermission(ScriptExecutionContext* context, PassRefPtr callback) { if (dumpNotification) @@ -350,7 +319,6 @@ void NotificationPresenterClientQt::requestPermission(ScriptExecutionContext* co } } } -#endif bool NotificationPresenterClientQt::hasPendingPermissionRequests(ScriptExecutionContext* context) const { @@ -403,20 +371,11 @@ void NotificationPresenterClientQt::setNotificationsAllowedForFrame(Frame* frame if (iter == m_pendingPermissionRequests.end()) return; -#if ENABLE(LEGACY_NOTIFICATIONS) - QList >& voidCallbacks = iter.value().m_voidCallbacks; - Q_FOREACH(const RefPtr& callback, voidCallbacks) { - if (callback) - callback->handleEvent(); - } -#endif -#if ENABLE(NOTIFICATIONS) QList >& callbacks = iter.value().m_callbacks; Q_FOREACH(const RefPtr& callback, callbacks) { if (callback) callback->handleEvent(Notification::permissionString(permission)); } -#endif m_pendingPermissionRequests.remove(iter.key()); } @@ -508,7 +467,7 @@ QWebFrameAdapter* NotificationPresenterClientQt::toFrame(ScriptExecutionContext* return QWebFrameAdapter::kit(document->frame()); } -#endif // ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) +#endif // ENABLE(NOTIFICATIONS) } #include "moc_NotificationPresenterClientQt.cpp" diff --git a/Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h b/Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h index 5c53e93f3..f53fe5101 100644 --- a/Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h +++ b/Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h @@ -74,7 +74,7 @@ private: friend class NotificationPresenterClientQt; }; -#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) +#if ENABLE(NOTIFICATIONS) typedef QHash NotificationsQueue; @@ -88,12 +88,7 @@ public: void cancel(Notification*) override; void notificationObjectDestroyed(Notification*) override; void notificationControllerDestroyed() override; -#if ENABLE(LEGACY_NOTIFICATIONS) - void requestPermission(ScriptExecutionContext*, PassRefPtr) override; -#endif -#if ENABLE(NOTIFICATIONS) void requestPermission(ScriptExecutionContext*, PassRefPtr) override; -#endif bool hasPendingPermissionRequests(ScriptExecutionContext*) const override; NotificationClient::Permission checkPermission(ScriptExecutionContext*) override; void cancelRequestsForPermission(ScriptExecutionContext*) override; @@ -132,12 +127,7 @@ private: int m_clientCount; struct CallbacksInfo { QWebFrameAdapter* m_frame; -#if ENABLE(LEGACY_NOTIFICATIONS) - QList > m_voidCallbacks; -#endif -#if ENABLE(NOTIFICATIONS) QList > m_callbacks; -#endif }; QHash m_pendingPermissionRequests; QHash m_cachedPermissions; @@ -149,7 +139,7 @@ private: #endif }; -#endif // ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) +#endif // ENABLE(NOTIFICATIONS) } diff --git a/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp b/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp index dc2370453..fb85535fc 100644 --- a/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp +++ b/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp @@ -287,7 +287,7 @@ void QWebPageAdapter::initializeWebCorePage() settings = new QWebSettings(&page->settings()); -#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) +#if ENABLE(NOTIFICATIONS) WebCore::provideNotification(page, NotificationPresenterClientQt::notificationPresenter()); #endif @@ -299,7 +299,7 @@ QWebPageAdapter::~QWebPageAdapter() delete page; delete settings; -#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) +#if ENABLE(NOTIFICATIONS) NotificationPresenterClientQt::notificationPresenter()->removeClient(); #endif #if ENABLE(DEVICE_ORIENTATION) @@ -1290,7 +1290,7 @@ QString QWebPageAdapter::contextMenuItemTagForAction(QWebPageAdapter::MenuAction } } -#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) +#if ENABLE(NOTIFICATIONS) void QWebPageAdapter::setNotificationsAllowedForFrame(QWebFrameAdapter* frame, bool allowed) { NotificationPresenterClientQt::notificationPresenter()->setNotificationsAllowedForFrame(frame->frame, allowed); @@ -1312,7 +1312,7 @@ void QWebPageAdapter::setSystemTrayIcon(QObject *icon) NotificationPresenterClientQt::notificationPresenter()->setSystemTrayIcon(icon); } #endif // QT_NO_SYSTEMTRAYICON -#endif // ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) +#endif // ENABLE(NOTIFICATIONS) #if ENABLE(GEOLOCATION) && HAVE(QTPOSITIONING) void QWebPageAdapter::setGeolocationEnabledForFrame(QWebFrameAdapter* frame, bool on) diff --git a/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.h b/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.h index 5e46fcdd7..48bc0afe0 100644 --- a/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.h +++ b/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.h @@ -352,14 +352,14 @@ public: #if ENABLE(GEOLOCATION) && HAVE(QTPOSITIONING) void setGeolocationEnabledForFrame(QWebFrameAdapter*, bool); #endif -#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) +#if ENABLE(NOTIFICATIONS) void setNotificationsAllowedForFrame(QWebFrameAdapter*, bool allowed); void addNotificationPresenterClient(); #ifndef QT_NO_SYSTEMTRAYICON bool hasSystemTrayIcon() const; void setSystemTrayIcon(QObject*); #endif // QT_NO_SYSTEMTRAYICON -#endif // ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) +#endif // ENABLE(NOTIFICATIONS) // Called from QWebPage as private slots. void _q_cleanupLeakMessages(); diff --git a/Source/WebKit/qt/WidgetApi/qwebpage.cpp b/Source/WebKit/qt/WidgetApi/qwebpage.cpp index 11b5a9dd6..c2bc712e8 100644 --- a/Source/WebKit/qt/WidgetApi/qwebpage.cpp +++ b/Source/WebKit/qt/WidgetApi/qwebpage.cpp @@ -207,13 +207,13 @@ QWebPagePrivate::QWebPagePrivate(QWebPage *qq) initializeWebCorePage(); memset(actions, 0, sizeof(actions)); -#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) +#if ENABLE(NOTIFICATIONS) addNotificationPresenterClient(); #ifndef QT_NO_SYSTEMTRAYICON if (!hasSystemTrayIcon()) setSystemTrayIcon(new QSystemTrayIcon); #endif // QT_NO_SYSTEMTRAYICON -#endif // ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) +#endif // ENABLE(NOTIFICATIONS) qRegisterMetaType(); int fullScreenRequestedIndex = q->metaObject()->indexOfMethod("fullScreenRequested(QWebFullScreenRequest)"); @@ -1674,13 +1674,13 @@ bool QWebPage::shouldInterruptJavaScript() */ void QWebPage::setFeaturePermission(QWebFrame* frame, Feature feature, PermissionPolicy policy) { -#if !ENABLE(NOTIFICATIONS) && !ENABLE(LEGACY_NOTIFICATIONS) && !ENABLE(GEOLOCATION) +#if !ENABLE(NOTIFICATIONS) && !ENABLE(GEOLOCATION) Q_UNUSED(frame); Q_UNUSED(policy); #endif switch (feature) { case Notifications: -#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) +#if ENABLE(NOTIFICATIONS) if (policy != PermissionUnknown) d->setNotificationsAllowedForFrame(frame->d, (policy == PermissionGrantedByUser)); #endif diff --git a/Source/WebKit/qt/declarative/CMakeLists.txt b/Source/WebKit/qt/declarative/CMakeLists.txt new file mode 100644 index 000000000..17502c664 --- /dev/null +++ b/Source/WebKit/qt/declarative/CMakeLists.txt @@ -0,0 +1,54 @@ +add_definitions(-DHAVE_WEBKIT2=1) +include_directories( + ${CMAKE_BINARY_DIR} + ${CMAKE_SOURCE_DIR}/Source + "${FORWARDING_HEADERS_DIR}" + "${FORWARDING_HEADERS_DIR}/QtWebKit" + + # The WebKit2 Qt APIs depend on qwebkitglobal.h, which lives in WebKit + "${WEBKIT_DIR}/qt/Api" + + "${WEBKIT2_DIR}/Platform" + "${WEBKIT2_DIR}/Platform/IPC" + "${WEBKIT2_DIR}/Shared/qt" + "${WEBKIT2_DIR}/UIProcess/API/qt" + + ${WTF_DIR} +) +include_directories(SYSTEM + ${Qt5Quick_INCLUDE_DIRS} + ${Qt5Quick_PRIVATE_INCLUDE_DIRS} +) + +add_library(qmlwebkitplugin MODULE plugin.cpp) +target_link_libraries(qmlwebkitplugin + WebKit Qt5::Quick) + +set(qmlwebkit_output_dir "${CMAKE_BINARY_DIR}/imports/QtWebKit") +set(qmlwebkit_install_dir "${QML_INSTALL_DIR}/QtWebKit") + +set_target_properties(qmlwebkitplugin PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY ${qmlwebkit_output_dir} + LIBRARY_OUTPUT_DIRECTORY ${qmlwebkit_output_dir} + RUNTIME_OUTPUT_DIRECTORY ${qmlwebkit_output_dir} + ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${qmlwebkit_output_dir} + LIBRARY_OUTPUT_DIRECTORY_DEBUG ${qmlwebkit_output_dir} + RUNTIME_OUTPUT_DIRECTORY_DEBUG ${qmlwebkit_output_dir} + ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${qmlwebkit_output_dir} + LIBRARY_OUTPUT_DIRECTORY_RELEASE ${qmlwebkit_output_dir} + RUNTIME_OUTPUT_DIRECTORY_RELEASE ${qmlwebkit_output_dir} +) + +add_custom_target( + qmlwebkitplugin-files ALL + COMMAND ${CMAKE_COMMAND} -E copy_if_different qmldir "${CMAKE_BINARY_DIR}/imports/QtWebKit/qmldir" + COMMAND ${CMAKE_COMMAND} -E copy_if_different plugins.qmltypes "${CMAKE_BINARY_DIR}/imports/QtWebKit/plugins.qmltypes" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} +) + +install(TARGETS qmlwebkitplugin + DESTINATION ${qmlwebkit_install_dir}) +install(FILES qmldir plugins.qmltypes + DESTINATION ${qmlwebkit_install_dir}) + +add_subdirectory(experimental) diff --git a/Source/WebKit/qt/declarative/experimental/CMakeLists.txt b/Source/WebKit/qt/declarative/experimental/CMakeLists.txt new file mode 100644 index 000000000..e4d41798c --- /dev/null +++ b/Source/WebKit/qt/declarative/experimental/CMakeLists.txt @@ -0,0 +1,29 @@ +add_library(qmlwebkitexperimentalplugin MODULE plugin.cpp) +target_link_libraries(qmlwebkitexperimentalplugin + WebKit Qt5::Quick) + +set(qmlwebkitexperimental_output_dir "${CMAKE_BINARY_DIR}/imports/QtWebKit/experimental") +set(qmlwebkitexperimental_install_dir "${QML_INSTALL_DIR}/QtWebKit/experimental") + +set_target_properties(qmlwebkitexperimentalplugin PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY ${qmlwebkitexperimental_output_dir} + LIBRARY_OUTPUT_DIRECTORY ${qmlwebkitexperimental_output_dir} + RUNTIME_OUTPUT_DIRECTORY ${qmlwebkitexperimental_output_dir} + ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${qmlwebkitexperimental_output_dir} + LIBRARY_OUTPUT_DIRECTORY_DEBUG ${qmlwebkitexperimental_output_dir} + RUNTIME_OUTPUT_DIRECTORY_DEBUG ${qmlwebkitexperimental_output_dir} + ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${qmlwebkitexperimental_output_dir} + LIBRARY_OUTPUT_DIRECTORY_RELEASE ${qmlwebkitexperimental_output_dir} + RUNTIME_OUTPUT_DIRECTORY_RELEASE ${qmlwebkitexperimental_output_dir} +) + +add_custom_target( + qmlwebkitexperimentalplugin-files ALL + COMMAND ${CMAKE_COMMAND} -E copy_if_different qmldir "${CMAKE_BINARY_DIR}/imports/QtWebKit/experimental/qmldir" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} +) + +install(TARGETS qmlwebkitexperimentalplugin + DESTINATION ${qmlwebkitexperimental_install_dir}) +install(FILES qmldir + DESTINATION ${qmlwebkitexperimental_install_dir}) diff --git a/Source/WebKit/qt/declarative/experimental/plugin.cpp b/Source/WebKit/qt/declarative/experimental/plugin.cpp index e81c31dbd..9d483cd38 100644 --- a/Source/WebKit/qt/declarative/experimental/plugin.cpp +++ b/Source/WebKit/qt/declarative/experimental/plugin.cpp @@ -35,7 +35,7 @@ QT_BEGIN_NAMESPACE -class QQuickWebViewExperimentalExtension : public QObject { +class QQuickWebViewExperimentalExtension final : public QObject { Q_OBJECT Q_PROPERTY(QQuickWebViewExperimental* experimental READ experimental CONSTANT FINAL) public: @@ -43,11 +43,11 @@ public: QQuickWebViewExperimental* experimental() { return static_cast(parent())->experimental(); } }; -class WebKitQmlExperimentalExtensionPlugin: public QQmlExtensionPlugin { +class WebKitQmlExperimentalExtensionPlugin final : public QQmlExtensionPlugin { Q_OBJECT Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid FILE "plugin.json") public: - void registerTypes(const char* uri) override + void registerTypes(const char* uri) final { qWarning("\nWARNING: This project is using the experimental QML API extensions for QtWebKit and is therefore tied to a specific QtWebKit release.\n" "WARNING: The experimental API will change from version to version, or even be removed. You have been warned!\n"); diff --git a/Source/WebKit/qt/declarative/plugin.cpp b/Source/WebKit/qt/declarative/plugin.cpp index bcd4c1187..8141914ad 100644 --- a/Source/WebKit/qt/declarative/plugin.cpp +++ b/Source/WebKit/qt/declarative/plugin.cpp @@ -37,19 +37,19 @@ QT_BEGIN_NAMESPACE -class WebKitQmlPlugin : public QQmlExtensionPlugin { +class WebKitQmlPlugin final : public QQmlExtensionPlugin { Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid FILE "plugin.json") Q_OBJECT public: #if defined(HAVE_WEBKIT2) - void initializeEngine(QQmlEngine* engine, const char* uri) override + void initializeEngine(QQmlEngine* engine, const char* uri) final { Q_UNUSED(uri); engine->addImageProvider(QLatin1String("webicon"), new QWebIconImageProvider); } #endif - void registerTypes(const char* uri) override + void registerTypes(const char* uri) final { Q_ASSERT(QLatin1String(uri) == QLatin1String("QtWebKit")); diff --git a/Source/WebKit/qt/tests/CMakeLists.txt b/Source/WebKit/qt/tests/CMakeLists.txt index 2691196b3..4fd45c624 100644 --- a/Source/WebKit/qt/tests/CMakeLists.txt +++ b/Source/WebKit/qt/tests/CMakeLists.txt @@ -2,7 +2,7 @@ remove_definitions(-DQT_ASCII_CAST_WARNINGS) include_directories( "${CMAKE_SOURCE_DIR}/Source" - "${DERIVED_SOURCES_DIR}/ForwardingHeaders" + "${FORWARDING_HEADERS_DIR}" "${WEBKIT_DIR}/qt/Api" "${WEBKIT_DIR}/qt/WidgetApi" ) @@ -48,19 +48,17 @@ set(QtWK1ApiTests set(tst_hybridPixmap_SOURCES hybridPixmap/widget.cpp) qt5_wrap_ui(tst_hybridPixmap_SOURCES hybridPixmap/widget.ui) -if (ENABLE_API_TESTS) - foreach (testName ${QtWK1ApiTests}) - list(APPEND tst_${testName}_SOURCES ${testName}/tst_${testName}.cpp) - if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${testName}/tst_${testName}.qrc") - qt5_add_resources(tst_${testName}_SOURCES ${testName}/tst_${testName}.qrc) - endif () +foreach (testName ${QtWK1ApiTests}) + list(APPEND tst_${testName}_SOURCES ${testName}/tst_${testName}.cpp) + if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${testName}/tst_${testName}.qrc") + qt5_add_resources(tst_${testName}_SOURCES ${testName}/tst_${testName}.qrc) + endif () - add_executable(tst_${testName} ${tst_${testName}_SOURCES}) - target_include_directories(tst_${testName} PRIVATE ${testName}) - target_link_libraries(tst_${testName} ${QtWK1ApiTests_LIBRARIES}) - set_target_properties(tst_${testName} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${QtWK1ApiTests_RUNTIME_OUTPUT_DIRECTORY}) + add_executable(tst_${testName} ${tst_${testName}_SOURCES}) + target_include_directories(tst_${testName} PRIVATE ${testName}) + target_link_libraries(tst_${testName} ${QtWK1ApiTests_LIBRARIES}) + set_target_properties(tst_${testName} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${QtWK1ApiTests_RUNTIME_OUTPUT_DIRECTORY}) - add_test(${testName} "${QtWK1ApiTests_RUNTIME_OUTPUT_DIRECTORY}/tst_${testName}") - set_tests_properties(${testName} PROPERTIES TIMEOUT 60) - endforeach () -endif () + add_test(${testName} "${QtWK1ApiTests_RUNTIME_OUTPUT_DIRECTORY}/tst_${testName}") + set_tests_properties(${testName} PROPERTIES TIMEOUT 60) +endforeach () diff --git a/Source/WebKit2/CMakeLists.txt b/Source/WebKit2/CMakeLists.txt index 4e4ec5c90..ffff0fc55 100644 --- a/Source/WebKit2/CMakeLists.txt +++ b/Source/WebKit2/CMakeLists.txt @@ -153,7 +153,9 @@ set(WebKit2_INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}/WebKitLibraries" ) -set(WebKit2_SYSTEM_INCLUDE_DIRECTORIES "") +set(WebKit2_SYSTEM_INCLUDE_DIRECTORIES + ${ICU_INCLUDE_DIRS} +) if (ENABLE_GRAPHICS_CONTEXT_3D) list(APPEND WebKit2_INCLUDE_DIRECTORIES @@ -384,6 +386,8 @@ set(WebKit2_SOURCES UIProcess/WebProcessProxy.cpp UIProcess/WebTextChecker.cpp UIProcess/WebTextCheckerClient.cpp + UIProcess/WebURLSchemeHandler.cpp + UIProcess/WebURLSchemeHandlerTask.cpp UIProcess/WebVibrationProvider.cpp UIProcess/WebVibrationProxy.cpp UIProcess/WebViewportAttributes.cpp @@ -396,6 +400,7 @@ set(WebKit2_SOURCES UIProcess/API/APIProcessPoolConfiguration.cpp UIProcess/API/APISession.cpp UIProcess/API/APISessionState.cpp + UIProcess/API/APIURLSchemeHandlerTask.cpp UIProcess/API/APIUserContentExtension.cpp UIProcess/API/APIUserContentExtensionStore.cpp UIProcess/API/APIWebsiteDataStore.cpp @@ -620,10 +625,10 @@ set(WebKit2_SOURCES WebProcess/WebPage/WebPage.cpp WebProcess/WebPage/WebPageGroupProxy.cpp WebProcess/WebPage/WebPageOverlay.cpp + WebProcess/WebPage/WebURLSchemeHandlerProxy.cpp + WebProcess/WebPage/WebURLSchemeHandlerTaskProxy.cpp WebProcess/WebPage/WebUndoStep.cpp - - ${NetworkProcess_COMMON_SOURCES} ) @@ -760,6 +765,8 @@ WEBKIT_FRAMEWORK(WebKit2) add_dependencies(WebKit2 WebCore ${WEBKIT2_EXTRA_DEPENDENCIES}) add_webkit2_prefix_header(WebKit2) +QT_ADD_EXTRA_WEBKIT_TARGET_EXPORT(WebKit2) + # Suppress unused parameter warnings for sources in WebKit2. ADD_TARGET_PROPERTIES(WebKit2 COMPILE_FLAGS "-Wno-unused-parameter") @@ -815,8 +822,8 @@ POPULATE_LIBRARY_VERSION(WEBKIT2) set_target_properties(WebKit2 PROPERTIES VERSION ${WEBKIT2_VERSION} SOVERSION ${WEBKIT2_VERSION_MAJOR}) if (NOT APPLE) - install(TARGETS WebKit2 WebProcess NetworkProcess - LIBRARY DESTINATION "${LIB_INSTALL_DIR}" - RUNTIME DESTINATION "${LIBEXEC_INSTALL_DIR}" - ) + install(TARGETS WebProcess NetworkProcess DESTINATION "${LIBEXEC_INSTALL_DIR}") + if (SHARED_CORE OR NOT PORT STREQUAL "Qt") + install(TARGETS WebKit2 DESTINATION "${LIB_INSTALL_DIR}") + endif () endif () diff --git a/Source/WebKit2/DatabaseProcess/EntryPoint/qt/DatabaseProcessMain.cpp b/Source/WebKit2/DatabaseProcess/EntryPoint/qt/DatabaseProcessMain.cpp new file mode 100644 index 000000000..27166c9a1 --- /dev/null +++ b/Source/WebKit2/DatabaseProcess/EntryPoint/qt/DatabaseProcessMain.cpp @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2016 Konstantin Tokarev + * + * 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" + +namespace WebKit { +Q_DECL_IMPORT int DatabaseProcessMainQt(int argc, char** argv); +} + +int main(int argc, char** argv) +{ + return WebKit::DatabaseProcessMainQt(argc, argv); +} diff --git a/Source/WebKit2/DatabaseProcess/qt/DatabaseProcessMainQt.cpp b/Source/WebKit2/DatabaseProcess/qt/DatabaseProcessMainQt.cpp new file mode 100644 index 000000000..93e86721a --- /dev/null +++ b/Source/WebKit2/DatabaseProcess/qt/DatabaseProcessMainQt.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2015 Naver Corp. 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 "DatabaseProcess.h" + +#if ENABLE(DATABASE_PROCESS) + +#include "ChildProcessMain.h" +#include + +using namespace WebCore; + +namespace WebKit { + +Q_DECL_EXPORT int DatabaseProcessMainQt(int argc, char** argv) +{ + QCoreApplication app(argc, argv); + return ChildProcessMain(argc, argv); +} + +} // namespace WebKit + +#endif // ENABLE(DATABASE_PROCESS) diff --git a/Source/WebKit2/NetworkProcess/CustomProtocols/qt/CustomProtocolManagerImpl.h b/Source/WebKit2/NetworkProcess/CustomProtocols/qt/CustomProtocolManagerImpl.h new file mode 100644 index 000000000..a115e40eb --- /dev/null +++ b/Source/WebKit2/NetworkProcess/CustomProtocols/qt/CustomProtocolManagerImpl.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2016 Konstantin Tokarev + * + * 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. + */ + +#pragma once + +#include + +namespace WebKit { + +class CustomProtocolManagerImpl { + WTF_MAKE_NONCOPYABLE(CustomProtocolManagerImpl); +}; + +} // namespace WebKit diff --git a/Source/WebKit2/NetworkProcess/CustomProtocols/qt/CustomProtocolManagerQt.cpp b/Source/WebKit2/NetworkProcess/CustomProtocols/qt/CustomProtocolManagerQt.cpp new file mode 100644 index 000000000..9e79503c4 --- /dev/null +++ b/Source/WebKit2/NetworkProcess/CustomProtocols/qt/CustomProtocolManagerQt.cpp @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2017 Konstantin Tokarev + * + * 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" + +namespace WebKit { + +const char* CustomProtocolManager::supplementName() +{ + return ""; +} + +CustomProtocolManager::CustomProtocolManager(ChildProcess*) + : m_impl(nullptr) +{ +} + +void CustomProtocolManager::initializeConnection(IPC::Connection*) +{ +} + +void CustomProtocolManager::initialize(const NetworkProcessCreationParameters&) +{ +} + +void CustomProtocolManager::registerScheme(const String&) +{ + ASSERT_NOT_REACHED(); +} + +void CustomProtocolManager::unregisterScheme(const String&) +{ +} + +bool CustomProtocolManager::supportsScheme(const String&) +{ + return false; +} + +void CustomProtocolManager::didFailWithError(uint64_t, const WebCore::ResourceError&) +{ + ASSERT_NOT_REACHED(); +} + +void CustomProtocolManager::didLoadData(uint64_t, const IPC::DataReference&) +{ +} + +void CustomProtocolManager::didReceiveResponse(uint64_t, const WebCore::ResourceResponse&, uint32_t) +{ +} + +void CustomProtocolManager::didFinishLoading(uint64_t) +{ +} + +void CustomProtocolManager::wasRedirectedToRequest(uint64_t, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&) +{ +} + +} // namespace WebKit diff --git a/Source/WebKit2/NetworkProcess/Downloads/Download.cpp b/Source/WebKit2/NetworkProcess/Downloads/Download.cpp index 67f8128fd..4d2398a54 100644 --- a/Source/WebKit2/NetworkProcess/Downloads/Download.cpp +++ b/Source/WebKit2/NetworkProcess/Downloads/Download.cpp @@ -53,9 +53,6 @@ Download::Download(DownloadManager& downloadManager, DownloadID downloadID, cons #if !USE(NETWORK_SESSION) , m_request(request) #endif -#if PLATFORM(QT) - , m_qtDownloader(0) -#endif { ASSERT(m_downloadID.downloadID()); diff --git a/Source/WebKit2/NetworkProcess/Downloads/Download.h b/Source/WebKit2/NetworkProcess/Downloads/Download.h index 9720f2aac..2c5a3a83d 100644 --- a/Source/WebKit2/NetworkProcess/Downloads/Download.h +++ b/Source/WebKit2/NetworkProcess/Downloads/Download.h @@ -149,7 +149,7 @@ private: RefPtr m_authenticationClient; #endif #if PLATFORM(QT) - QtFileDownloader* m_qtDownloader; + QtFileDownloader* m_qtDownloader { nullptr }; #endif #if PLATFORM(GTK) || PLATFORM(EFL) std::unique_ptr m_downloadClient; diff --git a/Source/WebKit2/NetworkProcess/Downloads/DownloadManager.cpp b/Source/WebKit2/NetworkProcess/Downloads/DownloadManager.cpp index 0dd20f0e1..f05aa645c 100644 --- a/Source/WebKit2/NetworkProcess/Downloads/DownloadManager.cpp +++ b/Source/WebKit2/NetworkProcess/Downloads/DownloadManager.cpp @@ -150,7 +150,7 @@ AuthenticationManager& DownloadManager::downloadsAuthenticationManager() } #if PLATFORM(QT) -void DownloadManager::startTransfer(uint64_t downloadID, const String& destination) +void DownloadManager::startTransfer(DownloadID downloadID, const String& destination) { ASSERT(m_downloads.contains(downloadID)); Download* download = m_downloads.get(downloadID); diff --git a/Source/WebKit2/NetworkProcess/Downloads/DownloadManager.h b/Source/WebKit2/NetworkProcess/Downloads/DownloadManager.h index ea433e5b0..53c8d3bb9 100644 --- a/Source/WebKit2/NetworkProcess/Downloads/DownloadManager.h +++ b/Source/WebKit2/NetworkProcess/Downloads/DownloadManager.h @@ -96,7 +96,7 @@ public: AuthenticationManager& downloadsAuthenticationManager(); #if PLATFORM(QT) - void startTransfer(uint64_t downloadID, const String& destination); + void startTransfer(DownloadID, const String& destination); #endif private: diff --git a/Source/WebKit2/NetworkProcess/Downloads/qt/DownloadQt.cpp b/Source/WebKit2/NetworkProcess/Downloads/qt/DownloadQt.cpp index 9747f5210..3db5ecdfb 100644 --- a/Source/WebKit2/NetworkProcess/Downloads/qt/DownloadQt.cpp +++ b/Source/WebKit2/NetworkProcess/Downloads/qt/DownloadQt.cpp @@ -28,7 +28,6 @@ #include "Download.h" #include "QtFileDownloader.h" -#include "WebProcess.h" #include #include #include @@ -41,19 +40,19 @@ namespace WebKit { void Download::start() { - QNetworkAccessManager* manager = WebProcess::singleton().networkAccessManager(); - ASSERT(manager); ASSERT(!m_qtDownloader); - - m_qtDownloader = new QtFileDownloader(this, manager->get(m_request.toNetworkRequest())); - m_qtDownloader->init(); + m_qtDownloader = new QtFileDownloader(*this, m_request.toNetworkRequest()); } void Download::startWithHandle(ResourceHandle* handle, const ResourceResponse& resp) { ASSERT(!m_qtDownloader); - m_qtDownloader = new QtFileDownloader(this, handle->getInternal()->m_job->release()); - m_qtDownloader->init(); + m_qtDownloader = new QtFileDownloader(*this, handle->getInternal()->m_job->release()); +} + +void Download::resume(const IPC::DataReference&, const WTF::String&, const SandboxExtension::Handle&) +{ + notImplemented(); } void Download::cancel() @@ -66,7 +65,7 @@ void Download::platformInvalidate() { ASSERT(m_qtDownloader); m_qtDownloader->deleteLater(); - m_qtDownloader = 0; + m_qtDownloader = nullptr; } void Download::startTransfer(const String& destination) diff --git a/Source/WebKit2/NetworkProcess/Downloads/qt/QtFileDownloader.cpp b/Source/WebKit2/NetworkProcess/Downloads/qt/QtFileDownloader.cpp index abed3cd34..2eaed702d 100644 --- a/Source/WebKit2/NetworkProcess/Downloads/qt/QtFileDownloader.cpp +++ b/Source/WebKit2/NetworkProcess/Downloads/qt/QtFileDownloader.cpp @@ -24,6 +24,7 @@ #include "Download.h" #include "HTTPParsers.h" #include "MIMETypeRegistry.h" +#include "NetworkProcess.h" #include #include #include @@ -37,12 +38,25 @@ using namespace WTF; namespace WebKit { -QtFileDownloader::QtFileDownloader(Download* download, QNetworkReply* reply) +QtFileDownloader::QtFileDownloader(Download& download, const QNetworkRequest& request) : m_download(download) - , m_reply(reply) + , m_reply(NetworkProcess::singleton().networkAccessManager().get(request)) , m_error(QNetworkReply::NoError) - , m_headersRead(false) { + makeConnections(); +} + +QtFileDownloader::QtFileDownloader(Download& download, QNetworkReply* reply) + : m_download(download) + , m_reply(reply) + , m_error(reply->error()) +{ + makeConnections(); + + if (reply->isFinished()) + onFinished(); + else if (reply->isReadable()) + onReadyRead(); } QtFileDownloader::~QtFileDownloader() @@ -53,7 +67,7 @@ QtFileDownloader::~QtFileDownloader() abortDownloadWritingAndEmitError(QtFileDownloader::DownloadErrorAborted); } -void QtFileDownloader::init() +void QtFileDownloader::makeConnections() { connect(m_reply.get(), SIGNAL(readyRead()), SLOT(onReadyRead())); connect(m_reply.get(), SIGNAL(finished()), SLOT(onFinished())); @@ -86,7 +100,7 @@ void QtFileDownloader::startTransfer(const QString& decidedFilePath) // finished shall be called in the end. m_destinationFile = WTFMove(downloadFile); - m_download->didCreateDestination(m_destinationFile->fileName()); + m_download.didCreateDestination(m_destinationFile->fileName()); // We might have gotten readyRead already even before this function // was called. @@ -105,7 +119,7 @@ void QtFileDownloader::abortDownloadWritingAndEmitError(QtFileDownloader::Downlo // On network failures it's QNetworkReplyHandler::errorForReply who will handle errors. if (errorCode == QtFileDownloader::DownloadErrorNetworkFailure) { - m_download->didFail(QNetworkReplyHandler::errorForReply(m_reply.get()), IPC::DataReference(0, 0)); + m_download.didFail(QNetworkReplyHandler::errorForReply(m_reply.get()), IPC::DataReference(0, 0)); return; } @@ -135,7 +149,7 @@ void QtFileDownloader::abortDownloadWritingAndEmitError(QtFileDownloader::Downlo ResourceError downloadError("Download", errorCode, m_reply->url(), translatedErrorMessage); - m_download->didFail(downloadError, IPC::DataReference(0, 0)); + m_download.didFail(downloadError, IPC::DataReference(0, 0)); } void QtFileDownloader::handleDownloadResponse() @@ -151,7 +165,7 @@ void QtFileDownloader::handleDownloadResponse() mimeType = MIMETypeRegistry::getMIMETypeForPath(m_reply->url().path()); ResourceResponse response(m_reply->url(), mimeType, m_reply->header(QNetworkRequest::ContentLengthHeader).toLongLong(), encoding); - m_download->didReceiveResponse(response); + m_download.didReceiveResponse(response); } void QtFileDownloader::onReadyRead() @@ -172,7 +186,7 @@ void QtFileDownloader::onReadyRead() // does not actually represent an error. ASSERT(bytesWritten == content.size()); - m_download->didReceiveData(bytesWritten); + m_download.didReceiveData(bytesWritten); } else if (!m_headersRead) { handleDownloadResponse(); m_headersRead = true; @@ -195,7 +209,7 @@ void QtFileDownloader::onFinished() m_destinationFile = nullptr; if (m_error == QNetworkReply::NoError) - m_download->didFinish(); + m_download.didFinish(); else if (m_error == QNetworkReply::OperationCanceledError) abortDownloadWritingAndEmitError(QtFileDownloader::DownloadErrorCancelled); else diff --git a/Source/WebKit2/NetworkProcess/Downloads/qt/QtFileDownloader.h b/Source/WebKit2/NetworkProcess/Downloads/qt/QtFileDownloader.h index 738f38b9c..58f2d5f1f 100644 --- a/Source/WebKit2/NetworkProcess/Downloads/qt/QtFileDownloader.h +++ b/Source/WebKit2/NetworkProcess/Downloads/qt/QtFileDownloader.h @@ -40,10 +40,11 @@ class Download; class QtFileDownloader : public QObject { Q_OBJECT public: - QtFileDownloader(Download*, QNetworkReply*); + QtFileDownloader(Download&, const QNetworkRequest&); + QtFileDownloader(Download&, QNetworkReply*); virtual ~QtFileDownloader(); + void cancel(); - void init(); void startTransfer(const QString& destination); enum DownloadError { @@ -62,14 +63,15 @@ private Q_SLOTS: void onError(QNetworkReply::NetworkError); private: + void makeConnections(); void abortDownloadWritingAndEmitError(QtFileDownloader::DownloadError); void handleDownloadResponse(); - Download* m_download; + Download& m_download; std::unique_ptr m_reply; std::unique_ptr m_destinationFile; QNetworkReply::NetworkError m_error; - bool m_headersRead; + bool m_headersRead { false }; }; } // namespace WebKit diff --git a/Source/WebKit2/NetworkProcess/EntryPoint/qt/NetworkProcessMain.cpp b/Source/WebKit2/NetworkProcess/EntryPoint/qt/NetworkProcessMain.cpp new file mode 100644 index 000000000..b102fc566 --- /dev/null +++ b/Source/WebKit2/NetworkProcess/EntryPoint/qt/NetworkProcessMain.cpp @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2016 Konstantin Tokarev + * + * 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" + +namespace WebKit { +Q_DECL_IMPORT int NetworkProcessMainQt(int argc, char** argv); +} + +int main(int argc, char** argv) +{ + return WebKit::NetworkProcessMainQt(argc, argv); +} diff --git a/Source/WebKit2/NetworkProcess/NetworkProcess.cpp b/Source/WebKit2/NetworkProcess/NetworkProcess.cpp index 15ee4a8f5..75ce5d4a2 100644 --- a/Source/WebKit2/NetworkProcess/NetworkProcess.cpp +++ b/Source/WebKit2/NetworkProcess/NetworkProcess.cpp @@ -451,6 +451,13 @@ void NetworkProcess::cancelDownload(DownloadID downloadID) { downloadManager().cancelDownload(downloadID); } + +#if PLATFORM(QT) +void NetworkProcess::startTransfer(DownloadID downloadID, const String& destination) +{ + downloadManager().startTransfer(downloadID, destination); +} +#endif #if USE(NETWORK_SESSION) void NetworkProcess::continueCanAuthenticateAgainstProtectionSpace(DownloadID downloadID, bool canAuthenticate) diff --git a/Source/WebKit2/NetworkProcess/NetworkProcess.h b/Source/WebKit2/NetworkProcess/NetworkProcess.h index e43a91fe9..4b573b9b5 100644 --- a/Source/WebKit2/NetworkProcess/NetworkProcess.h +++ b/Source/WebKit2/NetworkProcess/NetworkProcess.h @@ -41,6 +41,10 @@ #include "WebSQLiteDatabaseTracker.h" #endif +#if PLATFORM(QT) +#include "QtNetworkAccessManager.h" +#endif + namespace WebCore { class CertificateInfo; class NetworkStorageSession; @@ -99,6 +103,10 @@ public: void clearHSTSCache(WebCore::NetworkStorageSession&, std::chrono::system_clock::time_point modifiedSince); #endif +#if PLATFORM(QT) + QNetworkAccessManager& networkAccessManager() { return m_networkAccessManager; } +#endif + void prefetchDNS(const String&); private: @@ -154,6 +162,9 @@ private: void downloadRequest(WebCore::SessionID, DownloadID, const WebCore::ResourceRequest&); void resumeDownload(WebCore::SessionID, DownloadID, const IPC::DataReference& resumeData, const String& path, const SandboxExtension::Handle&); void cancelDownload(DownloadID); +#if PLATFORM(QT) + void startTransfer(DownloadID, const String& destination); +#endif #if USE(NETWORK_SESSION) void continueCanAuthenticateAgainstProtectionSpace(DownloadID, bool canAuthenticate); void continueWillSendRequest(DownloadID, const WebCore::ResourceRequest&); @@ -197,6 +208,10 @@ private: #if PLATFORM(IOS) WebSQLiteDatabaseTracker m_webSQLiteDatabaseTracker; #endif + +#if PLATFORM(QT) + QtNetworkAccessManager m_networkAccessManager; +#endif }; } // namespace WebKit diff --git a/Source/WebKit2/NetworkProcess/NetworkProcess.messages.in b/Source/WebKit2/NetworkProcess/NetworkProcess.messages.in index 315a54721..3c6f89337 100644 --- a/Source/WebKit2/NetworkProcess/NetworkProcess.messages.in +++ b/Source/WebKit2/NetworkProcess/NetworkProcess.messages.in @@ -44,6 +44,9 @@ messages -> NetworkProcess LegacyReceiver { DownloadRequest(WebCore::SessionID sessionID, WebKit::DownloadID downloadID, WebCore::ResourceRequest request) ResumeDownload(WebCore::SessionID sessionID, WebKit::DownloadID downloadID, IPC::DataReference resumeData, String path, WebKit::SandboxExtension::Handle sandboxExtensionHandle) CancelDownload(WebKit::DownloadID downloadID) +#if PLATFORM(QT) + StartTransfer(WebKit::DownloadID downloadID, String destination) +#endif #if USE(NETWORK_SESSION) ContinueCanAuthenticateAgainstProtectionSpace(WebKit::DownloadID downloadID, bool canAuthenticate) ContinueWillSendRequest(WebKit::DownloadID downloadID, WebCore::ResourceRequest request) diff --git a/Source/WebKit2/NetworkProcess/NetworkProcessCreationParameters.cpp b/Source/WebKit2/NetworkProcess/NetworkProcessCreationParameters.cpp index 751fbb11c..da6fb1902 100644 --- a/Source/WebKit2/NetworkProcess/NetworkProcessCreationParameters.cpp +++ b/Source/WebKit2/NetworkProcess/NetworkProcessCreationParameters.cpp @@ -77,7 +77,7 @@ void NetworkProcessCreationParameters::encode(IPC::ArgumentEncoder& encoder) con IPC::encode(encoder, networkATSContext.get()); #endif #endif -#if USE(SOUP) +#if USE(SOUP) || PLATFORM(QT) encoder << cookiePersistentStoragePath; encoder << cookiePersistentStorageType; encoder.encodeEnum(cookieAcceptPolicy); @@ -149,7 +149,7 @@ bool NetworkProcessCreationParameters::decode(IPC::ArgumentDecoder& decoder, Net #endif #endif -#if USE(SOUP) +#if USE(SOUP) || PLATFORM(QT) if (!decoder.decode(result.cookiePersistentStoragePath)) return false; if (!decoder.decode(result.cookiePersistentStorageType)) diff --git a/Source/WebKit2/NetworkProcess/NetworkProcessCreationParameters.h b/Source/WebKit2/NetworkProcess/NetworkProcessCreationParameters.h index a605d0ed3..dfd188a47 100644 --- a/Source/WebKit2/NetworkProcess/NetworkProcessCreationParameters.h +++ b/Source/WebKit2/NetworkProcess/NetworkProcessCreationParameters.h @@ -31,7 +31,7 @@ #include #include -#if USE(SOUP) +#if USE(SOUP) || PLATFORM(QT) #include "HTTPCookieAcceptPolicy.h" #endif @@ -90,7 +90,7 @@ struct NetworkProcessCreationParameters { #endif #endif -#if USE(SOUP) +#if USE(SOUP) || PLATFORM(QT) String cookiePersistentStoragePath; uint32_t cookiePersistentStorageType; HTTPCookieAcceptPolicy cookieAcceptPolicy; diff --git a/Source/WebKit2/NetworkProcess/RemoteNetworkingContext.h b/Source/WebKit2/NetworkProcess/RemoteNetworkingContext.h index 327f2c308..e44a5d078 100644 --- a/Source/WebKit2/NetworkProcess/RemoteNetworkingContext.h +++ b/Source/WebKit2/NetworkProcess/RemoteNetworkingContext.h @@ -69,6 +69,13 @@ private: #if PLATFORM(COCOA) bool m_localFileContentSniffingEnabled = false; #endif + +#if PLATFORM(QT) + QObject* originatingObject() const override { return nullptr; } + QNetworkAccessManager* networkAccessManager() const override; + bool mimeSniffingEnabled() const override { return true; } + bool thirdPartyCookiePolicyPermission(const QUrl&) const override { return true; } +#endif }; } diff --git a/Source/WebKit2/NetworkProcess/qt/NetworkProcessMainQt.cpp b/Source/WebKit2/NetworkProcess/qt/NetworkProcessMainQt.cpp new file mode 100644 index 000000000..d3799bb24 --- /dev/null +++ b/Source/WebKit2/NetworkProcess/qt/NetworkProcessMainQt.cpp @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2016 Konstantin Tokarev + * Copyright (C) 2014 Igalia S.L. + * Copyright (C) 2013 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 THE COPYRIGHT HOLDERS ``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 "NetworkProcess.h" + +#include "ChildProcessMain.h" + +#include +#include + +using namespace WebCore; + +namespace WebKit { + +class EnvHttpProxyFactory : public QNetworkProxyFactory { +public: + EnvHttpProxyFactory() { } + + bool initializeFromEnvironment(); + + QList queryProxy(const QNetworkProxyQuery& = QNetworkProxyQuery()); + +private: + QList m_httpProxy; + QList m_httpsProxy; +}; + +bool EnvHttpProxyFactory::initializeFromEnvironment() +{ + bool wasSetByEnvironment = false; + + QUrl proxyUrl = QUrl::fromUserInput(QString::fromLocal8Bit(qgetenv("http_proxy"))); + if (proxyUrl.isValid() && !proxyUrl.host().isEmpty()) { + int proxyPort = (proxyUrl.port() > 0) ? proxyUrl.port() : 8080; + m_httpProxy << QNetworkProxy(QNetworkProxy::HttpProxy, proxyUrl.host(), proxyPort); + wasSetByEnvironment = true; + } else + m_httpProxy << QNetworkProxy::NoProxy; + + proxyUrl = QUrl::fromUserInput(QString::fromLocal8Bit(qgetenv("https_proxy"))); + if (proxyUrl.isValid() && !proxyUrl.host().isEmpty()) { + int proxyPort = (proxyUrl.port() > 0) ? proxyUrl.port() : 8080; + m_httpsProxy << QNetworkProxy(QNetworkProxy::HttpProxy, proxyUrl.host(), proxyPort); + wasSetByEnvironment = true; + } else + m_httpsProxy << QNetworkProxy::NoProxy; + + return wasSetByEnvironment; +} + +QList EnvHttpProxyFactory::queryProxy(const QNetworkProxyQuery& query) +{ + QString protocol = query.protocolTag().toLower(); + bool localHost = false; + + if (!query.peerHostName().compare(QLatin1String("localhost"), Qt::CaseInsensitive) || !query.peerHostName().compare(QLatin1String("127.0.0.1"), Qt::CaseInsensitive)) + localHost = true; + if (protocol == QLatin1String("http") && !localHost) + return m_httpProxy; + if (protocol == QLatin1String("https") && !localHost) + return m_httpsProxy; + + QList proxies; + proxies << QNetworkProxy::NoProxy; + return proxies; +} + +static void initializeProxy() +{ + QList proxylist = QNetworkProxyFactory::systemProxyForQuery(); + if (proxylist.count() == 1) { + QNetworkProxy proxy = proxylist.first(); + if (proxy == QNetworkProxy::NoProxy || proxy == QNetworkProxy::DefaultProxy) { + auto proxyFactory = std::make_unique(); + if (proxyFactory->initializeFromEnvironment()) { + QNetworkProxyFactory::setApplicationProxyFactory(proxyFactory.release()); + return; + } + } + } + QNetworkProxyFactory::setUseSystemConfiguration(true); +} + +class NetworkProcessMain final: public ChildProcessMainBase { +public: + + bool platformInitialize() final + { + initializeProxy(); + return true; + } +}; + +Q_DECL_EXPORT int NetworkProcessMainQt(int argc, char** argv) +{ + QCoreApplication app(argc, argv); + return ChildProcessMain(argc, argv); +} + +} // namespace WebKit diff --git a/Source/WebKit2/NetworkProcess/qt/NetworkProcessQt.cpp b/Source/WebKit2/NetworkProcess/qt/NetworkProcessQt.cpp new file mode 100644 index 000000000..f822b3d20 --- /dev/null +++ b/Source/WebKit2/NetworkProcess/qt/NetworkProcessQt.cpp @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2016 Konstantin Tokarev + * + * 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 "NetworkProcess.h" + +#include "NetworkProcessCreationParameters.h" +#include "QtNetworkAccessManager.h" + +#include +#include +#include + +using namespace WebCore; + +namespace WebKit { + +void NetworkProcess::platformInitializeNetworkProcess(const NetworkProcessCreationParameters& parameters) +{ + if (!parameters.cookiePersistentStoragePath.isEmpty()) { + WebCore::SharedCookieJarQt* jar = WebCore::SharedCookieJarQt::create(parameters.cookiePersistentStoragePath); + m_networkAccessManager.setCookieJar(jar); + // Do not let QNetworkAccessManager delete the jar. + jar->setParent(0); + } + + if (!parameters.diskCacheDirectory.isEmpty()) { + QNetworkDiskCache* diskCache = new QNetworkDiskCache(); + diskCache->setCacheDirectory(parameters.diskCacheDirectory); + // The m_networkAccessManager takes ownership of the diskCache object upon the following call. + m_networkAccessManager.setCache(diskCache); + } +} + +void NetworkProcess::platformTerminate() +{ +} + +void NetworkProcess::allowSpecificHTTPSCertificateForHost(const CertificateInfo&, const String&) +{ +} + +void NetworkProcess::clearCacheForAllOrigins(uint32_t) +{ +} + +void NetworkProcess::clearDiskCache(std::chrono::system_clock::time_point, std::function) +{ +} + +void NetworkProcess::platformSetCacheModel(CacheModel) +{ +} + +} // namespace WebKit diff --git a/Source/WebKit2/NetworkProcess/qt/QtNetworkAccessManager.cpp b/Source/WebKit2/NetworkProcess/qt/QtNetworkAccessManager.cpp new file mode 100644 index 000000000..5e38a7717 --- /dev/null +++ b/Source/WebKit2/NetworkProcess/qt/QtNetworkAccessManager.cpp @@ -0,0 +1,136 @@ +/* + * Copyright (C) 2011 Zeno Albisser + * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) + * + * 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 "QtNetworkAccessManager.h" + +#include "WebPage.h" +#include "WebPageProxyMessages.h" +#include "WebProcess.h" +#include +#include +#include +#include + +namespace WebKit { + +QtNetworkAccessManager::QtNetworkAccessManager() + : QNetworkAccessManager() +{ + connect(this, SIGNAL(authenticationRequired(QNetworkReply*, QAuthenticator*)), SLOT(onAuthenticationRequired(QNetworkReply*, QAuthenticator*))); + connect(this, SIGNAL(proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*)), SLOT(onProxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*))); +#ifndef QT_NO_SSL + connect(this, SIGNAL(sslErrors(QNetworkReply*, QList)), SLOT(onSslErrors(QNetworkReply*, QList))); +#endif +} + +WebPage* QtNetworkAccessManager::obtainOriginatingWebPage(const QNetworkRequest& request) +{ + // QTFIXME: Old process model + if (!m_webProcess) + return nullptr; + + QObject* originatingObject = request.originatingObject(); + if (!originatingObject) + return 0; + + qulonglong pageID = originatingObject->property("pageID").toULongLong(); + return m_webProcess->webPage(pageID); +} + +void QtNetworkAccessManager::onProxyAuthenticationRequired(const QNetworkProxy& proxy, QAuthenticator* authenticator) +{ + // FIXME: Check if there is a better way to get a reference to the page. + WebPage* webPage = m_webProcess->focusedWebPage(); + + if (!webPage) + return; + + String hostname = proxy.hostName(); + uint16_t port = static_cast(proxy.port()); + String prefilledUsername = authenticator->user(); + String username; + String password; + + if (webPage->sendSync( + Messages::WebPageProxy::ProxyAuthenticationRequiredRequest(hostname, port, prefilledUsername), + Messages::WebPageProxy::ProxyAuthenticationRequiredRequest::Reply(username, password))) { + if (!username.isEmpty()) + authenticator->setUser(username); + if (!password.isEmpty()) + authenticator->setPassword(password); + } + +} + +void QtNetworkAccessManager::onAuthenticationRequired(QNetworkReply* reply, QAuthenticator* authenticator) +{ + WebPage* webPage = obtainOriginatingWebPage(reply->request()); + + // FIXME: This check can go away once our Qt version is up-to-date. See: QTBUG-23512. + if (!webPage) + return; + + String hostname = reply->url().toString(QUrl::RemovePath | QUrl::RemoveQuery | QUrl::RemoveFragment | QUrl::StripTrailingSlash); + String realm = authenticator->realm(); + String prefilledUsername = authenticator->user(); + String username; + String password; + + if (webPage->sendSync( + Messages::WebPageProxy::AuthenticationRequiredRequest(hostname, realm, prefilledUsername), + Messages::WebPageProxy::AuthenticationRequiredRequest::Reply(username, password))) { + if (!username.isEmpty()) + authenticator->setUser(username); + if (!password.isEmpty()) + authenticator->setPassword(password); + } +} + +void QtNetworkAccessManager::onSslErrors(QNetworkReply* reply, const QList& qSslErrors) +{ +#ifndef QT_NO_SSL + WebPage* webPage = obtainOriginatingWebPage(reply->request()); + + // FIXME: This check can go away once our Qt version is up-to-date. See: QTBUG-23512. + if (!webPage) + return; + + String hostname = reply->url().host(); + bool ignoreErrors = false; + + if (webPage->sendSync( + Messages::WebPageProxy::CertificateVerificationRequest(hostname), + Messages::WebPageProxy::CertificateVerificationRequest::Reply(ignoreErrors))) { + if (ignoreErrors) + reply->ignoreSslErrors(qSslErrors); + } +#endif +} + +} + +#include "moc_QtNetworkAccessManager.cpp" diff --git a/Source/WebKit2/NetworkProcess/qt/QtNetworkAccessManager.h b/Source/WebKit2/NetworkProcess/qt/QtNetworkAccessManager.h new file mode 100644 index 000000000..5b958f13e --- /dev/null +++ b/Source/WebKit2/NetworkProcess/qt/QtNetworkAccessManager.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2011 Zeno Albisser + * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) + * + * 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 QtNetworkAccessManager_h +#define QtNetworkAccessManager_h + +#include +#include +#include +#include + +namespace WebKit { + +class WebPage; +class WebProcess; + +class QtNetworkAccessManager : public QNetworkAccessManager { + Q_OBJECT +public: + QtNetworkAccessManager(); + +private Q_SLOTS: + void onAuthenticationRequired(QNetworkReply *, QAuthenticator *); + void onProxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator *); + void onSslErrors(QNetworkReply*, const QList&); + +private: + WebPage* obtainOriginatingWebPage(const QNetworkRequest&); + + WebProcess* m_webProcess { nullptr }; +}; + +} // namespace WebKit + +#endif // QtNetworkAccessManager_h diff --git a/Source/WebKit2/NetworkProcess/qt/RemoteNetworkingContextQt.cpp b/Source/WebKit2/NetworkProcess/qt/RemoteNetworkingContextQt.cpp new file mode 100644 index 000000000..96da15886 --- /dev/null +++ b/Source/WebKit2/NetworkProcess/qt/RemoteNetworkingContextQt.cpp @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2013 Apple Inc. All rights reserved. + * Copyright (C) 2013 University of Szeged. All rights reserved. + * Copyright (C) 2013 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 "RemoteNetworkingContext.h" + +#include "NetworkProcess.h" +#include +#include +#include +#include + +using namespace WebCore; + +namespace WebKit { + +RemoteNetworkingContext::~RemoteNetworkingContext() +{ +} + +bool RemoteNetworkingContext::isValid() const +{ + return true; +} + +void RemoteNetworkingContext::ensurePrivateBrowsingSession(SessionID) +{ + notImplemented(); +} + +NetworkStorageSession& RemoteNetworkingContext::storageSession() const +{ + return NetworkStorageSession::defaultStorageSession(); +} + +QNetworkAccessManager* RemoteNetworkingContext::networkAccessManager() const +{ + return &NetworkProcess::singleton().networkAccessManager(); +} + +} diff --git a/Source/WebKit2/Platform/IPC/mac/ConnectionMac.mm b/Source/WebKit2/Platform/IPC/mac/ConnectionMac.mm new file mode 100644 index 000000000..8626bf29c --- /dev/null +++ b/Source/WebKit2/Platform/IPC/mac/ConnectionMac.mm @@ -0,0 +1,643 @@ +/* + * 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 "Connection.h" + +#include "DataReference.h" +#include "ImportanceAssertion.h" +#include "MachPort.h" +#include "MachUtilities.h" +#include +#include +#include +#include +#include +#include + +#if PLATFORM(IOS) +#include "ProcessAssertion.h" +#include + +#if USE(APPLE_INTERNAL_SDK) +#include +#include +#else +#define kAXPidStatusChangedNotification 0 +#endif + +#endif + +#if PLATFORM(MAC) + +#if USE(APPLE_INTERNAL_SDK) +#include +#else +typedef enum { + AXSuspendStatusRunning = 0, + AXSuspendStatusSuspended, +} AXSuspendStatus; +#endif + +extern "C" AXError _AXUIElementNotifyProcessSuspendStatus(AXSuspendStatus); + +#endif // PLATFORM(MAC) + +namespace IPC { + +static const size_t inlineMessageMaxSize = 4096; + +// Message flags. +enum { + MessageBodyIsOutOfLine = 1 << 0 +}; + +// ConnectionTerminationWatchdog does two things: +// 1) It sets a watchdog timer to kill the peered process. +// 2) On iOS, make the process runnable for the duration of the watchdog +// to ensure it has a chance to terminate cleanly. +class ConnectionTerminationWatchdog { +public: + static void createConnectionTerminationWatchdog(OSObjectPtr& xpcConnection, double intervalInSeconds) + { + new ConnectionTerminationWatchdog(xpcConnection, intervalInSeconds); + } + +private: + ConnectionTerminationWatchdog(OSObjectPtr& xpcConnection, double intervalInSeconds) + : m_xpcConnection(xpcConnection) + , m_watchdogTimer(RunLoop::main(), this, &ConnectionTerminationWatchdog::watchdogTimerFired) +#if PLATFORM(IOS) + , m_assertion(std::make_unique(xpc_connection_get_pid(m_xpcConnection.get()), WebKit::AssertionState::Background)) +#endif + { + m_watchdogTimer.startOneShot(intervalInSeconds); + } + + void watchdogTimerFired() + { + xpc_connection_kill(m_xpcConnection.get(), SIGKILL); + delete this; + } + + OSObjectPtr m_xpcConnection; + RunLoop::Timer m_watchdogTimer; +#if PLATFORM(IOS) + std::unique_ptr m_assertion; +#endif +}; + +void Connection::platformInvalidate() +{ + if (!m_isConnected) + return; + + m_isConnected = false; + + ASSERT(m_sendPort); + ASSERT(m_receivePort); + + // Unregister our ports. + dispatch_source_cancel(m_deadNameSource); + dispatch_release(m_deadNameSource); + m_deadNameSource = 0; + m_sendPort = MACH_PORT_NULL; + + dispatch_source_cancel(m_receivePortDataAvailableSource); + dispatch_release(m_receivePortDataAvailableSource); + m_receivePortDataAvailableSource = 0; + m_receivePort = MACH_PORT_NULL; + +#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED <= 101000 + if (m_exceptionPort) { + dispatch_source_cancel(m_exceptionPortDataAvailableSource); + dispatch_release(m_exceptionPortDataAvailableSource); + m_exceptionPortDataAvailableSource = 0; + m_exceptionPort = MACH_PORT_NULL; + } +#endif + + m_xpcConnection = nullptr; +} + +void Connection::terminateSoon(double intervalInSeconds) +{ + if (m_xpcConnection) + ConnectionTerminationWatchdog::createConnectionTerminationWatchdog(m_xpcConnection, intervalInSeconds); +} + +void Connection::platformInitialize(Identifier identifier) +{ +#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED <= 101000 + m_exceptionPort = MACH_PORT_NULL; + m_exceptionPortDataAvailableSource = nullptr; +#endif + + if (m_isServer) { + m_receivePort = identifier.port; + m_sendPort = MACH_PORT_NULL; + } else { + m_receivePort = MACH_PORT_NULL; + m_sendPort = identifier.port; + } + + m_deadNameSource = nullptr; + m_receivePortDataAvailableSource = nullptr; + + m_xpcConnection = identifier.xpcConnection; +} + +template +static dispatch_source_t createDataAvailableSource(mach_port_t receivePort, WorkQueue& workQueue, Function&& function) +{ + dispatch_source_t source = dispatch_source_create(DISPATCH_SOURCE_TYPE_MACH_RECV, receivePort, 0, workQueue.dispatchQueue()); + dispatch_source_set_event_handler(source, function); + + dispatch_source_set_cancel_handler(source, ^{ + mach_port_mod_refs(mach_task_self(), receivePort, MACH_PORT_RIGHT_RECEIVE, -1); + }); + + return source; +} + +bool Connection::open() +{ + if (m_isServer) { + ASSERT(m_receivePort); + ASSERT(!m_sendPort); + + } else { + ASSERT(!m_receivePort); + ASSERT(m_sendPort); + + // Create the receive port. + mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &m_receivePort); + +#if PLATFORM(MAC) + mach_port_set_attributes(mach_task_self(), m_receivePort, MACH_PORT_DENAP_RECEIVER, (mach_port_info_t)0, 0); +#endif + + m_isConnected = true; + + // Send the initialize message, which contains a send right for the server to use. + auto encoder = std::make_unique("IPC", "InitializeConnection", 0); + encoder->encode(MachPort(m_receivePort, MACH_MSG_TYPE_MAKE_SEND)); + + sendMessage(WTFMove(encoder)); + + initializeDeadNameSource(); + } + + // Change the message queue length for the receive port. + setMachPortQueueLength(m_receivePort, MACH_PORT_QLIMIT_LARGE); + + // Register the data available handler. + RefPtr connection(this); + m_receivePortDataAvailableSource = createDataAvailableSource(m_receivePort, m_connectionQueue, [connection] { + connection->receiveSourceEventHandler(); + }); + +#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED <= 101000 + if (m_exceptionPort) { + m_exceptionPortDataAvailableSource = createDataAvailableSource(m_exceptionPort, m_connectionQueue, [connection] { + connection->exceptionSourceEventHandler(); + }); + + auto encoder = std::make_unique("IPC", "SetExceptionPort", 0); + encoder->encode(MachPort(m_exceptionPort, MACH_MSG_TYPE_MAKE_SEND)); + + sendMessage(WTFMove(encoder)); + } +#endif + + ref(); + dispatch_async(m_connectionQueue->dispatchQueue(), ^{ + dispatch_resume(m_receivePortDataAvailableSource); + + if (m_deadNameSource) + dispatch_resume(m_deadNameSource); +#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED <= 101000 + if (m_exceptionPortDataAvailableSource) + dispatch_resume(m_exceptionPortDataAvailableSource); +#endif + + deref(); + }); + + return true; +} + +static inline size_t machMessageSize(size_t bodySize, size_t numberOfPortDescriptors = 0, size_t numberOfOOLMemoryDescriptors = 0) +{ + size_t size = sizeof(mach_msg_header_t) + bodySize; + if (numberOfPortDescriptors || numberOfOOLMemoryDescriptors) { + size += sizeof(mach_msg_body_t); + if (numberOfPortDescriptors) + size += (numberOfPortDescriptors * sizeof(mach_msg_port_descriptor_t)); + if (numberOfOOLMemoryDescriptors) + size += (numberOfOOLMemoryDescriptors * sizeof(mach_msg_ool_descriptor_t)); + } + return round_msg(size); +} + +bool Connection::platformCanSendOutgoingMessages() const +{ + return true; +} + +bool Connection::sendOutgoingMessage(std::unique_ptr encoder) +{ + Vector attachments = encoder->releaseAttachments(); + + size_t numberOfPortDescriptors = 0; + size_t numberOfOOLMemoryDescriptors = 0; + for (size_t i = 0; i < attachments.size(); ++i) { + Attachment::Type type = attachments[i].type(); + if (type == Attachment::MachPortType) + numberOfPortDescriptors++; + } + + size_t messageSize = machMessageSize(encoder->bufferSize(), numberOfPortDescriptors, numberOfOOLMemoryDescriptors); + + bool messageBodyIsOOL = false; + if (messageSize > inlineMessageMaxSize) { + messageBodyIsOOL = true; + + numberOfOOLMemoryDescriptors++; + messageSize = machMessageSize(0, numberOfPortDescriptors, numberOfOOLMemoryDescriptors); + } + + char stackBuffer[inlineMessageMaxSize]; + char* buffer = &stackBuffer[0]; + if (messageSize > inlineMessageMaxSize) { + buffer = (char*)mmap(0, messageSize, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); + if (buffer == MAP_FAILED) + return false; + } + + bool isComplex = (numberOfPortDescriptors + numberOfOOLMemoryDescriptors > 0); + + mach_msg_header_t* header = reinterpret_cast(buffer); + header->msgh_bits = MACH_MSGH_BITS(MACH_MSG_TYPE_COPY_SEND, 0); + header->msgh_size = messageSize; + header->msgh_remote_port = m_sendPort; + header->msgh_local_port = MACH_PORT_NULL; + header->msgh_id = 0; + if (messageBodyIsOOL) + header->msgh_id |= MessageBodyIsOutOfLine; + + uint8_t* messageData; + + if (isComplex) { + header->msgh_bits |= MACH_MSGH_BITS_COMPLEX; + + mach_msg_body_t* body = reinterpret_cast(header + 1); + body->msgh_descriptor_count = numberOfPortDescriptors + numberOfOOLMemoryDescriptors; + uint8_t* descriptorData = reinterpret_cast(body + 1); + + for (size_t i = 0; i < attachments.size(); ++i) { + Attachment attachment = attachments[i]; + + mach_msg_descriptor_t* descriptor = reinterpret_cast(descriptorData); + switch (attachment.type()) { + case Attachment::MachPortType: + descriptor->port.name = attachment.port(); + descriptor->port.disposition = attachment.disposition(); + descriptor->port.type = MACH_MSG_PORT_DESCRIPTOR; + + descriptorData += sizeof(mach_msg_port_descriptor_t); + break; + default: + ASSERT_NOT_REACHED(); + } + } + + if (messageBodyIsOOL) { + mach_msg_descriptor_t* descriptor = reinterpret_cast(descriptorData); + + descriptor->out_of_line.address = encoder->buffer(); + descriptor->out_of_line.size = encoder->bufferSize(); + descriptor->out_of_line.copy = MACH_MSG_VIRTUAL_COPY; + descriptor->out_of_line.deallocate = false; + descriptor->out_of_line.type = MACH_MSG_OOL_DESCRIPTOR; + + descriptorData += sizeof(mach_msg_ool_descriptor_t); + } + + messageData = descriptorData; + } else + messageData = (uint8_t*)(header + 1); + + // Copy the data if it is not being sent out-of-line. + if (!messageBodyIsOOL) + memcpy(messageData, encoder->buffer(), encoder->bufferSize()); + + ASSERT(m_sendPort); + + // Send the message. + kern_return_t kr = mach_msg(header, MACH_SEND_MSG, messageSize, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (kr != KERN_SUCCESS) { + // FIXME: What should we do here? + } + + if (buffer != &stackBuffer[0]) + munmap(buffer, messageSize); + + return true; +} + +void Connection::initializeDeadNameSource() +{ + m_deadNameSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_MACH_SEND, m_sendPort, 0, m_connectionQueue->dispatchQueue()); + + RefPtr connection(this); + dispatch_source_set_event_handler(m_deadNameSource, [connection] { + connection->connectionDidClose(); + }); + + mach_port_t sendPort = m_sendPort; + dispatch_source_set_cancel_handler(m_deadNameSource, ^{ + // Release our send right. + mach_port_deallocate(mach_task_self(), sendPort); + }); +} + +static std::unique_ptr createMessageDecoder(mach_msg_header_t* header) +{ + if (!(header->msgh_bits & MACH_MSGH_BITS_COMPLEX)) { + // We have a simple message. + uint8_t* body = reinterpret_cast(header + 1); + size_t bodySize = header->msgh_size - sizeof(mach_msg_header_t); + + return std::make_unique(DataReference(body, bodySize), Vector()); + } + + bool messageBodyIsOOL = header->msgh_id & MessageBodyIsOutOfLine; + + mach_msg_body_t* body = reinterpret_cast(header + 1); + mach_msg_size_t numDescriptors = body->msgh_descriptor_count; + ASSERT(numDescriptors); + + uint8_t* descriptorData = reinterpret_cast(body + 1); + + // If the message body was sent out-of-line, don't treat the last descriptor + // as an attachment, since it is really the message body. + if (messageBodyIsOOL) + --numDescriptors; + + // Build attachment list + Vector attachments(numDescriptors); + + for (mach_msg_size_t i = 0; i < numDescriptors; ++i) { + mach_msg_descriptor_t* descriptor = reinterpret_cast(descriptorData); + + switch (descriptor->type.type) { + case MACH_MSG_PORT_DESCRIPTOR: + attachments[numDescriptors - i - 1] = Attachment(descriptor->port.name, descriptor->port.disposition); + descriptorData += sizeof(mach_msg_port_descriptor_t); + break; + default: + ASSERT(false && "Unhandled descriptor type"); + } + } + + if (messageBodyIsOOL) { + mach_msg_descriptor_t* descriptor = reinterpret_cast(descriptorData); + ASSERT(descriptor->type.type == MACH_MSG_OOL_DESCRIPTOR); + + uint8_t* messageBody = static_cast(descriptor->out_of_line.address); + size_t messageBodySize = descriptor->out_of_line.size; + + auto decoder = std::make_unique(DataReference(messageBody, messageBodySize), WTFMove(attachments)); + + vm_deallocate(mach_task_self(), reinterpret_cast(descriptor->out_of_line.address), descriptor->out_of_line.size); + + return decoder; + } + + uint8_t* messageBody = descriptorData; + size_t messageBodySize = header->msgh_size - (descriptorData - reinterpret_cast(header)); + + return std::make_unique(DataReference(messageBody, messageBodySize), attachments); +} + +// The receive buffer size should always include the maximum trailer size. +static const size_t receiveBufferSize = inlineMessageMaxSize + MAX_TRAILER_SIZE; +typedef Vector ReceiveBuffer; + +static mach_msg_header_t* readFromMachPort(mach_port_t machPort, ReceiveBuffer& buffer) +{ + buffer.resize(receiveBufferSize); + + mach_msg_header_t* header = reinterpret_cast(buffer.data()); + kern_return_t kr = mach_msg(header, MACH_RCV_MSG | MACH_RCV_LARGE | MACH_RCV_TIMEOUT, 0, buffer.size(), machPort, 0, MACH_PORT_NULL); + if (kr == MACH_RCV_TIMED_OUT) + return 0; + + if (kr == MACH_RCV_TOO_LARGE) { + // The message was too large, resize the buffer and try again. + buffer.resize(header->msgh_size + MAX_TRAILER_SIZE); + header = reinterpret_cast(buffer.data()); + + kr = mach_msg(header, MACH_RCV_MSG | MACH_RCV_LARGE | MACH_RCV_TIMEOUT, 0, buffer.size(), machPort, 0, MACH_PORT_NULL); + ASSERT(kr != MACH_RCV_TOO_LARGE); + } + + if (kr != MACH_MSG_SUCCESS) { + ASSERT_NOT_REACHED(); + return 0; + } + + return header; +} + +void Connection::receiveSourceEventHandler() +{ + ReceiveBuffer buffer; + + mach_msg_header_t* header = readFromMachPort(m_receivePort, buffer); + if (!header) + return; + + std::unique_ptr decoder = createMessageDecoder(header); + ASSERT(decoder); + +#if PLATFORM(MAC) + decoder->setImportanceAssertion(std::make_unique(header)); +#endif + + if (decoder->messageReceiverName() == "IPC" && decoder->messageName() == "InitializeConnection") { + ASSERT(m_isServer); + ASSERT(!m_isConnected); + ASSERT(!m_sendPort); + + MachPort port; + if (!decoder->decode(port)) { + // FIXME: Disconnect. + return; + } + + m_sendPort = port.port(); + + if (m_sendPort) { + initializeDeadNameSource(); + dispatch_resume(m_deadNameSource); + } + + m_isConnected = true; + + // Send any pending outgoing messages. + sendOutgoingMessages(); + + return; + } + +#if !PLATFORM(IOS) + if (decoder->messageReceiverName() == "IPC" && decoder->messageName() == "SetExceptionPort") { + if (m_isServer) { + // Server connections aren't supposed to have their exception ports overriden. Treat this as an invalid message. + RefPtr protectedThis(this); + StringReference messageReceiverName = decoder->messageReceiverName(); + StringCapture capturedMessageReceiverName(String(messageReceiverName.data(), messageReceiverName.size())); + StringReference messageName = decoder->messageName(); + StringCapture capturedMessageName(String(messageName.data(), messageName.size())); + RunLoop::main().dispatch([protectedThis, capturedMessageReceiverName, capturedMessageName] { + protectedThis->dispatchDidReceiveInvalidMessage(capturedMessageReceiverName.string().utf8(), capturedMessageName.string().utf8()); + }); + return; + } + MachPort exceptionPort; + if (!decoder->decode(exceptionPort)) + return; + + setMachExceptionPort(exceptionPort.port()); + return; + } +#endif + + processIncomingMessage(WTFMove(decoder)); +} + +#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED <= 101000 +void Connection::exceptionSourceEventHandler() +{ + ReceiveBuffer buffer; + + mach_msg_header_t* header = readFromMachPort(m_exceptionPort, buffer); + if (!header) + return; + + // We've read the exception message. Now send it on to the real exception port. + + // The remote port should have a send once right. + ASSERT(MACH_MSGH_BITS_REMOTE(header->msgh_bits) == MACH_MSG_TYPE_MOVE_SEND_ONCE); + + // Now get the real exception port. + mach_port_t exceptionPort = machExceptionPort(); + + // First, get the complex bit from the source message. + mach_msg_bits_t messageBits = header->msgh_bits & MACH_MSGH_BITS_COMPLEX; + messageBits |= MACH_MSGH_BITS(MACH_MSG_TYPE_COPY_SEND, MACH_MSG_TYPE_MOVE_SEND_ONCE); + + header->msgh_bits = messageBits; + header->msgh_local_port = header->msgh_remote_port; + header->msgh_remote_port = exceptionPort; + + // Now send along the message. + kern_return_t kr = mach_msg(header, MACH_SEND_MSG, header->msgh_size, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (kr != KERN_SUCCESS) + LOG_ERROR("Failed to send message to real exception port. %s (%x)", mach_error_string(kr), kr); + + connectionDidClose(); +} + +void Connection::setShouldCloseConnectionOnMachExceptions() +{ + ASSERT(m_exceptionPort == MACH_PORT_NULL); + + if (mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &m_exceptionPort) != KERN_SUCCESS) + ASSERT_NOT_REACHED(); + + if (mach_port_insert_right(mach_task_self(), m_exceptionPort, m_exceptionPort, MACH_MSG_TYPE_MAKE_SEND) != KERN_SUCCESS) + ASSERT_NOT_REACHED(); +} +#endif + +IPC::Connection::Identifier Connection::identifier() const +{ + return Identifier(m_isServer ? m_receivePort : m_sendPort, m_xpcConnection); +} + +bool Connection::getAuditToken(audit_token_t& auditToken) +{ + if (!m_xpcConnection) + return false; + + xpc_connection_get_audit_token(m_xpcConnection.get(), &auditToken); + return true; +} + +bool Connection::kill() +{ + if (m_xpcConnection) { + xpc_connection_kill(m_xpcConnection.get(), SIGKILL); + return true; + } + + return false; +} + +static void AccessibilityProcessSuspendedNotification(bool suspended) +{ +#if PLATFORM(MAC) + _AXUIElementNotifyProcessSuspendStatus(suspended ? AXSuspendStatusSuspended : AXSuspendStatusRunning); +#elif PLATFORM(IOS) + UIAccessibilityPostNotification(kAXPidStatusChangedNotification, @{ @"pid" : @(getpid()), @"suspended" : @(suspended) }); +#else + UNUSED_PARAM(suspended); +#endif +} + +void Connection::willSendSyncMessage(unsigned flags) +{ + if ((flags & InformPlatformProcessWillSuspend) && WebCore::AXObjectCache::accessibilityEnabled()) + AccessibilityProcessSuspendedNotification(true); +} + +void Connection::didReceiveSyncReply(unsigned flags) +{ + if ((flags & InformPlatformProcessWillSuspend) && WebCore::AXObjectCache::accessibilityEnabled()) + AccessibilityProcessSuspendedNotification(false); +} + +pid_t Connection::remoteProcessID() const +{ + if (!m_xpcConnection) + return 0; + + return xpc_connection_get_pid(m_xpcConnection.get()); +} + +} // namespace IPC diff --git a/Source/WebKit2/Platform/IPC/mac/ImportanceAssertion.h b/Source/WebKit2/Platform/IPC/mac/ImportanceAssertion.h new file mode 100644 index 000000000..f7687a7b7 --- /dev/null +++ b/Source/WebKit2/Platform/IPC/mac/ImportanceAssertion.h @@ -0,0 +1,63 @@ +/* + * 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 ImportanceAssertion_h +#define ImportanceAssertion_h + +#if PLATFORM(MAC) + +#if USE(APPLE_INTERNAL_SDK) +#include +#endif + +extern "C" int proc_denap_assertion_begin_with_msg(mach_msg_header_t*, uint64_t *); +extern "C" int proc_denap_assertion_complete(uint64_t); + +namespace IPC { + +class ImportanceAssertion { + WTF_MAKE_NONCOPYABLE(ImportanceAssertion); + +public: + explicit ImportanceAssertion(mach_msg_header_t* header) + : m_assertion(0) + { + proc_denap_assertion_begin_with_msg(header, &m_assertion); + } + + ~ImportanceAssertion() + { + proc_denap_assertion_complete(m_assertion); + } + +private: + uint64_t m_assertion; +}; + +} + +#endif // PLATFORM(MAC) + +#endif // ImportanceAssertion_h diff --git a/Source/WebKit2/Platform/IPC/mac/MachPort.h b/Source/WebKit2/Platform/IPC/mac/MachPort.h new file mode 100644 index 000000000..663ffcc46 --- /dev/null +++ b/Source/WebKit2/Platform/IPC/mac/MachPort.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 MachPort_h +#define MachPort_h + +#include "ArgumentDecoder.h" +#include "ArgumentEncoder.h" +#include "Attachment.h" + +namespace IPC { + +class MachPort { +public: + MachPort() + : m_port(MACH_PORT_NULL) + , m_disposition(0) + { + } + + MachPort(mach_port_name_t port, mach_msg_type_name_t disposition) + : m_port(port) + , m_disposition(disposition) + { + } + + void encode(ArgumentEncoder& encoder) const + { + encoder << Attachment(m_port, m_disposition); + } + + static bool decode(ArgumentDecoder& decoder, MachPort& p) + { + Attachment attachment; + if (!decoder.decode(attachment)) + return false; + + p.m_port = attachment.port(); + p.m_disposition = attachment.disposition(); + return true; + } + + mach_port_name_t port() const { return m_port; } + mach_msg_type_name_t disposition() const { return m_disposition; } + +private: + mach_port_name_t m_port; + mach_msg_type_name_t m_disposition; +}; + +} // namespace IPC + +#endif // MachPort_h diff --git a/Source/WebKit2/Platform/IPC/win/ConnectionWin.cpp b/Source/WebKit2/Platform/IPC/win/ConnectionWin.cpp new file mode 100644 index 000000000..a2730ca69 --- /dev/null +++ b/Source/WebKit2/Platform/IPC/win/ConnectionWin.cpp @@ -0,0 +1,351 @@ +/* + * 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 "Connection.h" + +#include "DataReference.h" +#include +#include +#include +#include + +using namespace std; + +namespace IPC { + +// FIXME: Rename this or use a different constant on windows. +static const size_t inlineMessageMaxSize = 4096; + +bool Connection::createServerAndClientIdentifiers(HANDLE& serverIdentifier, HANDLE& clientIdentifier) +{ + String pipeName; + + while (true) { + unsigned uniqueID = randomNumber() * std::numeric_limits::max(); + pipeName = String::format("\\\\.\\pipe\\com.apple.WebKit.%x", uniqueID); + + serverIdentifier = ::CreateNamedPipe(pipeName.charactersWithNullTermination().data(), + PIPE_ACCESS_DUPLEX | FILE_FLAG_FIRST_PIPE_INSTANCE | FILE_FLAG_OVERLAPPED, + PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE, 1, inlineMessageMaxSize, inlineMessageMaxSize, + 0, 0); + if (!serverIdentifier && ::GetLastError() == ERROR_PIPE_BUSY) { + // There was already a pipe with this name, try again. + continue; + } + + break; + } + + if (!serverIdentifier) + return false; + + clientIdentifier = ::CreateFileW(pipeName.charactersWithNullTermination().data(), GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0); + if (!clientIdentifier) { + ::CloseHandle(serverIdentifier); + return false; + } + + DWORD mode = PIPE_READMODE_MESSAGE; + if (!::SetNamedPipeHandleState(clientIdentifier, &mode, 0, 0)) { + ::CloseHandle(serverIdentifier); + ::CloseHandle(clientIdentifier); + return false; + } + + return true; +} + +void Connection::platformInitialize(Identifier identifier) +{ + memset(&m_readState, 0, sizeof(m_readState)); + m_readState.hEvent = ::CreateEventW(0, FALSE, FALSE, 0); + + memset(&m_writeState, 0, sizeof(m_writeState)); + m_writeState.hEvent = ::CreateEventW(0, FALSE, FALSE, 0); + + m_connectionPipe = identifier; +} + +void Connection::platformInvalidate() +{ + if (m_connectionPipe == INVALID_HANDLE_VALUE) + return; + + m_isConnected = false; + + m_connectionQueue->unregisterAndCloseHandle(m_readState.hEvent); + m_readState.hEvent = 0; + + m_connectionQueue->unregisterAndCloseHandle(m_writeState.hEvent); + m_writeState.hEvent = 0; + + ::CloseHandle(m_connectionPipe); + m_connectionPipe = INVALID_HANDLE_VALUE; +} + +void Connection::readEventHandler() +{ + if (m_connectionPipe == INVALID_HANDLE_VALUE) + return; + + while (true) { + // Check if we got some data. + DWORD numberOfBytesRead = 0; + if (!::GetOverlappedResult(m_connectionPipe, &m_readState, &numberOfBytesRead, FALSE)) { + DWORD error = ::GetLastError(); + + switch (error) { + case ERROR_BROKEN_PIPE: + connectionDidClose(); + return; + case ERROR_MORE_DATA: { + // Read the rest of the message out of the pipe. + + DWORD bytesToRead = 0; + if (!::PeekNamedPipe(m_connectionPipe, 0, 0, 0, 0, &bytesToRead)) { + DWORD error = ::GetLastError(); + if (error == ERROR_BROKEN_PIPE) { + connectionDidClose(); + return; + } + ASSERT_NOT_REACHED(); + return; + } + + // ::GetOverlappedResult told us there's more data. ::PeekNamedPipe shouldn't + // contradict it! + ASSERT(bytesToRead); + if (!bytesToRead) + break; + + m_readBuffer.grow(m_readBuffer.size() + bytesToRead); + if (!::ReadFile(m_connectionPipe, m_readBuffer.data() + numberOfBytesRead, bytesToRead, 0, &m_readState)) { + DWORD error = ::GetLastError(); + ASSERT_NOT_REACHED(); + return; + } + continue; + } + + // FIXME: We should figure out why we're getting this error. + case ERROR_IO_INCOMPLETE: + return; + default: + ASSERT_NOT_REACHED(); + } + } + + if (!m_readBuffer.isEmpty()) { + // We have a message, let's dispatch it. + + OwnPtr decoder = MessageDecoder::create(DataReference(m_readBuffer.data(), m_readBuffer.size())); + processIncomingMessage(decoder.release()); + } + + // Find out the size of the next message in the pipe (if there is one) so that we can read + // it all in one operation. (This is just an optimization to avoid an extra pass through the + // loop (if we chose a buffer size that was too small) or allocating extra memory (if we + // chose a buffer size that was too large).) + DWORD bytesToRead = 0; + if (!::PeekNamedPipe(m_connectionPipe, 0, 0, 0, 0, &bytesToRead)) { + DWORD error = ::GetLastError(); + if (error == ERROR_BROKEN_PIPE) { + connectionDidClose(); + return; + } + ASSERT_NOT_REACHED(); + } + if (!bytesToRead) { + // There's no message waiting in the pipe. Schedule a read of the first byte of the + // next message. We'll find out the message's actual size when it arrives. (If we + // change this to read more than a single byte for performance reasons, we'll have to + // deal with m_readBuffer potentially being larger than the message we read after + // calling ::GetOverlappedResult above.) + bytesToRead = 1; + } + + m_readBuffer.resize(bytesToRead); + + // Either read the next available message (which should occur synchronously), or start an + // asynchronous read of the next message that becomes available. + BOOL result = ::ReadFile(m_connectionPipe, m_readBuffer.data(), m_readBuffer.size(), 0, &m_readState); + if (result) { + // There was already a message waiting in the pipe, and we read it synchronously. + // Process it. + continue; + } + + DWORD error = ::GetLastError(); + + if (error == ERROR_IO_PENDING) { + // There are no messages in the pipe currently. readEventHandler will be called again once there is a message. + return; + } + + if (error == ERROR_MORE_DATA) { + // Either a message is available when we didn't think one was, or the message is larger + // than ::PeekNamedPipe told us. The former seems far more likely. Probably the message + // became available between our calls to ::PeekNamedPipe and ::ReadFile above. Go back + // to the top of the loop to use ::GetOverlappedResult to retrieve the available data. + continue; + } + + // FIXME: We need to handle other errors here. + ASSERT_NOT_REACHED(); + } +} + +void Connection::writeEventHandler() +{ + if (m_connectionPipe == INVALID_HANDLE_VALUE) + return; + + DWORD numberOfBytesWritten = 0; + if (!::GetOverlappedResult(m_connectionPipe, &m_writeState, &numberOfBytesWritten, FALSE)) { + DWORD error = ::GetLastError(); + if (error == ERROR_IO_INCOMPLETE) { + // FIXME: We should figure out why we're getting this error. + return; + } + if (error == ERROR_BROKEN_PIPE) { + connectionDidClose(); + return; + } + ASSERT_NOT_REACHED(); + } + + // The pending write has finished, so we are now done with its encoder. Clearing this member + // will allow us to send messages again. + m_pendingWriteEncoder = nullptr; + + // Now that the pending write has finished, we can try to send a new message. + sendOutgoingMessages(); +} + +bool Connection::open() +{ + // We connected the two ends of the pipe in createServerAndClientIdentifiers. + m_isConnected = true; + + // Start listening for read and write state events. + m_connectionQueue->registerHandle(m_readState.hEvent, bind(&Connection::readEventHandler, this)); + m_connectionQueue->registerHandle(m_writeState.hEvent, bind(&Connection::writeEventHandler, this)); + + // Schedule a read. + m_connectionQueue->dispatch(bind(&Connection::readEventHandler, this)); + + return true; +} + +bool Connection::platformCanSendOutgoingMessages() const +{ + // We only allow sending one asynchronous message at a time. If we wanted to send more than one + // at once, we'd have to use multiple OVERLAPPED structures and hold onto multiple pending + // MessageEncoders (one of each for each simultaneous asynchronous message). + return !m_pendingWriteEncoder; +} + +bool Connection::sendOutgoingMessage(PassOwnPtr encoder) +{ + ASSERT(!m_pendingWriteEncoder); + + // Just bail if the handle has been closed. + if (m_connectionPipe == INVALID_HANDLE_VALUE) + return false; + + // We put the message ID last. + *encoder << 0; + + // Write the outgoing message. + + if (::WriteFile(m_connectionPipe, encoder->buffer(), encoder->bufferSize(), 0, &m_writeState)) { + // We successfully sent this message. + return true; + } + + DWORD error = ::GetLastError(); + + if (error == ERROR_NO_DATA) { + // The pipe is being closed. + connectionDidClose(); + return false; + } + + if (error != ERROR_IO_PENDING) { + ASSERT_NOT_REACHED(); + return false; + } + + // The message will be sent soon. Hold onto the encoder so that it won't be destroyed + // before the write completes. + m_pendingWriteEncoder = encoder; + + // We can only send one asynchronous message at a time (see comment in platformCanSendOutgoingMessages). + return false; +} + +bool Connection::dispatchSentMessagesUntil(const Vector& windows, WTF::BinarySemaphore& semaphore, double absoluteTime) +{ + if (windows.isEmpty()) + return semaphore.wait(absoluteTime); + + HANDLE handle = semaphore.event(); + DWORD handleCount = 1; + + while (true) { + DWORD interval = absoluteTimeToWaitTimeoutInterval(absoluteTime); + if (!interval) { + // Consider the wait to have timed out, even if the semaphore is currently signaled. + // This matches the WTF::ThreadCondition implementation of BinarySemaphore::wait. + return false; + } + + DWORD result = ::MsgWaitForMultipleObjectsEx(handleCount, &handle, interval, QS_SENDMESSAGE, 0); + if (result == WAIT_OBJECT_0) { + // The semaphore was signaled. + return true; + } + if (result == WAIT_TIMEOUT) { + // absoluteTime was reached. + return false; + } + if (result == WAIT_OBJECT_0 + handleCount) { + // One or more sent messages are available. Process sent messages for all the windows + // we were given, since we don't have a way of knowing which window has available sent + // messages. + for (size_t i = 0; i < windows.size(); ++i) { + MSG message; + ::PeekMessageW(&message, windows[i], 0, 0, PM_NOREMOVE | PM_QS_SENDMESSAGE); + } + continue; + } + ASSERT_WITH_MESSAGE(result != WAIT_FAILED, "::MsgWaitForMultipleObjectsEx failed with error %lu", ::GetLastError()); + ASSERT_WITH_MESSAGE(false, "::MsgWaitForMultipleObjectsEx returned unexpected result %lu", result); + return false; + } +} + +} // namespace IPC diff --git a/Source/WebKit2/Platform/mac/LayerHostingContext.h b/Source/WebKit2/Platform/mac/LayerHostingContext.h new file mode 100644 index 000000000..9549b9f52 --- /dev/null +++ b/Source/WebKit2/Platform/mac/LayerHostingContext.h @@ -0,0 +1,85 @@ +/* + * 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 LayerHostingContext_h +#define LayerHostingContext_h + +#include "LayerTreeContext.h" +#include +#include +#include + +OBJC_CLASS CALayer; +OBJC_CLASS CAContext; + +namespace WebCore { +class MachSendRight; +} + +namespace WebKit { + +class LayerHostingContext { + WTF_MAKE_NONCOPYABLE(LayerHostingContext); WTF_MAKE_FAST_ALLOCATED; +public: + static std::unique_ptr createForPort(const WebCore::MachSendRight& serverPort); +#if HAVE(OUT_OF_PROCESS_LAYER_HOSTING) + static std::unique_ptr createForExternalHostingProcess(); +#endif + + LayerHostingContext(); + ~LayerHostingContext(); + + void setRootLayer(CALayer *); + CALayer *rootLayer() const; + + uint32_t contextID() const; + void invalidate(); + + LayerHostingMode layerHostingMode() { return m_layerHostingMode; } + + void setColorSpace(CGColorSpaceRef); + CGColorSpaceRef colorSpace() const; + +#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100 + void setColorMatchUntaggedContent(bool); + bool colorMatchUntaggedContent() const; +#endif + + // Fences only work on iOS and OS 10.10+. + void setFencePort(mach_port_t); + + // createFencePort does not install the fence port on the LayerHostingContext's + // CAContext; call setFencePort() with the newly created port if synchronization + // with this context is desired. + WebCore::MachSendRight createFencePort(); + +private: + LayerHostingMode m_layerHostingMode; + RetainPtr m_context; +}; + +} // namespace WebKit + +#endif // LayerHostingContext_h diff --git a/Source/WebKit2/Platform/mac/LayerHostingContext.mm b/Source/WebKit2/Platform/mac/LayerHostingContext.mm new file mode 100644 index 000000000..54fcb900d --- /dev/null +++ b/Source/WebKit2/Platform/mac/LayerHostingContext.mm @@ -0,0 +1,145 @@ +/* + * 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. + */ + +#import "config.h" +#import "LayerHostingContext.h" + +#import +#import +#import + +using namespace WebCore; + +namespace WebKit { + +std::unique_ptr LayerHostingContext::createForPort(const MachSendRight& serverPort) +{ + auto layerHostingContext = std::make_unique(); + + layerHostingContext->m_layerHostingMode = LayerHostingMode::InProcess; + layerHostingContext->m_context = (CAContext *)WKCAContextMakeRemoteWithServerPort(serverPort.sendRight()); + + return layerHostingContext; +} + +#if HAVE(OUT_OF_PROCESS_LAYER_HOSTING) +std::unique_ptr LayerHostingContext::createForExternalHostingProcess() +{ + auto layerHostingContext = std::make_unique(); + layerHostingContext->m_layerHostingMode = LayerHostingMode::OutOfProcess; + +#if PLATFORM(IOS) + // Use a very large display ID to ensure that the context is never put on-screen + // without being explicitly parented. See for details. + layerHostingContext->m_context = [CAContext remoteContextWithOptions:@{ + kCAContextIgnoresHitTest : @YES, + kCAContextDisplayId : @10000 }]; +#else + layerHostingContext->m_context = (CAContext *)WKCAContextMakeRemoteForWindowServer(); +#endif + + return layerHostingContext; +} +#endif + +LayerHostingContext::LayerHostingContext() +{ +} + +LayerHostingContext::~LayerHostingContext() +{ +} + +void LayerHostingContext::setRootLayer(CALayer *rootLayer) +{ + [m_context setLayer:rootLayer]; +} + +CALayer *LayerHostingContext::rootLayer() const +{ + return [m_context layer]; +} + +uint32_t LayerHostingContext::contextID() const +{ + return [m_context contextId]; +} + +void LayerHostingContext::invalidate() +{ + [m_context invalidate]; +} + +void LayerHostingContext::setColorSpace(CGColorSpaceRef colorSpace) +{ + [m_context setColorSpace:colorSpace]; +} + +CGColorSpaceRef LayerHostingContext::colorSpace() const +{ + return [m_context colorSpace]; +} + +#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100 +void LayerHostingContext::setColorMatchUntaggedContent(bool colorMatchUntaggedContent) +{ + if ([m_context respondsToSelector:@selector(setColorMatchUntaggedContent:)]) + [m_context setColorMatchUntaggedContent:colorMatchUntaggedContent]; +} + +bool LayerHostingContext::colorMatchUntaggedContent() const +{ + if ([m_context respondsToSelector:@selector(colorMatchUntaggedContent)]) + return [m_context colorMatchUntaggedContent]; + return false; +} +#endif + +#if HAVE(COREANIMATION_FENCES) +void LayerHostingContext::setFencePort(mach_port_t fencePort) +{ + [m_context setFencePort:fencePort]; +} + +MachSendRight LayerHostingContext::createFencePort() +{ + return MachSendRight::adopt([m_context createFencePort]); +} +#else +NO_RETURN_DUE_TO_ASSERT void LayerHostingContext::setFencePort(mach_port_t fencePort) +{ + ASSERT_NOT_REACHED(); +} + +NO_RETURN_DUE_TO_ASSERT MachSendRight LayerHostingContext::createFencePort() +{ + ASSERT_NOT_REACHED(); +#if ASSERT_DISABLED + return MachSendRight(); +#endif +} +#endif + +} // namespace WebKit diff --git a/Source/WebKit2/Platform/mac/MachUtilities.cpp b/Source/WebKit2/Platform/mac/MachUtilities.cpp new file mode 100644 index 000000000..7b38a3dbd --- /dev/null +++ b/Source/WebKit2/Platform/mac/MachUtilities.cpp @@ -0,0 +1,69 @@ +/* + * 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 "MachUtilities.h" + +#include +#include + +void setMachPortQueueLength(mach_port_t receivePort, mach_port_msgcount_t queueLength) +{ + mach_port_limits_t portLimits; + portLimits.mpl_qlimit = queueLength; + + mach_port_set_attributes(mach_task_self(), receivePort, MACH_PORT_LIMITS_INFO, reinterpret_cast(&portLimits), MACH_PORT_LIMITS_INFO_COUNT); +} + +mach_port_t machExceptionPort() +{ + exception_mask_t exceptionMasks[EXC_TYPES_COUNT]; + exception_port_t exceptionHandlers[EXC_TYPES_COUNT]; + exception_behavior_t exceptionBehaviors[EXC_TYPES_COUNT]; + thread_state_flavor_t exceptionFlavors[EXC_TYPES_COUNT]; + mach_msg_type_number_t numExceptionMasks; + + kern_return_t kr = task_get_exception_ports(mach_task_self(), EXC_MASK_CRASH, exceptionMasks, &numExceptionMasks, exceptionHandlers, exceptionBehaviors, exceptionFlavors); + if (kr != KERN_SUCCESS) { + ASSERT_NOT_REACHED(); + return MACH_PORT_NULL; + } + + // We're just interested in the first exception handler. + return exceptionHandlers[0]; +} + +void setMachExceptionPort(mach_port_t exceptionPort) +{ + // Assert that we dont try to call setMachExceptionPort more than once per process. +#if !ASSERT_DISABLED + static mach_port_t taskExceptionPort = MACH_PORT_NULL; + ASSERT(taskExceptionPort == MACH_PORT_NULL); + taskExceptionPort = exceptionPort; +#endif + + if (task_set_exception_ports(mach_task_self(), EXC_MASK_CRASH, exceptionPort, EXCEPTION_STATE_IDENTITY | MACH_EXCEPTION_CODES, MACHINE_THREAD_STATE) != KERN_SUCCESS) + ASSERT_NOT_REACHED(); +} diff --git a/Source/WebKit2/Platform/mac/MachUtilities.h b/Source/WebKit2/Platform/mac/MachUtilities.h new file mode 100644 index 000000000..a8d0d6ffe --- /dev/null +++ b/Source/WebKit2/Platform/mac/MachUtilities.h @@ -0,0 +1,36 @@ +/* + * 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 MachUtilities_h +#define MachUtilities_h + +#include + +void setMachPortQueueLength(mach_port_t, mach_port_msgcount_t queueLength); + +mach_port_t machExceptionPort(); +void setMachExceptionPort(mach_port_t exceptionPort); + +#endif // MachUtilities_h diff --git a/Source/WebKit2/Platform/mac/MenuUtilities.h b/Source/WebKit2/Platform/mac/MenuUtilities.h new file mode 100644 index 000000000..876882da1 --- /dev/null +++ b/Source/WebKit2/Platform/mac/MenuUtilities.h @@ -0,0 +1,42 @@ +/* + * 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 MenuUtilities_h +#define MenuUtilities_h + +#import +#import + +namespace WebKit { + +#if ENABLE(TELEPHONE_NUMBER_DETECTION) && PLATFORM(MAC) +NSMenuItem *menuItemForTelephoneNumber(const String& telephoneNumber); +RetainPtr menuForTelephoneNumber(const String& telephoneNumber); +NSString *menuItemTitleForTelephoneNumberGroup(); +#endif + +} // namespace WebKit + +#endif // MenuUtilities_h diff --git a/Source/WebKit2/Platform/mac/MenuUtilities.mm b/Source/WebKit2/Platform/mac/MenuUtilities.mm new file mode 100644 index 000000000..aaf23f0d2 --- /dev/null +++ b/Source/WebKit2/Platform/mac/MenuUtilities.mm @@ -0,0 +1,117 @@ +/* + * 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. + */ + +#import "config.h" +#import "MenuUtilities.h" + +#if PLATFORM(MAC) + +#import "StringUtilities.h" +#import +#import +#import + +#if ENABLE(TELEPHONE_NUMBER_DETECTION) +#import +#endif + +namespace WebKit { + +#if ENABLE(TELEPHONE_NUMBER_DETECTION) + +NSString *menuItemTitleForTelephoneNumberGroup() +{ + if ([getTUCallClass() respondsToSelector:@selector(supplementalDialTelephonyCallString)]) + return [getTUCallClass() supplementalDialTelephonyCallString]; + return WEB_UI_STRING("Call Using iPhone:", "menu item title for phone number"); +} + +NSMenuItem *menuItemForTelephoneNumber(const String& telephoneNumber) +{ + RetainPtr actionContext = [[getDDActionContextClass() alloc] init]; + [actionContext setAllowedActionUTIs:@[ @"com.apple.dial" ]]; + + NSArray *proposedMenuItems = [[getDDActionsManagerClass() sharedManager] menuItemsForValue:(NSString *)telephoneNumber type:getDDBinderPhoneNumberKey() service:nil context:actionContext.get()]; + for (NSMenuItem *item in proposedMenuItems) { + NSDictionary *representedObject = item.representedObject; + if (![representedObject isKindOfClass:[NSDictionary class]]) + continue; + + DDAction *actionObject = [representedObject objectForKey:@"DDAction"]; + if (![actionObject isKindOfClass:getDDActionClass()]) + continue; + + if ([actionObject.actionUTI hasPrefix:@"com.apple.dial"]) { + item.title = formattedPhoneNumberString(telephoneNumber); + return item; + } + } + + return nil; +} + +RetainPtr menuForTelephoneNumber(const String& telephoneNumber) +{ + RetainPtr menu = adoptNS([[NSMenu alloc] init]); + NSMutableArray *faceTimeItems = [NSMutableArray array]; + NSMenuItem *dialItem = nil; + + RetainPtr actionContext = [[getDDActionContextClass() alloc] init]; + [actionContext setAllowedActionUTIs:@[ @"com.apple.dial", @"com.apple.facetime", @"com.apple.facetimeaudio" ]]; + + NSArray *proposedMenuItems = [[getDDActionsManagerClass() sharedManager] menuItemsForValue:(NSString *)telephoneNumber type:getDDBinderPhoneNumberKey() service:nil context:actionContext.get()]; + for (NSMenuItem *item in proposedMenuItems) { + NSDictionary *representedObject = item.representedObject; + if (![representedObject isKindOfClass:[NSDictionary class]]) + continue; + + DDAction *actionObject = [representedObject objectForKey:@"DDAction"]; + if (![actionObject isKindOfClass:getDDActionClass()]) + continue; + + if ([actionObject.actionUTI hasPrefix:@"com.apple.dial"]) + dialItem = item; + else if ([actionObject.actionUTI hasPrefix:@"com.apple.facetime"]) + [faceTimeItems addObject:item]; + } + + if (dialItem) + [menu addItem:dialItem]; + + if (faceTimeItems.count) { + if ([menu numberOfItems]) + [menu addItem:[NSMenuItem separatorItem]]; + for (NSMenuItem *item in faceTimeItems) + [menu addItem:item]; + } + + return menu; +} + +#endif + +} // namespace WebKit + +#endif diff --git a/Source/WebKit2/Platform/mac/SharedMemoryMac.cpp b/Source/WebKit2/Platform/mac/SharedMemoryMac.cpp new file mode 100644 index 000000000..caf4fb49b --- /dev/null +++ b/Source/WebKit2/Platform/mac/SharedMemoryMac.cpp @@ -0,0 +1,235 @@ +/* + * 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 "SharedMemory.h" + +#include "ArgumentDecoder.h" +#include "ArgumentEncoder.h" +#include "Arguments.h" +#include "MachPort.h" +#include +#include +#include +#include +#include +#include + +namespace WebKit { + +SharedMemory::Handle::Handle() + : m_port(MACH_PORT_NULL) + , m_size(0) +{ +} + +SharedMemory::Handle::~Handle() +{ + clear(); +} + +bool SharedMemory::Handle::isNull() const +{ + return !m_port; +} + +void SharedMemory::Handle::clear() +{ + if (m_port) + mach_port_deallocate(mach_task_self(), m_port); + + m_port = MACH_PORT_NULL; + m_size = 0; +} + +void SharedMemory::Handle::encode(IPC::ArgumentEncoder& encoder) const +{ + encoder << static_cast(m_size); + encoder << IPC::MachPort(m_port, MACH_MSG_TYPE_MOVE_SEND); + m_port = MACH_PORT_NULL; +} + +bool SharedMemory::Handle::decode(IPC::ArgumentDecoder& decoder, Handle& handle) +{ + ASSERT(!handle.m_port); + ASSERT(!handle.m_size); + + uint64_t size; + if (!decoder.decode(size)) + return false; + + IPC::MachPort machPort; + if (!decoder.decode(machPort)) + return false; + + handle.m_size = size; + handle.m_port = machPort.port(); + return true; +} + +static inline void* toPointer(mach_vm_address_t address) +{ + return reinterpret_cast(static_cast(address)); +} + +static inline mach_vm_address_t toVMAddress(void* pointer) +{ + return static_cast(reinterpret_cast(pointer)); +} + +RefPtr SharedMemory::allocate(size_t size) +{ + ASSERT(size); + + mach_vm_address_t address; + kern_return_t kr = mach_vm_allocate(mach_task_self(), &address, round_page(size), VM_FLAGS_ANYWHERE); + if (kr != KERN_SUCCESS) { + LOG_ERROR("Failed to allocate mach_vm_allocate shared memory (%zu bytes). %s (%x)", size, mach_error_string(kr), kr); + return nullptr; + } + + RefPtr sharedMemory = adoptRef(*new SharedMemory); + sharedMemory->m_size = size; + sharedMemory->m_data = toPointer(address); + sharedMemory->m_port = MACH_PORT_NULL; + sharedMemory->m_protection = Protection::ReadWrite; + + return sharedMemory; +} + +static inline vm_prot_t machProtection(SharedMemory::Protection protection) +{ + switch (protection) { + case SharedMemory::Protection::ReadOnly: + return VM_PROT_READ; + case SharedMemory::Protection::ReadWrite: + return VM_PROT_READ | VM_PROT_WRITE; + } + + ASSERT_NOT_REACHED(); + return VM_PROT_NONE; +} + +static WebCore::MachSendRight makeMemoryEntry(size_t size, vm_offset_t offset, SharedMemory::Protection protection, mach_port_t parentEntry) +{ + memory_object_size_t memoryObjectSize = round_page(size); + + mach_port_t port; + kern_return_t kr = mach_make_memory_entry_64(mach_task_self(), &memoryObjectSize, offset, machProtection(protection) | VM_PROT_IS_MASK | MAP_MEM_VM_SHARE, &port, parentEntry); + if (kr != KERN_SUCCESS) { + LOG_ERROR("Failed to create a mach port for shared memory. %s (%x)", mach_error_string(kr), kr); + return { }; + } + + RELEASE_ASSERT(memoryObjectSize >= size); + + return WebCore::MachSendRight::adopt(port); +} + +RefPtr SharedMemory::create(void* data, size_t size, Protection protection) +{ + ASSERT(size); + + auto sendRight = makeMemoryEntry(size, toVMAddress(data), protection, MACH_PORT_NULL); + if (!sendRight) + return nullptr; + + RefPtr sharedMemory(adoptRef(new SharedMemory)); + sharedMemory->m_size = size; + sharedMemory->m_data = nullptr; + sharedMemory->m_port = sendRight.leakSendRight(); + sharedMemory->m_protection = protection; + + return sharedMemory.release(); +} + +RefPtr SharedMemory::map(const Handle& handle, Protection protection) +{ + if (handle.isNull()) + return 0; + + ASSERT(round_page(handle.m_size) == handle.m_size); + + vm_prot_t vmProtection = machProtection(protection); + mach_vm_address_t mappedAddress = 0; + kern_return_t kr = mach_vm_map(mach_task_self(), &mappedAddress, round_page(handle.m_size), 0, VM_FLAGS_ANYWHERE, handle.m_port, 0, false, vmProtection, vmProtection, VM_INHERIT_NONE); + if (kr != KERN_SUCCESS) + return nullptr; + + RefPtr sharedMemory(adoptRef(new SharedMemory)); + sharedMemory->m_size = handle.m_size; + sharedMemory->m_data = toPointer(mappedAddress); + sharedMemory->m_port = MACH_PORT_NULL; + sharedMemory->m_protection = protection; + + return sharedMemory; +} + +SharedMemory::~SharedMemory() +{ + if (m_data) { + kern_return_t kr = mach_vm_deallocate(mach_task_self(), toVMAddress(m_data), round_page(m_size)); + ASSERT_UNUSED(kr, kr == KERN_SUCCESS); + } + + if (m_port) { + kern_return_t kr = mach_port_deallocate(mach_task_self(), m_port); + ASSERT_UNUSED(kr, kr == KERN_SUCCESS); + } +} + +bool SharedMemory::createHandle(Handle& handle, Protection protection) +{ + ASSERT(!handle.m_port); + ASSERT(!handle.m_size); + + auto sendRight = createSendRight(protection); + if (!sendRight) + return false; + + handle.m_port = sendRight.leakSendRight(); + handle.m_size = round_page(m_size); + + return true; +} + +unsigned SharedMemory::systemPageSize() +{ + return vm_page_size; +} + +WebCore::MachSendRight SharedMemory::createSendRight(Protection protection) const +{ + ASSERT(m_protection == protection || m_protection == Protection::ReadWrite && protection == Protection::ReadOnly); + ASSERT(!!m_data ^ !!m_port); + + if (m_port && m_protection == protection) + return WebCore::MachSendRight::create(m_port); + + ASSERT(m_data); + return makeMemoryEntry(m_size, toVMAddress(m_data), protection, MACH_PORT_NULL); +} + +} // namespace WebKit diff --git a/Source/WebKit2/Platform/mac/StringUtilities.h b/Source/WebKit2/Platform/mac/StringUtilities.h new file mode 100644 index 000000000..d7a0e3fb2 --- /dev/null +++ b/Source/WebKit2/Platform/mac/StringUtilities.h @@ -0,0 +1,47 @@ +/* + * 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 StringUtilities_h +#define StringUtilities_h + +#import +#import + +namespace WebKit { + +#ifdef __OBJC__ + +// NOTE: This does not use String::operator NSString*() since that function +// expects to be called on the thread running WebCore. +NSString *nsStringFromWebCoreString(const String&); +NSString *formattedPhoneNumberString(NSString *originalPhoneNumber); + +#endif // defined(__OBJC__) + +WK_EXPORT bool stringMatchesWildcardString(const String& stringToBeMatched, const String& wildcardString); + +} + +#endif // StringUtilities_h diff --git a/Source/WebKit2/Platform/mac/StringUtilities.mm b/Source/WebKit2/Platform/mac/StringUtilities.mm new file mode 100644 index 000000000..1b6034f2c --- /dev/null +++ b/Source/WebKit2/Platform/mac/StringUtilities.mm @@ -0,0 +1,113 @@ +/* + * 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. + */ + +#import "config.h" +#import "StringUtilities.h" + +#import "WKSharedAPICast.h" +#import "WKStringCF.h" +#import +#import +#import +#import + +namespace WebKit { + +NSString *nsStringFromWebCoreString(const String& string) +{ + return string.isEmpty() ? @"" : CFBridgingRelease(WKStringCopyCFString(0, toAPI(string.impl()))); +} + +static String wildcardRegexPatternString(const String& string) +{ + String metaCharacters = ".|+?()[]{}^$"; + UChar escapeCharacter = '\\'; + UChar wildcardCharacter = '*'; + + StringBuilder stringBuilder; + + stringBuilder.append('^'); + for (unsigned i = 0; i < string.length(); i++) { + auto character = string[i]; + if (metaCharacters.contains(character) || character == escapeCharacter) + stringBuilder.append(escapeCharacter); + else if (character == wildcardCharacter) + stringBuilder.append('.'); + + stringBuilder.append(character); + } + stringBuilder.append('$'); + + return stringBuilder.toString(); +} + +bool stringMatchesWildcardString(const String& string, const String& wildcardString) +{ + return JSC::Yarr::RegularExpression(wildcardRegexPatternString(wildcardString), TextCaseInsensitive).match(string) != -1; +} + +#if ENABLE(TELEPHONE_NUMBER_DETECTION) && PLATFORM(MAC) + +SOFT_LINK_PRIVATE_FRAMEWORK(PhoneNumbers); + +typedef struct __CFPhoneNumber* CFPhoneNumberRef; + +// These functions are declared with __attribute__((visibility ("default"))) +// We currently don't have a way to soft link such functions, so we forward declare them again here. +extern "C" CFPhoneNumberRef CFPhoneNumberCreate(CFAllocatorRef, CFStringRef, CFStringRef); +SOFT_LINK(PhoneNumbers, CFPhoneNumberCreate, CFPhoneNumberRef, (CFAllocatorRef allocator, CFStringRef digits, CFStringRef countryCode), (allocator, digits, countryCode)); + +extern "C" CFStringRef CFPhoneNumberCopyFormattedRepresentation(CFPhoneNumberRef); +SOFT_LINK(PhoneNumbers, CFPhoneNumberCopyFormattedRepresentation, CFStringRef, (CFPhoneNumberRef phoneNumber), (phoneNumber)); + +extern "C" CFStringRef CFPhoneNumberCopyUnformattedRepresentation(CFPhoneNumberRef); +SOFT_LINK(PhoneNumbers, CFPhoneNumberCopyUnformattedRepresentation, CFStringRef, (CFPhoneNumberRef phoneNumber), (phoneNumber)); + + +NSString *formattedPhoneNumberString(NSString *originalPhoneNumber) +{ + NSString *countryCode = [[[NSLocale currentLocale] objectForKey:NSLocaleCountryCode] lowercaseString]; + + RetainPtr phoneNumber = adoptCF(CFPhoneNumberCreate(kCFAllocatorDefault, (CFStringRef)originalPhoneNumber, (CFStringRef)countryCode)); + if (!phoneNumber) + return originalPhoneNumber; + + CFStringRef phoneNumberString = CFPhoneNumberCopyFormattedRepresentation(phoneNumber.get()); + if (!phoneNumberString) + phoneNumberString = CFPhoneNumberCopyUnformattedRepresentation(phoneNumber.get()); + + return [(NSString *)phoneNumberString autorelease]; +} + +#else + +NSString *formattedPhoneNumberString(NSString *) +{ + return nil; +} + +#endif // ENABLE(TELEPHONE_NUMBER_DETECTION) && PLATFORM(MAC) + +} diff --git a/Source/WebKit2/Platform/win/SharedMemoryWin.cpp b/Source/WebKit2/Platform/win/SharedMemoryWin.cpp new file mode 100644 index 000000000..acf37be83 --- /dev/null +++ b/Source/WebKit2/Platform/win/SharedMemoryWin.cpp @@ -0,0 +1,241 @@ +/* + * 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 "SharedMemory.h" + +#include "ArgumentDecoder.h" +#include "ArgumentEncoder.h" +#include + +namespace WebKit { + +SharedMemory::Handle::Handle() + : m_handle(0) + , m_size(0) +{ +} + +SharedMemory::Handle::~Handle() +{ + if (!m_handle) + return; + + ::CloseHandle(m_handle); +} + +bool SharedMemory::Handle::isNull() const +{ + return !m_handle; +} + +void SharedMemory::Handle::encode(IPC::ArgumentEncoder& encoder) const +{ + encoder << static_cast(m_size); + + // Hand off ownership of our HANDLE to the receiving process. It will close it for us. + // FIXME: If the receiving process crashes before it receives the memory, the memory will be + // leaked. See . + encoder << reinterpret_cast(m_handle); + m_handle = 0; + + // Send along our PID so that the receiving process can duplicate the HANDLE for its own use. + encoder << static_cast(::GetCurrentProcessId()); +} + +static bool getDuplicatedHandle(HANDLE sourceHandle, DWORD sourcePID, HANDLE& duplicatedHandle) +{ + duplicatedHandle = 0; + if (!sourceHandle) + return true; + + HANDLE sourceProcess = ::OpenProcess(PROCESS_DUP_HANDLE, FALSE, sourcePID); + if (!sourceProcess) + return false; + + // Copy the handle into our process and close the handle that the sending process created for us. + BOOL success = ::DuplicateHandle(sourceProcess, sourceHandle, ::GetCurrentProcess(), &duplicatedHandle, 0, FALSE, DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE); + ASSERT_WITH_MESSAGE(success, "::DuplicateHandle failed with error %lu", ::GetLastError()); + + ::CloseHandle(sourceProcess); + + return success; +} + +bool SharedMemory::Handle::decode(IPC::ArgumentDecoder& decoder, Handle& handle) +{ + ASSERT_ARG(handle, !handle.m_handle); + ASSERT_ARG(handle, !handle.m_size); + + uint64_t size; + if (!decoder.decode(size)) + return false; + + uint64_t sourceHandle; + if (!decoder.decode(sourceHandle)) + return false; + + uint32_t sourcePID; + if (!decoder.decode(sourcePID)) + return false; + + HANDLE duplicatedHandle; + if (!getDuplicatedHandle(reinterpret_cast(sourceHandle), sourcePID, duplicatedHandle)) + return false; + + handle.m_handle = duplicatedHandle; + handle.m_size = size; + return true; +} + +PassRefPtr SharedMemory::create(size_t size) +{ + HANDLE handle = ::CreateFileMappingW(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, size, 0); + if (!handle) + return 0; + + void* baseAddress = ::MapViewOfFile(handle, FILE_MAP_ALL_ACCESS, 0, 0, size); + if (!baseAddress) { + ::CloseHandle(handle); + return 0; + } + + RefPtr memory = adoptRef(new SharedMemory); + memory->m_size = size; + memory->m_data = baseAddress; + memory->m_handle = handle; + + return memory.release(); +} + +static DWORD accessRights(SharedMemory::Protection protection) +{ + switch (protection) { + case SharedMemory::ReadOnly: + return FILE_MAP_READ; + case SharedMemory::ReadWrite: + return FILE_MAP_READ | FILE_MAP_WRITE; + } + + ASSERT_NOT_REACHED(); + return 0; +} + +PassRefPtr SharedMemory::create(const Handle& handle, Protection protection) +{ + RefPtr memory = adopt(handle.m_handle, handle.m_size, protection); + if (!memory) + return 0; + + // The SharedMemory object now owns the HANDLE. + handle.m_handle = 0; + + return memory.release(); +} + +PassRefPtr SharedMemory::adopt(HANDLE handle, size_t size, Protection protection) +{ + if (!handle) + return 0; + + DWORD desiredAccess = accessRights(protection); + + void* baseAddress = ::MapViewOfFile(handle, desiredAccess, 0, 0, size); + ASSERT_WITH_MESSAGE(baseAddress, "::MapViewOfFile failed with error %lu", ::GetLastError()); + if (!baseAddress) + return 0; + + RefPtr memory = adoptRef(new SharedMemory); + memory->m_size = size; + memory->m_data = baseAddress; + memory->m_handle = handle; + + return memory.release(); +} + +SharedMemory::~SharedMemory() +{ + ASSERT(m_data); + ASSERT(m_handle); + + ::UnmapViewOfFile(m_data); + ::CloseHandle(m_handle); +} + +bool SharedMemory::createHandle(Handle& handle, Protection protection) +{ + ASSERT_ARG(handle, !handle.m_handle); + ASSERT_ARG(handle, !handle.m_size); + + HANDLE processHandle = ::GetCurrentProcess(); + + HANDLE duplicatedHandle; + if (!::DuplicateHandle(processHandle, m_handle, processHandle, &duplicatedHandle, accessRights(protection), FALSE, 0)) + return false; + + handle.m_handle = duplicatedHandle; + handle.m_size = m_size; + return true; +} + +PassRefPtr SharedMemory::createCopyOnWriteCopy(size_t size) const +{ + ASSERT_ARG(size, size <= this->size()); + + HANDLE duplicatedHandle; + BOOL result = ::DuplicateHandle(::GetCurrentProcess(), m_handle, ::GetCurrentProcess(), &duplicatedHandle, 0, FALSE, DUPLICATE_SAME_ACCESS); + ASSERT_WITH_MESSAGE(result, "::DuplicateHandle failed with error %lu", ::GetLastError()); + if (!result) + return 0; + + void* newMapping = ::MapViewOfFile(duplicatedHandle, FILE_MAP_COPY, 0, 0, size); + ASSERT_WITH_MESSAGE(newMapping, "::MapViewOfFile failed with error %lu", ::GetLastError()); + if (!newMapping) { + ::CloseHandle(duplicatedHandle); + return 0; + } + + RefPtr memory = adoptRef(new SharedMemory); + memory->m_size = size; + memory->m_data = newMapping; + memory->m_handle = duplicatedHandle; + + return memory.release(); +} + +unsigned SharedMemory::systemPageSize() +{ + static unsigned pageSize = 0; + + if (!pageSize) { + SYSTEM_INFO systemInfo; + ::GetSystemInfo(&systemInfo); + pageSize = systemInfo.dwPageSize; + } + + return pageSize; +} + +} // namespace WebKit diff --git a/Source/WebKit2/PlatformQt.cmake b/Source/WebKit2/PlatformQt.cmake index 3d74594f0..9dac25f68 100644 --- a/Source/WebKit2/PlatformQt.cmake +++ b/Source/WebKit2/PlatformQt.cmake @@ -3,13 +3,19 @@ set(WebKit2_NetworkProcess_OUTPUT_NAME QtWebNetworkProcess) set(WebKit2_PluginProcess_OUTPUT_NAME QtWebPluginProcess) set(WebKit2_DatabaseProcess_OUTPUT_NAME QtWebDatabaseProcess) -#set(WebKit2_USE_PREFIX_HEADER ON) +file(MAKE_DIRECTORY ${DERIVED_SOURCES_WEBKIT2_DIR}) -# FIXME: It should be in WebKitFS actually -set(FORWARDING_HEADERS_DIR "${DERIVED_SOURCES_DIR}/ForwardingHeaders") +if (SHARED_CORE) + set(WebKit2_LIBRARY_TYPE SHARED) +else () + set(WebKit2_LIBRARY_TYPE STATIC) +endif () + +#set(WebKit2_USE_PREFIX_HEADER ON) list(APPEND WebKit2_INCLUDE_DIRECTORIES "${FORWARDING_HEADERS_DIR}" + "${FORWARDING_HEADERS_DIR}/QtWebKit" "${WEBCORE_DIR}/platform/graphics/opentype" "${WEBCORE_DIR}/platform/graphics/qt" @@ -18,10 +24,13 @@ list(APPEND WebKit2_INCLUDE_DIRECTORIES # The WebKit2 Qt APIs depend on qwebkitglobal.h, which lives in WebKit "${WEBKIT_DIR}/qt/Api" + "${WEBKIT_DIR}/qt/Plugins" "${WEBKIT2_DIR}/NetworkProcess/CustomProtocols/qt" + "${WEBKIT2_DIR}/NetworkProcess/qt" "${WEBKIT2_DIR}/Shared/CoordinatedGraphics" + "${WEBKIT2_DIR}/Shared/Plugins/unix" "${WEBKIT2_DIR}/Shared/qt" "${WEBKIT2_DIR}/Shared/unix" @@ -32,13 +41,17 @@ list(APPEND WebKit2_INCLUDE_DIRECTORIES "${WEBKIT2_DIR}/UIProcess/InspectorServer/qt" "${WEBKIT2_DIR}/UIProcess/gstreamer" "${WEBKIT2_DIR}/UIProcess/qt" + + "${WEBKIT2_DIR}/WebProcess/Plugins/Netscape/unix" + "${WEBKIT2_DIR}/WebProcess/Plugins/Netscape/x11" "${WEBKIT2_DIR}/WebProcess/WebCoreSupport/qt" "${WEBKIT2_DIR}/WebProcess/WebPage/CoordinatedGraphics" "${WEBKIT2_DIR}/WebProcess/qt" ) list(APPEND WebKit2_SOURCES - NetworkProcess/CustomProtocols/qt/CustomProtocolManagerImpl.cpp + DatabaseProcess/qt/DatabaseProcessMainQt.cpp + NetworkProcess/CustomProtocols/qt/CustomProtocolManagerQt.cpp NetworkProcess/Downloads/qt/DownloadQt.cpp @@ -46,6 +59,7 @@ list(APPEND WebKit2_SOURCES NetworkProcess/qt/NetworkProcessMainQt.cpp NetworkProcess/qt/NetworkProcessQt.cpp + NetworkProcess/qt/QtNetworkAccessManager.cpp NetworkProcess/qt/RemoteNetworkingContextQt.cpp Platform/qt/LoggingQt.cpp @@ -64,7 +78,12 @@ list(APPEND WebKit2_SOURCES Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp Shared/CoordinatedGraphics/WebCoordinatedSurface.cpp + Shared/Plugins/Netscape/x11/NetscapePluginModuleX11.cpp + + Shared/Plugins/unix/PluginSearchPath.cpp + Shared/qt/ArgumentCodersQt.cpp + Shared/qt/ChildProcessMainQt.cpp Shared/qt/NativeWebKeyboardEventQt.cpp Shared/qt/NativeWebMouseEventQt.cpp Shared/qt/NativeWebTouchEventQt.cpp @@ -77,11 +96,8 @@ list(APPEND WebKit2_SOURCES Shared/qt/WebEventFactoryQt.cpp Shared/qt/WebGestureEvent.cpp - Shared/unix/ChildProcessMain.cpp - UIProcess/BackingStore.cpp UIProcess/DefaultUndoController.cpp - UIProcess/DrawingAreaProxyImpl.cpp UIProcess/LegacySessionStateCodingNone.cpp UIProcess/API/C/qt/WKIconDatabaseQt.cpp @@ -89,6 +105,7 @@ list(APPEND WebKit2_SOURCES UIProcess/API/cpp/qt/WKStringQt.cpp UIProcess/API/cpp/qt/WKURLQt.cpp + UIProcess/API/qt/APIWebsiteDataStoreQt.cpp UIProcess/API/qt/qquicknetworkreply.cpp UIProcess/API/qt/qquicknetworkrequest.cpp UIProcess/API/qt/qquickurlschemedelegate.cpp @@ -121,6 +138,8 @@ list(APPEND WebKit2_SOURCES UIProcess/Plugins/qt/PluginProcessProxyQt.cpp + UIProcess/Plugins/unix/PluginInfoStoreUnix.cpp + UIProcess/Storage/StorageManager.cpp UIProcess/WebsiteData/unix/WebsiteDataStoreUnix.cpp @@ -130,6 +149,7 @@ list(APPEND WebKit2_SOURCES UIProcess/qt/BackingStoreQt.cpp UIProcess/qt/PageViewportControllerClientQt.cpp + UIProcess/qt/QrcSchemeHandler.cpp UIProcess/qt/QtDialogRunner.cpp UIProcess/qt/QtDownloadManager.cpp UIProcess/qt/QtGestureRecognizer.cpp @@ -147,7 +167,6 @@ list(APPEND WebKit2_SOURCES UIProcess/qt/TextCheckerQt.cpp UIProcess/qt/WebColorPickerQt.cpp UIProcess/qt/WebContextMenuProxyQt.cpp - UIProcess/qt/WebFullScreenManagerProxyQt.cpp UIProcess/qt/WebGeolocationProviderQt.cpp UIProcess/qt/WebInspectorProxyQt.cpp UIProcess/qt/WebPageProxyQt.cpp @@ -161,6 +180,10 @@ list(APPEND WebKit2_SOURCES WebProcess/Plugins/Netscape/qt/PluginProxyQt.cpp + WebProcess/Plugins/Netscape/unix/NetscapePluginUnix.cpp + + WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp + WebProcess/WebCoreSupport/qt/WebContextMenuClientQt.cpp WebProcess/WebCoreSupport/qt/WebDragClientQt.cpp WebProcess/WebCoreSupport/qt/WebErrorsQt.cpp @@ -178,13 +201,15 @@ list(APPEND WebKit2_SOURCES WebProcess/qt/QtBuiltinBundle.cpp WebProcess/qt/QtBuiltinBundlePage.cpp - WebProcess/qt/QtNetworkAccessManager.cpp - WebProcess/qt/QtNetworkReply.cpp WebProcess/qt/SeccompFiltersWebProcessQt.cpp WebProcess/qt/WebProcessMainQt.cpp WebProcess/qt/WebProcessQt.cpp ) +qt5_add_resources(WebKit2_SOURCES + WebKit2.qrc +) + if (APPLE) list(APPEND WebKit2_INCLUDE_DIRECTORIES "${WEBKIT2_DIR}/Platform/IPC/mac" @@ -211,15 +236,28 @@ else () ) endif () +if (ENABLE_NETSCAPE_PLUGIN_API) + # We don't build PluginProcess on Win and Mac because we don't + # support WK2 NPAPI on these platforms, however NPAPI works in WK1. + # Some WK2 code is guarded with ENABLE(NETSCAPE_PLUGIN_API) now + # so it should be compiled even when we don't want PluginProcess + # Enabling PLUGIN_PROCESS without building PluginProcess executable + # fixes things + add_definitions(-DENABLE_PLUGIN_PROCESS=1) +endif () + list(APPEND WebKit2_SYSTEM_INCLUDE_DIRECTORIES ${GSTREAMER_INCLUDE_DIRS} ${Qt5Quick_INCLUDE_DIRS} ${Qt5Quick_PRIVATE_INCLUDE_DIRS} + ${SQLITE_INCLUDE_DIR} ) list(APPEND WebKit2_LIBRARIES ${Qt5Positioning_LIBRARIES} ${Qt5Quick_LIBRARIES} + ${Qt5WebChannel_LIBRARIES} + ${X11_X11_LIB} ) list(APPEND WebKit2_MESSAGES_IN_FILES @@ -233,18 +271,30 @@ list(APPEND WebProcess_SOURCES ) # FIXME: Allow building without widgets -list(APPEND WebProcess_LIBRARIES +set(WebProcess_LIBRARIES + WebKit Qt5::Widgets WebKitWidgets ) +set(NetworkProcess_LIBRARIES + WebKit +) + +set(DatabaseProcess_LIBRARIES + WebKit +) + +set(PluginProcess_LIBRARIES + WebKit +) + list(APPEND NetworkProcess_SOURCES NetworkProcess/EntryPoint/qt/NetworkProcessMain.cpp ) -# FIXME list(APPEND DatabaseProcess_SOURCES - DatabaseProcess/EntryPoint/unix/DatabaseProcessMain.cpp + DatabaseProcess/EntryPoint/qt/DatabaseProcessMain.cpp ) list(APPEND PluginProcess_SOURCES @@ -259,3 +309,8 @@ set(WEBKIT2_EXTRA_DEPENDENCIES WebKit2-forwarding-headers ) +WEBKIT_CREATE_FORWARDING_HEADERS(QtWebKit/private DIRECTORIES UIProcess/API/qt) + +if (ENABLE_API_TESTS) + add_subdirectory(UIProcess/API/qt/tests) +endif () diff --git a/Source/WebKit2/PluginProcess/qt/PluginProcessMainQt.cpp b/Source/WebKit2/PluginProcess/qt/PluginProcessMainQt.cpp index 96e676d6e..7a93fbb85 100644 --- a/Source/WebKit2/PluginProcess/qt/PluginProcessMainQt.cpp +++ b/Source/WebKit2/PluginProcess/qt/PluginProcessMainQt.cpp @@ -34,7 +34,7 @@ #include #include #include -#include +#include using namespace WebCore; @@ -65,6 +65,7 @@ static bool initializeGtk() Q_DECL_EXPORT int PluginProcessMain(int argc, char** argv) { +#if PLUGIN_ARCHITECTURE(X11) QByteArray suppressOutput = qgetenv("QT_WEBKIT_SUPPRESS_WEB_PROCESS_OUTPUT"); if (!suppressOutput.isEmpty() && suppressOutput != "0") qInstallMessageHandler(messageHandler); @@ -99,9 +100,10 @@ Q_DECL_EXPORT int PluginProcessMain(int argc, char** argv) parameters.connectionIdentifier = identifier; parameters.extraInitializationData.add("plugin-path", app.arguments().at(2)); - WebKit::PluginProcess::shared().initialize(parameters); + WebKit::PluginProcess::singleton().initialize(parameters); RunLoop::run(); +#endif return 0; } diff --git a/Source/WebKit2/PluginProcess/qt/PluginProcessQt.cpp b/Source/WebKit2/PluginProcess/qt/PluginProcessQt.cpp index f3be1ada2..b584f73c0 100644 --- a/Source/WebKit2/PluginProcess/qt/PluginProcessQt.cpp +++ b/Source/WebKit2/PluginProcess/qt/PluginProcessQt.cpp @@ -38,7 +38,7 @@ void PluginProcess::platformInitializeProcess(const ChildProcessInitializationPa { } -void PluginProcess::platformInitializePluginProcess(const PluginProcessCreationParameters&) +void PluginProcess::platformInitializePluginProcess(PluginProcessCreationParameters&&) { notImplemented(); } diff --git a/Source/WebKit2/Shared/API/APIObject.h b/Source/WebKit2/Shared/API/APIObject.h index 676c583f4..0a1389e33 100644 --- a/Source/WebKit2/Shared/API/APIObject.h +++ b/Source/WebKit2/Shared/API/APIObject.h @@ -144,6 +144,7 @@ public: RunJavaScriptPromptResultListener, Session, TextChecker, + URLSchemeHandlerTask, UserContentController, UserContentExtension, UserContentExtensionStore, diff --git a/Source/WebKit2/Shared/Authentication/qt/AuthenticationManagerQt.cpp b/Source/WebKit2/Shared/Authentication/qt/AuthenticationManagerQt.cpp new file mode 100644 index 000000000..c26f2e5e7 --- /dev/null +++ b/Source/WebKit2/Shared/Authentication/qt/AuthenticationManagerQt.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/CoordinatedGraphics/CoordinatedGraphicsScene.cpp b/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp index e97a52733..192c8d8bf 100644 --- a/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp +++ b/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp @@ -148,6 +148,13 @@ void CoordinatedGraphicsScene::paintToGraphicsContext(PlatformGraphicsContext* p m_textureMapper->setGraphicsContext(0); } +#if PLATFORM(QT) +void CoordinatedGraphicsScene::setScrollPosition(const FloatPoint& scrollPosition) +{ + m_scrollPosition = scrollPosition; +} +#endif + void CoordinatedGraphicsScene::updateViewport() { ASSERT(&m_clientRunLoop == &RunLoop::current()); @@ -163,7 +170,11 @@ void CoordinatedGraphicsScene::adjustPositionForFixedLayers(const FloatPoint& co // 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. +#if PLATFORM(QT) + FloatSize delta = m_scrollPosition - m_renderedContentsScrollPosition; +#else FloatSize delta = contentPosition - m_renderedContentsScrollPosition; +#endif for (auto& fixedLayer : m_fixedLayers.values()) fixedLayer->setScrollPositionDeltaIfNeeded(delta); diff --git a/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.h b/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.h index 68aabfe40..89d271272 100644 --- a/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.h +++ b/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.h @@ -72,6 +72,9 @@ public: 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 paintToGraphicsContext(PlatformGraphicsContext*, const WebCore::Color& backgroundColor, bool drawsBackground); +#if PLATFORM(QT) + void setScrollPosition(const WebCore::FloatPoint&); +#endif void detach(); void appendUpdate(std::function); diff --git a/Source/WebKit2/Shared/SessionTracker.cpp b/Source/WebKit2/Shared/SessionTracker.cpp index fa8ffd013..a6b761c88 100644 --- a/Source/WebKit2/Shared/SessionTracker.cpp +++ b/Source/WebKit2/Shared/SessionTracker.cpp @@ -95,6 +95,10 @@ NetworkSession* SessionTracker::networkSession(SessionID sessionID) SessionID SessionTracker::sessionID(const NetworkStorageSession& session) { + // QTFIXME: See issues #54 and #53 +#if PLATFORM(QT) + return SessionID::defaultSessionID(); +#endif if (&session == &NetworkStorageSession::defaultStorageSession()) return SessionID::defaultSessionID(); return storageSessionToID().get(&session); diff --git a/Source/WebKit2/Shared/WebPageCreationParameters.cpp b/Source/WebKit2/Shared/WebPageCreationParameters.cpp index 7ec6be453..dbca781a1 100644 --- a/Source/WebKit2/Shared/WebPageCreationParameters.cpp +++ b/Source/WebKit2/Shared/WebPageCreationParameters.cpp @@ -85,6 +85,7 @@ void WebPageCreationParameters::encode(IPC::ArgumentEncoder& encoder) const #endif encoder << appleMailPaginationQuirkEnabled; encoder << shouldScaleViewToFitDocument; + encoder << urlSchemeHandlers; } bool WebPageCreationParameters::decode(IPC::ArgumentDecoder& decoder, WebPageCreationParameters& parameters) @@ -191,6 +192,9 @@ bool WebPageCreationParameters::decode(IPC::ArgumentDecoder& decoder, WebPageCre if (!decoder.decode(parameters.shouldScaleViewToFitDocument)) return false; + if (!decoder.decode(parameters.urlSchemeHandlers)) + return false; + return true; } diff --git a/Source/WebKit2/Shared/WebPageCreationParameters.h b/Source/WebKit2/Shared/WebPageCreationParameters.h index 69ce920ab..6ffca4b56 100644 --- a/Source/WebKit2/Shared/WebPageCreationParameters.h +++ b/Source/WebKit2/Shared/WebPageCreationParameters.h @@ -39,6 +39,7 @@ #include #include #include +#include #include #if PLATFORM(MAC) @@ -131,6 +132,8 @@ struct WebPageCreationParameters { #endif bool appleMailPaginationQuirkEnabled; bool shouldScaleViewToFitDocument; + + HashMap urlSchemeHandlers; }; } // namespace WebKit diff --git a/Source/WebKit2/Shared/qt/ChildProcessMainQt.cpp b/Source/WebKit2/Shared/qt/ChildProcessMainQt.cpp new file mode 100644 index 000000000..2db152766 --- /dev/null +++ b/Source/WebKit2/Shared/qt/ChildProcessMainQt.cpp @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2016 Konstantin Tokarev + * Copyright (C) 2014 Igalia S.L. + * Copyright (C) 2013 University of Szeged + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + * + * 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 "ChildProcessMain.h" + +#include + +#if OS(DARWIN) && !USE(UNIX_DOMAIN_SOCKETS) +#include + +extern "C" kern_return_t bootstrap_look_up2(mach_port_t, const name_t, mach_port_t*, pid_t, uint64_t); +#endif + +namespace WebKit { + +bool ChildProcessMainBase::parseCommandLine(int argc, char** argv) +{ + ASSERT(argc >= 2); + if (argc < 2) + return false; + +#if OS(DARWIN) + QByteArray serviceName(argv[1]); + + // Get the server port. + mach_port_t identifier; + kern_return_t kr = bootstrap_look_up2(bootstrap_port, serviceName.data(), &identifier, 0, 0); + if (kr) { + printf("bootstrap_look_up2 result: %x", kr); + return false; + } +#else + bool wasNumber = false; + qulonglong id = QByteArray(argv[1]).toULongLong(&wasNumber, 10); + if (!wasNumber) { + qDebug() << "Error: connection identifier wrong."; + return 1; + } + IPC::Connection::Identifier identifier; +#if OS(WINDOWS) + // Convert to HANDLE + identifier = reinterpret_cast(id); +#else + // Convert to int + identifier = static_cast(id); +#endif +#endif + + m_parameters.connectionIdentifier = identifier; + return true; +} + +} // namespace WebKit diff --git a/Source/WebKit2/Shared/qt/ProcessExecutablePathQt.cpp b/Source/WebKit2/Shared/qt/ProcessExecutablePathQt.cpp index 827cda6f9..c5f809d34 100644 --- a/Source/WebKit2/Shared/qt/ProcessExecutablePathQt.cpp +++ b/Source/WebKit2/Shared/qt/ProcessExecutablePathQt.cpp @@ -60,4 +60,9 @@ String executablePathOfPluginProcess() return executablePath(QStringLiteral("QtWebPluginProcess")); } +String executablePathOfNetworkProcess() +{ + return executablePath(QStringLiteral("QtWebNetworkProcess")); +} + } // namespace WebKit diff --git a/Source/WebKit2/Shared/qt/WebCoreArgumentCodersQt.cpp b/Source/WebKit2/Shared/qt/WebCoreArgumentCodersQt.cpp index f0b71844e..b293dc01c 100644 --- a/Source/WebKit2/Shared/qt/WebCoreArgumentCodersQt.cpp +++ b/Source/WebKit2/Shared/qt/WebCoreArgumentCodersQt.cpp @@ -36,20 +36,185 @@ namespace IPC { void ArgumentCoder::encodePlatformData(ArgumentEncoder& encoder, const ResourceRequest& resourceRequest) { + // QTFIXME: Copied from WebCoreArgumentCodersSoup.cpp, partially duplicates ResourceRequestBase::encodeWithoutPlatformData + // See r207407 + + encoder << resourceRequest.url().string(); + encoder << resourceRequest.httpMethod(); + encoder << resourceRequest.httpHeaderFields(); + encoder << resourceRequest.timeoutInterval(); + + // 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(); + encoder << resourceRequest.allowCookies(); + encoder.encodeEnum(resourceRequest.priority()); + encoder.encodeEnum(resourceRequest.cachePolicy()); + encoder.encodeEnum(resourceRequest.requester()); } bool ArgumentCoder::decodePlatformData(ArgumentDecoder& decoder, ResourceRequest& resourceRequest) { + // QTFIXME: ditto + + String url; + if (!decoder.decode(url)) + return false; + resourceRequest.setURL(URL(URL(), url)); + + String httpMethod; + if (!decoder.decode(httpMethod)) + return false; + resourceRequest.setHTTPMethod(httpMethod); + + HTTPHeaderMap headers; + if (!decoder.decode(headers)) + return false; + resourceRequest.setHTTPHeaderFields(WTFMove(headers)); + + double timeoutInterval; + if (!decoder.decode(timeoutInterval)) + return false; + resourceRequest.setTimeoutInterval(timeoutInterval); + + bool hasHTTPBody; + if (!decoder.decode(hasHTTPBody)) + return false; + if (hasHTTPBody) { + String httpBody; + if (!decoder.decode(httpBody)) + return false; + resourceRequest.setHTTPBody(FormData::create(httpBody.utf8())); + } + + String firstPartyForCookies; + if (!decoder.decode(firstPartyForCookies)) + return false; + resourceRequest.setFirstPartyForCookies(URL(URL(), firstPartyForCookies)); + + bool allowCookies; + if (!decoder.decode(allowCookies)) + return false; + resourceRequest.setAllowCookies(allowCookies); + + ResourceLoadPriority priority; + if (!decoder.decodeEnum(priority)) + return false; + resourceRequest.setPriority(priority); + + ResourceRequestCachePolicy cachePolicy; + if (!decoder.decodeEnum(cachePolicy)) + return false; + resourceRequest.setCachePolicy(cachePolicy); + + ResourceRequest::Requester requester; + if (!decoder.decodeEnum(requester)) + return false; + resourceRequest.setRequester(requester); + return true; } void ArgumentCoder::encodePlatformData(ArgumentEncoder& encoder, const ResourceError& resourceError) { + // QTFIXME: ditto + + bool errorIsNull = resourceError.isNull(); + encoder << errorIsNull; + if (errorIsNull) + return; + + encoder << resourceError.domain(); + encoder << resourceError.errorCode(); + encoder << resourceError.failingURL().string(); + encoder << resourceError.localizedDescription(); + encoder << resourceError.isCancellation(); + encoder << resourceError.isTimeout(); } bool ArgumentCoder::decodePlatformData(ArgumentDecoder& decoder, ResourceError& resourceError) { + // QTFIXME: ditto + + 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, URL(URL(), failingURL), localizedDescription); + resourceError.setIsCancellation(isCancellation); + resourceError.setIsTimeout(isTimeout); + return true; } +void ArgumentCoder::encode(ArgumentEncoder& encoder, const CertificateInfo& certificateInfo) +{ + // QTFIXME: Our CertificateInfo is a stub + notImplemented(); +} + +bool ArgumentCoder::decode(ArgumentDecoder& decoder, CertificateInfo& certificateInfo) +{ + // QTFIXME: Our CertificateInfo is a stub + notImplemented(); + return true; +} + +void ArgumentCoder::encodePlatformData(ArgumentEncoder&, const ProtectionSpace&) +{ + ASSERT_NOT_REACHED(); +} + +bool ArgumentCoder::decodePlatformData(ArgumentDecoder&, ProtectionSpace&) +{ + ASSERT_NOT_REACHED(); + return false; +} + +void ArgumentCoder::encodePlatformData(ArgumentEncoder&, const Credential&) +{ + ASSERT_NOT_REACHED(); +} + +bool ArgumentCoder::decodePlatformData(ArgumentDecoder&, Credential&) +{ + ASSERT_NOT_REACHED(); + return false; +} + + } // namespace IPC diff --git a/Source/WebKit2/Shared/qt/WebEventFactoryQt.cpp b/Source/WebKit2/Shared/qt/WebEventFactoryQt.cpp index ebf9d5f43..876208b99 100644 --- a/Source/WebKit2/Shared/qt/WebEventFactoryQt.cpp +++ b/Source/WebKit2/Shared/qt/WebEventFactoryQt.cpp @@ -57,9 +57,9 @@ static WebMouseEvent::Button mouseButtonForEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton || (event->buttons() & Qt::LeftButton)) return WebMouseEvent::LeftButton; - else if (event->button() == Qt::RightButton || (event->buttons() & Qt::RightButton)) + if (event->button() == Qt::RightButton || (event->buttons() & Qt::RightButton)) return WebMouseEvent::RightButton; - else if (event->button() == Qt::MidButton || (event->buttons() & Qt::MidButton)) + if (event->button() == Qt::MidButton || (event->buttons() & Qt::MidButton)) return WebMouseEvent::MiddleButton; return WebMouseEvent::NoButton; } diff --git a/Source/WebKit2/UIProcess/API/APIURLSchemeHandlerTask.cpp b/Source/WebKit2/UIProcess/API/APIURLSchemeHandlerTask.cpp new file mode 100644 index 000000000..8c4201c91 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/APIURLSchemeHandlerTask.cpp @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2017 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "APIURLSchemeHandlerTask.h" + +#include "WebURLSchemeHandler.h" +#include "WebURLSchemeHandlerTask.h" + +namespace API { + +Ref URLSchemeHandlerTask::create(WebKit::WebURLSchemeHandlerTask& webURLSchemeHandlerTask) +{ + return adoptRef(*new URLSchemeHandlerTask(webURLSchemeHandlerTask)); +} + +URLSchemeHandlerTask::URLSchemeHandlerTask(WebKit::WebURLSchemeHandlerTask& webURLSchemeHandlerTask) + : m_webURLSchemeHandlerTask(webURLSchemeHandlerTask) +{ +} + +} diff --git a/Source/WebKit2/UIProcess/API/APIURLSchemeHandlerTask.h b/Source/WebKit2/UIProcess/API/APIURLSchemeHandlerTask.h new file mode 100644 index 000000000..7e31508fd --- /dev/null +++ b/Source/WebKit2/UIProcess/API/APIURLSchemeHandlerTask.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2017 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include "APIObject.h" + +namespace WebKit { +class WebURLSchemeHandlerTask; +} + +namespace API { + +class URLSchemeHandlerTask final : public ObjectImpl { +public: + static Ref create(WebKit::WebURLSchemeHandlerTask&); + + WebKit::WebURLSchemeHandlerTask& task() { return m_webURLSchemeHandlerTask.get(); } + +private: + URLSchemeHandlerTask(WebKit::WebURLSchemeHandlerTask&); + + Ref m_webURLSchemeHandlerTask; +}; + +} diff --git a/Source/WebKit2/UIProcess/API/APIWebsiteDataStore.cpp b/Source/WebKit2/UIProcess/API/APIWebsiteDataStore.cpp index 1d0873890..7f6f4a0b2 100644 --- a/Source/WebKit2/UIProcess/API/APIWebsiteDataStore.cpp +++ b/Source/WebKit2/UIProcess/API/APIWebsiteDataStore.cpp @@ -66,7 +66,7 @@ bool WebsiteDataStore::isPersistent() return m_websiteDataStore->isPersistent(); } -#if !PLATFORM(COCOA) && !PLATFORM(EFL) && !PLATFORM(GTK) +#if !PLATFORM(COCOA) && !PLATFORM(EFL) && !PLATFORM(GTK) && !PLATFORM(QT) WebKit::WebsiteDataStore::Configuration WebsiteDataStore::defaultDataStoreConfiguration() { // FIXME: Fill everything in. diff --git a/Source/WebKit2/UIProcess/API/cpp/qt/WKStringQt.cpp b/Source/WebKit2/UIProcess/API/cpp/qt/WKStringQt.cpp index 4ae448e62..6fad021f6 100644 --- a/Source/WebKit2/UIProcess/API/cpp/qt/WKStringQt.cpp +++ b/Source/WebKit2/UIProcess/API/cpp/qt/WKStringQt.cpp @@ -39,8 +39,13 @@ QString WKStringCopyQString(WKStringRef stringRef) { if (!stringRef) return QString(); - const WTF::String& string = toImpl(stringRef)->string(); - return QString(reinterpret_cast(string.characters()), string.length()); + + auto stringView = toImpl(stringRef)->stringView(); + + if (stringView.is8Bit()) + return QString::fromLatin1(reinterpret_cast(stringView.characters8()), stringView.length()); + + return QString(reinterpret_cast(stringView.characters16()), stringView.length()); } namespace WebKit { diff --git a/Source/WebKit2/UIProcess/API/qt/APIWebsiteDataStoreQt.cpp b/Source/WebKit2/UIProcess/API/qt/APIWebsiteDataStoreQt.cpp new file mode 100644 index 000000000..ab2b11a1b --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/APIWebsiteDataStoreQt.cpp @@ -0,0 +1,90 @@ +/* + * 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 "APIWebsiteDataStore.h" + +#include "QtWebContext.h" + +#include +#include + +namespace API { + +String WebsiteDataStore::defaultApplicationCacheDirectory() +{ + return WebKit::QtWebContext::preparedStoragePath(WebKit::QtWebContext::ApplicationCacheStorage); +} + +String WebsiteDataStore::defaultNetworkCacheDirectory() +{ + return WebKit::QtWebContext::preparedStoragePath(WebKit::QtWebContext::DiskCacheStorage); +} + +String WebsiteDataStore::defaultIndexedDBDatabaseDirectory() +{ + return WebKit::QtWebContext::preparedStoragePath(WebKit::QtWebContext::DatabaseStorage); +} + +String WebsiteDataStore::defaultLocalStorageDirectory() +{ + return WebKit::QtWebContext::preparedStoragePath(WebKit::QtWebContext::LocalStorage); +} + +String WebsiteDataStore::defaultMediaKeysStorageDirectory() +{ + return String(); // QTFIXME: Add MediaKeys path +} + +String WebsiteDataStore::defaultWebSQLDatabaseDirectory() +{ + return WebKit::QtWebContext::preparedStoragePath(WebKit::QtWebContext::DatabaseStorage); +} + +String WebsiteDataStore::cacheDirectoryFileSystemRepresentation(const String& directoryName) +{ + return String(); +} + +String WebsiteDataStore::websiteDataDirectoryFileSystemRepresentation(const String& directoryName) +{ + return String(); +} + +WebKit::WebsiteDataStore::Configuration WebsiteDataStore::defaultDataStoreConfiguration() +{ + WebKit::WebsiteDataStore::Configuration configuration; + + configuration.applicationCacheDirectory = defaultApplicationCacheDirectory(); + configuration.networkCacheDirectory = defaultNetworkCacheDirectory(); + + configuration.webSQLDatabaseDirectory = defaultWebSQLDatabaseDirectory(); + configuration.localStorageDirectory = defaultLocalStorageDirectory(); + configuration.mediaKeysStorageDirectory = defaultMediaKeysStorageDirectory(); + + return configuration; +} + +} // namespace API diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp b/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp index a991bcfdd..f6717a405 100644 --- a/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp +++ b/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp @@ -59,10 +59,10 @@ QQuickWebPagePrivate::QQuickWebPagePrivate(QQuickWebPage* q, QQuickWebView* view { } -void QQuickWebPagePrivate::paint(QPainter* painter) +void QQuickWebPagePrivate::paint(QPainter* painter, const WebCore::Color& backgroundColor, bool drawsBackground) { if (CoordinatedGraphicsScene* scene = QQuickWebViewPrivate::get(viewportItem)->coordinatedGraphicsScene()) - scene->paintToGraphicsContext(painter); + scene->paintToGraphicsContext(painter, backgroundColor, drawsBackground); } @@ -88,7 +88,7 @@ QSGNode* QQuickWebPage::updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData*) } if (!node) - node = new QtWebPageSGNode; + node = new QtWebPageSGNode(*webViewPrivate->webPageProxy); node->setCoordinatedGraphicsScene(scene); diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebpage_p_p.h b/Source/WebKit2/UIProcess/API/qt/qquickwebpage_p_p.h index 9a04b3f03..e8120a19e 100644 --- a/Source/WebKit2/UIProcess/API/qt/qquickwebpage_p_p.h +++ b/Source/WebKit2/UIProcess/API/qt/qquickwebpage_p_p.h @@ -24,6 +24,10 @@ #include "qquickwebpage_p.h" #include +namespace WebCore { +class Color; +} + class QQuickWebViewPrivate; class QQuickWebPagePrivate { @@ -33,7 +37,7 @@ public: void updateSize(); - void paint(QPainter*); + void paint(QPainter*, const WebCore::Color& backgroundColor, bool drawsBackground); void resetPaintNode(); QQuickWebPage* const q; QQuickWebView* const viewportItem; diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp b/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp index 9b634184a..cf8ac19d9 100644 --- a/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp +++ b/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp @@ -23,11 +23,13 @@ #include "config.h" #include "qquickwebview_p.h" +#include "APIPageConfiguration.h" +#include "CoordinatedDrawingAreaProxy.h" #include "CoordinatedGraphicsScene.h" #include "CoordinatedLayerTreeHostProxy.h" #include "DownloadProxy.h" -#include "DrawingAreaProxyImpl.h" #include "PageViewportControllerClientQt.h" +#include "QrcSchemeHandler.h" #include "QtDialogRunner.h" #include "QtDownloadManager.h" #include "QtWebContext.h" @@ -68,8 +70,10 @@ #include #include #include +#include #include #include +#include #include #include #include @@ -84,7 +88,7 @@ #include #include -#ifdef HAVE_WEBCHANNEL +#if ENABLE(QT_WEBCHANNEL) #include "qwebchannelwebkittransport_p.h" #include #endif @@ -92,7 +96,8 @@ using namespace WebCore; using namespace WebKit; -static bool s_flickableViewportEnabled = true; +// QTFIXME: flickable viewport has painting artifacts so we cannot enable it by default +static bool s_flickableViewportEnabled = false; //true; static const int kAxisLockSampleCount = 5; static const qreal kAxisLockVelocityThreshold = 300; static const qreal kAxisLockVelocityDirectionThreshold = 50; @@ -131,6 +136,11 @@ static QJSValue buildQJSValue(QJSEngine* engine, JSGlobalContextRef context, JSV return var; switch (JSValueGetType(context, value)) { + case kJSTypeUndefined: + break; + case kJSTypeNull: + var = QJSValue(QJSValue::NullValue); + break; case kJSTypeBoolean: var = QJSValue(JSValueToBoolean(context, value)); break; @@ -324,39 +334,47 @@ QQuickWebViewPrivate::~QQuickWebViewPrivate() } // Note: we delay this initialization to make sure that QQuickWebView has its d-ptr in-place. -void QQuickWebViewPrivate::initialize(WKContextRef contextRef, WKPageGroupRef pageGroupRef) -{ - pageGroup = pageGroupRef; - if (!pageGroup) - pageGroup = adoptWK(WKPageGroupCreateWithIdentifier(0)); +void QQuickWebViewPrivate::initialize(WKPageConfigurationRef configurationRef) +{ + WKRetainPtr pageConfiguration; + WKContextRef contextRef = nullptr; + + if (configurationRef) { + pageConfiguration = adoptWK(configurationRef); + contextRef = WKPageConfigurationGetContext(configurationRef); + context = QtWebContext::create(contextRef); + } else { + pageConfiguration = adoptWK(WKPageConfigurationCreate()); + WKRetainPtr pageGroup = adoptWK(WKPageGroupCreateWithIdentifier(0)); + WKPageConfigurationSetPageGroup(pageConfiguration.get(), pageGroup.get()); + context = QtWebContext::defaultContext(); + } - context = contextRef ? QtWebContext::create(contextRef) : QtWebContext::defaultContext(); - webPageProxy = toImpl(context->context())->createWebPage(pageClient, toImpl(pageGroup.get())); + webPageProxy = toImpl(context->context())->createWebPage(pageClient, toImpl(pageConfiguration.get())->copy()); webPage = toAPI(webPageProxy.get()); pageToView()->insert(webPage.get(), this); - webPageProxy->setUseFixedLayout(s_flickableViewportEnabled); -#if ENABLE(FULLSCREEN_API) - webPageProxy->fullScreenManager()->setWebView(q_ptr); -#endif - pageEventHandler.reset(new QtWebPageEventHandler(webPage.get(), pageView.data(), q_ptr)); + pageClient.initialize(q_ptr, pageEventHandler.data(), &undoController); + webPageProxy->initializeWebPage(); + + webPageProxy->setUseFixedLayout(s_flickableViewportEnabled); { - WKPageFindClient findClient; - memset(&findClient, 0, sizeof(WKPageFindClient)); - findClient.version = kWKPageFindClientCurrentVersion; - findClient.clientInfo = this; + WKPageFindClientV0 findClient; + memset(&findClient, 0, sizeof(WKPageFindClientV0)); + findClient.base.version = 0; + findClient.base.clientInfo = this; findClient.didFindString = didFindString; findClient.didFailToFindString = didFailToFindString; - WKPageSetPageFindClient(webPage.get(), &findClient); + WKPageSetPageFindClient(webPage.get(), &findClient.base); } { - WKPageLoaderClient loadClient; - memset(&loadClient, 0, sizeof(WKPageLoaderClient)); - loadClient.version = kWKPageLoaderClientCurrentVersion; - loadClient.clientInfo = this; + WKPageLoaderClientV0 loadClient; + memset(&loadClient, 0, sizeof(WKPageLoaderClientV0)); + loadClient.base.version = 0; + loadClient.base.clientInfo = this; loadClient.didStartProvisionalLoadForFrame = didStartProvisionalLoadForFrame; loadClient.didReceiveServerRedirectForProvisionalLoadForFrame = didReceiveServerRedirectForProvisionalLoadForFrame; loadClient.didFailProvisionalLoadWithErrorForFrame = didFailLoad; @@ -371,7 +389,7 @@ void QQuickWebViewPrivate::initialize(WKContextRef contextRef, WKPageGroupRef pa loadClient.didChangeBackForwardList = didChangeBackForwardList; loadClient.processDidBecomeUnresponsive = processDidBecomeUnresponsive; loadClient.processDidBecomeResponsive = processDidBecomeResponsive; - WKPageSetPageLoaderClient(webPage.get(), &loadClient); + WKPageSetPageLoaderClient(webPage.get(), &loadClient.base); } pagePolicyClient.reset(new QtWebPagePolicyClient(webPage.get(), q_ptr)); @@ -382,18 +400,17 @@ void QQuickWebViewPrivate::initialize(WKContextRef contextRef, WKPageGroupRef pa QObject::connect(iconDatabase, SIGNAL(iconChangedForPageURL(QString)), q_ptr, SLOT(_q_onIconChangedForPageURL(QString))); // Any page setting should preferrable be set before creating the page. - WKPreferencesRef preferencesRef = WKPageGroupGetPreferences(pageGroup.get()); - WKPreferencesSetAcceleratedCompositingEnabled(preferencesRef, true); + auto& preferences = webPageProxy->pageGroup().preferences(); + preferences.setAcceleratedCompositingEnabled(true); bool showDebugVisuals = qgetenv("WEBKIT_SHOW_COMPOSITING_DEBUG_VISUALS") == "1"; - WKPreferencesSetCompositingBordersVisible(preferencesRef, showDebugVisuals); - WKPreferencesSetCompositingRepaintCountersVisible(preferencesRef, showDebugVisuals); - WKPreferencesSetFrameFlatteningEnabled(preferencesRef, true); - WKPreferencesSetWebGLEnabled(preferencesRef, true); - webPageProxy->pageGroup().preferences().setForceCompositingMode(true); + preferences.setCompositingBordersVisible(showDebugVisuals); + preferences.setCompositingRepaintCountersVisible(showDebugVisuals); + preferences.setFrameFlatteningEnabled(true); + preferences.setMediaSourceEnabled(false); + preferences.setWebGLEnabled(true); + preferences.setForceCompositingMode(true); - pageClient.initialize(q_ptr, pageEventHandler.data(), &undoController); - webPageProxy->initializeWebPage(); - webPageProxy->registerApplicationScheme(ASCIILiteral("qrc")); + webPageProxy->setURLSchemeHandlerForScheme(QrcSchemeHandler::create(), ASCIILiteral("qrc")); q_ptr->setAcceptedMouseButtons(Qt::MouseButtonMask); q_ptr->setAcceptHoverEvents(true); @@ -574,7 +591,7 @@ void QQuickWebViewPrivate::setNeedsDisplay() // the web process when running tests even if the render loop is not active. QImage dummyImage(1, 1, QImage::Format_ARGB32); QPainter painter(&dummyImage); - q->page()->d->paint(&painter); + q->page()->d->paint(&painter, webPageProxy->pageExtendedBackgroundColor(), webPageProxy->drawsBackground()); return; } q->page()->update(); @@ -600,7 +617,7 @@ void QQuickWebViewPrivate::processDidCrash() // Check if loading was ongoing, when process crashed. if (m_loadProgress > 0 && m_loadProgress < 100) { - QWebLoadRequest loadRequest(url, QQuickWebView::LoadFailedStatus, QLatin1String("The web process crashed."), QQuickWebView::InternalErrorDomain, 0); + QWebLoadRequest loadRequest(url, QQuickWebView::LoadFailedStatus, QStringLiteral("The web process crashed."), QQuickWebView::InternalErrorDomain, 0); loadProgressDidChange(100); emit q->loadingChanged(&loadRequest); @@ -643,7 +660,7 @@ void QQuickWebViewPrivate::processDidBecomeResponsive(WKPageRef, const void* cli std::unique_ptr QQuickWebViewPrivate::createDrawingAreaProxy() { - return std::make_unique(*webPageProxy.get()); + return std::make_unique(*webPageProxy.get()); } void QQuickWebViewPrivate::handleDownloadRequest(DownloadProxy* download) @@ -874,11 +891,11 @@ void QQuickWebViewPrivate::setNavigatorQtObjectEnabled(bool enabled) WKPagePostMessageToInjectedBundle(webPage.get(), messageName, wkEnabled.get()); } -static WKRetainPtr readUserFile(const QUrl& url, const char* userFileType) +static WTF::Optional readUserFile(const QUrl& url, const char* userFileType) { if (!url.isValid()) { qWarning("QQuickWebView: Couldn't open '%s' as %s because URL is invalid.", qPrintable(url.toString()), userFileType); - return 0; + return WTF::Nullopt; } QString path; @@ -888,33 +905,36 @@ static WKRetainPtr readUserFile(const QUrl& url, const char* userFi path = QStringLiteral(":") + url.path(); else { qWarning("QQuickWebView: Couldn't open '%s' as %s because only file:/// and qrc:/// URLs are supported.", qPrintable(url.toString()), userFileType); - return 0; + return WTF::Nullopt; } QFile file(path); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { qWarning("QQuickWebView: Couldn't open '%s' as %s due to error '%s'.", qPrintable(url.toString()), userFileType, qPrintable(file.errorString())); - return 0; + return WTF::Nullopt; } QByteArray contents = file.readAll(); - if (contents.isEmpty()) + if (contents.isEmpty()) { qWarning("QQuickWebView: Ignoring '%s' as %s because file is empty.", qPrintable(url.toString()), userFileType); + return WTF::Nullopt; + } - return adoptWK(WKStringCreateWithUTF8CString(contents.constData())); + return String::fromUTF8(contents); } void QQuickWebViewPrivate::updateUserScripts() { // This feature works per-WebView because we keep an unique page group for // each Page/WebView pair we create. - WKPageGroupRemoveAllUserScripts(pageGroup.get()); + webPageProxy->pageGroup().removeAllUserScripts(); - foreach (const QUrl& url, userScripts) { - WKRetainPtr contents = readUserFile(url, "user script"); - if (!contents || WKStringIsEmpty(contents.get())) + for (const QUrl& url : userScripts) { + auto contents = readUserFile(url, "user script"); + if (!contents) continue; - WKPageGroupAddUserScript(pageGroup.get(), contents.get(), /*baseURL*/ 0, /*whitelistedURLPatterns*/ 0, /*blacklistedURLPatterns*/ 0, kWKInjectInTopFrameOnly, kWKInjectAtDocumentEnd); + webPageProxy->pageGroup().addUserScript(contents.value(), /*baseURL*/ String(), + /*whitelistedURLPatterns*/ 0, /*blacklistedURLPatterns*/ 0, WebCore::InjectInTopFrameOnly, WebCore::InjectAtDocumentEnd); } } @@ -922,24 +942,25 @@ void QQuickWebViewPrivate::updateUserStyleSheets() { // This feature works per-WebView because we keep an unique page group for // each Page/WebView pair we create. - WKPageGroupRemoveAllUserStyleSheets(pageGroup.get()); + webPageProxy->pageGroup().removeAllUserStyleSheets(); - foreach (const QUrl& url, userStyleSheets) { - WKRetainPtr contents = readUserFile(url, "user style sheet"); - if (!contents || WKStringIsEmpty(contents.get())) + for (const QUrl& url : userStyleSheets) { + auto contents = readUserFile(url, "user style sheet"); + if (!contents) continue; - WKPageGroupAddUserStyleSheet(pageGroup.get(), contents.get(), /*baseURL*/ 0, /*whitelistedURLPatterns*/ 0, /*blacklistedURLPatterns*/ 0, kWKInjectInTopFrameOnly); + webPageProxy->pageGroup().addUserStyleSheet(contents.value(), /*baseURL*/ String(), + /*whitelistedURLPatterns*/ 0, /*blacklistedURLPatterns*/ 0, WebCore::InjectInTopFrameOnly, WebCore::UserStyleUserLevel); } } void QQuickWebViewPrivate::updateSchemeDelegates() { - webPageProxy->registerApplicationScheme(ASCIILiteral("qrc")); + webPageProxy->setURLSchemeHandlerForScheme(QrcSchemeHandler::create(), ASCIILiteral("qrc")); QQmlListProperty schemes = experimental->schemeDelegates(); for (int i = 0, numSchemes = experimental->schemeDelegates_Count(&schemes); i < numSchemes; ++i) { QQuickUrlSchemeDelegate* scheme = experimental->schemeDelegates_At(&schemes, i); - webPageProxy->registerApplicationScheme(scheme->scheme()); + //webPageProxy->registerApplicationScheme(scheme->scheme()); } } @@ -978,20 +999,25 @@ void QQuickWebViewPrivate::didReceiveMessageFromNavigatorQtObject(WKStringRef me emit q_ptr->experimental()->messageReceived(variantMap); } -#ifdef HAVE_WEBCHANNEL -void QQuickWebViewPrivate::didReceiveMessageFromNavigatorQtWebChannelTransportObject(WKStringRef message) +#if ENABLE(QT_WEBCHANNEL) +void QQuickWebViewPrivate::didReceiveMessageFromNavigatorQtWebChannelTransportObject(WKDataRef data) { - // TODO: can I convert a WKStringRef to a UTF8 QByteArray directly? - q_ptr->experimental()->m_webChannelTransport->receiveMessage(WKStringCopyQString(message).toUtf8()); + const char* bytes = reinterpret_cast(WKDataGetBytes(data)); + int size = WKDataGetSize(data); + q_ptr->experimental()->m_webChannelTransport->receiveMessage(bytes, size); } #endif CoordinatedGraphicsScene* QQuickWebViewPrivate::coordinatedGraphicsScene() { - if (webPageProxy && webPageProxy->drawingArea() && webPageProxy->drawingArea()->coordinatedLayerTreeHostProxy()) - return webPageProxy->drawingArea()->coordinatedLayerTreeHostProxy()->coordinatedGraphicsScene(); + // QTFIXME: redundant null check? +// if (!webPageProxy) +// return nullptr; - return 0; + if (CoordinatedDrawingAreaProxy* drawingArea = static_cast(webPageProxy->drawingArea())) + return drawingArea->coordinatedLayerTreeHostProxy().coordinatedGraphicsScene(); + + return nullptr; } float QQuickWebViewPrivate::deviceScaleFactor() @@ -1009,9 +1035,9 @@ QQuickWebViewLegacyPrivate::QQuickWebViewLegacyPrivate(QQuickWebView* viewport) { } -void QQuickWebViewLegacyPrivate::initialize(WKContextRef contextRef, WKPageGroupRef pageGroupRef) +void QQuickWebViewLegacyPrivate::initialize(WKPageConfigurationRef configurationRef) { - QQuickWebViewPrivate::initialize(contextRef, pageGroupRef); + QQuickWebViewPrivate::initialize(configurationRef); // Trigger setting of correct visibility flags after everything was allocated and initialized. _q_onVisibleChanged(); @@ -1026,7 +1052,7 @@ void QQuickWebViewLegacyPrivate::updateViewportSize() pageView->setContentsSize(viewportSize); - if (DrawingAreaProxy *drawingArea = webPageProxy->drawingArea()) { + if (CoordinatedDrawingAreaProxy* drawingArea = static_cast(webPageProxy->drawingArea())) { // The fixed layout is handled by the FrameView and the drawing area doesn't behave differently // whether its fixed or not. We still need to tell the drawing area which part of it // has to be rendered on tiles, and in desktop mode it's all of it. @@ -1052,9 +1078,9 @@ QQuickWebViewFlickablePrivate::QQuickWebViewFlickablePrivate(QQuickWebView* view { } -void QQuickWebViewFlickablePrivate::initialize(WKContextRef contextRef, WKPageGroupRef pageGroupRef) +void QQuickWebViewFlickablePrivate::initialize(WKPageConfigurationRef configurationRef) { - QQuickWebViewPrivate::initialize(contextRef, pageGroupRef); + QQuickWebViewPrivate::initialize(configurationRef); } void QQuickWebViewFlickablePrivate::onComponentComplete() @@ -1064,6 +1090,7 @@ void QQuickWebViewFlickablePrivate::onComponentComplete() Q_Q(QQuickWebView); m_pageViewportControllerClient.reset(new PageViewportControllerClientQt(q, pageView.data())); m_pageViewportController.reset(new PageViewportController(webPageProxy.get(), *m_pageViewportControllerClient.data())); + m_pageViewportControllerClient->setController(m_pageViewportController.data()); pageEventHandler->setViewportController(m_pageViewportControllerClient.data()); // Trigger setting of correct visibility flags after everything was allocated and initialized. @@ -1101,12 +1128,12 @@ QQuickWebViewExperimental::QQuickWebViewExperimental(QQuickWebView *webView, QQu , d_ptr(webViewPrivate) , schemeParent(new QObject(this)) , m_test(new QWebKitTest(webViewPrivate, this)) -#ifdef HAVE_WEBCHANNEL +#if ENABLE(QT_WEBCHANNEL) , m_webChannel(new QQmlWebChannel(this)) , m_webChannelTransport(new QWebChannelWebKitTransport(this)) #endif { -#ifdef HAVE_WEBCHANNEL +#if ENABLE(QT_WEBCHANNEL) m_webChannel->connectTo(m_webChannelTransport); #endif } @@ -1197,7 +1224,7 @@ bool QQuickWebViewExperimental::flickableViewportEnabled() return s_flickableViewportEnabled; } -#ifdef HAVE_WEBCHANNEL +#if ENABLE(QT_WEBCHANNEL) QQmlWebChannel* QQuickWebViewExperimental::webChannel() const { return m_webChannel; @@ -1239,12 +1266,13 @@ void QQuickWebViewExperimental::postMessage(const QString& message) WKPagePostMessageToInjectedBundle(d->webPage.get(), messageName, contents.get()); } -#ifdef HAVE_WEBCHANNEL +#if ENABLE(QT_WEBCHANNEL) void QQuickWebViewExperimental::postQtWebChannelTransportMessage(const QByteArray& message) { Q_D(QQuickWebView); static WKStringRef messageName = WKStringCreateWithUTF8CString("MessageToNavigatorQtWebChannelTransportObject"); - WKRetainPtr contents = adoptWK(WKStringCreateWithUTF8CString(message.constData())); + // TODO: API::Data::createWithoutCopying may help to avoid copy + WKRetainPtr contents = adoptWK(WKDataCreate(reinterpret_cast(message.data()), message.size())); WKPagePostMessageToInjectedBundle(d->webPage.get(), messageName, contents.get()); } #endif @@ -1585,7 +1613,7 @@ void QQuickWebViewExperimental::schemeDelegates_Append(QQmlListPropertyreply()->setWebViewExperimental(webViewExperimental); QQuickWebViewPrivate* d = webViewExperimental->d_func(); - d->webPageProxy->registerApplicationScheme(scheme->scheme()); + //d->webPageProxy->registerApplicationScheme(scheme->scheme()); } int QQuickWebViewExperimental::schemeDelegates_Count(QQmlListProperty* property) @@ -1640,7 +1668,7 @@ void QQuickWebViewExperimental::invokeApplicationSchemeHandler(PassRefPtrwebPageProxy->sendApplicationSchemeReply(reply); + //d_ptr->webPageProxy->sendApplicationSchemeReply(reply); } void QQuickWebViewExperimental::goForwardTo(int index) @@ -1749,12 +1777,12 @@ QQuickWebView::QQuickWebView(QQuickItem* parent) d->initialize(); } -QQuickWebView::QQuickWebView(WKContextRef contextRef, WKPageGroupRef pageGroupRef, QQuickItem* parent) - : QQuickFlickable(parent) +QQuickWebView::QQuickWebView(WKPageConfigurationRef configurationRef) + : QQuickFlickable() , d_ptr(createPrivateObject(this)) { Q_D(QQuickWebView); - d->initialize(contextRef, pageGroupRef); + d->initialize(configurationRef); } QQuickWebView::~QQuickWebView() diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h index c06f8f219..541544463 100644 --- a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h +++ b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h @@ -65,8 +65,7 @@ namespace WTF { template class PassRefPtr; } -typedef const struct OpaqueWKContext* WKContextRef; -typedef const struct OpaqueWKPageGroup* WKPageGroupRef; +typedef const struct OpaqueWKPageConfiguration* WKPageConfigurationRef; typedef const struct OpaqueWKPage* WKPageRef; QT_BEGIN_NAMESPACE @@ -210,7 +209,7 @@ private: QPointF contentPos() const; void setContentPos(const QPointF&); - QQuickWebView(WKContextRef, WKPageGroupRef, QQuickItem* parent = 0); + QQuickWebView(WKPageConfigurationRef); WKPageRef pageRef() const; void emitUrlChangeIfNeeded(); @@ -283,7 +282,7 @@ class QWEBKIT_EXPORT QQuickWebViewExperimental : public QObject { Q_PROPERTY(QList userScripts READ userScripts WRITE setUserScripts NOTIFY userScriptsChanged) Q_PROPERTY(QList userStyleSheets READ userStyleSheets WRITE setUserStyleSheets NOTIFY userStyleSheetsChanged) Q_PROPERTY(QUrl remoteInspectorUrl READ remoteInspectorUrl NOTIFY remoteInspectorUrlChanged FINAL) -#ifdef HAVE_WEBCHANNEL +#ifdef QT_WEBCHANNEL_LIB Q_PROPERTY(QQmlWebChannel* webChannel READ webChannel WRITE setWebChannel NOTIFY webChannelChanged) #endif Q_ENUMS(NavigationRequestActionExperimental) @@ -365,7 +364,7 @@ public: static void setFlickableViewportEnabled(bool enable); static bool flickableViewportEnabled(); -#ifdef HAVE_WEBCHANNEL +#ifdef QT_WEBCHANNEL_LIB QQmlWebChannel* webChannel() const; void setWebChannel(QQmlWebChannel* channel); void postQtWebChannelTransportMessage(const QByteArray& message); @@ -409,9 +408,7 @@ Q_SIGNALS: void processDidBecomeUnresponsive(); void processDidBecomeResponsive(); -#ifdef HAVE_WEBCHANNEL void webChannelChanged(QQmlWebChannel* channel); -#endif private: QQuickWebViewExperimental(QQuickWebView* webView, QQuickWebViewPrivate* webViewPrivate); @@ -420,7 +417,7 @@ private: QObject* schemeParent; QWebKitTest* m_test; -#ifdef HAVE_WEBCHANNEL +#ifdef QT_WEBCHANNEL_LIB QQmlWebChannel* m_webChannel; QWebChannelWebKitTransport* m_webChannelTransport; #endif diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h index d041a8eb1..fe40823ea 100644 --- a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h +++ b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h @@ -71,7 +71,7 @@ public: virtual ~QQuickWebViewPrivate(); - virtual void initialize(WKContextRef contextRef = 0, WKPageGroupRef pageGroupRef = 0); + virtual void initialize(WKPageConfigurationRef configurationRef = 0); virtual void onComponentComplete() { } @@ -135,8 +135,8 @@ public: void handleDownloadRequest(WebKit::DownloadProxy*); void didReceiveMessageFromNavigatorQtObject(WKStringRef message); -#ifdef HAVE_WEBCHANNEL - void didReceiveMessageFromNavigatorQtWebChannelTransportObject(WKStringRef message); +#if ENABLE(QT_WEBCHANNEL) + void didReceiveMessageFromNavigatorQtWebChannelTransportObject(WKDataRef); #endif WebKit::CoordinatedGraphicsScene* coordinatedGraphicsScene(); @@ -181,7 +181,6 @@ protected: QQuickWebViewPrivate(QQuickWebView* viewport); RefPtr webPageProxy; WKRetainPtr webPage; - WKRetainPtr pageGroup; WebKit::QtPageClient pageClient; WebKit::DefaultUndoController undoController; @@ -227,7 +226,7 @@ class QQuickWebViewLegacyPrivate : public QQuickWebViewPrivate { Q_DECLARE_PUBLIC(QQuickWebView) public: QQuickWebViewLegacyPrivate(QQuickWebView* viewport); - void initialize(WKContextRef contextRef = 0, WKPageGroupRef pageGroupRef = 0) Q_DECL_OVERRIDE; + void initialize(WKPageConfigurationRef configurationRef = 0) Q_DECL_OVERRIDE; void updateViewportSize() Q_DECL_OVERRIDE; @@ -239,7 +238,7 @@ class QQuickWebViewFlickablePrivate : public QQuickWebViewPrivate { Q_DECLARE_PUBLIC(QQuickWebView) public: QQuickWebViewFlickablePrivate(QQuickWebView* viewport); - void initialize(WKContextRef contextRef = 0, WKPageGroupRef pageGroupRef = 0) Q_DECL_OVERRIDE; + void initialize(WKPageConfigurationRef configurationRef = 0) Q_DECL_OVERRIDE; void onComponentComplete() Q_DECL_OVERRIDE; diff --git a/Source/WebKit2/UIProcess/API/qt/qwebchannelwebkittransport.cpp b/Source/WebKit2/UIProcess/API/qt/qwebchannelwebkittransport.cpp index b74c45b3c..c6f96f094 100644 --- a/Source/WebKit2/UIProcess/API/qt/qwebchannelwebkittransport.cpp +++ b/Source/WebKit2/UIProcess/API/qt/qwebchannelwebkittransport.cpp @@ -42,7 +42,7 @@ #include "config.h" #include "qwebchannelwebkittransport_p.h" -#ifdef HAVE_WEBCHANNEL +#if ENABLE(QT_WEBCHANNEL) #include "qquickwebview_p.h" @@ -57,23 +57,16 @@ QWebChannelWebKitTransport::QWebChannelWebKitTransport(QQuickWebViewExperimental void QWebChannelWebKitTransport::sendMessage(const QJsonObject& message) { - const QByteArray data = QJsonDocument(message).toJson(QJsonDocument::Compact); + QByteArray data = QJsonDocument(message).toBinaryData(); m_experimental->postQtWebChannelTransportMessage(data); } -void QWebChannelWebKitTransport::receiveMessage(const QByteArray& message) +void QWebChannelWebKitTransport::receiveMessage(const char* message, int size) { - QJsonParseError error; - const QJsonDocument doc = QJsonDocument::fromJson(message, &error); - if (error.error != QJsonParseError::NoError) { - qWarning() << "Failed to parse the client WebKit QWebChannel message as JSON: " << message - << "Error message is:" << error.errorString(); - return; - } else if (!doc.isObject()) { - qWarning() << "Received WebKit QWebChannel message is not a JSON object: " << message; - return; - } + QJsonDocument doc = QJsonDocument::fromRawData(message, size, QJsonDocument::BypassValidation); emit messageReceived(doc.object(), this); } -#endif // HAVE_WEBCHANNEL +#include "moc_qwebchannelwebkittransport_p.cpp" + +#endif // ENABLE(QT_WEBCHANNEL) diff --git a/Source/WebKit2/UIProcess/API/qt/qwebchannelwebkittransport_p.h b/Source/WebKit2/UIProcess/API/qt/qwebchannelwebkittransport_p.h index 9e17d6fa4..8d8cf643d 100644 --- a/Source/WebKit2/UIProcess/API/qt/qwebchannelwebkittransport_p.h +++ b/Source/WebKit2/UIProcess/API/qt/qwebchannelwebkittransport_p.h @@ -41,8 +41,6 @@ #pragma once -#ifdef HAVE_WEBCHANNEL - #include class QQuickWebViewExperimental; @@ -54,10 +52,8 @@ public: void sendMessage(const QJsonObject& message) override; - void receiveMessage(const QByteArray& message); + void receiveMessage(const char* message, int size); private: QQuickWebViewExperimental* m_experimental; }; - -#endif // HAVE_WEBCHANNEL diff --git a/Source/WebKit2/UIProcess/API/qt/qwebkittest.cpp b/Source/WebKit2/UIProcess/API/qt/qwebkittest.cpp index 20cfa388d..2909124da 100644 --- a/Source/WebKit2/UIProcess/API/qt/qwebkittest.cpp +++ b/Source/WebKit2/UIProcess/API/qt/qwebkittest.cpp @@ -140,8 +140,8 @@ QSize QWebKitTest::contentsSize() const static inline QJsonObject toJsonObject(const QSizeF& sizeF) { QJsonObject result; - result.insert(QLatin1String("width"), sizeF.width()); - result.insert(QLatin1String("height"), sizeF.height()); + result.insert(QStringLiteral("width"), sizeF.width()); + result.insert(QStringLiteral("height"), sizeF.height()); return result; } @@ -149,16 +149,16 @@ QJsonObject QWebKitTest::viewport() const { QJsonObject viewportData; if (const PageViewportController* const viewportHandler = m_webViewPrivate->viewportController()) { - viewportData.insert(QLatin1String("layoutSize"), toJsonObject(viewportHandler->contentsLayoutSize())); - viewportData.insert(QLatin1String("isScalable"), viewportHandler->allowsUserScaling()); - viewportData.insert(QLatin1String("minimumScale"), viewportHandler->minimumScale()); - viewportData.insert(QLatin1String("maximumScale"), viewportHandler->maximumScale()); + viewportData.insert(QStringLiteral("layoutSize"), toJsonObject(viewportHandler->contentsLayoutSize())); + viewportData.insert(QStringLiteral("isScalable"), viewportHandler->allowsUserScaling()); + viewportData.insert(QStringLiteral("minimumScale"), viewportHandler->minimumScale()); + viewportData.insert(QStringLiteral("maximumScale"), viewportHandler->maximumScale()); } else { - viewportData.insert(QLatin1String("initialScale"), 1.0); - viewportData.insert(QLatin1String("layoutSize"), toJsonObject(QSizeF())); - viewportData.insert(QLatin1String("isScalable"), false); - viewportData.insert(QLatin1String("minimumScale"), 1.0); - viewportData.insert(QLatin1String("maximumScale"), 1.0); + viewportData.insert(QStringLiteral("initialScale"), 1.0); + viewportData.insert(QStringLiteral("layoutSize"), toJsonObject(QSizeF())); + viewportData.insert(QStringLiteral("isScalable"), false); + viewportData.insert(QStringLiteral("minimumScale"), 1.0); + viewportData.insert(QStringLiteral("maximumScale"), 1.0); } return viewportData; } @@ -176,3 +176,5 @@ QVariant QWebKitTest::contentsScale() const return viewport->currentScale(); return 1.0; } + +#include "moc_qwebkittest_p.cpp" diff --git a/Source/WebKit2/UIProcess/API/qt/qwebloadrequest.cpp b/Source/WebKit2/UIProcess/API/qt/qwebloadrequest.cpp index 6271ebfa6..453abc03e 100644 --- a/Source/WebKit2/UIProcess/API/qt/qwebloadrequest.cpp +++ b/Source/WebKit2/UIProcess/API/qt/qwebloadrequest.cpp @@ -108,3 +108,5 @@ int QWebLoadRequest::errorCode() const { return d->errorCode; } + +#include "moc_qwebloadrequest_p.cpp" diff --git a/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp b/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp index b486e9391..cead3f7c2 100644 --- a/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp +++ b/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp @@ -20,8 +20,10 @@ #include "config.h" #include "qwebpreferences_p.h" +#include "WebPageGroup.h" #include "qquickwebview_p_p.h" #include "qwebpreferences_p_p.h" +#include #include #include #include @@ -37,7 +39,7 @@ QWebPreferences* QWebPreferencesPrivate::createPreferences(QQuickWebViewPrivate* bool QWebPreferencesPrivate::testAttribute(QWebPreferencesPrivate::WebAttribute attr) const { - WKPreferencesRef preferencesRef = WKPageGroupGetPreferences(webViewPrivate->pageGroup.get()); + WKPreferencesRef preferencesRef = toAPI(&webViewPrivate->webPageProxy->pageGroup().preferences()); switch (attr) { case AutoLoadImages: return WKPreferencesGetLoadsImagesAutomatically(preferencesRef); @@ -95,7 +97,7 @@ bool QWebPreferencesPrivate::testAttribute(QWebPreferencesPrivate::WebAttribute void QWebPreferencesPrivate::setAttribute(QWebPreferencesPrivate::WebAttribute attr, bool enable) { - WKPreferencesRef preferencesRef = WKPageGroupGetPreferences(webViewPrivate->pageGroup.get()); + WKPreferencesRef preferencesRef = toAPI(&webViewPrivate->webPageProxy->pageGroup().preferences()); switch (attr) { case AutoLoadImages: WKPreferencesSetLoadsImagesAutomatically(preferencesRef, enable); @@ -196,7 +198,7 @@ void QWebPreferencesPrivate::initializeDefaultFontSettings() void QWebPreferencesPrivate::setFontFamily(QWebPreferencesPrivate::FontFamily which, const QString& family) { - WKPreferencesRef preferencesRef = WKPageGroupGetPreferences(webViewPrivate->pageGroup.get()); + WKPreferencesRef preferencesRef = toAPI(&webViewPrivate->webPageProxy->pageGroup().preferences()); WKRetainPtr familyRef = adoptWK(WKStringCreateWithQString(family)); switch (which) { case StandardFont: @@ -224,7 +226,7 @@ void QWebPreferencesPrivate::setFontFamily(QWebPreferencesPrivate::FontFamily wh QString QWebPreferencesPrivate::fontFamily(QWebPreferencesPrivate::FontFamily which) const { - WKPreferencesRef preferencesRef = WKPageGroupGetPreferences(webViewPrivate->pageGroup.get()); + WKPreferencesRef preferencesRef = toAPI(&webViewPrivate->webPageProxy->pageGroup().preferences()); switch (which) { case StandardFont: return adoptToQString(WKPreferencesCopyStandardFontFamily(preferencesRef)); @@ -244,8 +246,8 @@ QString QWebPreferencesPrivate::fontFamily(QWebPreferencesPrivate::FontFamily wh } void QWebPreferencesPrivate::setFontSize(QWebPreferencesPrivate::FontSizeType type, unsigned size) -{ - WKPreferencesRef preferencesRef = WKPageGroupGetPreferences(webViewPrivate->pageGroup.get()); +{ + WKPreferencesRef preferencesRef = toAPI(&webViewPrivate->webPageProxy->pageGroup().preferences()); switch (type) { case MinimumFontSize: WKPreferencesSetMinimumFontSize(preferencesRef, static_cast(size)); @@ -263,7 +265,7 @@ void QWebPreferencesPrivate::setFontSize(QWebPreferencesPrivate::FontSizeType ty unsigned QWebPreferencesPrivate::fontSize(QWebPreferencesPrivate::FontSizeType type) const { - WKPreferencesRef preferencesRef = WKPageGroupGetPreferences(webViewPrivate->pageGroup.get()); + WKPreferencesRef preferencesRef = toAPI(&webViewPrivate->webPageProxy->pageGroup().preferences()); switch (type) { case MinimumFontSize: return static_cast(WKPreferencesGetMinimumFontSize(preferencesRef)); diff --git a/Source/WebKit2/UIProcess/API/qt/tests/CMakeLists.txt b/Source/WebKit2/UIProcess/API/qt/tests/CMakeLists.txt new file mode 100644 index 000000000..b26366492 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/CMakeLists.txt @@ -0,0 +1,93 @@ +include_directories( + "${CMAKE_SOURCE_DIR}/Source" + "${FORWARDING_HEADERS_DIR}/QtWebKit" + "${WEBKIT_DIR}/qt/Api" +) + +include_directories(SYSTEM + ${Qt5Quick_INCLUDE_DIRS} + ${Qt5Quick_PRIVATE_INCLUDE_DIRS} + ${Qt5QuickTest_INCLUDE_DIRS} +) + +set(tst_qmltests_DEFINITIONS + IMPORT_DIR="${CMAKE_BINARY_DIR}/imports" + QWP_PATH="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" + TESTS_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}" +) + +set(tst_qmltests_DesktopBehavior_DEFINITIONS + ${tst_qmltests_DEFINITIONS} + + QUICK_TEST_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}/qmltests/DesktopBehavior" + DISABLE_FLICKABLE_VIEWPORT=1 +) + +set(tst_qmltests_WebView_DEFINITIONS + ${tst_qmltests_DEFINITIONS} + + QUICK_TEST_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}/qmltests/WebView" +) + +set(qmltests_QML_SOURCES + qmltests/DesktopBehavior/tst_linkHovered.qml + qmltests/DesktopBehavior/tst_loadHtml.qml + qmltests/DesktopBehavior/tst_navigationRequested.qml + + qmltests/WebView/tst_applicationScheme.qml + qmltests/WebView/tst_colorChooser.qml + qmltests/WebView/tst_doubleTapToZoom.qml + qmltests/WebView/tst_download.qml + qmltests/WebView/tst_evaluateJavaScript.qml + qmltests/WebView/tst_favIconLoad.qml + qmltests/WebView/tst_findText.qml + qmltests/WebView/tst_fitToView.qml + qmltests/WebView/tst_geopermission.qml + qmltests/WebView/tst_itemSelector.qml + qmltests/WebView/tst_javaScriptDialogs.qml + qmltests/WebView/tst_loadFail.qml + qmltests/WebView/tst_loadHtml.qml + qmltests/WebView/tst_loadProgress.qml + qmltests/WebView/tst_loadProgressSignal.qml + qmltests/WebView/tst_loadUrl.qml + qmltests/WebView/tst_messaging.qml + qmltests/WebView/tst_multiFileUpload.qml + qmltests/WebView/tst_navigationHistory.qml + qmltests/WebView/tst_notification.qml + qmltests/WebView/tst_origin.qml + qmltests/WebView/tst_preferences.qml + qmltests/WebView/tst_properties.qml + qmltests/WebView/tst_resize.qml + qmltests/WebView/tst_singleFileUpload.qml + qmltests/WebView/tst_titleChanged.qml + qmltests/WebView/tst_userScripts.qml + qmltests/WebView/tst_webchannel.qml + qmltests/WebView/tst_wheelEventHandling.qml + + qmltests/common/TestWebView.qml +) + +set(qmltests_SOURCES + bytearraytestdata.cpp + util.cpp + + qmltests/tst_qmltests.cpp + ${qmltests_QML_SOURCES} +) + +qt5_add_resources(qmltests_SOURCES qmltests/resources.qrc) + +set(qmltests_LIBRARIES + WebKit + ${Qt5Quick_LIBRARIES} + ${Qt5QuickTest_LIBRARIES} + ${Qt5Test_LIBRARIES} +) + +add_executable(tst_qmltests_WebView ${qmltests_SOURCES}) +target_compile_definitions(tst_qmltests_WebView PRIVATE ${tst_qmltests_WebView_DEFINITIONS}) +target_link_libraries(tst_qmltests_WebView ${qmltests_LIBRARIES}) + +add_executable(tst_qmltests_DesktopBehavior ${qmltests_SOURCES}) +target_compile_definitions(tst_qmltests_DesktopBehavior PRIVATE ${tst_qmltests_DesktopBehavior_DEFINITIONS}) +target_link_libraries(tst_qmltests_DesktopBehavior ${qmltests_LIBRARIES}) diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_applicationScheme.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_applicationScheme.qml index e561e1a32..d25dcb9a8 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_applicationScheme.qml +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_applicationScheme.qml @@ -70,6 +70,7 @@ TestWebView { name: "WebViewApplicationSchemes" function test_applicationScheme() { + skip("QTFIXME: application schemes are not supported yet") var testUrl = "applicationScheme://something" webView.url = testUrl verify(webView.waitForLoadSucceeded()) @@ -77,6 +78,7 @@ TestWebView { } function test_multipleSchemes() { + skip("QTFIXME: application schemes are not supported yet") // Test if we receive the right reply when defining multiple schemes. var testUrl = "scheme2://some-url-string" webView.url = testUrl @@ -90,6 +92,7 @@ TestWebView { } function test_multipleUrlsForScheme() { + skip("QTFIXME: application schemes are not supported yet") var testUrl = "scheme3://url1" webView.url = testUrl verify(webView.waitForLoadSucceeded()) @@ -103,6 +106,7 @@ TestWebView { } function test_charsets() { + skip("QTFIXME: application schemes are not supported yet") var testUrl = "schemeCharset://latin1" webView.url = testUrl verify(webView.waitForLoadSucceeded()) diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_evaluateJavaScript.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_evaluateJavaScript.qml index 720b4cd04..b4576af36 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_evaluateJavaScript.qml +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_evaluateJavaScript.qml @@ -78,7 +78,43 @@ Item { resultSpy.wait() compare(JSON.stringify(webView.lastResult), - '{"child":{"level":2},"level":"1"}') + '{"level":"1","child":{"level":2}}') + } + + function test_undefinedValue() { + resultSpy.clear() + webView.url = "about:blank" + verify(webView.waitForLoadSucceeded()) + + webView.experimental.evaluateJavaScript( + "(function() { })()", + + function(result) { + webView.lastResult = result + }) + + resultSpy.wait() + verify(typeof webView.lastResult === "undefined") + compare(webView.lastResult, undefined) + } + + function test_nullValue() { + resultSpy.clear() + + webView.url = "about:blank" + verify(webView.waitForLoadSucceeded()) + + webView.experimental.evaluateJavaScript( + "(function() { return { value: null } })()", + + function(result) { + webView.lastResult = result + }) + + resultSpy.wait() + verify(typeof webView.lastResult === "object") + verify(typeof webView.lastResult.value === "object") + compare(webView.lastResult.value, null) } function test_booleanValue() { diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_webchannel.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_webchannel.qml index e16b7866e..dfdcf7add 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_webchannel.qml +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_webchannel.qml @@ -72,7 +72,7 @@ Item { TestWebView { id: webView - experimental.windowObjects: [testObject] + experimental.webChannel.registeredObjects: [testObject] experimental.preferences.developerExtrasEnabled: true } diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/notification.html b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/notification.html index b53533eb0..e9186a4fd 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/notification.html +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/notification.html @@ -3,9 +3,9 @@ Desktop Notification Permission test