diff options
Diffstat (limited to 'Source/WebKit2/WebProcess')
105 files changed, 3467 insertions, 1609 deletions
diff --git a/Source/WebKit2/WebProcess/ApplicationCache/WebApplicationCacheManager.cpp b/Source/WebKit2/WebProcess/ApplicationCache/WebApplicationCacheManager.cpp index 71ae14f..4f91e3d 100644 --- a/Source/WebKit2/WebProcess/ApplicationCache/WebApplicationCacheManager.cpp +++ b/Source/WebKit2/WebProcess/ApplicationCache/WebApplicationCacheManager.cpp @@ -30,6 +30,7 @@ #include "SecurityOriginData.h" #include "WebApplicationCacheManagerProxyMessages.h" #include "WebProcess.h" +#include <WebCore/ApplicationCache.h> #include <WebCore/ApplicationCacheStorage.h> #include <WebCore/SecurityOrigin.h> #include <WebCore/SecurityOriginHash.h> @@ -78,6 +79,7 @@ void WebApplicationCacheManager::getApplicationCacheOrigins(uint64_t callbackID) } WebProcess::shared().connection()->send(Messages::WebApplicationCacheManagerProxy::DidGetApplicationCacheOrigins(identifiers, callbackID), 0); + WebProcess::shared().terminateIfPossible(); } void WebApplicationCacheManager::deleteEntriesForOrigin(const SecurityOriginData& originData) @@ -87,8 +89,9 @@ void WebApplicationCacheManager::deleteEntriesForOrigin(const SecurityOriginData if (!origin) return; - cacheStorage().deleteEntriesForOrigin(origin.get()); + ApplicationCache::deleteCacheForOrigin(origin.get()); #endif + WebProcess::shared().terminateIfPossible(); } void WebApplicationCacheManager::deleteAllEntries() @@ -96,6 +99,7 @@ void WebApplicationCacheManager::deleteAllEntries() #if ENABLE(OFFLINE_WEB_APPLICATIONS) cacheStorage().deleteAllEntries(); #endif + WebProcess::shared().terminateIfPossible(); } } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/Authentication/AuthenticationManager.cpp b/Source/WebKit2/WebProcess/Authentication/AuthenticationManager.cpp index af35f75..e7550d0 100644 --- a/Source/WebKit2/WebProcess/Authentication/AuthenticationManager.cpp +++ b/Source/WebKit2/WebProcess/Authentication/AuthenticationManager.cpp @@ -26,6 +26,8 @@ #include "config.h" #include "AuthenticationManager.h" +#include "Download.h" +#include "DownloadProxyMessages.h" #include "MessageID.h" #include "WebCoreArgumentCoders.h" #include "WebFrame.h" @@ -35,6 +37,8 @@ #include <WebCore/AuthenticationChallenge.h> #include <WebCore/AuthenticationClient.h> +using namespace WebCore; + namespace WebKit { static uint64_t generateAuthenticationChallengeID() @@ -58,46 +62,64 @@ void AuthenticationManager::didReceiveMessage(CoreIPC::Connection* connection, C didReceiveAuthenticationManagerMessage(connection, messageID, arguments); } -void AuthenticationManager::didReceiveAuthenticationChallenge(WebFrame* frame, const WebCore::AuthenticationChallenge& authenticationChallenge) +void AuthenticationManager::didReceiveAuthenticationChallenge(WebFrame* frame, const AuthenticationChallenge& authenticationChallenge) { ASSERT(frame); ASSERT(frame->page()); - uint64_t id = generateAuthenticationChallengeID(); - m_challenges.set(id, authenticationChallenge); + uint64_t challengeID = generateAuthenticationChallengeID(); + m_challenges.set(challengeID, authenticationChallenge); - WebProcess::shared().connection()->send(Messages::WebPageProxy::DidReceiveAuthenticationChallenge(frame->frameID(), authenticationChallenge, id), frame->page()->pageID()); + WebProcess::shared().connection()->send(Messages::WebPageProxy::DidReceiveAuthenticationChallenge(frame->frameID(), authenticationChallenge, challengeID), frame->page()->pageID()); +} + +void AuthenticationManager::didReceiveAuthenticationChallenge(Download* download, const AuthenticationChallenge& authenticationChallenge) +{ + uint64_t challengeID = generateAuthenticationChallengeID(); + m_challenges.set(challengeID, authenticationChallenge); + + download->send(Messages::DownloadProxy::DidReceiveAuthenticationChallenge(authenticationChallenge, challengeID)); } -void AuthenticationManager::useCredentialForChallenge(uint64_t challengeID, const WebCore::Credential& credential) +void AuthenticationManager::useCredentialForChallenge(uint64_t challengeID, const Credential& credential) { - WebCore::AuthenticationChallenge challenge = m_challenges.take(challengeID); + AuthenticationChallenge challenge = m_challenges.take(challengeID); ASSERT(!challenge.isNull()); - WebCore::AuthenticationClient* coreClient = challenge.authenticationClient(); - if (!coreClient) + AuthenticationClient* coreClient = challenge.authenticationClient(); + if (!coreClient) { + // This authentication challenge comes from a download. + Download::receivedCredential(challenge, credential); return; + + } coreClient->receivedCredential(challenge, credential); } void AuthenticationManager::continueWithoutCredentialForChallenge(uint64_t challengeID) { - WebCore::AuthenticationChallenge challenge = m_challenges.take(challengeID); + AuthenticationChallenge challenge = m_challenges.take(challengeID); ASSERT(!challenge.isNull()); - WebCore::AuthenticationClient* coreClient = challenge.authenticationClient(); - if (!coreClient) + AuthenticationClient* coreClient = challenge.authenticationClient(); + if (!coreClient) { + // This authentication challenge comes from a download. + Download::receivedRequestToContinueWithoutCredential(challenge); return; + } coreClient->receivedRequestToContinueWithoutCredential(challenge); } void AuthenticationManager::cancelChallenge(uint64_t challengeID) { - WebCore::AuthenticationChallenge challenge = m_challenges.take(challengeID); + AuthenticationChallenge challenge = m_challenges.take(challengeID); ASSERT(!challenge.isNull()); - WebCore::AuthenticationClient* coreClient = challenge.authenticationClient(); - if (!coreClient) + AuthenticationClient* coreClient = challenge.authenticationClient(); + if (!coreClient) { + // This authentication challenge comes from a download. + Download::receivedCancellation(challenge); return; + } coreClient->receivedCancellation(challenge); } diff --git a/Source/WebKit2/WebProcess/Authentication/AuthenticationManager.h b/Source/WebKit2/WebProcess/Authentication/AuthenticationManager.h index ce5ff1c..2c67430 100644 --- a/Source/WebKit2/WebProcess/Authentication/AuthenticationManager.h +++ b/Source/WebKit2/WebProcess/Authentication/AuthenticationManager.h @@ -41,6 +41,7 @@ namespace WebCore { namespace WebKit { +class Download; class WebFrame; class AuthenticationManager { @@ -52,6 +53,7 @@ public: void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); void didReceiveAuthenticationChallenge(WebFrame*, const WebCore::AuthenticationChallenge&); + void didReceiveAuthenticationChallenge(Download*, const WebCore::AuthenticationChallenge&); void useCredentialForChallenge(uint64_t challengeID, const WebCore::Credential&); void continueWithoutCredentialForChallenge(uint64_t challengeID); diff --git a/Source/WebKit2/WebProcess/Cookies/WebCookieManager.cpp b/Source/WebKit2/WebProcess/Cookies/WebCookieManager.cpp index 1c88ee2..4181e14 100644 --- a/Source/WebKit2/WebProcess/Cookies/WebCookieManager.cpp +++ b/Source/WebKit2/WebProcess/Cookies/WebCookieManager.cpp @@ -62,21 +62,25 @@ void WebCookieManager::getHostnamesWithCookies(uint64_t callbackID) copyToVector(hostnames, hostnameList); WebProcess::shared().connection()->send(Messages::WebCookieManagerProxy::DidGetHostnamesWithCookies(hostnameList, callbackID), 0); + WebProcess::shared().terminateIfPossible(); } void WebCookieManager::deleteCookiesForHostname(const String& hostname) { WebCore::deleteCookiesForHostname(hostname); + WebProcess::shared().terminateIfPossible(); } void WebCookieManager::deleteAllCookies() { WebCore::deleteAllCookies(); + WebProcess::shared().terminateIfPossible(); } void WebCookieManager::startObservingCookieChanges() { WebCore::startObservingCookieChanges(); + WebProcess::shared().terminateIfPossible(); } void WebCookieManager::stopObservingCookieChanges() @@ -89,4 +93,16 @@ void WebCookieManager::dispatchCookiesDidChange() WebProcess::shared().connection()->send(Messages::WebCookieManagerProxy::CookiesDidChange(), 0); } +void WebCookieManager::setHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy policy) +{ + platformSetHTTPCookieAcceptPolicy(policy); + WebProcess::shared().terminateIfPossible(); +} + +void WebCookieManager::getHTTPCookieAcceptPolicy(uint64_t callbackID) +{ + WebProcess::shared().connection()->send(Messages::WebCookieManagerProxy::DidGetHTTPCookieAcceptPolicy(platformGetHTTPCookieAcceptPolicy(), callbackID), 0); + WebProcess::shared().terminateIfPossible(); +} + } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/Cookies/WebCookieManager.h b/Source/WebKit2/WebProcess/Cookies/WebCookieManager.h index 911020c..c0bd1f3 100644 --- a/Source/WebKit2/WebProcess/Cookies/WebCookieManager.h +++ b/Source/WebKit2/WebProcess/Cookies/WebCookieManager.h @@ -26,6 +26,7 @@ #ifndef WebCookieManager_h #define WebCookieManager_h +#include "HTTPCookieAcceptPolicy.h" #include <wtf/Noncopyable.h> #include <wtf/text/WTFString.h> @@ -46,6 +47,8 @@ public: void dispatchCookiesDidChange(); + void setHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy); + private: WebCookieManager(); @@ -53,6 +56,10 @@ private: void deleteCookiesForHostname(const String&); void deleteAllCookies(); + void platformSetHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy); + void getHTTPCookieAcceptPolicy(uint64_t callbackID); + HTTPCookieAcceptPolicy platformGetHTTPCookieAcceptPolicy(); + void startObservingCookieChanges(); void stopObservingCookieChanges(); diff --git a/Source/WebKit2/WebProcess/Cookies/WebCookieManager.messages.in b/Source/WebKit2/WebProcess/Cookies/WebCookieManager.messages.in index 470facb..15de9b6 100644 --- a/Source/WebKit2/WebProcess/Cookies/WebCookieManager.messages.in +++ b/Source/WebKit2/WebProcess/Cookies/WebCookieManager.messages.in @@ -27,6 +27,9 @@ void GetHostnamesWithCookies(uint64_t callbackID) void DeleteCookiesForHostname(WTF::String hostname) void DeleteAllCookies() + + void SetHTTPCookieAcceptPolicy(uint32_t policy) + void GetHTTPCookieAcceptPolicy(uint64_t callbackID) void StartObservingCookieChanges() void StopObservingCookieChanges() diff --git a/Source/WebKit2/WebProcess/Cookies/cf/WebCookieManagerCFNet.cpp b/Source/WebKit2/WebProcess/Cookies/cf/WebCookieManagerCFNet.cpp new file mode 100644 index 0000000..b0fb3d1 --- /dev/null +++ b/Source/WebKit2/WebProcess/Cookies/cf/WebCookieManagerCFNet.cpp @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "WebCookieManager.h" + +#include <CFNetwork/CFHTTPCookiesPriv.h> +#include <WebCore/CookieStorage.h> +#include <WebCore/CookieStorageCFNet.h> + +namespace WebKit { + +void WebCookieManager::platformSetHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy policy) +{ + CFHTTPCookieStorageSetCookieAcceptPolicy(WebCore::defaultCookieStorage(), policy); + + CFHTTPCookieStorageRef privateBrowsingCookieStorage = WebCore::privateBrowsingCookieStorage(); + if (!privateBrowsingCookieStorage) + return; + CFHTTPCookieStorageSetCookieAcceptPolicy(privateBrowsingCookieStorage, policy); +} + +HTTPCookieAcceptPolicy WebCookieManager::platformGetHTTPCookieAcceptPolicy() +{ + return CFHTTPCookieStorageGetCookieAcceptPolicy(WebCore::currentCookieStorage()); +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/Cookies/curl/WebCookieManagerCurl.cpp b/Source/WebKit2/WebProcess/Cookies/curl/WebCookieManagerCurl.cpp new file mode 100644 index 0000000..505082d --- /dev/null +++ b/Source/WebKit2/WebProcess/Cookies/curl/WebCookieManagerCurl.cpp @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * Copyright (C) 2011 Brent Fulgham <bfulgham@webkit.org>. 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 "WebCookieManager.h" + +#include <WebCore/CookieStorage.h> +#include <WebCore/NotImplemented.h> + +namespace WebKit { + +void WebCookieManager::platformSetHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy policy) +{ + // Fixme: To be implemented + notImplemented(); +} + +HTTPCookieAcceptPolicy WebCookieManager::platformGetHTTPCookieAcceptPolicy() +{ + notImplemented(); + return HTTPCookieAcceptPolicyOnlyFromMainDocumentDomain; +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/Cookies/gtk/WebCookieManagerGtk.cpp b/Source/WebKit2/WebProcess/Cookies/gtk/WebCookieManagerGtk.cpp new file mode 100644 index 0000000..acdd608 --- /dev/null +++ b/Source/WebKit2/WebProcess/Cookies/gtk/WebCookieManagerGtk.cpp @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "WebCookieManager.h" + +namespace WebKit { + +void WebCookieManager::platformSetHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy) +{ + // FIXME: Not implemented. +} + +HTTPCookieAcceptPolicy WebCookieManager::platformGetHTTPCookieAcceptPolicy() +{ + // FIXME: Not implemented. + return HTTPCookieAcceptPolicyAlways; +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/Cookies/mac/WebCookieManagerMac.mm b/Source/WebKit2/WebProcess/Cookies/mac/WebCookieManagerMac.mm new file mode 100644 index 0000000..cf73622 --- /dev/null +++ b/Source/WebKit2/WebProcess/Cookies/mac/WebCookieManagerMac.mm @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import "config.h" +#import "WebCookieManager.h" + +namespace WebKit { + +void WebCookieManager::platformSetHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy policy) +{ + [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookieAcceptPolicy:policy]; + +#if USE(CFURLSTORAGESESSIONS) + // FIXME: Also update the Private Browsing Storage Session's cookie storage. +#endif +} + +HTTPCookieAcceptPolicy WebCookieManager::platformGetHTTPCookieAcceptPolicy() +{ + return [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookieAcceptPolicy]; +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/Cookies/qt/WebCookieManagerQt.cpp b/Source/WebKit2/WebProcess/Cookies/qt/WebCookieManagerQt.cpp new file mode 100644 index 0000000..acdd608 --- /dev/null +++ b/Source/WebKit2/WebProcess/Cookies/qt/WebCookieManagerQt.cpp @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "WebCookieManager.h" + +namespace WebKit { + +void WebCookieManager::platformSetHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy) +{ + // FIXME: Not implemented. +} + +HTTPCookieAcceptPolicy WebCookieManager::platformGetHTTPCookieAcceptPolicy() +{ + // FIXME: Not implemented. + return HTTPCookieAcceptPolicyAlways; +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/Downloads/Download.cpp b/Source/WebKit2/WebProcess/Downloads/Download.cpp index 1c36df2..3fc87d9 100644 --- a/Source/WebKit2/WebProcess/Downloads/Download.cpp +++ b/Source/WebKit2/WebProcess/Downloads/Download.cpp @@ -26,6 +26,7 @@ #include "config.h" #include "Download.h" +#include "AuthenticationManager.h" #include "Connection.h" #include "DataReference.h" #include "DownloadProxyMessages.h" @@ -68,6 +69,11 @@ void Download::didStart() send(Messages::DownloadProxy::DidStart(m_request)); } +void Download::didReceiveAuthenticationChallenge(const AuthenticationChallenge& authenticationChallenge) +{ + AuthenticationManager::shared().didReceiveAuthenticationChallenge(this, authenticationChallenge); +} + void Download::didReceiveResponse(const ResourceResponse& response) { send(Messages::DownloadProxy::DidReceiveResponse(response)); diff --git a/Source/WebKit2/WebProcess/Downloads/Download.h b/Source/WebKit2/WebProcess/Downloads/Download.h index 26d8f3d..780e8c2 100644 --- a/Source/WebKit2/WebProcess/Downloads/Download.h +++ b/Source/WebKit2/WebProcess/Downloads/Download.h @@ -47,6 +47,8 @@ namespace CoreIPC { } namespace WebCore { + class AuthenticationChallenge; + class Credential; class ResourceError; class ResourceHandle; class ResourceResponse; @@ -74,6 +76,7 @@ public: uint64_t downloadID() const { return m_downloadID; } void didStart(); + void didReceiveAuthenticationChallenge(const WebCore::AuthenticationChallenge&); void didReceiveResponse(const WebCore::ResourceResponse&); void didReceiveData(uint64_t length); bool shouldDecodeSourceDataOfMIMEType(const String& mimeType); @@ -89,6 +92,11 @@ public: const String& destination() const { return m_destination; } #endif + // Authentication + static void receivedCredential(const WebCore::AuthenticationChallenge&, const WebCore::Credential&); + static void receivedRequestToContinueWithoutCredential(const WebCore::AuthenticationChallenge&); + static void receivedCancellation(const WebCore::AuthenticationChallenge&); + private: Download(uint64_t downloadID, const WebCore::ResourceRequest&); @@ -105,10 +113,10 @@ private: RetainPtr<NSURLDownload> m_nsURLDownload; RetainPtr<WKDownloadAsDelegate> m_delegate; #endif -#if USE(CFNETWORK) bool m_allowOverwrite; String m_destination; String m_bundlePath; +#if USE(CFNETWORK) RetainPtr<CFURLDownloadRef> m_download; #endif }; diff --git a/Source/WebKit2/WebProcess/Downloads/cf/win/DownloadCFNetWin.cpp b/Source/WebKit2/WebProcess/Downloads/cf/win/DownloadCFWin.cpp index 0dd6508..0dd6508 100644 --- a/Source/WebKit2/WebProcess/Downloads/cf/win/DownloadCFNetWin.cpp +++ b/Source/WebKit2/WebProcess/Downloads/cf/win/DownloadCFWin.cpp diff --git a/Source/WebKit2/WebProcess/Downloads/cf/DownloadCFNet.cpp b/Source/WebKit2/WebProcess/Downloads/cfnet/DownloadCFNet.cpp index 3215039..170c6aa 100644 --- a/Source/WebKit2/WebProcess/Downloads/cf/DownloadCFNet.cpp +++ b/Source/WebKit2/WebProcess/Downloads/cfnet/DownloadCFNet.cpp @@ -70,6 +70,8 @@ void Download::start(WebPage*) CFURLDownloadScheduleWithCurrentMessageQueue(m_download.get()); CFURLDownloadScheduleDownloadWithRunLoop(m_download.get(), loaderRunLoop(), kCFRunLoopDefaultMode); + + CFURLDownloadStart(m_download.get()); } void Download::startWithHandle(WebPage*, ResourceHandle* handle, const ResourceRequest& initialRequest, const ResourceResponse& response) @@ -206,4 +208,19 @@ void didFailCallback(CFURLDownloadRef, CFErrorRef error, const void* clientInfo) downloadFromClientInfo(clientInfo)->didFail(ResourceError(error), dataReference); } +void Download::receivedCredential(const AuthenticationChallenge& authenticationChallenge, const Credential& credential) +{ + notImplemented(); +} + +void Download::receivedRequestToContinueWithoutCredential(const AuthenticationChallenge& authenticationChallenge) +{ + notImplemented(); +} + +void Download::receivedCancellation(const AuthenticationChallenge& authenticationChallenge) +{ + notImplemented(); +} + } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/Downloads/curl/DownloadCurl.cpp b/Source/WebKit2/WebProcess/Downloads/curl/DownloadCurl.cpp index 6ebce01..0466e7c 100644 --- a/Source/WebKit2/WebProcess/Downloads/curl/DownloadCurl.cpp +++ b/Source/WebKit2/WebProcess/Downloads/curl/DownloadCurl.cpp @@ -58,7 +58,17 @@ void Download::didDecideDestination(const String& destination, bool allowOverwri notImplemented(); } -void Download::platformDidFinish() +void Download::receivedCredential(const AuthenticationChallenge& authenticationChallenge, const Credential& credential) +{ + notImplemented(); +} + +void Download::receivedRequestToContinueWithoutCredential(const AuthenticationChallenge& authenticationChallenge) +{ + notImplemented(); +} + +void Download::receivedCancellation(const AuthenticationChallenge& authenticationChallenge) { notImplemented(); } diff --git a/Source/WebKit2/WebProcess/Downloads/mac/DownloadMac.mm b/Source/WebKit2/WebProcess/Downloads/mac/DownloadMac.mm index f7fe8dc..2d09612 100644 --- a/Source/WebKit2/WebProcess/Downloads/mac/DownloadMac.mm +++ b/Source/WebKit2/WebProcess/Downloads/mac/DownloadMac.mm @@ -26,6 +26,7 @@ #import "config.h" #import "Download.h" +#import <WebCore/AuthenticationMac.h> #import <WebCore/BackForwardController.h> #import <WebCore/HistoryItem.h> #import <WebCore/NotImplemented.h> @@ -177,6 +178,21 @@ void Download::platformDidFinish() { } +void Download::receivedCredential(const AuthenticationChallenge& authenticationChallenge, const Credential& credential) +{ + [authenticationChallenge.sender() useCredential:mac(credential) forAuthenticationChallenge:authenticationChallenge.nsURLAuthenticationChallenge()]; +} + +void Download::receivedRequestToContinueWithoutCredential(const AuthenticationChallenge& authenticationChallenge) +{ + [authenticationChallenge.sender() continueWithoutCredentialForAuthenticationChallenge:authenticationChallenge.nsURLAuthenticationChallenge()]; +} + +void Download::receivedCancellation(const AuthenticationChallenge& authenticationChallenge) +{ + [authenticationChallenge.sender() cancelAuthenticationChallenge:authenticationChallenge.nsURLAuthenticationChallenge()]; +} + } // namespace WebKit @implementation WKDownloadAsDelegate @@ -216,8 +232,8 @@ void Download::platformDidFinish() - (void)download:(NSURLDownload *)download didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge { - // FIXME: Implement. - notImplemented(); + if (_download) + _download->didReceiveAuthenticationChallenge(core(challenge)); } - (void)download:(NSURLDownload *)download didCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge @@ -228,9 +244,7 @@ void Download::platformDidFinish() - (BOOL)downloadShouldUseCredentialStorage:(NSURLDownload *)download { - // FIXME: Implement. - notImplemented(); - return YES; + return NO; } - (void)download:(NSURLDownload *)download didReceiveResponse:(NSURLResponse *)response diff --git a/Source/WebKit2/WebProcess/Downloads/qt/DownloadQt.cpp b/Source/WebKit2/WebProcess/Downloads/qt/DownloadQt.cpp index 19b86f0..ad5e7de 100644 --- a/Source/WebKit2/WebProcess/Downloads/qt/DownloadQt.cpp +++ b/Source/WebKit2/WebProcess/Downloads/qt/DownloadQt.cpp @@ -62,4 +62,19 @@ void Download::platformDidFinish() notImplemented(); } +void Download::receivedCredential(const AuthenticationChallenge& authenticationChallenge, const Credential& credential) +{ + notImplemented(); +} + +void Download::receivedRequestToContinueWithoutCredential(const AuthenticationChallenge& authenticationChallenge) +{ + notImplemented(); +} + +void Download::receivedCancellation(const AuthenticationChallenge& authenticationChallenge) +{ + notImplemented(); +} + } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/gtk/NetscapePluginGtk.cpp b/Source/WebKit2/WebProcess/Downloads/soup/DownloadSoup.cpp index f7c9440..a228916 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/gtk/NetscapePluginGtk.cpp +++ b/Source/WebKit2/WebProcess/Downloads/soup/DownloadSoup.cpp @@ -1,6 +1,6 @@ /* - * Copyright (C) 2010 Apple Inc. All rights reserved. - * Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved. + * Copyright (C) 2010, 2011 Apple Inc. All rights reserved. + * Copyright (C) 2010 Brent Fulgham <bfulgham@webkit.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -25,7 +25,7 @@ */ #include "config.h" -#include "NetscapePlugin.h" +#include "Download.h" #include <WebCore/NotImplemented.h> @@ -33,73 +33,49 @@ using namespace WebCore; namespace WebKit { -bool NetscapePlugin::platformPostInitialize() +void Download::start(WebPage* initiatingWebPage) { notImplemented(); - return true; } -void NetscapePlugin::platformDestroy() +void Download::startWithHandle(WebPage* initiatingPage, ResourceHandle*, const ResourceRequest& initialRequest, const ResourceResponse&) { notImplemented(); } -bool NetscapePlugin::platformInvalidate(const IntRect&) +void Download::cancel() { notImplemented(); - return false; } -void NetscapePlugin::platformGeometryDidChange() +void Download::platformInvalidate() { notImplemented(); } -void NetscapePlugin::platformPaint(GraphicsContext* context, const IntRect& dirtyRect, bool) +void Download::didDecideDestination(const String& destination, bool allowOverwrite) { notImplemented(); } -NPEvent toNP(const WebMouseEvent& event) +void Download::platformDidFinish() { - NPEvent npEvent = NPEvent(); notImplemented(); - return npEvent; } -bool NetscapePlugin::platformHandleMouseEvent(const WebMouseEvent& event) +void Download::receivedCredential(const AuthenticationChallenge& authenticationChallenge, const Credential& credential) { notImplemented(); - return true; } -bool NetscapePlugin::platformHandleWheelEvent(const WebWheelEvent&) +void Download::receivedRequestToContinueWithoutCredential(const AuthenticationChallenge& authenticationChallenge) { notImplemented(); - return false; } -void NetscapePlugin::platformSetFocus(bool) +void Download::receivedCancellation(const AuthenticationChallenge& authenticationChallenge) { notImplemented(); } -bool NetscapePlugin::platformHandleMouseEnterEvent(const WebMouseEvent& event) -{ - notImplemented(); - return true; -} - -bool NetscapePlugin::platformHandleMouseLeaveEvent(const WebMouseEvent& event) -{ - notImplemented(); - return true; -} - -bool NetscapePlugin::platformHandleKeyboardEvent(const WebKeyboardEvent&) -{ - notImplemented(); - return false; -} - } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.cpp b/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.cpp new file mode 100644 index 0000000..e856876 --- /dev/null +++ b/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.cpp @@ -0,0 +1,147 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "config.h" +#include "WebFullScreenManager.h" + +#if ENABLE(FULLSCREEN_API) + +#include "Connection.h" +#include "MessageID.h" +#include "WebCoreArgumentCoders.h" +#include "WebFullScreenManagerProxyMessages.h" +#include "WebPage.h" +#include "WebProcess.h" +#include <WebCore/Color.h> +#include <WebCore/Page.h> +#include <WebCore/Settings.h> + +using namespace WebCore; + +namespace WebKit { + +WebFullScreenManager::WebFullScreenManager(WebPage* page) + : m_page(page) +{ +} + +WebFullScreenManager::~WebFullScreenManager() +{ + +} + +WebCore::Element* WebFullScreenManager::element() +{ + return m_element.get(); +} + +void WebFullScreenManager::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments) +{ + didReceiveWebFullScreenManagerMessage(connection, messageID, arguments); +} + +bool WebFullScreenManager::supportsFullScreen(bool withKeyboard) +{ + if (!m_page->corePage()->settings()->fullScreenEnabled()) + return false; + + bool supports = true; + m_page->sendSync(Messages::WebFullScreenManagerProxy::SupportsFullScreen(withKeyboard), supports); + return supports; +} + +void WebFullScreenManager::enterFullScreenForElement(WebCore::Element* element) +{ + ASSERT(element); + m_element = element; + m_initialFrame = m_element->screenRect(); + m_page->send(Messages::WebFullScreenManagerProxy::EnterFullScreen()); +} + +void WebFullScreenManager::exitFullScreenForElement(WebCore::Element* element) +{ + ASSERT(element); + ASSERT(m_element == element); + m_page->send(Messages::WebFullScreenManagerProxy::ExitFullScreen()); +} + +void WebFullScreenManager::beganEnterFullScreenAnimation() +{ + m_page->send(Messages::WebFullScreenManagerProxy::BeganEnterFullScreenAnimation()); +} + +void WebFullScreenManager::finishedEnterFullScreenAnimation(bool completed) +{ + m_page->send(Messages::WebFullScreenManagerProxy::FinishedEnterFullScreenAnimation(completed)); +} + +void WebFullScreenManager::beganExitFullScreenAnimation() +{ + m_page->send(Messages::WebFullScreenManagerProxy::BeganExitFullScreenAnimation()); +} + +void WebFullScreenManager::finishedExitFullScreenAnimation(bool completed) +{ + m_page->send(Messages::WebFullScreenManagerProxy::FinishedExitFullScreenAnimation(completed)); +} + +IntRect WebFullScreenManager::getFullScreenRect() +{ + IntRect rect; + m_page->sendSync(Messages::WebFullScreenManagerProxy::GetFullScreenRect(), Messages::WebFullScreenManagerProxy::GetFullScreenRect::Reply(rect)); + return rect; +} + +void WebFullScreenManager::willEnterFullScreen() +{ + ASSERT(m_element); + m_element->document()->webkitWillEnterFullScreenForElement(m_element.get()); + m_element->document()->setFullScreenRendererBackgroundColor(Color::transparent); +} + +void WebFullScreenManager::didEnterFullScreen() +{ + ASSERT(m_element); + m_element->document()->webkitDidEnterFullScreenForElement(m_element.get()); + m_element->document()->setFullScreenRendererBackgroundColor(Color::black); +} + +void WebFullScreenManager::willExitFullScreen() +{ + ASSERT(m_element); + m_element->document()->webkitWillExitFullScreenForElement(m_element.get()); + m_element->document()->setFullScreenRendererBackgroundColor(Color::transparent); +} + +void WebFullScreenManager::didExitFullScreen() +{ + ASSERT(m_element); + m_element->document()->webkitDidExitFullScreenForElement(m_element.get()); + m_element->document()->setFullScreenRendererBackgroundColor(Color::black); +} + + +} // namespace WebKit + +#endif // ENABLE(FULLSCREEN_API) diff --git a/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.h b/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.h new file mode 100644 index 0000000..d4ec15d --- /dev/null +++ b/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.h @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef WebFullScreenManager_h +#define WebFullScreenManager_h + +#if ENABLE(FULLSCREEN_API) + +#include <WebCore/IntRect.h> +#include <wtf/RefCounted.h> +#include <wtf/RefPtr.h> + +namespace CoreIPC { +class ArgumentDecoder; +class Connection; +class MessageID; +} + +namespace WebCore { +class IntRect; +class Element; +class GraphicsLayer; +} + +namespace WebKit { + +class WebPage; + +class WebFullScreenManager : public RefCounted<WebFullScreenManager> { +public: + static PassRefPtr<WebFullScreenManager> create(WebPage*); + virtual ~WebFullScreenManager(); + + void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); + + bool supportsFullScreen(bool withKeyboard); + void enterFullScreenForElement(WebCore::Element*); + void exitFullScreenForElement(WebCore::Element*); + void beganEnterFullScreenAnimation(); + void finishedEnterFullScreenAnimation(bool completed); + void beganExitFullScreenAnimation(); + void finishedExitFullScreenAnimation(bool completed); + virtual void setRootFullScreenLayer(WebCore::GraphicsLayer*) = 0; + + WebCore::Element* element(); + +protected: + WebFullScreenManager(WebPage*); + + void willEnterFullScreen(); + void didEnterFullScreen(); + void willExitFullScreen(); + void didExitFullScreen(); + virtual void beginEnterFullScreenAnimation(float duration) = 0; + virtual void beginExitFullScreenAnimation(float duration) = 0; + WebCore::IntRect getFullScreenRect(); + + void didReceiveWebFullScreenManagerMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); + + WebCore::IntRect m_initialFrame; + RefPtr<WebPage> m_page; + RefPtr<WebCore::Element> m_element; +}; + +} // namespace WebKit + +#endif // ENABLE(FULLSCREEN_API) + +#endif // WebFullScreenManager_h diff --git a/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.messages.in b/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.messages.in new file mode 100644 index 0000000..d53f9d5 --- /dev/null +++ b/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.messages.in @@ -0,0 +1,32 @@ +# Copyright (C) 2011 Apple Inc. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#if ENABLE(FULLSCREEN_API) +messages -> WebFullScreenManager { + WillEnterFullScreen() + DidEnterFullScreen() + WillExitFullScreen() + DidExitFullScreen() + BeginEnterFullScreenAnimation(float duration) + BeginExitFullScreenAnimation(float duration) +} +#endif diff --git a/Source/WebKit2/WebProcess/FullScreen/gtk/WebFullScreenManagerGtk.cpp b/Source/WebKit2/WebProcess/FullScreen/gtk/WebFullScreenManagerGtk.cpp new file mode 100644 index 0000000..5c4e697 --- /dev/null +++ b/Source/WebKit2/WebProcess/FullScreen/gtk/WebFullScreenManagerGtk.cpp @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2011 Igalia S.L. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "config.h" +#include "WebFullScreenManagerGtk.h" + +#if ENABLE(FULLSCREEN_API) + +#include <WebCore/NotImplemented.h> + +namespace WebKit { + +WebFullScreenManagerGtk::WebFullScreenManagerGtk(WebPage* page) + : WebFullScreenManager(page) +{ +} + +PassRefPtr<WebFullScreenManager> WebFullScreenManager::create(WebPage* page) +{ + return adoptRef(new WebFullScreenManagerGtk(page)); +} + +void WebFullScreenManagerGtk::setRootFullScreenLayer(WebCore::GraphicsLayer* layer) +{ + notImplemented(); +} + +void WebFullScreenManagerGtk::beginEnterFullScreenAnimation(float duration) +{ + notImplemented(); +} + +void WebFullScreenManagerGtk::beginExitFullScreenAnimation(float duration) +{ + notImplemented(); +} + +} // namespace WebKit + +#endif // ENABLE(FULLSCREEN_API) diff --git a/Source/WebKit2/WebProcess/FullScreen/gtk/WebFullScreenManagerGtk.h b/Source/WebKit2/WebProcess/FullScreen/gtk/WebFullScreenManagerGtk.h new file mode 100644 index 0000000..51f5527 --- /dev/null +++ b/Source/WebKit2/WebProcess/FullScreen/gtk/WebFullScreenManagerGtk.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebFullScreenManagerGtk_h +#define WebFullScreenManagerGtk_h + +#if ENABLE(FULLSCREEN_API) + +#include "WebFullScreenManager.h" + +namespace WebKit { + +class WebFullScreenManagerGtk : public WebFullScreenManager { +public: + WebFullScreenManagerGtk(WebPage*); + virtual void setRootFullScreenLayer(WebCore::GraphicsLayer*); + +private: + virtual void beginEnterFullScreenAnimation(float duration); + virtual void beginExitFullScreenAnimation(float duration); + +}; + +} + +#endif // ENABLE(FULLSCREEN_API) + +#endif // WebFullScreenManagerGtk_h diff --git a/Source/WebKit2/WebProcess/FullScreen/mac/WebFullScreenManagerMac.h b/Source/WebKit2/WebProcess/FullScreen/mac/WebFullScreenManagerMac.h new file mode 100644 index 0000000..e247eb5 --- /dev/null +++ b/Source/WebKit2/WebProcess/FullScreen/mac/WebFullScreenManagerMac.h @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebFullScreenManagerMac_h +#define WebFullScreenManagerMac_h + +#if ENABLE(FULLSCREEN_API) + +#import "LayerTreeContext.h" +#import "WebFullScreenManager.h" + +#import <WebCore/IntRect.h> +#import <wtf/RetainPtr.h> + +typedef struct __WKCARemoteLayerClientRef* WKCARemoteLayerClientRef; +OBJC_CLASS WebFullScreenManagerAnimationListener; + +namespace WebKit { + +class WebFullScreenManagerMac : public WebFullScreenManager { +public: + static PassRefPtr<WebFullScreenManagerMac> create(WebPage*); + + virtual void setRootFullScreenLayer(WebCore::GraphicsLayer*); + +private: + WebFullScreenManagerMac(WebPage*); + virtual ~WebFullScreenManagerMac(); + + virtual void beginEnterFullScreenAnimation(float duration); + virtual void beginExitFullScreenAnimation(float duration); + + OwnPtr<WebCore::GraphicsLayer> m_rootLayer; + WebCore::GraphicsLayer* m_fullScreenRootLayer; + LayerTreeContext m_layerTreeContext; + RetainPtr<WKCARemoteLayerClientRef> m_remoteLayerClient; + RetainPtr<id> m_enterFullScreenListener; + RetainPtr<id> m_exitFullScreenListener; +}; + +} + +#endif // ENABLE(FULLSCREEN_API) + +#endif // WebFullScreenManagerMac_h diff --git a/Source/WebKit2/WebProcess/FullScreen/mac/WebFullScreenManagerMac.mm b/Source/WebKit2/WebProcess/FullScreen/mac/WebFullScreenManagerMac.mm new file mode 100644 index 0000000..66243c5 --- /dev/null +++ b/Source/WebKit2/WebProcess/FullScreen/mac/WebFullScreenManagerMac.mm @@ -0,0 +1,277 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ +#import "config.h" +#import "WebFullScreenManagerMac.h" + +#if ENABLE(FULLSCREEN_API) + +#import "Connection.h" +#import "LayerTreeContext.h" +#import "MessageID.h" +#import "WebFullScreenManagerProxyMessages.h" +#import "WebPage.h" +#import "WebProcess.h" +#import <QuartzCore/QuartzCore.h> +#import <WebCore/Frame.h> +#import <WebCore/FrameView.h> +#import <WebCore/GraphicsLayer.h> +#import <WebCore/Page.h> +#import <WebCore/Settings.h> +#import <WebKitSystemInterface.h> + +using namespace WebCore; + +typedef void (WebKit::WebFullScreenManager::*AnimationBeganFunction)(); +typedef void (WebKit::WebFullScreenManager::*AnimationFinishedFunction)(bool); + +#if defined(BUILDING_ON_LEOPARD) +@interface CATransaction(SnowLeopardConvenienceFunctions) ++ (void)setDisableActions:(BOOL)flag; +@end + +@implementation CATransaction(SnowLeopardConvenienceFunctions) ++ (void)setDisableActions:(BOOL)flag +{ + [self setValue:[NSNumber numberWithBool:flag] forKey:kCATransactionDisableActions]; +} +@end +#endif + +@interface WebFullScreenManagerAnimationListener : NSObject { + WebKit::WebFullScreenManager* _manager; + AnimationBeganFunction _began; + AnimationFinishedFunction _finished; +} +- (id)initWithManager:(WebKit::WebFullScreenManager*)manager began:(AnimationBeganFunction)began finished:(AnimationFinishedFunction)finished; +- (void)animationDidStart:(CAAnimation *)anim; +- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag; +- (void)invalidate; +@end + +@implementation WebFullScreenManagerAnimationListener +- (id)initWithManager:(WebKit::WebFullScreenManager*)manager began:(AnimationBeganFunction)began finished:(AnimationFinishedFunction)finished +{ + self = [super init]; + if (!self) + return nil; + + _manager = manager; + _began = began; + _finished = finished; + return self; +} + +- (void)animationDidStart:(CAAnimation *)anim +{ + if (_manager && _began) + (_manager->*_began)(); +} + +- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag +{ + if (_manager && _finished) + (_manager->*_finished)(flag); +} + +- (void)invalidate +{ + _manager = 0; + _began = 0; + _finished = 0; +} +@end + +namespace WebKit { + +PassRefPtr<WebFullScreenManager> WebFullScreenManager::create(WebPage* page) +{ + return WebFullScreenManagerMac::create(page); +} + +PassRefPtr<WebFullScreenManagerMac> WebFullScreenManagerMac::create(WebPage* page) +{ + return adoptRef(new WebFullScreenManagerMac(page)); +} + +WebFullScreenManagerMac::WebFullScreenManagerMac(WebPage* page) + : WebFullScreenManager(page) +{ + m_enterFullScreenListener.adoptNS([[WebFullScreenManagerAnimationListener alloc] initWithManager:this began:&WebFullScreenManagerMac::beganEnterFullScreenAnimation finished:&WebFullScreenManagerMac::finishedEnterFullScreenAnimation]); + m_exitFullScreenListener.adoptNS([[WebFullScreenManagerAnimationListener alloc] initWithManager:this began:&WebFullScreenManagerMac::beganExitFullScreenAnimation finished:&WebFullScreenManagerMac::finishedExitFullScreenAnimation]); +} + +WebFullScreenManagerMac::~WebFullScreenManagerMac() +{ + m_page->send(Messages::WebFullScreenManagerProxy::ExitAcceleratedCompositingMode()); + [m_enterFullScreenListener.get() invalidate]; + [m_exitFullScreenListener.get() invalidate]; +} + +void WebFullScreenManagerMac::setRootFullScreenLayer(WebCore::GraphicsLayer* layer) +{ + if (m_fullScreenRootLayer == layer) + return; + m_fullScreenRootLayer = layer; + + if (!m_fullScreenRootLayer) { + m_page->send(Messages::WebFullScreenManagerProxy::ExitAcceleratedCompositingMode()); + if (m_rootLayer) { + m_rootLayer->removeAllChildren(); + m_rootLayer = 0; + } + return; + } + + if (!m_rootLayer) { + mach_port_t serverPort = WebProcess::shared().compositingRenderServerPort(); + m_remoteLayerClient = WKCARemoteLayerClientMakeWithServerPort(serverPort); + + m_rootLayer = GraphicsLayer::create(NULL); +#ifndef NDEBUG + m_rootLayer->setName("Full screen root layer"); +#endif + m_rootLayer->setDrawsContent(false); + m_rootLayer->setSize(getFullScreenRect().size()); + + [m_rootLayer->platformLayer() setGeometryFlipped:YES]; + WKCARemoteLayerClientSetLayer(m_remoteLayerClient.get(), m_rootLayer->platformLayer()); + m_layerTreeContext.contextID = WKCARemoteLayerClientGetClientId(m_remoteLayerClient.get()); + m_page->send(Messages::WebFullScreenManagerProxy::EnterAcceleratedCompositingMode(m_layerTreeContext)); + } + + m_rootLayer->removeAllChildren(); + + if (m_fullScreenRootLayer) + m_rootLayer->addChild(m_fullScreenRootLayer); + + m_rootLayer->syncCompositingStateForThisLayerOnly(); + m_page->corePage()->mainFrame()->view()->syncCompositingStateIncludingSubframes(); +} + +void WebFullScreenManagerMac::beginEnterFullScreenAnimation(float duration) +{ + ASSERT(m_element); + ASSERT(m_fullScreenRootLayer); + + IntRect destinationFrame = getFullScreenRect(); + m_element->document()->setFullScreenRendererSize(destinationFrame.size()); + m_rootLayer->syncCompositingStateForThisLayerOnly(); + m_page->corePage()->mainFrame()->view()->syncCompositingStateIncludingSubframes(); + + // FIXME: Once we gain the ability to do native WebKit animations of generated + // content, this can change to use them. Meanwhile, we'll have to animate the + // CALayer directly: + CALayer* caLayer = m_fullScreenRootLayer->platformLayer(); + + // Create a transformation matrix that will transform the renderer layer such that + // the fullscreen element appears to move from its starting position and size to its + // final one. + CGPoint destinationPosition = [caLayer position]; + CGPoint layerAnchor = [caLayer anchorPoint]; + CGPoint initialPosition = CGPointMake( + m_initialFrame.x() + m_initialFrame.width() * layerAnchor.x, + m_initialFrame.y() + m_initialFrame.height() * layerAnchor.y); + CATransform3D shrinkTransform = CATransform3DMakeScale( + static_cast<CGFloat>(m_initialFrame.width()) / destinationFrame.width(), + static_cast<CGFloat>(m_initialFrame.height()) / destinationFrame.height(), 1); + CATransform3D shiftTransform = CATransform3DMakeTranslation( + initialPosition.x - destinationPosition.x, + // Drawing is flipped here, and so much be the translation transformation + destinationPosition.y - initialPosition.y, 0); + CATransform3D finalTransform = CATransform3DConcat(shrinkTransform, shiftTransform); + + // Use a CABasicAnimation here for the zoom effect. We want to be notified that the animation has + // completed by way of the CAAnimation delegate. + CABasicAnimation* zoomAnimation = [CABasicAnimation animationWithKeyPath:@"transform"]; + [zoomAnimation setFromValue:[NSValue valueWithCATransform3D:finalTransform]]; + [zoomAnimation setToValue:[NSValue valueWithCATransform3D:CATransform3DIdentity]]; + [zoomAnimation setDelegate:m_enterFullScreenListener.get()]; + [zoomAnimation setDuration:duration]; + [zoomAnimation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]]; + [zoomAnimation setFillMode:kCAFillModeForwards]; + + // Disable implicit animations and set the layer's transformation matrix to its final state. + [CATransaction begin]; + [CATransaction setDisableActions:YES]; + [caLayer addAnimation:zoomAnimation forKey:@"zoom"]; + [CATransaction commit]; +} + +void WebFullScreenManagerMac::beginExitFullScreenAnimation(float duration) +{ + ASSERT(m_element); + ASSERT(m_fullScreenRootLayer); + + IntRect destinationFrame = getFullScreenRect(); + m_element->document()->setFullScreenRendererSize(destinationFrame.size()); + m_rootLayer->syncCompositingStateForThisLayerOnly(); + m_page->corePage()->mainFrame()->view()->syncCompositingStateIncludingSubframes(); + + // FIXME: Once we gain the ability to do native WebKit animations of generated + // content, this can change to use them. Meanwhile, we'll have to animate the + // CALayer directly: + CALayer* caLayer = m_fullScreenRootLayer->platformLayer(); + + // Create a transformation matrix that will transform the renderer layer such that + // the fullscreen element appears to move from its starting position and size to its + // final one. + CGPoint destinationPosition = [(CALayer*)[caLayer presentationLayer] position]; + CGRect destinationBounds = NSRectToCGRect([[caLayer presentationLayer] bounds]); + CGPoint layerAnchor = [caLayer anchorPoint]; + CGPoint initialPosition = CGPointMake( + m_initialFrame.x() + m_initialFrame.width() * layerAnchor.x, + m_initialFrame.y() + m_initialFrame.height() * layerAnchor.y); + CATransform3D shrinkTransform = CATransform3DMakeScale( + static_cast<CGFloat>(m_initialFrame.width()) / destinationBounds.size.width, + static_cast<CGFloat>(m_initialFrame.height()) / destinationBounds.size.height, 1); + CATransform3D shiftTransform = CATransform3DMakeTranslation( + initialPosition.x - destinationPosition.x, + // Drawing is flipped here, and so must be the translation transformation + destinationPosition.y - initialPosition.y, 0); + CATransform3D finalTransform = CATransform3DConcat(shrinkTransform, shiftTransform); + + CATransform3D initialTransform = [(CALayer*)[caLayer presentationLayer] transform]; + + // Use a CABasicAnimation here for the zoom effect. We want to be notified that the animation has + // completed by way of the CAAnimation delegate. + CABasicAnimation* zoomAnimation = [CABasicAnimation animationWithKeyPath:@"transform"]; + [zoomAnimation setFromValue:[NSValue valueWithCATransform3D:initialTransform]]; + [zoomAnimation setToValue:[NSValue valueWithCATransform3D:finalTransform]]; + [zoomAnimation setDelegate:m_exitFullScreenListener.get()]; + [zoomAnimation setDuration:duration]; + [zoomAnimation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]]; + [zoomAnimation setFillMode:kCAFillModeForwards]; + + // Disable implicit animations and set the layer's transformation matrix to its final state. + [CATransaction begin]; + [CATransaction setDisableActions:YES]; + [caLayer addAnimation:zoomAnimation forKey:@"zoom"]; + [caLayer setTransform:finalTransform]; + [CATransaction commit]; +} + +} // namespace WebKit + +#endif // ENABLE(FULLSCREEN_API) diff --git a/Source/WebKit2/WebProcess/IconDatabase/WebIconDatabaseProxy.cpp b/Source/WebKit2/WebProcess/IconDatabase/WebIconDatabaseProxy.cpp new file mode 100644 index 0000000..0207791 --- /dev/null +++ b/Source/WebKit2/WebProcess/IconDatabase/WebIconDatabaseProxy.cpp @@ -0,0 +1,151 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "WebIconDatabaseProxy.h" + +#include "DataReference.h" +#include "MessageID.h" +#include "WebIconDatabaseMessages.h" +#include "WebProcess.h" +#include <WebCore/SharedBuffer.h> +#include <wtf/text/WTFString.h> + +using namespace WebCore; + +namespace WebKit { + +WebIconDatabaseProxy::~WebIconDatabaseProxy() +{ +} + +WebIconDatabaseProxy::WebIconDatabaseProxy(WebProcess* process) + : m_isEnabled(false) + , m_process(process) +{ +} + +bool WebIconDatabaseProxy::isEnabled() const +{ + return m_isEnabled; +} + +void WebIconDatabaseProxy::setEnabled(bool enabled) +{ + if (enabled == m_isEnabled) + return; + + m_isEnabled = enabled; + setGlobalIconDatabase(enabled ? this : 0); +} + + +void WebIconDatabaseProxy::retainIconForPageURL(const String& pageURL) +{ + m_process->connection()->send(Messages::WebIconDatabase::RetainIconForPageURL(pageURL), 0); +} + +void WebIconDatabaseProxy::releaseIconForPageURL(const String& pageURL) +{ + m_process->connection()->send(Messages::WebIconDatabase::ReleaseIconForPageURL(pageURL), 0); +} + +Image* WebIconDatabaseProxy::synchronousIconForPageURL(const String& pageURL, const IntSize& size) +{ + CoreIPC::DataReference result; + if (!m_process->connection()->sendSync(Messages::WebIconDatabase::SynchronousIconDataForPageURL(pageURL), Messages::WebIconDatabase::SynchronousIconDataForPageURL::Reply(result), 0)) + return 0; + + // FIXME: Return Image created with the above data. + return 0; +} + + +String WebIconDatabaseProxy::synchronousIconURLForPageURL(const String& pageURL) +{ + // FIXME: This needs to ask the UI process for the iconURL, but it can't do so synchronously because it will slow down page loading. + // The parts in WebCore that need this data will have to be changed to work asycnchronously. + return String(); +} + +bool WebIconDatabaseProxy::synchronousIconDataKnownForIconURL(const String& iconURL) +{ + // FIXME: This needs to ask the UI process for the iconURL, but it can't do so synchronously because it will slow down page loading. + // The parts in WebCore that need this data will have to be changed to work asycnchronously. + return false; +} + +IconLoadDecision WebIconDatabaseProxy::synchronousLoadDecisionForIconURL(const String& iconURL, DocumentLoader* documentLoader) +{ + // FIXME: This needs to ask the UI process for the iconURL, but it can't do so synchronously because it will slow down page loading. + // The parts in WebCore that need this data will have to be changed to work asycnchronously. + return IconLoadNo; +} + +bool WebIconDatabaseProxy::supportsAsynchronousMode() +{ + return true; +} + +void WebIconDatabaseProxy::loadDecisionForIconURL(const String& iconURL, PassRefPtr<WebCore::IconLoadDecisionCallback> callback) +{ + uint64_t id = callback->callbackID(); + m_iconLoadDecisionCallbacks.add(id, callback); + + m_process->connection()->send(Messages::WebIconDatabase::GetLoadDecisionForIconURL(iconURL, id), 0); +} + +void WebIconDatabaseProxy::receivedIconLoadDecision(int decision, uint64_t callbackID) +{ + RefPtr<WebCore::IconLoadDecisionCallback> callback = m_iconLoadDecisionCallbacks.take(callbackID); + if (callback) + callback->performCallback(static_cast<WebCore::IconLoadDecision>(decision)); +} + +void WebIconDatabaseProxy::iconDataForIconURL(const String& iconURL, PassRefPtr<WebCore::IconDataCallback> callback) +{ +} + +void WebIconDatabaseProxy::setIconURLForPageURL(const String& iconURL, const String& pageURL) +{ + m_process->connection()->send(Messages::WebIconDatabase::SetIconURLForPageURL(iconURL, pageURL), 0); +} + +void WebIconDatabaseProxy::setIconDataForIconURL(PassRefPtr<SharedBuffer> iconData, const String& iconURL) +{ + CoreIPC::DataReference data(reinterpret_cast<const uint8_t*>(iconData ? iconData->data() : 0), iconData ? iconData->size() : 0); + m_process->connection()->send(Messages::WebIconDatabase::SetIconDataForIconURL(data, iconURL), 0); +} + +void WebIconDatabaseProxy::urlImportFinished() +{ +} + +void WebIconDatabaseProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments) +{ + didReceiveWebIconDatabaseProxyMessage(connection, messageID, arguments); +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/IconDatabase/WebIconDatabaseProxy.h b/Source/WebKit2/WebProcess/IconDatabase/WebIconDatabaseProxy.h new file mode 100644 index 0000000..2096aba --- /dev/null +++ b/Source/WebKit2/WebProcess/IconDatabase/WebIconDatabaseProxy.h @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebIconDatabaseProxy_h +#define WebIconDatabaseProxy_h + +#include "APIObject.h" + +#include <WebCore/IconDatabaseBase.h> + +#include <wtf/HashMap.h> +#include <wtf/PassRefPtr.h> +#include <wtf/RefPtr.h> +#include <wtf/Vector.h> + +namespace CoreIPC { +class ArgumentDecoder; +class Connection; +class MessageID; +} + +namespace WebKit { + +class WebProcess; + +class WebIconDatabaseProxy : public WebCore::IconDatabaseBase { +public: + explicit WebIconDatabaseProxy(WebProcess*); + virtual ~WebIconDatabaseProxy(); + + virtual bool isEnabled() const; + void setEnabled(bool); + + + virtual void retainIconForPageURL(const String&); + virtual void releaseIconForPageURL(const String&); + virtual void setIconURLForPageURL(const String&, const String&); + virtual void setIconDataForIconURL(PassRefPtr<WebCore::SharedBuffer>, const String&); + + virtual String synchronousIconURLForPageURL(const String&); + virtual bool synchronousIconDataKnownForIconURL(const String&); + virtual WebCore::IconLoadDecision synchronousLoadDecisionForIconURL(const String&, WebCore::DocumentLoader*); + virtual WebCore::Image* synchronousIconForPageURL(const String&, const WebCore::IntSize&); + + // Asynchronous calls we should use to replace the above when supported. + virtual bool supportsAsynchronousMode(); + virtual void loadDecisionForIconURL(const String&, PassRefPtr<WebCore::IconLoadDecisionCallback>); + void receivedIconLoadDecision(int decision, uint64_t callbackID); + virtual void iconDataForIconURL(const String&, PassRefPtr<WebCore::IconDataCallback>); + + void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); + +private: + void didReceiveWebIconDatabaseProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); + + // Callbacks from the UIProcess + void urlImportFinished(); + + bool m_isEnabled; + WebProcess* m_process; + + HashMap<uint64_t, RefPtr<WebCore::IconLoadDecisionCallback> > m_iconLoadDecisionCallbacks; +}; + +} // namespace WebKit + +#endif // WebIconDatabaseProxy_h diff --git a/Source/WebKit2/WebProcess/IconDatabase/WebIconDatabaseProxy.messages.in b/Source/WebKit2/WebProcess/IconDatabase/WebIconDatabaseProxy.messages.in new file mode 100644 index 0000000..049a0d9 --- /dev/null +++ b/Source/WebKit2/WebProcess/IconDatabase/WebIconDatabaseProxy.messages.in @@ -0,0 +1,26 @@ +# Copyright (C) 2011 Apple Inc. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +messages -> WebIconDatabaseProxy { + URLImportFinished() + ReceivedIconLoadDecision(int loadDecision, uint64_t callbackID) +} diff --git a/Source/WebKit2/WebProcess/Info.plist b/Source/WebKit2/WebProcess/Info.plist index 1fa2672..dabaf1f 100644 --- a/Source/WebKit2/WebProcess/Info.plist +++ b/Source/WebKit2/WebProcess/Info.plist @@ -2,10 +2,6 @@ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> - <key>LSFileQuarantineEnabled</key> - <true/> - <key>CFBundleDevelopmentRegion</key> - <string>English</string> <key>CFBundleExecutable</key> <string>${PRODUCT_NAME}</string> <key>CFBundleGetInfoString</key> @@ -22,11 +18,13 @@ <string>${SHORT_VERSION_STRING}</string> <key>CFBundleVersion</key> <string>${BUNDLE_VERSION}</string> + <key>LSFileQuarantineEnabled</key> + <true/> <key>LSMinimumSystemVersion</key> <string>${MACOSX_DEPLOYMENT_TARGET}</string> - <key>NSPrincipalClass</key> - <string>NSApplication</string> <key>LSUIElement</key> <true/> + <key>NSPrincipalClass</key> + <string>NSApplication</string> </dict> </plist> diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp index a58dbda..587968c 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp @@ -128,6 +128,11 @@ void WKBundleOverrideXSSAuditorEnabledForTestRunner(WKBundleRef bundleRef, WKBun toImpl(bundleRef)->overrideXSSAuditorEnabledForTestRunner(toImpl(pageGroupRef), enabled); } +void WKBundleOverrideAllowUniversalAccessFromFileURLsForTestRunner(WKBundleRef bundleRef, WKBundlePageGroupRef pageGroupRef, bool enabled) +{ + toImpl(bundleRef)->overrideAllowUniversalAccessFromFileURLsForTestRunner(toImpl(pageGroupRef), enabled); +} + void WKBundleReportException(JSContextRef context, JSValueRef exception) { InjectedBundle::reportException(context, exception); diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp index 0e91d8e..6bed7a4 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp @@ -76,6 +76,16 @@ void WKBundleNodeHandleSetHTMLInputElementAutofilled(WKBundleNodeHandleRef htmlI toImpl(htmlInputElementHandleRef)->setHTMLInputElementAutofilled(filled); } +bool WKBundleNodeHandleGetHTMLInputElementLastChangeWasUserEdit(WKBundleNodeHandleRef htmlInputElementHandleRef) +{ + return toImpl(htmlInputElementHandleRef)->htmlInputElementLastChangeWasUserEdit(); +} + +bool WKBundleNodeHandleGetHTMLTextAreaElementLastChangeWasUserEdit(WKBundleNodeHandleRef htmlTextAreaElementHandleRef) +{ + return toImpl(htmlTextAreaElementHandleRef)->htmlTextAreaElementLastChangeWasUserEdit(); +} + WKBundleNodeHandleRef WKBundleNodeHandleCopyHTMLTableCellElementCellAbove(WKBundleNodeHandleRef htmlTableCellElementHandleRef) { RefPtr<InjectedBundleNodeHandle> nodeHandle = toImpl(htmlTableCellElementHandleRef)->htmlTableCellElementCellAbove(); diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h index aaa95e6..6006596 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h @@ -50,7 +50,11 @@ WK_EXPORT WKRect WKBundleNodeHandleGetRenderRect(WKBundleNodeHandleRef nodeHandl WK_EXPORT void WKBundleNodeHandleSetHTMLInputElementValueForUser(WKBundleNodeHandleRef htmlInputElementHandle, WKStringRef value); WK_EXPORT bool WKBundleNodeHandleGetHTMLInputElementAutofilled(WKBundleNodeHandleRef htmlInputElementHandle); WK_EXPORT void WKBundleNodeHandleSetHTMLInputElementAutofilled(WKBundleNodeHandleRef htmlInputElementHandle, bool filled); +WK_EXPORT bool WKBundleNodeHandleGetHTMLInputElementLastChangeWasUserEdit(WKBundleNodeHandleRef htmlInputElementHandle); +/* HTMLTextAreaElement Specific Operations */ +WK_EXPORT bool WKBundleNodeHandleGetHTMLTextAreaElementLastChangeWasUserEdit(WKBundleNodeHandleRef htmlTextAreaElementHandle); + /* HTMLTableCellElement Specific Operations */ WK_EXPORT WKBundleNodeHandleRef WKBundleNodeHandleCopyHTMLTableCellElementCellAbove(WKBundleNodeHandleRef htmlTableCellElementHandle); diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h index 4be67d5..e01f51f 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h @@ -168,6 +168,7 @@ typedef void (*WKBundlePageWillRunJavaScriptPromptCallback)(WKBundlePageRef page typedef void (*WKBundlePageMouseDidMoveOverElementCallback)(WKBundlePageRef page, WKBundleHitTestResultRef hitTestResult, WKEventModifiers modifiers, WKTypeRef* userData, const void *clientInfo); typedef void (*WKBundlePageDidScrollCallback)(WKBundlePageRef page, const void *clientInfo); typedef void (*WKBundlePagePaintCustomOverhangAreaCallback)(WKBundlePageRef page, WKGraphicsContextRef graphicsContext, WKRect horizontalOverhang, WKRect verticalOverhang, WKRect dirtyRect, const void* clientInfo); +typedef WKStringRef (*WKBundlePageGenerateFileForUploadCallback)(WKBundlePageRef page, WKStringRef originalFilePath, const void* clientInfo); struct WKBundlePageUIClient { int version; @@ -180,6 +181,8 @@ struct WKBundlePageUIClient { WKBundlePageMouseDidMoveOverElementCallback mouseDidMoveOverElement; WKBundlePageDidScrollCallback pageDidScroll; WKBundlePagePaintCustomOverhangAreaCallback paintCustomOverhangArea; + WKBundlePageGenerateFileForUploadCallback shouldGenerateFileForUpload; + WKBundlePageGenerateFileForUploadCallback generateFileForUpload; }; typedef struct WKBundlePageUIClient WKBundlePageUIClient; diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h index bb0bd9f..79c796a 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h @@ -65,6 +65,7 @@ WK_EXPORT void WKBundleRemoveAllUserContent(WKBundleRef bundle, WKBundlePageGrou // Will make WebProcess ignore this preference until a preferences change notification, only for WebKitTestRunner use. WK_EXPORT void WKBundleOverrideXSSAuditorEnabledForTestRunner(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled); +WK_EXPORT void WKBundleOverrideAllowUniversalAccessFromFileURLsForTestRunner(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled); #ifdef __cplusplus } diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/win/WKBundlePrivateWin.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/win/WKBundlePrivateWin.cpp new file mode 100644 index 0000000..d97784e --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/win/WKBundlePrivateWin.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "WKBundlePrivateWin.h" + +#include "InjectedBundle.h" +#include "WKAPICast.h" +#include "WKBundleAPICast.h" + +using namespace WebKit; + +void WKBundleSetHostAllowsAnyHTTPSCertificate(WKBundleRef bundleRef, WKStringRef host) +{ + toImpl(bundleRef)->setHostAllowsAnyHTTPSCertificate(toWTFString(host)); +} + +void WKBundleSetClientCertificate(WKBundleRef bundleRef, WKStringRef host, WKCertificateInfoRef certificateInfoRef) +{ + toImpl(bundleRef)->setClientCertificate(toWTFString(host), toImpl(certificateInfoRef)); +} diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/win/WKBundlePrivateWin.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/win/WKBundlePrivateWin.h new file mode 100644 index 0000000..e404ec8 --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/win/WKBundlePrivateWin.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKBundlePrivateWin_h +#define WKBundlePrivateWin_h + +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT void WKBundleSetHostAllowsAnyHTTPSCertificate(WKBundleRef bundle, WKStringRef host); +WK_EXPORT void WKBundleSetClientCertificate(WKBundleRef bundle, WKStringRef host, WKCertificateInfoRef certificateInfo); + +#ifdef __cplusplus +} +#endif + +#endif /* WKBundlePrivateWin_h */ diff --git a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp index 858941e..5e15872 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp @@ -30,12 +30,13 @@ #include "WebFrameLoaderClient.h" #include <JavaScriptCore/APICast.h> #include <WebCore/Document.h> +#include <WebCore/Frame.h> #include <WebCore/HTMLFrameElement.h> #include <WebCore/HTMLIFrameElement.h> -#include <WebCore/Frame.h> #include <WebCore/HTMLInputElement.h> #include <WebCore/HTMLNames.h> #include <WebCore/HTMLTableCellElement.h> +#include <WebCore/HTMLTextAreaElement.h> #include <WebCore/IntRect.h> #include <WebCore/JSNode.h> #include <WebCore/Node.h> @@ -132,7 +133,6 @@ bool InjectedBundleNodeHandle::isHTMLInputElementAutofilled() const return static_cast<HTMLInputElement*>(m_node.get())->isAutofilled(); } - void InjectedBundleNodeHandle::setHTMLInputElementAutofilled(bool filled) { if (!m_node->hasTagName(inputTag)) @@ -141,6 +141,22 @@ void InjectedBundleNodeHandle::setHTMLInputElementAutofilled(bool filled) static_cast<HTMLInputElement*>(m_node.get())->setAutofilled(filled); } +bool InjectedBundleNodeHandle::htmlInputElementLastChangeWasUserEdit() +{ + if (!m_node->hasTagName(inputTag)) + return false; + + return static_cast<HTMLInputElement*>(m_node.get())->lastChangeWasUserEdit(); +} + +bool InjectedBundleNodeHandle::htmlTextAreaElementLastChangeWasUserEdit() +{ + if (!m_node->hasTagName(textareaTag)) + return false; + + return static_cast<HTMLTextAreaElement*>(m_node.get())->lastChangeWasUserEdit(); +} + PassRefPtr<InjectedBundleNodeHandle> InjectedBundleNodeHandle::htmlTableCellElementCellAbove() { if (!m_node->hasTagName(tdTag)) diff --git a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h index 0dcebf6..e4a5ab9 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h @@ -63,6 +63,9 @@ public: void setHTMLInputElementValueForUser(const String&); bool isHTMLInputElementAutofilled() const; void setHTMLInputElementAutofilled(bool); + bool htmlInputElementLastChangeWasUserEdit(); + bool htmlTextAreaElementLastChangeWasUserEdit(); + PassRefPtr<InjectedBundleNodeHandle> htmlTableCellElementCellAbove(); PassRefPtr<WebFrame> documentFrame(); diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp index b887374..24dc7f9 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp @@ -108,6 +108,16 @@ void InjectedBundle::overrideXSSAuditorEnabledForTestRunner(WebPageGroupProxy* p (*iter)->settings()->setXSSAuditorEnabled(enabled); } +void InjectedBundle::overrideAllowUniversalAccessFromFileURLsForTestRunner(WebPageGroupProxy* pageGroup, bool enabled) +{ + // Override the preference for all future pages. + WebPreferencesStore::overrideAllowUniversalAccessFromFileURLsForTestRunner(enabled); + + // Change the setting for existing ones. + const HashSet<Page*>& pages = PageGroup::pageGroup(pageGroup->identifier())->pages(); + for (HashSet<Page*>::iterator iter = pages.begin(); iter != pages.end(); ++iter) + (*iter)->settings()->setAllowUniversalAccessFromFileURLs(enabled); +} static PassOwnPtr<Vector<String> > toStringVector(ImmutableArray* patterns) { diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h index cf844c9..6896669 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h @@ -59,6 +59,7 @@ typedef void* PlatformBundle; class ImmutableArray; class InjectedBundleScriptWorld; +class WebCertificateInfo; class WebPage; class WebPageGroupProxy; @@ -79,12 +80,17 @@ public: void initializeClient(WKBundleClient*); void postMessage(const String&, APIObject*); void postSynchronousMessage(const String&, APIObject*, RefPtr<APIObject>& returnData); +#if PLATFORM(WIN) + void setHostAllowsAnyHTTPSCertificate(const String&); + void setClientCertificate(const String&, const WebCertificateInfo*); +#endif // TestRunner only SPI void setShouldTrackVisitedLinks(bool); void removeAllVisitedLinks(); void activateMacFontAscentHack(); void overrideXSSAuditorEnabledForTestRunner(WebPageGroupProxy* pageGroup, bool enabled); + void overrideAllowUniversalAccessFromFileURLsForTestRunner(WebPageGroupProxy*, bool); // UserContent API void addUserScript(WebPageGroupProxy*, InjectedBundleScriptWorld*, const String& source, const String& url, ImmutableArray* whitelist, ImmutableArray* blacklist, WebCore::UserScriptInjectionTime, WebCore::UserContentInjectedFrames); diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp index 7bb4f89..532d058 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp @@ -99,4 +99,20 @@ void InjectedBundlePageUIClient::paintCustomOverhangArea(WebPage* page, Graphics m_client.paintCustomOverhangArea(toAPI(page), toAPI(context.get()), toAPI(horizontalOverhangArea), toAPI(verticalOverhangArea), toAPI(dirtyRect), m_client.clientInfo); } +String InjectedBundlePageUIClient::shouldGenerateFileForUpload(WebPage* page, const String& originalFilePath) +{ + if (!m_client.shouldGenerateFileForUpload) + return String(); + RefPtr<WebString> generatedFilePath = adoptRef(toImpl(m_client.shouldGenerateFileForUpload(toAPI(page), toAPI(originalFilePath.impl()), m_client.clientInfo))); + return generatedFilePath ? generatedFilePath->string() : String(); +} + +String InjectedBundlePageUIClient::generateFileForUpload(WebPage* page, const String& originalFilePath) +{ + if (!m_client.shouldGenerateFileForUpload) + return String(); + RefPtr<WebString> generatedFilePath = adoptRef(toImpl(m_client.generateFileForUpload(toAPI(page), toAPI(originalFilePath.impl()), m_client.clientInfo))); + return generatedFilePath ? generatedFilePath->string() : String(); +} + } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.h b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.h index 94925b7..47a5ca8 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.h @@ -55,6 +55,9 @@ public: bool shouldPaintCustomOverhangArea(); void paintCustomOverhangArea(WebPage*, WebCore::GraphicsContext*, const WebCore::IntRect&, const WebCore::IntRect&, const WebCore::IntRect&); + + String shouldGenerateFileForUpload(WebPage*, const String& originalFilePath); + String generateFileForUpload(WebPage*, const String& originalFilePath); }; } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/InjectedBundle/win/InjectedBundleWin.cpp b/Source/WebKit2/WebProcess/InjectedBundle/win/InjectedBundleWin.cpp index 1e593fc..4b415a4 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/win/InjectedBundleWin.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/win/InjectedBundleWin.cpp @@ -28,6 +28,8 @@ #include "WKBundleAPICast.h" #include "WKBundleInitialize.h" +#include "WebCertificateInfo.h" +#include <WebCore/ResourceHandle.h> #include <WebCore/SimpleFontData.h> #include <windows.h> @@ -35,6 +37,10 @@ #include <shlobj.h> #include <shlwapi.h> +#if USE(CFNETWORK) +#include <WebCore/CertificateCFWin.h> +#endif + using namespace WebCore; namespace WebKit { @@ -86,4 +92,27 @@ void InjectedBundle::activateMacFontAscentHack() SimpleFontData::setShouldApplyMacAscentHack(true); } +void InjectedBundle::setHostAllowsAnyHTTPSCertificate(const String& host) +{ +#if USE(CFNETWORK) + ResourceHandle::setHostAllowsAnyHTTPSCertificate(host); +#endif +} + +void InjectedBundle::setClientCertificate(const String& host, const WebCertificateInfo* certificateInfo) +{ +#if USE(CFNETWORK) + ASSERT(certificateInfo); + if (!certificateInfo) + return; + + const Vector<PCCERT_CONTEXT> certificateChain = certificateInfo->platformCertificateInfo().certificateChain(); + ASSERT(certificateChain.size() == 1); + if (certificateChain.size() != 1) + return; + + ResourceHandle::setClientCertificate(host, WebCore::copyCertificateToData(certificateChain.first()).get()); +#endif +} + } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/KeyValueStorage/WebKeyValueStorageManager.cpp b/Source/WebKit2/WebProcess/KeyValueStorage/WebKeyValueStorageManager.cpp index 5ee1419..45431c3 100644 --- a/Source/WebKit2/WebProcess/KeyValueStorage/WebKeyValueStorageManager.cpp +++ b/Source/WebKit2/WebProcess/KeyValueStorage/WebKeyValueStorageManager.cpp @@ -34,6 +34,7 @@ #include <WebCore/NotImplemented.h> #include <WebCore/SecurityOrigin.h> #include <WebCore/SecurityOriginHash.h> +#include <WebCore/StorageTracker.h> using namespace WebCore; @@ -56,39 +57,42 @@ void WebKeyValueStorageManager::didReceiveMessage(CoreIPC::Connection* connectio void WebKeyValueStorageManager::getKeyValueStorageOrigins(uint64_t callbackID) { - HashSet<RefPtr<SecurityOrigin>, SecurityOriginHash> origins; + Vector<RefPtr<SecurityOrigin> > coreOrigins; - // FIXME: <rdar://problem/8762095> and https://bugs.webkit.org/show_bug.cgi?id=55172 - Actually get the origins from WebCore once https://bugs.webkit.org/show_bug.cgi?id=51878 is resolved. + StorageTracker::tracker().origins(coreOrigins); + size_t size = coreOrigins.size(); Vector<SecurityOriginData> identifiers; - identifiers.reserveCapacity(origins.size()); + identifiers.reserveCapacity(size); - HashSet<RefPtr<SecurityOrigin>, SecurityOriginHash>::iterator end = origins.end(); - HashSet<RefPtr<SecurityOrigin>, SecurityOriginHash>::iterator i = origins.begin(); - for (; i != end; ++i) { - RefPtr<SecurityOrigin> origin = *i; - + for (size_t i = 0; i < size; ++i) { SecurityOriginData originData; - originData.protocol = origin->protocol(); - originData.host = origin->host(); - originData.port = origin->port(); + + originData.protocol = coreOrigins[i]->protocol(); + originData.host = coreOrigins[i]->host(); + originData.port = coreOrigins[i]->port(); identifiers.uncheckedAppend(originData); } WebProcess::shared().connection()->send(Messages::WebKeyValueStorageManagerProxy::DidGetKeyValueStorageOrigins(identifiers, callbackID), 0); + WebProcess::shared().terminateIfPossible(); } void WebKeyValueStorageManager::deleteEntriesForOrigin(const SecurityOriginData& originData) { - // FIXME: <rdar://problem/8762095> and https://bugs.webkit.org/show_bug.cgi?id=55172 - Implement once https://bugs.webkit.org/show_bug.cgi?id=51878 is resolved. - notImplemented(); + RefPtr<SecurityOrigin> origin = SecurityOrigin::create(originData.protocol, originData.host, originData.port); + if (!origin) + return; + + StorageTracker::tracker().deleteOrigin(origin.get()); + WebProcess::shared().terminateIfPossible(); } void WebKeyValueStorageManager::deleteAllEntries() { - // FIXME: <rdar://problem/8762095> and https://bugs.webkit.org/show_bug.cgi?id=55172 - Implement once https://bugs.webkit.org/show_bug.cgi?id=51878 is resolved. - notImplemented(); + StorageTracker::tracker().deleteAllOrigins(); + WebProcess::shared().terminateIfPossible(); } } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/MediaCache/WebMediaCacheManager.cpp b/Source/WebKit2/WebProcess/MediaCache/WebMediaCacheManager.cpp new file mode 100644 index 0000000..6baf6d9 --- /dev/null +++ b/Source/WebKit2/WebProcess/MediaCache/WebMediaCacheManager.cpp @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "WebMediaCacheManager.h" + +#include "MessageID.h" +#include "SecurityOriginData.h" +#include "WebMediaCacheManagerProxyMessages.h" +#include "WebProcess.h" +#include <WebCore/HTMLMediaElement.h> + +using namespace WebCore; + +namespace WebKit { + +WebMediaCacheManager& WebMediaCacheManager::shared() +{ + static WebMediaCacheManager& shared = *new WebMediaCacheManager; + return shared; +} + +WebMediaCacheManager::WebMediaCacheManager() +{ +} + +void WebMediaCacheManager::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments) +{ + didReceiveWebMediaCacheManagerMessage(connection, messageID, arguments); +} + +void WebMediaCacheManager::getHostnamesWithMediaCache(uint64_t callbackID) +{ + Vector<String> mediaCacheHostnames; + +#if ENABLE(VIDEO) + HTMLMediaElement::getSitesInMediaCache(mediaCacheHostnames); +#endif + + WebProcess::shared().connection()->send(Messages::WebMediaCacheManagerProxy::DidGetHostnamesWithMediaCache(mediaCacheHostnames, callbackID), 0); + WebProcess::shared().terminateIfPossible(); +} + +void WebMediaCacheManager::clearCacheForHostname(const String& hostname) +{ +#if ENABLE(VIDEO) + HTMLMediaElement::clearMediaCacheForSite(hostname); +#endif + WebProcess::shared().terminateIfPossible(); +} + +void WebMediaCacheManager::clearCacheForAllHostnames() +{ +#if ENABLE(VIDEO) + HTMLMediaElement::clearMediaCache(); +#endif + WebProcess::shared().terminateIfPossible(); +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/MediaCache/WebMediaCacheManager.h b/Source/WebKit2/WebProcess/MediaCache/WebMediaCacheManager.h new file mode 100644 index 0000000..909be97 --- /dev/null +++ b/Source/WebKit2/WebProcess/MediaCache/WebMediaCacheManager.h @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebMediaCacheManager_h +#define WebMediaCacheManager_h + +#include <wtf/Noncopyable.h> +#include <wtf/text/WTFString.h> + +namespace CoreIPC { + class ArgumentDecoder; + class Connection; + class MessageID; +} + +namespace WebKit { + +class WebMediaCacheManager { + WTF_MAKE_NONCOPYABLE(WebMediaCacheManager); + +public: + static WebMediaCacheManager& shared(); + + void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); + +private: + WebMediaCacheManager(); + + void getHostnamesWithMediaCache(uint64_t callbackID); + void clearCacheForHostname(const String&); + void clearCacheForAllHostnames(); + + void didReceiveWebMediaCacheManagerMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); +}; + +} // namespace WebKit + +#endif // WebMediaCacheManager_h diff --git a/Source/WebKit2/WebProcess/MediaCache/WebMediaCacheManager.messages.in b/Source/WebKit2/WebProcess/MediaCache/WebMediaCacheManager.messages.in new file mode 100644 index 0000000..5eee8cc --- /dev/null +++ b/Source/WebKit2/WebProcess/MediaCache/WebMediaCacheManager.messages.in @@ -0,0 +1,27 @@ +# Copyright (C) 2011 Apple Inc. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +messages -> WebMediaCacheManager { + void GetHostnamesWithMediaCache(uint64_t callbackID) + void ClearCacheForHostname(WTF::String hostname) + void ClearCacheForAllHostnames() +} diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPMethod.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPMethod.cpp index fc73519..8b36d1d 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPMethod.cpp +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPMethod.cpp @@ -42,7 +42,7 @@ namespace WebKit { const ClassInfo JSNPMethod::s_info = { "NPMethod", &InternalFunction::s_info, 0, 0 }; JSNPMethod::JSNPMethod(ExecState* exec, JSGlobalObject* globalObject, const Identifier& name, NPIdentifier npIdentifier) - : InternalFunction(&exec->globalData(), globalObject, createStructure(globalObject->functionPrototype()), name) + : InternalFunction(&exec->globalData(), globalObject, createStructure(exec->globalData(), globalObject->functionPrototype()), name) , m_npIdentifier(npIdentifier) { ASSERT(inherits(&s_info)); diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPMethod.h b/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPMethod.h index a913a99..f0c2424 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPMethod.h +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPMethod.h @@ -42,9 +42,9 @@ public: NPIdentifier npIdentifier() const { return m_npIdentifier; } private: - static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) + static PassRefPtr<JSC::Structure> createStructure(JSC::JSGlobalData& globalData, JSC::JSValue prototype) { - return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount, &s_info); + return JSC::Structure::create(globalData, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount, &s_info); } virtual JSC::CallType getCallData(JSC::CallData&); diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.cpp index 2724f0d..93f9fc5 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.cpp +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.cpp @@ -50,7 +50,7 @@ static NPIdentifier npIdentifierFromIdentifier(const Identifier& identifier) const ClassInfo JSNPObject::s_info = { "NPObject", &JSObjectWithGlobalObject::s_info, 0, 0 }; JSNPObject::JSNPObject(JSGlobalObject* globalObject, NPRuntimeObjectMap* objectMap, NPObject* npObject) - : JSObjectWithGlobalObject(globalObject, createStructure(globalObject->objectPrototype())) + : JSObjectWithGlobalObject(globalObject, createStructure(globalObject->globalData(), globalObject->objectPrototype())) , m_objectMap(objectMap) , m_npObject(npObject) { diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.h b/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.h index adaffa7..e8a08da 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.h +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.h @@ -55,9 +55,9 @@ public: private: static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::OverridesGetPropertyNames | JSObject::StructureFlags; - static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) + static PassRefPtr<JSC::Structure> createStructure(JSC::JSGlobalData& globalData, JSC::JSValue prototype) { - return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount, &s_info); + return JSC::Structure::create(globalData, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount, &s_info); } virtual JSC::CallType getCallData(JSC::CallData&); diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp index 679de6f..a548fd6 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp @@ -35,6 +35,12 @@ #include <WebCore/SharedBuffer.h> #include <utility> +#if PLATFORM(QT) +#include <QX11Info> +#elif PLATFORM(GTK) +#include <gdk/gdkx.h> +#endif + using namespace WebCore; using namespace std; @@ -484,17 +490,33 @@ static NPError NPN_GetValue(NPP npp, NPNVariable variable, void *value) *(NPBool*)value = true; break; #elif PLUGIN_ARCHITECTURE(X11) + case NPNVxDisplay: +#if PLATFORM(QT) + *reinterpret_cast<Display**>(value) = QX11Info::display(); + break; +#elif PLATFORM(GTK) + *reinterpret_cast<Display**>(value) = GDK_DISPLAY_XDISPLAY(gdk_display_get_default()); + break; +#else + goto default; +#endif + case NPNVSupportsXEmbedBool: + *static_cast<NPBool*>(value) = true; + break; + case NPNVSupportsWindowless: + *static_cast<NPBool*>(value) = true; + break; + case NPNVToolkit: { const uint32_t expectedGTKToolKitVersion = 2; RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp); - if (plugin->quirks().contains(PluginQuirks::RequiresGTKToolKit)) { - *reinterpret_cast<uint32_t*>(value) = expectedGTKToolKitVersion; - break; - } - - return NPERR_GENERIC_ERROR; + *reinterpret_cast<uint32_t*>(value) = plugin->quirks().contains(PluginQuirks::RequiresGTKToolKit) ? + expectedGTKToolKitVersion : 0; + break; } + + // TODO: implement NPNVnetscapeWindow once we want to support windowed plugins. #endif default: notImplemented(); @@ -529,7 +551,12 @@ static NPError NPN_SetValue(NPP npp, NPPVariable variable, void *value) return NPERR_NO_ERROR; } - case NPPVpluginTransparentBool: + case NPPVpluginTransparentBool: { + RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp); + plugin->setIsTransparent(value); + return NPERR_NO_ERROR; + } + default: notImplemented(); return NPERR_GENERIC_ERROR; diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp index 7e9b059..7d00219 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp @@ -64,6 +64,7 @@ NetscapePlugin::NetscapePlugin(PassRefPtr<NetscapePluginModule> pluginModule) #else , m_isWindowed(true) #endif + , m_isTransparent(false) , m_inNPPNew(false) , m_loadManually(false) #if PLATFORM(MAC) @@ -75,20 +76,23 @@ NetscapePlugin::NetscapePlugin(PassRefPtr<NetscapePluginModule> pluginModule) #ifndef NP_NO_CARBON , m_nullEventTimer(RunLoop::main(), this, &NetscapePlugin::nullEventTimerFired) , m_npCGContext() -#endif +#endif +#elif PLUGIN_ARCHITECTURE(X11) + , m_drawable(0) + , m_pluginDisplay(0) #endif { m_npp.ndata = this; m_npp.pdata = 0; - m_pluginModule->pluginCreated(); + m_pluginModule->incrementLoadCount(); } NetscapePlugin::~NetscapePlugin() { ASSERT(!m_isStarted); - m_pluginModule->pluginDestroyed(); + m_pluginModule->decrementLoadCount(); } PassRefPtr<NetscapePlugin> NetscapePlugin::fromNPP(NPP npp) @@ -189,6 +193,11 @@ void NetscapePlugin::setIsWindowed(bool isWindowed) m_isWindowed = isWindowed; } +void NetscapePlugin::setIsTransparent(bool isTransparent) +{ + m_isTransparent = isTransparent; +} + void NetscapePlugin::setStatusbarText(const String& statusbarText) { m_pluginController->setStatusbarText(statusbarText); @@ -347,8 +356,14 @@ NPError NetscapePlugin::NPP_SetValue(NPNVariable variable, void *value) void NetscapePlugin::callSetWindow() { +#if PLUGIN_ARCHITECTURE(X11) + // We use a backing store as the painting area for the plugin. + m_npWindow.x = 0; + m_npWindow.y = 0; +#else m_npWindow.x = m_frameRect.x(); m_npWindow.y = m_frameRect.y(); +#endif m_npWindow.width = m_frameRect.width(); m_npWindow.height = m_frameRect.height(); m_npWindow.clipRect.top = m_clipRect.y(); @@ -427,6 +442,17 @@ bool NetscapePlugin::initialize(PluginController* pluginController, const Parame values.append(paramValues[i].data()); } +#if PLATFORM(MAC) + if (m_pluginModule->pluginQuirks().contains(PluginQuirks::MakeTransparentIfBackgroundAttributeExists)) { + for (size_t i = 0; i < parameters.names.size(); ++i) { + if (equalIgnoringCase(parameters.names[i], "background")) { + setIsTransparent(true); + break; + } + } + } +#endif + NetscapePlugin* previousNPPNewPlugin = currentNPPNewPlugin; m_inNPPNew = true; @@ -487,7 +513,7 @@ PassRefPtr<ShareableBitmap> NetscapePlugin::snapshot() ASSERT(m_isStarted); - RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(m_frameRect.size()); + RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(m_frameRect.size(), ShareableBitmap::SupportsAlpha); OwnPtr<GraphicsContext> context = bitmap->createGraphicsContext(); context->translate(-m_frameRect.x(), -m_frameRect.y()); @@ -497,6 +523,11 @@ PassRefPtr<ShareableBitmap> NetscapePlugin::snapshot() return bitmap.release(); } +bool NetscapePlugin::isTransparent() +{ + return m_isTransparent; +} + void NetscapePlugin::geometryDidChange(const IntRect& frameRect, const IntRect& clipRect) { ASSERT(m_isStarted); diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h index e865d93..7cf9ead 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h @@ -78,6 +78,7 @@ public: const Vector<uint8_t>& httpBody, bool sendNotification, void* notificationData); NPError destroyStream(NPStream*, NPReason); void setIsWindowed(bool); + void setIsTransparent(bool); void setStatusbarText(const String&); static void setException(const String&); bool evaluate(NPObject*, const String&scriptString, NPVariant* result); @@ -145,6 +146,7 @@ private: #if PLATFORM(MAC) virtual PlatformLayer* pluginLayer(); #endif + virtual bool isTransparent(); virtual void geometryDidChange(const WebCore::IntRect& frameRect, const WebCore::IntRect& clipRect); virtual void frameDidFinishLoading(uint64_t requestID); virtual void frameDidFail(uint64_t requestID, bool wasCancelled); @@ -203,12 +205,13 @@ private: bool m_isStarted; bool m_isWindowed; + bool m_isTransparent; bool m_inNPPNew; bool m_loadManually; RefPtr<NetscapePluginStream> m_manualStream; Vector<bool, 8> m_popupEnabledStates; -#if PLATFORM(MAC) +#if PLUGIN_ARCHITECTURE(MAC) NPDrawingModel m_drawingModel; NPEventModel m_eventModel; RetainPtr<PlatformLayer> m_pluginLayer; @@ -229,8 +232,11 @@ private: RunLoop::Timer<NetscapePlugin> m_nullEventTimer; NP_CGContext m_npCGContext; #endif -#elif PLATFORM(WIN) +#elif PLUGIN_ARCHITECTURE(WIN) HWND m_window; +#elif PLUGIN_ARCHITECTURE(X11) + Pixmap m_drawable; + Display* m_pluginDisplay; #endif }; diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.cpp index 9450317..cf5affc 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.cpp +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.cpp @@ -304,7 +304,7 @@ void NetscapePluginStream::stop(NPReason reason) ASSERT(!m_filePath.isNull()); - m_plugin->NPP_StreamAsFile(&m_npStream, m_filePath.data()); + m_plugin->NPP_StreamAsFile(&m_npStream, m_filePath.utf8().data()); } else { // Just close the file. if (m_fileHandle != invalidPlatformFileHandle) @@ -315,8 +315,8 @@ void NetscapePluginStream::stop(NPReason reason) // to delete the file here -- NPP_StreamAsFile() is always called immediately before NPP_DestroyStream() // (the stream destruction function), so there can be no expectation that a plugin will read the stream // file asynchronously after NPP_StreamAsFile() is called. - deleteFile(String::fromUTF8(m_filePath.data())); - m_filePath = CString(); + deleteFile(m_filePath); + m_filePath = String(); // NPP_StreamAsFile could call NPN_DestroyStream and destroy the stream. if (!m_isStarted) diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.h b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.h index 7757001..f22ab61 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.h +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.h @@ -88,7 +88,7 @@ private: uint16_t m_transferMode; int32_t m_offset; - CString m_filePath; + String m_filePath; WebCore::PlatformFileHandle m_fileHandle; // Whether NPP_NewStream has successfully been called. diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm b/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm index 2a33008..14ac070 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm @@ -221,7 +221,8 @@ bool NetscapePlugin::platformPostInitialize() #ifndef NP_NO_QUICKDRAW // Right now we don't support the QuickDraw drawing model at all - if (m_drawingModel == NPDrawingModelQuickDraw) + if (m_drawingModel == NPDrawingModelQuickDraw && + !m_pluginModule->pluginQuirks().contains(PluginQuirks::AllowHalfBakedQuickDrawSupport)) return false; #endif @@ -230,7 +231,17 @@ bool NetscapePlugin::platformPostInitialize() // Get the Core Animation layer. if (NPP_GetValue(NPPVpluginCoreAnimationLayer, &value) == NPERR_NO_ERROR && value) { ASSERT(!m_pluginLayer); - m_pluginLayer = reinterpret_cast<CALayer *>(value); + + CALayer *realPluginLayer = reinterpret_cast<CALayer *>(value); + + // Create a layer with flipped geometry and add the real plug-in layer as a sublayer + // so the coordinate system will match the event coordinate system. + m_pluginLayer.adoptNS([[CALayer alloc] init]); + [m_pluginLayer.get() setBounds:[realPluginLayer bounds]]; + [m_pluginLayer.get() setGeometryFlipped:YES]; + + [realPluginLayer setAutoresizingMask:kCALayerWidthSizable | kCALayerHeightSizable]; + [m_pluginLayer.get() addSublayer:realPluginLayer]; } } @@ -277,6 +288,10 @@ void NetscapePlugin::platformDestroy() bool NetscapePlugin::platformInvalidate(const IntRect&) { + // NPN_InvalidateRect is just a no-op in the Core Animation drawing model. + if (m_drawingModel == NPDrawingModelCoreAnimation) + return true; + return false; } diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/qt/NetscapePluginQt.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/qt/NetscapePluginQt.cpp deleted file mode 100644 index 581dcf3..0000000 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/qt/NetscapePluginQt.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (C) 2010 Apple Inc. All rights reserved. - * Copyright (C) 2010 University of Szeged - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (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 "NetscapePlugin.h" - -#include "WebEvent.h" -#include <WebCore/GraphicsContext.h> -#include <WebCore/NotImplemented.h> - -using namespace WebCore; - -namespace WebKit { - -bool NetscapePlugin::platformPostInitialize() -{ - notImplemented(); - return true; -} - -void NetscapePlugin::platformDestroy() -{ - notImplemented(); -} - -bool NetscapePlugin::platformInvalidate(const IntRect&) -{ - notImplemented(); - return false; -} - -void NetscapePlugin::platformGeometryDidChange() -{ - notImplemented(); -} - -void NetscapePlugin::platformPaint(GraphicsContext* context, const IntRect& dirtyRect, bool) -{ - notImplemented(); -} - -NPEvent toNP(const WebMouseEvent& event) -{ -#if OS(SYMBIAN) - NPEvent npEvent = QEvent(QEvent::None); -#else - NPEvent npEvent = NPEvent(); -#endif - - notImplemented(); - - return npEvent; -} - -bool NetscapePlugin::platformHandleMouseEvent(const WebMouseEvent& event) -{ - if (m_isWindowed) - return false; - - NPEvent npEvent = toNP(event); - NPP_HandleEvent(&npEvent); - return true; -} - -bool NetscapePlugin::platformHandleWheelEvent(const WebWheelEvent&) -{ - notImplemented(); - return false; -} - -void NetscapePlugin::platformSetFocus(bool) -{ - notImplemented(); -} - -bool NetscapePlugin::platformHandleMouseEnterEvent(const WebMouseEvent& event) -{ - if (m_isWindowed) - return false; - - NPEvent npEvent = toNP(event); - NPP_HandleEvent(&npEvent); - return true; -} - -bool NetscapePlugin::platformHandleMouseLeaveEvent(const WebMouseEvent& event) -{ - if (m_isWindowed) - return false; - - NPEvent npEvent = toNP(event); - NPP_HandleEvent(&npEvent); - return true; -} - -bool NetscapePlugin::platformHandleKeyboardEvent(const WebKeyboardEvent&) -{ - notImplemented(); - return false; -} - -} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp new file mode 100644 index 0000000..27e694b --- /dev/null +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp @@ -0,0 +1,425 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010 University of Szeged + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (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 "NetscapePlugin.h" + +#include "WebEvent.h" +#include <WebCore/GraphicsContext.h> +#include <WebCore/NotImplemented.h> + +#if PLATFORM(QT) +#include <QApplication> +#include <QDesktopWidget> +#include <QPixmap> +#include <QX11Info> +#elif PLATFORM(GTK) +#include <gdk/gdkx.h> +#endif + +using namespace WebCore; + +namespace WebKit { + +static Display *getPluginDisplay() +{ +#if PLATFORM(QT) + // At the moment, we only support gdk based plugins (like Flash) that use a different X connection. + // The code below has the same effect as this one: + // Display *gdkDisplay = gdk_x11_display_get_xdisplay(gdk_display_get_default()); + + QLibrary library(QLatin1String("libgdk-x11-2.0"), 0); + if (!library.load()) + return 0; + + typedef void *(*gdk_display_get_default_ptr)(); + gdk_display_get_default_ptr gdk_display_get_default = (gdk_display_get_default_ptr)library.resolve("gdk_display_get_default"); + if (!gdk_display_get_default) + return 0; + + typedef void *(*gdk_x11_display_get_xdisplay_ptr)(void *); + gdk_x11_display_get_xdisplay_ptr gdk_x11_display_get_xdisplay = (gdk_x11_display_get_xdisplay_ptr)library.resolve("gdk_x11_display_get_xdisplay"); + if (!gdk_x11_display_get_xdisplay) + return 0; + + return (Display*)gdk_x11_display_get_xdisplay(gdk_display_get_default()); +#elif PLATFORM(GTK) + // Since we're a gdk/gtk app, we'll (probably?) have the same X connection as any gdk-based + // plugins, so we can return that. We might want to add other implementations here later. + return GDK_DISPLAY_XDISPLAY(gdk_display_get_default()); +#else + return 0; +#endif +} + +static inline Display* x11Display() +{ +#if PLATFORM(QT) + return QX11Info::display(); +#elif PLATFORM(GTK) + return GDK_DISPLAY_XDISPLAY(gdk_display_get_default()); +#else + return 0; +#endif +} + +static inline int displayDepth() +{ +#if PLATFORM(QT) + return QApplication::desktop()->x11Info().depth(); +#elif PLATFORM(GTK) + return gdk_visual_get_depth(gdk_screen_get_system_visual(gdk_screen_get_default())); +#else + return 0; +#endif +} + +static inline unsigned long rootWindowID() +{ +#if PLATFORM(QT) + return QX11Info::appRootWindow(); +#elif PLATFORM(GTK) + return GDK_ROOT_WINDOW(); +#else + return 0; +#endif +} + +static inline int x11Screen() +{ +#if PLATFORM(QT) + return QX11Info::appScreen(); +#elif PLATFORM(GTK) + return gdk_screen_get_number(gdk_screen_get_default()); +#else + return 0; +#endif +} + +bool NetscapePlugin::platformPostInitialize() +{ + if (m_isWindowed) + return false; + + if (!(m_pluginDisplay = getPluginDisplay())) + return false; + + NPSetWindowCallbackStruct* callbackStruct = new NPSetWindowCallbackStruct; + callbackStruct->type = 0; + Display* display = x11Display(); + int depth = displayDepth(); + callbackStruct->display = display; + callbackStruct->depth = depth; + + XVisualInfo visualTemplate; + visualTemplate.screen = x11Screen(); + visualTemplate.depth = depth; + visualTemplate.c_class = TrueColor; + int numMatching; + XVisualInfo* visualInfo = XGetVisualInfo(display, VisualScreenMask | VisualDepthMask | VisualClassMask, + &visualTemplate, &numMatching); + ASSERT(visualInfo); + Visual* visual = visualInfo[0].visual; + ASSERT(visual); + XFree(visualInfo); + + callbackStruct->visual = visual; + callbackStruct->colormap = XCreateColormap(display, rootWindowID(), visual, AllocNone); + + m_npWindow.type = NPWindowTypeDrawable; + m_npWindow.window = 0; + m_npWindow.ws_info = callbackStruct; + + callSetWindow(); + + return true; +} + +void NetscapePlugin::platformDestroy() +{ + delete static_cast<NPSetWindowCallbackStruct*>(m_npWindow.ws_info); + + if (m_drawable) { + XFreePixmap(x11Display(), m_drawable); + m_drawable = 0; + } +} + +bool NetscapePlugin::platformInvalidate(const IntRect&) +{ + notImplemented(); + return false; +} + +void NetscapePlugin::platformGeometryDidChange() +{ + if (m_isWindowed) { + notImplemented(); + return; + } + + Display* display = x11Display(); + if (m_drawable) + XFreePixmap(display, m_drawable); + + m_drawable = XCreatePixmap(display, rootWindowID(), m_frameRect.width(), m_frameRect.height(), displayDepth()); + + XSync(display, false); // Make sure that the server knows about the Drawable. +} + +void NetscapePlugin::platformPaint(GraphicsContext* context, const IntRect& dirtyRect, bool /*isSnapshot*/) +{ + if (m_isWindowed) { + notImplemented(); + return; + } + + if (!m_isStarted) { + // FIXME: we should paint a missing plugin icon. + return; + } + + if (context->paintingDisabled()) + return; + + ASSERT(m_drawable); + +#if PLATFORM(QT) + QPainter* painter = context->platformContext(); + painter->translate(m_frameRect.x(), m_frameRect.y()); +#else + notImplemented(); + return; +#endif + + XEvent xevent; + memset(&xevent, 0, sizeof(XEvent)); + XGraphicsExposeEvent& exposeEvent = xevent.xgraphicsexpose; + exposeEvent.type = GraphicsExpose; + exposeEvent.display = x11Display(); + exposeEvent.drawable = m_drawable; + + IntRect exposedRect(dirtyRect); + exposedRect.intersect(m_frameRect); + exposedRect.move(-m_frameRect.x(), -m_frameRect.y()); + exposeEvent.x = exposedRect.x(); + exposeEvent.y = exposedRect.y(); + + // Note: in transparent mode Flash thinks width is the right and height is the bottom. + // We should take it into account if we want to support transparency. + exposeEvent.width = exposedRect.width(); + exposeEvent.height = exposedRect.height(); + + NPP_HandleEvent(&xevent); + + if (m_pluginDisplay != x11Display()) + XSync(m_pluginDisplay, false); + +#if PLATFORM(QT) + QPixmap qtDrawable = QPixmap::fromX11Pixmap(m_drawable, QPixmap::ExplicitlyShared); + ASSERT(qtDrawable.depth() == static_cast<NPSetWindowCallbackStruct*>(m_npWindow.ws_info)->depth); + painter->drawPixmap(QPoint(exposedRect.x(), exposedRect.y()), qtDrawable, exposedRect); + + painter->translate(-m_frameRect.x(), -m_frameRect.y()); +#endif +} + +static inline void initializeXEvent(XEvent& event) +{ + memset(&event, 0, sizeof(XEvent)); + event.xany.serial = 0; + event.xany.send_event = false; + event.xany.display = x11Display(); + event.xany.window = 0; +} + +static inline uint64_t xTimeStamp(double timestampInSeconds) +{ + return timestampInSeconds * 1000; +} + +static inline unsigned xKeyModifiers(const WebEvent& event) +{ + unsigned xModifiers = 0; + if (event.controlKey()) + xModifiers |= ControlMask; + if (event.shiftKey()) + xModifiers |= ShiftMask; + if (event.altKey()) + xModifiers |= Mod1Mask; + if (event.metaKey()) + xModifiers |= Mod4Mask; + + return xModifiers; +} + +template <typename XEventType> +static inline void setCommonMouseEventFields(XEventType& xEvent, const WebMouseEvent& webEvent, const WebCore::IntPoint& pluginLocation) +{ + xEvent.root = rootWindowID(); + xEvent.subwindow = 0; + xEvent.time = xTimeStamp(webEvent.timestamp()); + xEvent.x = webEvent.position().x() - pluginLocation.x(); + xEvent.y = webEvent.position().y() - pluginLocation.y(); + xEvent.x_root = webEvent.globalPosition().x(); + xEvent.y_root = webEvent.globalPosition().y(); + xEvent.state = xKeyModifiers(webEvent); + xEvent.same_screen = true; +} + +static inline void setXMotionEventFields(XEvent& xEvent, const WebMouseEvent& webEvent, const WebCore::IntPoint& pluginLocation) +{ + XMotionEvent& xMotion = xEvent.xmotion; + setCommonMouseEventFields(xMotion, webEvent, pluginLocation); + xMotion.type = MotionNotify; +} + +static inline void setXButtonEventFields(XEvent& xEvent, const WebMouseEvent& webEvent, const WebCore::IntPoint& pluginLocation) +{ + XButtonEvent& xButton = xEvent.xbutton; + setCommonMouseEventFields(xButton, webEvent, pluginLocation); + + xButton.type = (webEvent.type() == WebEvent::MouseDown) ? ButtonPress : ButtonRelease; + switch (webEvent.button()) { + case WebMouseEvent::LeftButton: + xButton.button = Button1; + break; + case WebMouseEvent::MiddleButton: + xButton.button = Button2; + break; + case WebMouseEvent::RightButton: + xButton.button = Button3; + break; + } +} + +static inline void setXCrossingEventFields(XEvent& xEvent, const WebMouseEvent& webEvent, const WebCore::IntPoint& pluginLocation, int type) +{ + XCrossingEvent& xCrossing = xEvent.xcrossing; + setCommonMouseEventFields(xCrossing, webEvent, pluginLocation); + + xCrossing.type = type; + xCrossing.mode = NotifyNormal; + xCrossing.detail = NotifyDetailNone; + xCrossing.focus = false; +} + +bool NetscapePlugin::platformHandleMouseEvent(const WebMouseEvent& event) +{ + if (m_isWindowed) + return false; + + XEvent xEvent; + initializeXEvent(xEvent); + + switch (event.type()) { + case WebEvent::MouseDown: + case WebEvent::MouseUp: + setXButtonEventFields(xEvent, event, m_frameRect.location()); + break; + case WebEvent::MouseMove: + setXMotionEventFields(xEvent, event, m_frameRect.location()); + break; + } + + return NPP_HandleEvent(&xEvent); +} + +// We undefine these constants in npruntime_internal.h to avoid collision +// with WebKit and platform headers. Values are defined in X.h. +const int kKeyPressType = 2; +const int kKeyReleaseType = 3; +const int kFocusInType = 9; +const int kFocusOutType = 10; + +bool NetscapePlugin::platformHandleWheelEvent(const WebWheelEvent&) +{ + notImplemented(); + return false; +} + +void NetscapePlugin::platformSetFocus(bool) +{ + notImplemented(); +} + +bool NetscapePlugin::platformHandleMouseEnterEvent(const WebMouseEvent& event) +{ + if (m_isWindowed) + return false; + + XEvent xEvent; + initializeXEvent(xEvent); + setXCrossingEventFields(xEvent, event, m_frameRect.location(), EnterNotify); + + return NPP_HandleEvent(&xEvent); +} + +bool NetscapePlugin::platformHandleMouseLeaveEvent(const WebMouseEvent& event) +{ + if (m_isWindowed) + return false; + + XEvent xEvent; + initializeXEvent(xEvent); + setXCrossingEventFields(xEvent, event, m_frameRect.location(), LeaveNotify); + + return NPP_HandleEvent(&xEvent); +} + +static inline void setXKeyEventFields(XEvent& xEvent, const WebKeyboardEvent& webEvent) +{ + xEvent.xany.type = (webEvent.type() == WebEvent::KeyDown) ? kKeyPressType : kKeyReleaseType; + XKeyEvent& xKey = xEvent.xkey; + xKey.root = rootWindowID(); + xKey.subwindow = 0; + xKey.time = xTimeStamp(webEvent.timestamp()); + xKey.state = xKeyModifiers(webEvent); + xKey.keycode = webEvent.nativeVirtualKeyCode(); + + xKey.same_screen = true; + + // Key events propagated to the plugin does not need to have position. + // source: https://developer.mozilla.org/en/NPEvent + xKey.x = 0; + xKey.y = 0; + xKey.x_root = 0; + xKey.y_root = 0; +} + +bool NetscapePlugin::platformHandleKeyboardEvent(const WebKeyboardEvent& event) +{ + // We don't generate other types of keyboard events via WebEventFactory. + ASSERT(event.type() == WebEvent::KeyDown || event.type() == WebEvent::KeyUp); + + XEvent xEvent; + initializeXEvent(xEvent); + setXKeyEventFields(xEvent, event); + + return NPP_HandleEvent(&xEvent); +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/Plugins/Plugin.h b/Source/WebKit2/WebProcess/Plugins/Plugin.h index 6afeb5c..83a0ff1 100644 --- a/Source/WebKit2/WebProcess/Plugins/Plugin.h +++ b/Source/WebKit2/WebProcess/Plugins/Plugin.h @@ -84,6 +84,9 @@ public: // If a plug-in is using the Core Animation drawing model, this returns its plug-in layer. virtual PlatformLayer* pluginLayer() = 0; #endif + + // Returns whether the plug-in is transparent or not. + virtual bool isTransparent() = 0; // Tells the plug-in that either the plug-ins frame rect or its clip rect has changed. Both rects are in window coordinates. virtual void geometryDidChange(const WebCore::IntRect& frameRect, const WebCore::IntRect& clipRect) = 0; diff --git a/Source/WebKit2/WebProcess/Plugins/PluginProcessConnection.cpp b/Source/WebKit2/WebProcess/Plugins/PluginProcessConnection.cpp index ef931c8..3d007a6 100644 --- a/Source/WebKit2/WebProcess/Plugins/PluginProcessConnection.cpp +++ b/Source/WebKit2/WebProcess/Plugins/PluginProcessConnection.cpp @@ -62,13 +62,14 @@ void PluginProcessConnection::removePluginProxy(PluginProxy* plugin) ASSERT(m_plugins.contains(plugin->pluginInstanceID())); m_plugins.remove(plugin->pluginInstanceID()); + // Invalidate all objects related to this plug-in. + m_npRemoteObjectMap->pluginDestroyed(plugin); + if (!m_plugins.isEmpty()) return; - // Invalidate our remote object map. - m_npRemoteObjectMap->invalidate(); - m_npRemoteObjectMap = 0; - + m_npRemoteObjectMap = nullptr; + // We have no more plug-ins, invalidate the connection to the plug-in process. ASSERT(m_connection); m_connection->invalidate(); diff --git a/Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp b/Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp index f267d9e..fc8f552 100644 --- a/Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp +++ b/Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp @@ -132,7 +132,8 @@ void PluginProxy::paint(GraphicsContext* graphicsContext, const IntRect& dirtyRe // Blit the plug-in backing store into our own backing store. OwnPtr<WebCore::GraphicsContext> graphicsContext = m_backingStore->createGraphicsContext(); - + graphicsContext->setCompositeOperation(CompositeCopy); + m_pluginBackingStore->paint(*graphicsContext, IntPoint(), IntRect(0, 0, m_frameRect.width(), m_frameRect.height())); m_pluginBackingStoreContainsValidData = true; @@ -152,14 +153,20 @@ void PluginProxy::paint(GraphicsContext* graphicsContext, const IntRect& dirtyRe PassRefPtr<ShareableBitmap> PluginProxy::snapshot() { - IntSize bufferSize; - SharedMemory::Handle snapshotStoreHandle; - m_connection->connection()->sendSync(Messages::PluginControllerProxy::Snapshot(), Messages::PluginControllerProxy::Snapshot::Reply(bufferSize, snapshotStoreHandle), m_pluginInstanceID); + ShareableBitmap::Handle snapshotStoreHandle; + m_connection->connection()->sendSync(Messages::PluginControllerProxy::Snapshot(), Messages::PluginControllerProxy::Snapshot::Reply(snapshotStoreHandle), m_pluginInstanceID); - RefPtr<ShareableBitmap> snapshotBuffer = ShareableBitmap::create(bufferSize, snapshotStoreHandle); + RefPtr<ShareableBitmap> snapshotBuffer = ShareableBitmap::create(snapshotStoreHandle); return snapshotBuffer.release(); } +bool PluginProxy::isTransparent() +{ + // This should never be called from the web process. + ASSERT_NOT_REACHED(); + return false; +} + void PluginProxy::geometryDidChange(const IntRect& frameRect, const IntRect& clipRect) { ASSERT(m_isStarted); @@ -167,14 +174,14 @@ void PluginProxy::geometryDidChange(const IntRect& frameRect, const IntRect& cli m_frameRect = frameRect; if (!needsBackingStore()) { - SharedMemory::Handle pluginBackingStoreHandle; - m_connection->connection()->send(Messages::PluginControllerProxy::GeometryDidChange(frameRect, clipRect, pluginBackingStoreHandle), m_pluginInstanceID); + ShareableBitmap::Handle pluginBackingStoreHandle; + m_connection->connection()->send(Messages::PluginControllerProxy::GeometryDidChange(frameRect, clipRect, pluginBackingStoreHandle), m_pluginInstanceID, CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply); return; } bool didUpdateBackingStore = false; if (!m_backingStore) { - m_backingStore = ShareableBitmap::create(frameRect.size()); + m_backingStore = ShareableBitmap::create(frameRect.size(), ShareableBitmap::SupportsAlpha); didUpdateBackingStore = true; } else if (frameRect.size() != m_backingStore->size()) { // The backing store already exists, just resize it. @@ -184,24 +191,24 @@ void PluginProxy::geometryDidChange(const IntRect& frameRect, const IntRect& cli didUpdateBackingStore = true; } - SharedMemory::Handle pluginBackingStoreHandle; + ShareableBitmap::Handle pluginBackingStoreHandle; if (didUpdateBackingStore) { // Create a new plug-in backing store. - m_pluginBackingStore = ShareableBitmap::createShareable(frameRect.size()); + m_pluginBackingStore = ShareableBitmap::createShareable(frameRect.size(), ShareableBitmap::SupportsAlpha); if (!m_pluginBackingStore) return; // Create a handle to the plug-in backing store so we can send it over. if (!m_pluginBackingStore->createHandle(pluginBackingStoreHandle)) { - m_pluginBackingStore.clear(); + m_pluginBackingStore = nullptr; return; } m_pluginBackingStoreContainsValidData = false; } - m_connection->connection()->send(Messages::PluginControllerProxy::GeometryDidChange(frameRect, clipRect, pluginBackingStoreHandle), m_pluginInstanceID); + m_connection->connection()->send(Messages::PluginControllerProxy::GeometryDidChange(frameRect, clipRect, pluginBackingStoreHandle), m_pluginInstanceID, CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply); } void PluginProxy::frameDidFinishLoading(uint64_t requestID) @@ -319,7 +326,7 @@ NPObject* PluginProxy::pluginScriptableNPObject() if (!pluginScriptableNPObjectID) return 0; - return m_connection->npRemoteObjectMap()->createNPObjectProxy(pluginScriptableNPObjectID); + return m_connection->npRemoteObjectMap()->createNPObjectProxy(pluginScriptableNPObjectID, this); } #if PLATFORM(MAC) @@ -388,7 +395,7 @@ void PluginProxy::getWindowScriptNPObject(uint64_t& windowScriptNPObjectID) return; } - windowScriptNPObjectID = m_connection->npRemoteObjectMap()->registerNPObject(windowScriptNPObject); + windowScriptNPObjectID = m_connection->npRemoteObjectMap()->registerNPObject(windowScriptNPObject, this); releaseNPObject(windowScriptNPObject); } @@ -400,7 +407,7 @@ void PluginProxy::getPluginElementNPObject(uint64_t& pluginElementNPObjectID) return; } - pluginElementNPObjectID = m_connection->npRemoteObjectMap()->registerNPObject(pluginElementNPObject); + pluginElementNPObjectID = m_connection->npRemoteObjectMap()->registerNPObject(pluginElementNPObject, this); releaseNPObject(pluginElementNPObject); } @@ -408,16 +415,19 @@ void PluginProxy::evaluate(const NPVariantData& npObjectAsVariantData, const Str { PluginController::PluginDestructionProtector protector(m_pluginController); - NPVariant npObjectAsVariant = m_connection->npRemoteObjectMap()->npVariantDataToNPVariant(npObjectAsVariantData); - ASSERT(NPVARIANT_IS_OBJECT(npObjectAsVariant)); - + NPVariant npObjectAsVariant = m_connection->npRemoteObjectMap()->npVariantDataToNPVariant(npObjectAsVariantData, this); + if (!NPVARIANT_IS_OBJECT(npObjectAsVariant) || !(NPVARIANT_TO_OBJECT(npObjectAsVariant))) { + returnValue = false; + return; + } + NPVariant result; returnValue = m_pluginController->evaluate(NPVARIANT_TO_OBJECT(npObjectAsVariant), scriptString, &result, allowPopups); if (!returnValue) return; // Convert the NPVariant to an NPVariantData. - resultData = m_connection->npRemoteObjectMap()->npVariantToNPVariantData(result); + resultData = m_connection->npRemoteObjectMap()->npVariantToNPVariantData(result, this); // And release the result. releaseNPVariantValue(&result); @@ -458,7 +468,7 @@ void PluginProxy::update(const IntRect& paintedRect) if (m_backingStore) { // Blit the plug-in backing store into our own backing store. OwnPtr<GraphicsContext> graphicsContext = m_backingStore->createGraphicsContext(); - + graphicsContext->setCompositeOperation(CompositeCopy); m_pluginBackingStore->paint(*graphicsContext, paintedRectPluginCoordinates.location(), paintedRectPluginCoordinates); } diff --git a/Source/WebKit2/WebProcess/Plugins/PluginProxy.h b/Source/WebKit2/WebProcess/Plugins/PluginProxy.h index 4fe99a7..bd55a9e 100644 --- a/Source/WebKit2/WebProcess/Plugins/PluginProxy.h +++ b/Source/WebKit2/WebProcess/Plugins/PluginProxy.h @@ -68,6 +68,7 @@ private: #if PLATFORM(MAC) virtual PlatformLayer* pluginLayer(); #endif + virtual bool isTransparent(); virtual void geometryDidChange(const WebCore::IntRect& frameRect, const WebCore::IntRect& clipRect); virtual void frameDidFinishLoading(uint64_t requestID); virtual void frameDidFail(uint64_t requestID, bool wasCancelled); diff --git a/Source/WebKit2/WebProcess/Plugins/PluginView.cpp b/Source/WebKit2/WebProcess/Plugins/PluginView.cpp index 3b1629d..ec770ec 100644 --- a/Source/WebKit2/WebProcess/Plugins/PluginView.cpp +++ b/Source/WebKit2/WebProcess/Plugins/PluginView.cpp @@ -825,6 +825,11 @@ void PluginView::invalidateRect(const IntRect& dirtyRect) if (!parent() || !m_plugin || !m_isInitialized) return; +#if PLATFORM(MAC) + if (m_plugin->pluginLayer()) + return; +#endif + IntRect dirtyRectInWindowCoordinates = convertToContainingWindow(dirtyRect); parent()->hostWindow()->invalidateContentsAndWindow(intersection(dirtyRectInWindowCoordinates, clipRectInWindowCoordinates()), false); @@ -926,11 +931,12 @@ NPObject* PluginView::pluginElementNPObject() bool PluginView::evaluate(NPObject* npObject, const String& scriptString, NPVariant* result, bool allowPopups) { - if (!frame()) + RefPtr<Frame> frame = m_pluginElement->document()->frame(); + if (!frame) return false; - bool oldAllowPopups = frame()->script()->allowPopupsFromPlugin(); - frame()->script()->setAllowPopupsFromPlugin(allowPopups); + bool oldAllowPopups = frame->script()->allowPopupsFromPlugin(); + frame->script()->setAllowPopupsFromPlugin(allowPopups); // Calling evaluate will run JavaScript that can potentially remove the plug-in element, so we need to // protect the plug-in view from destruction. @@ -938,7 +944,7 @@ bool PluginView::evaluate(NPObject* npObject, const String& scriptString, NPVari bool returnValue = m_npRuntimeObjectMap.evaluate(npObject, scriptString, result); - frame()->script()->setAllowPopupsFromPlugin(oldAllowPopups); + frame->script()->setAllowPopupsFromPlugin(oldAllowPopups); return returnValue; } diff --git a/Source/WebKit2/WebProcess/ResourceCache/WebResourceCacheManager.cpp b/Source/WebKit2/WebProcess/ResourceCache/WebResourceCacheManager.cpp index dad2791..1596319 100644 --- a/Source/WebKit2/WebProcess/ResourceCache/WebResourceCacheManager.cpp +++ b/Source/WebKit2/WebProcess/ResourceCache/WebResourceCacheManager.cpp @@ -93,6 +93,7 @@ void WebResourceCacheManager::getCacheOrigins(uint64_t callbackID) const } WebProcess::shared().connection()->send(Messages::WebResourceCacheManagerProxy::DidGetCacheOrigins(identifiers, callbackID), 0); + WebProcess::shared().terminateIfPossible(); } void WebResourceCacheManager::clearCacheForOrigin(SecurityOriginData originData) const @@ -110,11 +111,13 @@ void WebResourceCacheManager::clearCacheForOrigin(SecurityOriginData originData) clearCFURLCacheForHostNames(hostArray.get()); #endif + WebProcess::shared().terminateIfPossible(); } void WebResourceCacheManager::clearCacheForAllOrigins() const { WebProcess::shared().clearResourceCaches(); + WebProcess::shared().terminateIfPossible(); } } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp index d4c357d..becf48f 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp @@ -34,6 +34,7 @@ #include "WebCoreArgumentCoders.h" #include "WebFrame.h" #include "WebFrameLoaderClient.h" +#include "WebFullScreenManager.h" #include "WebOpenPanelParameters.h" #include "WebOpenPanelResultListener.h" #include "WebPage.h" @@ -51,6 +52,7 @@ #include <WebCore/FrameView.h> #include <WebCore/HTMLNames.h> #include <WebCore/HTMLPlugInImageElement.h> +#include <WebCore/Icon.h> #include <WebCore/NotImplemented.h> #include <WebCore/Page.h> #include <WebCore/SecurityOrigin.h> @@ -115,18 +117,17 @@ FloatRect WebChromeClient::pageRect() float WebChromeClient::scaleFactor() { - notImplemented(); - return 1.0; + return m_page->userSpaceScaleFactor(); } void WebChromeClient::focus() { - notImplemented(); + m_page->send(Messages::WebPageProxy::SetFocus(true)); } void WebChromeClient::unfocus() { - notImplemented(); + m_page->send(Messages::WebPageProxy::SetFocus(false)); } bool WebChromeClient::canTakeFocus(FocusDirection) @@ -373,7 +374,7 @@ void WebChromeClient::scroll(const IntSize& scrollOffset, const IntRect& scrollR } #if ENABLE(TILED_BACKING_STORE) -void WebChromeClient::delegatedScrollRequested(const IntSize& scrollOffset) +void WebChromeClient::delegatedScrollRequested(const IntPoint& scrollOffset) { m_page->pageDidRequestScroll(scrollOffset); } @@ -385,10 +386,9 @@ IntPoint WebChromeClient::screenToWindow(const IntPoint&) const return IntPoint(); } -IntRect WebChromeClient::windowToScreen(const IntRect&) const +IntRect WebChromeClient::windowToScreen(const IntRect& rect) const { - notImplemented(); - return IntRect(); + return m_page->windowToScreen(rect); } PlatformPageClient WebChromeClient::platformPageClient() const @@ -545,14 +545,13 @@ void WebChromeClient::paintCustomHighlight(Node*, const AtomicString& type, cons bool WebChromeClient::shouldReplaceWithGeneratedFileForUpload(const String& path, String& generatedFilename) { - notImplemented(); - return false; + generatedFilename = m_page->injectedBundleUIClient().shouldGenerateFileForUpload(m_page, path); + return !generatedFilename.isNull(); } String WebChromeClient::generateReplacementFile(const String& path) { - notImplemented(); - return String(); + return m_page->injectedBundleUIClient().generateFileForUpload(m_page, path); } bool WebChromeClient::paintCustomScrollbar(GraphicsContext*, const FloatRect&, ScrollbarControlSize, @@ -610,9 +609,9 @@ void WebChromeClient::runOpenPanel(Frame* frame, PassRefPtr<FileChooser> prpFile m_page->send(Messages::WebPageProxy::RunOpenPanel(static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame()->frameID(), parameters)); } -void WebChromeClient::chooseIconForFiles(const Vector<String>&, FileChooser*) +void WebChromeClient::chooseIconForFiles(const Vector<String>& filenames, FileChooser* chooser) { - notImplemented(); + chooser->iconLoaded(Icon::createIconForFiles(filenames)); } void WebChromeClient::setCursor(const WebCore::Cursor& cursor) @@ -639,12 +638,20 @@ void WebChromeClient::formDidBlur(const Node*) bool WebChromeClient::selectItemWritingDirectionIsNatural() { +#if PLATFORM(WIN) + return true; +#else return false; +#endif } bool WebChromeClient::selectItemAlignmentFollowsMenuWritingDirection() { +#if PLATFORM(WIN) + return false; +#else return true; +#endif } PassRefPtr<WebCore::PopupMenu> WebChromeClient::createPopupMenu(WebCore::PopupMenuClient* client) const @@ -705,6 +712,29 @@ void WebChromeClient::setLastSetCursorToCurrentCursor() } #endif +#if ENABLE(FULLSCREEN_API) +bool WebChromeClient::supportsFullScreenForElement(const WebCore::Element* element, bool withKeyboard) +{ + return m_page->fullScreenManager()->supportsFullScreen(withKeyboard); +} + +void WebChromeClient::enterFullScreenForElement(WebCore::Element* element) +{ + m_page->fullScreenManager()->enterFullScreenForElement(element); +} + +void WebChromeClient::exitFullScreenForElement(WebCore::Element* element) +{ + m_page->fullScreenManager()->exitFullScreenForElement(element); +} + +void WebChromeClient::setRootFullScreenLayer(GraphicsLayer* layer) +{ + m_page->fullScreenManager()->setRootFullScreenLayer(layer); +} + +#endif + void WebChromeClient::dispatchViewportDataDidChange(const ViewportArguments& args) const { m_page->send(Messages::WebPageProxy::DidChangeViewportData(args)); diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h index 96da752..57e98c5 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h @@ -113,7 +113,7 @@ private: virtual void invalidateContentsForSlowScroll(const WebCore::IntRect&, bool); virtual void scroll(const WebCore::IntSize& scrollOffset, const WebCore::IntRect& scrollRect, const WebCore::IntRect& clipRect); #if ENABLE(TILED_BACKING_STORE) - virtual void delegatedScrollRequested(const WebCore::IntSize& scrollOffset); + virtual void delegatedScrollRequested(const WebCore::IntPoint& scrollOffset); #endif virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint&) const; virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&) const; @@ -205,6 +205,13 @@ private: virtual void setLastSetCursorToCurrentCursor(); #endif +#if ENABLE(FULLSCREEN_API) + virtual bool supportsFullScreenForElement(const WebCore::Element*, bool withKeyboard); + virtual void enterFullScreenForElement(WebCore::Element*); + virtual void exitFullScreenForElement(WebCore::Element*); + virtual void setRootFullScreenLayer(WebCore::GraphicsLayer*); +#endif + virtual void dispatchViewportDataDidChange(const WebCore::ViewportArguments&) const; virtual void didCompleteRubberBandForMainFrame(const WebCore::IntSize&) const; diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.cpp index caa6eda..825a448 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.cpp +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.cpp @@ -105,6 +105,7 @@ void WebDatabaseManager::getDatabasesByOrigin(uint64_t callbackID) const } WebProcess::shared().connection()->send(Messages::WebDatabaseManagerProxy::DidGetDatabasesByOrigin(originAndDatabasesVector, callbackID), 0); + WebProcess::shared().terminateIfPossible(); } void WebDatabaseManager::getDatabaseOrigins(uint64_t callbackID) const @@ -118,6 +119,7 @@ void WebDatabaseManager::getDatabaseOrigins(uint64_t callbackID) const for (size_t i = 0; i < numOrigins; ++i) identifiers[i] = origins[i]->databaseIdentifier(); WebProcess::shared().connection()->send(Messages::WebDatabaseManagerProxy::DidGetDatabaseOrigins(identifiers, callbackID), 0); + WebProcess::shared().terminateIfPossible(); } void WebDatabaseManager::deleteDatabaseWithNameForOrigin(const String& databaseIdentifier, const String& originIdentifier) const @@ -127,6 +129,7 @@ void WebDatabaseManager::deleteDatabaseWithNameForOrigin(const String& databaseI return; DatabaseTracker::tracker().deleteDatabase(origin.get(), databaseIdentifier); + WebProcess::shared().terminateIfPossible(); } void WebDatabaseManager::deleteDatabasesForOrigin(const String& originIdentifier) const @@ -136,11 +139,13 @@ void WebDatabaseManager::deleteDatabasesForOrigin(const String& originIdentifier return; DatabaseTracker::tracker().deleteOrigin(origin.get()); + WebProcess::shared().terminateIfPossible(); } void WebDatabaseManager::deleteAllDatabases() const { DatabaseTracker::tracker().deleteAllDatabases(); + WebProcess::shared().terminateIfPossible(); } void WebDatabaseManager::setQuotaForOrigin(const String& originIdentifier, unsigned long long quota) const @@ -154,6 +159,7 @@ void WebDatabaseManager::setQuotaForOrigin(const String& originIdentifier, unsig return; DatabaseTracker::tracker().setQuota(origin.get(), quota); + WebProcess::shared().terminateIfPossible(); } void WebDatabaseManager::dispatchDidModifyOrigin(SecurityOrigin* origin) diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h index fa8426a..9200af0 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h @@ -141,11 +141,11 @@ private: virtual void willSetInputMethodState(); virtual void setInputMethodState(bool enabled); virtual void requestCheckingOfString(WebCore::SpellChecker*, int, const WTF::String&); -#if PLATFORM(MAC) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) - virtual void showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelType, const WebCore::FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings, WebCore::Editor*); +#if PLATFORM(MAC) && !defined(BUILDING_ON_SNOW_LEOPARD) + virtual void showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelType, const WebCore::FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings); virtual void dismissCorrectionPanel(WebCore::ReasonForDismissingCorrectionPanel); - virtual bool isShowingCorrectionPanel(); - virtual void recordAutocorrectionResponse(AutocorrectionResponseType, const WTF::String& replacedString, const WTF::String& replacementString); + virtual String dismissCorrectionPanelSoon(WebCore::ReasonForDismissingCorrectionPanel); + virtual void recordAutocorrectionResponse(AutocorrectionResponseType, const String& replacedString, const String& replacementString); #endif WebPage* m_page; }; diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp index 3770ca6..fa3cdce 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010, 2011 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -386,8 +386,10 @@ void WebFrameLoaderClient::dispatchDidStartProvisionalLoad() WebPage* webPage = m_frame->page(); if (!webPage) return; + webPage->findController().hideFindUI(); - + webPage->sandboxExtensionTracker().didStartProvisionalLoad(m_frame); + DocumentLoader* provisionalLoader = m_frame->coreFrame()->loader()->provisionalDocumentLoader(); const String& url = provisionalLoader->url().string(); RefPtr<APIObject> userData; @@ -395,12 +397,10 @@ void WebFrameLoaderClient::dispatchDidStartProvisionalLoad() // Notify the bundle client. webPage->injectedBundleLoaderClient().didStartProvisionalLoadForFrame(webPage, m_frame, userData); - bool loadingSubstituteDataForUnreachableURL = !provisionalLoader->unreachableURL().isNull(); - - webPage->sandboxExtensionTracker().didStartProvisionalLoad(m_frame); + String unreachableURL = provisionalLoader->unreachableURL().string(); // Notify the UIProcess. - webPage->send(Messages::WebPageProxy::DidStartProvisionalLoadForFrame(m_frame->frameID(), url, loadingSubstituteDataForUnreachableURL, InjectedBundleUserMessageEncoder(userData.get()))); + webPage->send(Messages::WebPageProxy::DidStartProvisionalLoadForFrame(m_frame->frameID(), url, unreachableURL, InjectedBundleUserMessageEncoder(userData.get()))); } void WebFrameLoaderClient::dispatchDidReceiveTitle(const String& title) @@ -653,7 +653,7 @@ void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction(FramePolicyFu (m_frame->coreFrame()->loader()->policyChecker()->*function)(PolicyUse); return; } - + uint64_t listenerID = m_frame->setUpPolicyListener(function); bool receivedPolicyAction; uint64_t policyAction; @@ -1086,6 +1086,11 @@ void WebFrameLoaderClient::savePlatformDataToCachedFrame(CachedFrame*) void WebFrameLoaderClient::transitionToCommittedFromCachedFrame(CachedFrame*) { + WebPage* webPage = m_frame->page(); + bool isMainFrame = webPage->mainFrame() == m_frame; + + const String& mimeType = m_frame->coreFrame()->loader()->documentLoader()->response().mimeType(); + m_frameHasCustomRepresentation = isMainFrame && WebProcess::shared().shouldUseCustomRepresentationForMIMEType(mimeType); } void WebFrameLoaderClient::transitionToCommittedForNewPage() @@ -1217,6 +1222,19 @@ PassRefPtr<Widget> WebFrameLoaderClient::createPlugin(const IntSize&, HTMLPlugIn parameters.names[i] = paramNames[i].lower(); } +#if PLUGIN_ARCHITECTURE(X11) + if (equalIgnoringCase(mimeType, "application/x-shockwave-flash")) { + // Currently we don't support transparency and windowed mode. + // Inject wmode=opaque to make Flash work in these conditions. + size_t wmodeIndex = parameters.names.find("wmode"); + if (wmodeIndex == -1) { + parameters.names.append("wmode"); + parameters.values.append("opaque"); + } else if (equalIgnoringCase(parameters.values[wmodeIndex], "window")) + parameters.values[wmodeIndex] = "opaque"; + } +#endif + RefPtr<Plugin> plugin = webPage->createPlugin(parameters); if (!plugin) return 0; @@ -1237,27 +1255,58 @@ PassRefPtr<Widget> WebFrameLoaderClient::createJavaAppletWidget(const IntSize& p return createPlugin(pluginSize, appletElement, KURL(), paramNames, paramValues, "application/x-java-applet", false); } -ObjectContentType WebFrameLoaderClient::objectContentType(const KURL& url, const String& mimeTypeIn) +static bool pluginSupportsExtension(PluginData* pluginData, const String& extension) +{ + ASSERT(extension.lower() == extension); + + for (size_t i = 0; i < pluginData->mimes().size(); ++i) { + const MimeClassInfo& mimeClassInfo = pluginData->mimes()[i]; + + if (mimeClassInfo.extensions.contains(extension)) + return true; + } + return false; +} + +ObjectContentType WebFrameLoaderClient::objectContentType(const KURL& url, const String& mimeTypeIn, bool shouldPreferPlugInsForImages) { // FIXME: This should be merged with WebCore::FrameLoader::defaultObjectContentType when the plugin code // is consolidated. String mimeType = mimeTypeIn; - if (mimeType.isEmpty()) - mimeType = MIMETypeRegistry::getMIMETypeForExtension(url.path().substring(url.path().reverseFind('.') + 1)); + if (mimeType.isEmpty()) { + String extension = url.path().substring(url.path().reverseFind('.') + 1).lower(); + + // Try to guess the MIME type from the extension. + mimeType = MIMETypeRegistry::getMIMETypeForExtension(extension); + + if (mimeType.isEmpty()) { + // Check if there's a plug-in around that can handle the extension. + if (WebPage* webPage = m_frame->page()) { + if (PluginData* pluginData = webPage->corePage()->pluginData()) { + if (pluginSupportsExtension(pluginData, extension)) + return ObjectContentNetscapePlugin; + } + } + } + } if (mimeType.isEmpty()) return ObjectContentFrame; - if (MIMETypeRegistry::isSupportedImageMIMEType(mimeType)) - return WebCore::ObjectContentImage; - + bool plugInSupportsMIMEType = false; if (WebPage* webPage = m_frame->page()) { if (PluginData* pluginData = webPage->corePage()->pluginData()) { if (pluginData->supportsMimeType(mimeType)) - return ObjectContentNetscapePlugin; + plugInSupportsMIMEType = true; } } + + if (MIMETypeRegistry::isSupportedImageMIMEType(mimeType)) + return shouldPreferPlugInsForImages && plugInSupportsMIMEType ? ObjectContentNetscapePlugin : ObjectContentImage; + + if (plugInSupportsMIMEType) + return ObjectContentNetscapePlugin; if (MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType)) return ObjectContentFrame; diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h index 9ca9a75..1948541 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010, 2011 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -191,7 +191,7 @@ private: virtual PassRefPtr<WebCore::Widget> createJavaAppletWidget(const WebCore::IntSize&, WebCore::HTMLAppletElement*, const WebCore::KURL& baseURL, const Vector<String>& paramNames, const Vector<String>& paramValues); - virtual WebCore::ObjectContentType objectContentType(const WebCore::KURL& url, const String& mimeType); + virtual WebCore::ObjectContentType objectContentType(const WebCore::KURL&, const String& mimeType, bool shouldPreferPlugInsForImages); virtual String overrideMediaType() const; virtual void dispatchDidClearWindowObjectInWorld(WebCore::DOMWrapperWorld*); diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp index 7e14701..9cb6bec 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp @@ -33,60 +33,16 @@ #include "WebCookieManager.h" #include "WebCoreArgumentCoders.h" #include "WebProcess.h" -#include <WebCore/LocalizedStrings.h> -#include <WebCore/NotImplemented.h> #include <WebCore/Page.h> -#include <WebCore/PageGroup.h> -#include <wtf/MathExtras.h> -#include <wtf/text/CString.h> #if USE(CF) #include <wtf/RetainPtr.h> #endif -#if PLATFORM(MAC) - -#define UI_STRING(string, description) localizedString(string) -#define UI_STRING_KEY(string, key, description) localizedString(key) - -#else - -#define UI_STRING(string, description) String::fromUTF8(string, strlen(string)) -#define UI_STRING_KEY(string, key, description) String::fromUTF8(string, strlen(string)) - -#endif - using namespace WebCore; namespace WebKit { -// We can't use String::format for two reasons: -// 1) It doesn't handle non-ASCII characters in the format string. -// 2) It doesn't handle the %2$d syntax. -// Note that because |format| is used as the second parameter to va_start, it cannot be a reference -// type according to section 18.7/3 of the C++ N1905 standard. -static String formatLocalizedString(String format, ...) -{ -#if USE(CF) - va_list arguments; - va_start(arguments, format); - RetainPtr<CFStringRef> formatCFString(AdoptCF, format.createCFString()); - RetainPtr<CFStringRef> result(AdoptCF, CFStringCreateWithFormatAndArguments(0, 0, formatCFString.get(), arguments)); - va_end(arguments); - return result.get(); -#elif PLATFORM(QT) - va_list arguments; - va_start(arguments, format); - QString result; - result.vsprintf(format.latin1().data(), arguments); - va_end(arguments); - return result; -#else - notImplemented(); - return format; -#endif -} - void WebPlatformStrategies::initialize() { DEFINE_STATIC_LOCAL(WebPlatformStrategies, platformStrategies, ()); @@ -109,11 +65,6 @@ PluginStrategy* WebPlatformStrategies::createPluginStrategy() return this; } -LocalizationStrategy* WebPlatformStrategies::createLocalizationStrategy() -{ - return this; -} - VisitedLinkStrategy* WebPlatformStrategies::createVisitedLinkStrategy() { return this; @@ -128,25 +79,6 @@ void WebPlatformStrategies::notifyCookiesChanged() // PluginStrategy -void WebPlatformStrategies::populatePluginCache() -{ - if (m_pluginCacheIsPopulated) - return; - - ASSERT(m_cachedPlugins.isEmpty()); - - Vector<PluginInfo> plugins; - - // FIXME: Should we do something in case of error here? - WebProcess::shared().connection()->sendSync(Messages::WebContext::GetPlugins(m_shouldRefreshPlugins), - Messages::WebContext::GetPlugins::Reply(plugins), 0); - - m_cachedPlugins.swap(plugins); - - m_shouldRefreshPlugins = false; - m_pluginCacheIsPopulated = true; -} - void WebPlatformStrategies::refreshPlugins() { m_cachedPlugins.clear(); @@ -162,777 +94,27 @@ void WebPlatformStrategies::getPluginInfo(const WebCore::Page*, Vector<WebCore:: plugins = m_cachedPlugins; } -// LocalizationStrategy - -String WebPlatformStrategies::inputElementAltText() -{ - return UI_STRING_KEY("Submit", "Submit (input element)", "alt text for <input> elements with no alt, title, or value"); -} - -String WebPlatformStrategies::resetButtonDefaultLabel() -{ - return UI_STRING("Reset", "default label for Reset buttons in forms on web pages"); -} - -String WebPlatformStrategies::searchableIndexIntroduction() -{ - return UI_STRING("This is a searchable index. Enter search keywords: ", - "text that appears at the start of nearly-obsolete web pages in the form of a 'searchable index'"); -} - -String WebPlatformStrategies::submitButtonDefaultLabel() -{ - return UI_STRING("Submit", "default label for Submit buttons in forms on web pages"); -} - -String WebPlatformStrategies::fileButtonChooseFileLabel() -{ - return UI_STRING("Choose File", "title for file button used in HTML forms"); -} - -String WebPlatformStrategies::fileButtonNoFileSelectedLabel() -{ - return UI_STRING("no file selected", "text to display in file button used in HTML forms when no file is selected"); -} - -String WebPlatformStrategies::defaultDetailsSummaryText() -{ - return UI_STRING("Details", "text to display in <details> tag when it has no <summary> child"); -} - -#if PLATFORM(MAC) -String WebPlatformStrategies::copyImageUnknownFileLabel() -{ - return UI_STRING("unknown", "Unknown filename"); -} -#endif - -#if ENABLE(CONTEXT_MENUS) - -String WebPlatformStrategies::contextMenuItemTagOpenLinkInNewWindow() -{ - return UI_STRING("Open Link in New Window", "Open in New Window context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagDownloadLinkToDisk() -{ - return UI_STRING("Download Linked File", "Download Linked File context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagCopyLinkToClipboard() -{ - return UI_STRING("Copy Link", "Copy Link context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagOpenImageInNewWindow() -{ - return UI_STRING("Open Image in New Window", "Open Image in New Window context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagDownloadImageToDisk() -{ - return UI_STRING("Download Image", "Download Image context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagCopyImageToClipboard() -{ - return UI_STRING("Copy Image", "Copy Image context menu item"); -} - -#if PLATFORM(QT) -String WebPlatformStrategies::contextMenuItemTagCopyImageUrlToClipboard() -{ - return UI_STRING("Copy Image Address", "Copy Image Address menu item"); -} -#endif - -String WebPlatformStrategies::contextMenuItemTagOpenVideoInNewWindow() -{ - return UI_STRING("Open Video in New Window", "Open Video in New Window context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagOpenAudioInNewWindow() -{ - return UI_STRING("Open Audio in New Window", "Open Audio in New Window context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagCopyVideoLinkToClipboard() -{ - return UI_STRING("Copy Video Address", "Copy Video Address Location context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagCopyAudioLinkToClipboard() -{ - return UI_STRING("Copy Audio Address", "Copy Audio Address Location context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagToggleMediaControls() -{ - return UI_STRING("Controls", "Media Controls context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagToggleMediaLoop() -{ - return UI_STRING("Loop", "Media Loop context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagEnterVideoFullscreen() -{ - return UI_STRING("Enter Fullscreen", "Video Enter Fullscreen context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagMediaPlay() -{ - return UI_STRING("Play", "Media Play context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagMediaPause() -{ - return UI_STRING("Pause", "Media Pause context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagMediaMute() -{ - return UI_STRING("Mute", "Media Mute context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagOpenFrameInNewWindow() -{ - return UI_STRING("Open Frame in New Window", "Open Frame in New Window context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagCopy() -{ - return UI_STRING("Copy", "Copy context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagGoBack() -{ - return UI_STRING("Back", "Back context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagGoForward() -{ - return UI_STRING("Forward", "Forward context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagStop() -{ - return UI_STRING("Stop", "Stop context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagReload() -{ - return UI_STRING("Reload", "Reload context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagCut() -{ - return UI_STRING("Cut", "Cut context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagPaste() -{ - return UI_STRING("Paste", "Paste context menu item"); -} - -#if PLATFORM(GTK) - -String WebPlatformStrategies::contextMenuItemTagDelete() -{ - notImplemented(); - return "Delete"; -} - -String WebPlatformStrategies::contextMenuItemTagInputMethods() -{ - notImplemented(); - return "Input Methods"; -} - -String WebPlatformStrategies::contextMenuItemTagUnicode() -{ - notImplemented(); - return "Unicode"; -} - -#endif - -#if PLATFORM(GTK) || PLATFORM(QT) - -String WebPlatformStrategies::contextMenuItemTagSelectAll() -{ - notImplemented(); - return "Select All"; -} - -#endif - -String WebPlatformStrategies::contextMenuItemTagNoGuessesFound() -{ - return UI_STRING("No Guesses Found", "No Guesses Found context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagIgnoreSpelling() -{ - return UI_STRING("Ignore Spelling", "Ignore Spelling context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagLearnSpelling() -{ - return UI_STRING("Learn Spelling", "Learn Spelling context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagSearchWeb() -{ - return UI_STRING("Search in Google", "Search in Google context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagLookUpInDictionary() -{ - return UI_STRING("Look Up in Dictionary", "Look Up in Dictionary context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagOpenLink() -{ - return UI_STRING("Open Link", "Open Link context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagIgnoreGrammar() -{ - return UI_STRING("Ignore Grammar", "Ignore Grammar context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagSpellingMenu() -{ - return UI_STRING("Spelling and Grammar", "Spelling and Grammar context sub-menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagShowSpellingPanel(bool show) -{ - if (show) - return UI_STRING("Show Spelling and Grammar", "menu item title"); - return UI_STRING("Hide Spelling and Grammar", "menu item title"); -} - -String WebPlatformStrategies::contextMenuItemTagCheckSpelling() -{ - return UI_STRING("Check Document Now", "Check spelling context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagCheckSpellingWhileTyping() -{ - return UI_STRING("Check Spelling While Typing", "Check spelling while typing context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagCheckGrammarWithSpelling() -{ - return UI_STRING("Check Grammar With Spelling", "Check grammar with spelling context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagFontMenu() -{ - return UI_STRING("Font", "Font context sub-menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagBold() -{ - return UI_STRING("Bold", "Bold context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagItalic() -{ - return UI_STRING("Italic", "Italic context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagUnderline() -{ - return UI_STRING("Underline", "Underline context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagOutline() -{ - return UI_STRING("Outline", "Outline context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagWritingDirectionMenu() -{ - return UI_STRING("Paragraph Direction", "Paragraph direction context sub-menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagTextDirectionMenu() -{ - return UI_STRING("Selection Direction", "Selection direction context sub-menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagDefaultDirection() -{ - return UI_STRING("Default", "Default writing direction context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagLeftToRight() -{ - return UI_STRING("Left to Right", "Left to Right context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagRightToLeft() -{ - return UI_STRING("Right to Left", "Right to Left context menu item"); -} - -#if PLATFORM(MAC) - -String WebPlatformStrategies::contextMenuItemTagSearchInSpotlight() -{ - return UI_STRING("Search in Spotlight", "Search in Spotlight context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagShowFonts() -{ - return UI_STRING("Show Fonts", "Show fonts context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagStyles() -{ - return UI_STRING("Styles...", "Styles context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagShowColors() -{ - return UI_STRING("Show Colors", "Show colors context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagSpeechMenu() -{ - return UI_STRING("Speech", "Speech context sub-menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagStartSpeaking() -{ - return UI_STRING("Start Speaking", "Start speaking context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagStopSpeaking() -{ - return UI_STRING("Stop Speaking", "Stop speaking context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagCorrectSpellingAutomatically() -{ - return UI_STRING("Correct Spelling Automatically", "Correct Spelling Automatically context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagSubstitutionsMenu() -{ - return UI_STRING("Substitutions", "Substitutions context sub-menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagShowSubstitutions(bool show) -{ - if (show) - return UI_STRING("Show Substitutions", "menu item title"); - return UI_STRING("Hide Substitutions", "menu item title"); -} - -String WebPlatformStrategies::contextMenuItemTagSmartCopyPaste() -{ - return UI_STRING("Smart Copy/Paste", "Smart Copy/Paste context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagSmartQuotes() -{ - return UI_STRING("Smart Quotes", "Smart Quotes context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagSmartDashes() -{ - return UI_STRING("Smart Dashes", "Smart Dashes context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagSmartLinks() -{ - return UI_STRING("Smart Links", "Smart Links context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagTextReplacement() -{ - return UI_STRING("Text Replacement", "Text Replacement context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagTransformationsMenu() -{ - return UI_STRING("Transformations", "Transformations context sub-menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagMakeUpperCase() -{ - return UI_STRING("Make Upper Case", "Make Upper Case context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagMakeLowerCase() -{ - return UI_STRING("Make Lower Case", "Make Lower Case context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagCapitalize() -{ - return UI_STRING("Capitalize", "Capitalize context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagChangeBack(const String& replacedString) -{ - notImplemented(); - return replacedString; -} - -#endif - -String WebPlatformStrategies::contextMenuItemTagInspectElement() -{ - return UI_STRING("Inspect Element", "Inspect Element context menu item"); -} - -#endif // ENABLE(CONTEXT_MENUS) - -String WebPlatformStrategies::searchMenuNoRecentSearchesText() -{ - return UI_STRING("No recent searches", "Label for only item in menu that appears when clicking on the search field image, when no searches have been performed"); -} - -String WebPlatformStrategies::searchMenuRecentSearchesText() -{ - return UI_STRING("Recent Searches", "label for first item in the menu that appears when clicking on the search field image, used as embedded menu title"); -} - -String WebPlatformStrategies::searchMenuClearRecentSearchesText() -{ - return UI_STRING("Clear Recent Searches", "menu item in Recent Searches menu that empties menu's contents"); -} - -String WebPlatformStrategies::AXWebAreaText() -{ - return UI_STRING("HTML content", "accessibility role description for web area"); -} - -String WebPlatformStrategies::AXLinkText() -{ - return UI_STRING("link", "accessibility role description for link"); -} - -String WebPlatformStrategies::AXListMarkerText() -{ - return UI_STRING("list marker", "accessibility role description for list marker"); -} - -String WebPlatformStrategies::AXImageMapText() -{ - return UI_STRING("image map", "accessibility role description for image map"); -} - -String WebPlatformStrategies::AXHeadingText() -{ - return UI_STRING("heading", "accessibility role description for headings"); -} - -String WebPlatformStrategies::AXDefinitionListTermText() -{ - return UI_STRING("term", "term word of a definition"); -} - -String WebPlatformStrategies::AXDefinitionListDefinitionText() -{ - return UI_STRING("definition", "definition phrase"); -} - -#if PLATFORM(MAC) -String WebPlatformStrategies::AXARIAContentGroupText(const String& ariaType) -{ - if (ariaType == "ARIAApplicationAlert") - return UI_STRING("alert", "An ARIA accessibility group that acts as an alert."); - if (ariaType == "ARIAApplicationAlertDialog") - return UI_STRING("alert dialog", "An ARIA accessibility group that acts as an alert dialog."); - if (ariaType == "ARIAApplicationDialog") - return UI_STRING("dialog", "An ARIA accessibility group that acts as an dialog."); - if (ariaType == "ARIAApplicationLog") - return UI_STRING("log", "An ARIA accessibility group that acts as a console log."); - if (ariaType == "ARIAApplicationMarquee") - return UI_STRING("marquee", "An ARIA accessibility group that acts as a marquee."); - if (ariaType == "ARIAApplicationStatus") - return UI_STRING("application status", "An ARIA accessibility group that acts as a status update."); - if (ariaType == "ARIAApplicationTimer") - return UI_STRING("timer", "An ARIA accessibility group that acts as an updating timer."); - if (ariaType == "ARIADocument") - return UI_STRING("document", "An ARIA accessibility group that acts as a document."); - if (ariaType == "ARIADocumentArticle") - return UI_STRING("article", "An ARIA accessibility group that acts as an article."); - if (ariaType == "ARIADocumentNote") - return UI_STRING("note", "An ARIA accessibility group that acts as a note in a document."); - if (ariaType == "ARIADocumentRegion") - return UI_STRING("region", "An ARIA accessibility group that acts as a distinct region in a document."); - if (ariaType == "ARIALandmarkApplication") - return UI_STRING("application", "An ARIA accessibility group that acts as an application."); - if (ariaType == "ARIALandmarkBanner") - return UI_STRING("banner", "An ARIA accessibility group that acts as a banner."); - if (ariaType == "ARIALandmarkComplementary") - return UI_STRING("complementary", "An ARIA accessibility group that acts as a region of complementary information."); - if (ariaType == "ARIALandmarkContentInfo") - return UI_STRING("content", "An ARIA accessibility group that contains content."); - if (ariaType == "ARIALandmarkMain") - return UI_STRING("main", "An ARIA accessibility group that is the main portion of the website."); - if (ariaType == "ARIALandmarkNavigation") - return UI_STRING("navigation", "An ARIA accessibility group that contains the main navigation elements of a website."); - if (ariaType == "ARIALandmarkSearch") - return UI_STRING("search", "An ARIA accessibility group that contains a search feature of a website."); - if (ariaType == "ARIAUserInterfaceTooltip") - return UI_STRING("tooltip", "An ARIA accessibility group that acts as a tooltip."); - if (ariaType == "ARIATabPanel") - return UI_STRING("tab panel", "An ARIA accessibility group that contains the content of a tab."); - if (ariaType == "ARIADocumentMath") - return UI_STRING("math", "An ARIA accessibility group that contains mathematical symbols."); - return String(); -} -#endif - -String WebPlatformStrategies::AXButtonActionVerb() -{ - return UI_STRING("press", "Verb stating the action that will occur when a button is pressed, as used by accessibility"); -} - -String WebPlatformStrategies::AXRadioButtonActionVerb() -{ - return UI_STRING("select", "Verb stating the action that will occur when a radio button is clicked, as used by accessibility"); -} - -String WebPlatformStrategies::AXTextFieldActionVerb() -{ - return UI_STRING("activate", "Verb stating the action that will occur when a text field is selected, as used by accessibility"); -} - -String WebPlatformStrategies::AXCheckedCheckBoxActionVerb() -{ - return UI_STRING("uncheck", "Verb stating the action that will occur when a checked checkbox is clicked, as used by accessibility"); -} - -String WebPlatformStrategies::AXUncheckedCheckBoxActionVerb() -{ - return UI_STRING("check", "Verb stating the action that will occur when an unchecked checkbox is clicked, as used by accessibility"); -} - -String WebPlatformStrategies::AXMenuListActionVerb() -{ - notImplemented(); - return "select"; -} - -String WebPlatformStrategies::AXMenuListPopupActionVerb() -{ - notImplemented(); - return "select"; -} - -String WebPlatformStrategies::AXLinkActionVerb() -{ - return UI_STRING("jump", "Verb stating the action that will occur when a link is clicked, as used by accessibility"); -} - -String WebPlatformStrategies::missingPluginText() -{ - return UI_STRING("Missing Plug-in", "Label text to be used when a plugin is missing"); -} - -String WebPlatformStrategies::crashedPluginText() -{ - return UI_STRING("Plug-in Failure", "Label text to be used if plugin host process has crashed"); -} - -String WebPlatformStrategies::multipleFileUploadText(unsigned numberOfFiles) -{ - return formatLocalizedString(UI_STRING("%d files", "Label to describe the number of files selected in a file upload control that allows multiple files"), numberOfFiles); -} - -String WebPlatformStrategies::unknownFileSizeText() -{ - return UI_STRING("Unknown", "Unknown filesize FTP directory listing item"); -} - -#if PLATFORM(WIN) - -String WebPlatformStrategies::uploadFileText() -{ - notImplemented(); - return "upload"; -} - -String WebPlatformStrategies::allFilesText() -{ - notImplemented(); - return "all files"; -} - -#endif - -String WebPlatformStrategies::imageTitle(const String& filename, const IntSize& size) -{ - // FIXME: This should format the numbers correctly. In Mac WebKit, we used +[NSNumberFormatter localizedStringFromNumber:numberStyle:]. - return formatLocalizedString(UI_STRING("<filename> %d×%d pixels", "window title suffix for a standalone image (uses multiplication symbol, not x)"), size.width(), size.height()).replace("<filename>", filename); -} - -String WebPlatformStrategies::mediaElementLoadingStateText() -{ - return UI_STRING("Loading...", "Media controller status message when the media is loading"); -} - -String WebPlatformStrategies::mediaElementLiveBroadcastStateText() -{ - return UI_STRING("Live Broadcast", "Media controller status message when watching a live broadcast"); -} - -String WebPlatformStrategies::localizedMediaControlElementString(const String& name) -{ - if (name == "AudioElement") - return UI_STRING("audio element controller", "accessibility role description for audio element controller"); - if (name == "VideoElement") - return UI_STRING("video element controller", "accessibility role description for video element controller"); - if (name == "MuteButton") - return UI_STRING("mute", "accessibility role description for mute button"); - if (name == "UnMuteButton") - return UI_STRING("unmute", "accessibility role description for turn mute off button"); - if (name == "PlayButton") - return UI_STRING("play", "accessibility role description for play button"); - if (name == "PauseButton") - return UI_STRING("pause", "accessibility role description for pause button"); - if (name == "Slider") - return UI_STRING("movie time", "accessibility role description for timeline slider"); - if (name == "SliderThumb") - return UI_STRING("timeline slider thumb", "accessibility role description for timeline thumb"); - if (name == "RewindButton") - return UI_STRING("back 30 seconds", "accessibility role description for seek back 30 seconds button"); - if (name == "ReturnToRealtimeButton") - return UI_STRING("return to realtime", "accessibility role description for return to real time button"); - if (name == "CurrentTimeDisplay") - return UI_STRING("elapsed time", "accessibility role description for elapsed time display"); - if (name == "TimeRemainingDisplay") - return UI_STRING("remaining time", "accessibility role description for time remaining display"); - if (name == "StatusDisplay") - return UI_STRING("status", "accessibility role description for movie status"); - if (name == "FullscreenButton") - return UI_STRING("fullscreen", "accessibility role description for enter fullscreen button"); - if (name == "SeekForwardButton") - return UI_STRING("fast forward", "accessibility role description for fast forward button"); - if (name == "SeekBackButton") - return UI_STRING("fast reverse", "accessibility role description for fast reverse button"); - if (name == "ShowClosedCaptionsButton") - return UI_STRING("show closed captions", "accessibility role description for show closed captions button"); - if (name == "HideClosedCaptionsButton") - return UI_STRING("hide closed captions", "accessibility role description for hide closed captions button"); - - // FIXME: the ControlsPanel container should never be visible in the accessibility hierarchy. - if (name == "ControlsPanel") - return String(); - - ASSERT_NOT_REACHED(); - return String(); -} - -String WebPlatformStrategies::localizedMediaControlElementHelpText(const String& name) -{ - if (name == "AudioElement") - return UI_STRING("audio element playback controls and status display", "accessibility role description for audio element controller"); - if (name == "VideoElement") - return UI_STRING("video element playback controls and status display", "accessibility role description for video element controller"); - if (name == "MuteButton") - return UI_STRING("mute audio tracks", "accessibility help text for mute button"); - if (name == "UnMuteButton") - return UI_STRING("unmute audio tracks", "accessibility help text for un mute button"); - if (name == "PlayButton") - return UI_STRING("begin playback", "accessibility help text for play button"); - if (name == "PauseButton") - return UI_STRING("pause playback", "accessibility help text for pause button"); - if (name == "Slider") - return UI_STRING("movie time scrubber", "accessibility help text for timeline slider"); - if (name == "SliderThumb") - return UI_STRING("movie time scrubber thumb", "accessibility help text for timeline slider thumb"); - if (name == "RewindButton") - return UI_STRING("seek movie back 30 seconds", "accessibility help text for jump back 30 seconds button"); - if (name == "ReturnToRealtimeButton") - return UI_STRING("return streaming movie to real time", "accessibility help text for return streaming movie to real time button"); - if (name == "CurrentTimeDisplay") - return UI_STRING("current movie time in seconds", "accessibility help text for elapsed time display"); - if (name == "TimeRemainingDisplay") - return UI_STRING("number of seconds of movie remaining", "accessibility help text for remaining time display"); - if (name == "StatusDisplay") - return UI_STRING("current movie status", "accessibility help text for movie status display"); - if (name == "SeekBackButton") - return UI_STRING("seek quickly back", "accessibility help text for fast rewind button"); - if (name == "SeekForwardButton") - return UI_STRING("seek quickly forward", "accessibility help text for fast forward button"); - if (name == "FullscreenButton") - return UI_STRING("Play movie in fullscreen mode", "accessibility help text for enter fullscreen button"); - if (name == "ShowClosedCaptionsButton") - return UI_STRING("start displaying closed captions", "accessibility help text for show closed captions button"); - if (name == "HideClosedCaptionsButton") - return UI_STRING("stop displaying closed captions", "accessibility help text for hide closed captions button"); - - ASSERT_NOT_REACHED(); - return String(); -} - -String WebPlatformStrategies::localizedMediaTimeDescription(float time) -{ - if (!isfinite(time)) - return UI_STRING("indefinite time", "accessibility help text for an indefinite media controller time value"); - - int seconds = static_cast<int>(fabsf(time)); - int days = seconds / (60 * 60 * 24); - int hours = seconds / (60 * 60); - int minutes = (seconds / 60) % 60; - seconds %= 60; - - if (days) - return formatLocalizedString(UI_STRING("%1$d days %2$d hours %3$d minutes %4$d seconds", "accessibility help text for media controller time value >= 1 day"), days, hours, minutes, seconds); - if (hours) - return formatLocalizedString(UI_STRING("%1$d hours %2$d minutes %3$d seconds", "accessibility help text for media controller time value >= 60 minutes"), hours, minutes, seconds); - if (minutes) - return formatLocalizedString(UI_STRING("%1$d minutes %2$d seconds", "accessibility help text for media controller time value >= 60 seconds"), minutes, seconds); - return formatLocalizedString(UI_STRING("%1$d seconds", "accessibility help text for media controller time value < 60 seconds"), seconds); -} - -String WebPlatformStrategies::validationMessageValueMissingText() -{ - return UI_STRING("value missing", "Validation message for required form control elements that have no value"); -} - -String WebPlatformStrategies::validationMessageTypeMismatchText() -{ - return UI_STRING("type mismatch", "Validation message for input form controls with a value not matching type"); -} - -String WebPlatformStrategies::validationMessagePatternMismatchText() -{ - return UI_STRING("pattern mismatch", "Validation message for input form controls requiring a constrained value according to pattern"); -} - -String WebPlatformStrategies::validationMessageTooLongText() -{ - return UI_STRING("too long", "Validation message for form control elements with a value longer than maximum allowed length"); -} - -String WebPlatformStrategies::validationMessageRangeUnderflowText() +void WebPlatformStrategies::populatePluginCache() { - return UI_STRING("range underflow", "Validation message for input form controls with value lower than allowed minimum"); -} + if (m_pluginCacheIsPopulated) + return; -String WebPlatformStrategies::validationMessageRangeOverflowText() -{ - return UI_STRING("range overflow", "Validation message for input form controls with value higher than allowed maximum"); -} + ASSERT(m_cachedPlugins.isEmpty()); + + Vector<PluginInfo> plugins; + + // FIXME: Should we do something in case of error here? + WebProcess::shared().connection()->sendSync(Messages::WebContext::GetPlugins(m_shouldRefreshPlugins), + Messages::WebContext::GetPlugins::Reply(plugins), 0); -String WebPlatformStrategies::validationMessageStepMismatchText() -{ - return UI_STRING("step mismatch", "Validation message for input form controls with value not respecting the step attribute"); + m_cachedPlugins.swap(plugins); + + m_shouldRefreshPlugins = false; + m_pluginCacheIsPopulated = true; } // VisitedLinkStrategy + bool WebPlatformStrategies::isLinkVisited(Page* page, LinkHash linkHash) { return WebProcess::shared().isLinkVisited(linkHash); diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h index 92f8236..55285de 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h @@ -31,12 +31,11 @@ #include <WebCore/CookiesStrategy.h> #include <WebCore/PlatformStrategies.h> #include <WebCore/PluginStrategy.h> -#include <WebCore/LocalizationStrategy.h> #include <WebCore/VisitedLinkStrategy.h> namespace WebKit { -class WebPlatformStrategies : public WebCore::PlatformStrategies, private WebCore::CookiesStrategy, private WebCore::PluginStrategy, private WebCore::LocalizationStrategy, private WebCore::VisitedLinkStrategy { +class WebPlatformStrategies : public WebCore::PlatformStrategies, private WebCore::CookiesStrategy, private WebCore::PluginStrategy, private WebCore::VisitedLinkStrategy { public: static void initialize(); @@ -46,7 +45,6 @@ private: // WebCore::PlatformStrategies virtual WebCore::CookiesStrategy* createCookiesStrategy(); virtual WebCore::PluginStrategy* createPluginStrategy(); - virtual WebCore::LocalizationStrategy* createLocalizationStrategy(); virtual WebCore::VisitedLinkStrategy* createVisitedLinkStrategy(); // WebCore::CookiesStrategy @@ -55,152 +53,15 @@ private: // WebCore::PluginStrategy virtual void refreshPlugins(); virtual void getPluginInfo(const WebCore::Page*, Vector<WebCore::PluginInfo>&); - - // WebCore::LocalizationStrategy - virtual String inputElementAltText(); - virtual String resetButtonDefaultLabel(); - virtual String searchableIndexIntroduction(); - virtual String submitButtonDefaultLabel(); - virtual String fileButtonChooseFileLabel(); - virtual String fileButtonNoFileSelectedLabel(); - virtual String defaultDetailsSummaryText(); -#if PLATFORM(MAC) - virtual String copyImageUnknownFileLabel(); -#endif -#if ENABLE(CONTEXT_MENUS) - virtual String contextMenuItemTagOpenLinkInNewWindow(); - virtual String contextMenuItemTagDownloadLinkToDisk(); - virtual String contextMenuItemTagCopyLinkToClipboard(); - virtual String contextMenuItemTagOpenImageInNewWindow(); - virtual String contextMenuItemTagDownloadImageToDisk(); - virtual String contextMenuItemTagCopyImageToClipboard(); -#if PLATFORM(QT) - virtual String contextMenuItemTagCopyImageUrlToClipboard(); -#endif - virtual String contextMenuItemTagOpenFrameInNewWindow(); - virtual String contextMenuItemTagCopy(); - virtual String contextMenuItemTagGoBack(); - virtual String contextMenuItemTagGoForward(); - virtual String contextMenuItemTagStop(); - virtual String contextMenuItemTagReload(); - virtual String contextMenuItemTagCut(); - virtual String contextMenuItemTagPaste(); -#if PLATFORM(GTK) - virtual String contextMenuItemTagDelete(); - virtual String contextMenuItemTagInputMethods(); - virtual String contextMenuItemTagUnicode(); -#endif -#if PLATFORM(GTK) || PLATFORM(QT) - virtual String contextMenuItemTagSelectAll(); -#endif - virtual String contextMenuItemTagNoGuessesFound(); - virtual String contextMenuItemTagIgnoreSpelling(); - virtual String contextMenuItemTagLearnSpelling(); - virtual String contextMenuItemTagSearchWeb(); - virtual String contextMenuItemTagLookUpInDictionary(); - virtual String contextMenuItemTagOpenLink(); - virtual String contextMenuItemTagIgnoreGrammar(); - virtual String contextMenuItemTagSpellingMenu(); - virtual String contextMenuItemTagShowSpellingPanel(bool show); - virtual String contextMenuItemTagCheckSpelling(); - virtual String contextMenuItemTagCheckSpellingWhileTyping(); - virtual String contextMenuItemTagCheckGrammarWithSpelling(); - virtual String contextMenuItemTagFontMenu(); - virtual String contextMenuItemTagBold(); - virtual String contextMenuItemTagItalic(); - virtual String contextMenuItemTagUnderline(); - virtual String contextMenuItemTagOutline(); - virtual String contextMenuItemTagWritingDirectionMenu(); - virtual String contextMenuItemTagTextDirectionMenu(); - virtual String contextMenuItemTagDefaultDirection(); - virtual String contextMenuItemTagLeftToRight(); - virtual String contextMenuItemTagRightToLeft(); -#if PLATFORM(MAC) - virtual String contextMenuItemTagSearchInSpotlight(); - virtual String contextMenuItemTagShowFonts(); - virtual String contextMenuItemTagStyles(); - virtual String contextMenuItemTagShowColors(); - virtual String contextMenuItemTagSpeechMenu(); - virtual String contextMenuItemTagStartSpeaking(); - virtual String contextMenuItemTagStopSpeaking(); - virtual String contextMenuItemTagCorrectSpellingAutomatically(); - virtual String contextMenuItemTagSubstitutionsMenu(); - virtual String contextMenuItemTagShowSubstitutions(bool show); - virtual String contextMenuItemTagSmartCopyPaste(); - virtual String contextMenuItemTagSmartQuotes(); - virtual String contextMenuItemTagSmartDashes(); - virtual String contextMenuItemTagSmartLinks(); - virtual String contextMenuItemTagTextReplacement(); - virtual String contextMenuItemTagTransformationsMenu(); - virtual String contextMenuItemTagMakeUpperCase(); - virtual String contextMenuItemTagMakeLowerCase(); - virtual String contextMenuItemTagCapitalize(); - virtual String contextMenuItemTagChangeBack(const String& replacedString); -#endif - virtual String contextMenuItemTagInspectElement(); - virtual String contextMenuItemTagOpenVideoInNewWindow(); - virtual String contextMenuItemTagOpenAudioInNewWindow(); - virtual String contextMenuItemTagCopyVideoLinkToClipboard(); - virtual String contextMenuItemTagCopyAudioLinkToClipboard(); - virtual String contextMenuItemTagToggleMediaControls(); - virtual String contextMenuItemTagToggleMediaLoop(); - virtual String contextMenuItemTagEnterVideoFullscreen(); - virtual String contextMenuItemTagMediaPlay(); - virtual String contextMenuItemTagMediaPause(); - virtual String contextMenuItemTagMediaMute(); -#endif // ENABLE(CONTEXT_MENUS) - virtual String searchMenuNoRecentSearchesText(); - virtual String searchMenuRecentSearchesText(); - virtual String searchMenuClearRecentSearchesText(); - virtual String AXWebAreaText(); - virtual String AXLinkText(); - virtual String AXListMarkerText(); - virtual String AXImageMapText(); - virtual String AXHeadingText(); - virtual String AXDefinitionListTermText(); - virtual String AXDefinitionListDefinitionText(); -#if PLATFORM(MAC) - virtual String AXARIAContentGroupText(const String& ariaType); -#endif - virtual String AXButtonActionVerb(); - virtual String AXRadioButtonActionVerb(); - virtual String AXTextFieldActionVerb(); - virtual String AXCheckedCheckBoxActionVerb(); - virtual String AXUncheckedCheckBoxActionVerb(); - virtual String AXMenuListActionVerb(); - virtual String AXMenuListPopupActionVerb(); - virtual String AXLinkActionVerb(); - virtual String missingPluginText(); - virtual String crashedPluginText(); - virtual String multipleFileUploadText(unsigned numberOfFiles); - virtual String unknownFileSizeText(); -#if PLATFORM(WIN) - virtual String uploadFileText(); - virtual String allFilesText(); -#endif - virtual String imageTitle(const String& filename, const WebCore::IntSize& size); - virtual String mediaElementLoadingStateText(); - virtual String mediaElementLiveBroadcastStateText(); - virtual String localizedMediaControlElementString(const String&); - virtual String localizedMediaControlElementHelpText(const String&); - virtual String localizedMediaTimeDescription(float); - virtual String validationMessageValueMissingText(); - virtual String validationMessageTypeMismatchText(); - virtual String validationMessagePatternMismatchText(); - virtual String validationMessageTooLongText(); - virtual String validationMessageRangeUnderflowText(); - virtual String validationMessageRangeOverflowText(); - virtual String validationMessageStepMismatchText(); - void populatePluginCache(); - bool m_pluginCacheIsPopulated; - bool m_shouldRefreshPlugins; - Vector<WebCore::PluginInfo> m_cachedPlugins; - // WebCore::VisitedLinkStrategy virtual bool isLinkVisited(WebCore::Page*, WebCore::LinkHash); virtual void addVisitedLink(WebCore::Page*, WebCore::LinkHash); + + bool m_pluginCacheIsPopulated; + bool m_shouldRefreshPlugins; + Vector<WebCore::PluginInfo> m_cachedPlugins; }; } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebContextMenuClientMac.mm b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebContextMenuClientMac.mm index 7d91c56..6aa83f8 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebContextMenuClientMac.mm +++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebContextMenuClientMac.mm @@ -41,11 +41,7 @@ namespace WebKit { void WebContextMenuClient::lookUpInDictionary(Frame* frame) { - RefPtr<Range> selectedRange = frame->selection()->selection().toNormalizedRange(); - if (!selectedRange) - return; - - m_page->performDictionaryLookupForRange(DictionaryPopupInfo::ContextMenu, frame, selectedRange.get()); + m_page->performDictionaryLookupForSelection(DictionaryPopupInfo::ContextMenu, frame, frame->selection()->selection()); } bool WebContextMenuClient::isSpeaking() diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm index ae9cec3..75d92e2 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm +++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm @@ -32,134 +32,273 @@ #import "WebPage.h" #import "WebPageProxyMessages.h" #import <WebCore/CachedImage.h> -#import <WebCore/DOMPrivate.h> #import <WebCore/DOMElementInternal.h> +#import <WebCore/DOMPrivate.h> +#import <WebCore/DragController.h> #import <WebCore/FrameView.h> #import <WebCore/GraphicsContext.h> #import <WebCore/LegacyWebArchive.h> #import <WebCore/RenderImage.h> +#import <WebCore/ResourceHandle.h> #import <WebCore/StringTruncator.h> -#import <wtf/StdLibExtras.h> +#import <WebKit/WebArchive.h> #import <WebKit/WebKitNSStringExtras.h> +#import <WebKit/WebNSFileManagerExtras.h> +#import <WebKit/WebNSPasteboardExtras.h> #import <WebKit/WebNSURLExtras.h> +#import <WebKitSystemInterface.h> +#import <wtf/StdLibExtras.h> using namespace WebCore; +using namespace WebKit; + +// Internal AppKit class. If the pasteboard handling was in the same process +// that called the dragImage method, this would be created automatically. +// Create it explicitly because dragImage is called in the UI process. +@interface NSFilePromiseDragSource : NSObject +{ + char _unknownFields[256]; +} +- (id)initWithSource:(id)dragSource; +- (void)setTypes:(NSArray *)types onPasteboard:(NSPasteboard *)pasteboard; +@end + +@interface WKPasteboardFilePromiseOwner : NSFilePromiseDragSource +@end + +@interface WKPasteboardOwner : NSObject +{ + CachedResourceHandle<CachedImage> _image; +} +- (id)initWithImage:(CachedImage*)image; +@end namespace WebKit { -using namespace WebCore; - -void WebDragClient::startDrag(DragImageRef dragImage, const IntPoint& at, const IntPoint& eventPos, Clipboard* clipboard, Frame* frame, bool linkDrag) +static PassRefPtr<ShareableBitmap> convertImageToBitmap(NSImage *image) { - if (!frame) - return; - ASSERT(clipboard); - - NSImage *dragNSImage = dragImage.get(); - RefPtr<ShareableBitmap> dragShareableImage = ShareableBitmap::createShareable(IntSize([dragNSImage size])); - OwnPtr<GraphicsContext> graphicsContext = dragShareableImage->createGraphicsContext(); + RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(IntSize([image size]), ShareableBitmap::SupportsAlpha); + OwnPtr<GraphicsContext> graphicsContext = bitmap->createGraphicsContext(); - [NSGraphicsContext saveGraphicsState]; - NSGraphicsContext* bitmapContext = [NSGraphicsContext graphicsContextWithGraphicsPort:graphicsContext->platformContext() flipped:YES]; - [NSGraphicsContext setCurrentContext: bitmapContext]; - - [dragNSImage drawInRect:NSMakeRect(0, 0, [dragNSImage size].width , [dragNSImage size].height) fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1 respectFlipped:YES hints:nil]; - [NSGraphicsContext restoreGraphicsState]; - - SharedMemory::Handle handle; - if (!dragShareableImage->createHandle(handle)) + RetainPtr<NSGraphicsContext> savedContext = [NSGraphicsContext currentContext]; + + [NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithGraphicsPort:graphicsContext->platformContext() flipped:YES]]; + [image drawInRect:NSMakeRect(0, 0, bitmap->size().width(), bitmap->size().height()) fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1 respectFlipped:YES hints:nil]; + + [NSGraphicsContext setCurrentContext:savedContext.get()]; + + return bitmap.release(); +} + +void WebDragClient::startDrag(RetainPtr<NSImage> image, const IntPoint& point, const IntPoint&, Clipboard*, Frame* frame, bool linkDrag) +{ + RefPtr<ShareableBitmap> bitmap = convertImageToBitmap(image.get()); + ShareableBitmap::Handle handle; + if (!bitmap->createHandle(handle)) return; - IntPoint clientPoint(at); - m_page->send(Messages::WebPageProxy::SetDragImage(clientPoint, IntSize([dragNSImage size]), handle, linkDrag)); + + // FIXME: Seems this message should be named StartDrag, not SetDragImage. + m_page->send(Messages::WebPageProxy::SetDragImage(frame->view()->contentsToWindow(point), handle, linkDrag)); } -static void writeURL(NSPasteboard* pasteboard, NSURL* URL, NSString* title, NSArray* types) +static CachedImage* cachedImage(Element* element) { - ASSERT(URL); - + RenderObject* renderer = element->renderer(); + if (!renderer) + return 0; + if (!renderer->isRenderImage()) + return 0; + CachedImage* image = toRenderImage(renderer)->cachedImage(); + if (!image || image->errorOccurred()) + return 0; + return image; +} + +static NSArray *arrayForURLsWithTitles(NSURL *URL, NSString *title) +{ + return [NSArray arrayWithObjects:[NSArray arrayWithObject:[URL _web_originalDataAsString]], + [NSArray arrayWithObject:[title _webkit_stringByTrimmingWhitespace]], nil]; +} + +void WebDragClient::declareAndWriteDragImage(NSPasteboard *pasteboard, DOMElement *element, NSURL *URL, NSString *title, WebCore::Frame*) +{ + ASSERT(element); + ASSERT(pasteboard && pasteboard == [NSPasteboard pasteboardWithName:NSDragPboard]); + + Element* coreElement = core(element); + + CachedImage* image = cachedImage(coreElement); + + NSString *extension = @""; + if (image) { + extension = image->image()->filenameExtension(); + if (![extension length]) + return; + } + if (![title length]) { title = [[URL path] lastPathComponent]; if (![title length]) title = [URL _web_userVisibleString]; } - - if ([types containsObject:NSURLPboardType]) - [URL writeToPasteboard:pasteboard]; - if ([types containsObject:PasteboardTypes::WebURLPboardType]) - [pasteboard setString:[URL _web_originalDataAsString] forType:PasteboardTypes::WebURLPboardType]; - if ([types containsObject:PasteboardTypes::WebURLNamePboardType]) - [pasteboard setString:title forType:PasteboardTypes::WebURLNamePboardType]; - if ([types containsObject:NSStringPboardType]) - [pasteboard setString:[URL _web_userVisibleString] forType:NSStringPboardType]; - if ([types containsObject:PasteboardTypes::WebURLsWithTitlesPboardType]) { - NSArray* URLs = [NSArray arrayWithObject:URL]; - unsigned count = [URLs count]; - - if (!count || [pasteboard availableTypeFromArray:[NSArray arrayWithObject:PasteboardTypes::WebURLsWithTitlesPboardType]] == nil) - return; - NSArray* titles = [NSArray arrayWithObject:title]; - - if (count != [titles count]) - titles = nil; - - NSMutableArray* URLStrings = [NSMutableArray arrayWithCapacity:count]; - NSMutableArray* titlesOrEmptyStrings = [NSMutableArray arrayWithCapacity:count]; - for (unsigned index = 0; index < count; ++index) { - [URLStrings addObject:[[URLs objectAtIndex:index] _web_originalDataAsString]]; - [titlesOrEmptyStrings addObject:(titles == nil) ? @"" : [[titles objectAtIndex:index] _webkit_stringByTrimmingWhitespace]]; + RefPtr<LegacyWebArchive> archive = LegacyWebArchive::create(coreElement); + + RetainPtr<NSMutableArray> types(AdoptNS, [[NSMutableArray alloc] initWithObjects:NSFilesPromisePboardType, nil]); + [types.get() addObjectsFromArray:archive ? PasteboardTypes::forImagesWithArchive() : PasteboardTypes::forImages()]; + + RetainPtr<WKPasteboardOwner> pasteboardOwner(AdoptNS, [[WKPasteboardOwner alloc] initWithImage:image]); + + RetainPtr<WKPasteboardFilePromiseOwner> filePromiseOwner(AdoptNS, [(WKPasteboardFilePromiseOwner *)[WKPasteboardFilePromiseOwner alloc] initWithSource:pasteboardOwner.get()]); + m_page->setDragSource(filePromiseOwner.get()); + + [pasteboard declareTypes:types.get() owner:pasteboardOwner.get()]; + + [pasteboard setPropertyList:[NSArray arrayWithObject:extension] forType:NSFilesPromisePboardType]; + + [filePromiseOwner.get() setTypes:[pasteboard propertyListForType:NSFilesPromisePboardType] onPasteboard:pasteboard]; + + [URL writeToPasteboard:pasteboard]; + + [pasteboard setString:[URL _web_originalDataAsString] forType:PasteboardTypes::WebURLPboardType]; + + [pasteboard setString:title forType:PasteboardTypes::WebURLNamePboardType]; + + [pasteboard setString:[URL _web_userVisibleString] forType:NSStringPboardType]; + + [pasteboard setPropertyList:arrayForURLsWithTitles(URL, title) forType:PasteboardTypes::WebURLsWithTitlesPboardType]; + + if (archive) + [pasteboard setData:(NSData *)archive->rawDataRepresentation().get() forType:PasteboardTypes::WebArchivePboardType]; +} + +} // namespace WebKit + +@implementation WKPasteboardFilePromiseOwner + +// The AppKit implementation of copyDropDirectory gets the current pasteboard in +// a way that only works in the process where the drag is initiated. We supply +// an implementation that gets the pasteboard by name instead. +- (CFURLRef)copyDropDirectory +{ + PasteboardRef pasteboard; + OSStatus status = PasteboardCreate((CFStringRef)NSDragPboard, &pasteboard); + if (status != noErr || !pasteboard) + return 0; + CFURLRef location = 0; + status = PasteboardCopyPasteLocation(pasteboard, &location); + CFRelease(pasteboard); + if (status != noErr || !location) + return 0; + CFMakeCollectable(location); + return location; +} + +@end + +@implementation WKPasteboardOwner + +static CachedResourceClient* promisedDataClient() +{ + static CachedResourceClient* client = new CachedResourceClient; + return client; +} + +- (void)clearImage +{ + if (!_image) + return; + _image->removeClient(promisedDataClient()); + _image = 0; +} + +- (id)initWithImage:(CachedImage*)image +{ + self = [super init]; + if (!self) + return nil; + + _image = image; + if (image) + image->addClient(promisedDataClient()); + return self; +} + +- (void)dealloc +{ + [self clearImage]; + [super dealloc]; +} + +- (void)finalize +{ + [self clearImage]; + [super finalize]; +} + +- (void)pasteboard:(NSPasteboard *)pasteboard provideDataForType:(NSString *)type +{ + if ([type isEqual:NSTIFFPboardType]) { + if (_image) { + if (Image* image = _image->image()) + [pasteboard setData:(NSData *)image->getTIFFRepresentation() forType:NSTIFFPboardType]; + [self clearImage]; } - - [pasteboard setPropertyList:[NSArray arrayWithObjects:URLStrings, titlesOrEmptyStrings, nil] - forType:PasteboardTypes::WebURLsWithTitlesPboardType]; + return; } + // FIXME: Handle RTFD here. } - -static void writeImage(NSPasteboard* pasteboard, NSImage *image, DOMElement* element, NSURL* URL, NSString* title, LegacyWebArchive* archive, NSArray* types) + +- (void)pasteboardChangedOwner:(NSPasteboard *)pasteboard { - ASSERT(image || element); - ASSERT(URL); - - writeURL(pasteboard, URL, title, types); - - if ([types containsObject:NSTIFFPboardType]) { - // FIXME: we should add handling of promised types. - if (image) - [pasteboard setData:[image TIFFRepresentation] forType:NSTIFFPboardType]; - else if (element) - [pasteboard setData:[element _imageTIFFRepresentation] forType:NSTIFFPboardType]; - } - - if (archive && [types containsObject:PasteboardTypes::WebArchivePboardType]) - [pasteboard setData:[[(NSData *)archive->rawDataRepresentation().get() retain] autorelease] forType:PasteboardTypes::WebArchivePboardType]; + [self clearImage]; } - -void WebDragClient::declareAndWriteDragImage(NSPasteboard* pasteboard, DOMElement* element, NSURL* URL, NSString* title, WebCore::Frame*) + +static bool matchesExtensionOrEquivalent(NSString *filename, NSString *extension) { - ASSERT(element); - ASSERT(pasteboard && pasteboard == [NSPasteboard pasteboardWithName:NSDragPboard]); + NSString *extensionAsSuffix = [@"." stringByAppendingString:extension]; + return [filename _webkit_hasCaseInsensitiveSuffix:extensionAsSuffix] + || ([extension _webkit_isCaseInsensitiveEqualToString:@"jpeg"] + && [filename _webkit_hasCaseInsensitiveSuffix:@".jpg"]); +} + +- (NSArray *)namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination +{ + NSFileWrapper *wrapper = nil; + NSURL *draggingImageURL = nil; - NSString *extension = @""; - if (RenderObject* renderer = core(element)->renderer()) { - if (renderer->isImage()) { - if (CachedImage* image = toRenderImage(renderer)->cachedImage()) { - extension = image->image()->filenameExtension(); - if (![extension length]) - return; - } + if (_image) { + if (SharedBuffer* buffer = _image->CachedResource::data()) { + NSData *data = buffer->createNSData(); + NSURLResponse *response = _image->response().nsURLResponse(); + draggingImageURL = [response URL]; + wrapper = [[[NSFileWrapper alloc] initRegularFileWithContents:data] autorelease]; + NSString* filename = [response suggestedFilename]; + NSString* trueExtension(_image->image()->filenameExtension()); + if (!matchesExtensionOrEquivalent(filename, trueExtension)) + filename = [[filename stringByAppendingString:@"."] stringByAppendingString:trueExtension]; + [wrapper setPreferredFilename:filename]; } } + + // FIXME: Do we need to handle the case where we do not have a CachedImage? + // WebKit1 had code for this case. - RefPtr<LegacyWebArchive> archive = LegacyWebArchive::create(core(element)); - NSMutableArray *types = [[NSMutableArray alloc] initWithObjects:NSFilesPromisePboardType, nil]; - [types addObjectsFromArray:(archive) ? PasteboardTypes::forImagesWithArchive() : PasteboardTypes::forImages()]; - [pasteboard declareTypes:types owner:nil]; - writeImage(pasteboard, nil, element, URL, title, archive.get(), types); - [types release]; - - NSArray *extensions = [[NSArray alloc] initWithObjects:extension, nil]; - [pasteboard setPropertyList:extensions forType:NSFilesPromisePboardType]; - [extensions release]; + if (!wrapper) { + LOG_ERROR("Failed to create image file."); + return nil; + } + + // FIXME: Report an error if we fail to create a file. + NSString *path = [[dropDestination path] stringByAppendingPathComponent:[wrapper preferredFilename]]; + path = [[NSFileManager defaultManager] _webkit_pathWithUniqueFilenameForPath:path]; + if (![wrapper writeToFile:path atomically:NO updateFilenames:YES]) + LOG_ERROR("Failed to create image file via -[NSFileWrapper writeToFile:atomically:updateFilenames:] at path %@", path); + + if (draggingImageURL) + [[NSFileManager defaultManager] _webkit_setMetadataURL:[draggingImageURL absoluteString] referrer:nil atPath:path]; + + return [NSArray arrayWithObject:[path lastPathComponent]]; } -} // namespace WebKit +@end diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm index 8af0438..7a95a72 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm +++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm @@ -46,7 +46,7 @@ #import <WebCore/Page.h> #import <WebKit/WebResource.h> #import <WebKit/WebNSURLExtras.h> -#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) +#if !defined(BUILDING_ON_SNOW_LEOPARD) #import <AppKit/NSTextChecker.h> #endif @@ -246,26 +246,27 @@ void WebEditorClient::checkTextOfParagraph(const UChar* text, int length, uint64 m_page->sendSync(Messages::WebPageProxy::CheckTextOfParagraph(String(text, length), checkingTypes), Messages::WebPageProxy::CheckTextOfParagraph::Reply(results)); } -#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) -void WebEditorClient::showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelType type, const WebCore::FloatRect& boundingBoxOfReplacedString, const WTF::String& replacedString, const WTF::String& replacementString, const Vector<String>& alternativeReplacementStrings, WebCore::Editor*) +#if !defined(BUILDING_ON_SNOW_LEOPARD) +void WebEditorClient::showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelType type, const WebCore::FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings) { - notImplemented(); + m_page->send(Messages::WebPageProxy::ShowCorrectionPanel(type, boundingBoxOfReplacedString, replacedString, replacementString, alternativeReplacementStrings)); } -void WebEditorClient::dismissCorrectionPanel(WebCore::ReasonForDismissingCorrectionPanel) +void WebEditorClient::dismissCorrectionPanel(WebCore::ReasonForDismissingCorrectionPanel reason) { - notImplemented(); + m_page->send(Messages::WebPageProxy::DismissCorrectionPanel(reason)); } -bool WebEditorClient::isShowingCorrectionPanel() +String WebEditorClient::dismissCorrectionPanelSoon(WebCore::ReasonForDismissingCorrectionPanel reason) { - notImplemented(); - return false; + String result; + m_page->sendSync(Messages::WebPageProxy::DismissCorrectionPanelSoon(reason), Messages::WebPageProxy::DismissCorrectionPanelSoon::Reply(result)); + return result; } void WebEditorClient::recordAutocorrectionResponse(EditorClient::AutocorrectionResponseType responseType, const String& replacedString, const String& replacementString) { - notImplemented(); + m_page->send(Messages::WebPageProxy::RecordAutocorrectionResponse(responseType, replacedString, replacementString)); } #endif diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebErrorsMac.mm b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebErrorsMac.mm index 677c537..70e7607 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebErrorsMac.mm +++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebErrorsMac.mm @@ -28,6 +28,7 @@ #import "WKError.h" #import "WebError.h" +#import <WebCore/LocalizedStrings.h> #import <WebCore/ResourceRequest.h> #import <WebCore/ResourceResponse.h> #import <pthread.h> @@ -41,9 +42,6 @@ static NSString * const WebKitErrorMIMETypeKey = @"WebKitErrorMIME static NSString * const WebKitErrorPlugInNameKey = @"WebKitErrorPlugInNameKey"; static NSString * const WebKitErrorPlugInPageURLStringKey = @"WebKitErrorPlugInPageURLStringKey"; -// FIXME (WebKit2) <rdar://problem/8728860> WebKit2 needs to be localized -#define UI_STRING(__str, __desc) [NSString stringWithUTF8String:__str] - // Policy errors #define WebKitErrorDescriptionCannotShowMIMEType UI_STRING("Content with specified MIME type can’t be shown", "WebKitErrorCannotShowMIMEType description") #define WebKitErrorDescriptionCannotShowURL UI_STRING("The URL can’t be shown", "WebKitErrorCannotShowURL description") @@ -119,17 +117,17 @@ static void registerErrors() NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: // Policy errors - WebKitErrorDescriptionCannotShowMIMEType, [NSNumber numberWithInt: kWKErrorCodeCannotShowMIMEType], - WebKitErrorDescriptionCannotShowURL, [NSNumber numberWithInt: kWKErrorCodeCannotShowURL], - WebKitErrorDescriptionFrameLoadInterruptedByPolicyChange, [NSNumber numberWithInt: kWKErrorCodeFrameLoadInterruptedByPolicyChange], - WebKitErrorDescriptionCannotUseRestrictedPort, [NSNumber numberWithInt: kWKErrorCodeCannotUseRestrictedPort], + (NSString *)WebKitErrorDescriptionCannotShowMIMEType, [NSNumber numberWithInt: kWKErrorCodeCannotShowMIMEType], + (NSString *)WebKitErrorDescriptionCannotShowURL, [NSNumber numberWithInt: kWKErrorCodeCannotShowURL], + (NSString *)WebKitErrorDescriptionFrameLoadInterruptedByPolicyChange, [NSNumber numberWithInt: kWKErrorCodeFrameLoadInterruptedByPolicyChange], + (NSString *)WebKitErrorDescriptionCannotUseRestrictedPort, [NSNumber numberWithInt: kWKErrorCodeCannotUseRestrictedPort], // Plug-in and java errors - WebKitErrorDescriptionCannotFindPlugin, [NSNumber numberWithInt: kWKErrorCodeCannotFindPlugIn], - WebKitErrorDescriptionCannotLoadPlugin, [NSNumber numberWithInt: kWKErrorCodeCannotLoadPlugIn], - WebKitErrorDescriptionJavaUnavailable, [NSNumber numberWithInt: kWKErrorCodeJavaUnavailable], - WebKitErrorDescriptionPlugInCancelledConnection, [NSNumber numberWithInt: kWKErrorCodePlugInCancelledConnection], - WebKitErrorDescriptionPlugInWillHandleLoad, [NSNumber numberWithInt: kWKErrorCodePlugInWillHandleLoad], + (NSString *)WebKitErrorDescriptionCannotFindPlugin, [NSNumber numberWithInt: kWKErrorCodeCannotFindPlugIn], + (NSString *)WebKitErrorDescriptionCannotLoadPlugin, [NSNumber numberWithInt: kWKErrorCodeCannotLoadPlugIn], + (NSString *)WebKitErrorDescriptionJavaUnavailable, [NSNumber numberWithInt: kWKErrorCodeJavaUnavailable], + (NSString *)WebKitErrorDescriptionPlugInCancelledConnection, [NSNumber numberWithInt: kWKErrorCodePlugInCancelledConnection], + (NSString *)WebKitErrorDescriptionPlugInWillHandleLoad, [NSNumber numberWithInt: kWKErrorCodePlugInWillHandleLoad], nil]; [NSError _webkit_addErrorsWithCodesAndDescriptions:dict inDomain:WebError::webKitErrorDomain()]; diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm index 2c8649e..06faa2f 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm +++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm @@ -59,6 +59,7 @@ void InitWebCoreSystemInterface(void) INIT(GetHTTPPipeliningPriority); INIT(GetMIMETypeForExtension); INIT(GetNSURLResponseLastModifiedDate); + INIT(SignedPublicKeyAndChallengeString); INIT(GetPreferredExtensionForMIMEType); INIT(GetUserToBaseCTM); INIT(GetWheelEventDeltas); @@ -95,7 +96,7 @@ void InitWebCoreSystemInterface(void) INIT(SignalCFReadStreamHasBytes); INIT(CreatePrivateStorageSession); INIT(CopyRequestWithStorageSession); - INIT(CreatePrivateInMemoryHTTPCookieStorage); + INIT(CopyHTTPCookieStorage); INIT(GetHTTPCookieAcceptPolicy); INIT(HTTPCookiesForURL); INIT(SetHTTPCookiesForURL); @@ -108,6 +109,7 @@ void InitWebCoreSystemInterface(void) INIT(MakeScrollbarPainter); INIT(ScrollbarPainterSetDelegate); INIT(ScrollbarPainterPaint); + INIT(ScrollbarPainterForceFlashScrollers); INIT(ScrollbarThickness); INIT(ScrollbarMinimumThumbLength); INIT(ScrollbarMinimumTotalLengthNeededForThumb); @@ -148,5 +150,11 @@ void InitWebCoreSystemInterface(void) INIT(AccessibilityHandleFocusChanged); INIT(CreateAXUIElementRef); INIT(UnregisterUniqueIdForElement); + + INIT(GetCFURLResponseMIMEType); + INIT(GetCFURLResponseURL); + INIT(GetCFURLResponseHTTPResponse); + INIT(CopyCFURLResponseSuggestedFilename); + INIT(SetCFURLResponseMIMEType); }); } diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/win/WebPopupMenuWin.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/win/WebPopupMenuWin.cpp index b4db406..851203c 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/win/WebPopupMenuWin.cpp +++ b/Source/WebKit2/WebProcess/WebCoreSupport/win/WebPopupMenuWin.cpp @@ -78,9 +78,9 @@ void WebPopupMenu::setUpPlatformData(const WebCore::IntRect& pageCoordinates, Pl // The backing stores should be drawn at least as wide as the control on the page to match the width of the popup window we'll create. int backingStoreWidth = max(pageCoordinates.width() - m_popupClient->clientInsetLeft() - m_popupClient->clientInsetRight(), popupWidth); - data.m_backingStoreSize = IntSize(backingStoreWidth, (itemCount * data.m_itemHeight)); - data.m_notSelectedBackingStore = ShareableBitmap::createShareable(data.m_backingStoreSize); - data.m_selectedBackingStore = ShareableBitmap::createShareable(data.m_backingStoreSize); + IntSize backingStoreSize(backingStoreWidth, (itemCount * data.m_itemHeight)); + data.m_notSelectedBackingStore = ShareableBitmap::createShareable(backingStoreSize, ShareableBitmap::SupportsAlpha); + data.m_selectedBackingStore = ShareableBitmap::createShareable(backingStoreSize, ShareableBitmap::SupportsAlpha); OwnPtr<GraphicsContext> notSelectedBackingStoreContext = data.m_notSelectedBackingStore->createGraphicsContext(); OwnPtr<GraphicsContext> selectedBackingStoreContext = data.m_selectedBackingStore->createGraphicsContext(); @@ -88,7 +88,7 @@ void WebPopupMenu::setUpPlatformData(const WebCore::IntRect& pageCoordinates, Pl Color activeOptionBackgroundColor = RenderTheme::defaultTheme()->activeListBoxSelectionBackgroundColor(); Color activeOptionTextColor = RenderTheme::defaultTheme()->activeListBoxSelectionForegroundColor(); - for (int y = 0; y < data.m_backingStoreSize.height(); y += data.m_itemHeight) { + for (int y = 0; y < backingStoreSize.height(); y += data.m_itemHeight) { int index = y / data.m_itemHeight; PopupMenuStyle itemStyle = m_popupClient->itemStyle(index); diff --git a/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp b/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp index 0a18256..47acc7a 100644 --- a/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp +++ b/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp @@ -64,7 +64,8 @@ DrawingAreaImpl::DrawingAreaImpl(WebPage* webPage, const WebPageCreationParamete , m_isWaitingForDidUpdate(false) , m_isPaintingSuspended(!parameters.isVisible) , m_alwaysUseCompositing(false) - , m_displayTimer(WebProcess::shared().runLoop(), this, &DrawingAreaImpl::display) + , m_lastDisplayTime(0) + , m_displayTimer(WebProcess::shared().runLoop(), this, &DrawingAreaImpl::displayTimerFired) , m_exitCompositingTimer(WebProcess::shared().runLoop(), this, &DrawingAreaImpl::exitAcceleratedCompositingMode) { if (webPage->corePage()->settings()->acceleratedDrawingEnabled()) @@ -89,6 +90,9 @@ void DrawingAreaImpl::setNeedsDisplay(const IntRect& rect) return; } + if (m_webPage->mainFrameHasCustomRepresentation()) + return; + m_dirtyRegion.unite(dirtyRect); scheduleDisplay(); } @@ -104,6 +108,9 @@ void DrawingAreaImpl::scroll(const IntRect& scrollRect, const IntSize& scrollOff return; } + if (m_webPage->mainFrameHasCustomRepresentation()) + return; + if (!m_scrollRect.isEmpty() && scrollRect != m_scrollRect) { unsigned scrollArea = scrollRect.width() * scrollRect.height(); unsigned currentScrollArea = m_scrollRect.width() * m_scrollRect.height(); @@ -197,7 +204,9 @@ void DrawingAreaImpl::layerHostDidFlushLayers() if (!m_layerTreeHost) return; +#if USE(ACCELERATED_COMPOSITING) m_webPage->send(Messages::DrawingAreaProxy::EnterAcceleratedCompositingMode(m_backingStoreStateID, m_layerTreeHost->layerTreeContext())); +#endif } void DrawingAreaImpl::setRootCompositingLayer(GraphicsLayer* graphicsLayer) @@ -291,11 +300,13 @@ void DrawingAreaImpl::sendDidUpdateBackingStoreState() m_shouldSendDidUpdateBackingStoreState = false; UpdateInfo updateInfo; - LayerTreeContext layerTreeContext; if (!m_isPaintingSuspended && !m_layerTreeHost) display(updateInfo); +#if USE(ACCELERATED_COMPOSITING) + LayerTreeContext layerTreeContext; + if (m_isPaintingSuspended || m_layerTreeHost) { updateInfo.viewSize = m_webPage->size(); @@ -311,6 +322,7 @@ void DrawingAreaImpl::sendDidUpdateBackingStoreState() } m_webPage->send(Messages::DrawingAreaProxy::DidUpdateBackingStoreState(m_backingStoreStateID, updateInfo, layerTreeContext)); +#endif } void DrawingAreaImpl::didUpdate() @@ -322,8 +334,8 @@ void DrawingAreaImpl::didUpdate() m_isWaitingForDidUpdate = false; - // Display if needed. - display(); + // Display if needed. We call displayTimerFired here since it will throttle updates to 60fps. + displayTimerFired(); } void DrawingAreaImpl::suspendPainting() @@ -391,9 +403,11 @@ void DrawingAreaImpl::exitAcceleratedCompositingMode() else display(updateInfo); +#if USE(ACCELERATED_COMPOSITING) // Send along a complete update of the page so we can paint the contents right after we exit the // accelerated compositing mode, eliminiating flicker. m_webPage->send(Messages::DrawingAreaProxy::ExitAcceleratedCompositingMode(m_backingStoreStateID, updateInfo)); +#endif } void DrawingAreaImpl::exitAcceleratedCompositingModeSoon() @@ -421,6 +435,21 @@ void DrawingAreaImpl::scheduleDisplay() m_displayTimer.startOneShot(0); } +void DrawingAreaImpl::displayTimerFired() +{ + static const double minimumFrameInterval = 1.0 / 60.0; + + double timeSinceLastDisplay = currentTime() - m_lastDisplayTime; + double timeUntilNextDisplay = minimumFrameInterval - timeSinceLastDisplay; + + if (timeUntilNextDisplay > 0) { + m_displayTimer.startOneShot(timeUntilNextDisplay); + return; + } + + display(); +} + void DrawingAreaImpl::display() { ASSERT(!m_layerTreeHost); @@ -479,8 +508,11 @@ void DrawingAreaImpl::display(UpdateInfo& updateInfo) ASSERT(!m_webPage->size().isEmpty()); // FIXME: It would be better if we could avoid painting altogether when there is a custom representation. - if (m_webPage->mainFrameHasCustomRepresentation()) + if (m_webPage->mainFrameHasCustomRepresentation()) { + // ASSUMPTION: the custom representation will be painting the dirty region for us. + m_dirtyRegion = Region(); return; + } m_webPage->layoutIfNeeded(); @@ -492,7 +524,7 @@ void DrawingAreaImpl::display(UpdateInfo& updateInfo) IntRect bounds = m_dirtyRegion.bounds(); ASSERT(m_webPage->bounds().contains(bounds)); - RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(bounds.size()); + RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(bounds.size(), ShareableBitmap::SupportsAlpha); if (!bitmap->createHandle(updateInfo.bitmapHandle)) return; @@ -527,6 +559,8 @@ void DrawingAreaImpl::display(UpdateInfo& updateInfo) // Layout can trigger more calls to setNeedsDisplay and we don't want to process them // until the UI process has painted the update, so we stop the timer here. m_displayTimer.stop(); + + m_lastDisplayTime = currentTime(); } diff --git a/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h b/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h index 8d85200..9e93869 100644 --- a/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h +++ b/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h @@ -72,6 +72,7 @@ private: void exitAcceleratedCompositingMode(); void scheduleDisplay(); + void displayTimerFired(); void display(); void display(UpdateInfo&); @@ -97,6 +98,8 @@ private: bool m_isPaintingSuspended; bool m_alwaysUseCompositing; + double m_lastDisplayTime; + RunLoop::Timer<DrawingAreaImpl> m_displayTimer; RunLoop::Timer<DrawingAreaImpl> m_exitCompositingTimer; diff --git a/Source/WebKit2/WebProcess/WebPage/FindController.cpp b/Source/WebKit2/WebProcess/WebPage/FindController.cpp index 8e9dba7..3e7b268 100644 --- a/Source/WebKit2/WebProcess/WebPage/FindController.cpp +++ b/Source/WebKit2/WebProcess/WebPage/FindController.cpp @@ -153,6 +153,10 @@ bool FindController::updateFindIndicator(Frame* selectedFrame, bool isShowingOve return false; IntRect selectionRect = enclosingIntRect(selectedFrame->selection()->bounds()); + + // Selection rect can be empty for matches that are currently obscured from view. + if (selectionRect.isEmpty()) + return false; // We want the selection rect in window coordinates. IntRect selectionRectInWindowCoordinates = selectedFrame->view()->contentsToWindow(selectionRect); @@ -161,7 +165,7 @@ bool FindController::updateFindIndicator(Frame* selectedFrame, bool isShowingOve selectedFrame->selection()->getClippedVisibleTextRectangles(textRects); // Create a backing store and paint the find indicator text into it. - RefPtr<ShareableBitmap> findIndicatorTextBackingStore = ShareableBitmap::createShareable(selectionRect.size()); + RefPtr<ShareableBitmap> findIndicatorTextBackingStore = ShareableBitmap::createShareable(selectionRect.size(), ShareableBitmap::SupportsAlpha); if (!findIndicatorTextBackingStore) return false; @@ -178,7 +182,7 @@ bool FindController::updateFindIndicator(Frame* selectedFrame, bool isShowingOve selectedFrame->view()->paint(graphicsContext.get(), paintRect); selectedFrame->view()->setPaintBehavior(PaintBehaviorNormal); - SharedMemory::Handle handle; + ShareableBitmap::Handle handle; if (!findIndicatorTextBackingStore->createHandle(handle)) return false; @@ -203,7 +207,7 @@ void FindController::hideFindIndicator() if (!m_isShowingFindIndicator) return; - SharedMemory::Handle handle; + ShareableBitmap::Handle handle; m_webPage->send(Messages::WebPageProxy::SetFindIndicator(FloatRect(), Vector<FloatRect>(), handle, false)); m_isShowingFindIndicator = false; } diff --git a/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.cpp b/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.cpp index 1112d39..737e195 100644 --- a/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.cpp +++ b/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.cpp @@ -27,7 +27,7 @@ #include "LayerTreeHost.h" #if PLATFORM(MAC) -#include "LayerTreeHostMac.h" +#include "LayerTreeHostCA.h" #endif #if !PLATFORM(MAC) && !PLATFORM(WIN) @@ -41,7 +41,7 @@ namespace WebKit { PassRefPtr<LayerTreeHost> LayerTreeHost::create(WebPage* webPage) { #if PLATFORM(MAC) - return LayerTreeHostMac::create(webPage); + return LayerTreeHostCA::create(webPage); #endif return 0; diff --git a/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp b/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp index fa4dc2c..574634f 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp +++ b/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp @@ -335,7 +335,11 @@ String WebFrame::url() const if (!m_coreFrame) return String(); - return m_coreFrame->document()->url().string(); + DocumentLoader* documentLoader = m_coreFrame->loader()->documentLoader(); + if (!documentLoader) + return String(); + + return documentLoader->url().string(); } String WebFrame::innerText() const @@ -611,7 +615,12 @@ String WebFrame::suggestedFilenameForResourceWithURL(const KURL& url) const DocumentLoader* loader = m_coreFrame->loader()->documentLoader(); if (!loader) return String(); - + + // First, try the main resource. + if (loader->url() == url) + return loader->response().suggestedFilename(); + + // Next, try subresources. RefPtr<ArchiveResource> resource = loader->subresource(url); if (!resource) return String(); @@ -627,7 +636,12 @@ String WebFrame::mimeTypeForResourceWithURL(const KURL& url) const DocumentLoader* loader = m_coreFrame->loader()->documentLoader(); if (!loader) return String(); - + + // First, try the main resource. + if (loader->url() == url) + return loader->response().mimeType(); + + // Next, try subresources. RefPtr<ArchiveResource> resource = loader->subresource(url); if (resource) return resource->mimeType(); diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.cpp b/Source/WebKit2/WebProcess/WebPage/WebPage.cpp index ff567bd..d5f3724 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebPage.cpp +++ b/Source/WebKit2/WebProcess/WebPage/WebPage.cpp @@ -54,6 +54,7 @@ #include "WebEvent.h" #include "WebEventConversion.h" #include "WebFrame.h" +#include "WebFullScreenManager.h" #include "WebGeolocationClient.h" #include "WebImage.h" #include "WebInspector.h" @@ -91,6 +92,7 @@ #include <WebCore/RenderView.h> #include <WebCore/ReplaceSelectionCommand.h> #include <WebCore/ResourceRequest.h> +#include <WebCore/SchemeRegistry.h> #include <WebCore/SerializedScriptValue.h> #include <WebCore/Settings.h> #include <WebCore/SharedBuffer.h> @@ -158,6 +160,7 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters) , m_canRunBeforeUnloadConfirmPanel(parameters.canRunBeforeUnloadConfirmPanel) , m_canRunModal(parameters.canRunModal) , m_isRunningModal(false) + , m_userSpaceScaleFactor(parameters.userSpaceScaleFactor) , m_cachedMainFrameIsPinnedToLeftSide(false) , m_cachedMainFrameIsPinnedToRightSide(false) { @@ -352,6 +355,9 @@ void WebPage::close() #if ENABLE(INSPECTOR) m_inspector = 0; #endif +#if ENABLE(FULLSCREEN_API) + m_fullScreenManager = 0; +#endif if (m_activePopupMenu) { m_activePopupMenu->disconnectFromPage(); @@ -424,7 +430,7 @@ void WebPage::loadAlternateHTMLString(const String& htmlString, const String& ba { RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(reinterpret_cast<const char*>(htmlString.characters()), htmlString.length() * sizeof(UChar)); KURL baseURL = baseURLString.isEmpty() ? blankURL() : KURL(KURL(), baseURLString); - KURL unreachableURL = unreachableURLString.isEmpty() ? KURL() : KURL(KURL(), unreachableURLString) ; + KURL unreachableURL = unreachableURLString.isEmpty() ? KURL() : KURL(KURL(), unreachableURLString); loadData(sharedBuffer, "text/html", "utf-16", baseURL, unreachableURL); } @@ -785,9 +791,9 @@ void WebPage::pageDidScroll() } #if ENABLE(TILED_BACKING_STORE) -void WebPage::pageDidRequestScroll(const IntSize& delta) +void WebPage::pageDidRequestScroll(const IntPoint& point) { - send(Messages::WebPageProxy::PageDidRequestScroll(delta)); + send(Messages::WebPageProxy::PageDidRequestScroll(point)); } #endif @@ -1051,6 +1057,21 @@ void WebPage::touchEvent(const WebTouchEvent& touchEvent) } #endif +void WebPage::scroll(Page* page, ScrollDirection direction, ScrollGranularity granularity) +{ + page->focusController()->focusedOrMainFrame()->eventHandler()->scrollRecursively(direction, granularity); +} + +void WebPage::logicalScroll(Page* page, ScrollLogicalDirection direction, ScrollGranularity granularity) +{ + page->focusController()->focusedOrMainFrame()->eventHandler()->logicalScrollRecursively(direction, granularity); +} + +void WebPage::scrollBy(uint32_t scrollDirection, uint32_t scrollGranularity) +{ + scroll(m_page.get(), static_cast<ScrollDirection>(scrollDirection), static_cast<ScrollGranularity>(scrollGranularity)); +} + void WebPage::setActive(bool isActive) { m_page->focusController()->setActive(isActive); @@ -1121,6 +1142,8 @@ void WebPage::viewWillEndLiveResize() void WebPage::setFocused(bool isFocused) { + if (!isFocused) + m_page->focusController()->focusedOrMainFrame()->selection()->clear(); m_page->focusController()->setFocused(isFocused); } @@ -1176,6 +1199,13 @@ void WebPage::setUserAgent(const String& userAgent) { m_userAgent = userAgent; } + +IntRect WebPage::windowToScreen(const IntRect& rect) +{ + IntRect screenRect; + sendSync(Messages::WebPageProxy::WindowToScreen(rect), Messages::WebPageProxy::WindowToScreen::Reply(screenRect)); + return screenRect; +} IntRect WebPage::windowResizerRect() const { @@ -1353,6 +1383,9 @@ void WebPage::updatePreferences(const WebPreferencesStore& store) settings->setDOMPasteAllowed(store.getBoolValueForKey(WebPreferencesKey::domPasteAllowedKey())); settings->setJavaScriptCanAccessClipboard(store.getBoolValueForKey(WebPreferencesKey::javaScriptCanAccessClipboardKey())); settings->setShouldPrintBackgrounds(store.getBoolValueForKey(WebPreferencesKey::shouldPrintBackgroundsKey())); + settings->setWebSecurityEnabled(store.getBoolValueForKey(WebPreferencesKey::webSecurityEnabledKey())); + settings->setAllowUniversalAccessFromFileURLs(store.getBoolValueForKey(WebPreferencesKey::allowUniversalAccessFromFileURLsKey())); + settings->setAllowFileAccessFromFileURLs(store.getBoolValueForKey(WebPreferencesKey::allowFileAccessFromFileURLsKey())); settings->setMinimumFontSize(store.getUInt32ValueForKey(WebPreferencesKey::minimumFontSizeKey())); settings->setMinimumLogicalFontSize(store.getUInt32ValueForKey(WebPreferencesKey::minimumLogicalFontSizeKey())); @@ -1363,9 +1396,11 @@ void WebPage::updatePreferences(const WebPreferencesStore& store) // Temporarily turn off accelerated compositing until we have a good solution for rendering it. settings->setAcceleratedCompositingEnabled(false); settings->setAcceleratedDrawingEnabled(false); + settings->setCanvasUsesAcceleratedDrawing(false); #else settings->setAcceleratedCompositingEnabled(store.getBoolValueForKey(WebPreferencesKey::acceleratedCompositingEnabledKey())); settings->setAcceleratedDrawingEnabled(store.getBoolValueForKey(WebPreferencesKey::acceleratedDrawingEnabledKey())); + settings->setCanvasUsesAcceleratedDrawing(store.getBoolValueForKey(WebPreferencesKey::canvasUsesAcceleratedDrawingKey())); #endif settings->setShowDebugBorders(store.getBoolValueForKey(WebPreferencesKey::compositingBordersVisibleKey())); settings->setShowRepaintCounter(store.getBoolValueForKey(WebPreferencesKey::compositingRepaintCountersVisibleKey())); @@ -1375,6 +1410,14 @@ void WebPage::updatePreferences(const WebPreferencesStore& store) AbstractDatabase::setIsAvailable(store.getBoolValueForKey(WebPreferencesKey::databasesEnabledKey())); #endif +#if ENABLE(FULLSCREEN_API) + settings->setFullScreenEnabled(store.getBoolValueForKey(WebPreferencesKey::fullScreenEnabledKey())); +#endif + +#if ENABLE(DOM_STORAGE) + settings->setLocalStorageDatabasePath(WebProcess::shared().localStorageDirectory()); +#endif + platformPreferencesDidChange(store); } @@ -1389,6 +1432,15 @@ WebInspector* WebPage::inspector() } #endif +#if ENABLE(FULLSCREEN_API) +WebFullScreenManager* WebPage::fullScreenManager() +{ + if (!m_fullScreenManager) + m_fullScreenManager = WebFullScreenManager::create(this); + return m_fullScreenManager.get(); +} +#endif + #if !PLATFORM(MAC) bool WebPage::handleEditingKeyboardEvent(KeyboardEvent* evt) { @@ -1488,6 +1540,7 @@ void WebPage::dragEnded(WebCore::IntPoint clientPosition, WebCore::IntPoint glob IntPoint adjustedClientPosition(clientPosition.x() + m_page->dragController()->dragOffset().x(), clientPosition.y() + m_page->dragController()->dragOffset().y()); IntPoint adjustedGlobalPosition(globalPosition.x() + m_page->dragController()->dragOffset().x(), globalPosition.y() + m_page->dragController()->dragOffset().y()); + platformDragEnded(); m_page->dragController()->dragEnded(); FrameView* view = m_page->mainFrame()->view(); if (!view) @@ -1729,13 +1782,13 @@ void WebPage::windowAndViewFramesChanged(const WebCore::IntRect& windowFrameInSc (*it)->windowAndViewFramesChanged(windowFrameInScreenCoordinates, viewFrameInWindowCoordinates); } +#endif + bool WebPage::windowIsFocused() const { return m_page->focusController()->isActive(); } - -#endif - + void WebPage::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments) { if (messageID.is<CoreIPC::MessageClassDrawingAreaLegacy>()) { @@ -1760,6 +1813,13 @@ void WebPage::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::Messag } #endif +#if ENABLE(FULLSCREEN_API) + if (messageID.is<CoreIPC::MessageClassWebFullScreenManager>()) { + fullScreenManager()->didReceiveMessage(connection, messageID, arguments); + return; + } +#endif + didReceiveWebPageMessage(connection, messageID, arguments); } @@ -1998,6 +2058,7 @@ void WebPage::drawRectToPDF(uint64_t frameID, const WebCore::IntRect& rect, uint if (coreFrame) { ASSERT(coreFrame->document()->printing()); +#if PLATFORM(CG) // FIXME: Use CGDataConsumerCreate with callbacks to avoid copying the data. RetainPtr<CGDataConsumerRef> pdfDataConsumer(AdoptCF, CGDataConsumerCreateWithCFData(pdfPageData.get())); @@ -2013,6 +2074,7 @@ void WebPage::drawRectToPDF(uint64_t frameID, const WebCore::IntRect& rect, uint CGPDFContextEndPage(context.get()); CGPDFContextClose(context.get()); +#endif } send(Messages::WebPageProxy::DataCallback(CoreIPC::DataReference(CFDataGetBytePtr(pdfPageData.get()), CFDataGetLength(pdfPageData.get())), callbackID)); @@ -2028,6 +2090,7 @@ void WebPage::drawPagesToPDF(uint64_t frameID, uint32_t first, uint32_t count, u if (coreFrame) { ASSERT(coreFrame->document()->printing()); +#if PLATFORM(CG) // FIXME: Use CGDataConsumerCreate with callbacks to avoid copying the data. RetainPtr<CGDataConsumerRef> pdfDataConsumer(AdoptCF, CGDataConsumerCreateWithCFData(pdfPageData.get())); @@ -2048,6 +2111,7 @@ void WebPage::drawPagesToPDF(uint64_t frameID, uint32_t first, uint32_t count, u CGPDFContextEndPage(context.get()); } CGPDFContextClose(context.get()); +#endif } send(Messages::WebPageProxy::DataCallback(CoreIPC::DataReference(CFDataGetBytePtr(pdfPageData.get()), CFDataGetLength(pdfPageData.get())), callbackID)); @@ -2072,4 +2136,27 @@ void WebPage::setMemoryCacheMessagesEnabled(bool memoryCacheMessagesEnabled) m_page->setMemoryCacheClientCallsEnabled(memoryCacheMessagesEnabled); } +#if !PLATFORM(MAC) +void WebPage::platformDragEnded() +{ +} +#endif + +bool WebPage::canHandleRequest(const WebCore::ResourceRequest& request) +{ + if (SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument(request.url().protocol())) + return true; + return platformCanHandleRequest(request); +} + +#if PLATFORM(MAC) && !defined(BUILDING_ON_SNOW_LEOPARD) +void WebPage::handleCorrectionPanelResult(const String& result) +{ + Frame* frame = m_page->focusController()->focusedOrMainFrame(); + if (!frame) + return; + frame->editor()->handleCorrectionPanelResult(result); +} +#endif + } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.h b/Source/WebKit2/WebProcess/WebPage/WebPage.h index 8ce6405..8e4e71c 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebPage.h +++ b/Source/WebKit2/WebProcess/WebPage/WebPage.h @@ -46,6 +46,7 @@ #include <WebCore/Editor.h> #include <WebCore/FrameLoaderTypes.h> #include <WebCore/IntRect.h> +#include <WebCore/ScrollTypes.h> #include <WebCore/WebCoreKeyboardUIMode.h> #include <wtf/HashMap.h> #include <wtf/OwnPtr.h> @@ -61,6 +62,8 @@ #include "DictionaryPopupInfo.h" #include <wtf/RetainPtr.h> OBJC_CLASS AccessibilityWebPageObject; +OBJC_CLASS NSDictionary; +OBJC_CLASS NSObject; #endif namespace CoreIPC { @@ -77,6 +80,7 @@ namespace WebCore { class Range; class ResourceRequest; class SharedBuffer; + class VisibleSelection; } namespace WebKit { @@ -90,6 +94,7 @@ class WebContextMenu; class WebContextMenuItemData; class WebEvent; class WebFrame; +class WebFullScreenManager; class WebImage; class WebInspector; class WebKeyboardEvent; @@ -137,10 +142,16 @@ public: void scrollMainFrameIfNotAtMaxScrollPosition(const WebCore::IntSize& scrollOffset); + void scrollBy(uint32_t scrollDirection, uint32_t scrollGranularity); + #if ENABLE(INSPECTOR) WebInspector* inspector(); #endif +#if ENABLE(FULLSCREEN_API) + WebFullScreenManager* fullScreenManager(); +#endif + // -- Called by the DrawingArea. // FIXME: We could genericize these into a DrawingArea client interface. Would that be beneficial? void drawRect(WebCore::GraphicsContext&, const WebCore::IntRect&); @@ -229,15 +240,16 @@ public: bool windowIsVisible() const { return m_windowIsVisible; } const WebCore::IntRect& windowFrameInScreenCoordinates() const { return m_windowFrameInScreenCoordinates; } const WebCore::IntRect& viewFrameInWindowCoordinates() const { return m_viewFrameInWindowCoordinates; } - bool windowIsFocused() const; bool interceptEditingKeyboardEvent(WebCore::KeyboardEvent*, bool); #elif PLATFORM(WIN) HWND nativeWindow() const { return m_nativeWindow; } #endif + bool windowIsFocused() const; void installPageOverlay(PassRefPtr<PageOverlay>); void uninstallPageOverlay(PageOverlay*); bool hasPageOverlay() const { return m_pageOverlay; } + WebCore::IntRect windowToScreen(const WebCore::IntRect&); PassRefPtr<WebImage> snapshotInViewCoordinates(const WebCore::IntRect&, ImageOptions); PassRefPtr<WebImage> snapshotInDocumentCoordinates(const WebCore::IntRect&, ImageOptions); @@ -250,7 +262,7 @@ public: void pageDidScroll(); #if ENABLE(TILED_BACKING_STORE) - void pageDidRequestScroll(const WebCore::IntSize& delta); + void pageDidRequestScroll(const WebCore::IntPoint&); void setActualVisibleContentRect(const WebCore::IntRect&); bool resizesToContentsEnabled() const { return !m_resizesToContentsLayoutSize.isEmpty(); } @@ -297,6 +309,7 @@ public: void characterIndexForPoint(const WebCore::IntPoint point, uint64_t& result); void firstRectForCharacterRange(uint64_t location, uint64_t length, WebCore::IntRect& resultRect); void writeSelectionToPasteboard(const WTF::String& pasteboardName, const WTF::Vector<WTF::String>& pasteboardTypes, bool& result); + void readSelectionFromPasteboard(const WTF::String& pasteboardName, bool& result); #elif PLATFORM(WIN) void confirmComposition(const String& compositionString); void setComposition(const WTF::String& compositionString, const WTF::Vector<WebCore::CompositionUnderline>& underlines, uint64_t cursorPosition); @@ -309,7 +322,7 @@ public: void dummy(bool&); #if PLATFORM(MAC) - void performDictionaryLookupForRange(DictionaryPopupInfo::Type, WebCore::Frame*, WebCore::Range*); + void performDictionaryLookupForSelection(DictionaryPopupInfo::Type, WebCore::Frame*, const WebCore::VisibleSelection&); bool isSpeaking(); void speak(const String&); @@ -346,10 +359,20 @@ public: void runModal(); + float userSpaceScaleFactor() const { return m_userSpaceScaleFactor; } + void setMemoryCacheMessagesEnabled(bool); void forceRepaintWithoutCallback(); +#if PLATFORM(MAC) + void setDragSource(NSObject *); +#endif + +#if PLATFORM(MAC) && !defined(BUILDING_ON_SNOW_LEOPARD) + void handleCorrectionPanelResult(const String&); +#endif + private: WebPage(uint64_t pageID, const WebPageCreationParameters&); @@ -398,6 +421,9 @@ private: void touchEvent(const WebTouchEvent&); #endif + static void scroll(WebCore::Page*, WebCore::ScrollDirection, WebCore::ScrollGranularity); + static void logicalScroll(WebCore::Page*, WebCore::ScrollLogicalDirection, WebCore::ScrollGranularity); + uint64_t restoreSession(const SessionState&); void restoreSessionAndNavigateToCurrentItem(const SessionState&, const SandboxExtension::Handle&); @@ -429,6 +455,7 @@ private: #if PLATFORM(MAC) void performDictionaryLookupAtLocation(const WebCore::FloatPoint&); + void performDictionaryLookupForRange(DictionaryPopupInfo::Type, WebCore::Frame*, WebCore::Range*, NSDictionary *options); void setWindowIsVisible(bool windowIsVisible); void windowAndViewFramesChanged(const WebCore::IntRect& windowFrameInScreenCoordinates, const WebCore::IntRect& viewFrameInWindowCoordinates, const WebCore::IntPoint& accessibilityViewCoordinates); @@ -473,6 +500,10 @@ private: void didSelectItemFromActiveContextMenu(const WebContextMenuItemData&); #endif + void platformDragEnded(); + + static bool platformCanHandleRequest(const WebCore::ResourceRequest&); + OwnPtr<WebCore::Page> m_page; RefPtr<WebFrame> m_mainFrame; RefPtr<InjectedBundleBackForwardList> m_backForwardList; @@ -512,6 +543,8 @@ private: HashSet<PluginView*> m_pluginViews; RetainPtr<AccessibilityWebPageObject> m_mockAccessibilityElement; + + RetainPtr<NSObject> m_dragSource; #elif PLATFORM(WIN) // Our view's window (in the UI process). HWND m_nativeWindow; @@ -539,6 +572,9 @@ private: #if ENABLE(INSPECTOR) RefPtr<WebInspector> m_inspector; #endif +#if ENABLE(FULLSCREEN_API) + RefPtr<WebFullScreenManager> m_fullScreenManager; +#endif RefPtr<WebPopupMenu> m_activePopupMenu; RefPtr<WebContextMenu> m_contextMenu; RefPtr<WebOpenPanelResultListener> m_activeOpenPanelResultListener; @@ -554,6 +590,8 @@ private: bool m_canRunModal; bool m_isRunningModal; + float m_userSpaceScaleFactor; + bool m_cachedMainFrameIsPinnedToLeftSide; bool m_cachedMainFrameIsPinnedToRightSide; }; diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in b/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in index 0c0eea5..69bd54d 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in +++ b/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in @@ -42,6 +42,8 @@ messages -> WebPage { TouchEvent(WebKit::WebTouchEvent event) #endif + ScrollBy(uint32_t scrollDirection, uint32_t scrollGranularity) + GoBack(uint64_t backForwardItemID, WebKit::SandboxExtension::Handle sandboxExtensionHandle) GoForward(uint64_t backForwardItemID, WebKit::SandboxExtension::Handle sandboxExtensionHandle) GoToBackForwardItem(uint64_t backForwardItemID, WebKit::SandboxExtension::Handle sandboxExtensionHandle) @@ -55,6 +57,7 @@ messages -> WebPage { StopLoadingFrame(uint64_t frameID) + RestoreSession(WebKit::SessionState state) RestoreSessionAndNavigateToCurrentItem(WebKit::SessionState state, WebKit::SandboxExtension::Handle sandboxExtensionHandle) DidRemoveBackForwardItem(uint64_t backForwardItemID) @@ -181,6 +184,7 @@ messages -> WebPage { FirstRectForCharacterRange(uint64_t location, uint64_t length) -> (WebCore::IntRect resultRect) RegisterUIProcessAccessibilityTokens(CoreIPC::DataReference elemenToken, CoreIPC::DataReference windowToken) WriteSelectionToPasteboard(WTF::String pasteboardName, WTF::Vector<WTF::String> pasteboardTypes) -> (bool result) + ReadSelectionFromPasteboard(WTF::String pasteboardName) -> (bool result) #endif #if PLATFORM(WIN) ConfirmComposition(WTF::String compositionString) @@ -191,4 +195,8 @@ messages -> WebPage { #if PLATFORM(QT) FindZoomableAreaForPoint(WebCore::IntPoint point) #endif + +#if PLATFORM(MAC) && !defined(BUILDING_ON_SNOW_LEOPARD) + HandleCorrectionPanelResult(String result) +#endif } diff --git a/Source/WebKit2/WebProcess/WebPage/mac/LayerTreeHostMac.mm b/Source/WebKit2/WebProcess/WebPage/ca/LayerTreeHostCA.cpp index 494f5e6..2460607 100644 --- a/Source/WebKit2/WebProcess/WebPage/mac/LayerTreeHostMac.mm +++ b/Source/WebKit2/WebProcess/WebPage/ca/LayerTreeHostCA.cpp @@ -23,39 +23,31 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#import "config.h" -#import "LayerTreeHostMac.h" - -#import "DrawingAreaImpl.h" -#import "WebPage.h" -#import "WebProcess.h" -#import <QuartzCore/CATransaction.h> -#import <WebCore/Frame.h> -#import <WebCore/FrameView.h> -#import <WebCore/Page.h> -#import <WebCore/Settings.h> -#import <WebKitSystemInterface.h> - -@interface CATransaction (Details) -+ (void)synchronize; -@end +#include "config.h" +#include "LayerTreeHostCA.h" + +#include "DrawingAreaImpl.h" +#include "WebPage.h" +#include "WebProcess.h" +#include <WebCore/Frame.h> +#include <WebCore/FrameView.h> +#include <WebCore/Page.h> +#include <WebCore/Settings.h> using namespace WebCore; namespace WebKit { -PassRefPtr<LayerTreeHostMac> LayerTreeHostMac::create(WebPage* webPage) +PassRefPtr<LayerTreeHostCA> LayerTreeHostCA::create(WebPage* webPage) { - return adoptRef(new LayerTreeHostMac(webPage)); + return adoptRef(new LayerTreeHostCA(webPage)); } -LayerTreeHostMac::LayerTreeHostMac(WebPage* webPage) +LayerTreeHostCA::LayerTreeHostCA(WebPage* webPage) : LayerTreeHost(webPage) , m_isValid(true) , m_notifyAfterScheduledLayerFlush(false) { - mach_port_t serverPort = WebProcess::shared().compositingRenderServerPort(); - m_remoteLayerClient = WKCARemoteLayerClientMakeWithServerPort(serverPort); // Create a root layer. m_rootLayer = GraphicsLayer::create(this); @@ -65,8 +57,6 @@ LayerTreeHostMac::LayerTreeHostMac(WebPage* webPage) m_rootLayer->setDrawsContent(false); m_rootLayer->setSize(webPage->size()); - [m_rootLayer->platformLayer() setGeometryFlipped:YES]; - m_nonCompositedContentLayer = GraphicsLayer::create(this); #ifndef NDEBUG m_nonCompositedContentLayer->setName("LayerTreeHost non-composited content"); @@ -79,53 +69,35 @@ LayerTreeHostMac::LayerTreeHostMac(WebPage* webPage) m_rootLayer->addChild(m_nonCompositedContentLayer.get()); - WKCARemoteLayerClientSetLayer(m_remoteLayerClient.get(), m_rootLayer->platformLayer()); - if (m_webPage->hasPageOverlay()) createPageOverlayLayer(); - scheduleLayerFlush(); + platformInitialize(); - m_layerTreeContext.contextID = WKCARemoteLayerClientGetClientId(m_remoteLayerClient.get()); + scheduleLayerFlush(); } -LayerTreeHostMac::~LayerTreeHostMac() +LayerTreeHostCA::~LayerTreeHostCA() { ASSERT(!m_isValid); + ASSERT(!m_rootLayer); +#if PLATFORM(MAC) ASSERT(!m_flushPendingLayerChangesRunLoopObserver); ASSERT(!m_remoteLayerClient); - ASSERT(!m_rootLayer); +#endif } -const LayerTreeContext& LayerTreeHostMac::layerTreeContext() +const LayerTreeContext& LayerTreeHostCA::layerTreeContext() { return m_layerTreeContext; } -void LayerTreeHostMac::scheduleLayerFlush() -{ - CFRunLoopRef currentRunLoop = CFRunLoopGetCurrent(); - - // Make sure we wake up the loop or the observer could be delayed until some other source fires. - CFRunLoopWakeUp(currentRunLoop); - - if (m_flushPendingLayerChangesRunLoopObserver) - return; - - // Run before the Core Animation commit observer, which has order 2000000. - const CFIndex runLoopOrder = 2000000 - 1; - CFRunLoopObserverContext context = { 0, this, 0, 0, 0 }; - m_flushPendingLayerChangesRunLoopObserver.adoptCF(CFRunLoopObserverCreate(0, kCFRunLoopBeforeWaiting | kCFRunLoopExit, true, runLoopOrder, flushPendingLayerChangesRunLoopObserverCallback, &context)); - - CFRunLoopAddObserver(currentRunLoop, m_flushPendingLayerChangesRunLoopObserver.get(), kCFRunLoopCommonModes); -} - -void LayerTreeHostMac::setShouldNotifyAfterNextScheduledLayerFlush(bool notifyAfterScheduledLayerFlush) +void LayerTreeHostCA::setShouldNotifyAfterNextScheduledLayerFlush(bool notifyAfterScheduledLayerFlush) { m_notifyAfterScheduledLayerFlush = notifyAfterScheduledLayerFlush; } -void LayerTreeHostMac::setRootCompositingLayer(GraphicsLayer* graphicsLayer) +void LayerTreeHostCA::setRootCompositingLayer(GraphicsLayer* graphicsLayer) { m_nonCompositedContentLayer->removeAllChildren(); @@ -134,22 +106,15 @@ void LayerTreeHostMac::setRootCompositingLayer(GraphicsLayer* graphicsLayer) m_nonCompositedContentLayer->addChild(graphicsLayer); } -void LayerTreeHostMac::invalidate() +void LayerTreeHostCA::invalidate() { ASSERT(m_isValid); - - if (m_flushPendingLayerChangesRunLoopObserver) { - CFRunLoopObserverInvalidate(m_flushPendingLayerChangesRunLoopObserver.get()); - m_flushPendingLayerChangesRunLoopObserver = nullptr; - } - - WKCARemoteLayerClientInvalidate(m_remoteLayerClient.get()); - m_remoteLayerClient = nullptr; + platformInvalidate(); m_rootLayer = nullptr; m_isValid = false; } -void LayerTreeHostMac::setNonCompositedContentsNeedDisplay(const IntRect& rect) +void LayerTreeHostCA::setNonCompositedContentsNeedDisplay(const IntRect& rect) { m_nonCompositedContentLayer->setNeedsDisplayInRect(rect); if (m_pageOverlayLayer) @@ -158,12 +123,12 @@ void LayerTreeHostMac::setNonCompositedContentsNeedDisplay(const IntRect& rect) scheduleLayerFlush(); } -void LayerTreeHostMac::scrollNonCompositedContents(const IntRect& scrollRect, const IntSize& scrollOffset) +void LayerTreeHostCA::scrollNonCompositedContents(const IntRect& scrollRect, const IntSize& scrollOffset) { setNonCompositedContentsNeedDisplay(scrollRect); } -void LayerTreeHostMac::sizeDidChange(const IntSize& newSize) +void LayerTreeHostCA::sizeDidChange(const IntSize& newSize) { m_rootLayer->setSize(newSize); m_nonCompositedContentLayer->setSize(newSize); @@ -174,47 +139,45 @@ void LayerTreeHostMac::sizeDidChange(const IntSize& newSize) scheduleLayerFlush(); flushPendingLayerChanges(); - [CATransaction flush]; - [CATransaction synchronize]; + platformSizeDidChange(); } -void LayerTreeHostMac::forceRepaint() +void LayerTreeHostCA::forceRepaint() { scheduleLayerFlush(); flushPendingLayerChanges(); - [CATransaction flush]; - [CATransaction synchronize]; + platformForceRepaint(); } -void LayerTreeHostMac::didInstallPageOverlay() +void LayerTreeHostCA::didInstallPageOverlay() { createPageOverlayLayer(); scheduleLayerFlush(); } -void LayerTreeHostMac::didUninstallPageOverlay() +void LayerTreeHostCA::didUninstallPageOverlay() { destroyPageOverlayLayer(); scheduleLayerFlush(); } -void LayerTreeHostMac::setPageOverlayNeedsDisplay(const IntRect& rect) +void LayerTreeHostCA::setPageOverlayNeedsDisplay(const IntRect& rect) { ASSERT(m_pageOverlayLayer); m_pageOverlayLayer->setNeedsDisplayInRect(rect); scheduleLayerFlush(); } -void LayerTreeHostMac::notifyAnimationStarted(const WebCore::GraphicsLayer*, double time) +void LayerTreeHostCA::notifyAnimationStarted(const WebCore::GraphicsLayer*, double time) { } -void LayerTreeHostMac::notifySyncRequired(const WebCore::GraphicsLayer*) +void LayerTreeHostCA::notifySyncRequired(const WebCore::GraphicsLayer*) { } -void LayerTreeHostMac::paintContents(const GraphicsLayer* graphicsLayer, GraphicsContext& graphicsContext, GraphicsLayerPaintingPhase, const IntRect& clipRect) +void LayerTreeHostCA::paintContents(const GraphicsLayer* graphicsLayer, GraphicsContext& graphicsContext, GraphicsLayerPaintingPhase, const IntRect& clipRect) { if (graphicsLayer == m_nonCompositedContentLayer) { m_webPage->drawRect(graphicsContext, clipRect); @@ -227,25 +190,20 @@ void LayerTreeHostMac::paintContents(const GraphicsLayer* graphicsLayer, Graphic } } -bool LayerTreeHostMac::showDebugBorders() const +bool LayerTreeHostCA::showDebugBorders() const { return m_webPage->corePage()->settings()->showDebugBorders(); } -bool LayerTreeHostMac::showRepaintCounter() const +bool LayerTreeHostCA::showRepaintCounter() const { return m_webPage->corePage()->settings()->showRepaintCounter(); } -void LayerTreeHostMac::flushPendingLayerChangesRunLoopObserverCallback(CFRunLoopObserverRef, CFRunLoopActivity, void* context) -{ - static_cast<LayerTreeHostMac*>(context)->flushPendingLayerChangesRunLoopObserverCallback(); -} - -void LayerTreeHostMac::flushPendingLayerChangesRunLoopObserverCallback() +void LayerTreeHostCA::performScheduledLayerFlush() { { - RefPtr<LayerTreeHostMac> protect(this); + RefPtr<LayerTreeHostCA> protect(this); m_webPage->layoutIfNeeded(); if (!m_isValid) @@ -255,10 +213,12 @@ void LayerTreeHostMac::flushPendingLayerChangesRunLoopObserverCallback() if (!flushPendingLayerChanges()) return; - // We successfully flushed the pending layer changes, remove the run loop observer. - ASSERT(m_flushPendingLayerChangesRunLoopObserver); - CFRunLoopObserverInvalidate(m_flushPendingLayerChangesRunLoopObserver.get()); - m_flushPendingLayerChangesRunLoopObserver = 0; + didPerformScheduledLayerFlush(); +} + +void LayerTreeHostCA::didPerformScheduledLayerFlush() +{ + platformDidPerformScheduledLayerFlush(); if (m_notifyAfterScheduledLayerFlush) { // Let the drawing area know that we've done a flush of the layer changes. @@ -267,7 +227,7 @@ void LayerTreeHostMac::flushPendingLayerChangesRunLoopObserverCallback() } } -bool LayerTreeHostMac::flushPendingLayerChanges() +bool LayerTreeHostCA::flushPendingLayerChanges() { m_rootLayer->syncCompositingStateForThisLayerOnly(); m_nonCompositedContentLayer->syncCompositingStateForThisLayerOnly(); @@ -277,7 +237,7 @@ bool LayerTreeHostMac::flushPendingLayerChanges() return m_webPage->corePage()->mainFrame()->view()->syncCompositingStateIncludingSubframes(); } -void LayerTreeHostMac::createPageOverlayLayer() +void LayerTreeHostCA::createPageOverlayLayer() { ASSERT(!m_pageOverlayLayer); @@ -292,7 +252,7 @@ void LayerTreeHostMac::createPageOverlayLayer() m_rootLayer->addChild(m_pageOverlayLayer.get()); } -void LayerTreeHostMac::destroyPageOverlayLayer() +void LayerTreeHostCA::destroyPageOverlayLayer() { ASSERT(m_pageOverlayLayer); m_pageOverlayLayer->removeFromParent(); diff --git a/Source/WebKit2/WebProcess/WebPage/mac/LayerTreeHostMac.h b/Source/WebKit2/WebProcess/WebPage/ca/LayerTreeHostCA.h index d05e43e..ba4e33a 100644 --- a/Source/WebKit2/WebProcess/WebPage/mac/LayerTreeHostMac.h +++ b/Source/WebKit2/WebProcess/WebPage/ca/LayerTreeHostCA.h @@ -23,26 +23,31 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef LayerTreeHostMac_h -#define LayerTreeHostMac_h +#ifndef LayerTreeHostCA_h +#define LayerTreeHostCA_h #include "LayerTreeContext.h" #include "LayerTreeHost.h" #include <WebCore/GraphicsLayerClient.h> #include <wtf/OwnPtr.h> + +#if PLATFORM(MAC) #include <wtf/RetainPtr.h> +#endif +#if PLATFORM(MAC) typedef struct __WKCARemoteLayerClientRef* WKCARemoteLayerClientRef; +#endif namespace WebKit { -class LayerTreeHostMac : public LayerTreeHost, WebCore::GraphicsLayerClient { +class LayerTreeHostCA : public LayerTreeHost, WebCore::GraphicsLayerClient { public: - static PassRefPtr<LayerTreeHostMac> create(WebPage*); - ~LayerTreeHostMac(); + static PassRefPtr<LayerTreeHostCA> create(WebPage*); + ~LayerTreeHostCA(); private: - explicit LayerTreeHostMac(WebPage*); + explicit LayerTreeHostCA(WebPage*); // LayerTreeHost. virtual const LayerTreeContext& layerTreeContext(); @@ -67,13 +72,23 @@ private: virtual bool showDebugBorders() const; virtual bool showRepaintCounter() const; - static void flushPendingLayerChangesRunLoopObserverCallback(CFRunLoopObserverRef, CFRunLoopActivity, void*); - void flushPendingLayerChangesRunLoopObserverCallback(); + void platformInitialize(); + void platformInvalidate(); + void platformSizeDidChange(); + void platformForceRepaint(); + + void performScheduledLayerFlush(); + void didPerformScheduledLayerFlush(); + void platformDidPerformScheduledLayerFlush(); bool flushPendingLayerChanges(); void createPageOverlayLayer(); void destroyPageOverlayLayer(); +#if PLATFORM(MAC) + static void flushPendingLayerChangesRunLoopObserverCallback(CFRunLoopObserverRef, CFRunLoopActivity, void*); +#endif + // The context for this layer tree. LayerTreeContext m_layerTreeContext; @@ -93,10 +108,12 @@ private: // The page overlay layer. Will be null if there's no page overlay. OwnPtr<WebCore::GraphicsLayer> m_pageOverlayLayer; +#if PLATFORM(MAC) RetainPtr<WKCARemoteLayerClientRef> m_remoteLayerClient; RetainPtr<CFRunLoopObserverRef> m_flushPendingLayerChangesRunLoopObserver; +#endif }; } // namespace WebKit -#endif // LayerTreeHostMac_h +#endif // LayerTreeHostCA_h diff --git a/Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.mm b/Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.mm new file mode 100644 index 0000000..50776d7 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.mm @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import "config.h" +#import "LayerTreeHostCA.h" + +#import "WebProcess.h" +#import <QuartzCore/CATransaction.h> +#import <WebCore/GraphicsLayer.h> +#import <WebKitSystemInterface.h> + +@interface CATransaction (Details) ++ (void)synchronize; +@end + +namespace WebKit { + +void LayerTreeHostCA::platformInitialize() +{ + mach_port_t serverPort = WebProcess::shared().compositingRenderServerPort(); + m_remoteLayerClient = WKCARemoteLayerClientMakeWithServerPort(serverPort); + + [m_rootLayer->platformLayer() setGeometryFlipped:YES]; + + WKCARemoteLayerClientSetLayer(m_remoteLayerClient.get(), m_rootLayer->platformLayer()); + + m_layerTreeContext.contextID = WKCARemoteLayerClientGetClientId(m_remoteLayerClient.get()); +} + +void LayerTreeHostCA::scheduleLayerFlush() +{ + CFRunLoopRef currentRunLoop = CFRunLoopGetCurrent(); + + // Make sure we wake up the loop or the observer could be delayed until some other source fires. + CFRunLoopWakeUp(currentRunLoop); + + if (m_flushPendingLayerChangesRunLoopObserver) + return; + + // Run before the Core Animation commit observer, which has order 2000000. + const CFIndex runLoopOrder = 2000000 - 1; + CFRunLoopObserverContext context = { 0, this, 0, 0, 0 }; + m_flushPendingLayerChangesRunLoopObserver.adoptCF(CFRunLoopObserverCreate(0, kCFRunLoopBeforeWaiting | kCFRunLoopExit, true, runLoopOrder, flushPendingLayerChangesRunLoopObserverCallback, &context)); + + CFRunLoopAddObserver(currentRunLoop, m_flushPendingLayerChangesRunLoopObserver.get(), kCFRunLoopCommonModes); +} + +void LayerTreeHostCA::platformInvalidate() +{ + if (m_flushPendingLayerChangesRunLoopObserver) { + CFRunLoopObserverInvalidate(m_flushPendingLayerChangesRunLoopObserver.get()); + m_flushPendingLayerChangesRunLoopObserver = nullptr; + } + + WKCARemoteLayerClientInvalidate(m_remoteLayerClient.get()); + m_remoteLayerClient = nullptr; +} + +void LayerTreeHostCA::platformSizeDidChange() +{ + [CATransaction flush]; + [CATransaction synchronize]; +} + +void LayerTreeHostCA::platformForceRepaint() +{ + [CATransaction flush]; + [CATransaction synchronize]; +} + +void LayerTreeHostCA::flushPendingLayerChangesRunLoopObserverCallback(CFRunLoopObserverRef, CFRunLoopActivity, void* context) +{ + // This gets called outside of the normal event loop so wrap in an autorelease pool + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + static_cast<LayerTreeHostCA*>(context)->performScheduledLayerFlush(); + [pool drain]; +} + +void LayerTreeHostCA::platformDidPerformScheduledLayerFlush() +{ + // We successfully flushed the pending layer changes, remove the run loop observer. + ASSERT(m_flushPendingLayerChangesRunLoopObserver); + CFRunLoopObserverInvalidate(m_flushPendingLayerChangesRunLoopObserver.get()); + m_flushPendingLayerChangesRunLoopObserver = 0; +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebPage/ca/win/LayerTreeHostCAWin.cpp b/Source/WebKit2/WebProcess/WebPage/ca/win/LayerTreeHostCAWin.cpp new file mode 100644 index 0000000..81db03e --- /dev/null +++ b/Source/WebKit2/WebProcess/WebPage/ca/win/LayerTreeHostCAWin.cpp @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "LayerTreeHostCA.h" + +#include <WebCore/NotImplemented.h> + +namespace WebKit { + +void LayerTreeHostCA::platformInitialize() +{ + // FIXME: <http://webkit.org/b/45567> Implement this! + notImplemented(); +} + +void LayerTreeHostCA::scheduleLayerFlush() +{ + // FIXME: <http://webkit.org/b/45567> Implement this! + notImplemented(); +} + +void LayerTreeHostCA::platformInvalidate() +{ + // FIXME: <http://webkit.org/b/45567> Implement this! + notImplemented(); +} + +void LayerTreeHostCA::platformSizeDidChange() +{ + // FIXME: <http://webkit.org/b/45567> Implement this! + notImplemented(); +} + +void LayerTreeHostCA::platformForceRepaint() +{ + // FIXME: <http://webkit.org/b/45567> Implement this! + notImplemented(); +} + +void LayerTreeHostCA::platformDidPerformScheduledLayerFlush() +{ + // FIXME: <http://webkit.org/b/45567> Implement this! + notImplemented(); +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebPage/mac/AccessibilityWebPageObject.mm b/Source/WebKit2/WebProcess/WebPage/mac/AccessibilityWebPageObject.mm index c88ab7e..1d036fa 100644 --- a/Source/WebKit2/WebProcess/WebPage/mac/AccessibilityWebPageObject.mm +++ b/Source/WebKit2/WebProcess/WebPage/mac/AccessibilityWebPageObject.mm @@ -175,10 +175,12 @@ using namespace WebKit; point.y -= remotePosition.y; point.x -= remotePosition.x; - WebCore::FrameView* fv = m_page->mainFrame()->coreFrame()->view(); - if (fv) { - point.y += fv->scrollPosition().y(); - point.x += fv->scrollPosition().x(); + if (m_page && m_page->mainFrame() && m_page->mainFrame()->coreFrame()) { + WebCore::FrameView* fv = m_page->mainFrame()->coreFrame()->view(); + if (fv) { + point.y += fv->scrollPosition().y(); + point.x += fv->scrollPosition().x(); + } } return [[self accessibilityRootObjectWrapper] accessibilityHitTest:point]; @@ -186,7 +188,7 @@ using namespace WebKit; - (id)accessibilityFocusedUIElement { - return NSAccessibilityUnignoredDescendant(self); + return [[self accessibilityRootObjectWrapper] accessibilityFocusedUIElement]; } diff --git a/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm b/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm index 4cae5aa..8d81889 100644 --- a/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm +++ b/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010, 2011 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -46,6 +46,7 @@ #import <WebCore/ScrollView.h> #import <WebCore/TextIterator.h> #import <WebCore/WindowsKeyboardCodes.h> +#import <WebCore/visible_units.h> #import <WebKitSystemInterface.h> using namespace WebCore; @@ -76,8 +77,6 @@ void WebPage::platformPreferencesDidChange(const WebPreferencesStore&) { } -// FIXME: need to add support for input methods - bool WebPage::interceptEditingKeyboardEvent(KeyboardEvent* evt, bool shouldSaveCommand) { Node* node = evt->target()->toNode(); @@ -164,12 +163,12 @@ void WebPage::getMarkedRange(uint64_t& location, uint64_t& length) getLocationAndLengthFromRange(frame->editor()->compositionRange().get(), location, length); } -static PassRefPtr<Range> characterRangeAtPoint(Frame* frame, const IntPoint& point) + +static PassRefPtr<Range> characterRangeAtPositionForPoint(Frame* frame, const VisiblePosition& position, const IntPoint& point) { - VisiblePosition position = frame->visiblePositionForPoint(point); if (position.isNull()) return 0; - + VisiblePosition previous = position.previous(); if (previous.isNotNull()) { RefPtr<Range> previousCharacterRange = makeRange(previous, position); @@ -188,7 +187,12 @@ static PassRefPtr<Range> characterRangeAtPoint(Frame* frame, const IntPoint& poi return 0; } - + +static PassRefPtr<Range> characterRangeAtPoint(Frame* frame, const IntPoint& point) +{ + return characterRangeAtPositionForPoint(frame, frame->visiblePositionForPoint(point), point); +} + void WebPage::characterIndexForPoint(IntPoint point, uint64_t& index) { index = NSNotFound; @@ -242,6 +246,32 @@ void WebPage::firstRectForCharacterRange(uint64_t location, uint64_t length, Web resultRect = frame->view()->contentsToWindow(rect); } +static bool isPositionInRange(const VisiblePosition& position, Range* range) +{ + RefPtr<Range> positionRange = makeRange(position, position); + + ExceptionCode ec = 0; + range->compareBoundaryPoints(Range::START_TO_START, positionRange.get(), ec); + if (ec) + return false; + + if (!range->isPointInRange(positionRange->startContainer(), positionRange->startOffset(), ec)) + return false; + if (ec) + return false; + + return true; +} + +static bool shouldUseSelection(const VisiblePosition& position, const VisibleSelection& selection) +{ + RefPtr<Range> selectedRange = selection.toNormalizedRange(); + if (!selectedRange) + return false; + + return isPositionInRange(position, selectedRange.get()); +} + void WebPage::performDictionaryLookupAtLocation(const FloatPoint& floatPoint) { Frame* frame = m_page->mainFrame(); @@ -250,46 +280,78 @@ void WebPage::performDictionaryLookupAtLocation(const FloatPoint& floatPoint) // Find the frame the point is over. IntPoint point = roundedIntPoint(floatPoint); - HitTestResult result = frame->eventHandler()->hitTestResultAtPoint(point, false); frame = result.innerNonSharedNode() ? result.innerNonSharedNode()->document()->frame() : m_page->focusController()->focusedOrMainFrame(); - // Figure out if there are any characters under the point. - RefPtr<Range> characterRange = characterRangeAtPoint(frame, frame->view()->windowToContents(point)); - if (!characterRange) + IntPoint translatedPoint = frame->view()->windowToContents(point); + VisiblePosition position = frame->visiblePositionForPoint(translatedPoint); + + // Don't do anything if there is no character at the point. + if (!characterRangeAtPositionForPoint(frame, position, translatedPoint)) return; - // Grab the currently selected text. - RefPtr<Range> selectedRange = m_page->focusController()->focusedOrMainFrame()->selection()->selection().toNormalizedRange(); - - // Use the selected text if the point was anywhere in it. Assertain this by seeing if either character range - // the mouse is over is contained by the selection range. - if (characterRange && selectedRange) { - ExceptionCode ec = 0; - selectedRange->compareBoundaryPoints(Range::START_TO_START, characterRange.get(), ec); - if (!ec) { - if (selectedRange->isPointInRange(characterRange->startContainer(), characterRange->startOffset(), ec)) { - if (!ec) - characterRange = selectedRange; - } - } + VisibleSelection selection = m_page->focusController()->focusedOrMainFrame()->selection()->selection(); + if (shouldUseSelection(position, selection)) { + performDictionaryLookupForSelection(DictionaryPopupInfo::HotKey, frame, selection); + return; } - if (!characterRange) - return; + NSDictionary *options = nil; + +#if !defined(BUILDING_ON_SNOW_LEOPARD) + // As context, we are going to use the surrounding paragraph of text. + VisiblePosition paragraphStart = startOfParagraph(position); + VisiblePosition paragraphEnd = endOfParagraph(position); + + NSRange rangeToPass = NSMakeRange(TextIterator::rangeLength(makeRange(paragraphStart, position).get()), 0); - // Ensure we have whole words. - VisibleSelection selection(characterRange.get()); - selection.expandUsingGranularity(WordGranularity); + RefPtr<Range> fullCharacterRange = makeRange(paragraphStart, paragraphEnd); + String fullPlainTextString = plainText(fullCharacterRange.get()); - RefPtr<Range> finalRange = selection.toNormalizedRange(); + NSRange extractedRange = WKExtractWordDefinitionTokenRangeFromContextualString(fullPlainTextString, rangeToPass, &options); + + RefPtr<Range> finalRange = TextIterator::subrange(fullCharacterRange.get(), extractedRange.location, extractedRange.length); + if (!finalRange) + return; +#else + RefPtr<Range> finalRange = makeRange(startOfWord(position), endOfWord(position)); if (!finalRange) return; +#endif + + performDictionaryLookupForRange(DictionaryPopupInfo::HotKey, frame, finalRange.get(), options); +} + +void WebPage::performDictionaryLookupForSelection(DictionaryPopupInfo::Type type, Frame* frame, const VisibleSelection& selection) +{ + RefPtr<Range> selectedRange = selection.toNormalizedRange(); + if (!selectedRange) + return; - performDictionaryLookupForRange(DictionaryPopupInfo::HotKey, frame, finalRange.get()); + NSDictionary *options = nil; + +#if !defined(BUILDING_ON_SNOW_LEOPARD) + VisiblePosition selectionStart = selection.visibleStart(); + VisiblePosition selectionEnd = selection.visibleEnd(); + + // As context, we are going to use the surrounding paragraphs of text. + VisiblePosition paragraphStart = startOfParagraph(selectionStart); + VisiblePosition paragraphEnd = endOfParagraph(selectionEnd); + + int lengthToSelectionStart = TextIterator::rangeLength(makeRange(paragraphStart, selectionStart).get()); + int lengthToSelectionEnd = TextIterator::rangeLength(makeRange(paragraphStart, selectionEnd).get()); + NSRange rangeToPass = NSMakeRange(lengthToSelectionStart, lengthToSelectionEnd - lengthToSelectionStart); + + String fullPlainTextString = plainText(makeRange(paragraphStart, paragraphEnd).get()); + + // Since we already have the range we want, we just need to grab the returned options. + WKExtractWordDefinitionTokenRangeFromContextualString(fullPlainTextString, rangeToPass, &options); +#endif + + performDictionaryLookupForRange(type, frame, selectedRange.get(), options); } -void WebPage::performDictionaryLookupForRange(DictionaryPopupInfo::Type type, Frame* frame, Range* range) +void WebPage::performDictionaryLookupForRange(DictionaryPopupInfo::Type type, Frame* frame, Range* range, NSDictionary *options) { String rangeText = range->text(); if (rangeText.stripWhiteSpace().isEmpty()) @@ -316,20 +378,11 @@ void WebPage::performDictionaryLookupForRange(DictionaryPopupInfo::Type type, Fr dictionaryPopupInfo.type = type; dictionaryPopupInfo.origin = FloatPoint(rangeRect.x(), rangeRect.y()); dictionaryPopupInfo.fontInfo.fontAttributeDictionary = fontDescriptorAttributes; + dictionaryPopupInfo.options = (CFDictionaryRef)options; send(Messages::WebPageProxy::DidPerformDictionaryLookup(rangeText, dictionaryPopupInfo)); } -static inline void scroll(Page* page, ScrollDirection direction, ScrollGranularity granularity) -{ - page->focusController()->focusedOrMainFrame()->eventHandler()->scrollRecursively(direction, granularity); -} - -static inline void logicalScroll(Page* page, ScrollLogicalDirection direction, ScrollGranularity granularity) -{ - page->focusController()->focusedOrMainFrame()->eventHandler()->logicalScrollRecursively(direction, granularity); -} - bool WebPage::performDefaultBehaviorForKeyEvent(const WebKeyboardEvent& keyboardEvent) { if (keyboardEvent.type() != WebEvent::KeyDown) @@ -390,7 +443,7 @@ bool WebPage::performDefaultBehaviorForKeyEvent(const WebKeyboardEvent& keyboard if (keyboardEvent.metaKey()) m_page->goBack(); else { - if (keyboardEvent.altKey() | keyboardEvent.controlKey()) + if (keyboardEvent.altKey() || keyboardEvent.controlKey()) scroll(m_page.get(), ScrollLeft, ScrollByPage); else scroll(m_page.get(), ScrollLeft, ScrollByLine); @@ -435,6 +488,13 @@ void WebPage::writeSelectionToPasteboard(const String& pasteboardName, const Vec result = true; } +void WebPage::readSelectionFromPasteboard(const String& pasteboardName, bool& result) +{ + Frame* frame = m_page->focusController()->focusedOrMainFrame(); + frame->editor()->readSelectionFromPasteboard(pasteboardName); + result = true; +} + AccessibilityWebPageObject* WebPage::accessibilityRemoteObject() { return m_mockAccessibilityElement.get(); @@ -472,13 +532,26 @@ String WebPage::cachedResponseMIMETypeForURL(const WebCore::KURL& url) return [[cachedResponse response] MIMEType]; } -bool WebPage::canHandleRequest(const WebCore::ResourceRequest& request) +bool WebPage::platformCanHandleRequest(const WebCore::ResourceRequest& request) { if ([NSURLConnection canHandleRequest:request.nsURLRequest()]) - return YES; + return true; // FIXME: Return true if this scheme is any one WebKit2 knows how to handle. return request.url().protocolIs("applewebdata"); } +void WebPage::setDragSource(NSObject *dragSource) +{ + m_dragSource = dragSource; +} + +void WebPage::platformDragEnded() +{ + // The drag source we care about here is NSFilePromiseDragSource, which doesn't look at + // the arguments. It's OK to just pass arbitrary constant values, so we just pass all zeroes. + [m_dragSource.get() draggedImage:nil endedAt:NSZeroPoint operation:NSDragOperationNone]; + m_dragSource = nullptr; +} + } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebPage/qt/WebPageQt.cpp b/Source/WebKit2/WebProcess/WebPage/qt/WebPageQt.cpp index cad0c04..de8385c 100644 --- a/Source/WebKit2/WebProcess/WebPage/qt/WebPageQt.cpp +++ b/Source/WebKit2/WebProcess/WebPage/qt/WebPageQt.cpp @@ -277,7 +277,7 @@ String WebPage::cachedResponseMIMETypeForURL(const WebCore::KURL&) return String(); } -bool WebPage::canHandleRequest(const WebCore::ResourceRequest&) +bool WebPage::platformCanHandleRequest(const WebCore::ResourceRequest&) { // FIXME: Implement return true; diff --git a/Source/WebKit2/WebProcess/WebPage/win/WebPageWin.cpp b/Source/WebKit2/WebProcess/WebPage/win/WebPageWin.cpp index 73ba2b2..41bb219 100644 --- a/Source/WebKit2/WebProcess/WebPage/win/WebPageWin.cpp +++ b/Source/WebKit2/WebProcess/WebPage/win/WebPageWin.cpp @@ -192,16 +192,6 @@ const char* WebPage::interpretKeyEvent(const KeyboardEvent* evt) return mapKey ? keyPressCommandsMap->get(mapKey) : 0; } -static inline void scroll(Page* page, ScrollDirection direction, ScrollGranularity granularity) -{ - page->focusController()->focusedOrMainFrame()->eventHandler()->scrollRecursively(direction, granularity); -} - -static inline void logicalScroll(Page* page, ScrollLogicalDirection direction, ScrollGranularity granularity) -{ - page->focusController()->focusedOrMainFrame()->eventHandler()->logicalScrollRecursively(direction, granularity); -} - bool WebPage::performDefaultBehaviorForKeyEvent(const WebKeyboardEvent& keyboardEvent) { if (keyboardEvent.type() != WebEvent::KeyDown && keyboardEvent.type() != WebEvent::RawKeyDown) @@ -209,33 +199,53 @@ bool WebPage::performDefaultBehaviorForKeyEvent(const WebKeyboardEvent& keyboard switch (keyboardEvent.windowsVirtualKeyCode()) { case VK_BACK: + if (keyboardEvent.isSystemKey()) + return false; if (keyboardEvent.shiftKey()) m_page->goForward(); else m_page->goBack(); break; case VK_LEFT: - scroll(m_page.get(), ScrollLeft, ScrollByLine); + if (keyboardEvent.isSystemKey()) + m_page->goBack(); + else + scroll(m_page.get(), ScrollLeft, ScrollByLine); break; case VK_RIGHT: - scroll(m_page.get(), ScrollRight, ScrollByLine); + if (keyboardEvent.isSystemKey()) + m_page->goForward(); + else + scroll(m_page.get(), ScrollRight, ScrollByLine); break; case VK_UP: + if (keyboardEvent.isSystemKey()) + return false; scroll(m_page.get(), ScrollUp, ScrollByLine); break; case VK_DOWN: + if (keyboardEvent.isSystemKey()) + return false; scroll(m_page.get(), ScrollDown, ScrollByLine); break; case VK_HOME: + if (keyboardEvent.isSystemKey()) + return false; logicalScroll(m_page.get(), ScrollBlockDirectionBackward, ScrollByDocument); break; case VK_END: + if (keyboardEvent.isSystemKey()) + return false; logicalScroll(m_page.get(), ScrollBlockDirectionForward, ScrollByDocument); break; case VK_PRIOR: + if (keyboardEvent.isSystemKey()) + return false; logicalScroll(m_page.get(), ScrollBlockDirectionBackward, ScrollByPage); break; case VK_NEXT: + if (keyboardEvent.isSystemKey()) + return false; logicalScroll(m_page.get(), ScrollBlockDirectionForward, ScrollByPage); break; default: @@ -296,10 +306,9 @@ String WebPage::cachedResponseMIMETypeForURL(const WebCore::KURL& url) #endif } -bool WebPage::canHandleRequest(const WebCore::ResourceRequest& request) +bool WebPage::platformCanHandleRequest(const WebCore::ResourceRequest& request) { #if USE(CFNETWORK) - // FIXME: Are there other requests we need to be able to handle? WebKit1's WebView.cpp has a FIXME here as well. return CFURLProtocolCanHandleRequest(request.cfURLRequest()); #else return true; diff --git a/Source/WebKit2/WebProcess/WebProcess.cpp b/Source/WebKit2/WebProcess/WebProcess.cpp index 6de748f..ba3290b 100644 --- a/Source/WebKit2/WebProcess/WebProcess.cpp +++ b/Source/WebKit2/WebProcess/WebProcess.cpp @@ -41,6 +41,7 @@ #include "WebFrame.h" #include "WebGeolocationManagerMessages.h" #include "WebKeyValueStorageManager.h" +#include "WebMediaCacheManager.h" #include "WebMemorySampler.h" #include "WebPage.h" #include "WebPageCreationParameters.h" @@ -50,6 +51,7 @@ #include "WebProcessMessages.h" #include "WebProcessProxyMessages.h" #include "WebResourceCacheManager.h" +#include <WebCore/AXObjectCache.h> #include <WebCore/ApplicationCacheStorage.h> #include <WebCore/CrossOriginPreflightResultCache.h> #include <WebCore/Font.h> @@ -62,6 +64,7 @@ #include <WebCore/SchemeRegistry.h> #include <WebCore/SecurityOrigin.h> #include <WebCore/Settings.h> +#include <WebCore/StorageTracker.h> #include <wtf/PassRefPtr.h> #include <wtf/RandomNumber.h> @@ -126,6 +129,7 @@ WebProcess::WebProcess() #endif , m_textCheckerState() , m_geolocationManager(this) + , m_iconDatabaseProxy(this) { #if USE(PLATFORM_STRATEGIES) // Initialize our platform strategies. @@ -175,6 +179,15 @@ void WebProcess::initializeWebProcess(const WebProcessCreationParameters& parame WebDatabaseManager::initialize(parameters.databaseDirectory); #endif +#if ENABLE(ICONDATABASE) + m_iconDatabaseProxy.setEnabled(parameters.iconDatabaseEnabled); +#endif + +#if ENABLE(DOM_STORAGE) + StorageTracker::initializeTracker(parameters.localStorageDirectory); + m_localStorageDirectory = parameters.localStorageDirectory; +#endif + #if ENABLE(OFFLINE_WEB_APPLICATIONS) if (!parameters.applicationCacheDirectory.isEmpty()) cacheStorage().setCacheDirectory(parameters.applicationCacheDirectory); @@ -453,6 +466,17 @@ void WebProcess::calculateCacheSizes(CacheModel cacheModel, uint64_t memorySize, }; } +WebPage* WebProcess::focusedWebPage() const +{ + HashMap<uint64_t, RefPtr<WebPage> >::const_iterator end = m_pageMap.end(); + for (HashMap<uint64_t, RefPtr<WebPage> >::const_iterator it = m_pageMap.begin(); it != end; ++it) { + WebPage* page = (*it).second.get(); + if (page->windowIsFocused()) + return page; + } + return 0; +} + WebPage* WebProcess::webPage(uint64_t pageID) const { return m_pageMap.get(pageID).get(); @@ -565,11 +589,21 @@ void WebProcess::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::Mes return; } + if (messageID.is<CoreIPC::MessageClassWebIconDatabaseProxy>()) { + m_iconDatabaseProxy.didReceiveMessage(connection, messageID, arguments); + return; + } + if (messageID.is<CoreIPC::MessageClassWebKeyValueStorageManager>()) { WebKeyValueStorageManager::shared().didReceiveMessage(connection, messageID, arguments); return; } + if (messageID.is<CoreIPC::MessageClassWebMediaCacheManager>()) { + WebMediaCacheManager::shared().didReceiveMessage(connection, messageID, arguments); + return; + } + if (messageID.is<CoreIPC::MessageClassWebResourceCacheManager>()) { WebResourceCacheManager::shared().didReceiveMessage(connection, messageID, arguments); return; @@ -668,9 +702,11 @@ WebPageGroupProxy* WebProcess::webPageGroup(const WebPageGroupData& pageGroupDat return result.first->second.get(); } -void WebProcess::clearResourceCaches() +void WebProcess::clearResourceCaches(uint32_t cachesToClear) { - platformClearResourceCaches(); + ResourceCachesToClear resourceCachesToClear = static_cast<ResourceCachesToClear>(cachesToClear); + + platformClearResourceCaches(resourceCachesToClear); // Toggling the cache model like this forces the cache to evict all its in-memory resources. // FIXME: We need a better way to do this. @@ -748,6 +784,11 @@ void WebProcess::cancelDownload(uint64_t downloadID) DownloadManager::shared().cancelDownload(downloadID); } +void WebProcess::setEnhancedAccessibility(bool flag) +{ + WebCore::AXObjectCache::setEnhancedUserInterfaceAccessibility(flag); +} + void WebProcess::startMemorySampler(const SandboxExtension::Handle& sampleLogFileHandle, const String& sampleLogFilePath, const double interval) { #if ENABLE(MEMORY_SAMPLER) diff --git a/Source/WebKit2/WebProcess/WebProcess.h b/Source/WebKit2/WebProcess/WebProcess.h index 946bb69..d666910 100644 --- a/Source/WebKit2/WebProcess/WebProcess.h +++ b/Source/WebKit2/WebProcess/WebProcess.h @@ -29,11 +29,13 @@ #include "CacheModel.h" #include "ChildProcess.h" #include "DrawingArea.h" +#include "ResourceCachesToClear.h" #include "SandboxExtension.h" #include "SharedMemory.h" #include "TextCheckerState.h" #include "VisitedLinkTable.h" #include "WebGeolocationManager.h" +#include "WebIconDatabaseProxy.h" #include "WebPageGroupProxy.h" #include <WebCore/LinkHash.h> #include <wtf/Forward.h> @@ -76,7 +78,8 @@ public: WebPage* webPage(uint64_t pageID) const; void createWebPage(uint64_t pageID, const WebPageCreationParameters&); void removeWebPage(uint64_t pageID); - + WebPage* focusedWebPage() const; + InjectedBundle* injectedBundle() const { return m_injectedBundle.get(); } bool isSeparateProcess() const; @@ -116,7 +119,9 @@ public: // Geolocation WebGeolocationManager& geolocationManager() { return m_geolocationManager; } - void clearResourceCaches(); + void clearResourceCaches(uint32_t cachesToClear = AllResourceCaches); + + const String& localStorageDirectory() const { return m_localStorageDirectory; } private: WebProcess(); @@ -144,9 +149,11 @@ private: static void calculateCacheSizes(CacheModel cacheModel, uint64_t memorySize, uint64_t diskFreeSize, unsigned& cacheTotalCapacity, unsigned& cacheMinDeadCapacity, unsigned& cacheMaxDeadCapacity, double& deadDecodedDataDeletionInterval, unsigned& pageCacheCapacity, unsigned long& urlCacheMemoryCapacity, unsigned long& urlCacheDiskCapacity); - void platformClearResourceCaches(); + void platformClearResourceCaches(ResourceCachesToClear); void clearApplicationCache(); + void setEnhancedAccessibility(bool); + #if !ENABLE(PLUGIN_PROCESS) void getSitesWithPluginData(const Vector<String>& pluginPaths, uint64_t callbackID); void clearPluginSiteData(const Vector<String>& pluginPaths, const Vector<String>& sites, uint64_t flags, uint64_t maxAgeInSeconds, uint64_t callbackID); @@ -202,6 +209,9 @@ private: TextCheckerState m_textCheckerState; WebGeolocationManager m_geolocationManager; + WebIconDatabaseProxy m_iconDatabaseProxy; + + String m_localStorageDirectory; }; } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebProcess.messages.in b/Source/WebKit2/WebProcess/WebProcess.messages.in index e297179..36155a7 100644 --- a/Source/WebKit2/WebProcess/WebProcess.messages.in +++ b/Source/WebKit2/WebProcess/WebProcess.messages.in @@ -51,7 +51,7 @@ messages -> WebProcess { ClearPluginSiteData(Vector<WTF::String> pluginPaths, Vector<WTF::String> sites, uint64_t flags, uint64_t maxAgeInSeconds, uint64_t callbackID) #endif - ClearResourceCaches(); + ClearResourceCaches(uint32_t cachesToClear); ClearApplicationCache(); void StartMemorySampler(WebKit::SandboxExtension::Handle sampleLogFileHandle, WTF::String sampleLogFilePath, double interval); @@ -63,4 +63,6 @@ messages -> WebProcess { CancelDownload(uint64_t downloadID) SetTextCheckerState(WebKit::TextCheckerState textCheckerState) + + SetEnhancedAccessibility(bool flag) } diff --git a/Source/WebKit2/WebProcess/com.apple.WebProcess.sb b/Source/WebKit2/WebProcess/com.apple.WebProcess.sb index 07c1f52..fa81666 100644 --- a/Source/WebKit2/WebProcess/com.apple.WebProcess.sb +++ b/Source/WebKit2/WebProcess/com.apple.WebProcess.sb @@ -3,6 +3,10 @@ (allow ipc-posix-shm system-audit system-socket file-read-metadata) (import "system.sb") +(import "com.apple.corefoundation.sb") + +;; Distributed notifications, local pasteboard client +(corefoundation) ;; Read-only preferences and data (allow file-read* @@ -69,6 +73,10 @@ (if (positive? (string-length (param "WEBKIT_DATABASE_DIR"))) (allow file* (subpath (param "WEBKIT_DATABASE_DIR")))) +;; LocalStorage dir +(if (positive? (string-length (param "WEBKIT_LOCALSTORAGE_DIR"))) + (allow file* (subpath (param "WEBKIT_LOCALSTORAGE_DIR")))) + ;; The NSURLCache directory. (if (positive? (string-length (param "NSURL_CACHE_DIR"))) (allow file* (subpath (param "NSURL_CACHE_DIR")))) @@ -87,7 +95,6 @@ ;; Various services required by AppKit and other frameworks (allow mach-lookup (global-name "com.apple.CoreServices.coreservicesd") - (global-name "com.apple.CFPasteboardClient") (global-name "com.apple.DiskArbitration.diskarbitrationd") (global-name "com.apple.FileCoordination") (global-name "com.apple.FontObjectsServer") @@ -99,7 +106,6 @@ (global-name "com.apple.audio.coreaudiod") (global-name "com.apple.cookied") (global-name "com.apple.cvmsServ") - (global-name "com.apple.distributed_notifications.2") (global-name "com.apple.dock.server") (global-name "com.apple.ocspd") (global-name "com.apple.pasteboard.1") diff --git a/Source/WebKit2/WebProcess/gtk/WebProcessGtk.cpp b/Source/WebKit2/WebProcess/gtk/WebProcessGtk.cpp index 0deed68..77088a3 100644 --- a/Source/WebKit2/WebProcess/gtk/WebProcessGtk.cpp +++ b/Source/WebKit2/WebProcess/gtk/WebProcessGtk.cpp @@ -37,7 +37,7 @@ void WebProcess::platformSetCacheModel(CacheModel) notImplemented(); } -void WebProcess::platformClearResourceCaches() +void WebProcess::platformClearResourceCaches(ResourceCachesToClear) { notImplemented(); } diff --git a/Source/WebKit2/WebProcess/mac/WebProcessMac.mm b/Source/WebKit2/WebProcess/mac/WebProcessMac.mm index 92b36b8..88ef834 100644 --- a/Source/WebKit2/WebProcess/mac/WebProcessMac.mm +++ b/Source/WebKit2/WebProcess/mac/WebProcessMac.mm @@ -28,6 +28,7 @@ #import "FullKeyboardAccessWatcher.h" #import "SandboxExtension.h" +#import "WebPage.h" #import "WebProcessCreationParameters.h" #import <WebCore/MemoryCache.h> #import <WebCore/PageCache.h> @@ -37,6 +38,8 @@ #import <mach/host_info.h> #import <mach/mach.h> #import <mach/mach_error.h> +#import <objc/runtime.h> +#import <WebCore/LocalizedStrings.h> #if ENABLE(WEB_PROCESS_SANDBOX) #import <sandbox.h> @@ -106,8 +109,10 @@ void WebProcess::platformSetCacheModel(CacheModel cacheModel) [nsurlCache setDiskCapacity:max<unsigned long>(urlCacheDiskCapacity, [nsurlCache diskCapacity])]; // Don't shrink a big disk cache, since that would cause churn. } -void WebProcess::platformClearResourceCaches() +void WebProcess::platformClearResourceCaches(ResourceCachesToClear cachesToClear) { + if (cachesToClear == InMemoryResourceCachesOnly) + return; [[NSURLCache sharedURLCache] removeAllCachedResponses]; } @@ -152,6 +157,7 @@ static void initializeSandbox(const WebProcessCreationParameters& parameters) appendSandboxParameterConfPath(sandboxParameters, "DARWIN_USER_TEMP_DIR", _CS_DARWIN_USER_TEMP_DIR); appendSandboxParameterConfPath(sandboxParameters, "DARWIN_USER_CACHE_DIR", _CS_DARWIN_USER_CACHE_DIR); appendSandboxParameterPath(sandboxParameters, "WEBKIT_DATABASE_DIR", [(NSString *)parameters.databaseDirectory fileSystemRepresentation]); + appendSandboxParameterPath(sandboxParameters, "WEBKIT_LOCALSTORAGE_DIR", [(NSString *)parameters.localStorageDirectory fileSystemRepresentation]); appendSandboxParameterPath(sandboxParameters, "NSURL_CACHE_DIR", parameters.nsURLCachePath.data()); appendSandboxParameterPath(sandboxParameters, "UI_PROCESS_BUNDLE_RESOURCE_DIR", parameters.uiProcessBundleResourcePath.data()); sandboxParameters.append(static_cast<const char*>(0)); @@ -171,13 +177,23 @@ static void initializeSandbox(const WebProcessCreationParameters& parameters) #endif } +static id NSApplicationAccessibilityFocusedUIElement(NSApplication*, SEL) +{ + WebPage* page = WebProcess::shared().focusedWebPage(); + if (!page || !page->accessibilityRemoteObject()) + return 0; + + return [page->accessibilityRemoteObject() accessibilityFocusedUIElement]; +} + void WebProcess::platformInitializeWebProcess(const WebProcessCreationParameters& parameters, CoreIPC::ArgumentDecoder*) { + [[NSFileManager defaultManager] changeCurrentDirectoryPath:[[NSBundle mainBundle] bundlePath]]; + initializeSandbox(parameters); if (!parameters.parentProcessName.isNull()) { - // FIXME (WebKit2) <rdar://problem/8728860> WebKit2 needs to be localized - NSString *applicationName = [NSString stringWithFormat:@"%@ Web Content", (NSString *)parameters.parentProcessName]; + NSString *applicationName = [NSString stringWithFormat:UI_STRING("%@ Web Content", "Visible name of the web process. The argument is the application name."), (NSString *)parameters.parentProcessName]; WKSetVisibleApplicationName((CFStringRef)applicationName); } @@ -191,6 +207,11 @@ void WebProcess::platformInitializeWebProcess(const WebProcessCreationParameters } m_compositingRenderServerPort = parameters.acceleratedCompositingPort.port(); + + // rdar://9118639 accessibilityFocusedUIElement in NSApplication defaults to use the keyWindow. Since there's + // no window in WK2, NSApplication needs to use the focused page's focused element. + Method methodToPatch = class_getInstanceMethod([NSApplication class], @selector(accessibilityFocusedUIElement)); + method_setImplementation(methodToPatch, (IMP)NSApplicationAccessibilityFocusedUIElement); } void WebProcess::platformTerminate() diff --git a/Source/WebKit2/WebProcess/qt/WebProcessMainQt.cpp b/Source/WebKit2/WebProcess/qt/WebProcessMainQt.cpp index 291c3e7..6ff10ba 100644 --- a/Source/WebKit2/WebProcess/qt/WebProcessMainQt.cpp +++ b/Source/WebKit2/WebProcess/qt/WebProcessMainQt.cpp @@ -48,13 +48,6 @@ #endif #endif -#if !defined(QWEBKIT_EXPORT) -#if defined(QT_SHARED) -#define QWEBKIT_EXPORT Q_DECL_EXPORT -#else -#define QWEBKIT_EXPORT -#endif -#endif #ifndef NDEBUG #include <QDebug> #endif @@ -89,7 +82,7 @@ bool EnvHttpProxyFactory::initializeFromEnvironment() { bool wasSetByEnvironment = false; - QUrl proxyUrl = QUrl::fromUserInput(qgetenv("http_proxy")); + 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); @@ -97,7 +90,7 @@ bool EnvHttpProxyFactory::initializeFromEnvironment() } else m_httpProxy << QNetworkProxy::NoProxy; - proxyUrl = QUrl::fromUserInput(qgetenv("https_proxy")); + 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); @@ -137,9 +130,9 @@ static void initializeProxy() QNetworkProxyFactory::setUseSystemConfiguration(true); } -QWEBKIT_EXPORT int WebProcessMainQt(int argc, char** argv) +Q_DECL_EXPORT int WebProcessMainQt(int argc, char** argv) { - QApplication::setGraphicsSystem("raster"); + QApplication::setGraphicsSystem(QLatin1String("raster")); QApplication* app = new QApplication(argc, argv); #ifndef NDEBUG if (!qgetenv("WEBKIT2_PAUSE_WEB_PROCESS_ON_LAUNCH").isEmpty()) { diff --git a/Source/WebKit2/WebProcess/qt/WebProcessQt.cpp b/Source/WebKit2/WebProcess/qt/WebProcessQt.cpp index 459274c..919044e 100644 --- a/Source/WebKit2/WebProcess/qt/WebProcessQt.cpp +++ b/Source/WebKit2/WebProcess/qt/WebProcessQt.cpp @@ -37,7 +37,7 @@ void WebProcess::platformSetCacheModel(CacheModel) // FIXME: Implement. } -void WebProcess::platformClearResourceCaches() +void WebProcess::platformClearResourceCaches(ResourceCachesToClear) { } diff --git a/Source/WebKit2/WebProcess/win/WebProcessWin.cpp b/Source/WebKit2/WebProcess/win/WebProcessWin.cpp index 58230d3..d56fef6 100644 --- a/Source/WebKit2/WebProcess/win/WebProcessWin.cpp +++ b/Source/WebKit2/WebProcess/win/WebProcessWin.cpp @@ -26,6 +26,7 @@ #include "config.h" #include "WebProcess.h" +#include "WebCookieManager.h" #include "WebProcessCreationParameters.h" #include <WebCore/FileSystem.h> #include <WebCore/MemoryCache.h> @@ -98,9 +99,11 @@ void WebProcess::platformSetCacheModel(CacheModel cacheModel) #endif } -void WebProcess::platformClearResourceCaches() +void WebProcess::platformClearResourceCaches(ResourceCachesToClear cachesToClear) { #if USE(CFNETWORK) + if (cachesToClear == InMemoryResourceCachesOnly) + return; CFURLCacheRemoveAllCachedResponses(RetainPtr<CFURLCacheRef>(AdoptCF, CFURLCacheCopySharedURLCache()).get()); #endif } @@ -119,6 +122,8 @@ void WebProcess::platformInitializeWebProcess(const WebProcessCreationParameters RetainPtr<CFURLCacheRef> uiProcessCache(AdoptCF, CFURLCacheCreate(kCFAllocatorDefault, cacheMemoryCapacity, cacheDiskCapacity, cachePath.get())); CFURLCacheSetSharedURLCache(uiProcessCache.get()); #endif + + WebCookieManager::shared().setHTTPCookieAcceptPolicy(parameters.initialHTTPCookieAcceptPolicy); } void WebProcess::platformTerminate() |