diff options
author | Konstantin Tokarev <annulen@yandex.ru> | 2017-04-24 22:40:03 +0300 |
---|---|---|
committer | Konstantin Tokarev <annulen@yandex.ru> | 2017-04-25 18:29:55 +0000 |
commit | 4bd713d56aa9bb86bc96ea9cb0c64cbf94bf43d4 (patch) | |
tree | 02bd448d49627f059df0d8036fbdb9d9ee883a50 | |
parent | bd3f57b00bee3088971209a0ebc513eb1ef4ba14 (diff) | |
download | qtwebkit-4bd713d56aa9bb86bc96ea9cb0c64cbf94bf43d4.tar.gz |
Import WebKit commit 3040e0455efecd271f1aeef53cf287e75486a70d
Change-Id: I7df106cef8ce93ce33e49ad6fb0d202cd066d87c
Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
185 files changed, 5760 insertions, 974 deletions
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 <wtf/CurrentTime.h> -#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<GraphicsLayer*>& 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<GraphicsLayer*>&); #endif void setChildren(const Vector<TextureMapperLayer*>&); 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> GraphicsLayer::create(GraphicsLayerFactory* factory, GraphicsLayerClient& client, Type layerType) { if (!factory) @@ -49,6 +50,7 @@ std::unique_ptr<GraphicsLayer> 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<Cookie>& rawCookies) @@ -138,12 +138,12 @@ void getHostnamesWithCookies(const NetworkStorageSession& session, HashSet<Strin jar->getHostnamesWithCookies(hostnames); } -void deleteCookiesForHostname(const NetworkStorageSession& session, const String& hostname) +void deleteCookiesForHostnames(const NetworkStorageSession& session, const Vector<String>& 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<WTF::String>& 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<QNetworkCookie>()); } +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<String>&); bool deleteCookie(const QNetworkCookie&) final; - void deleteCookiesForHostname(const String&); + void deleteCookiesForHostnames(const Vector<String>&); void deleteAllCookies(); + void deleteAllCookiesModifiedSince(std::chrono::system_clock::time_point); bool setCookiesFromUrl(const QList<QNetworkCookie>&, 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<char> 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<char>& data) { WebCoreSynchronousLoader syncLoader(error, response, data); diff --git a/Source/WebKit/qt/Plugins/QtX11ImageConversion.cpp b/Source/WebCore/plugins/qt/QtX11ImageConversion.cpp index 0a76fe239..0a76fe239 100644 --- a/Source/WebKit/qt/Plugins/QtX11ImageConversion.cpp +++ b/Source/WebCore/plugins/qt/QtX11ImageConversion.cpp diff --git a/Source/WebKit/qt/Plugins/QtX11ImageConversion.h b/Source/WebCore/plugins/qt/QtX11ImageConversion.h index 1a999a4ca..1a999a4ca 100644 --- a/Source/WebKit/qt/Plugins/QtX11ImageConversion.h +++ b/Source/WebCore/plugins/qt/QtX11ImageConversion.h 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 + <QtWebKit/QtWebKitDepends> + \"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 <QtCore/QtCore> @@ -586,10 +609,15 @@ ecm_generate_headers( QWebView COMMON_HEADER QtWebKitWidgets + COMMON_HEADER_EXTRAS + <QtWebKitWidgets/QtWebKitWidgetsDepends> + \"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 <QtCore/QtCore> @@ -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/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<VoidCallback> 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<ScriptExecutionContext*, CallbacksInfo >::iterator iter = m_pendingPermissionRequests.find(context); - if (iter != m_pendingPermissionRequests.end()) - iter.value().m_voidCallbacks.append(callback); - else { - RefPtr<VoidCallback> 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<NotificationPermissionCallback> 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<RefPtr<VoidCallback> >& voidCallbacks = iter.value().m_voidCallbacks; - Q_FOREACH(const RefPtr<VoidCallback>& callback, voidCallbacks) { - if (callback) - callback->handleEvent(); - } -#endif -#if ENABLE(NOTIFICATIONS) QList<RefPtr<NotificationPermissionCallback> >& callbacks = iter.value().m_callbacks; Q_FOREACH(const RefPtr<NotificationPermissionCallback>& 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 <Notification*, NotificationWrapper*> 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<VoidCallback>) override; -#endif -#if ENABLE(NOTIFICATIONS) void requestPermission(ScriptExecutionContext*, PassRefPtr<NotificationPermissionCallback>) 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<RefPtr<VoidCallback> > m_voidCallbacks; -#endif -#if ENABLE(NOTIFICATIONS) QList<RefPtr<NotificationPermissionCallback> > m_callbacks; -#endif }; QHash<ScriptExecutionContext*, CallbacksInfo > m_pendingPermissionRequests; QHash<ScriptExecutionContext*, NotificationClient::Permission> 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<QWebFullScreenRequest>(); 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<QQuickWebView*>(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 <annulen@yandex.ru> + * + * 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 <QCoreApplication> + +using namespace WebCore; + +namespace WebKit { + +Q_DECL_EXPORT int DatabaseProcessMainQt(int argc, char** argv) +{ + QCoreApplication app(argc, argv); + return ChildProcessMain<DatabaseProcess, ChildProcessMainBase>(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 <annulen@yandex.ru> + * + * 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 <wtf/Noncopyable.h> + +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 <annulen@yandex.ru> + * + * 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<DownloadAuthenticationClient> m_authenticationClient; #endif #if PLATFORM(QT) - QtFileDownloader* m_qtDownloader; + QtFileDownloader* m_qtDownloader { nullptr }; #endif #if PLATFORM(GTK) || PLATFORM(EFL) std::unique_ptr<WebCore::ResourceHandleClient> 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 <WebCore/NotImplemented.h> #include <WebCore/QNetworkReplyHandler.h> #include <WebCore/ResourceHandle.h> @@ -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 <QCoreApplication> #include <QFile> #include <QFileInfo> @@ -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<QNetworkReply> m_reply; std::unique_ptr<QFile> 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 <annulen@yandex.ru> + * + * 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 <wtf/Vector.h> #include <wtf/text/WTFString.h> -#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 <annulen@yandex.ru> + * 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 <QCoreApplication> +#include <QNetworkProxyFactory> + +using namespace WebCore; + +namespace WebKit { + +class EnvHttpProxyFactory : public QNetworkProxyFactory { +public: + EnvHttpProxyFactory() { } + + bool initializeFromEnvironment(); + + QList<QNetworkProxy> queryProxy(const QNetworkProxyQuery& = QNetworkProxyQuery()); + +private: + QList<QNetworkProxy> m_httpProxy; + QList<QNetworkProxy> 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<QNetworkProxy> 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<QNetworkProxy> proxies; + proxies << QNetworkProxy::NoProxy; + return proxies; +} + +static void initializeProxy() +{ + QList<QNetworkProxy> proxylist = QNetworkProxyFactory::systemProxyForQuery(); + if (proxylist.count() == 1) { + QNetworkProxy proxy = proxylist.first(); + if (proxy == QNetworkProxy::NoProxy || proxy == QNetworkProxy::DefaultProxy) { + auto proxyFactory = std::make_unique<EnvHttpProxyFactory>(); + 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<NetworkProcess, ChildProcessMainBase>(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 <annulen@yandex.ru> + * + * 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 <QNetworkDiskCache> +#include <WebCore/CertificateInfo.h> +#include <WebCore/CookieJarQt.h> + +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()>) +{ +} + +void NetworkProcess::platformSetCacheModel(CacheModel) +{ +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/qt/QtNetworkAccessManager.cpp b/Source/WebKit2/NetworkProcess/qt/QtNetworkAccessManager.cpp index 2251c2ed1..5e38a7717 100644 --- a/Source/WebKit2/WebProcess/qt/QtNetworkAccessManager.cpp +++ b/Source/WebKit2/NetworkProcess/qt/QtNetworkAccessManager.cpp @@ -27,8 +27,6 @@ #include "config.h" #include "QtNetworkAccessManager.h" -#include "SharedMemory.h" -#include "WebFrameNetworkingContext.h" #include "WebPage.h" #include "WebPageProxyMessages.h" #include "WebProcess.h" @@ -39,9 +37,8 @@ namespace WebKit { -QtNetworkAccessManager::QtNetworkAccessManager(WebProcess* webProcess) +QtNetworkAccessManager::QtNetworkAccessManager() : QNetworkAccessManager() - , m_webProcess(webProcess) { connect(this, SIGNAL(authenticationRequired(QNetworkReply*, QAuthenticator*)), SLOT(onAuthenticationRequired(QNetworkReply*, QAuthenticator*))); connect(this, SIGNAL(proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*)), SLOT(onProxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*))); @@ -52,6 +49,10 @@ QtNetworkAccessManager::QtNetworkAccessManager(WebProcess* webProcess) WebPage* QtNetworkAccessManager::obtainOriginatingWebPage(const QNetworkRequest& request) { + // QTFIXME: Old process model + if (!m_webProcess) + return nullptr; + QObject* originatingObject = request.originatingObject(); if (!originatingObject) return 0; @@ -60,23 +61,6 @@ WebPage* QtNetworkAccessManager::obtainOriginatingWebPage(const QNetworkRequest& return m_webProcess->webPage(pageID); } -QNetworkReply* QtNetworkAccessManager::createRequest(Operation operation, const QNetworkRequest& request, QIODevice* outData) -{ - WebPage* webPage = obtainOriginatingWebPage(request); - if (webPage && m_applicationSchemes.contains(webPage, request.url().scheme().toLower())) { - QtNetworkReply* reply = new QtNetworkReply(request, this); - webPage->receivedApplicationSchemeRequest(request, reply); - return reply; - } - - return QNetworkAccessManager::createRequest(operation, request, outData); -} - -void QtNetworkAccessManager::registerApplicationScheme(const WebPage* page, const QString& scheme) -{ - m_applicationSchemes.insert(page, scheme.toLower()); -} - void QtNetworkAccessManager::onProxyAuthenticationRequired(const QNetworkProxy& proxy, QAuthenticator* authenticator) { // FIXME: Check if there is a better way to get a reference to the page. @@ -98,7 +82,7 @@ void QtNetworkAccessManager::onProxyAuthenticationRequired(const QNetworkProxy& authenticator->setUser(username); if (!password.isEmpty()) authenticator->setPassword(password); - } + } } diff --git a/Source/WebKit2/WebProcess/qt/QtNetworkAccessManager.h b/Source/WebKit2/NetworkProcess/qt/QtNetworkAccessManager.h index 5a3934b0e..5b958f13e 100644 --- a/Source/WebKit2/WebProcess/qt/QtNetworkAccessManager.h +++ b/Source/WebKit2/NetworkProcess/qt/QtNetworkAccessManager.h @@ -40,11 +40,7 @@ class WebProcess; class QtNetworkAccessManager : public QNetworkAccessManager { Q_OBJECT public: - QtNetworkAccessManager(WebProcess*); - void registerApplicationScheme(const WebPage*, const QString& scheme); - -protected: - QNetworkReply* createRequest(Operation, const QNetworkRequest&, QIODevice* outgoingData = 0) override; + QtNetworkAccessManager(); private Q_SLOTS: void onAuthenticationRequired(QNetworkReply *, QAuthenticator *); @@ -54,9 +50,7 @@ private Q_SLOTS: private: WebPage* obtainOriginatingWebPage(const QNetworkRequest&); - QMultiHash<const WebPage*, QString> m_applicationSchemes; - WebProcess* m_webProcess; - + WebProcess* m_webProcess { nullptr }; }; } // namespace WebKit 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 <WebCore/NetworkStorageSession.h> +#include <WebCore/NotImplemented.h> +#include <WebCore/ResourceHandle.h> +#include <wtf/NeverDestroyed.h> + +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 <WebCore/AXObjectCache.h> +#include <mach/mach_error.h> +#include <mach/vm_map.h> +#include <sys/mman.h> +#include <wtf/RunLoop.h> +#include <wtf/spi/darwin/XPCSPI.h> + +#if PLATFORM(IOS) +#include "ProcessAssertion.h" +#include <UIKit/UIAccessibility.h> + +#if USE(APPLE_INTERNAL_SDK) +#include <AXRuntime/AXDefines.h> +#include <AXRuntime/AXNotificationConstants.h> +#else +#define kAXPidStatusChangedNotification 0 +#endif + +#endif + +#if PLATFORM(MAC) + +#if USE(APPLE_INTERNAL_SDK) +#include <HIServices/AccessibilityPriv.h> +#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<xpc_connection_t>& xpcConnection, double intervalInSeconds) + { + new ConnectionTerminationWatchdog(xpcConnection, intervalInSeconds); + } + +private: + ConnectionTerminationWatchdog(OSObjectPtr<xpc_connection_t>& xpcConnection, double intervalInSeconds) + : m_xpcConnection(xpcConnection) + , m_watchdogTimer(RunLoop::main(), this, &ConnectionTerminationWatchdog::watchdogTimerFired) +#if PLATFORM(IOS) + , m_assertion(std::make_unique<WebKit::ProcessAndUIAssertion>(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<xpc_connection_t> m_xpcConnection; + RunLoop::Timer<ConnectionTerminationWatchdog> m_watchdogTimer; +#if PLATFORM(IOS) + std::unique_ptr<WebKit::ProcessAndUIAssertion> 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<typename Function> +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<MessageEncoder>("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> 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<MessageEncoder>("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<MessageEncoder> encoder) +{ + Vector<Attachment> 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<mach_msg_header_t*>(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<mach_msg_body_t*>(header + 1); + body->msgh_descriptor_count = numberOfPortDescriptors + numberOfOOLMemoryDescriptors; + uint8_t* descriptorData = reinterpret_cast<uint8_t*>(body + 1); + + for (size_t i = 0; i < attachments.size(); ++i) { + Attachment attachment = attachments[i]; + + mach_msg_descriptor_t* descriptor = reinterpret_cast<mach_msg_descriptor_t*>(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<mach_msg_descriptor_t*>(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> 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<MessageDecoder> createMessageDecoder(mach_msg_header_t* header) +{ + if (!(header->msgh_bits & MACH_MSGH_BITS_COMPLEX)) { + // We have a simple message. + uint8_t* body = reinterpret_cast<uint8_t*>(header + 1); + size_t bodySize = header->msgh_size - sizeof(mach_msg_header_t); + + return std::make_unique<MessageDecoder>(DataReference(body, bodySize), Vector<Attachment>()); + } + + bool messageBodyIsOOL = header->msgh_id & MessageBodyIsOutOfLine; + + mach_msg_body_t* body = reinterpret_cast<mach_msg_body_t*>(header + 1); + mach_msg_size_t numDescriptors = body->msgh_descriptor_count; + ASSERT(numDescriptors); + + uint8_t* descriptorData = reinterpret_cast<uint8_t*>(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<Attachment> attachments(numDescriptors); + + for (mach_msg_size_t i = 0; i < numDescriptors; ++i) { + mach_msg_descriptor_t* descriptor = reinterpret_cast<mach_msg_descriptor_t*>(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<mach_msg_descriptor_t*>(descriptorData); + ASSERT(descriptor->type.type == MACH_MSG_OOL_DESCRIPTOR); + + uint8_t* messageBody = static_cast<uint8_t*>(descriptor->out_of_line.address); + size_t messageBodySize = descriptor->out_of_line.size; + + auto decoder = std::make_unique<MessageDecoder>(DataReference(messageBody, messageBodySize), WTFMove(attachments)); + + vm_deallocate(mach_task_self(), reinterpret_cast<vm_address_t>(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<uint8_t*>(header)); + + return std::make_unique<MessageDecoder>(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<char, receiveBufferSize> ReceiveBuffer; + +static mach_msg_header_t* readFromMachPort(mach_port_t machPort, ReceiveBuffer& buffer) +{ + buffer.resize(receiveBufferSize); + + mach_msg_header_t* header = reinterpret_cast<mach_msg_header_t*>(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<mach_msg_header_t*>(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<MessageDecoder> decoder = createMessageDecoder(header); + ASSERT(decoder); + +#if PLATFORM(MAC) + decoder->setImportanceAssertion(std::make_unique<ImportanceAssertion>(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<Connection> 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 <libproc_internal.h> +#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 <wtf/Functional.h> +#include <wtf/RandomNumber.h> +#include <wtf/text/WTFString.h> +#include <wtf/threads/BinarySemaphore.h> + +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<unsigned>::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<MessageDecoder> 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<MessageEncoder> 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<HWND>& 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 <wtf/Forward.h> +#include <wtf/Noncopyable.h> +#include <wtf/RetainPtr.h> + +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<LayerHostingContext> createForPort(const WebCore::MachSendRight& serverPort); +#if HAVE(OUT_OF_PROCESS_LAYER_HOSTING) + static std::unique_ptr<LayerHostingContext> 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<CAContext> 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 <WebCore/MachSendRight.h> +#import <WebCore/QuartzCoreSPI.h> +#import <WebKitSystemInterface.h> + +using namespace WebCore; + +namespace WebKit { + +std::unique_ptr<LayerHostingContext> LayerHostingContext::createForPort(const MachSendRight& serverPort) +{ + auto layerHostingContext = std::make_unique<LayerHostingContext>(); + + 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> LayerHostingContext::createForExternalHostingProcess() +{ + auto layerHostingContext = std::make_unique<LayerHostingContext>(); + 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 <rdar://problem/16089267> 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 <mach/mach_init.h> +#include <mach/task.h> + +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<mach_port_info_t>(&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 <mach/mach_port.h> + +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 <wtf/Vector.h> +#import <wtf/text/WTFString.h> + +namespace WebKit { + +#if ENABLE(TELEPHONE_NUMBER_DETECTION) && PLATFORM(MAC) +NSMenuItem *menuItemForTelephoneNumber(const String& telephoneNumber); +RetainPtr<NSMenu> 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 <WebCore/DataDetectorsSPI.h> +#import <WebCore/LocalizedStrings.h> +#import <objc/runtime.h> + +#if ENABLE(TELEPHONE_NUMBER_DETECTION) +#import <WebCore/TUCallSPI.h> +#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<DDActionContext> 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<NSMenu> menuForTelephoneNumber(const String& telephoneNumber) +{ + RetainPtr<NSMenu> menu = adoptNS([[NSMenu alloc] init]); + NSMutableArray *faceTimeItems = [NSMutableArray array]; + NSMenuItem *dialItem = nil; + + RetainPtr<DDActionContext> 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 <WebCore/MachSendRight.h> +#include <WebCore/MachVMSPI.h> +#include <mach/mach_error.h> +#include <mach/mach_port.h> +#include <mach/vm_map.h> +#include <wtf/RefPtr.h> + +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<uint64_t>(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<void*>(static_cast<uintptr_t>(address)); +} + +static inline mach_vm_address_t toVMAddress(void* pointer) +{ + return static_cast<mach_vm_address_t>(reinterpret_cast<uintptr_t>(pointer)); +} + +RefPtr<SharedMemory> 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> 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> 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> 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> 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> 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 <WebKit/WKDeclarationSpecifiers.h> +#import <wtf/Forward.h> + +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 <WebCore/SoftLinking.h> +#import <wtf/ObjcRuntimeExtras.h> +#import <wtf/text/StringBuilder.h> +#import <yarr/RegularExpression.h> + +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<CFPhoneNumberRef> 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 <wtf/RefPtr.h> + +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<uint64_t>(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 <http://webkit.org/b/47502>. + encoder << reinterpret_cast<uint64_t>(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<uint32_t>(::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<HANDLE>(sourceHandle), sourcePID, duplicatedHandle)) + return false; + + handle.m_handle = duplicatedHandle; + handle.m_size = size; + return true; +} + +PassRefPtr<SharedMemory> 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<SharedMemory> 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> SharedMemory::create(const Handle& handle, Protection protection) +{ + RefPtr<SharedMemory> 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> 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<SharedMemory> 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> 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<SharedMemory> 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 <QGuiApplication> #include <QStringList> #include <QtGlobal> -#include <WebCore/RunLoop.h> +#include <wtf/RunLoop.h> 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<void()>); 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 <WebCore/ScrollTypes.h> #include <WebCore/SessionID.h> #include <WebCore/ViewState.h> +#include <wtf/HashMap.h> #include <wtf/text/WTFString.h> #if PLATFORM(MAC) @@ -131,6 +132,8 @@ struct WebPageCreationParameters { #endif bool appleMailPaginationQuirkEnabled; bool shouldScaleViewToFitDocument; + + HashMap<String, uint64_t> 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 <annulen@yandex.ru> + * 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 <QDebug> + +#if OS(DARWIN) && !USE(UNIX_DOMAIN_SOCKETS) +#include <servers/bootstrap.h> + +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<IPC::Connection::Identifier>(id); +#else + // Convert to int + identifier = static_cast<IPC::Connection::Identifier>(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<ResourceRequest>::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<bool>(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<ResourceRequest>::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<ResourceError>::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<ResourceError>::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<CertificateInfo>::encode(ArgumentEncoder& encoder, const CertificateInfo& certificateInfo) +{ + // QTFIXME: Our CertificateInfo is a stub + notImplemented(); +} + +bool ArgumentCoder<CertificateInfo>::decode(ArgumentDecoder& decoder, CertificateInfo& certificateInfo) +{ + // QTFIXME: Our CertificateInfo is a stub + notImplemented(); + return true; +} + +void ArgumentCoder<ProtectionSpace>::encodePlatformData(ArgumentEncoder&, const ProtectionSpace&) +{ + ASSERT_NOT_REACHED(); +} + +bool ArgumentCoder<ProtectionSpace>::decodePlatformData(ArgumentDecoder&, ProtectionSpace&) +{ + ASSERT_NOT_REACHED(); + return false; +} + +void ArgumentCoder<Credential>::encodePlatformData(ArgumentEncoder&, const Credential&) +{ + ASSERT_NOT_REACHED(); +} + +bool ArgumentCoder<Credential>::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> 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<Object::Type::URLSchemeHandlerTask> { +public: + static Ref<URLSchemeHandlerTask> create(WebKit::WebURLSchemeHandlerTask&); + + WebKit::WebURLSchemeHandlerTask& task() { return m_webURLSchemeHandlerTask.get(); } + +private: + URLSchemeHandlerTask(WebKit::WebURLSchemeHandlerTask&); + + Ref<WebKit::WebURLSchemeHandlerTask> 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<const QChar*>(string.characters()), string.length()); + + auto stringView = toImpl(stringRef)->stringView(); + + if (stringView.is8Bit()) + return QString::fromLatin1(reinterpret_cast<const char*>(stringView.characters8()), stringView.length()); + + return QString(reinterpret_cast<const QChar*>(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 <WebCore/ApplicationCacheStorage.h> +#include <WebCore/FileSystem.h> + +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 <QTransform> +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 <QtCore/QFile> #include <QtQml/QJSValue> #include <QtQuick/QQuickView> +#include <WKData.h> #include <WKNumber.h> #include <WKOpenPanelResultListener.h> +#include <WKPageConfigurationRef.h> #include <WKPageGroup.h> #include <WKPreferencesRef.h> #include <WKSerializedScriptValue.h> @@ -84,7 +88,7 @@ #include <wtf/Vector.h> #include <wtf/text/WTFString.h> -#ifdef HAVE_WEBCHANNEL +#if ENABLE(QT_WEBCHANNEL) #include "qwebchannelwebkittransport_p.h" #include <QtWebChannel/QQmlWebChannel> #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<WKPageConfigurationRef> pageConfiguration; + WKContextRef contextRef = nullptr; + + if (configurationRef) { + pageConfiguration = adoptWK(configurationRef); + contextRef = WKPageConfigurationGetContext(configurationRef); + context = QtWebContext::create(contextRef); + } else { + pageConfiguration = adoptWK(WKPageConfigurationCreate()); + WKRetainPtr<WKPageGroupRef> 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<DrawingAreaProxy> QQuickWebViewPrivate::createDrawingAreaProxy() { - return std::make_unique<WebKit::DrawingAreaProxyImpl>(*webPageProxy.get()); + return std::make_unique<WebKit::CoordinatedDrawingAreaProxy>(*webPageProxy.get()); } void QQuickWebViewPrivate::handleDownloadRequest(DownloadProxy* download) @@ -874,11 +891,11 @@ void QQuickWebViewPrivate::setNavigatorQtObjectEnabled(bool enabled) WKPagePostMessageToInjectedBundle(webPage.get(), messageName, wkEnabled.get()); } -static WKRetainPtr<WKStringRef> readUserFile(const QUrl& url, const char* userFileType) +static WTF::Optional<String> 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<WKStringRef> 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<WKStringRef> 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<WKStringRef> 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<QQuickUrlSchemeDelegate> 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<const char*>(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<CoordinatedDrawingAreaProxy*>(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<CoordinatedDrawingAreaProxy*>(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<WKStringRef> contents = adoptWK(WKStringCreateWithUTF8CString(message.constData())); + // TODO: API::Data::createWithoutCopying may help to avoid copy + WKRetainPtr<WKDataRef> contents = adoptWK(WKDataCreate(reinterpret_cast<const unsigned char*>(message.data()), message.size())); WKPagePostMessageToInjectedBundle(d->webPage.get(), messageName, contents.get()); } #endif @@ -1585,7 +1613,7 @@ void QQuickWebViewExperimental::schemeDelegates_Append(QQmlListProperty<QQuickUr return; scheme->reply()->setWebViewExperimental(webViewExperimental); QQuickWebViewPrivate* d = webViewExperimental->d_func(); - d->webPageProxy->registerApplicationScheme(scheme->scheme()); + //d->webPageProxy->registerApplicationScheme(scheme->scheme()); } int QQuickWebViewExperimental::schemeDelegates_Count(QQmlListProperty<QQuickUrlSchemeDelegate>* property) @@ -1640,7 +1668,7 @@ void QQuickWebViewExperimental::invokeApplicationSchemeHandler(PassRefPtr<QtRefC void QQuickWebViewExperimental::sendApplicationSchemeReply(QQuickNetworkReply* reply) { - d_ptr->webPageProxy->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 T> 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<QUrl> userScripts READ userScripts WRITE setUserScripts NOTIFY userScriptsChanged) Q_PROPERTY(QList<QUrl> 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<WebKit::WebPageProxy> webPageProxy; WKRetainPtr<WKPageRef> webPage; - WKRetainPtr<WKPageGroupRef> 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 <QtWebChannel/QWebChannelAbstractTransport> 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 <WKPageConfigurationRef.h> #include <WKPageGroup.h> #include <WKPreferencesRef.h> #include <WKRetainPtr.h> @@ -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<WKStringRef> 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<uint32_t>(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<unsigned>(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 @@ <title>Desktop Notification Permission test</title> <script> requestPermission = function(cb) { - window.webkitNotifications.requestPermission(function() { + window.Notification.requestPermission(function() { if (cb) - cb(window.webkitNotifications.checkPermission() == 0); + cb(window.Notification.permission); }); } requestPermission() diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/tst_qmltests.cpp b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/tst_qmltests.cpp index ab57556bd..e681daa0d 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/tst_qmltests.cpp +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/tst_qmltests.cpp @@ -21,7 +21,6 @@ #include "../util.h" #include "private/qquickwebview_p.h" -#include <QGuiApplication> #include <QVarLengthArray> #include <QtQuickTest/quicktest.h> @@ -40,9 +39,6 @@ int main(int argc, char** argv) suppressDebugOutput(); addQtWebProcessToPath(); - // Instantiate QApplication to prevent quick_test_main to instantiate a QGuiApplication. - // This can be removed as soon as we do not use QtWidgets any more. - QGuiApplication app(argc, argv); qmlRegisterType<ByteArrayTestData>("Test", 1, 0, "ByteArrayTestData"); #ifdef DISABLE_FLICKABLE_VIEWPORT diff --git a/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.cpp b/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.cpp index de1f0af8e..ddef49d05 100644 --- a/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.cpp +++ b/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.cpp @@ -72,6 +72,15 @@ void CoordinatedLayerTreeHostProxy::commitCoordinatedGraphicsState(const Coordin void CoordinatedLayerTreeHostProxy::setVisibleContentsRect(const FloatRect& rect, const FloatPoint& trajectoryVector) { +#if PLATFORM(QT) + // Inform the renderer to adjust viewport-fixed layers. + RefPtr<CoordinatedGraphicsScene> sceneProtector(m_scene); + const FloatPoint& scrollPosition = rect.location(); + dispatchUpdate([=] { + sceneProtector->setScrollPosition(scrollPosition); + }); +#endif + if (rect == m_lastSentVisibleRect && trajectoryVector == m_lastSentTrajectoryVector) return; diff --git a/Source/WebKit2/UIProcess/CoordinatedGraphics/PageViewportController.cpp b/Source/WebKit2/UIProcess/CoordinatedGraphics/PageViewportController.cpp index 63badacc3..1e4859c4a 100644 --- a/Source/WebKit2/UIProcess/CoordinatedGraphics/PageViewportController.cpp +++ b/Source/WebKit2/UIProcess/CoordinatedGraphics/PageViewportController.cpp @@ -251,6 +251,12 @@ void PageViewportController::didChangeViewportSize(const FloatSize& newSize) return; m_viewportSize = newSize; + +#if PLATFORM(QT) + // Let the WebProcess know about the new viewport size, so that + // it can resize the content accordingly. + m_webPageProxy->drawingArea()->setSize(roundedIntSize(newSize), IntSize(), IntSize()); +#endif } void PageViewportController::didChangeContentsVisibility(const FloatPoint& position, float scale, const FloatPoint& trajectoryVector) diff --git a/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp b/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp index 6418ce9ec..499faf1bc 100644 --- a/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp +++ b/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp @@ -236,11 +236,11 @@ void DownloadProxy::didCancel(const IPC::DataReference& resumeData) #if PLATFORM(QT) void DownloadProxy::startTransfer(const String& filename) { - if (!m_webContext) + if (!m_processPool) return; - // FIXME (Multi-WebProcess): <rdar://problem/12239483> Downloads shouldn't be handled in the web process. - m_webContext->sendToAllProcesses(Messages::WebProcess::StartTransfer(m_downloadID, filename)); + if (NetworkProcessProxy* networkProcess = m_processPool->networkProcess()) + networkProcess->connection()->send(Messages::NetworkProcess::StartTransfer(m_downloadID, filename), 0); } #endif diff --git a/Source/WebKit2/UIProcess/InspectorServer/qt/WebInspectorServerQt.cpp b/Source/WebKit2/UIProcess/InspectorServer/qt/WebInspectorServerQt.cpp index 317508b76..73a0c2664 100644 --- a/Source/WebKit2/UIProcess/InspectorServer/qt/WebInspectorServerQt.cpp +++ b/Source/WebKit2/UIProcess/InspectorServer/qt/WebInspectorServerQt.cpp @@ -36,7 +36,7 @@ namespace WebKit { static String remoteInspectorPagePath() { - static NeverDestroyed<WTF::String> pagePath(ASCIILiteral("/webkit/inspector/inspector.html?page=")); + static NeverDestroyed<WTF::String> pagePath(ASCIILiteral("/webkit/inspector/UserInterface/Main.html?page=")); return pagePath; } diff --git a/Source/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp b/Source/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp index 84cb7ea0b..6b6bcf5c6 100644 --- a/Source/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp +++ b/Source/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp @@ -117,14 +117,20 @@ void ProcessLauncher::launchProcess() commandLine = QLatin1String("%1 \"%2\" %3"); QByteArray webProcessPrefix = qgetenv("QT_WEBKIT2_WP_CMD_PREFIX"); commandLine = commandLine.arg(QLatin1String(webProcessPrefix.constData())).arg(QString(executablePathOfWebProcess())); + } else if (m_launchOptions.processType == ProcessType::Network) { + commandLine = QLatin1String("%1 \"%2\" %3"); + QByteArray networkProcessPrefix = qgetenv("QT_WEBKIT2_NP_CMD_PREFIX"); + commandLine = commandLine.arg(QLatin1String(networkProcessPrefix.constData())).arg(QString(executablePathOfNetworkProcess())); #if ENABLE(PLUGIN_PROCESS) - } else if (m_launchOptions.processType == PluginProcess) { + } else if (m_launchOptions.processType == ProcessType::Plugin32 || m_launchOptions.processType == ProcessType::Plugin64) { commandLine = QLatin1String("%1 \"%2\" %3 %4"); QByteArray pluginProcessPrefix = qgetenv("QT_WEBKIT2_PP_CMD_PREFIX"); commandLine = commandLine.arg(QLatin1String(pluginProcessPrefix.constData())).arg(QString(executablePathOfPluginProcess())); #endif - } else + } else { + qDebug() << "Unsupported process type" << (int)m_launchOptions.processType; ASSERT_NOT_REACHED(); + } #if OS(DARWIN) // Create the listening port. @@ -173,7 +179,7 @@ void ProcessLauncher::launchProcess() #endif #if ENABLE(PLUGIN_PROCESS) - if (m_launchOptions.processType == PluginProcess) + if (m_launchOptions.processType == ProcessType::Plugin32 || m_launchOptions.processType == ProcessType::Plugin64) commandLine = commandLine.arg(QString(m_launchOptions.extraInitializationData.get("plugin-path"))); #endif diff --git a/Source/WebKit2/UIProcess/Network/CustomProtocols/qt/CustomProtocolManagerProxyQt.cpp b/Source/WebKit2/UIProcess/Network/CustomProtocols/qt/CustomProtocolManagerProxyQt.cpp new file mode 100644 index 000000000..33fa5474c --- /dev/null +++ b/Source/WebKit2/UIProcess/Network/CustomProtocols/qt/CustomProtocolManagerProxyQt.cpp @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2017 Konstantin Tokarev <annulen@yandex.ru> + * + * 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 "CustomProtocolManagerProxy.h" + +namespace WebKit { + +CustomProtocolManagerProxy::CustomProtocolManagerProxy(ChildProcessProxy* childProcessProxy, WebProcessPool& processPool) + : m_childProcessProxy(childProcessProxy) + , m_processPool(processPool) +{ +} + +CustomProtocolManagerProxy::~CustomProtocolManagerProxy() +{ +} + +void CustomProtocolManagerProxy::startLoading(uint64_t customProtocolID, const WebCore::ResourceRequest& request) +{ + ASSERT_NOT_REACHED(); +} + +void CustomProtocolManagerProxy::stopLoading(uint64_t customProtocolID) +{ +} + +} // namespace WebKit diff --git a/Source/WebKit2/UIProcess/Plugins/qt/PluginProcessProxyQt.cpp b/Source/WebKit2/UIProcess/Plugins/qt/PluginProcessProxyQt.cpp index c5337b3f9..ff5ed76de 100644 --- a/Source/WebKit2/UIProcess/Plugins/qt/PluginProcessProxyQt.cpp +++ b/Source/WebKit2/UIProcess/Plugins/qt/PluginProcessProxyQt.cpp @@ -44,8 +44,6 @@ #include <QStringBuilder> #include <QVariant> #include <WebCore/FileSystem.h> -#include <wtf/OwnPtr.h> -#include <wtf/PassOwnPtr.h> namespace WebKit { @@ -53,6 +51,7 @@ struct PluginProcessCreationParameters; void PluginProcessProxy::platformGetLaunchOptions(ProcessLauncher::LaunchOptions& launchOptions, const PluginProcessAttributes& pluginProcessAttributes) { + launchOptions.processType = ProcessLauncher::ProcessType::Plugin64; launchOptions.extraInitializationData.add("plugin-path", pluginProcessAttributes.moduleInfo.path); } @@ -60,23 +59,25 @@ void PluginProcessProxy::platformInitializePluginProcess(PluginProcessCreationPa { } -static PassOwnPtr<QFile> cacheFile() +#if PLUGIN_ARCHITECTURE(X11) + +static std::unique_ptr<QFile> cacheFile() { QString cachePath = QStandardPaths::writableLocation(QStandardPaths::CacheLocation); if (cachePath.isEmpty()) - return PassOwnPtr<QFile>(); + return std::make_unique<QFile>(); // This should match the path set through WKContextSetDiskCacheDirectory. cachePath.append(QDir::separator()).append(QStringLiteral(".QtWebKit")).append(QDir::separator()); QString cacheFilePath = cachePath % QStringLiteral("plugin_meta_data.json"); QDir::root().mkpath(cachePath); - return adoptPtr(new QFile(cacheFilePath)); + return std::make_unique<QFile>(cacheFilePath); } static void removeCacheFile() { - if (OwnPtr<QFile> file = cacheFile()) + if (auto file = cacheFile()) file->remove(); } @@ -90,7 +91,7 @@ struct ReadResult { static ReadResult::Tag readMetaDataFromCacheFile(QJsonDocument& result) { - OwnPtr<QFile> file = cacheFile(); + auto file = cacheFile(); if (!file || !file->open(QFile::ReadOnly)) return ReadResult::Empty; QByteArray data = file->readAll(); @@ -110,7 +111,7 @@ static ReadResult::Tag readMetaDataFromCacheFile(QJsonDocument& result) static void writeToCacheFile(const QJsonArray& array) { - OwnPtr<QFile> file = cacheFile(); + auto file = cacheFile(); if (file && file->open(QFile::WriteOnly | QFile::Truncate)) // Don't care about write error here. We will detect it later. file->write(QJsonDocument(array).toJson()); @@ -168,7 +169,7 @@ static MetaDataResult::Tag tryReadPluginMetaDataFromCacheFile(const QString& can return MetaDataResult::NotAvailable; } - if (object.contains(QLatin1String("unloadable"))) + if (object.contains(QStringLiteral("unloadable"))) return MetaDataResult::Unloadable; // Match. @@ -213,11 +214,8 @@ bool PluginProcessProxy::scanPlugin(const String& pluginPath, RawPluginMetaData& && process.exitCode() == EXIT_SUCCESS; if (ranSuccessfully) { QByteArray outputBytes = process.readAll(); - ASSERT(!(outputBytes.size() % sizeof(UChar))); - - String output(reinterpret_cast<const UChar*>(outputBytes.constData()), outputBytes.size() / sizeof(UChar)); Vector<String> lines; - output.split(UChar('\n'), true, lines); + String::fromUTF8(outputBytes.data(), outputBytes.size()).split('\n', true, lines); ASSERT(lines.size() == 4 && lines.last().isEmpty()); result.name.swap(lines[0]); @@ -246,6 +244,8 @@ bool PluginProcessProxy::scanPlugin(const String& pluginPath, RawPluginMetaData& return true; } +#endif // PLUGIN_ARCHITECTURE(X11) + } // namespace WebKit #endif // ENABLE(PLUGIN_PROCESS) diff --git a/Source/WebKit2/UIProcess/WebPageProxy.cpp b/Source/WebKit2/UIProcess/WebPageProxy.cpp index 9b2033f32..3bb4a0134 100644 --- a/Source/WebKit2/UIProcess/WebPageProxy.cpp +++ b/Source/WebKit2/UIProcess/WebPageProxy.cpp @@ -103,6 +103,7 @@ #include "WebProcessPool.h" #include "WebProcessProxy.h" #include "WebProtectionSpace.h" +#include "WebURLSchemeHandler.h" #include "WebUserContentControllerProxy.h" #include "WebsiteDataStore.h" #include <WebCore/BitmapImage.h> @@ -179,6 +180,27 @@ #define MESSAGE_CHECK(assertion) MESSAGE_CHECK_BASE(assertion, m_process->connection()) #define MESSAGE_CHECK_URL(url) MESSAGE_CHECK_BASE(m_process->checkURLReceivedFromWebProcess(url), m_process->connection()) +// Instead of URLParser class added later +namespace URLParser +{ +static WTF::Optional<String> maybeCanonicalizeScheme(const String& scheme) +{ + if (scheme.isEmpty()) + return WTF::Nullopt; + + if (!isASCIIAlpha(scheme[0])) + return WTF::Nullopt; + + for (size_t i = 1; i < scheme.length(); ++i) { + if (isASCIIAlphanumeric(scheme[i]) || scheme[i] == '+' || scheme[i] == '-' || scheme[i] == '.') + continue; + return WTF::Nullopt; + } + + return scheme.convertToASCIILowercase(); +} +} + using namespace WebCore; // Represents the number of wheel events we can hold in the queue before we start pushing them preemptively. @@ -500,7 +522,9 @@ WebPageProxy::WebPageProxy(PageClient& pageClient, WebProcessProxy& process, uin WebPageProxy::~WebPageProxy() { - ASSERT(m_process->webPage(m_pageID) != this); + // QtWebPageSGNode may be the last owner of WebPageProxy, but it is destroyed + // in the renderer thread which causes assertion failure when accessing globalPageMap + ASSERT(!RunLoop::isMain() || m_process->webPage(m_pageID) != this); #if !ASSERT_DISABLED for (WebPageProxy* page : m_process->pages()) ASSERT(page != this); @@ -5264,6 +5288,9 @@ WebPageCreationParameters WebPageProxy::creationParameters() #endif parameters.shouldScaleViewToFitDocument = m_shouldScaleViewToFitDocument; + for (auto& iterator : m_urlSchemeHandlersByScheme) + parameters.urlSchemeHandlers.set(iterator.key, iterator.value->identifier()); + return parameters; } @@ -6240,4 +6267,41 @@ void WebPageProxy::didRestoreScrollPosition() m_pageClient.didRestoreScrollPosition(); } +void WebPageProxy::setURLSchemeHandlerForScheme(Ref<WebURLSchemeHandler>&& handler, const String& scheme) +{ + auto canonicalizedScheme = URLParser::maybeCanonicalizeScheme(scheme); + ASSERT(canonicalizedScheme); +// ASSERT(!URLParser::isSpecialScheme(canonicalizedScheme.value())); + + auto schemeResult = m_urlSchemeHandlersByScheme.add(canonicalizedScheme.value(), handler.ptr()); + ASSERT_UNUSED(schemeResult, schemeResult.isNewEntry); + + auto identifier = handler->identifier(); + auto identifierResult = m_urlSchemeHandlersByIdentifier.add(identifier, WTFMove(handler)); + ASSERT_UNUSED(identifierResult, identifierResult.isNewEntry); + + m_process->send(Messages::WebPage::RegisterURLSchemeHandler(identifier, canonicalizedScheme.value()), m_pageID); +} + +WebURLSchemeHandler* WebPageProxy::urlSchemeHandlerForScheme(const String& scheme) +{ + return m_urlSchemeHandlersByScheme.get(scheme); +} + +void WebPageProxy::startURLSchemeHandlerTask(uint64_t handlerIdentifier, uint64_t resourceIdentifier, const WebCore::ResourceRequest& request) +{ + auto iterator = m_urlSchemeHandlersByIdentifier.find(handlerIdentifier); + ASSERT(iterator != m_urlSchemeHandlersByIdentifier.end()); + + iterator->value->startTask(*this, resourceIdentifier, request); +} + +void WebPageProxy::stopURLSchemeHandlerTask(uint64_t handlerIdentifier, uint64_t resourceIdentifier) +{ + auto iterator = m_urlSchemeHandlersByIdentifier.find(handlerIdentifier); + ASSERT(iterator != m_urlSchemeHandlersByIdentifier.end()); + + iterator->value->stopTask(*this, resourceIdentifier); +} + } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/WebPageProxy.h b/Source/WebKit2/UIProcess/WebPageProxy.h index a404e8664..6b39475e2 100644 --- a/Source/WebKit2/UIProcess/WebPageProxy.h +++ b/Source/WebKit2/UIProcess/WebPageProxy.h @@ -209,6 +209,7 @@ class WebFullScreenManagerProxy; class WebNavigationState; class WebVideoFullscreenManagerProxy; class WebKeyboardEvent; +class WebURLSchemeHandler; class WebMouseEvent; class WebOpenPanelResultListenerProxy; class WebPageGroup; @@ -546,9 +547,6 @@ public: void commitPageTransitionViewport(); #endif #if PLATFORM(QT) - void registerApplicationScheme(const String& scheme); - void resolveApplicationSchemeRequest(QtNetworkRequestData); - void sendApplicationSchemeReply(const QQuickNetworkReply*); void authenticationRequiredRequest(const String& hostname, const String& realm, const String& prefilledUsername, String& username, String& password); void certificateVerificationRequest(const String& hostname, bool& ignoreErrors); void proxyAuthenticationRequiredRequest(const String& hostname, uint16_t port, const String& prefilledUsername, String& username, String& password); @@ -1121,6 +1119,9 @@ public: void didRestoreScrollPosition(); + void setURLSchemeHandlerForScheme(Ref<WebURLSchemeHandler>&&, const String& scheme); + WebURLSchemeHandler* urlSchemeHandlerForScheme(const String& scheme); + private: WebPageProxy(PageClient&, WebProcessProxy&, uint64_t pageID, Ref<API::PageConfiguration>&&); void platformInitialize(); @@ -1516,6 +1517,9 @@ private: #endif #endif + void startURLSchemeHandlerTask(uint64_t handlerIdentifier, uint64_t resourceIdentifier, const WebCore::ResourceRequest&); + void stopURLSchemeHandlerTask(uint64_t handlerIdentifier, uint64_t resourceIdentifier); + void handleAutoFillButtonClick(const UserData&); void finishInitializingWebPageAfterProcessLaunch(); @@ -1846,6 +1850,9 @@ private: bool m_hasDeferredStartAssistingNode { false }; std::unique_ptr<NodeAssistanceArguments> m_deferredNodeAssistanceArguments; #endif + + HashMap<String, RefPtr<WebURLSchemeHandler>> m_urlSchemeHandlersByScheme; + HashMap<uint64_t, RefPtr<WebURLSchemeHandler>> m_urlSchemeHandlersByIdentifier; }; } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/WebPageProxy.messages.in b/Source/WebKit2/UIProcess/WebPageProxy.messages.in index fd205c52d..a4fc7c4bb 100644 --- a/Source/WebKit2/UIProcess/WebPageProxy.messages.in +++ b/Source/WebKit2/UIProcess/WebPageProxy.messages.in @@ -147,10 +147,6 @@ messages -> WebPageProxy { FrameDidBecomeFrameSet(uint64_t frameID, bool value) -#if PLATFORM(QT) - ResolveApplicationSchemeRequest(struct WebKit::QtNetworkRequestData request) -#endif - # History client messages. DidNavigateWithNavigationData(struct WebKit::WebNavigationDataStore store, uint64_t frameID) DidPerformClientRedirect(String sourceURLString, String destinationURLString, uint64_t frameID) @@ -468,4 +464,7 @@ messages -> WebPageProxy { #if PLATFORM(MAC) DidHandleAcceptedCandidate() #endif + + StartURLSchemeHandlerTask(uint64_t loaderIdentifier, uint64_t resourceIdentifier, WebCore::ResourceRequest request) + StopURLSchemeHandlerTask(uint64_t loaderIdentifier, uint64_t resourceIdentifier) } diff --git a/Source/WebKit2/UIProcess/WebURLSchemeHandler.cpp b/Source/WebKit2/UIProcess/WebURLSchemeHandler.cpp new file mode 100644 index 000000000..939599d2b --- /dev/null +++ b/Source/WebKit2/UIProcess/WebURLSchemeHandler.cpp @@ -0,0 +1,72 @@ +/* + * 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 "WebURLSchemeHandler.h" + +#include "WebURLSchemeHandlerTask.h" + +using namespace WebCore; + +namespace WebKit { + +static uint64_t generateWebURLSchemeHandlerIdentifier() +{ + static uint64_t nextIdentifier = 1; + return nextIdentifier++; +} + +WebURLSchemeHandler::WebURLSchemeHandler() + : m_identifier(generateWebURLSchemeHandlerIdentifier()) +{ +} + +WebURLSchemeHandler::~WebURLSchemeHandler() +{ + ASSERT(m_tasks.isEmpty()); +} + +void WebURLSchemeHandler::startTask(WebPageProxy& page, uint64_t resourceIdentifier, const ResourceRequest& request) +{ + auto result = m_tasks.add(resourceIdentifier, WebURLSchemeHandlerTask::create(*this, page, resourceIdentifier, request)); + ASSERT(result.isNewEntry); + + platformStartTask(page, *result.iterator->value); +} + +void WebURLSchemeHandler::stopTask(WebPageProxy& page, uint64_t resourceIdentifier) +{ + auto iterator = m_tasks.find(resourceIdentifier); + if (iterator == m_tasks.end()) + return; + + iterator->value->stop(); + + platformStopTask(page, *iterator->value); + + m_tasks.remove(iterator); +} + +} // namespace WebKit diff --git a/Source/WebKit2/UIProcess/WebURLSchemeHandler.h b/Source/WebKit2/UIProcess/WebURLSchemeHandler.h new file mode 100644 index 000000000..091d4a000 --- /dev/null +++ b/Source/WebKit2/UIProcess/WebURLSchemeHandler.h @@ -0,0 +1,64 @@ +/* + * 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 "WebURLSchemeHandlerTask.h" +#include <wtf/HashMap.h> +#include <wtf/RefCounted.h> +#include <wtf/RefPtr.h> + +namespace WebCore { +class ResourceRequest; +} + +namespace WebKit { + +class WebPageProxy; + +class WebURLSchemeHandler : public RefCounted<WebURLSchemeHandler> { + WTF_MAKE_NONCOPYABLE(WebURLSchemeHandler); +public: + virtual ~WebURLSchemeHandler(); + + uint64_t identifier() const { return m_identifier; } + + void startTask(WebPageProxy&, uint64_t resourceIdentifier, const WebCore::ResourceRequest&); + void stopTask(WebPageProxy&, uint64_t resourceIdentifier); + +protected: + WebURLSchemeHandler(); + +private: + virtual void platformStartTask(WebPageProxy&, WebURLSchemeHandlerTask&) = 0; + virtual void platformStopTask(WebPageProxy&, WebURLSchemeHandlerTask&) = 0; + + uint64_t m_identifier; + + HashMap<uint64_t, RefPtr<WebURLSchemeHandlerTask>> m_tasks; + +}; // class WebURLSchemeHandler + +} // namespace WebKit diff --git a/Source/WebKit2/UIProcess/WebURLSchemeHandlerTask.cpp b/Source/WebKit2/UIProcess/WebURLSchemeHandlerTask.cpp new file mode 100644 index 000000000..120ab3f95 --- /dev/null +++ b/Source/WebKit2/UIProcess/WebURLSchemeHandlerTask.cpp @@ -0,0 +1,112 @@ +/* + * 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 "WebURLSchemeHandlerTask.h" + +#include "DataReference.h" +#include "WebPageMessages.h" +#include "WebPageProxy.h" +#include "WebURLSchemeHandler.h" + +using namespace WebCore; + +namespace WebKit { + +Ref<WebURLSchemeHandlerTask> WebURLSchemeHandlerTask::create(WebURLSchemeHandler& handler, WebPageProxy& page, uint64_t resourceIdentifier, const ResourceRequest& request) +{ + return adoptRef(*new WebURLSchemeHandlerTask(handler, page, resourceIdentifier, request)); +} + +WebURLSchemeHandlerTask::WebURLSchemeHandlerTask(WebURLSchemeHandler& handler, WebPageProxy& page, uint64_t resourceIdentifier, const ResourceRequest& request) + : m_urlSchemeHandler(handler) + , m_page(&page) + , m_identifier(resourceIdentifier) + , m_request(request) +{ +} + +WebURLSchemeHandlerTask::ExceptionType WebURLSchemeHandlerTask::didReceiveResponse(const ResourceResponse& response) +{ + if (m_stopped) + return WebURLSchemeHandlerTask::ExceptionType::TaskAlreadyStopped; + + if (m_completed) + return WebURLSchemeHandlerTask::ExceptionType::CompleteAlreadyCalled; + + if (m_dataSent) + return WebURLSchemeHandlerTask::ExceptionType::DataAlreadySent; + + m_responseSent = true; + m_page->send(Messages::WebPage::URLSchemeHandlerTaskDidReceiveResponse(m_urlSchemeHandler->identifier(), m_identifier, response)); + return WebURLSchemeHandlerTask::ExceptionType::None; +} + +WebURLSchemeHandlerTask::ExceptionType WebURLSchemeHandlerTask::didReceiveData(Ref<SharedBuffer> buffer) +{ + if (m_stopped) + return WebURLSchemeHandlerTask::ExceptionType::TaskAlreadyStopped; + + if (m_completed) + return WebURLSchemeHandlerTask::ExceptionType::CompleteAlreadyCalled; + + if (!m_responseSent) + return WebURLSchemeHandlerTask::ExceptionType::NoResponseSent; + + m_dataSent = true; + m_page->send(Messages::WebPage::URLSchemeHandlerTaskDidReceiveData(m_urlSchemeHandler->identifier(), m_identifier, IPC::SharedBufferDataReference(buffer.ptr()))); + return WebURLSchemeHandlerTask::ExceptionType::None; +} + +WebURLSchemeHandlerTask::ExceptionType WebURLSchemeHandlerTask::didComplete(const ResourceError& error) +{ + if (m_stopped) + return WebURLSchemeHandlerTask::ExceptionType::TaskAlreadyStopped; + + if (m_completed) + return WebURLSchemeHandlerTask::ExceptionType::CompleteAlreadyCalled; + + if (!m_responseSent && error.isNull()) + return WebURLSchemeHandlerTask::ExceptionType::NoResponseSent; + + m_completed = true; + m_page->send(Messages::WebPage::URLSchemeHandlerTaskDidComplete(m_urlSchemeHandler->identifier(), m_identifier, error)); + return WebURLSchemeHandlerTask::ExceptionType::None; +} + +void WebURLSchemeHandlerTask::pageDestroyed() +{ + ASSERT(m_page); + m_page = nullptr; + m_stopped = true; +} + +void WebURLSchemeHandlerTask::stop() +{ + ASSERT(!m_stopped); + m_stopped = true; +} + +} // namespace WebKit diff --git a/Source/WebKit2/UIProcess/WebURLSchemeHandlerTask.h b/Source/WebKit2/UIProcess/WebURLSchemeHandlerTask.h new file mode 100644 index 000000000..77db32d95 --- /dev/null +++ b/Source/WebKit2/UIProcess/WebURLSchemeHandlerTask.h @@ -0,0 +1,79 @@ +/* + * 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 <WebCore/ResourceRequest.h> +#include <wtf/RefCounted.h> +#include <wtf/RefPtr.h> + +namespace WebCore { +class ResourceError; +class ResourceResponse; +class SharedBuffer; +} + +namespace WebKit { + +class WebURLSchemeHandler; +class WebPageProxy; + +class WebURLSchemeHandlerTask : public RefCounted<WebURLSchemeHandlerTask> { + WTF_MAKE_NONCOPYABLE(WebURLSchemeHandlerTask); +public: + static Ref<WebURLSchemeHandlerTask> create(WebURLSchemeHandler&, WebPageProxy&, uint64_t identifier, const WebCore::ResourceRequest&); + + uint64_t identifier() const { return m_identifier; } + + const WebCore::ResourceRequest& request() const { return m_request; } + + enum class ExceptionType { + DataAlreadySent, + CompleteAlreadyCalled, + TaskAlreadyStopped, + NoResponseSent, + None, + }; + ExceptionType didReceiveResponse(const WebCore::ResourceResponse&); + ExceptionType didReceiveData(Ref<WebCore::SharedBuffer>); + ExceptionType didComplete(const WebCore::ResourceError&); + + void stop(); + void pageDestroyed(); + +private: + WebURLSchemeHandlerTask(WebURLSchemeHandler&, WebPageProxy&, uint64_t identifier, const WebCore::ResourceRequest&); + + Ref<WebURLSchemeHandler> m_urlSchemeHandler; + WebPageProxy* m_page; + uint64_t m_identifier; + WebCore::ResourceRequest m_request; + bool m_stopped { false }; + bool m_responseSent { false }; + bool m_dataSent { false }; + bool m_completed { false }; +}; + +} // namespace WebKit diff --git a/Source/WebKit2/UIProcess/qt/PageViewportControllerClientQt.cpp b/Source/WebKit2/UIProcess/qt/PageViewportControllerClientQt.cpp index 0dbaa651e..adac7bb80 100644 --- a/Source/WebKit2/UIProcess/qt/PageViewportControllerClientQt.cpp +++ b/Source/WebKit2/UIProcess/qt/PageViewportControllerClientQt.cpp @@ -41,7 +41,8 @@ namespace WebKit { static const int kScaleAnimationDurationMillis = 250; PageViewportControllerClientQt::PageViewportControllerClientQt(QQuickWebView* viewportItem, QQuickWebPage* pageItem) - : m_viewportItem(viewportItem) + : m_controller(nullptr) + , m_viewportItem(viewportItem) , m_pageItem(pageItem) , m_scaleChange(this) , m_scrollChange(this) diff --git a/Source/WebKit2/UIProcess/qt/PageViewportControllerClientQt.h b/Source/WebKit2/UIProcess/qt/PageViewportControllerClientQt.h index 805fe7e40..f1b8afd15 100644 --- a/Source/WebKit2/UIProcess/qt/PageViewportControllerClientQt.h +++ b/Source/WebKit2/UIProcess/qt/PageViewportControllerClientQt.h @@ -54,7 +54,7 @@ public: void didChangeVisibleContents() final; void didChangeViewportAttributes() final; - virtual void setController(PageViewportController* controller) { m_controller = controller; } + void setController(PageViewportController* controller) { m_controller = controller; } // Additional methods currently only relevant in the QQuick context. void touchBegin(); diff --git a/Source/WebKit2/UIProcess/qt/QrcSchemeHandler.cpp b/Source/WebKit2/UIProcess/qt/QrcSchemeHandler.cpp new file mode 100644 index 000000000..9b07e3e32 --- /dev/null +++ b/Source/WebKit2/UIProcess/qt/QrcSchemeHandler.cpp @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2017 Konstantin Tokarev <annulen@yandex.ru> + * + * 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 "QrcSchemeHandler.h" + +#include <QCoreApplication> +#include <QFile> +#include <QFileInfo> +#include <QMimeDatabase> +#include <QNetworkReply> +#include <WebCore/ResourceError.h> +#include <WebCore/ResourceResponse.h> +#include <WebCore/SharedBuffer.h> + +using namespace WebCore; + +namespace WebKit { + +Ref<QrcSchemeHandler> QrcSchemeHandler::create() +{ + return adoptRef(*new QrcSchemeHandler()); +} + +static void sendResponse(WebURLSchemeHandlerTask& task, const QString& fileName, const QByteArray& fileData) +{ + QMimeDatabase mimeDb; + QMimeType mimeType = mimeDb.mimeTypeForFileNameAndData(fileName, fileData); + + WebCore::ResourceResponse response(task.request().url(), mimeType.name(), fileData.size(), String()); + auto result = task.didReceiveResponse(response); + ASSERT_UNUSED(result, result == WebURLSchemeHandlerTask::ExceptionType::None); +} + +static void sendError(WebURLSchemeHandlerTask& task) +{ + // QTFIXME: Move error templates to ErrorsQt + WebCore::ResourceError error("QtNetwork", QNetworkReply::ContentNotFoundError, task.request().url(), + QCoreApplication::translate("QWebFrame", "File does not exist")); + + auto result = task.didComplete(error); + ASSERT_UNUSED(result, result == WebURLSchemeHandlerTask::ExceptionType::None); +} + +void QrcSchemeHandler::platformStartTask(WebPageProxy& page, WebURLSchemeHandlerTask& task) +{ + QString fileName = ':' + QString(task.request().url().path()); + QByteArray fileData; + + { + QFile file(fileName); + QFileInfo fileInfo(file); + if (fileInfo.isDir() || !file.open(QIODevice::ReadOnly | QIODevice::Unbuffered)) { + sendError(task); + return; + } + fileData = file.readAll(); + } + + sendResponse(task, fileName, fileData); + + // TODO: Wrap SharedBuffer around QByteArray when it's possible + auto result = task.didReceiveData(*SharedBuffer::create(fileData.data(), fileData.size())); + ASSERT_UNUSED(result, result == WebURLSchemeHandlerTask::ExceptionType::None); + + result = task.didComplete(WebCore::ResourceError()); + ASSERT_UNUSED(result, result == WebURLSchemeHandlerTask::ExceptionType::None); +} + +void QrcSchemeHandler::platformStopTask(WebPageProxy&, WebURLSchemeHandlerTask&) +{ +} + +} // namespace WebKit diff --git a/Source/WebKit2/UIProcess/qt/QrcSchemeHandler.h b/Source/WebKit2/UIProcess/qt/QrcSchemeHandler.h new file mode 100644 index 000000000..2350c97b3 --- /dev/null +++ b/Source/WebKit2/UIProcess/qt/QrcSchemeHandler.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2017 Konstantin Tokarev <annulen@yandex.ru> + * + * 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 "WebURLSchemeHandler.h" + +namespace WebKit { + +class QrcSchemeHandler final : public WebURLSchemeHandler { +public: + static Ref<QrcSchemeHandler> create(); + +private: + QrcSchemeHandler() = default; + + void platformStartTask(WebPageProxy&, WebURLSchemeHandlerTask&) final; + void platformStopTask(WebPageProxy&, WebURLSchemeHandlerTask&) final; +}; + +} // namespace WebKit diff --git a/Source/WebKit2/UIProcess/qt/QtDialogRunner.cpp b/Source/WebKit2/UIProcess/qt/QtDialogRunner.cpp index 6d1949830..5043a170f 100644 --- a/Source/WebKit2/UIProcess/qt/QtDialogRunner.cpp +++ b/Source/WebKit2/UIProcess/qt/QtDialogRunner.cpp @@ -417,7 +417,7 @@ bool QtDialogRunner::createDialog(QQmlComponent* component, QObject* contextObje // This makes both "message" and "model.message" work for the dialog, // just like QtQuick's ListView delegates. contextObject->setParent(m_dialogContext.get()); - m_dialogContext->setContextProperty(QLatin1String("model"), contextObject); + m_dialogContext->setContextProperty(QStringLiteral("model"), contextObject); m_dialogContext->setContextObject(contextObject); QObject* object = component->beginCreate(m_dialogContext.get()); diff --git a/Source/WebKit2/UIProcess/qt/QtDownloadManager.cpp b/Source/WebKit2/UIProcess/qt/QtDownloadManager.cpp index 514a3e554..c5b7ef1da 100644 --- a/Source/WebKit2/UIProcess/qt/QtDownloadManager.cpp +++ b/Source/WebKit2/UIProcess/qt/QtDownloadManager.cpp @@ -39,16 +39,16 @@ static inline QtDownloadManager* toQtDownloadManager(const void* clientInfo) QtDownloadManager::QtDownloadManager(WKContextRef context) { - WKContextDownloadClient downloadClient; - memset(&downloadClient, 0, sizeof(WKContextDownloadClient)); - downloadClient.version = kWKContextDownloadClientCurrentVersion; - downloadClient.clientInfo = this; + WKContextDownloadClientV0 downloadClient; + memset(&downloadClient, 0, sizeof(WKContextDownloadClientV0)); + downloadClient.base.version = 0; + downloadClient.base.clientInfo = this; downloadClient.didReceiveResponse = didReceiveResponse; downloadClient.didReceiveData = didReceiveDataForDownload; downloadClient.didCreateDestination = didCreateDestination; downloadClient.didFinish = didFinishDownload; downloadClient.didFail = didFailDownload; - WKContextSetDownloadClient(context, &downloadClient); + WKContextSetDownloadClient(context, &downloadClient.base); } QtDownloadManager::~QtDownloadManager() diff --git a/Source/WebKit2/UIProcess/qt/QtPageClient.cpp b/Source/WebKit2/UIProcess/qt/QtPageClient.cpp index d5afa7996..c4edb793e 100644 --- a/Source/WebKit2/UIProcess/qt/QtPageClient.cpp +++ b/Source/WebKit2/UIProcess/qt/QtPageClient.cpp @@ -88,7 +88,7 @@ void QtPageClient::pageDidRequestScroll(const IntPoint& pos) QQuickWebViewPrivate::get(m_webView)->pageDidRequestScroll(pos); } -void QtPageClient::processDidCrash() +void QtPageClient::processDidExit() { QQuickWebViewPrivate::get(m_webView)->processDidCrash(); } @@ -98,7 +98,7 @@ void QtPageClient::didRelaunchProcess() QQuickWebViewPrivate::get(m_webView)->didRelaunchProcess(); } -void QtPageClient::didChangeContentsSize(const IntSize& newSize) +void QtPageClient::didChangeContentSize(const IntSize& newSize) { PageViewportController* pvc = QQuickWebViewPrivate::get(m_webView)->viewportController(); if (pvc) @@ -199,12 +199,12 @@ FloatRect QtPageClient::convertToUserSpace(const FloatRect& rect) return rect; } -IntPoint QtPageClient::screenToWindow(const IntPoint& point) +IntPoint QtPageClient::screenToRootView(const IntPoint& point) { return point; } -IntRect QtPageClient::windowToScreen(const IntRect& rect) +IntRect QtPageClient::rootViewToScreen(const IntRect& rect) { return rect; } @@ -220,7 +220,7 @@ std::unique_ptr<WebContextMenuProxy> QtPageClient::createContextMenuProxy(WebPag } #if ENABLE(INPUT_TYPE_COLOR) -PassRefPtr<WebColorPicker> QtPageClient::createColorPicker(WebPageProxy* webPageProxy, const WebCore::Color& initialColor, const WebCore::IntRect& elementRect) +RefPtr<WebColorPicker> QtPageClient::createColorPicker(WebPageProxy* webPageProxy, const WebCore::Color& initialColor, const WebCore::IntRect& elementRect) { return WebColorPickerQt::create(webPageProxy, m_webView, initialColor, elementRect); } @@ -267,6 +267,43 @@ void QtPageClient::doneWithTouchEvent(const NativeWebTouchEvent& event, bool was } #endif +WebFullScreenManagerProxyClient& QtPageClient::fullScreenManagerProxyClient() +{ + return *this; +} + +// QTFIXME: #419 +void QtPageClient::closeFullScreenManager() +{ + notImplemented(); +} + +bool QtPageClient::isFullScreen() +{ + notImplemented(); + return false; +} + +void QtPageClient::enterFullScreen() +{ + notImplemented(); +} + +void QtPageClient::exitFullScreen() +{ + notImplemented(); +} + +void QtPageClient::beganEnterFullScreen(const IntRect& initialFrame, const IntRect& finalFrame) +{ + notImplemented(); +} + +void QtPageClient::beganExitFullScreen(const IntRect& initialFrame, const IntRect& finalFrame) +{ + notImplemented(); +} + void QtPageClient::displayView() { // FIXME: Implement. @@ -328,4 +365,84 @@ void QtPageClient::updateAcceleratedCompositingMode(const LayerTreeContext&) // FIXME: Implement. } +void QtPageClient::requestScroll(const FloatPoint& scrollPosition, const IntPoint& scrollOrigin, bool isProgrammaticScroll) +{ +} + +void QtPageClient::didCommitLoadForMainFrame(const WTF::String& mimeType, bool useCustomContentProvider) +{ +} + +void QtPageClient::willEnterAcceleratedCompositingMode() +{ +} + +void QtPageClient::didFinishLoadingDataForCustomContentProvider(const WTF::String& suggestedFilename, const IPC::DataReference&) +{ +} + +void QtPageClient::navigationGestureDidBegin() +{ +} + +void QtPageClient::navigationGestureWillEnd(bool willNavigate, WebKit::WebBackForwardListItem&) +{ +} + +void QtPageClient::navigationGestureDidEnd(bool willNavigate, WebKit::WebBackForwardListItem&) +{ +} + +void QtPageClient::navigationGestureDidEnd() +{ +} + +void QtPageClient::willRecordNavigationSnapshot(WebKit::WebBackForwardListItem&) +{ +} + +void QtPageClient::didRemoveNavigationGestureSnapshot() +{ +} + +void QtPageClient::didFirstVisuallyNonEmptyLayoutForMainFrame() +{ +} + +void QtPageClient::didFinishLoadForMainFrame() +{ +} + +void QtPageClient::didFailLoadForMainFrame() +{ +} + +void QtPageClient::didSameDocumentNavigationForMainFrame(WebKit::SameDocumentNavigationType) +{ +} + +void QtPageClient::didChangeBackgroundColor() +{ +} + +void QtPageClient::refView() +{ +} + +void QtPageClient::derefView() +{ +} + +#if ENABLE(VIDEO) && USE(GSTREAMER) +bool QtPageClient::decidePolicyForInstallMissingMediaPluginsPermissionRequest(WebKit::InstallMissingMediaPluginsPermissionRequest&) +{ + // QTFIXME + return false; +} +#endif + +void QtPageClient::didRestoreScrollPosition() +{ +} + } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/qt/QtPageClient.h b/Source/WebKit2/UIProcess/qt/QtPageClient.h index a30b25dd3..3467ceaa9 100644 --- a/Source/WebKit2/UIProcess/qt/QtPageClient.h +++ b/Source/WebKit2/UIProcess/qt/QtPageClient.h @@ -22,6 +22,7 @@ #define QtPageClient_h #include "PageClient.h" +#include "WebFullScreenManagerProxy.h" class QQuickWebView; @@ -33,7 +34,11 @@ class QtWebPageEventHandler; class DefaultUndoController; class ShareableBitmap; -class QtPageClient final : public PageClient { +class QtPageClient final : public PageClient +#if ENABLE(FULLSCREEN_API) + , public WebFullScreenManagerProxyClient +#endif +{ public: QtPageClient(); ~QtPageClient(); @@ -47,13 +52,13 @@ public: bool isViewFocused() override; bool isViewVisible() override; void pageDidRequestScroll(const WebCore::IntPoint&) override; - void didChangeContentsSize(const WebCore::IntSize&) override; + void didChangeContentSize(const WebCore::IntSize&) override; void didChangeViewportProperties(const WebCore::ViewportAttributes&) override; - void processDidCrash() override; + void processDidExit() override; void didRelaunchProcess() override; std::unique_ptr<DrawingAreaProxy> createDrawingAreaProxy() override; void handleDownloadRequest(DownloadProxy*) override; - void handleApplicationSchemeRequest(PassRefPtr<QtRefCountedNetworkRequestData>) override; + void handleApplicationSchemeRequest(PassRefPtr<QtRefCountedNetworkRequestData>); // QTFIXME void handleAuthenticationRequiredRequest(const String& hostname, const String& realm, const String& prefilledUsername, String& username, String& password) override; void handleCertificateVerificationRequest(const String& hostname, bool& ignoreErrors) override; void handleProxyAuthenticationRequiredRequest(const String& hostname, uint16_t port, const String& prefilledUsername, String& username, String& password) override; @@ -81,13 +86,13 @@ public: WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&) override; WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&) override; - WebCore::IntPoint screenToWindow(const WebCore::IntPoint&) override; - WebCore::IntRect windowToScreen(const WebCore::IntRect&) override; + WebCore::IntPoint screenToRootView(const WebCore::IntPoint&) override; + WebCore::IntRect rootViewToScreen(const WebCore::IntRect&) override; void doneWithKeyEvent(const NativeWebKeyboardEvent&, bool wasEventHandled) override { } RefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy&) override; std::unique_ptr<WebContextMenuProxy> createContextMenuProxy(WebPageProxy&, const ContextMenuContextData&, const UserData&) override; #if ENABLE(INPUT_TYPE_COLOR) - virtual PassRefPtr<WebColorPicker> createColorPicker(WebPageProxy*, const WebCore::Color& initialColor, const WebCore::IntRect&); + RefPtr<WebColorPicker> createColorPicker(WebPageProxy*, const WebCore::Color& initialColor, const WebCore::IntRect&) override; #endif void pageTransitionViewportReady() override; void didFindZoomableArea(const WebCore::IntPoint&, const WebCore::IntRect&) override; @@ -100,10 +105,46 @@ public: void doneWithTouchEvent(const NativeWebTouchEvent&, bool wasEventHandled) override; #endif +#if ENABLE(FULLSCREEN_API) + WebFullScreenManagerProxyClient& fullScreenManagerProxyClient() final; + + // WebFullScreenManagerProxyClient + void closeFullScreenManager() final; + bool isFullScreen() final; + void enterFullScreen() final; + void exitFullScreen() final; + void beganEnterFullScreen(const WebCore::IntRect& initialFrame, const WebCore::IntRect& finalFrame) final; + void beganExitFullScreen(const WebCore::IntRect& initialFrame, const WebCore::IntRect& finalFrame) final; +#endif + private: QQuickWebView* m_webView; QtWebPageEventHandler* m_eventHandler; DefaultUndoController* m_undoController; + + // PageClient interface +public: + void requestScroll(const WebCore::FloatPoint& scrollPosition, const WebCore::IntPoint& scrollOrigin, bool isProgrammaticScroll) override; + void didCommitLoadForMainFrame(const WTF::String& mimeType, bool useCustomContentProvider) override; + void willEnterAcceleratedCompositingMode() override; + void didFinishLoadingDataForCustomContentProvider(const WTF::String& suggestedFilename, const IPC::DataReference&) override; + void navigationGestureDidBegin() override; + void navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem&) override; + void navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem&) override; + void navigationGestureDidEnd() override; + void willRecordNavigationSnapshot(WebBackForwardListItem&) override; + void didRemoveNavigationGestureSnapshot() override; + void didFirstVisuallyNonEmptyLayoutForMainFrame() override; + void didFinishLoadForMainFrame() override; + void didFailLoadForMainFrame() override; + void didSameDocumentNavigationForMainFrame(SameDocumentNavigationType) override; + void didChangeBackgroundColor() override; + void refView() override; + void derefView() override; +#if ENABLE(VIDEO) && USE(GSTREAMER) + bool decidePolicyForInstallMissingMediaPluginsPermissionRequest(InstallMissingMediaPluginsPermissionRequest&) override; +#endif + void didRestoreScrollPosition() override; }; } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/qt/QtWebContext.cpp b/Source/WebKit2/UIProcess/qt/QtWebContext.cpp index 7d3ecc920..7030e13d9 100644 --- a/Source/WebKit2/UIProcess/qt/QtWebContext.cpp +++ b/Source/WebKit2/UIProcess/qt/QtWebContext.cpp @@ -31,6 +31,7 @@ #include <WKAPICast.h> #include <WKArray.h> #include <WKContextPrivate.h> +#include <WKData.h> #include <WKPage.h> #include <WKString.h> #include <WKStringQt.h> @@ -50,7 +51,7 @@ static void initInspectorServer() #if ENABLE(INSPECTOR_SERVER) QString inspectorEnv = QString::fromUtf8(qgetenv("QTWEBKIT_INSPECTOR_SERVER")); if (!inspectorEnv.isEmpty()) { - QString bindAddress = QLatin1String("127.0.0.1"); + QString bindAddress = QStringLiteral("127.0.0.1"); QString portStr = inspectorEnv; int port = 0; @@ -69,7 +70,7 @@ static void initInspectorServer() bool success = WebInspectorServer::singleton().listen(bindAddress, port); if (success) { - QString inspectorServerUrl = QString::fromLatin1("http://%1:%2").arg(bindAddress).arg(port); + QString inspectorServerUrl = QStringLiteral("http://%1:%2").arg(bindAddress).arg(port); qWarning("Inspector server started successfully. Try pointing a WebKit browser to %s", qPrintable(inspectorServerUrl)); } else qWarning("Couldn't start the inspector server on bind address \"%s\" and port \"%d\". In case of invalid input, try something like: \"12345\" or \"192.168.2.14:12345\" (with the address of one of this host's interface).", qPrintable(bindAddress), port); @@ -90,7 +91,7 @@ static void globalInitialization() static void didReceiveMessageFromInjectedBundle(WKContextRef, WKStringRef messageName, WKTypeRef messageBody, const void*) { if (!WKStringIsEqualToUTF8CString(messageName, "MessageFromNavigatorQtObject") -#ifdef HAVE_WEBCHANNEL +#if ENABLE(QT_WEBCHANNEL) && !WKStringIsEqualToUTF8CString(messageName, "MessageFromNavigatorQtWebChannelTransportObject") #endif ) @@ -104,26 +105,30 @@ static void didReceiveMessageFromInjectedBundle(WKContextRef, WKStringRef messag WKArrayRef body = static_cast<WKArrayRef>(messageBody); ASSERT(WKArrayGetSize(body) == 2); ASSERT(WKGetTypeID(WKArrayGetItemAtIndex(body, 0)) == WKPageGetTypeID()); - ASSERT(WKGetTypeID(WKArrayGetItemAtIndex(body, 1)) == WKStringGetTypeID()); WKPageRef page = static_cast<WKPageRef>(WKArrayGetItemAtIndex(body, 0)); - WKStringRef str = static_cast<WKStringRef>(WKArrayGetItemAtIndex(body, 1)); - if (WKStringIsEqualToUTF8CString(messageName, "MessageFromNavigatorQtObject")) - QQuickWebViewPrivate::get(page)->didReceiveMessageFromNavigatorQtObject(str); -#ifdef HAVE_WEBCHANNEL - else if (WKStringIsEqualToUTF8CString(messageName, "MessageFromNavigatorQtWebChannelTransportObject")) - QQuickWebViewPrivate::get(page)->didReceiveMessageFromNavigatorQtWebChannelTransportObject(str); + if (WKStringIsEqualToUTF8CString(messageName, "MessageFromNavigatorQtObject")) { + ASSERT(WKGetTypeID(WKArrayGetItemAtIndex(body, 1)) == WKStringGetTypeID()); + WKStringRef data = static_cast<WKStringRef>(WKArrayGetItemAtIndex(body, 1)); + QQuickWebViewPrivate::get(page)->didReceiveMessageFromNavigatorQtObject(data); + } +#if ENABLE(QT_WEBCHANNEL) + else if (WKStringIsEqualToUTF8CString(messageName, "MessageFromNavigatorQtWebChannelTransportObject")) { + ASSERT(WKGetTypeID(WKArrayGetItemAtIndex(body, 1)) == WKDataGetTypeID()); + WKDataRef data = static_cast<WKDataRef>(WKArrayGetItemAtIndex(body, 1)); + QQuickWebViewPrivate::get(page)->didReceiveMessageFromNavigatorQtWebChannelTransportObject(data); + } #endif } static void initializeContextInjectedBundleClient(WKContextRef context) { - WKContextInjectedBundleClient injectedBundleClient; - memset(&injectedBundleClient, 0, sizeof(WKContextInjectedBundleClient)); - injectedBundleClient.version = kWKContextInjectedBundleClientCurrentVersion; + WKContextInjectedBundleClientV0 injectedBundleClient; + memset(&injectedBundleClient, 0, sizeof(WKContextInjectedBundleClientV0)); + injectedBundleClient.base.version = 0; injectedBundleClient.didReceiveMessageFromInjectedBundle = didReceiveMessageFromInjectedBundle; - WKContextSetInjectedBundleClient(context, &injectedBundleClient); + WKContextSetInjectedBundleClient(context, &injectedBundleClient.base); } QtWebContext::QtWebContext(WKContextRef context) @@ -155,10 +160,11 @@ QtWebContext* QtWebContext::defaultContext() WKContextSetCacheModel(wkContext.get(), kWKCacheModelDocumentBrowser); // Those paths have to be set before the first web process is spawned. - WKContextSetDatabaseDirectory(wkContext.get(), adoptWK(WKStringCreateWithQString(preparedStoragePath(DatabaseStorage))).get()); - WKContextSetLocalStorageDirectory(wkContext.get(), adoptWK(WKStringCreateWithQString(preparedStoragePath(LocalStorage))).get()); +// QTFIXME +// WKContextSetDatabaseDirectory(wkContext.get(), adoptWK(WKStringCreateWithQString(preparedStoragePath(DatabaseStorage))).get()); +// WKContextSetLocalStorageDirectory(wkContext.get(), adoptWK(WKStringCreateWithQString(preparedStoragePath(LocalStorage))).get()); WKContextSetCookieStorageDirectory(wkContext.get(), adoptWK(WKStringCreateWithQString(preparedStoragePath(CookieStorage))).get()); - WKContextSetDiskCacheDirectory(wkContext.get(), adoptWK(WKStringCreateWithQString(preparedStoragePath(DiskCacheStorage))).get()); +// WKContextSetDiskCacheDirectory(wkContext.get(), adoptWK(WKStringCreateWithQString(preparedStoragePath(DiskCacheStorage))).get()); s_defaultQtWebContext = QtWebContext::create(wkContext.get()); } @@ -177,6 +183,10 @@ QString QtWebContext::preparedStoragePath(StorageType type) { QString path; switch (type) { + case ApplicationCacheStorage: + path = defaultLocation(QStandardPaths::DataLocation) % QStringLiteral("Applications"); + QDir::root().mkpath(path); + break; case DatabaseStorage: path = defaultLocation(QStandardPaths::DataLocation) % QStringLiteral("Databases"); QDir::root().mkpath(path); @@ -190,7 +200,11 @@ QString QtWebContext::preparedStoragePath(StorageType type) QDir::root().mkpath(path); break; case DiskCacheStorage: +#if ENABLE(NETWORK_CACHE) + path = defaultLocation(QStandardPaths::CacheLocation) % QStringLiteral("WebKitCache"); +#else path = defaultLocation(QStandardPaths::CacheLocation) % QStringLiteral("DiskCache"); +#endif QDir::root().mkpath(path); break; case IconDatabaseStorage: diff --git a/Source/WebKit2/UIProcess/qt/QtWebContext.h b/Source/WebKit2/UIProcess/qt/QtWebContext.h index 4251f29e7..972e388a4 100644 --- a/Source/WebKit2/UIProcess/qt/QtWebContext.h +++ b/Source/WebKit2/UIProcess/qt/QtWebContext.h @@ -36,11 +36,13 @@ public: ~QtWebContext(); enum StorageType { + ApplicationCacheStorage, DatabaseStorage, LocalStorage, CookieStorage, DiskCacheStorage, - IconDatabaseStorage + IconDatabaseStorage, + NetworkCacheStorage }; static QtWebContext* create(WKContextRef); diff --git a/Source/WebKit2/UIProcess/qt/QtWebIconDatabaseClient.cpp b/Source/WebKit2/UIProcess/qt/QtWebIconDatabaseClient.cpp index f28fb4163..b641ab7f1 100644 --- a/Source/WebKit2/UIProcess/qt/QtWebIconDatabaseClient.cpp +++ b/Source/WebKit2/UIProcess/qt/QtWebIconDatabaseClient.cpp @@ -46,12 +46,12 @@ QtWebIconDatabaseClient::QtWebIconDatabaseClient(WKContextRef context) { m_iconDatabase = WKContextGetIconDatabase(context); - WKIconDatabaseClient iconDatabaseClient; - memset(&iconDatabaseClient, 0, sizeof(WKIconDatabaseClient)); - iconDatabaseClient.version = kWKIconDatabaseClientCurrentVersion; - iconDatabaseClient.clientInfo = this; + WKIconDatabaseClientV0 iconDatabaseClient; + memset(&iconDatabaseClient, 0, sizeof(WKIconDatabaseClientV0)); + iconDatabaseClient.base.version = 0; + iconDatabaseClient.base.clientInfo = this; iconDatabaseClient.didChangeIconForPageURL = didChangeIconForPageURL; - WKIconDatabaseSetIconDatabaseClient(m_iconDatabase, &iconDatabaseClient); + WKIconDatabaseSetIconDatabaseClient(m_iconDatabase, &iconDatabaseClient.base); // Triggers the startup of the icon database. WKRetainPtr<WKStringRef> path = adoptWK(WKStringCreateWithQString(QtWebContext::preparedStoragePath(QtWebContext::IconDatabaseStorage))); WKContextSetIconDatabasePath(context, path.get()); diff --git a/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp b/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp index b56f475cc..d05649736 100644 --- a/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp +++ b/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp @@ -184,7 +184,7 @@ void QtWebPageEventHandler::handleHoverMoveEvent(QHoverEvent* ev) void QtWebPageEventHandler::handleDragEnterEvent(QDragEnterEvent* ev) { - m_webPageProxy->resetDragOperation(); + m_webPageProxy->resetCurrentDragInformation(); QTransform fromItemTransform = m_webPage->transformFromItem(); // FIXME: Should not use QCursor::pos() DragData dragData(ev->mimeData(), fromItemTransform.map(ev->pos()), QCursor::pos(), dropActionToDragOperation(ev->possibleActions())); @@ -199,7 +199,7 @@ void QtWebPageEventHandler::handleDragLeaveEvent(QDragLeaveEvent* ev) // FIXME: Should not use QCursor::pos() DragData dragData(0, IntPoint(), QCursor::pos(), DragOperationNone); m_webPageProxy->dragExited(dragData); - m_webPageProxy->resetDragOperation(); + m_webPageProxy->resetCurrentDragInformation(); ev->setAccepted(accepted); } @@ -212,8 +212,8 @@ void QtWebPageEventHandler::handleDragMoveEvent(QDragMoveEvent* ev) // FIXME: Should not use QCursor::pos() DragData dragData(ev->mimeData(), fromItemTransform.map(ev->pos()), QCursor::pos(), dropActionToDragOperation(ev->possibleActions())); m_webPageProxy->dragUpdated(dragData); - ev->setDropAction(dragOperationToDropAction(m_webPageProxy->dragSession().operation)); - if (m_webPageProxy->dragSession().operation != DragOperationNone) + ev->setDropAction(dragOperationToDropAction(m_webPageProxy->currentDragOperation())); + if (m_webPageProxy->currentDragOperation() != DragOperationNone) ev->accept(); ev->setAccepted(accepted); @@ -228,7 +228,7 @@ void QtWebPageEventHandler::handleDropEvent(QDropEvent* ev) SandboxExtension::Handle handle; SandboxExtension::HandleArray sandboxExtensionForUpload; m_webPageProxy->performDragOperation(dragData, String(), handle, sandboxExtensionForUpload); - ev->setDropAction(dragOperationToDropAction(m_webPageProxy->dragSession().operation)); + ev->setDropAction(dragOperationToDropAction(m_webPageProxy->currentDragOperation())); ev->accept(); ev->setAccepted(accepted); @@ -566,7 +566,9 @@ void QtWebPageEventHandler::handleInputEvent(const QInputEvent* event) // Early return since this was a touch-end event. return; - } else if (activeTouchPointCount == 1) { + } + + if (activeTouchPointCount == 1) { // If the pinch gesture recognizer was previously in active state the content might // be out of valid zoom boundaries, thus we need to finish the pinch gesture here. // This will resume the content to valid zoom levels before the pan gesture is started. @@ -642,4 +644,3 @@ void QtWebPageEventHandler::startDrag(const WebCore::DragData& dragData, PassRef } // namespace WebKit #include "moc_QtWebPageEventHandler.cpp" - diff --git a/Source/WebKit2/UIProcess/qt/QtWebPagePolicyClient.cpp b/Source/WebKit2/UIProcess/qt/QtWebPagePolicyClient.cpp index 88a9436af..90e74fd9c 100644 --- a/Source/WebKit2/UIProcess/qt/QtWebPagePolicyClient.cpp +++ b/Source/WebKit2/UIProcess/qt/QtWebPagePolicyClient.cpp @@ -35,13 +35,12 @@ namespace WebKit { QtWebPagePolicyClient::QtWebPagePolicyClient(WKPageRef pageRef, QQuickWebView* webView) : m_webView(webView) { - WKPagePolicyClient policyClient; - memset(&policyClient, 0, sizeof(WKPagePolicyClient)); - policyClient.version = kWKPagePolicyClientCurrentVersion; - policyClient.clientInfo = this; + WKPagePolicyClientV1 policyClient; + memset(&policyClient, 0, sizeof(WKPagePolicyClientV0)); + policyClient.base = { 1, this }; policyClient.decidePolicyForNavigationAction = decidePolicyForNavigationAction; policyClient.decidePolicyForResponse = decidePolicyForResponse; - WKPageSetPagePolicyClient(pageRef, &policyClient); + WKPageSetPagePolicyClient(pageRef, &policyClient.base); } void QtWebPagePolicyClient::decidePolicyForNavigationAction(const QUrl& url, Qt::MouseButton mouseButton, Qt::KeyboardModifiers keyboardModifiers, QQuickWebView::NavigationType navigationType, bool isMainFrame, WKFramePolicyListenerRef listener) @@ -121,7 +120,7 @@ static QQuickWebView::NavigationType toQuickWebViewNavigationType(WKFrameNavigat return QQuickWebView::OtherNavigation; } -void QtWebPagePolicyClient::decidePolicyForNavigationAction(WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef, const void* clientInfo) +void QtWebPagePolicyClient::decidePolicyForNavigationAction(WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKFrameRef originatingFrame, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef, const void* clientInfo) { WKRetainPtr<WKURLRef> frameURL(AdoptWK, WKFrameCopyURL(frame)); WKRetainPtr<WKURLRef> requestURL(AdoptWK, WKURLRequestCopyURL(request)); @@ -130,11 +129,10 @@ void QtWebPagePolicyClient::decidePolicyForNavigationAction(WKPageRef page, WKFr toQtWebPagePolicyClient(clientInfo)->decidePolicyForNavigationAction(qUrl, toQtMouseButton(mouseButton), toQtKeyboardModifiers(modifiers), toQuickWebViewNavigationType(navigationType), isMainFrame, listener); } -void QtWebPagePolicyClient::decidePolicyForResponse(WKPageRef page, WKFrameRef frame, WKURLResponseRef response, WKURLRequestRef, WKFramePolicyListenerRef listener, WKTypeRef, const void*) +void QtWebPagePolicyClient::decidePolicyForResponse(WKPageRef page, WKFrameRef frame, WKURLResponseRef response, WKURLRequestRef, bool canShowMIMEType, WKFramePolicyListenerRef listener, WKTypeRef, const void*) { String type = toImpl(response)->resourceResponse().mimeType(); - type.makeLower(); - bool canShowMIMEType = toImpl(frame)->canShowMIMEType(type); + type.convertToASCIILowercase(); // QTFIXME: See also FrameLoaderClientQt if (WKPageGetMainFrame(page) == frame) { if (canShowMIMEType) { diff --git a/Source/WebKit2/UIProcess/qt/QtWebPagePolicyClient.h b/Source/WebKit2/UIProcess/qt/QtWebPagePolicyClient.h index c9267508d..4e1d7f250 100644 --- a/Source/WebKit2/UIProcess/qt/QtWebPagePolicyClient.h +++ b/Source/WebKit2/UIProcess/qt/QtWebPagePolicyClient.h @@ -39,8 +39,8 @@ private: void decidePolicyForNavigationAction(const QUrl&, Qt::MouseButton, Qt::KeyboardModifiers, QQuickWebView::NavigationType, bool isMainFrame, WKFramePolicyListenerRef); // WKPagePolicyClient callbacks. - static void decidePolicyForNavigationAction(WKPageRef, WKFrameRef, WKFrameNavigationType, WKEventModifiers, WKEventMouseButton, WKURLRequestRef, WKFramePolicyListenerRef, WKTypeRef userData, const void* clientInfo); - static void decidePolicyForResponse(WKPageRef, WKFrameRef, WKURLResponseRef, WKURLRequestRef, WKFramePolicyListenerRef, WKTypeRef userData, const void* clientInfo); + static void decidePolicyForNavigationAction(WKPageRef, WKFrameRef, WKFrameNavigationType, WKEventModifiers, WKEventMouseButton, WKFrameRef, WKURLRequestRef, WKFramePolicyListenerRef, WKTypeRef userData, const void* clientInfo); + static void decidePolicyForResponse(WKPageRef, WKFrameRef, WKURLResponseRef, WKURLRequestRef, bool, WKFramePolicyListenerRef, WKTypeRef userData, const void* clientInfo); QQuickWebView* m_webView; }; diff --git a/Source/WebKit2/UIProcess/qt/QtWebPageSGNode.cpp b/Source/WebKit2/UIProcess/qt/QtWebPageSGNode.cpp index 67df10114..6630f6276 100644 --- a/Source/WebKit2/UIProcess/qt/QtWebPageSGNode.cpp +++ b/Source/WebKit2/UIProcess/qt/QtWebPageSGNode.cpp @@ -22,10 +22,9 @@ #include "QtWebPageSGNode.h" #include "CoordinatedGraphicsScene.h" +#include "WebPageProxy.h" #include <QtGui/QPolygonF> -#include <QtQuick/QQuickItem> -#include <QtQuick/QQuickWindow> #include <QtQuick/QSGSimpleRectNode> #include <WebCore/TransformationMatrix.h> @@ -88,7 +87,9 @@ public: bool mirrored = projection && (*projection)(0, 0) * (*projection)(1, 1) - (*projection)(0, 1) * (*projection)(1, 0) > 0; // FIXME: Support non-rectangular clippings. - coordinatedGraphicsScene()->paintToCurrentGLContext(renderMatrix, inheritedOpacity(), clipRect(), mirrored ? TextureMapper::PaintingMirrored : 0); + coordinatedGraphicsScene()->paintToCurrentGLContext(renderMatrix, inheritedOpacity(), clipRect(), + pageNode()->page().pageExtendedBackgroundColor(), pageNode()->page().drawsBackground(), FloatPoint(), + mirrored ? TextureMapper::PaintingMirrored : 0); } void releaseResources() @@ -163,8 +164,9 @@ private: RefPtr<CoordinatedGraphicsScene> m_scene; }; -QtWebPageSGNode::QtWebPageSGNode() - : m_contentsNode(0) +QtWebPageSGNode::QtWebPageSGNode(WebPageProxy& page) + : m_page(page) + , m_contentsNode(0) , m_backgroundNode(new QSGSimpleRectNode) , m_devicePixelRatio(1) { diff --git a/Source/WebKit2/UIProcess/qt/QtWebPageSGNode.h b/Source/WebKit2/UIProcess/qt/QtWebPageSGNode.h index 830c6d64f..49c4c5000 100644 --- a/Source/WebKit2/UIProcess/qt/QtWebPageSGNode.h +++ b/Source/WebKit2/UIProcess/qt/QtWebPageSGNode.h @@ -33,17 +33,20 @@ namespace WebKit { class ContentsSGNode; class CoordinatedGraphicsScene; +class WebPageProxy; class QtWebPageSGNode final : public QSGTransformNode { public: - QtWebPageSGNode(); + QtWebPageSGNode(WebPageProxy&); void setBackground(const QRectF&, const QColor&); void setScale(float); void setCoordinatedGraphicsScene(PassRefPtr<CoordinatedGraphicsScene>); qreal devicePixelRatio() const { return m_devicePixelRatio; } void setDevicePixelRatio(qreal devicePixelRatio) { m_devicePixelRatio = devicePixelRatio; } + const WebPageProxy& page() const { return m_page; } private: + Ref<WebPageProxy> m_page; ContentsSGNode* m_contentsNode; QSGSimpleRectNode* m_backgroundNode; qreal m_devicePixelRatio; diff --git a/Source/WebKit2/UIProcess/qt/QtWebPageUIClient.cpp b/Source/WebKit2/UIProcess/qt/QtWebPageUIClient.cpp index 482076370..c58f20065 100644 --- a/Source/WebKit2/UIProcess/qt/QtWebPageUIClient.cpp +++ b/Source/WebKit2/UIProcess/qt/QtWebPageUIClient.cpp @@ -37,10 +37,10 @@ namespace WebKit { QtWebPageUIClient::QtWebPageUIClient(WKPageRef pageRef, QQuickWebView* webView) : m_webView(webView) { - WKPageUIClient uiClient; - memset(&uiClient, 0, sizeof(WKPageUIClient)); - uiClient.version = kWKPageUIClientCurrentVersion; - uiClient.clientInfo = this; + WKPageUIClientV1 uiClient; + memset(&uiClient, 0, sizeof(WKPageUIClientV1)); + uiClient.base.version = 1; + uiClient.base.clientInfo = this; uiClient.runJavaScriptAlert = runJavaScriptAlert; uiClient.runJavaScriptConfirm = runJavaScriptConfirm; uiClient.runJavaScriptPrompt = runJavaScriptPrompt; @@ -49,7 +49,7 @@ QtWebPageUIClient::QtWebPageUIClient(WKPageRef pageRef, QQuickWebView* webView) uiClient.exceededDatabaseQuota = exceededDatabaseQuota; uiClient.decidePolicyForGeolocationPermissionRequest = policyForGeolocationPermissionRequest; uiClient.decidePolicyForNotificationPermissionRequest = policyForNotificationPermissionRequest; - WKPageSetPageUIClient(pageRef, &uiClient); + WKPageSetPageUIClient(pageRef, &uiClient.base); } quint64 QtWebPageUIClient::exceededDatabaseQuota(const QString& databaseName, const QString& displayName, WKSecurityOriginRef securityOrigin, quint64 currentQuota, quint64 currentOriginUsage, quint64 currentDatabaseUsage, quint64 expectedUsage) diff --git a/Source/WebKit2/UIProcess/qt/TextCheckerQt.cpp b/Source/WebKit2/UIProcess/qt/TextCheckerQt.cpp index 7e343e179..4880ac119 100644 --- a/Source/WebKit2/UIProcess/qt/TextCheckerQt.cpp +++ b/Source/WebKit2/UIProcess/qt/TextCheckerQt.cpp @@ -80,12 +80,12 @@ void TextChecker::closeSpellDocumentWithTag(int64_t) notImplemented(); } -void TextChecker::checkSpellingOfString(int64_t, const UChar*, uint32_t, int32_t&, int32_t&) +void TextChecker::checkSpellingOfString(int64_t, StringView, int32_t&, int32_t&) { notImplemented(); } -void TextChecker::checkGrammarOfString(int64_t, const UChar*, uint32_t, Vector<WebCore::GrammarDetail>&, int32_t&, int32_t&) +void TextChecker::checkGrammarOfString(int64_t, StringView, Vector<WebCore::GrammarDetail>&, int32_t&, int32_t&) { notImplemented(); } diff --git a/Source/WebKit2/UIProcess/qt/WebColorPickerQt.cpp b/Source/WebKit2/UIProcess/qt/WebColorPickerQt.cpp index d23cff04a..031c32d9e 100644 --- a/Source/WebKit2/UIProcess/qt/WebColorPickerQt.cpp +++ b/Source/WebKit2/UIProcess/qt/WebColorPickerQt.cpp @@ -110,7 +110,7 @@ void WebColorPickerQt::createContext(QQmlComponent* component, QObject* contextO m_context.reset(new QQmlContext(baseContext)); contextObject->setParent(m_context.get()); - m_context->setContextProperty(QLatin1String("model"), contextObject); + m_context->setContextProperty(QStringLiteral("model"), contextObject); m_context->setContextObject(contextObject); } @@ -123,6 +123,12 @@ void WebColorPickerQt::setSelectedColor(const Color&) // And yes, the name sounds misleading but comes from WebCore. } +void WebColorPickerQt::showColorPicker(const Color&) +{ + // We use ENABLE(INPUT_TYPE_COLOR_POPOVER), so new color picker is created + // each time +} + void WebColorPickerQt::notifyColorSelected(const QColor& color) { if (!m_client) @@ -139,11 +145,6 @@ void WebColorPickerQt::endPicker() { m_colorChooser = nullptr; m_context = nullptr; - - if (!m_client) - return; - - m_client->didEndColorPicker(); } } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/qt/WebColorPickerQt.h b/Source/WebKit2/UIProcess/qt/WebColorPickerQt.h index 40181b6f0..0d57f7d3d 100644 --- a/Source/WebKit2/UIProcess/qt/WebColorPickerQt.h +++ b/Source/WebKit2/UIProcess/qt/WebColorPickerQt.h @@ -50,6 +50,7 @@ public: ~WebColorPickerQt(); void setSelectedColor(const WebCore::Color&) final; + void showColorPicker(const WebCore::Color&) final; public Q_SLOTS: void endPicker() final; diff --git a/Source/WebKit2/UIProcess/qt/WebContextMenuProxyQt.cpp b/Source/WebKit2/UIProcess/qt/WebContextMenuProxyQt.cpp index 1ff57e9c9..b0eea135a 100644 --- a/Source/WebKit2/UIProcess/qt/WebContextMenuProxyQt.cpp +++ b/Source/WebKit2/UIProcess/qt/WebContextMenuProxyQt.cpp @@ -36,11 +36,7 @@ WebContextMenuProxyQt::WebContextMenuProxyQt(const ContextMenuContextData& conte { } -void WebContextMenuProxyQt::showContextMenu(const IntPoint&, const Vector<WebContextMenuItemData>&) -{ -} - -void WebContextMenuProxyQt::hideContextMenu() +void WebContextMenuProxyQt::show() { } diff --git a/Source/WebKit2/UIProcess/qt/WebContextMenuProxyQt.h b/Source/WebKit2/UIProcess/qt/WebContextMenuProxyQt.h index a0cc82d0a..9a8645aa3 100644 --- a/Source/WebKit2/UIProcess/qt/WebContextMenuProxyQt.h +++ b/Source/WebKit2/UIProcess/qt/WebContextMenuProxyQt.h @@ -40,8 +40,7 @@ public: WebContextMenuProxyQt(const ContextMenuContextData&, const UserData&); private: - virtual void showContextMenu(const WebCore::IntPoint&, const Vector<WebContextMenuItemData>&); - virtual void hideContextMenu(); + void show() override; }; } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/qt/WebGeolocationProviderQt.cpp b/Source/WebKit2/UIProcess/qt/WebGeolocationProviderQt.cpp index 7d05f043e..ca9cae747 100644 --- a/Source/WebKit2/UIProcess/qt/WebGeolocationProviderQt.cpp +++ b/Source/WebKit2/UIProcess/qt/WebGeolocationProviderQt.cpp @@ -46,16 +46,16 @@ WebGeolocationProviderQt* WebGeolocationProviderQt::create(WKGeolocationManagerR return new WebGeolocationProviderQt(manager); } -WKGeolocationProvider* WebGeolocationProviderQt::provider(const WebGeolocationProviderQt* location) +WKGeolocationProviderBase* WebGeolocationProviderQt::provider(const WebGeolocationProviderQt* location) { - static WKGeolocationProvider provider = { - 0, // This features the version. - location, // This points to the object implementer. + static WKGeolocationProviderV0 provider = { + { 0, // This features the version. + location }, // This points to the object implementer. locationStartUpdating, // The callbacks are next. locationStopUpdating }; - return &provider; + return &provider.base; } WebGeolocationProviderQt::WebGeolocationProviderQt(WKGeolocationManagerRef manager) diff --git a/Source/WebKit2/UIProcess/qt/WebGeolocationProviderQt.h b/Source/WebKit2/UIProcess/qt/WebGeolocationProviderQt.h index 9f1b13c87..035eff0cd 100644 --- a/Source/WebKit2/UIProcess/qt/WebGeolocationProviderQt.h +++ b/Source/WebKit2/UIProcess/qt/WebGeolocationProviderQt.h @@ -37,7 +37,7 @@ class WebGeolocationProviderQt final : public QObject { Q_OBJECT public: static WebGeolocationProviderQt* create(WKGeolocationManagerRef); - static WKGeolocationProvider* provider(const WebGeolocationProviderQt*); + static WKGeolocationProviderBase* provider(const WebGeolocationProviderQt*); virtual ~WebGeolocationProviderQt(); diff --git a/Source/WebKit2/UIProcess/qt/WebInspectorProxyQt.cpp b/Source/WebKit2/UIProcess/qt/WebInspectorProxyQt.cpp index 6a520c383..2de52d2c4 100644 --- a/Source/WebKit2/UIProcess/qt/WebInspectorProxyQt.cpp +++ b/Source/WebKit2/UIProcess/qt/WebInspectorProxyQt.cpp @@ -26,8 +26,6 @@ #include "config.h" #include "WebInspectorProxy.h" -#if ENABLE(INSPECTOR) - #include <WebCore/NotImplemented.h> #include <wtf/text/WTFString.h> @@ -49,6 +47,11 @@ void WebInspectorProxy::platformDidClose() notImplemented(); } +void WebKit::WebInspectorProxy::platformInvalidate() +{ + notImplemented(); +} + void WebInspectorProxy::platformHide() { notImplemented(); @@ -107,7 +110,7 @@ void WebInspectorProxy::platformSetAttachedWindowWidth(unsigned) notImplemented(); } -void WebInspectorProxy::platformSetToolbarHeight(unsigned) +void WebKit::WebInspectorProxy::platformStartWindowDrag() { notImplemented(); } @@ -122,18 +125,22 @@ void WebInspectorProxy::platformAppend(const String&, const String&) notImplemented(); } -String WebInspectorProxy::inspectorPageURL() const +String WebInspectorProxy::inspectorPageURL() { notImplemented(); return String(); } -String WebInspectorProxy::inspectorBaseURL() const +String WebInspectorProxy::inspectorTestPageURL() { notImplemented(); return String(); } -} // namespace WebKit +String WebInspectorProxy::inspectorBaseURL() +{ + notImplemented(); + return String(); +} -#endif // ENABLE(INSPECTOR) +} // namespace WebKit diff --git a/Source/WebKit2/UIProcess/qt/WebPageProxyQt.cpp b/Source/WebKit2/UIProcess/qt/WebPageProxyQt.cpp index 541cca01f..d3eeb5962 100644 --- a/Source/WebKit2/UIProcess/qt/WebPageProxyQt.cpp +++ b/Source/WebKit2/UIProcess/qt/WebPageProxyQt.cpp @@ -32,6 +32,7 @@ #include "WebKitVersion.h" #include "WebPageMessages.h" #include "WebProcessProxy.h" +#include "WebsiteDataStore.h" #include <WebCore/Editor.h> #include <WebCore/NotImplemented.h> @@ -45,45 +46,37 @@ using namespace WebCore; namespace WebKit { +void WebPageProxy::platformInitialize() +{ +} + String WebPageProxy::standardUserAgent(const String& applicationNameForUserAgent) { return UserAgentQt::standardUserAgent(applicationNameForUserAgent, WEBKIT_MAJOR_VERSION, WEBKIT_MINOR_VERSION); } -void WebPageProxy::saveRecentSearches(const String&, const Vector<String>&) +void WebPageProxy::saveRecentSearches(const String&, const Vector<WebCore::RecentSearch>&) { notImplemented(); } -void WebPageProxy::loadRecentSearches(const String&, Vector<String>&) +void WebPageProxy::loadRecentSearches(const String&, Vector<WebCore::RecentSearch>&) { notImplemented(); } -void WebPageProxy::registerApplicationScheme(const String& scheme) +void WebsiteDataStore::platformRemoveRecentSearches(std::chrono::system_clock::time_point oldestTimeToRemove) { - process().send(Messages::WebPage::RegisterApplicationScheme(scheme), m_pageID); + notImplemented(); } -void WebPageProxy::resolveApplicationSchemeRequest(QtNetworkRequestData request) +void WebPageProxy::editorStateChanged(const EditorState& editorState) { -#if HAVE(QTQUICK) - RefPtr<QtRefCountedNetworkRequestData> requestData = adoptRef(new QtRefCountedNetworkRequestData(request)); - m_applicationSchemeRequests.add(requestData); - static_cast<QtPageClient*>(m_pageClient)->handleApplicationSchemeRequest(requestData); -#endif -} + m_editorState = editorState; -void WebPageProxy::sendApplicationSchemeReply(const QQuickNetworkReply* reply) -{ -#if HAVE(QTQUICK) - RefPtr<QtRefCountedNetworkRequestData> requestData = reply->networkRequestData(); - if (m_applicationSchemeRequests.contains(requestData)) { - RefPtr<QtRefCountedNetworkReplyData> replyData = reply->networkReplyData(); - process().send(Messages::WebPage::ApplicationSchemeReply(replyData->data()), pageID()); - m_applicationSchemeRequests.remove(requestData); - } -#endif + if (editorState.shouldIgnoreCompositionSelectionChange) + return; + m_pageClient.updateTextInputState(); } void WebPageProxy::authenticationRequiredRequest(const String& hostname, const String& realm, const String& prefilledUsername, String& username, String& password) @@ -111,6 +104,11 @@ void WebPageProxy::windowedPluginGeometryDidChange(const WebCore::IntRect& frame { notImplemented(); } + +void WebPageProxy::windowedPluginVisibilityDidChange(bool isVisible, uint64_t windowID) +{ + notImplemented(); +} #endif void WebPageProxy::changeSelectedIndex(int32_t selectedIndex) diff --git a/Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.cpp b/Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.cpp index e1d556e08..249de62ec 100644 --- a/Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.cpp +++ b/Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.cpp @@ -342,7 +342,7 @@ void WebPopupMenuProxyQt::createContext(QQmlComponent* component, QObject* conte m_context.reset(new QQmlContext(baseContext)); contextObject->setParent(m_context.get()); - m_context->setContextProperty(QLatin1String("model"), contextObject); + m_context->setContextProperty(QStringLiteral("model"), contextObject); m_context->setContextObject(contextObject); } diff --git a/Source/WebKit2/UIProcess/qt/WebPreferencesQt.cpp b/Source/WebKit2/UIProcess/qt/WebPreferencesQt.cpp index 35dc7ebb9..6072394cb 100644 --- a/Source/WebKit2/UIProcess/qt/WebPreferencesQt.cpp +++ b/Source/WebKit2/UIProcess/qt/WebPreferencesQt.cpp @@ -25,7 +25,10 @@ #include "config.h" #include "WebPreferences.h" + +#include "WebPreferencesKeys.h" #include <QFont> +#include <WebCore/NotImplemented.h> namespace WebKit { @@ -62,22 +65,51 @@ void WebPreferences::platformInitializeStore() void WebPreferences::platformUpdateStringValueForKey(const String&, const String&) { + notImplemented(); } void WebPreferences::platformUpdateBoolValueForKey(const String&, bool) { + notImplemented(); } void WebPreferences::platformUpdateUInt32ValueForKey(const String&, uint32_t) { + notImplemented(); } void WebPreferences::platformUpdateDoubleValueForKey(const String&, double) { + notImplemented(); } void WebPreferences::platformUpdateFloatValueForKey(const String&, float) { + notImplemented(); +} + +bool WebPreferences::platformGetStringUserValueForKey(const String&, String&) +{ + notImplemented(); + return false; +} + +bool WebPreferences::platformGetBoolUserValueForKey(const String&, bool&) +{ + notImplemented(); + return false; +} + +bool WebPreferences::platformGetUInt32UserValueForKey(const String&, uint32_t&) +{ + notImplemented(); + return false; +} + +bool WebPreferences::platformGetDoubleUserValueForKey(const String&, double&) +{ + notImplemented(); + return false; } } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/qt/WebProcessPoolQt.cpp b/Source/WebKit2/UIProcess/qt/WebProcessPoolQt.cpp index 11ef5e380..e2662a7d7 100644 --- a/Source/WebKit2/UIProcess/qt/WebProcessPoolQt.cpp +++ b/Source/WebKit2/UIProcess/qt/WebProcessPoolQt.cpp @@ -27,10 +27,14 @@ #include "config.h" #include "WebProcessPool.h" +#include "NetworkProcessCreationParameters.h" +#include "QtWebContext.h" #include "WKSharedAPICast.h" +#include "WebCookieManagerProxy.h" #include "WebProcessCreationParameters.h" #include <QProcess> #include <WebCore/ApplicationCacheStorage.h> +#include <WebCore/Language.h> #if ENABLE(GEOLOCATION) #include "WebGeolocationManagerProxy.h" @@ -41,12 +45,14 @@ namespace WebKit { String WebProcessPool::legacyPlatformDefaultApplicationCacheDirectory() { - const String cacheDirectory = WebCore::cacheStorage().cacheDirectory(); +// QTFIXME +// const String cacheDirectory = WebCore::cacheStorage().cacheDirectory(); - if (cacheDirectory.isEmpty()) - return diskCacheDirectory(); +// if (cacheDirectory.isEmpty()) +// return diskCacheDirectory(); - return cacheDirectory; +// return cacheDirectory; + return API::WebsiteDataStore::defaultApplicationCacheDirectory(); } void WebProcessPool::platformInitializeWebProcess(WebProcessCreationParameters& parameters) @@ -62,15 +68,41 @@ void WebProcessPool::platformInvalidateContext() { } +void WebProcessPool::platformInitializeNetworkProcess(NetworkProcessCreationParameters& parameters) +{ + // QTFIXME + parameters.cookiePersistentStoragePath = QtWebContext::preparedStoragePath(QtWebContext::CookieStorage); + parameters.languages = WebCore::userPreferredLanguages(); +} String WebProcessPool::platformDefaultIconDatabasePath() const { - return String(); + return WebKit::QtWebContext::preparedStoragePath(WebKit::QtWebContext::IconDatabaseStorage); +} + +String WebProcessPool::legacyPlatformDefaultLocalStorageDirectory() +{ + return WebKit::QtWebContext::preparedStoragePath(WebKit::QtWebContext::LocalStorage); +} + +String WebProcessPool::legacyPlatformDefaultIndexedDBDatabaseDirectory() +{ + return WebKit::QtWebContext::preparedStoragePath(WebKit::QtWebContext::DatabaseStorage); +} + +String WebProcessPool::legacyPlatformDefaultWebSQLDatabaseDirectory() +{ + return WebKit::QtWebContext::preparedStoragePath(WebKit::QtWebContext::DatabaseStorage); +} + +String WebProcessPool::legacyPlatformDefaultMediaKeysStorageDirectory() +{ + return String(); // QTFIXME: Add MediaKeys path } -String WebProcessPool::platformDefaultLocalStorageDirectory() const +String WebProcessPool::legacyPlatformDefaultNetworkCacheDirectory() { - return String(); + return WebKit::QtWebContext::preparedStoragePath(WebKit::QtWebContext::DiskCacheStorage); } } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/InjectedBundle/qt/InjectedBundleQt.cpp b/Source/WebKit2/WebProcess/InjectedBundle/qt/InjectedBundleQt.cpp index 9f5ff5d0e..2334856ef 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/qt/InjectedBundleQt.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/qt/InjectedBundleQt.cpp @@ -34,8 +34,12 @@ using namespace WebCore; namespace WebKit { -bool InjectedBundle::load(APIObject* initializationUserData) +bool InjectedBundle::initialize(const WebProcessCreationParameters&, API::Object* initializationUserData) { + // Built-in bundle + if (m_path.isEmpty()) + return true; + m_platformBundle.setFileName(static_cast<QString>(m_path)); if (!m_platformBundle.load()) { qWarning("Error loading the injected bundle: %s", qPrintable(m_platformBundle.errorString())); @@ -54,4 +58,12 @@ bool InjectedBundle::load(APIObject* initializationUserData) return true; } +void InjectedBundle::setBundleParameter(const WTF::String&, const IPC::DataReference&) +{ +} + +void InjectedBundle::setBundleParameters(const IPC::DataReference&) +{ +} + } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/Network/WebLoaderStrategy.cpp b/Source/WebKit2/WebProcess/Network/WebLoaderStrategy.cpp index f18ddd2c5..ad042e53e 100644 --- a/Source/WebKit2/WebProcess/Network/WebLoaderStrategy.cpp +++ b/Source/WebKit2/WebProcess/Network/WebLoaderStrategy.cpp @@ -38,8 +38,11 @@ #include "WebFrameLoaderClient.h" #include "WebFrameNetworkingContext.h" #include "WebPage.h" +#include "WebPageProxyMessages.h" #include "WebProcess.h" #include "WebResourceLoader.h" +#include "WebURLSchemeHandlerProxy.h" +#include "WebURLSchemeHandlerTaskProxy.h" #include <WebCore/ApplicationCacheHost.h> #include <WebCore/CachedResource.h> #include <WebCore/Document.h> @@ -130,6 +133,13 @@ void WebLoaderStrategy::scheduleLoad(ResourceLoader* resourceLoader, CachedResou ResourceLoadIdentifier identifier = resourceLoader->identifier(); ASSERT(identifier); + // FIXME: Some entities in WebCore use WebCore's "EmptyFrameLoaderClient" instead of having a proper WebFrameLoaderClient. + // EmptyFrameLoaderClient shouldn't exist and everything should be using a WebFrameLoaderClient, + // but in the meantime we have to make sure not to mis-cast. + WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(resourceLoader->frameLoader()->client()); + WebFrame* webFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : nullptr; + WebPage* webPage = webFrame ? webFrame->page() : nullptr; + #if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML) // If the DocumentLoader schedules this as an archive resource load, // then we should remember the ResourceLoader in our records but not schedule it in the NetworkProcess. @@ -170,18 +180,21 @@ void WebLoaderStrategy::scheduleLoad(ResourceLoader* resourceLoader, CachedResou } #endif + if (webPage) { + if (auto* handler = webPage->urlSchemeHandlerForScheme(resourceLoader->request().url().protocol())) { + LOG(NetworkScheduling, "(WebProcess) WebLoaderStrategy::scheduleLoad, URL '%s' will be handled by a UIProcess URL scheme handler.", resourceLoader->url().string().utf8().data()); + //RELEASE_LOG_IF_ALLOWED(resourceLoader, "scheduleLoad: URL will be handled by a UIProcess URL scheme handler (frame = %p, resourceID = %" PRIu64 ")", resourceLoader->frame(), identifier); + + handler->startNewTask(*resourceLoader); + return; + } + } + LOG(NetworkScheduling, "(WebProcess) WebLoaderStrategy::scheduleLoad, url '%s' will be scheduled with the NetworkProcess with priority %d", resourceLoader->url().string().utf8().data(), static_cast<int>(resourceLoader->request().priority())); ContentSniffingPolicy contentSniffingPolicy = resourceLoader->shouldSniffContent() ? SniffContent : DoNotSniffContent; StoredCredentials allowStoredCredentials = resourceLoader->shouldUseCredentialStorage() ? AllowStoredCredentials : DoNotAllowStoredCredentials; - // FIXME: Some entities in WebCore use WebCore's "EmptyFrameLoaderClient" instead of having a proper WebFrameLoaderClient. - // EmptyFrameLoaderClient shouldn't exist and everything should be using a WebFrameLoaderClient, - // but in the meantime we have to make sure not to mis-cast. - WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(resourceLoader->frameLoader()->client()); - WebFrame* webFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0; - WebPage* webPage = webFrame ? webFrame->page() : 0; - NetworkResourceLoadParameters loadParameters; loadParameters.identifier = identifier; loadParameters.webPageID = webPage ? webPage->pageID() : 0; @@ -239,6 +252,11 @@ void WebLoaderStrategy::remove(ResourceLoader* resourceLoader) m_internallyFailedResourceLoaders.remove(resourceLoader); return; } + + if (auto task = m_urlSchemeHandlerTasks.take(resourceLoader->identifier())) { + task->stopLoading(); + return; + } ResourceLoadIdentifier identifier = resourceLoader->identifier(); if (!identifier) { diff --git a/Source/WebKit2/WebProcess/Network/WebLoaderStrategy.h b/Source/WebKit2/WebProcess/Network/WebLoaderStrategy.h index eea6c06b1..471ad4bbe 100644 --- a/Source/WebKit2/WebProcess/Network/WebLoaderStrategy.h +++ b/Source/WebKit2/WebProcess/Network/WebLoaderStrategy.h @@ -35,6 +35,7 @@ namespace WebKit { class NetworkProcessConnection; +class WebURLSchemeHandlerTaskProxy; typedef uint64_t ResourceLoadIdentifier; class WebLoaderStrategy : public WebCore::LoaderStrategy { @@ -72,6 +73,7 @@ private: RunLoop::Timer<WebLoaderStrategy> m_internallyFailedLoadTimer; HashMap<unsigned long, RefPtr<WebResourceLoader>> m_webResourceLoaders; + HashMap<unsigned long, std::unique_ptr<WebURLSchemeHandlerTaskProxy>> m_urlSchemeHandlerTasks; }; } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp index ee7d32600..c612f0a30 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp @@ -107,7 +107,7 @@ static Display* getPluginDisplay() static inline int x11Screen() { #if PLATFORM(QT) - return XDefaultScreen(NetscapePlugin::x11HostDisplay()); + return XDefaultScreen(x11HostDisplay()); #elif PLATFORM(GTK) return gdk_screen_get_number(gdk_screen_get_default()); #elif PLATFORM(EFL) && defined(HAVE_ECORE_X) @@ -120,7 +120,7 @@ static inline int x11Screen() static inline int displayDepth() { #if PLATFORM(QT) - return XDefaultDepth(NetscapePlugin::x11HostDisplay(), x11Screen()); + return XDefaultDepth(x11HostDisplay(), x11Screen()); #elif PLATFORM(GTK) return gdk_visual_get_depth(gdk_screen_get_system_visual(gdk_screen_get_default())); #elif PLATFORM(EFL) && defined(HAVE_ECORE_X) @@ -133,7 +133,7 @@ static inline int displayDepth() static inline unsigned long rootWindowID() { #if PLATFORM(QT) - return XDefaultRootWindow(NetscapePlugin::x11HostDisplay()); + return XDefaultRootWindow(x11HostDisplay()); #elif PLATFORM(GTK) return GDK_ROOT_WINDOW(); #elif PLATFORM(EFL) && defined(HAVE_ECORE_X) @@ -336,9 +336,9 @@ void NetscapePluginX11::paint(GraphicsContext& context, const IntRect& dirtyRect XSync(m_pluginDisplay, false); #if PLATFORM(QT) - XImage* xImage = XGetImage(NetscapePlugin::x11HostDisplay(), m_drawable, exposedRect.x(), exposedRect.y(), + XImage* xImage = XGetImage(x11HostDisplay(), m_drawable.get(), exposedRect.x(), exposedRect.y(), exposedRect.width(), exposedRect.height(), ULONG_MAX, ZPixmap); - QPainter* painter = context->platformContext(); + QPainter* painter = context.platformContext(); painter->drawImage(QPoint(exposedRect.x(), exposedRect.y()), qimageFromXImage(xImage), exposedRect); XDestroyImage(xImage); diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp index 5c341bacf..c166b072b 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp @@ -1329,7 +1329,11 @@ void WebFrameLoaderClient::transitionToCommittedForNewPage() m_frameHasCustomContentProvider = isMainFrame && webPage->shouldUseCustomContentProviderForResponse(response); m_frameCameFromPageCache = false; +#if PLATFORM(QT) + ScrollbarMode defaultScrollbarMode = ScrollbarAuto; +#else ScrollbarMode defaultScrollbarMode = shouldHideScrollbars ? ScrollbarAlwaysOff : ScrollbarAuto; +#endif m_frame->coreFrame()->createView(webPage->size(), backgroundColor, isTransparent, webPage->fixedLayoutSize(), fixedVisibleContentRect, shouldUseFixedLayout, diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/qt/WebFrameNetworkingContext.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/qt/WebFrameNetworkingContext.cpp index e17ca0376..e8718777e 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/qt/WebFrameNetworkingContext.cpp +++ b/Source/WebKit2/WebProcess/WebCoreSupport/qt/WebFrameNetworkingContext.cpp @@ -20,10 +20,15 @@ #include "config.h" #include "WebFrameNetworkingContext.h" +#include "SessionTracker.h" #include "WebFrame.h" #include "WebPage.h" + #include <QObject> #include <QVariant> +#include <WebCore/SessionID.h> + +using namespace WebCore; namespace WebKit { @@ -38,9 +43,45 @@ WebFrameNetworkingContext::WebFrameNetworkingContext(WebFrame* frame) } } -PassRefPtr<WebFrameNetworkingContext> WebFrameNetworkingContext::create(WebFrame* frame) +Ref<WebFrameNetworkingContext> WebFrameNetworkingContext::create(WebFrame* frame) +{ + return adoptRef(*new WebFrameNetworkingContext(frame)); +} + +void WebFrameNetworkingContext::ensurePrivateBrowsingSession(SessionID sessionID) +{ + ASSERT(isMainThread()); + + if (SessionTracker::storageSession(sessionID)) + return; + + SessionTracker::setSession(sessionID, NetworkStorageSession::createPrivateBrowsingSession(String::number(sessionID.sessionID()))); +} + +WebFrameLoaderClient* WebFrameNetworkingContext::webFrameLoaderClient() const { - return adoptRef(new WebFrameNetworkingContext(frame)); + if (!frame()) + return nullptr; + + return toWebFrameLoaderClient(frame()->loader().client()); +} + +QNetworkAccessManager* WebFrameNetworkingContext::networkAccessManager() const +{ + // QTFIXME: This is a leftover of old process model + // QtMM player may call networkAccessManager() in WebProcess + // so we cannot just have ASSERT here. + qWarning("QtWebKit bug: WebFrameNetworkingContext::networkAccessManager() is called"); + return nullptr; +} + +WebCore::NetworkStorageSession& WebFrameNetworkingContext::storageSession() const +{ + if (frame() && frame()->page()->usesEphemeralSession()) + return *SessionTracker::storageSession(SessionID::legacyPrivateSessionID()); + + return NetworkStorageSession::defaultStorageSession(); + } } diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/qt/WebFrameNetworkingContext.h b/Source/WebKit2/WebProcess/WebCoreSupport/qt/WebFrameNetworkingContext.h index 8e72baef6..02527313d 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/qt/WebFrameNetworkingContext.h +++ b/Source/WebKit2/WebProcess/WebCoreSupport/qt/WebFrameNetworkingContext.h @@ -26,10 +26,15 @@ namespace WebKit { class WebFrame; +class WebFrameLoaderClient; class WebFrameNetworkingContext : public WebCore::FrameNetworkingContext { public: - static PassRefPtr<WebFrameNetworkingContext> create(WebFrame*); + static Ref<WebFrameNetworkingContext> create(WebFrame*); + + static void ensurePrivateBrowsingSession(WebCore::SessionID); + + WebFrameLoaderClient* webFrameLoaderClient() const; QObject* originatingObject() const override { return m_originatingObject.get(); } @@ -37,9 +42,10 @@ private: WebFrameNetworkingContext(WebFrame*); ~WebFrameNetworkingContext() { } - QNetworkAccessManager* networkAccessManager() const override { return WebProcess::singleton().networkAccessManager(); } + QNetworkAccessManager* networkAccessManager() const override; bool mimeSniffingEnabled() const override { return m_mimeSniffingEnabled; } bool thirdPartyCookiePolicyPermission(const QUrl&) const override { /*TODO. Used QWebSettings in WK1.*/ return true; } + WebCore::NetworkStorageSession& storageSession() const override; std::unique_ptr<QObject> m_originatingObject; bool m_mimeSniffingEnabled; diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.cpp b/Source/WebKit2/WebProcess/WebPage/WebPage.cpp index 6eafa5123..c8d54d523 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebPage.cpp +++ b/Source/WebKit2/WebProcess/WebPage/WebPage.cpp @@ -100,6 +100,7 @@ #include "WebProcessProxyMessages.h" #include "WebProgressTrackerClient.h" #include "WebStorageNamespaceProvider.h" +#include "WebURLSchemeHandlerProxy.h" #include "WebUndoStep.h" #include "WebUserContentController.h" #include "WebUserMediaClient.h" @@ -313,11 +314,6 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters) , m_formClient(std::make_unique<API::InjectedBundle::FormClient>()) , m_uiClient(std::make_unique<API::InjectedBundle::PageUIClient>()) , m_findController(this) -#if ENABLE(TOUCH_EVENTS) -#if PLATFORM(QT) - , m_tapHighlightController(this) -#endif -#endif #if ENABLE(INPUT_TYPE_COLOR) , m_activeColorChooser(0) #endif @@ -561,6 +557,9 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters) #if PLATFORM(IOS) m_page->settings().setContentDispositionAttachmentSandboxEnabled(true); #endif + + for (auto iterator : parameters.urlSchemeHandlers) + registerURLSchemeHandler(iterator.value, iterator.key); } void WebPage::reinitializeWebPage(const WebPageCreationParameters& parameters) @@ -797,6 +796,18 @@ WebCore::WebGLLoadPolicy WebPage::resolveWebGLPolicyForURL(WebFrame*, const Stri } #endif +#if PLATFORM(QT) + +static Element* rootEditableElementRespectingShadowTree(const Frame& frame) +{ + Element* selectionRoot = frame.selection().selection().rootEditableElement(); + if (selectionRoot && selectionRoot->isInShadowTree()) + selectionRoot = selectionRoot->shadowHost(); + return selectionRoot; +} + +#endif + EditorState WebPage::editorState(IncludePostLayoutDataHint shouldIncludePostLayoutData) const { Frame& frame = m_page->focusController().focusedOrMainFrame(); @@ -828,7 +839,7 @@ EditorState WebPage::editorState(IncludePostLayoutDataHint shouldIncludePostLayo size_t location = 0; size_t length = 0; - Element* selectionRoot = frame.selection().rootEditableElementRespectingShadowTree(); + Element* selectionRoot = rootEditableElementRespectingShadowTree(frame); Element* scope = selectionRoot ? selectionRoot : frame.document()->documentElement(); if (!scope) @@ -857,14 +868,14 @@ EditorState WebPage::editorState(IncludePostLayoutDataHint shouldIncludePostLayo } } - if (selectionRoot) - result.editorRect = frame.view()->contentsToWindow(selectionRoot->pixelSnappedBoundingBox()); + if (selectionRoot && selectionRoot->renderer()) + result.editorRect = frame.view()->contentsToWindow(selectionRoot->renderer()->absoluteBoundingBoxRect()); RefPtr<Range> range; if (result.hasComposition && (range = frame.editor().compositionRange())) { frame.editor().getCompositionSelection(result.anchorPosition, result.cursorPosition); - result.compositionRect = frame.view()->contentsToWindow(range->boundingBox()); + result.compositionRect = frame.view()->contentsToWindow(range->absoluteBoundingBox()); } if (!result.hasComposition && !result.selectionIsNone && (range = frame.selection().selection().firstRange())) { @@ -5312,4 +5323,42 @@ void WebPage::didRestoreScrollPosition() send(Messages::WebPageProxy::DidRestoreScrollPosition()); } +WebURLSchemeHandlerProxy* WebPage::urlSchemeHandlerForScheme(const String& scheme) +{ + return m_schemeToURLSchemeHandlerProxyMap.get(scheme); +} + +void WebPage::registerURLSchemeHandler(uint64_t handlerIdentifier, const String& scheme) +{ + auto schemeResult = m_schemeToURLSchemeHandlerProxyMap.add(scheme, std::make_unique<WebURLSchemeHandlerProxy>(*this, handlerIdentifier)); + ASSERT(schemeResult.isNewEntry); + + auto identifierResult = m_identifierToURLSchemeHandlerProxyMap.add(handlerIdentifier, schemeResult.iterator->value.get()); + ASSERT_UNUSED(identifierResult, identifierResult.isNewEntry); +} + +void WebPage::urlSchemeHandlerTaskDidReceiveResponse(uint64_t handlerIdentifier, uint64_t taskIdentifier, const ResourceResponse& response) +{ + auto* handler = m_identifierToURLSchemeHandlerProxyMap.get(handlerIdentifier); + ASSERT(handler); + + handler->taskDidReceiveResponse(taskIdentifier, response); +} + +void WebPage::urlSchemeHandlerTaskDidReceiveData(uint64_t handlerIdentifier, uint64_t taskIdentifier, const IPC::DataReference& data) +{ + auto* handler = m_identifierToURLSchemeHandlerProxyMap.get(handlerIdentifier); + ASSERT(handler); + + handler->taskDidReceiveData(taskIdentifier, data.size(), data.data()); +} + +void WebPage::urlSchemeHandlerTaskDidComplete(uint64_t handlerIdentifier, uint64_t taskIdentifier, const ResourceError& error) +{ + auto* handler = m_identifierToURLSchemeHandlerProxyMap.get(handlerIdentifier); + ASSERT(handler); + + handler->taskDidComplete(taskIdentifier, error); +} + } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.h b/Source/WebKit2/WebProcess/WebPage/WebPage.h index a41239ac6..e279e7463 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebPage.h +++ b/Source/WebKit2/WebProcess/WebPage/WebPage.h @@ -49,6 +49,7 @@ #include "ShareableBitmap.h" #include "UserData.h" #include "UserMediaPermissionRequestManager.h" +#include "WebURLSchemeHandler.h" #include <WebCore/DictationAlternative.h> #include <WebCore/DictionaryPopupInfo.h> #include <WebCore/DragData.h> @@ -79,13 +80,7 @@ #if PLATFORM(QT) #include "ArgumentCodersQt.h" -#include "QtNetworkAccessManager.h" -#include "QtNetworkReply.h" -#include "QtNetworkReplyData.h" -#include "QtNetworkRequestData.h" #include "TapHighlightController.h" -#include <QNetworkReply> -#include <QNetworkRequest> #endif #if HAVE(ACCESSIBILITY) && (PLATFORM(GTK) || PLATFORM(EFL)) @@ -186,6 +181,7 @@ class WebInspectorClient; class WebInspectorUI; class WebGestureEvent; class WebKeyboardEvent; +class WebURLSchemeHandlerProxy; class WebMouseEvent; class WebNotificationClient; class WebOpenPanelResultListener; @@ -805,9 +801,6 @@ public: #endif #if PLATFORM(QT) - void registerApplicationScheme(const String& scheme); - void applicationSchemeReply(const QtNetworkReplyData&); - void receivedApplicationSchemeRequest(const QNetworkRequest&, QtNetworkReply*); void setUserScripts(const Vector<String>&); #endif void wheelEvent(const WebWheelEvent&); @@ -948,6 +941,8 @@ public: void didRestoreScrollPosition(); + WebURLSchemeHandlerProxy* urlSchemeHandlerForScheme(const String&); + private: WebPage(uint64_t pageID, const WebPageCreationParameters&); @@ -1207,6 +1202,12 @@ private: void didEndRequestInstallMissingMediaPlugins(uint32_t result); #endif + void registerURLSchemeHandler(uint64_t identifier, const String& scheme); + + void urlSchemeHandlerTaskDidReceiveResponse(uint64_t handlerIdentifier, uint64_t taskIdentifier, const WebCore::ResourceResponse&); + void urlSchemeHandlerTaskDidReceiveData(uint64_t handlerIdentifier, uint64_t taskIdentifier, const IPC::DataReference&); + void urlSchemeHandlerTaskDidComplete(uint64_t handlerIdentifier, uint64_t taskIdentifier, const WebCore::ResourceError&); + uint64_t m_pageID; std::unique_ptr<WebCore::Page> m_page; @@ -1317,7 +1318,7 @@ private: FindController m_findController; #if ENABLE(TOUCH_EVENTS) && PLATFORM(QT) - TapHighlightController m_tapHighlightController; + TapHighlightController m_tapHighlightController { this }; #endif RefPtr<WebInspector> m_inspector; @@ -1432,10 +1433,6 @@ private: WebCore::Timer m_volatilityTimer; #endif -#if PLATFORM(QT) - HashMap<String, QtNetworkReply*> m_applicationSchemeReplies; -#endif - HashSet<String, ASCIICaseInsensitiveHash> m_mimeTypesWithCustomContentProviders; WebCore::Color m_backgroundColor; @@ -1470,6 +1467,9 @@ private: #if ENABLE(VIDEO) && USE(GSTREAMER) RefPtr<WebCore::MediaPlayerRequestInstallMissingPluginsCallback> m_installMediaPluginsCallback; #endif + + HashMap<String, std::unique_ptr<WebURLSchemeHandlerProxy>> m_schemeToURLSchemeHandlerProxyMap; + HashMap<uint64_t, WebURLSchemeHandlerProxy*> m_identifierToURLSchemeHandlerProxyMap; }; } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in b/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in index d6007b331..4ead600dd 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in +++ b/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in @@ -138,11 +138,6 @@ messages -> WebPage LegacyReceiver { Reload(uint64_t navigationID, bool reloadFromOrigin, bool contentBlockersEnabled, WebKit::SandboxExtension::Handle sandboxExtensionHandle) StopLoading() -#if PLATFORM(QT) - ApplicationSchemeReply(struct WebKit::QtNetworkReplyData reply) - RegisterApplicationScheme(String scheme) -#endif - StopLoadingFrame(uint64_t frameID) RestoreSession(Vector<WebKit::BackForwardListItemState> itemStates) @@ -434,4 +429,10 @@ messages -> WebPage LegacyReceiver { #if ENABLE(VIDEO) && USE(GSTREAMER) DidEndRequestInstallMissingMediaPlugins(uint32_t result) #endif + + RegisterURLSchemeHandler(uint64_t identifier, String scheme) + + URLSchemeHandlerTaskDidReceiveResponse(uint64_t providerIdentifier, uint64_t taskIdentifier, WebCore::ResourceResponse response) + URLSchemeHandlerTaskDidReceiveData(uint64_t providerIdentifier, uint64_t taskIdentifier, IPC::DataReference data) + URLSchemeHandlerTaskDidComplete(uint64_t providerIdentifier, uint64_t taskIdentifier, WebCore::ResourceError error) } diff --git a/Source/WebKit2/WebProcess/WebPage/WebURLSchemeHandlerProxy.cpp b/Source/WebKit2/WebProcess/WebPage/WebURLSchemeHandlerProxy.cpp new file mode 100644 index 000000000..7e0a8d12c --- /dev/null +++ b/Source/WebKit2/WebProcess/WebPage/WebURLSchemeHandlerProxy.cpp @@ -0,0 +1,83 @@ +/* + * 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 "WebURLSchemeHandlerProxy.h" + +#include "WebErrors.h" +#include <WebCore/ResourceLoader.h> + +using namespace WebCore; + +namespace WebKit { + +WebURLSchemeHandlerProxy::WebURLSchemeHandlerProxy(WebPage& page, uint64_t identifier) + : m_webPage(page) + , m_identifier(identifier) +{ +} + +WebURLSchemeHandlerProxy::~WebURLSchemeHandlerProxy() +{ + ASSERT(m_tasks.isEmpty()); +} + +void WebURLSchemeHandlerProxy::startNewTask(ResourceLoader& loader) +{ + auto result = m_tasks.add(loader.identifier(), std::make_unique<WebURLSchemeHandlerTaskProxy>(*this, loader)); + ASSERT(result.isNewEntry); + + result.iterator->value->startLoading(); +} + + +void WebURLSchemeHandlerProxy::taskDidReceiveResponse(uint64_t taskIdentifier, const ResourceResponse& response) +{ + auto* task = m_tasks.get(taskIdentifier); + if (!task) + return; + + task->didReceiveResponse(response); +} + +void WebURLSchemeHandlerProxy::taskDidReceiveData(uint64_t taskIdentifier, size_t size, const uint8_t* data) +{ + auto* task = m_tasks.get(taskIdentifier); + if (!task) + return; + + task->didReceiveData(size, data); +} + +void WebURLSchemeHandlerProxy::taskDidComplete(uint64_t taskIdentifier, const ResourceError& error) +{ + auto task = m_tasks.take(taskIdentifier); + if (!task) + return; + + task->didComplete(error); +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebPage/WebURLSchemeHandlerProxy.h b/Source/WebKit2/WebProcess/WebPage/WebURLSchemeHandlerProxy.h new file mode 100644 index 000000000..cefc3af1a --- /dev/null +++ b/Source/WebKit2/WebProcess/WebPage/WebURLSchemeHandlerProxy.h @@ -0,0 +1,63 @@ +/* + * 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 "WebURLSchemeHandlerTaskProxy.h" +#include <wtf/HashMap.h> + +namespace WebCore { +class ResourceError; +class ResourceLoader; +class ResourceResponse; +} + +namespace WebKit { + +class WebPage; + +class WebURLSchemeHandlerProxy { + WTF_MAKE_NONCOPYABLE(WebURLSchemeHandlerProxy); +public: + WebURLSchemeHandlerProxy(WebPage&, uint64_t identifier); + ~WebURLSchemeHandlerProxy(); + + void startNewTask(WebCore::ResourceLoader&); + + uint64_t identifier() const { return m_identifier; } + WebPage& page() { return m_webPage; } + + void taskDidReceiveResponse(uint64_t taskIdentifier, const WebCore::ResourceResponse&); + void taskDidReceiveData(uint64_t taskIdentifier, size_t, const uint8_t* data); + void taskDidComplete(uint64_t taskIdentifier, const WebCore::ResourceError&); + +private: + WebPage& m_webPage; + uint64_t m_identifier { 0 }; + + HashMap<unsigned long, std::unique_ptr<WebURLSchemeHandlerTaskProxy>> m_tasks; +}; // class WebURLSchemeHandlerProxy + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebPage/WebURLSchemeHandlerTaskProxy.cpp b/Source/WebKit2/WebProcess/WebPage/WebURLSchemeHandlerTaskProxy.cpp new file mode 100644 index 000000000..06290d11c --- /dev/null +++ b/Source/WebKit2/WebProcess/WebPage/WebURLSchemeHandlerTaskProxy.cpp @@ -0,0 +1,91 @@ +/* + * 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 "WebURLSchemeHandlerTaskProxy.h" + +#include "WebPage.h" +#include "WebPageProxyMessages.h" +#include "WebURLSchemeHandlerProxy.h" +#include <WebCore/ResourceError.h> +#include <WebCore/ResourceLoader.h> +#include <wtf/CurrentTime.h> + +using namespace WebCore; + +namespace WebKit { + +WebURLSchemeHandlerTaskProxy::WebURLSchemeHandlerTaskProxy(WebURLSchemeHandlerProxy& handler, ResourceLoader& loader) + : m_urlSchemeHandler(handler) + , m_coreLoader(&loader) + , m_request(loader.request()) +{ +} + +void WebURLSchemeHandlerTaskProxy::startLoading() +{ + ASSERT(m_coreLoader); + m_urlSchemeHandler.page().send(Messages::WebPageProxy::StartURLSchemeHandlerTask(m_urlSchemeHandler.identifier(), m_coreLoader->identifier(), m_request)); +} + +void WebURLSchemeHandlerTaskProxy::stopLoading() +{ + if (!m_coreLoader) + return; + + m_urlSchemeHandler.page().send(Messages::WebPageProxy::StopURLSchemeHandlerTask(m_urlSchemeHandler.identifier(), m_coreLoader->identifier())); + m_coreLoader = nullptr; +} + +void WebURLSchemeHandlerTaskProxy::didReceiveResponse(const ResourceResponse& response) +{ + if (!m_coreLoader) + return; + + m_coreLoader->didReceiveResponse(response); +} + +void WebURLSchemeHandlerTaskProxy::didReceiveData(size_t size, const uint8_t* data) +{ + if (!m_coreLoader) + return; + + m_coreLoader->didReceiveData(reinterpret_cast<const char*>(data), size, 0, DataPayloadType::DataPayloadBytes); +} + +void WebURLSchemeHandlerTaskProxy::didComplete(const ResourceError& error) +{ + if (!m_coreLoader) + return; + + if (error.isNull()) + m_coreLoader->didFinishLoading(0); + else + m_coreLoader->didFail(error); + + m_coreLoader = nullptr; +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/qt/QtNetworkReply.h b/Source/WebKit2/WebProcess/WebPage/WebURLSchemeHandlerTaskProxy.h index 52c36aa91..f97f26365 100644 --- a/Source/WebKit2/WebProcess/qt/QtNetworkReply.h +++ b/Source/WebKit2/WebProcess/WebPage/WebURLSchemeHandlerTaskProxy.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 Zeno Albisser <zeno@webkit.org> + * 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 @@ -23,42 +23,39 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef QtNetworkReply_h -#define QtNetworkReply_h +#pragma once -#include "QtNetworkReplyData.h" -#include "SharedMemory.h" -#include <QByteArray> -#include <QDateTime> -#include <QNetworkReply> +#include <WebCore/ResourceRequest.h> + +namespace WebCore { +class ResourceError; +class ResourceLoader; +class ResourceResponse; +} namespace WebKit { -class QtNetworkAccessManager; +class WebURLSchemeHandlerProxy; -class QtNetworkReply final : public QNetworkReply { +class WebURLSchemeHandlerTaskProxy { + WTF_MAKE_NONCOPYABLE(WebURLSchemeHandlerTaskProxy); public: - QtNetworkReply(const QNetworkRequest&, QtNetworkAccessManager* parent); + WebURLSchemeHandlerTaskProxy(WebURLSchemeHandlerProxy&, WebCore::ResourceLoader&); - qint64 readData(char *data, qint64 maxlen) final; - qint64 bytesAvailable() const final; - void setReplyData(const QtNetworkReplyData&); - void finalize(); + const WebCore::ResourceRequest& request() const { return m_request; } -protected: - void setData(const SharedMemory::Handle&, qint64 dataSize); + void startLoading(); + void stopLoading(); - void abort() final; - void close() final; - void setReadBufferSize(qint64) final; - bool canReadLine() const final; + void didReceiveResponse(const WebCore::ResourceResponse&); + void didReceiveData(size_t, const uint8_t* data); + void didComplete(const WebCore::ResourceError&); private: - qint64 m_bytesAvailable; - RefPtr<SharedMemory> m_sharedMemory; - qint64 m_sharedMemorySize; + WebURLSchemeHandlerProxy& m_urlSchemeHandler; + RefPtr<WebCore::ResourceLoader> m_coreLoader; + WebCore::ResourceRequest m_request; + }; } // namespace WebKit - -#endif // QtNetworkReply_h diff --git a/Source/WebKit2/WebProcess/WebPage/qt/WebInspectorUIQt.cpp b/Source/WebKit2/WebProcess/WebPage/qt/WebInspectorUIQt.cpp index 838627309..d72a61d6e 100644 --- a/Source/WebKit2/WebProcess/WebPage/qt/WebInspectorUIQt.cpp +++ b/Source/WebKit2/WebProcess/WebPage/qt/WebInspectorUIQt.cpp @@ -26,8 +26,6 @@ #include "config.h" #include "WebInspectorUI.h" -#if ENABLE(INSPECTOR) - #include <WebCore/NotImplemented.h> #include <wtf/text/WTFString.h> @@ -44,5 +42,3 @@ String WebInspectorUI::localizedStringsURL() } } // namespace WebKit - -#endif // ENABLE(INSPECTOR) diff --git a/Source/WebKit2/WebProcess/WebPage/qt/WebPageQt.cpp b/Source/WebKit2/WebProcess/WebPage/qt/WebPageQt.cpp index af3321926..899d09a51 100644 --- a/Source/WebKit2/WebProcess/WebPage/qt/WebPageQt.cpp +++ b/Source/WebKit2/WebProcess/WebPage/qt/WebPageQt.cpp @@ -97,6 +97,19 @@ void WebPage::platformInitialize() { } +void WebPage::platformDetach() +{ +} + +String WebPage::platformUserAgent(const WebCore::URL&) const +{ + return String(); +} + +void WebPage::platformEditorState(Frame&, EditorState&, WebPage::IncludePostLayoutDataHint) const +{ +} + void WebPage::platformPreferencesDidChange(const WebPreferencesStore&) { } @@ -288,31 +301,6 @@ PassRefPtr<SharedBuffer> WebPage::cachedResponseDataForURL(const URL&) return 0; } -void WebPage::registerApplicationScheme(const String& scheme) -{ - QtNetworkAccessManager* qnam = qobject_cast<QtNetworkAccessManager*>(WebProcess::singleton().networkAccessManager()); - if (!qnam) - return; - qnam->registerApplicationScheme(this, QString(scheme)); -} - -void WebPage::receivedApplicationSchemeRequest(const QNetworkRequest& request, QtNetworkReply* reply) -{ - QtNetworkRequestData requestData(request, reply); - m_applicationSchemeReplies.add(requestData.m_replyUuid, reply); - send(Messages::WebPageProxy::ResolveApplicationSchemeRequest(requestData)); -} - -void WebPage::applicationSchemeReply(const QtNetworkReplyData& replyData) -{ - if (!m_applicationSchemeReplies.contains(replyData.m_replyUuid)) - return; - - QtNetworkReply* networkReply = m_applicationSchemeReplies.take(replyData.m_replyUuid); - networkReply->setReplyData(replyData); - networkReply->finalize(); -} - void WebPage::selectedIndex(int32_t newIndex) { changeSelectedIndex(newIndex); diff --git a/Source/WebKit2/WebProcess/WebProcess.cpp b/Source/WebKit2/WebProcess/WebProcess.cpp index 8e6b10c21..0ca88c527 100644 --- a/Source/WebKit2/WebProcess/WebProcess.cpp +++ b/Source/WebKit2/WebProcess/WebProcess.cpp @@ -156,9 +156,6 @@ WebProcess::WebProcess() , m_hasSetCacheModel(false) , m_cacheModel(CacheModelDocumentViewer) , m_fullKeyboardAccessEnabled(false) -#if PLATFORM(QT) - , m_networkAccessManager(0) -#endif , m_textCheckerState() , m_iconDatabaseProxy(*new WebIconDatabaseProxy(this)) , m_webLoaderStrategy(*new WebLoaderStrategy) @@ -1065,13 +1062,6 @@ void WebProcess::ensureWebToDatabaseProcessConnection() #endif // ENABLED(DATABASE_PROCESS) -#if PLATFORM(QT) -void WebProcess::startTransfer(uint64_t downloadID, const String& destination) -{ - downloadManager().startTransfer(downloadID, destination); -} -#endif - void WebProcess::setEnhancedAccessibility(bool flag) { WebCore::AXObjectCache::setEnhancedUserInterfaceAccessibility(flag); diff --git a/Source/WebKit2/WebProcess/WebProcess.h b/Source/WebKit2/WebProcess/WebProcess.h index 0cb19dcf9..2acaa81e2 100644 --- a/Source/WebKit2/WebProcess/WebProcess.h +++ b/Source/WebKit2/WebProcess/WebProcess.h @@ -55,12 +55,6 @@ #include "WebSQLiteDatabaseTracker.h" #endif -#if PLATFORM(QT) -QT_BEGIN_NAMESPACE -class QNetworkAccessManager; -QT_END_NAMESPACE -#endif - namespace API { class Object; } @@ -148,10 +142,6 @@ public: const TextCheckerState& textCheckerState() const { return m_textCheckerState; } -#if PLATFORM(QT) - QNetworkAccessManager* networkAccessManager() { return m_networkAccessManager; } -#endif - void clearResourceCaches(ResourceCachesToClear = AllResourceCaches); #if ENABLE(NETSCAPE_PLUGIN_API) @@ -255,10 +245,6 @@ private: void startMemorySampler(const SandboxExtension::Handle&, const String&, const double); void stopMemorySampler(); -#if PLATFORM(QT) - void startTransfer(uint64_t downloadID, const String& destination); -#endif - void setTextCheckerState(const TextCheckerState&); void getWebCoreStatistics(uint64_t callbackID); @@ -340,10 +326,6 @@ private: bool m_fullKeyboardAccessEnabled; -#if PLATFORM(QT) - QNetworkAccessManager* m_networkAccessManager; -#endif - HashMap<uint64_t, WebFrame*> m_frameMap; typedef HashMap<const char*, std::unique_ptr<WebProcessSupplement>, PtrHash<const char*>> WebProcessSupplementMap; diff --git a/Source/WebKit2/WebProcess/WebProcess.messages.in b/Source/WebKit2/WebProcess/WebProcess.messages.in index 4811d4ad6..854fcc60e 100644 --- a/Source/WebKit2/WebProcess/WebProcess.messages.in +++ b/Source/WebKit2/WebProcess/WebProcess.messages.in @@ -63,10 +63,6 @@ messages -> WebProcess LegacyReceiver { SetTextCheckerState(struct WebKit::TextCheckerState textCheckerState) -#if PLATFORM(QT) - StartTransfer(uint64_t downloadID, String destination) -#endif - SetEnhancedAccessibility(bool flag) GetWebCoreStatistics(uint64_t callbackID) diff --git a/Source/WebKit2/WebProcess/qt/QtBuiltinBundle.cpp b/Source/WebKit2/WebProcess/qt/QtBuiltinBundle.cpp index c0894bff7..ae2c96fbb 100644 --- a/Source/WebKit2/WebProcess/qt/QtBuiltinBundle.cpp +++ b/Source/WebKit2/WebProcess/qt/QtBuiltinBundle.cpp @@ -29,6 +29,7 @@ #include "QtBuiltinBundlePage.h" #include "WKBundlePage.h" +#include "WKData.h" #include "WKNumber.h" #include "WKString.h" #include "WKStringQt.h" @@ -51,14 +52,14 @@ void QtBuiltinBundle::initialize(WKBundleRef bundle) { m_bundle = bundle; - WKBundleClient client; - memset(&client, 0, sizeof(WKBundleClient)); - client.version = kWKBundleClientCurrentVersion; - client.clientInfo = this; + WKBundleClientV1 client; + memset(&client, 0, sizeof(WKBundleClientV1)); + client.base.version = 1; + client.base.clientInfo = this; client.didCreatePage = QtBuiltinBundle::didCreatePage; client.willDestroyPage = QtBuiltinBundle::willDestroyPage; client.didReceiveMessageToPage = QtBuiltinBundle::didReceiveMessageToPage; - WKBundleSetClient(m_bundle, &client); + WKBundleSetClient(m_bundle, &client.base); } void QtBuiltinBundle::didCreatePage(WKBundleRef, WKBundlePageRef page, const void* clientInfo) @@ -92,7 +93,7 @@ void QtBuiltinBundle::didReceiveMessageToPage(WKBundlePageRef page, WKStringRef handleMessageToNavigatorQtObject(page, messageBody); else if (WKStringIsEqualToUTF8CString(messageName, "SetNavigatorQtObjectEnabled")) handleSetNavigatorQtObjectEnabled(page, messageBody); -#ifdef HAVE_WEBCHANNEL +#if ENABLE(QT_WEBCHANNEL) else if (WKStringIsEqualToUTF8CString(messageName, "MessageToNavigatorQtWebChannelTransportObject")) handleMessageToNavigatorQtWebChannelTransport(page, messageBody); #endif @@ -122,12 +123,12 @@ void QtBuiltinBundle::handleSetNavigatorQtObjectEnabled(WKBundlePageRef page, WK bundlePage->setNavigatorQtObjectEnabled(enabled); } -#ifdef HAVE_WEBCHANNEL +#if ENABLE(QT_WEBCHANNEL) void QtBuiltinBundle::handleMessageToNavigatorQtWebChannelTransport(WKBundlePageRef page, WKTypeRef messageBody) { ASSERT(messageBody); - ASSERT(WKGetTypeID(messageBody) == WKStringGetTypeID()); - WKStringRef contents = static_cast<WKStringRef>(messageBody); + ASSERT(WKGetTypeID(messageBody) == WKDataGetTypeID()); + WKDataRef contents = static_cast<WKDataRef>(messageBody); QtBuiltinBundlePage* bundlePage = m_pages.get(page); if (!bundlePage) diff --git a/Source/WebKit2/WebProcess/qt/QtBuiltinBundle.h b/Source/WebKit2/WebProcess/qt/QtBuiltinBundle.h index fea74f8c5..bf4b6c45a 100644 --- a/Source/WebKit2/WebProcess/qt/QtBuiltinBundle.h +++ b/Source/WebKit2/WebProcess/qt/QtBuiltinBundle.h @@ -56,7 +56,7 @@ public: private: void handleMessageToNavigatorQtObject(WKBundlePageRef, WKTypeRef messageBody); void handleSetNavigatorQtObjectEnabled(WKBundlePageRef, WKTypeRef messageBody); -#ifdef HAVE_WEBCHANNEL +#if ENABLE(QT_WEBCHANNEL) void handleMessageToNavigatorQtWebChannelTransport(WKBundlePageRef, WKTypeRef messageBody); #endif diff --git a/Source/WebKit2/WebProcess/qt/QtBuiltinBundlePage.cpp b/Source/WebKit2/WebProcess/qt/QtBuiltinBundlePage.cpp index 2ca4bdb1c..fa368a962 100644 --- a/Source/WebKit2/WebProcess/qt/QtBuiltinBundlePage.cpp +++ b/Source/WebKit2/WebProcess/qt/QtBuiltinBundlePage.cpp @@ -27,15 +27,20 @@ #include "config.h" #include "QtBuiltinBundlePage.h" +#include "APIData.h" #include "QtBuiltinBundle.h" #include "WKArray.h" #include "WKBundleFrame.h" +#include "WKData.h" #include "WKRetainPtr.h" #include "WKString.h" #include "WKStringPrivate.h" #include "WKStringQt.h" #include <JavaScript.h> +#include <JavaScriptCore/APICast.h> #include <JavaScriptCore/JSRetainPtr.h> +#include <QDebug> +#include <QJsonDocument> namespace WebKit { @@ -127,13 +132,31 @@ static void callOnMessage(JSObjectRef object, WKStringRef contents, WKBundlePage JSObjectCallAsFunction(context, onmessageFunction, 0, 1, &wrappedMessage, 0); } -#ifdef HAVE_WEBCHANNEL +#if ENABLE(QT_WEBCHANNEL) static JSClassRef navigatorQtWebChannelTransportObjectClass() { static JSClassRef classRef = createEmptyJSClassRef(); return classRef; } +static QByteArray convertJsonTextToBinary(const CString& textJson) +{ + QByteArray jsonData = QByteArray::fromRawData(textJson.data(), textJson.length()); + + QJsonParseError error; + QJsonDocument doc = QJsonDocument::fromJson(jsonData, &error); + if (error.error != QJsonParseError::NoError) { + qWarning() << "Failed to parse the client WebKit QWebChannel message as JSON: " << jsonData + << "Error message is:" << error.errorString(); + return QByteArray(); + } + if (!doc.isObject()) { + qWarning() << "Received WebKit QWebChannel message is not a JSON object: " << jsonData; + return QByteArray(); + } + return doc.toBinaryData(); +} + static JSValueRef qt_postWebChannelMessageCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef*) { // FIXME: should it work regardless of the thisObject? @@ -144,10 +167,16 @@ static JSValueRef qt_postWebChannelMessageCallback(JSContextRef context, JSObjec QtBuiltinBundlePage* bundlePage = reinterpret_cast<QtBuiltinBundlePage*>(JSObjectGetPrivate(thisObject)); ASSERT(bundlePage); - // TODO: can we transmit the data as JS object, instead of as a string? - JSRetainPtr<JSStringRef> jsContents = JSValueToStringCopy(context, arguments[0], 0); - WKRetainPtr<WKStringRef> contents(AdoptWK, WKStringCreateWithJSString(jsContents.get())); - bundlePage->postMessageFromNavigatorQtWebChannelTransport(contents.get()); + JSC::ExecState* exec = toJS(context); + JSC::JSLockHolder locker(exec); + + JSC::JSValue jsValue = toJS(exec, arguments[0]); + CString textJson = jsValue.toString(exec)->value(exec).utf8(); + + QByteArray message = convertJsonTextToBinary(textJson); + if (!message.isEmpty()) + bundlePage->postMessageFromNavigatorQtWebChannelTransport(WKDataCreate(reinterpret_cast<const unsigned char*>(message.data()), message.length())); + return JSValueMakeUndefined(context); } #endif @@ -157,56 +186,22 @@ QtBuiltinBundlePage::QtBuiltinBundlePage(QtBuiltinBundle* bundle, WKBundlePageRe , m_page(page) , m_navigatorQtObject(0) , m_navigatorQtObjectEnabled(false) -#ifdef HAVE_WEBCHANNEL +#if ENABLE(QT_WEBCHANNEL) , m_navigatorQtWebChannelTransportObject(0) #endif { - WKBundlePageLoaderClient loaderClient = { - kWKBundlePageLoaderClientCurrentVersion, - this, - 0, // didStartProvisionalLoadForFrame - 0, // didReceiveServerRedirectForProvisionalLoadForFrame - 0, // didFailProvisionalLoadWithErrorForFrame - 0, // didCommitLoadForFrame - 0, // didFinishDocumentLoadForFrame - 0, // didFinishLoadForFrame - 0, // didFailLoadWithErrorForFrame - 0, // didSameDocumentNavigationForFrame - 0, // didReceiveTitleForFrame - 0, // didFirstLayoutForFrame - 0, // didFirstVisuallyNonEmptyLayoutForFrame - 0, // didRemoveFrameFromHierarchy - 0, // didDisplayInsecureContentForFrame - 0, // didRunInsecureContentForFrame - didClearWindowForFrame, - 0, // didCancelClientRedirectForFrame - 0, // willPerformClientRedirectForFrame - 0, // didHandleOnloadEventsForFrame - 0, // didLayoutForFrame - 0, // didNewFirstVisuallyNonEmptyLayoutForFrame - 0, // didDetectXSSForFrame - 0, // shouldGoToBackForwardListItem - 0, // didCreateGlobalObjectForFrame - 0, // willDisconnectDOMWindowExtensionFromGlobalObject - 0, // didReconnectDOMWindowExtensionToGlobalObject - 0, // willDestroyGlobalObjectForDOMWindowExtension - 0, // didFinishProgress - 0, // shouldForceUniversalAccessFromLocalURL - 0, // didReceiveIntentForFrame - 0, // registerIntentServiceForFrame - 0, // didLayout - 0, // featuresUsedInPage - 0, // willLoadURLRequest - 0, // willLoadDataRequest - 0, // willDestroyFrame - }; - WKBundlePageSetPageLoaderClient(m_page, &loaderClient); + WKBundlePageLoaderClientV0 loaderClient; + memset(&loaderClient, 0, sizeof(WKBundlePageLoaderClientV0)); + loaderClient.base.version = 0; + loaderClient.base.clientInfo = this; + loaderClient.didClearWindowObjectForFrame = didClearWindowForFrame; + WKBundlePageSetPageLoaderClient(m_page, &loaderClient.base); } QtBuiltinBundlePage::~QtBuiltinBundlePage() { if (!m_navigatorQtObject -#ifdef HAVE_WEBCHANNEL +#if ENABLE(QT_WEBCHANNEL) && !m_navigatorQtWebChannelTransportObject #endif ) @@ -220,7 +215,7 @@ QtBuiltinBundlePage::~QtBuiltinBundlePage() if (m_navigatorQtObject) JSValueUnprotect(context, m_navigatorQtObject); -#ifdef HAVE_WEBCHANNEL +#if ENABLE(QT_WEBCHANNEL) if (m_navigatorQtWebChannelTransportObject) JSValueUnprotect(context, m_navigatorQtWebChannelTransportObject); #endif @@ -237,7 +232,7 @@ void QtBuiltinBundlePage::didClearWindowForFrame(WKBundleFrameRef frame, WKBundl return; JSGlobalContextRef context = WKBundleFrameGetJavaScriptContextForWorld(frame, world); registerNavigatorQtObject(context); -#ifdef HAVE_WEBCHANNEL +#if ENABLE(QT_WEBCHANNEL) registerNavigatorQtWebChannelTransportObject(context); #endif } @@ -270,7 +265,7 @@ void QtBuiltinBundlePage::registerNavigatorQtObject(JSGlobalContextRef context) postMessageName, &qt_postMessageCallback); } -#ifdef HAVE_WEBCHANNEL +#if ENABLE(QT_WEBCHANNEL) void QtBuiltinBundlePage::registerNavigatorQtWebChannelTransportObject(JSGlobalContextRef context) { static JSStringRef name = JSStringCreateWithUTF8CString("qtWebChannelTransport"); @@ -280,19 +275,26 @@ void QtBuiltinBundlePage::registerNavigatorQtWebChannelTransportObject(JSGlobalC postMessageName, &qt_postWebChannelMessageCallback); } -void QtBuiltinBundlePage::didReceiveMessageToNavigatorQtWebChannelTransport(WKStringRef contents) +void QtBuiltinBundlePage::didReceiveMessageToNavigatorQtWebChannelTransport(WKDataRef contents) { - callOnMessage(m_navigatorQtWebChannelTransportObject, contents, m_page); + const char* bytes = reinterpret_cast<const char*>(WKDataGetBytes(contents)); + int size = WKDataGetSize(contents); + QJsonDocument doc = QJsonDocument::fromRawData(bytes, size, QJsonDocument::BypassValidation); + ASSERT(doc.isObject()); + + QByteArray textJson = doc.toJson(QJsonDocument::Compact); + WKStringRef message = WKStringCreateWithUTF8CString(textJson.constData()); + callOnMessage(m_navigatorQtWebChannelTransportObject, message, m_page); } -void QtBuiltinBundlePage::postMessageFromNavigatorQtWebChannelTransport(WKStringRef message) +void QtBuiltinBundlePage::postMessageFromNavigatorQtWebChannelTransport(WKDataRef message) { static WKStringRef messageName = WKStringCreateWithUTF8CString("MessageFromNavigatorQtWebChannelTransportObject"); postNavigatorMessage(messageName, message); } #endif -void QtBuiltinBundlePage::postNavigatorMessage(WKStringRef messageName, WKStringRef message) +void QtBuiltinBundlePage::postNavigatorMessage(WKStringRef messageName, WKTypeRef message) { WKTypeRef body[] = { page(), message }; WKRetainPtr<WKArrayRef> messageBody(AdoptWK, WKArrayCreate(body, sizeof(body) / sizeof(WKTypeRef))); diff --git a/Source/WebKit2/WebProcess/qt/QtBuiltinBundlePage.h b/Source/WebKit2/WebProcess/qt/QtBuiltinBundlePage.h index 3c466f040..bd94afed6 100644 --- a/Source/WebKit2/WebProcess/qt/QtBuiltinBundlePage.h +++ b/Source/WebKit2/WebProcess/qt/QtBuiltinBundlePage.h @@ -53,24 +53,24 @@ public: bool navigatorQtObjectEnabled() const { return m_navigatorQtObjectEnabled; } void setNavigatorQtObjectEnabled(bool); -#ifdef HAVE_WEBCHANNEL - void postMessageFromNavigatorQtWebChannelTransport(WKStringRef message); - void didReceiveMessageToNavigatorQtWebChannelTransport(WKStringRef message); +#if ENABLE(QT_WEBCHANNEL) + void postMessageFromNavigatorQtWebChannelTransport(WKDataRef message); + void didReceiveMessageToNavigatorQtWebChannelTransport(WKDataRef message); #endif private: void registerNavigatorQtObject(JSGlobalContextRef); -#ifdef HAVE_WEBCHANNEL +#if ENABLE(QT_WEBCHANNEL) void registerNavigatorQtWebChannelTransportObject(JSGlobalContextRef); #endif - void postNavigatorMessage(WKStringRef messageName, WKStringRef message); + void postNavigatorMessage(WKStringRef messageName, WKTypeRef message); QtBuiltinBundle* m_bundle; WKBundlePageRef m_page; JSObjectRef m_navigatorQtObject; bool m_navigatorQtObjectEnabled; -#ifdef HAVE_WEBCHANNEL +#if ENABLE(QT_WEBCHANNEL) JSObjectRef m_navigatorQtWebChannelTransportObject; #endif }; diff --git a/Source/WebKit2/WebProcess/qt/QtNetworkReply.cpp b/Source/WebKit2/WebProcess/qt/QtNetworkReply.cpp deleted file mode 100644 index bcda4380b..000000000 --- a/Source/WebKit2/WebProcess/qt/QtNetworkReply.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (C) 2011 Zeno Albisser <zeno@webkit.org> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "QtNetworkReply.h" - -#include "SharedMemory.h" -#include "WebFrameNetworkingContext.h" -#include "WebPage.h" -#include "WebProcess.h" -#include <QNetworkCookie> -#include <QNetworkReply> -#include <QNetworkRequest> - -namespace WebKit { - -QtNetworkReply::QtNetworkReply(const QNetworkRequest& req, QtNetworkAccessManager* parent) - : QNetworkReply(parent) - , m_bytesAvailable(0) - , m_sharedMemorySize(0) -{ - setRequest(req); - setOperation(QNetworkAccessManager::GetOperation); - setUrl(req.url()); - setOpenMode(QIODevice::ReadOnly); -} - -void QtNetworkReply::setData(const SharedMemory::Handle& handle, qint64 dataSize) -{ - if (handle.isNull()) - return; - m_sharedMemory = SharedMemory::map(handle, SharedMemory::Protection::ReadOnly); - if (!m_sharedMemory) - return; - - m_bytesAvailable = dataSize; - m_sharedMemorySize = dataSize; -} - -void QtNetworkReply::setReplyData(const QtNetworkReplyData& replyData) -{ - if (!replyData.m_contentType.isEmpty()) - setHeader(QNetworkRequest::ContentTypeHeader, QString(replyData.m_contentType)); - setHeader(QNetworkRequest::ContentLengthHeader, QVariant::fromValue(replyData.m_contentLength)); - setData(replyData.m_dataHandle, replyData.m_contentLength); -} - -qint64 QtNetworkReply::readData(char* data, qint64 maxlen) -{ - if (!m_sharedMemory) - return 0; - - qint64 bytesRead = maxlen < m_bytesAvailable ? maxlen : m_bytesAvailable; - if (memcpy(data, static_cast<char*>(m_sharedMemory->data()) + m_sharedMemorySize - m_bytesAvailable, bytesRead)) { - m_bytesAvailable -= bytesRead; - return bytesRead; - } - return 0; -} - -qint64 QtNetworkReply::bytesAvailable() const -{ - return m_bytesAvailable + QNetworkReply::bytesAvailable(); -} - -void QtNetworkReply::abort() { } -void QtNetworkReply::close() { } -void QtNetworkReply::setReadBufferSize(qint64 size) { } -bool QtNetworkReply::canReadLine () const { return true; } - -void QtNetworkReply::finalize() -{ - QNetworkReply::setFinished(true); - emit readyRead(); - emit finished(); -} - -} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/qt/WebProcessMainQt.cpp b/Source/WebKit2/WebProcess/qt/WebProcessMainQt.cpp index 1c202cf08..2d0d7df10 100644 --- a/Source/WebKit2/WebProcess/qt/WebProcessMainQt.cpp +++ b/Source/WebKit2/WebProcess/qt/WebProcessMainQt.cpp @@ -30,9 +30,9 @@ #include "WebProcess.h" #include "WebKit2Initialize.h" +#include <QDebug> #include <QGuiApplication> #include <QList> -#include <QNetworkProxyFactory> #include <QString> #include <QStringList> #include <QUrl> @@ -45,10 +45,6 @@ #endif #endif -#ifndef NDEBUG -#include <QDebug> -#endif - #if OS(DARWIN) && !USE(UNIX_DOMAIN_SOCKETS) #include <servers/bootstrap.h> @@ -72,75 +68,6 @@ static void sleep(unsigned seconds) #endif #endif -class EnvHttpProxyFactory : public QNetworkProxyFactory { -public: - EnvHttpProxyFactory() { } - - bool initializeFromEnvironment(); - - QList<QNetworkProxy> queryProxy(const QNetworkProxyQuery& = QNetworkProxyQuery()); - -private: - QList<QNetworkProxy> m_httpProxy; - QList<QNetworkProxy> 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<QNetworkProxy> 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<QNetworkProxy> proxies; - proxies << QNetworkProxy::NoProxy; - return proxies; -} - -static void initializeProxy() -{ - QList<QNetworkProxy> proxylist = QNetworkProxyFactory::systemProxyForQuery(); - if (proxylist.count() == 1) { - QNetworkProxy proxy = proxylist.first(); - if (proxy == QNetworkProxy::NoProxy || proxy == QNetworkProxy::DefaultProxy) { - auto proxyFactory = std::make_unique<EnvHttpProxyFactory>(); - if (proxyFactory->initializeFromEnvironment()) { - QNetworkProxyFactory::setApplicationProxyFactory(proxyFactory.release()); - return; - } - } - } - QNetworkProxyFactory::setUseSystemConfiguration(true); -} - #if ENABLE(SUID_SANDBOX_LINUX) pid_t chrootMe() { @@ -204,8 +131,6 @@ Q_DECL_EXPORT int WebProcessMainQt(QGuiApplication* app) return -1; } #endif - initializeProxy(); - InitializeWebKit2(); // Create the connection. diff --git a/Source/WebKit2/WebProcess/qt/WebProcessQt.cpp b/Source/WebKit2/WebProcess/qt/WebProcessQt.cpp index f395198ef..d4864af5b 100644 --- a/Source/WebKit2/WebProcess/qt/WebProcessQt.cpp +++ b/Source/WebKit2/WebProcess/qt/WebProcessQt.cpp @@ -28,16 +28,11 @@ #include "InjectedBundle.h" #include "QtBuiltinBundle.h" -#include "QtNetworkAccessManager.h" #include "SeccompFiltersWebProcessQt.h" #include "WKBundleAPICast.h" #include "WebProcessCreationParameters.h" #include <QCoreApplication> -#include <QNetworkAccessManager> -#include <QNetworkCookieJar> -#include <QNetworkDiskCache> -#include <WebCore/CookieJarQt.h> #include <WebCore/FileSystem.h> #include <WebCore/MemoryCache.h> #include <WebCore/PageCache.h> @@ -61,11 +56,15 @@ void WebProcess::platformSetCacheModel(CacheModel cacheModel) { uint64_t physicalMemorySizeInMegabytes = WTF::ramSize() / 1024 / 1024; + // QTFIXME: leftover of old process model +#if 0 // The Mac port of WebKit2 uses a fudge factor of 1000 here to account for misalignment, however, // that tends to overestimate the memory quite a bit (1 byte misalignment ~ 48 MiB misestimation). // We use 1024 * 1023 for now to keep the estimation error down to +/- ~1 MiB. QNetworkDiskCache* diskCache = qobject_cast<QNetworkDiskCache*>(m_networkAccessManager->cache()); uint64_t freeVolumeSpace = !diskCache ? 0 : WebCore::getVolumeFreeSizeForPath(diskCache->cacheDirectory().toLocal8Bit().constData()) / 1024 / 1023; +#endif + uint64_t freeVolumeSpace = 0; // The following variables are initialised to 0 because WebProcess::calculateCacheSizes might not // set them in some rare cases. @@ -81,8 +80,11 @@ void WebProcess::platformSetCacheModel(CacheModel cacheModel) cacheTotalCapacity, cacheMinDeadCapacity, cacheMaxDeadCapacity, deadDecodedDataDeletionInterval, pageCacheCapacity, urlCacheMemoryCapacity, urlCacheDiskCapacity); + // QTFIXME: leftover of old process model +#if 0 if (diskCache) diskCache->setMaximumCacheSize(urlCacheDiskCapacity); +#endif auto& memoryCache = MemoryCache::singleton(); memoryCache.setCapacities(cacheMinDeadCapacity, cacheMaxDeadCapacity, cacheTotalCapacity); @@ -104,7 +106,7 @@ static void parentProcessDiedCallback(void*) } #endif -void WebProcess::platformInitializeWebProcess(const WebProcessCreationParameters& parameters, IPC::MessageDecoder&) +void WebProcess::platformInitializeWebProcess(WebProcessCreationParameters&& parameters) { #if ENABLE(SECCOMP_FILTERS) { @@ -113,6 +115,8 @@ void WebProcess::platformInitializeWebProcess(const WebProcessCreationParameters } #endif + // QTFIXME: leftover of old process model +#if 0 m_networkAccessManager = new QtNetworkAccessManager(this); if (!parameters.cookieStorageDirectory.isEmpty()) { @@ -128,6 +132,7 @@ void WebProcess::platformInitializeWebProcess(const WebProcessCreationParameters // The m_networkAccessManager takes ownership of the diskCache object upon the following call. m_networkAccessManager->setCache(diskCache); } +#endif #if defined(Q_OS_MACX) pid_t ppid = getppid(); @@ -142,16 +147,19 @@ void WebProcess::platformInitializeWebProcess(const WebProcessCreationParameters // We'll only install the Qt builtin bundle if we don't have one given by the UI process. // Currently only WTR provides its own bundle. if (parameters.injectedBundlePath.isEmpty()) { - InjectedBundle::create(parameters, transformHandlesToObjects(parameters.initializationUserData.object()).get()); + m_injectedBundle = InjectedBundle::create(parameters, transformHandlesToObjects(parameters.initializationUserData.object()).get()); QtBuiltinBundle::shared().initialize(toAPI(m_injectedBundle.get())); } } void WebProcess::platformTerminate() { + // QTFIXME: leftover of old process model +#if 0 delete m_networkAccessManager; m_networkAccessManager = 0; WebCore::SharedCookieJarQt::shared()->destroy(); +#endif } } // namespace WebKit diff --git a/Source/cmake/ECMGenerateHeaders.cmake b/Source/cmake/ECMGenerateHeaders.cmake index cefc82dfb..93e96dbbc 100644 --- a/Source/cmake/ECMGenerateHeaders.cmake +++ b/Source/cmake/ECMGenerateHeaders.cmake @@ -13,6 +13,8 @@ # [PREFIX <prefix>] # [REQUIRED_HEADERS <variable>] # [COMMON_HEADER <HeaderName>] +# [COMMON_HEADER_EXTRAS <HeaderName> [<HeaderName> [...]] +# [COMMON_HEADER_GUARD_NAME <guard_name>] # [RELATIVE <relative_path>]) # # For each CamelCase header name passed to HEADER_NAMES, a file of that name @@ -125,8 +127,8 @@ include(CMakeParseArguments) function(ECM_GENERATE_HEADERS camelcase_forwarding_headers_var) set(options) - set(oneValueArgs ORIGINAL OUTPUT_DIR PREFIX REQUIRED_HEADERS COMMON_HEADER RELATIVE) - set(multiValueArgs HEADER_NAMES) + set(oneValueArgs ORIGINAL OUTPUT_DIR PREFIX REQUIRED_HEADERS COMMON_HEADER COMMON_HEADER_GUARD_NAME RELATIVE) + set(multiValueArgs HEADER_NAMES COMMON_HEADER_EXTRAS) cmake_parse_arguments(EGH "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) if (EGH_UNPARSED_ARGUMENTS) @@ -207,10 +209,20 @@ function(ECM_GENERATE_HEADERS camelcase_forwarding_headers_var) #combine required headers into 1 big convenience header set(COMMON_HEADER ${EGH_OUTPUT_DIR}/${EGH_PREFIX}${EGH_COMMON_HEADER}) file(WRITE ${COMMON_HEADER} "// convenience header\n") + if(EGH_COMMON_HEADER_GUARD_NAME) + file(APPEND ${COMMON_HEADER} "#ifndef ${EGH_COMMON_HEADER_GUARD_NAME}\n") + file(APPEND ${COMMON_HEADER} "#define ${EGH_COMMON_HEADER_GUARD_NAME}\n") + endif() + foreach(_extraheader ${EGH_COMMON_HEADER_EXTRAS}) + file(APPEND ${COMMON_HEADER} "#include ${_extraheader}\n") + endforeach() foreach(_header ${_REQUIRED_HEADERS}) get_filename_component(_base ${_header} NAME) file(APPEND ${COMMON_HEADER} "#include \"${_base}\"\n") endforeach() + if(EGH_COMMON_HEADER_GUARD_NAME) + file(APPEND ${COMMON_HEADER} "#endif\n") + endif() list(APPEND ${camelcase_forwarding_headers_var} "${COMMON_HEADER}") endif() diff --git a/Source/cmake/OptionsQt.cmake b/Source/cmake/OptionsQt.cmake index cec1a3d1b..252decd05 100644 --- a/Source/cmake/OptionsQt.cmake +++ b/Source/cmake/OptionsQt.cmake @@ -86,10 +86,12 @@ if (WIN32 OR APPLE) set(USE_LIBHYPHEN_DEFAULT OFF) set(USE_GSTREAMER_DEFAULT OFF) set(USE_QT_MULTIMEDIA_DEFAULT ON) + set(ENABLE_WEBKIT2_DEFAULT OFF) else () set(USE_LIBHYPHEN_DEFAULT ON) set(USE_GSTREAMER_DEFAULT ON) set(USE_QT_MULTIMEDIA_DEFAULT OFF) + set(ENABLE_WEBKIT2_DEFAULT ON) endif () if (CMAKE_SYSTEM_NAME MATCHES "Linux") @@ -131,6 +133,8 @@ WEBKIT_OPTION_DEFINE(ENABLE_INSPECTOR_UI "Include Inspector UI into resources" P WEBKIT_OPTION_DEFINE(ENABLE_OPENGL "Whether to use OpenGL." PUBLIC ON) WEBKIT_OPTION_DEFINE(ENABLE_PRINT_SUPPORT "Enable support for printing web pages" PUBLIC ON) WEBKIT_OPTION_DEFINE(ENABLE_QT_GESTURE_EVENTS "Enable support for gesture events (required for mouse in WK2)" PUBLIC ON) +WEBKIT_OPTION_DEFINE(ENABLE_QT_WEBCHANNEL "Enable support for Qt WebChannel" PUBLIC ON) +WEBKIT_OPTION_DEFINE(ENABLE_WEBKIT2 "Enable WebKit2 (QML API)" PUBLIC ${ENABLE_WEBKIT2_DEFAULT}) WEBKIT_OPTION_DEFINE(ENABLE_X11_TARGET "Whether to enable support for the X11 windowing target." PUBLIC ${ENABLE_X11_TARGET_DEFAULT}) option(GENERATE_DOCUMENTATION "Generate HTML and QCH documentation" OFF) @@ -149,7 +153,7 @@ WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ACCELERATED_2D_CANVAS PUBLIC ON) WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ALLINONE_BUILD PUBLIC ON) WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_API_TESTS PUBLIC ON) WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_GRID_LAYOUT PUBLIC ON) -WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_DATABASE_PROCESS PUBLIC OFF) +WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_DATABASE_PROCESS PUBLIC ON) WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_DATALIST_ELEMENT PUBLIC ON) WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_DEVICE_ORIENTATION PUBLIC ON) WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_FULLSCREEN_API PUBLIC ON) @@ -185,6 +189,7 @@ WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_DOWNLOAD_ATTRIBUTE PRIVATE ON) WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_FTL_JIT PRIVATE ${ENABLE_FTL_DEFAULT}) WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_FTPDIR PRIVATE OFF) WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_INPUT_TYPE_COLOR PRIVATE ON) +WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_INPUT_TYPE_COLOR_POPOVER PRIVATE ON) WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MEDIA_CONTROLS_SCRIPT PRIVATE ON) WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MHTML PRIVATE ON) WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NOTIFICATIONS PRIVATE ON) @@ -209,6 +214,8 @@ WEBKIT_OPTION_DEPEND(ENABLE_WEB_AUDIO USE_GSTREAMER) WEBKIT_OPTION_DEPEND(ENABLE_LEGACY_WEB_AUDIO USE_GSTREAMER) WEBKIT_OPTION_DEPEND(ENABLE_MEDIA_SOURCE USE_GSTREAMER) +WEBKIT_OPTION_DEPEND(ENABLE_QT_WEBCHANNEL ENABLE_WEBKIT2) + # While it's possible to have UI-less NPAPI plugins without X11, we don't support this case yet if (UNIX AND NOT APPLE) WEBKIT_OPTION_DEPEND(ENABLE_NETSCAPE_PLUGIN_API ENABLE_X11_TARGET) @@ -237,7 +244,6 @@ if (APPLE AND CMAKE_SYSTEM_VERSION VERSION_LESS 14.0.0) endif () set(ENABLE_WEBKIT ON) -set(ENABLE_WEBKIT2 OFF) set(WTF_USE_UDIS86 1) get_target_property(QT_CORE_TYPE Qt5::Core TYPE) @@ -388,6 +394,11 @@ if (ENABLE_API_TESTS OR ENABLE_TEST_SUPPORT) list(APPEND QT_REQUIRED_COMPONENTS Test ) + if (ENABLE_WEBKIT2) + list(APPEND QT_REQUIRED_COMPONENTS + QuickTest + ) + endif () endif () if (ENABLE_GEOLOCATION) @@ -405,6 +416,20 @@ if (ENABLE_PRINT_SUPPORT) SET_AND_EXPOSE_TO_BUILD(HAVE_QTPRINTSUPPORT 1) endif () +if (ENABLE_WEBKIT2) + list(APPEND QT_REQUIRED_COMPONENTS + Quick + ) + SET_AND_EXPOSE_TO_BUILD(USE_COORDINATED_GRAPHICS TRUE) + SET_AND_EXPOSE_TO_BUILD(USE_COORDINATED_GRAPHICS_MULTIPROCESS TRUE) +endif () + +if (ENABLE_QT_WEBCHANNEL) + list(APPEND QT_REQUIRED_COMPONENTS + WebChannel + ) +endif () + find_package(Qt5 ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS ${QT_REQUIRED_COMPONENTS}) if (QT_STATIC_BUILD) foreach (qt_module ${QT_REQUIRED_COMPONENTS}) @@ -490,6 +515,17 @@ if (ENABLE_NETSCAPE_PLUGIN_API) SET_AND_EXPOSE_TO_BUILD(ENABLE_NETSCAPE_PLUGIN_METADATA_CACHE 1) SET_AND_EXPOSE_TO_BUILD(ENABLE_PLUGIN_PACKAGE_SIMPLE_HASH 1) endif () + + if (ENABLE_WEBKIT2) + if (ENABLE_X11_TARGET) + set(ENABLE_PLUGIN_PROCESS 1) + SET_AND_EXPOSE_TO_BUILD(PLUGIN_ARCHITECTURE_X11 1) + SET_AND_EXPOSE_TO_BUILD(PLUGIN_ARCHITECTURE_UNSUPPORTED 0) + else () + SET_AND_EXPOSE_TO_BUILD(PLUGIN_ARCHITECTURE_X11 0) + SET_AND_EXPOSE_TO_BUILD(PLUGIN_ARCHITECTURE_UNSUPPORTED 1) + endif () + endif () endif () if (ENABLE_X11_TARGET) diff --git a/Source/cmake/WebKitFS.cmake b/Source/cmake/WebKitFS.cmake index 41d94dc40..0d53924ce 100644 --- a/Source/cmake/WebKitFS.cmake +++ b/Source/cmake/WebKitFS.cmake @@ -31,6 +31,8 @@ set(DERIVED_SOURCES_WEBKIT_DIR "${CMAKE_BINARY_DIR}/DerivedSources/WebKit") set(DERIVED_SOURCES_WEBKIT2_DIR "${CMAKE_BINARY_DIR}/DerivedSources/WebKit2") set(DERIVED_SOURCES_WEBINSPECTORUI_DIR "${CMAKE_BINARY_DIR}/DerivedSources/WebInspectorUI") +set(FORWARDING_HEADERS_DIR ${DERIVED_SOURCES_DIR}/ForwardingHeaders) + file(MAKE_DIRECTORY ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}) file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/Source/JavaScriptCore/runtime) diff --git a/Tools/DumpRenderTree/PlatformQt.cmake b/Tools/DumpRenderTree/PlatformQt.cmake index a914dfd8d..e2e26e46d 100644 --- a/Tools/DumpRenderTree/PlatformQt.cmake +++ b/Tools/DumpRenderTree/PlatformQt.cmake @@ -1,6 +1,6 @@ list(APPEND DumpRenderTree_INCLUDE_DIRECTORIES - "${DERIVED_SOURCES_DIR}/ForwardingHeaders/QtWebKit" - "${DERIVED_SOURCES_DIR}/ForwardingHeaders/QtWebKitWidgets" + "${FORWARDING_HEADERS_DIR}/QtWebKit" + "${FORWARDING_HEADERS_DIR}/QtWebKitWidgets" "${WEBCORE_DIR}/Modules/notifications" "${WEBCORE_DIR}/platform/qt" "${WEBKIT_DIR}/qt/WebCoreSupport" diff --git a/Tools/MiniBrowser/qt/CMakeLists.txt b/Tools/MiniBrowser/qt/CMakeLists.txt new file mode 100644 index 000000000..0d5c7783f --- /dev/null +++ b/Tools/MiniBrowser/qt/CMakeLists.txt @@ -0,0 +1,64 @@ +set(MiniBrowser_INCLUDE_DIRECTORIES + ${CMAKE_BINARY_DIR} + "${CMAKE_SOURCE_DIR}/Source" + "${FORWARDING_HEADERS_DIR}/QtWebKit" + "${WEBKIT_DIR}/qt/Api" + "${WEBKIT_DIR}/qt/WebCoreSupport" + "${WEBKIT2_DIR}/UIProcess/API/qt" + ${WTF_DIR} +) + +set(MiniBrowser_QML_SOURCES + qml/AlertDialog.qml + qml/AuthenticationDialog.qml + qml/BrowserWindow.qml + qml/CheckBox.qml + qml/ColorChooser.qml + qml/ConfirmDialog.qml + qml/Dialog.qml + qml/DialogButton.qml + qml/DialogLineInput.qml + qml/FilePicker.qml + qml/ItemSelector.qml + qml/MockTouchPoint.qml + qml/PromptDialog.qml + qml/ProxyAuthenticationDialog.qml + qml/ScrollIndicator.qml + qml/ViewportInfoItem.qml +) + +set(QML_IMPORT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/qml ${CMAKE_BINARY_DIR}/imports + CACHE STRING "" FORCE) + +set(MiniBrowser_SOURCES + BrowserWindow.cpp + MiniBrowserApplication.cpp + UrlLoader.cpp + main.cpp + utils.cpp + ${MiniBrowser_QML_SOURCES} +) + +qt5_add_resources(MiniBrowser_SOURCES + MiniBrowser.qrc +) + +set(MiniBrowser_SYSTEM_INCLUDE_DIRECTORIES + ${Qt5Quick_INCLUDE_DIRS} + ${Qt5Quick_PRIVATE_INCLUDE_DIRS} +) + +set(MiniBrowser_LIBRARIES + WebKit + ${Qt5Quick_LIBRARIES} +) + +if (ENABLE_TEST_SUPPORT) + add_definitions(-DHAVE_QTTESTSUPPORT) +endif () + +include_directories(${MiniBrowser_INCLUDE_DIRECTORIES}) +include_directories(SYSTEM ${MiniBrowser_SYSTEM_INCLUDE_DIRECTORIES}) +add_executable(MiniBrowser ${MiniBrowser_SOURCES}) +target_link_libraries(MiniBrowser ${MiniBrowser_LIBRARIES}) +set_target_properties(MiniBrowser PROPERTIES FOLDER "Tools") diff --git a/Tools/MiniBrowser/qt/MiniBrowserApplication.cpp b/Tools/MiniBrowser/qt/MiniBrowserApplication.cpp index f2eadba94..7dbb4c519 100644 --- a/Tools/MiniBrowser/qt/MiniBrowserApplication.cpp +++ b/Tools/MiniBrowser/qt/MiniBrowserApplication.cpp @@ -330,7 +330,8 @@ void MiniBrowserApplication::handleUserOptions() if (useDesktopBehavior) windowOptions()->setTouchMockingEnabled(false); - QQuickWebViewExperimental::setFlickableViewportEnabled(!useDesktopBehavior); + // QTFIXME: flickable viewport has painting artifacts so we cannot enable it by default + // QQuickWebViewExperimental::setFlickableViewportEnabled(!useDesktopBehavior); if (!useDesktopBehavior) qputenv("QT_WEBKIT_USE_MOBILE_THEME", QByteArray("1")); m_windowOptions.setPrintLoadedUrls(takeOptionFlag(&args, "-v")); diff --git a/Tools/PlatformQt.cmake b/Tools/PlatformQt.cmake index 311156446..9c5548aa3 100644 --- a/Tools/PlatformQt.cmake +++ b/Tools/PlatformQt.cmake @@ -2,7 +2,7 @@ remove_definitions(-DQT_ASCII_CAST_WARNINGS) add_subdirectory(QtTestBrowser) -if (ENABLE_API_TESTS) +if (ENABLE_API_TESTS AND NOT ENABLE_WEBKIT2) add_subdirectory(TestWebKitAPI) endif () @@ -10,3 +10,10 @@ if (ENABLE_TEST_SUPPORT) add_subdirectory(DumpRenderTree) add_subdirectory(ImageDiff) endif () + +if (ENABLE_WEBKIT2) + add_subdirectory(MiniBrowser/qt) +endif () + +# FIXME: Remove when WK2 Tools patches are merged +set(ENABLE_WEBKIT2 0) diff --git a/Tools/QtTestBrowser/CMakeLists.txt b/Tools/QtTestBrowser/CMakeLists.txt index ab625f6e5..f43bb7852 100644 --- a/Tools/QtTestBrowser/CMakeLists.txt +++ b/Tools/QtTestBrowser/CMakeLists.txt @@ -2,9 +2,9 @@ set(QtTestBrowser_INCLUDE_DIRECTORIES "${CMAKE_BINARY_DIR}" "${CMAKE_SOURCE_DIR}/Source" "${DERIVED_SOURCES_WEBKIT_DIR}" - "${DERIVED_SOURCES_DIR}/ForwardingHeaders" - "${DERIVED_SOURCES_DIR}/ForwardingHeaders/QtWebKit" - "${DERIVED_SOURCES_DIR}/ForwardingHeaders/QtWebKitWidgets" + "${FORWARDING_HEADERS_DIR}" + "${FORWARDING_HEADERS_DIR}/QtWebKit" + "${FORWARDING_HEADERS_DIR}/QtWebKitWidgets" "${JAVASCRIPTCORE_DIR}" "${JAVASCRIPTCORE_DIR}/runtime" "${WEBCORE_DIR}" diff --git a/Tools/WebKitTestRunner/CMakeLists.txt b/Tools/WebKitTestRunner/CMakeLists.txt index b81377a6d..6355772ce 100644 --- a/Tools/WebKitTestRunner/CMakeLists.txt +++ b/Tools/WebKitTestRunner/CMakeLists.txt @@ -63,6 +63,7 @@ set(WebKitTestRunner_INCLUDE_DIRECTORIES set(WebKitTestRunner_SYSTEM_INCLUDE_DIRECTORIES ${LIBSOUP_INCLUDE_DIRS} + ${ICU_INCLUDE_DIRS} ) set(WebKitTestRunnerInjectedBundle_SOURCES diff --git a/Tools/qt/manifest.txt b/Tools/qt/manifest.txt index 8affd54a2..a09153070 100644 --- a/Tools/qt/manifest.txt +++ b/Tools/qt/manifest.txt @@ -83,6 +83,12 @@ file Source/WTF/wtf/cocoa file Source/WTF/wtf/text/cf file Source/WebCore/platform/cf/SharedBufferCF.cpp +# WK2 on Windows and macOS +file Source/WebKit2/Platform/IPC/mac +file Source/WebKit2/Platform/IPC/win +file Source/WebKit2/Platform/mac +file Source/WebKit2/Platform/win + # WK1 plugin code is in WebKit/win file Source/WebKit/win/Plugins |