diff options
author | Ben Murdoch <benm@google.com> | 2011-05-24 11:24:40 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2011-06-02 09:53:15 +0100 |
commit | 81bc750723a18f21cd17d1b173cd2a4dda9cea6e (patch) | |
tree | 7a9e5ed86ff429fd347a25153107221543909b19 /Source/WebKit2/UIProcess/API | |
parent | 94088a6d336c1dd80a1e734af51e96abcbb689a7 (diff) | |
download | external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.zip external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.tar.gz external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.tar.bz2 |
Merge WebKit at r80534: Intial merge by Git
Change-Id: Ia7a83357124c9e1cdb1debf55d9661ec0bd09a61
Diffstat (limited to 'Source/WebKit2/UIProcess/API')
41 files changed, 1264 insertions, 193 deletions
diff --git a/Source/WebKit2/UIProcess/API/C/WKAPICast.h b/Source/WebKit2/UIProcess/API/C/WKAPICast.h index 5ce3b1f..a2983e9 100644 --- a/Source/WebKit2/UIProcess/API/C/WKAPICast.h +++ b/Source/WebKit2/UIProcess/API/C/WKAPICast.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010, 2011 Apple Inc. All rights reserved. * Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -45,9 +45,12 @@ class AuthenticationChallengeProxy; class AuthenticationDecisionListener; class DownloadProxy; class GeolocationPermissionRequestProxy; +class WebApplicationCacheManagerProxy; class WebBackForwardList; class WebBackForwardListItem; +class WebResourceCacheManagerProxy; class WebContext; +class WebCookieManagerProxy; class WebCredential; class WebDatabaseManagerProxy; class WebFormSubmissionListenerProxy; @@ -56,19 +59,24 @@ class WebFrameProxy; class WebGeolocationManagerProxy; class WebGeolocationPosition; class WebInspectorProxy; +class WebKeyValueStorageManagerProxy; class WebNavigationData; class WebOpenPanelParameters; class WebOpenPanelResultListenerProxy; class WebPageGroup; class WebPageProxy; +class WebPluginSiteDataManager; class WebPreferences; class WebProtectionSpace; +WK_ADD_API_MAPPING(WKApplicationCacheManagerRef, WebApplicationCacheManagerProxy) WK_ADD_API_MAPPING(WKAuthenticationChallengeRef, AuthenticationChallengeProxy) WK_ADD_API_MAPPING(WKAuthenticationDecisionListenerRef, AuthenticationDecisionListener) WK_ADD_API_MAPPING(WKBackForwardListItemRef, WebBackForwardListItem) WK_ADD_API_MAPPING(WKBackForwardListRef, WebBackForwardList) +WK_ADD_API_MAPPING(WKResourceCacheManagerRef, WebResourceCacheManagerProxy) WK_ADD_API_MAPPING(WKContextRef, WebContext) +WK_ADD_API_MAPPING(WKCookieManagerRef, WebCookieManagerProxy) WK_ADD_API_MAPPING(WKCredentialRef, WebCredential) WK_ADD_API_MAPPING(WKDatabaseManagerRef, WebDatabaseManagerProxy) WK_ADD_API_MAPPING(WKDownloadRef, DownloadProxy) @@ -78,11 +86,13 @@ WK_ADD_API_MAPPING(WKFrameRef, WebFrameProxy) WK_ADD_API_MAPPING(WKGeolocationManagerRef, WebGeolocationManagerProxy) WK_ADD_API_MAPPING(WKGeolocationPermissionRequestRef, GeolocationPermissionRequestProxy) WK_ADD_API_MAPPING(WKGeolocationPositionRef, WebGeolocationPosition) +WK_ADD_API_MAPPING(WKKeyValueStorageManagerRef, WebKeyValueStorageManagerProxy) WK_ADD_API_MAPPING(WKNavigationDataRef, WebNavigationData) WK_ADD_API_MAPPING(WKOpenPanelParametersRef, WebOpenPanelParameters) WK_ADD_API_MAPPING(WKOpenPanelResultListenerRef, WebOpenPanelResultListenerProxy) WK_ADD_API_MAPPING(WKPageGroupRef, WebPageGroup) WK_ADD_API_MAPPING(WKPageRef, WebPageProxy) +WK_ADD_API_MAPPING(WKPluginSiteDataManagerRef, WebPluginSiteDataManager) WK_ADD_API_MAPPING(WKPreferencesRef, WebPreferences) WK_ADD_API_MAPPING(WKProtectionSpaceRef, WebProtectionSpace) diff --git a/Source/WebKit2/UIProcess/API/C/WKApplicationCacheManager.cpp b/Source/WebKit2/UIProcess/API/C/WKApplicationCacheManager.cpp new file mode 100644 index 0000000..2d95c67 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKApplicationCacheManager.cpp @@ -0,0 +1,52 @@ +/* + * 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 "WKApplicationCacheManager.h" + +#include "WKAPICast.h" +#include "WebApplicationCacheManagerProxy.h" + +using namespace WebKit; + +WKTypeID WKApplicationCacheManagerGetTypeID() +{ + return toAPI(WebApplicationCacheManagerProxy::APIType); +} + +void WKApplicationCacheManagerGetApplicationCacheOrigins(WKApplicationCacheManagerRef applicationCacheManagerRef, void* context, WKApplicationCacheManagerGetApplicationCacheOriginsFunction callback) +{ + toImpl(applicationCacheManagerRef)->getApplicationCacheOrigins(ArrayCallback::create(context, callback)); +} + +void WKApplicationCacheManagerDeleteEntriesForOrigin(WKApplicationCacheManagerRef applicationCacheManagerRef, WKSecurityOriginRef originRef) +{ + toImpl(applicationCacheManagerRef)->deleteEntriesForOrigin(toImpl(originRef)); +} + +void WKApplicationCacheManagerDeleteAllEntries(WKApplicationCacheManagerRef applicationCacheManagerRef) +{ + toImpl(applicationCacheManagerRef)->deleteAllEntries(); +} diff --git a/Source/WebKit2/UIProcess/API/C/WKApplicationCacheManager.h b/Source/WebKit2/UIProcess/API/C/WKApplicationCacheManager.h new file mode 100644 index 0000000..c40039e --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKApplicationCacheManager.h @@ -0,0 +1,47 @@ +/* + * 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 WKApplicationCacheManager_h +#define WKApplicationCacheManager_h + +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKTypeID WKApplicationCacheManagerGetTypeID(); + +typedef void (*WKApplicationCacheManagerGetApplicationCacheOriginsFunction)(WKArrayRef, WKErrorRef, void*); +WK_EXPORT void WKApplicationCacheManagerGetApplicationCacheOrigins(WKApplicationCacheManagerRef applicationCacheManager, void* context, WKApplicationCacheManagerGetApplicationCacheOriginsFunction function); + +WK_EXPORT void WKApplicationCacheManagerDeleteEntriesForOrigin(WKApplicationCacheManagerRef applicationCacheManager, WKSecurityOriginRef origin); +WK_EXPORT void WKApplicationCacheManagerDeleteAllEntries(WKApplicationCacheManagerRef applicationCacheManager); + +#ifdef __cplusplus +} +#endif + +#endif // WKApplicationCacheManager_h diff --git a/Source/WebKit2/UIProcess/API/C/WKContext.cpp b/Source/WebKit2/UIProcess/API/C/WKContext.cpp index 82bd13d..6e4e5e0 100644 --- a/Source/WebKit2/UIProcess/API/C/WKContext.cpp +++ b/Source/WebKit2/UIProcess/API/C/WKContext.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 @@ -158,6 +158,16 @@ void WKContextClearApplicationCache(WKContextRef contextRef) toImpl(contextRef)->clearApplicationCache(); } +WKCookieManagerRef WKContextGetCookieManager(WKContextRef contextRef) +{ + return toAPI(toImpl(contextRef)->cookieManagerProxy()); +} + +WKApplicationCacheManagerRef WKContextGetApplicationCacheManager(WKContextRef contextRef) +{ + return toAPI(toImpl(contextRef)->applicationCacheManagerProxy()); +} + WKDatabaseManagerRef WKContextGetDatabaseManager(WKContextRef contextRef) { return toAPI(toImpl(contextRef)->databaseManagerProxy()); @@ -168,6 +178,21 @@ WKGeolocationManagerRef WKContextGetGeolocationManager(WKContextRef contextRef) return toAPI(toImpl(contextRef)->geolocationManagerProxy()); } +WKKeyValueStorageManagerRef WKContextGetKeyValueStorageManager(WKContextRef contextRef) +{ + return toAPI(toImpl(contextRef)->keyValueStorageManagerProxy()); +} + +WKPluginSiteDataManagerRef WKContextGetPluginSiteDataManager(WKContextRef contextRef) +{ + return toAPI(toImpl(contextRef)->pluginSiteDataManager()); +} + +WKResourceCacheManagerRef WKContextGetResourceCacheManager(WKContextRef contextRef) +{ + return toAPI(toImpl(contextRef)->resourceCacheManagerProxy()); +} + void WKContextStartMemorySampler(WKContextRef contextRef, WKDoubleRef interval) { toImpl(contextRef)->startMemorySampler(toImpl(interval)->value()); diff --git a/Source/WebKit2/UIProcess/API/C/WKContext.h b/Source/WebKit2/UIProcess/API/C/WKContext.h index 810ad20..f8e7cee 100644 --- a/Source/WebKit2/UIProcess/API/C/WKContext.h +++ b/Source/WebKit2/UIProcess/API/C/WKContext.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 @@ -119,12 +119,17 @@ WK_EXPORT WKCacheModel WKContextGetCacheModel(WKContextRef context); WK_EXPORT void WKContextClearResourceCaches(WKContextRef context); WK_EXPORT void WKContextClearApplicationCache(WKContextRef context); - + WK_EXPORT void WKContextStartMemorySampler(WKContextRef context, WKDoubleRef interval); WK_EXPORT void WKContextStopMemorySampler(WKContextRef context); +WK_EXPORT WKApplicationCacheManagerRef WKContextGetApplicationCacheManager(WKContextRef context); +WK_EXPORT WKCookieManagerRef WKContextGetCookieManager(WKContextRef context); WK_EXPORT WKDatabaseManagerRef WKContextGetDatabaseManager(WKContextRef context); WK_EXPORT WKGeolocationManagerRef WKContextGetGeolocationManager(WKContextRef context); +WK_EXPORT WKKeyValueStorageManagerRef WKContextGetKeyValueStorageManager(WKContextRef context); +WK_EXPORT WKPluginSiteDataManagerRef WKContextGetPluginSiteDataManager(WKContextRef context); +WK_EXPORT WKResourceCacheManagerRef WKContextGetResourceCacheManager(WKContextRef context); #ifdef __cplusplus } diff --git a/Source/WebKit2/UIProcess/API/C/WKCookieManager.cpp b/Source/WebKit2/UIProcess/API/C/WKCookieManager.cpp new file mode 100644 index 0000000..83578f7 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKCookieManager.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 "WKCookieManager.h" + +#include "WKAPICast.h" +#include "WebCookieManagerProxy.h" + +using namespace WebKit; + +WKTypeID WKCookieManagerGetTypeID() +{ + return toAPI(WebCookieManagerProxy::APIType); +} + +void WKCookieManagerSetClient(WKCookieManagerRef cookieManagerRef, const WKCookieManagerClient* wkClient) +{ + if (wkClient && wkClient->version) + return; + toImpl(cookieManagerRef)->initializeClient(wkClient); +} + +void WKCookieManagerGetHostnamesWithCookies(WKCookieManagerRef cookieManagerRef, void* context, WKCookieManagerGetCookieHostnamesFunction callback) +{ + toImpl(cookieManagerRef)->getHostnamesWithCookies(ArrayCallback::create(context, callback)); +} + +void WKCookieManagerDeleteCookiesForHostname(WKCookieManagerRef cookieManagerRef, WKStringRef hostname) +{ + toImpl(cookieManagerRef)->deleteCookiesForHostname(toImpl(hostname)->string()); +} + +void WKCookieManagerDeleteAllCookies(WKCookieManagerRef cookieManagerRef) +{ + toImpl(cookieManagerRef)->deleteAllCookies(); +} + +void WKCookieManagerStartObservingCookieChanges(WKCookieManagerRef cookieManager) +{ + toImpl(cookieManager)->startObservingCookieChanges(); +} + +void WKCookieManagerStopObservingCookieChanges(WKCookieManagerRef cookieManager) +{ + toImpl(cookieManager)->stopObservingCookieChanges(); +} diff --git a/Source/WebKit2/UIProcess/API/C/WKCookieManager.h b/Source/WebKit2/UIProcess/API/C/WKCookieManager.h new file mode 100644 index 0000000..75d8ef5 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKCookieManager.h @@ -0,0 +1,62 @@ +/* + * 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 WKCookieManager_h +#define WKCookieManager_h + +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +// Cookie Manager Client +typedef void (*WKCookieManagerCookiesDidChangeCallback)(WKCookieManagerRef cookieManager, const void *clientInfo); + +struct WKCookieManagerClient { + int version; + const void * clientInfo; + WKCookieManagerCookiesDidChangeCallback cookiesDidChange; +}; +typedef struct WKCookieManagerClient WKCookieManagerClient; + +WK_EXPORT WKTypeID WKCookieManagerGetTypeID(); + +WK_EXPORT void WKCookieManagerSetClient(WKCookieManagerRef cookieManager, const WKCookieManagerClient* client); + +typedef void (*WKCookieManagerGetCookieHostnamesFunction)(WKArrayRef, WKErrorRef, void*); +WK_EXPORT void WKCookieManagerGetHostnamesWithCookies(WKCookieManagerRef cookieManager, void* context, WKCookieManagerGetCookieHostnamesFunction function); + +WK_EXPORT void WKCookieManagerDeleteCookiesForHostname(WKCookieManagerRef cookieManager, WKStringRef hostname); +WK_EXPORT void WKCookieManagerDeleteAllCookies(WKCookieManagerRef cookieManager); + +WK_EXPORT void WKCookieManagerStartObservingCookieChanges(WKCookieManagerRef cookieManager); +WK_EXPORT void WKCookieManagerStopObservingCookieChanges(WKCookieManagerRef cookieManager); + +#ifdef __cplusplus +} +#endif + +#endif // WKCookieManager_h diff --git a/Source/WebKit2/UIProcess/API/C/WKKeyValueStorageManager.cpp b/Source/WebKit2/UIProcess/API/C/WKKeyValueStorageManager.cpp new file mode 100644 index 0000000..f050692 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKKeyValueStorageManager.cpp @@ -0,0 +1,52 @@ +/* + * 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 "WKKeyValueStorageManager.h" + +#include "WKAPICast.h" +#include "WebKeyValueStorageManagerProxy.h" + +using namespace WebKit; + +WKTypeID WKKeyValueStorageManagerGetTypeID() +{ + return toAPI(WebKeyValueStorageManagerProxy::APIType); +} + +void WKKeyValueStorageManagerGetKeyValueStorageOrigins(WKKeyValueStorageManagerRef keyValueStorageManagerRef, void* context, WKKeyValueStorageManagerGetKeyValueStorageOriginsFunction callback) +{ + toImpl(keyValueStorageManagerRef)->getKeyValueStorageOrigins(ArrayCallback::create(context, callback)); +} + +void WKKeyValueStorageManagerDeleteEntriesForOrigin(WKKeyValueStorageManagerRef keyValueStorageManagerRef, WKSecurityOriginRef originRef) +{ + toImpl(keyValueStorageManagerRef)->deleteEntriesForOrigin(toImpl(originRef)); +} + +void WKKeyValueStorageManagerDeleteAllEntries(WKKeyValueStorageManagerRef keyValueStorageManagerRef) +{ + toImpl(keyValueStorageManagerRef)->deleteAllEntries(); +} diff --git a/Source/WebKit2/UIProcess/API/C/WKKeyValueStorageManager.h b/Source/WebKit2/UIProcess/API/C/WKKeyValueStorageManager.h new file mode 100644 index 0000000..a0ee278 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKKeyValueStorageManager.h @@ -0,0 +1,47 @@ +/* + * 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 WKKeyValueStorageManager_h +#define WKKeyValueStorageManager_h + +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKTypeID WKKeyValueStorageManagerGetTypeID(); + +typedef void (*WKKeyValueStorageManagerGetKeyValueStorageOriginsFunction)(WKArrayRef, WKErrorRef, void*); +WK_EXPORT void WKKeyValueStorageManagerGetKeyValueStorageOrigins(WKKeyValueStorageManagerRef keyValueStorageManager, void* context, WKKeyValueStorageManagerGetKeyValueStorageOriginsFunction function); + +WK_EXPORT void WKKeyValueStorageManagerDeleteEntriesForOrigin(WKKeyValueStorageManagerRef keyValueStorageManager, WKSecurityOriginRef origin); +WK_EXPORT void WKKeyValueStorageManagerDeleteAllEntries(WKKeyValueStorageManagerRef keyValueStorageManager); + +#ifdef __cplusplus +} +#endif + +#endif // WKKeyValueStorageManager_h diff --git a/Source/WebKit2/UIProcess/API/C/WKPage.cpp b/Source/WebKit2/UIProcess/API/C/WKPage.cpp index 1d5763f..c4e8eae 100644 --- a/Source/WebKit2/UIProcess/API/C/WKPage.cpp +++ b/Source/WebKit2/UIProcess/API/C/WKPage.cpp @@ -27,6 +27,7 @@ #include "WKPage.h" #include "WKPagePrivate.h" +#include "PrintInfo.h" #include "WKAPICast.h" #include "WebBackForwardList.h" #include "WebData.h" @@ -170,6 +171,11 @@ double WKPageGetEstimatedProgress(WKPageRef pageRef) return toImpl(pageRef)->estimatedProgress(); } +void WKPageSetMemoryCacheClientCallsEnabled(WKPageRef pageRef, bool memoryCacheClientCallsEnabled) +{ + toImpl(pageRef)->setMemoryCacheClientCallsEnabled(memoryCacheClientCallsEnabled); +} + WKStringRef WKPageCopyUserAgent(WKPageRef pageRef) { return toCopiedAPI(toImpl(pageRef)->userAgent()); @@ -301,6 +307,31 @@ bool WKPageHasVerticalScrollbar(WKPageRef pageRef) return toImpl(pageRef)->hasVerticalScrollbar(); } +bool WKPageIsPinnedToLeftSide(WKPageRef pageRef) +{ + return toImpl(pageRef)->isPinnedToLeftSide(); +} + +bool WKPageIsPinnedToRightSide(WKPageRef pageRef) +{ + return toImpl(pageRef)->isPinnedToRightSide(); +} + +bool WKPageCanDelete(WKPageRef pageRef) +{ + return toImpl(pageRef)->canDelete(); +} + +bool WKPageHasSelectedRange(WKPageRef pageRef) +{ + return toImpl(pageRef)->hasSelectedRange(); +} + +bool WKPageIsContentEditable(WKPageRef pageRef) +{ + return toImpl(pageRef)->isContentEditable(); +} + void WKPageFindString(WKPageRef pageRef, WKStringRef string, WKFindOptions options, unsigned maxMatchCount) { toImpl(pageRef)->findString(toImpl(string)->string(), toFindOptions(options), maxMatchCount); @@ -367,11 +398,11 @@ void WKPageSetPageUIClient(WKPageRef pageRef, const WKPageUIClient* wkClient) void WKPageRunJavaScriptInMainFrame(WKPageRef pageRef, WKStringRef scriptRef, void* context, WKPageRunJavaScriptFunction callback) { - toImpl(pageRef)->runJavaScriptInMainFrame(toImpl(scriptRef)->string(), StringCallback::create(context, callback)); + toImpl(pageRef)->runJavaScriptInMainFrame(toImpl(scriptRef)->string(), ScriptValueCallback::create(context, callback)); } #ifdef __BLOCKS__ -static void callRunJavaScriptBlockAndRelease(WKStringRef resultValue, WKErrorRef error, void* context) +static void callRunJavaScriptBlockAndRelease(WKSerializedScriptValueRef resultValue, WKErrorRef error, void* context) { WKPageRunJavaScriptBlock block = (WKPageRunJavaScriptBlock)context; block(resultValue, error); @@ -452,3 +483,69 @@ WK_EXPORT WKURLRef WKPageCopyPendingAPIRequestURL(WKPageRef pageRef) return 0; return toCopiedURLAPI(toImpl(pageRef)->pendingAPIRequestURL()); } + +void WKPageSetDebugPaintFlags(WKPageDebugPaintFlags flags) +{ + WebPageProxy::setDebugPaintFlags(flags); +} + +WKPageDebugPaintFlags WKPageGetDebugPaintFlags() +{ + return WebPageProxy::debugPaintFlags(); +} + +void WKPageValidateCommand(WKPageRef pageRef, WKStringRef command, void* context, WKPageValidateCommandCallback callback) +{ + toImpl(pageRef)->validateCommand(toImpl(command)->string(), ValidateCommandCallback::create(context, callback)); +} + +void WKPageExecuteCommand(WKPageRef pageRef, WKStringRef command) +{ + toImpl(pageRef)->executeEditCommand(toImpl(command)->string()); +} + +#if PLATFORM(MAC) || PLATFORM(WIN) +struct ComputedPagesContext { + ComputedPagesContext(WKPageComputePagesForPrintingFunction callback, void* context) + : callback(callback) + , context(context) + { + } + WKPageComputePagesForPrintingFunction callback; + void* context; +}; + +static void computedPagesCallback(const Vector<WebCore::IntRect>& rects, double scaleFactor, WKErrorRef error, void* untypedContext) +{ + OwnPtr<ComputedPagesContext> context = adoptPtr(static_cast<ComputedPagesContext*>(untypedContext)); + Vector<WKRect> wkRects(rects.size()); + for (size_t i = 0; i < rects.size(); ++i) + wkRects[i] = toAPI(rects[i]); + context->callback(wkRects.data(), wkRects.size(), scaleFactor, error, context->context); +} + +static PrintInfo printInfoFromWKPrintInfo(const WKPrintInfo& printInfo) +{ + PrintInfo result; + result.pageSetupScaleFactor = printInfo.pageSetupScaleFactor; + result.availablePaperWidth = printInfo.availablePaperWidth; + result.availablePaperHeight = printInfo.availablePaperHeight; + return result; +} + +void WKPageComputePagesForPrinting(WKPageRef page, WKFrameRef frame, WKPrintInfo printInfo, WKPageComputePagesForPrintingFunction callback, void* context) +{ + toImpl(page)->computePagesForPrinting(toImpl(frame), printInfoFromWKPrintInfo(printInfo), ComputedPagesCallback::create(new ComputedPagesContext(callback, context), computedPagesCallback)); +} + +void WKPageBeginPrinting(WKPageRef page, WKFrameRef frame, WKPrintInfo printInfo) +{ + toImpl(page)->beginPrinting(toImpl(frame), printInfoFromWKPrintInfo(printInfo)); +} + +void WKPageDrawPagesToPDF(WKPageRef page, WKFrameRef frame, uint32_t first, uint32_t count, WKPageDrawToPDFFunction callback, void* context) +{ + toImpl(page)->drawPagesToPDF(toImpl(frame), first, count, DataCallback::create(context, callback)); +} +#endif + diff --git a/Source/WebKit2/UIProcess/API/C/WKPage.h b/Source/WebKit2/UIProcess/API/C/WKPage.h index e6ebc5c..655e999 100644 --- a/Source/WebKit2/UIProcess/API/C/WKPage.h +++ b/Source/WebKit2/UIProcess/API/C/WKPage.h @@ -61,6 +61,7 @@ typedef void (*WKPageDidRunInsecureContentForFrameCallback)(WKPageRef page, WKFr typedef bool (*WKPageCanAuthenticateAgainstProtectionSpaceInFrameCallback)(WKPageRef page, WKFrameRef frame, WKProtectionSpaceRef protectionSpace, const void *clientInfo); typedef void (*WKPageDidReceiveAuthenticationChallengeInFrameCallback)(WKPageRef page, WKFrameRef frame, WKAuthenticationChallengeRef authenticationChallenge, const void *clientInfo); typedef void (*WKPageDidChangeBackForwardListCallback)(WKPageRef page, WKBackForwardListItemRef addedItem, WKArrayRef removedItems, const void *clientInfo); +typedef bool (*WKPageShouldGoToBackForwardListItemCallback)(WKPageRef page, WKBackForwardListItemRef item, const void *clientInfo); struct WKPageLoaderClient { int version; @@ -93,20 +94,23 @@ struct WKPageLoaderClient { WKPageCallback processDidCrash; WKPageDidChangeBackForwardListCallback didChangeBackForwardList; + WKPageShouldGoToBackForwardListItemCallback shouldGoToBackForwardListItem; }; typedef struct WKPageLoaderClient WKPageLoaderClient; // Policy Client. typedef void (*WKPageDecidePolicyForNavigationActionCallback)(WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo); typedef void (*WKPageDecidePolicyForNewWindowActionCallback)(WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKStringRef frameName, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo); -typedef void (*WKPageDecidePolicyForMIMETypeCallback)(WKPageRef page, WKFrameRef frame, WKStringRef MIMEType, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo); +typedef void (*WKPageDecidePolicyForResponseCallback)(WKPageRef page, WKFrameRef frame, WKURLResponseRef response, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo); +typedef void (*WKPageUnableToImplementPolicyCallback)(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void* clientInfo); struct WKPagePolicyClient { int version; const void * clientInfo; WKPageDecidePolicyForNavigationActionCallback decidePolicyForNavigationAction; WKPageDecidePolicyForNewWindowActionCallback decidePolicyForNewWindowAction; - WKPageDecidePolicyForMIMETypeCallback decidePolicyForMIMEType; + WKPageDecidePolicyForResponseCallback decidePolicyForResponse; + WKPageUnableToImplementPolicyCallback unableToImplementPolicy; }; typedef struct WKPagePolicyClient WKPagePolicyClient; @@ -147,7 +151,7 @@ typedef bool (*WKPageRunJavaScriptConfirmCallback)(WKPageRef page, WKStringRef m typedef WKStringRef (*WKPageRunJavaScriptPromptCallback)(WKPageRef page, WKStringRef message, WKStringRef defaultValue, WKFrameRef frame, const void *clientInfo); typedef void (*WKPageSetStatusTextCallback)(WKPageRef page, WKStringRef text, const void *clientInfo); typedef void (*WKPageMouseDidMoveOverElementCallback)(WKPageRef page, WKEventModifiers modifiers, WKTypeRef userData, const void *clientInfo); -typedef void (*WKPageMissingPluginButtonClickedCallback)(WKPageRef page, WKStringRef mimeType, WKStringRef url, const void* clientInfo); +typedef void (*WKPageMissingPluginButtonClickedCallback)(WKPageRef page, WKStringRef mimeType, WKStringRef url, WKStringRef pluginsPageURL, const void* clientInfo); typedef void (*WKPageDidNotHandleKeyEventCallback)(WKPageRef page, WKNativeEventPtr event, const void *clientInfo); typedef bool (*WKPageGetToolbarsAreVisibleCallback)(WKPageRef page, const void *clientInfo); typedef void (*WKPageSetToolbarsAreVisibleCallback)(WKPageRef page, bool toolbarsVisible, const void *clientInfo); @@ -267,11 +271,15 @@ WK_EXPORT WKBackForwardListRef WKPageGetBackForwardList(WKPageRef page); WK_EXPORT WKStringRef WKPageCopyTitle(WKPageRef page); +WK_EXPORT WKURLRef WKPageCopyPendingAPIRequestURL(WKPageRef page); + WK_EXPORT WKFrameRef WKPageGetMainFrame(WKPageRef page); WK_EXPORT WKFrameRef WKPageGetFocusedFrame(WKPageRef page); // The focused frame may be inactive. WK_EXPORT WKFrameRef WKPageGetFrameSetLargestFrame(WKPageRef page); WK_EXPORT double WKPageGetEstimatedProgress(WKPageRef page); +WK_EXPORT void WKPageSetMemoryCacheClientCallsEnabled(WKPageRef page, bool memoryCacheClientCallsEnabled); + #if defined(ENABLE_INSPECTOR) && ENABLE_INSPECTOR WK_EXPORT WKInspectorRef WKPageGetInspector(WKPageRef page); #endif @@ -314,6 +322,13 @@ WK_EXPORT WKSize WKPageFixedLayoutSize(WKPageRef page); WK_EXPORT bool WKPageHasHorizontalScrollbar(WKPageRef page); WK_EXPORT bool WKPageHasVerticalScrollbar(WKPageRef page); +WK_EXPORT bool WKPageIsPinnedToLeftSide(WKPageRef page); +WK_EXPORT bool WKPageIsPinnedToRightSide(WKPageRef page); + +WK_EXPORT bool WKPageCanDelete(WKPageRef page); +WK_EXPORT bool WKPageHasSelectedRange(WKPageRef page); +WK_EXPORT bool WKPageIsContentEditable(WKPageRef page); + WK_EXPORT void WKPageFindString(WKPageRef page, WKStringRef string, WKFindOptions findOptions, unsigned maxMatchCount); WK_EXPORT void WKPageHideFindUI(WKPageRef page); WK_EXPORT void WKPageCountStringMatches(WKPageRef page, WKStringRef string, WKFindOptions findOptions, unsigned maxMatchCount); @@ -326,10 +341,10 @@ WK_EXPORT void WKPageSetPagePolicyClient(WKPageRef page, const WKPagePolicyClien WK_EXPORT void WKPageSetPageResourceLoadClient(WKPageRef page, const WKPageResourceLoadClient* client); WK_EXPORT void WKPageSetPageUIClient(WKPageRef page, const WKPageUIClient* client); -typedef void (*WKPageRunJavaScriptFunction)(WKStringRef, WKErrorRef, void*); +typedef void (*WKPageRunJavaScriptFunction)(WKSerializedScriptValueRef, WKErrorRef, void*); WK_EXPORT void WKPageRunJavaScriptInMainFrame(WKPageRef page, WKStringRef script, void* context, WKPageRunJavaScriptFunction function); #ifdef __BLOCKS__ -typedef void (^WKPageRunJavaScriptBlock)(WKStringRef, WKErrorRef); +typedef void (^WKPageRunJavaScriptBlock)(WKSerializedScriptValueRef, WKErrorRef); WK_EXPORT void WKPageRunJavaScriptInMainFrame_b(WKPageRef page, WKStringRef script, WKPageRunJavaScriptBlock block); #endif @@ -350,7 +365,21 @@ WK_EXPORT void WKPageGetContentsAsString_b(WKPageRef page, WKPageGetContentsAsSt typedef void (*WKPageForceRepaintFunction)(WKErrorRef, void*); WK_EXPORT void WKPageForceRepaint(WKPageRef page, void* context, WKPageForceRepaintFunction function); -WK_EXPORT WKURLRef WKPageCopyPendingAPIRequestURL(WKPageRef page); +/* + Some of the more common command name strings include the following, although any WebCore EditorCommand string is supported: + + "Cut" + "Copy" + "Paste" + "SelectAll" + "Undo" + "Redo" +*/ + +// state represents the state of the command in a menu (on is 1, off is 0, and mixed is -1), typically used to add a checkmark next to the menu item. +typedef void (*WKPageValidateCommandCallback)(WKStringRef command, bool isEnabled, int32_t state, WKErrorRef, void* context); +WK_EXPORT void WKPageValidateCommand(WKPageRef page, WKStringRef command, void* context, WKPageValidateCommandCallback callback); +WK_EXPORT void WKPageExecuteCommand(WKPageRef page, WKStringRef command); #ifdef __cplusplus } diff --git a/Source/WebKit2/UIProcess/API/C/WKPagePrivate.h b/Source/WebKit2/UIProcess/API/C/WKPagePrivate.h index 3bf50c3..2c1f985 100644 --- a/Source/WebKit2/UIProcess/API/C/WKPagePrivate.h +++ b/Source/WebKit2/UIProcess/API/C/WKPagePrivate.h @@ -41,6 +41,29 @@ typedef void (^WKPageRenderTreeExternalRepresentationBlock)(WKStringRef, WKError WK_EXPORT void WKPageRenderTreeExternalRepresentation_b(WKPageRef page, WKPageRenderTreeExternalRepresentationBlock block); #endif +enum { + kWKDebugFlashViewUpdates = 1 << 0, + kWKDebugFlashBackingStoreUpdates = 1 << 1 +}; +typedef unsigned WKPageDebugPaintFlags; + +WK_EXPORT void WKPageSetDebugPaintFlags(WKPageDebugPaintFlags flags); +WK_EXPORT WKPageDebugPaintFlags WKPageGetDebugPaintFlags(void); + +struct WKPrintInfo { + float pageSetupScaleFactor; + float availablePaperWidth; + float availablePaperHeight; +}; +typedef struct WKPrintInfo WKPrintInfo; + +typedef void (*WKPageComputePagesForPrintingFunction)(WKRect* pageRects, uint32_t pageCount, double resultPageScaleFactor, WKErrorRef error, void* functionContext); +WK_EXPORT void WKPageComputePagesForPrinting(WKPageRef page, WKFrameRef frame, WKPrintInfo, WKPageComputePagesForPrintingFunction, void* context); + +typedef void (*WKPageDrawToPDFFunction)(WKDataRef data, WKErrorRef error, void* functionContext); +WK_EXPORT void WKPageBeginPrinting(WKPageRef page, WKFrameRef frame, WKPrintInfo); +WK_EXPORT void WKPageDrawPagesToPDF(WKPageRef page, WKFrameRef frame, uint32_t first, uint32_t count, WKPageDrawToPDFFunction callback, void* context); + #ifdef __cplusplus } #endif diff --git a/Source/WebKit2/UIProcess/API/C/WKPluginSiteDataManager.cpp b/Source/WebKit2/UIProcess/API/C/WKPluginSiteDataManager.cpp new file mode 100644 index 0000000..8cfe143 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKPluginSiteDataManager.cpp @@ -0,0 +1,65 @@ +/* + * 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 "WKPluginSiteDataManager.h" + +#include "WKAPICast.h" +#include "WebPluginSiteDataManager.h" +#include <WebCore/npapi.h> + +using namespace WebKit; +using namespace std; + +WKTypeID WKPluginSiteDataManagerGetTypeID() +{ + return toAPI(WebPluginSiteDataManager::APIType); +} + +void WKPluginSiteDataManagerGetSitesWithData(WKPluginSiteDataManagerRef managerRef, void* context, WKPluginSiteDataManagerGetSitesWithDataFunction callback) +{ + toImpl(managerRef)->getSitesWithData(ArrayCallback::create(context, callback)); +} + +static uint64_t toNPClearSiteDataFlags(WKClearSiteDataFlags flags) +{ + if (flags == kWKClearSiteDataFlagsClearAll) + return NP_CLEAR_ALL; + + uint64_t result = 0; + if (flags & kWKClearSiteDataFlagsClearCache) + result |= NP_CLEAR_CACHE; + return result; +} + +void WKPluginSiteDataManagerClearSiteData(WKPluginSiteDataManagerRef managerRef, WKArrayRef sitesRef, WKClearSiteDataFlags flags, uint64_t maxAgeInSeconds, void* context, WKPluginSiteDataManagerClearSiteDataFunction function) +{ + toImpl(managerRef)->clearSiteData(toImpl(sitesRef), toNPClearSiteDataFlags(flags), maxAgeInSeconds, VoidCallback::create(context, function)); +} + +void WKPluginSiteDataManagerClearAllSiteData(WKPluginSiteDataManagerRef managerRef, void* context, WKPluginSiteDataManagerClearSiteDataFunction function) +{ + toImpl(managerRef)->clearSiteData(0, NP_CLEAR_ALL, numeric_limits<uint64_t>::max(), VoidCallback::create(context, function)); +} diff --git a/Source/WebKit2/UIProcess/API/C/WKPluginSiteDataManager.h b/Source/WebKit2/UIProcess/API/C/WKPluginSiteDataManager.h new file mode 100644 index 0000000..66e76fb --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKPluginSiteDataManager.h @@ -0,0 +1,55 @@ +/* + * 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 WKPluginSiteDataManager_h +#define WKPluginSiteDataManager_h + +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKTypeID WKPluginSiteDataManagerGetTypeID(); + +typedef void (*WKPluginSiteDataManagerGetSitesWithDataFunction)(WKArrayRef, WKErrorRef, void*); +WK_EXPORT void WKPluginSiteDataManagerGetSitesWithData(WKPluginSiteDataManagerRef manager, void* context, WKPluginSiteDataManagerGetSitesWithDataFunction function); + +enum { + kWKClearSiteDataFlagsClearAll = 0, + kWKClearSiteDataFlagsClearCache = 1 << 0, +}; +typedef uint64_t WKClearSiteDataFlags; + +typedef void (*WKPluginSiteDataManagerClearSiteDataFunction)(WKErrorRef, void*); + +WK_EXPORT void WKPluginSiteDataManagerClearSiteData(WKPluginSiteDataManagerRef manager, WKArrayRef sites, WKClearSiteDataFlags flags, uint64_t maxAgeInSeconds, void* context, WKPluginSiteDataManagerClearSiteDataFunction function); +WK_EXPORT void WKPluginSiteDataManagerClearAllSiteData(WKPluginSiteDataManagerRef manager, void* context, WKPluginSiteDataManagerClearSiteDataFunction function); + +#ifdef __cplusplus +} +#endif + +#endif // WKPluginSiteDataManager_h diff --git a/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp b/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp index 97e9403..7ba9ba0 100644 --- a/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp +++ b/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp @@ -301,6 +301,16 @@ WKFontSmoothingLevel WKPreferencesGetFontSmoothingLevel(WKPreferencesRef prefere return toAPI(static_cast<FontSmoothingLevel>(toImpl(preferencesRef)->fontSmoothingLevel())); } +void WKPreferencesSetAcceleratedDrawingEnabled(WKPreferencesRef preferencesRef, bool flag) +{ + toImpl(preferencesRef)->setAcceleratedDrawingEnabled(flag); +} + +bool WKPreferencesGetAcceleratedDrawingEnabled(WKPreferencesRef preferencesRef) +{ + return toImpl(preferencesRef)->acceleratedDrawingEnabled(); +} + void WKPreferencesSetAcceleratedCompositingEnabled(WKPreferencesRef preferencesRef, bool flag) { toImpl(preferencesRef)->setAcceleratedCompositingEnabled(flag); diff --git a/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h b/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h index ff9beec..426119b 100644 --- a/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h +++ b/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h @@ -47,6 +47,10 @@ typedef enum WKFontSmoothingLevel WKFontSmoothingLevel; WK_EXPORT void WKPreferencesSetFontSmoothingLevel(WKPreferencesRef, WKFontSmoothingLevel); WK_EXPORT WKFontSmoothingLevel WKPreferencesGetFontSmoothingLevel(WKPreferencesRef); +// Defaults to false. +WK_EXPORT void WKPreferencesSetAcceleratedDrawingEnabled(WKPreferencesRef, bool); +WK_EXPORT bool WKPreferencesGetAcceleratedDrawingEnabled(WKPreferencesRef); + // Defaults to true. WK_EXPORT void WKPreferencesSetAcceleratedCompositingEnabled(WKPreferencesRef, bool); WK_EXPORT bool WKPreferencesGetAcceleratedCompositingEnabled(WKPreferencesRef); diff --git a/Source/WebKit2/UIProcess/API/C/WKResourceCacheManager.cpp b/Source/WebKit2/UIProcess/API/C/WKResourceCacheManager.cpp new file mode 100644 index 0000000..483beeb --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKResourceCacheManager.cpp @@ -0,0 +1,52 @@ +/* + * 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 "WKResourceCacheManager.h" + +#include "WebResourceCacheManagerProxy.h" +#include "WKAPICast.h" + +using namespace WebKit; + +WKTypeID WKResourceCacheManagerGetTypeID() +{ + return toAPI(WebResourceCacheManagerProxy::APIType); +} + +void WKResourceCacheManagerGetCacheOrigins(WKResourceCacheManagerRef cacheManagerRef, void* context, WKResourceCacheManagerGetCacheOriginsFunction callback) +{ + toImpl(cacheManagerRef)->getCacheOrigins(ArrayCallback::create(context, callback)); +} + +void WKResourceCacheManagerClearCacheForOrigin(WKResourceCacheManagerRef cacheManagerRef, WKSecurityOriginRef originRef) +{ + toImpl(cacheManagerRef)->clearCacheForOrigin(toImpl(originRef)); +} + +void WKResourceCacheManagerClearCacheForAllOrigins(WKResourceCacheManagerRef cacheManagerRef) +{ + toImpl(cacheManagerRef)->clearCacheForAllOrigins(); +} diff --git a/Source/WebKit2/UIProcess/API/C/WKResourceCacheManager.h b/Source/WebKit2/UIProcess/API/C/WKResourceCacheManager.h new file mode 100644 index 0000000..479169d --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKResourceCacheManager.h @@ -0,0 +1,47 @@ +/* + * 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 WKResourceCacheManager_h +#define WKResourceCacheManager_h + +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKTypeID WKResourceCacheManagerGetTypeID(); + +typedef void (*WKResourceCacheManagerGetCacheOriginsFunction)(WKArrayRef, WKErrorRef, void*); +WK_EXPORT void WKResourceCacheManagerGetCacheOrigins(WKResourceCacheManagerRef contextRef, void* context, WKResourceCacheManagerGetCacheOriginsFunction function); + +WK_EXPORT void WKResourceCacheManagerClearCacheForOrigin(WKResourceCacheManagerRef cacheManger, WKSecurityOriginRef origin); +WK_EXPORT void WKResourceCacheManagerClearCacheForAllOrigins(WKResourceCacheManagerRef cacheManager); + +#ifdef __cplusplus +} +#endif + +#endif // WKResourceCacheManager_h diff --git a/Source/WebKit2/UIProcess/API/C/gtk/WKView.cpp b/Source/WebKit2/UIProcess/API/C/gtk/WKView.cpp index aa88151..e3d6c69 100644 --- a/Source/WebKit2/UIProcess/API/C/gtk/WKView.cpp +++ b/Source/WebKit2/UIProcess/API/C/gtk/WKView.cpp @@ -37,9 +37,9 @@ using namespace WebKit; using namespace WebCore; -WKViewRef WKViewCreate(GdkRectangle rect, WKContextRef contextRef, WKPageGroupRef pageGroupRef) +WKViewRef WKViewCreate(WKContextRef contextRef, WKPageGroupRef pageGroupRef) { - RefPtr<WebView> view = WebView::create(rect, toImpl(contextRef), toImpl(pageGroupRef)); + RefPtr<WebView> view = WebView::create(toImpl(contextRef), toImpl(pageGroupRef)); return toAPI(view.release().leakRef()); } diff --git a/Source/WebKit2/UIProcess/API/C/gtk/WKView.h b/Source/WebKit2/UIProcess/API/C/gtk/WKView.h index 5415fd3..82e55ab 100644 --- a/Source/WebKit2/UIProcess/API/C/gtk/WKView.h +++ b/Source/WebKit2/UIProcess/API/C/gtk/WKView.h @@ -35,13 +35,14 @@ extern "C" { #endif -WK_EXPORT WKViewRef WKViewCreate(GdkRectangle rect, WKContextRef context, WKPageGroupRef pageGroup); +WK_EXPORT WKViewRef WKViewCreate(WKContextRef context, WKPageGroupRef pageGroup); WK_EXPORT GtkWidget* WKViewGetWindow(WKViewRef view); WK_EXPORT WKPageRef WKViewGetPage(WKViewRef view); WK_EXPORT WKURLRef WKURLCreateWithURL(const char*); + #ifdef __cplusplus } #endif diff --git a/Source/WebKit2/UIProcess/API/mac/FindIndicatorWindow.mm b/Source/WebKit2/UIProcess/API/mac/FindIndicatorWindow.mm index e622c9d..715bba7 100644 --- a/Source/WebKit2/UIProcess/API/mac/FindIndicatorWindow.mm +++ b/Source/WebKit2/UIProcess/API/mac/FindIndicatorWindow.mm @@ -27,6 +27,7 @@ #import "FindIndicatorWindow.h" #import "FindIndicator.h" +#import "WKView.h" #import <WebCore/GraphicsContext.h> static const double bounceAnimationDuration = 0.12; diff --git a/Source/WebKit2/UIProcess/API/mac/PDFViewController.h b/Source/WebKit2/UIProcess/API/mac/PDFViewController.h index 2c4a235..d22d8b5 100644 --- a/Source/WebKit2/UIProcess/API/mac/PDFViewController.h +++ b/Source/WebKit2/UIProcess/API/mac/PDFViewController.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 @@ -49,7 +49,7 @@ public: ~PDFViewController(); WKView* wkView() const { return m_wkView; } - void setPDFDocumentData(const String& mimeType, const CoreIPC::DataReference&); + void setPDFDocumentData(const String& mimeType, const String& suggestedFilename, const CoreIPC::DataReference&); double zoomFactor() const; void setZoomFactor(double); @@ -57,16 +57,26 @@ public: static Class pdfPreviewViewClass(); NSPrintOperation *makePrintOperation(NSPrintInfo *); - + void openPDFInFinder(); + private: explicit PDFViewController(WKView *wkView); static Class pdfDocumentClass(); static NSBundle* pdfKitBundle(); + NSString *pathToPDFOnDisk(); + WKView* m_wkView; + RetainPtr<WKPDFView> m_wkPDFView; PDFView* m_pdfView; + + RetainPtr<NSString> m_suggestedFilename; + RetainPtr<CFDataRef> m_pdfData; + + RetainPtr<NSString> m_pathToPDFOnDisk; + bool m_hasWrittenPDFToDisk; }; } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/API/mac/PDFViewController.mm b/Source/WebKit2/UIProcess/API/mac/PDFViewController.mm index 6ab425d..5d9b860 100644 --- a/Source/WebKit2/UIProcess/API/mac/PDFViewController.mm +++ b/Source/WebKit2/UIProcess/API/mac/PDFViewController.mm @@ -87,6 +87,7 @@ extern "C" NSString *_NSPathForSystemFramework(NSString *framework); [self addSubview:_pdfPreviewView.get()]; _pdfView = [_pdfPreviewView.get() performSelector:@selector(pdfView)]; + [_pdfView setDelegate:self]; } return self; @@ -179,6 +180,13 @@ extern "C" NSString *_NSPathForSystemFramework(NSString *framework); [notificationCenter removeObserver:self name:_webkit_PDFViewPageChangedNotification object:_pdfView]; } +// PDFView delegate methods + +- (void)PDFViewOpenPDFInNativeApplication:(PDFView *)sender +{ + _pdfViewController->openPDFInFinder(); +} + @end namespace WebKit { @@ -192,6 +200,7 @@ PDFViewController::PDFViewController(WKView *wkView) : m_wkView(wkView) , m_wkPDFView(AdoptNS, [[WKPDFView alloc] initWithFrame:[m_wkView bounds] PDFViewController:this]) , m_pdfView([m_wkPDFView.get() pdfView]) + , m_hasWrittenPDFToDisk(false) { [m_wkView addSubview:m_wkPDFView.get()]; } @@ -231,20 +240,20 @@ static RetainPtr<CFDataRef> convertPostScriptDataSourceToPDF(const CoreIPC::Data return result; } -void PDFViewController::setPDFDocumentData(const String& mimeType, const CoreIPC::DataReference& dataReference) +void PDFViewController::setPDFDocumentData(const String& mimeType, const String& suggestedFilename, const CoreIPC::DataReference& dataReference) { - RetainPtr<CFDataRef> data; - if (equalIgnoringCase(mimeType, "application/postscript")) { - data = convertPostScriptDataSourceToPDF(dataReference); - if (!data) + m_pdfData = convertPostScriptDataSourceToPDF(dataReference); + if (!m_pdfData) return; } else { // Make sure to copy the data. - data.adoptCF(CFDataCreate(0, dataReference.data(), dataReference.size())); + m_pdfData.adoptCF(CFDataCreate(0, dataReference.data(), dataReference.size())); } - RetainPtr<PDFDocument> pdfDocument(AdoptNS, [[pdfDocumentClass() alloc] initWithData:(NSData *)data.get()]); + m_suggestedFilename = suggestedFilename; + + RetainPtr<PDFDocument> pdfDocument(AdoptNS, [[pdfDocumentClass() alloc] initWithData:(NSData *)m_pdfData.get()]); [m_wkPDFView.get() setDocument:pdfDocument.get()]; } @@ -295,4 +304,74 @@ NSPrintOperation *PDFViewController::makePrintOperation(NSPrintInfo *printInfo) return [[m_pdfView document] getPrintOperationForPrintInfo:printInfo autoRotate:YES]; } +void PDFViewController::openPDFInFinder() +{ + // We don't want to open the PDF until we have a document to write. (see 4892525). + if (![m_pdfView document]) { + NSBeep(); + return; + } + + NSString *path = pathToPDFOnDisk(); + if (!path) + return; + + if (!m_hasWrittenPDFToDisk) { + // Create a PDF file with the minimal permissions (only accessible to the current user, see 4145714). + RetainPtr<NSNumber> permissions(AdoptNS, [[NSNumber alloc] initWithInt:S_IRUSR]); + RetainPtr<NSDictionary> fileAttributes(AdoptNS, [[NSDictionary alloc] initWithObjectsAndKeys:permissions.get(), NSFilePosixPermissions, nil]); + + if (![[NSFileManager defaultManager] createFileAtPath:path contents:(NSData *)m_pdfData.get() attributes:fileAttributes.get()]) + return; + + m_hasWrittenPDFToDisk = true; + } + + [[NSWorkspace sharedWorkspace] openFile:path]; +} + +static NSString *temporaryPDFDirectoryPath() +{ + static NSString *temporaryPDFDirectoryPath; + + if (!temporaryPDFDirectoryPath) { + NSString *temporaryDirectoryTemplate = [NSTemporaryDirectory() stringByAppendingPathComponent:@"WebKitPDFs-XXXXXX"]; + CString templateRepresentation = [temporaryDirectoryTemplate fileSystemRepresentation]; + + if (mkdtemp(templateRepresentation.mutableData())) + temporaryPDFDirectoryPath = [[[NSFileManager defaultManager] stringWithFileSystemRepresentation:templateRepresentation.data() length:templateRepresentation.length()] copy]; + } + + return temporaryPDFDirectoryPath; +} + +NSString *PDFViewController::pathToPDFOnDisk() +{ + if (m_pathToPDFOnDisk) + return m_pathToPDFOnDisk.get(); + + NSString *pdfDirectoryPath = temporaryPDFDirectoryPath(); + if (!pdfDirectoryPath) + return nil; + + NSString *path = [pdfDirectoryPath stringByAppendingPathComponent:m_suggestedFilename.get()]; + + NSFileManager *fileManager = [NSFileManager defaultManager]; + if ([fileManager fileExistsAtPath:path]) { + NSString *pathTemplatePrefix = [pdfDirectoryPath stringByAppendingString:@"XXXXXX-"]; + NSString *pathTemplate = [pathTemplatePrefix stringByAppendingPathComponent:m_suggestedFilename.get()]; + CString pathTemplateRepresentation = [pathTemplate fileSystemRepresentation]; + + int fd = mkstemps(pathTemplateRepresentation.mutableData(), pathTemplateRepresentation.length() - strlen([pathTemplatePrefix fileSystemRepresentation]) + 1); + if (fd < 0) + return nil; + + close(fd); + path = [fileManager stringWithFileSystemRepresentation:pathTemplateRepresentation.data() length:pathTemplateRepresentation.length()]; + } + + m_pathToPDFOnDisk.adoptNS([path copy]); + return path; +} + } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h index b557c1a..e01cf66 100644 --- a/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h +++ b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h @@ -69,7 +69,6 @@ private: virtual void registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo); virtual void clearAllEditCommands(); - virtual void setEditCommandState(const String& commandName, bool isEnabled, int state); virtual void interceptKeyEvent(const NativeWebKeyboardEvent& event, Vector<WebCore::KeypressCommand>& commandName, uint32_t selectionStart, uint32_t selectionEnd, Vector<WebCore::CompositionUnderline>& underlines); virtual void setDragImage(const WebCore::IntPoint& clientPosition, const WebCore::IntSize& imageSize, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag); @@ -86,11 +85,6 @@ private: virtual void enterAcceleratedCompositingMode(const LayerTreeContext&); virtual void exitAcceleratedCompositingMode(); -#if USE(ACCELERATED_COMPOSITING) - virtual void pageDidEnterAcceleratedCompositing(); - virtual void pageDidLeaveAcceleratedCompositing(); -#endif - virtual void accessibilityWebProcessTokenReceived(const CoreIPC::DataReference&); virtual void setComplexTextInputEnabled(uint64_t pluginComplexTextInputIdentifier, bool complexTextInputEnabled); virtual void setAutodisplay(bool); @@ -100,11 +94,15 @@ private: virtual void didChangeScrollbarsForMainFrame() const; virtual void didCommitLoadForMainFrame(bool useCustomRepresentation); - virtual void didFinishLoadingDataForCustomRepresentation(const CoreIPC::DataReference&); + virtual void didFinishLoadingDataForCustomRepresentation(const String& suggestedFilename, const CoreIPC::DataReference&); virtual double customRepresentationZoomFactor(); virtual void setCustomRepresentationZoomFactor(double); + virtual void flashBackingStoreUpdates(const Vector<WebCore::IntRect>& updateRects); + + virtual void didPerformDictionaryLookup(const String&, double scaleFactor, const DictionaryPopupInfo&); + WKView* m_wkView; RetainPtr<WebEditorUndoTargetObjC> m_undoTarget; }; diff --git a/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm index fd70a67..88bb9a4 100644 --- a/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm +++ b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm @@ -27,6 +27,7 @@ #import "PageClientImpl.h" #import "DataReference.h" +#import "DictionaryPopupInfo.h" #import "FindIndicator.h" #import "NativeWebKeyboardEvent.h" #import "WKAPICast.h" @@ -40,6 +41,7 @@ #import <WebCore/FoundationExtras.h> #import <WebCore/GraphicsContext.h> #import <WebCore/KeyboardEvent.h> +#import <WebCore/NotImplemented.h> #import <wtf/PassOwnPtr.h> #import <wtf/text/CString.h> #import <wtf/text/WTFString.h> @@ -279,11 +281,6 @@ void PageClientImpl::clearAllEditCommands() [[m_wkView undoManager] removeAllActionsWithTarget:m_undoTarget.get()]; } -void PageClientImpl::setEditCommandState(const String& commandName, bool isEnabled, int newState) -{ - [m_wkView _setUserInterfaceItemState:nsStringFromWebCoreString(commandName) enabled:isEnabled state:newState]; -} - void PageClientImpl::interceptKeyEvent(const NativeWebKeyboardEvent& event, Vector<WebCore::KeypressCommand>& commandsList, uint32_t selectionStart, uint32_t selectionEnd, Vector<WebCore::CompositionUnderline>& underlines) { commandsList = [m_wkView _interceptKeyEvent:event.nativeEvent()]; @@ -294,7 +291,6 @@ void PageClientImpl::setDragImage(const IntPoint& clientPosition, const IntSize& { OwnPtr<GraphicsContext> graphicsContext = dragImage->createGraphicsContext(); RetainPtr<NSImage> dragNSImage(AdoptNS, [[NSImage alloc] initWithCGImage:CGBitmapContextCreateImage(graphicsContext->platformContext()) size:imageSize]); - [dragNSImage.get() setFlipped:YES]; [m_wkView _setDragImage:dragNSImage.get() at:clientPosition linkDrag:isLinkDrag]; } @@ -352,16 +348,6 @@ void PageClientImpl::exitAcceleratedCompositingMode() { [m_wkView _exitAcceleratedCompositingMode]; } - -void PageClientImpl::pageDidEnterAcceleratedCompositing() -{ - [m_wkView _pageDidEnterAcceleratedCompositing]; -} - -void PageClientImpl::pageDidLeaveAcceleratedCompositing() -{ - [m_wkView _pageDidLeaveAcceleratedCompositing]; -} #endif // USE(ACCELERATED_COMPOSITING) void PageClientImpl::setComplexTextInputEnabled(uint64_t pluginComplexTextInputIdentifier, bool complexTextInputEnabled) @@ -375,11 +361,21 @@ void PageClientImpl::setAutodisplay(bool newState) [m_wkView displayIfNeeded]; [[m_wkView window] setAutodisplay:newState]; + + // For some reason, painting doesn't happen for a long time without this call, <rdar://problem/8975229>. + if (newState) + [m_wkView displayIfNeeded]; } CGContextRef PageClientImpl::containingWindowGraphicsContext() { - return static_cast<CGContextRef>([[[m_wkView window] graphicsContext] graphicsPort]); + NSWindow *window = [m_wkView window]; + + // Don't try to get the graphics context if the NSWindow doesn't have a window device. + if ([window windowNumber] <= 0) + return 0; + + return static_cast<CGContextRef>([[window graphicsContext] graphicsPort]); } void PageClientImpl::didChangeScrollbarsForMainFrame() const @@ -392,9 +388,9 @@ void PageClientImpl::didCommitLoadForMainFrame(bool useCustomRepresentation) [m_wkView _setPageHasCustomRepresentation:useCustomRepresentation]; } -void PageClientImpl::didFinishLoadingDataForCustomRepresentation(const CoreIPC::DataReference& dataReference) +void PageClientImpl::didFinishLoadingDataForCustomRepresentation(const String& suggestedFilename, const CoreIPC::DataReference& dataReference) { - [m_wkView _didFinishLoadingDataForCustomRepresentation:dataReference]; + [m_wkView _didFinishLoadingDataForCustomRepresentationWithSuggestedFilename:suggestedFilename dataReference:dataReference]; } double PageClientImpl::customRepresentationZoomFactor() @@ -407,4 +403,25 @@ void PageClientImpl::setCustomRepresentationZoomFactor(double zoomFactor) [m_wkView _setCustomRepresentationZoomFactor:zoomFactor]; } +void PageClientImpl::flashBackingStoreUpdates(const Vector<IntRect>&) +{ + notImplemented(); +} + +void PageClientImpl::didPerformDictionaryLookup(const String& text, double scaleFactor, const DictionaryPopupInfo& dictionaryPopupInfo) +{ + NSFontDescriptor *fontDescriptor = [NSFontDescriptor fontDescriptorWithFontAttributes:(NSDictionary *)dictionaryPopupInfo.fontInfo.fontAttributeDictionary.get()]; + NSFont *font = [NSFont fontWithDescriptor:fontDescriptor size:((scaleFactor != 1) ? [fontDescriptor pointSize] * scaleFactor : 0)]; + + RetainPtr<NSMutableAttributedString> attributedString(AdoptNS, [[NSMutableAttributedString alloc] initWithString:nsStringFromWebCoreString(text)]); + [attributedString.get() addAttribute:NSFontAttributeName value:font range:NSMakeRange(0, [attributedString.get() length])]; + + NSPoint textBaselineOrigin = dictionaryPopupInfo.origin; + textBaselineOrigin.y += [font ascender]; + + // If the dictionary lookup is being triggered by a hot key, force the overlay style. + NSDictionary *options = (dictionaryPopupInfo.type == DictionaryPopupInfo::HotKey) ? [NSDictionary dictionaryWithObject:NSDefinitionPresentationTypeOverlay forKey:NSDefinitionPresentationTypeKey] : 0; + [m_wkView showDefinitionForAttributedString:attributedString.get() range:NSMakeRange(0, [attributedString.get() length]) options:options baselineOriginProvider:^(NSRange adjustedRange) { return (NSPoint)textBaselineOrigin; }]; +} + } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/API/mac/WKView.mm b/Source/WebKit2/UIProcess/API/mac/WKView.mm index da29e04..e432549 100644 --- a/Source/WebKit2/UIProcess/API/mac/WKView.mm +++ b/Source/WebKit2/UIProcess/API/mac/WKView.mm @@ -31,7 +31,6 @@ #import "DrawingAreaProxyImpl.h" #import "FindIndicator.h" #import "FindIndicatorWindow.h" -#import "LayerBackedDrawingAreaProxy.h" #import "LayerTreeContext.h" #import "Logging.h" #import "NativeWebKeyboardEvent.h" @@ -52,7 +51,6 @@ #import "WebEventFactory.h" #import "WebPage.h" #import "WebPageProxy.h" -#import "WebProcessManager.h" #import "WebProcessProxy.h" #import "WebSystemInterface.h" #import <QuartzCore/QuartzCore.h> @@ -208,6 +206,8 @@ static bool useNewDrawingArea() if (!self) return nil; + [NSApp registerServicesMenuSendTypes:PasteboardTypes::forSelection() returnTypes:PasteboardTypes::forEditing()]; + InitWebCoreSystemInterface(); RunLoop::initializeMainRunLoop(); @@ -496,6 +496,30 @@ WEBCORE_COMMAND(yankAndSelect) #undef WEBCORE_COMMAND +- (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pasteboard types:(NSArray *)types +{ + Vector<String> pasteboardTypes; + size_t numTypes = [types count]; + for (size_t i = 0; i < numTypes; ++i) + pasteboardTypes.append([types objectAtIndex:i]); + return _data->_page->writeSelectionToPasteboard([pasteboard name], pasteboardTypes); +} + +- (id)validRequestorForSendType:(NSString *)sendType returnType:(NSString *)returnType +{ + BOOL isValidSendType = !sendType || ([PasteboardTypes::forSelection() containsObject:sendType] && !_data->_page->selectionState().isNone); + BOOL isValidReturnType = NO; + if (!returnType) + isValidReturnType = YES; + else if ([PasteboardTypes::forEditing() containsObject:returnType] && _data->_page->selectionState().isContentEditable) { + // We can insert strings in any editable context. We can insert other types, like images, only in rich edit contexts. + isValidReturnType = _data->_page->selectionState().isContentRichlyEditable || [returnType isEqualToString:NSStringPboardType]; + } + if (isValidSendType && isValidReturnType) + return self; + return [[self nextResponder] validRequestorForSendType:sendType returnType:returnType]; +} + /* When possible, editing-related methods should be implemented in WebCore with the @@ -548,6 +572,18 @@ static NSToolbarItem *toolbarItem(id <NSValidatedUserInterfaceItem> item) return (NSToolbarItem *)item; } +static void validateCommandCallback(WKStringRef commandName, bool isEnabled, int32_t state, WKErrorRef error, void* context) +{ + // If the process exits before the command can be validated, we'll be called back with an error. + if (error) + return; + + WKView* wkView = static_cast<WKView*>(context); + ASSERT(wkView); + + [wkView _setUserInterfaceItemState:nsStringFromWebCoreString(toImpl(commandName)->string()) enabled:isEnabled state:state]; +} + - (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)item { SEL action = [item action]; @@ -643,8 +679,7 @@ static NSToolbarItem *toolbarItem(id <NSValidatedUserInterfaceItem> item) // If we are not already awaiting validation for this command, start the asynchronous validation process. // FIXME: Theoretically, there is a race here; when we get the answer it might be old, from a previous time // we asked for the same command; there is no guarantee the answer is still valid. - // FIXME: The function called here should be renamed validateCommand because it is not specific to menu items. - _data->_page->validateMenuItem(commandName); + _data->_page->validateCommand(commandName, ValidateCommandCallback::create(self, validateCommandCallback)); } // Treat as enabled until we get the result back from the web process and _setUserInterfaceItemState is called. @@ -715,6 +750,23 @@ static void speakString(WKStringRef string, WKErrorRef error, void*) _data->_page->unmarkAllMisspellings(); } +- (BOOL)isGrammarCheckingEnabled +{ + return TextChecker::state().isGrammarCheckingEnabled; +} + +- (void)setGrammarCheckingEnabled:(BOOL)flag +{ + if (static_cast<bool>(flag) == TextChecker::state().isGrammarCheckingEnabled) + return; + + TextChecker::setGrammarCheckingEnabled(flag); + _data->_page->process()->updateTextCheckerState(); + + if (!flag) + _data->_page->unmarkAllBadGrammar(); +} + - (IBAction)toggleGrammarChecking:(id)sender { bool grammarCheckingEnabled = !TextChecker::state().isGrammarCheckingEnabled; @@ -1496,6 +1548,13 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I return _data->_page->drawsBackground(); } +- (BOOL)mouseDownCanMoveWindow +{ + // -[NSView mouseDownCanMoveWindow] returns YES when the NSView is transparent, + // but we don't want a drag in the NSView to move the window, even if it's transparent. + return NO; +} + - (void)viewDidHide { _data->_page->viewStateDidChange(WebPageProxy::ViewIsVisible); @@ -1506,6 +1565,11 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I _data->_page->viewStateDidChange(WebPageProxy::ViewIsVisible); } +- (id)accessibilityFocusedUIElement +{ + return _data->_remoteAccessibilityChild.get(); +} + - (BOOL)accessibilityIsIgnored { return NO; @@ -1802,95 +1866,6 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I _data->_findIndicatorWindow->setFindIndicator(findIndicator, fadeOut); } -#if USE(ACCELERATED_COMPOSITING) -- (void)_startAcceleratedCompositing:(CALayer *)rootLayer -{ - if (!_data->_oldLayerHostingView) { - NSView *hostingView = [[NSView alloc] initWithFrame:[self bounds]]; -#if !defined(BUILDING_ON_LEOPARD) - [hostingView setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; -#endif - - [self addSubview:hostingView]; - [hostingView release]; - _data->_oldLayerHostingView = hostingView; - } - - // Make a container layer, which will get sized/positioned by AppKit and CA. - CALayer *viewLayer = [CALayer layer]; - -#ifndef NDEBUG - [viewLayer setName:@"hosting layer"]; -#endif - -#if defined(BUILDING_ON_LEOPARD) - // Turn off default animations. - NSNull *nullValue = [NSNull null]; - NSDictionary *actions = [NSDictionary dictionaryWithObjectsAndKeys: - nullValue, @"anchorPoint", - nullValue, @"bounds", - nullValue, @"contents", - nullValue, @"contentsRect", - nullValue, @"opacity", - nullValue, @"position", - nullValue, @"sublayerTransform", - nullValue, @"sublayers", - nullValue, @"transform", - nil]; - [viewLayer setStyle:[NSDictionary dictionaryWithObject:actions forKey:@"actions"]]; -#endif - -#if !defined(BUILDING_ON_LEOPARD) - // If we aren't in the window yet, we'll use the screen's scale factor now, and reset the scale - // via -viewDidMoveToWindow. - CGFloat scaleFactor = [self window] ? [[self window] userSpaceScaleFactor] : [[NSScreen mainScreen] userSpaceScaleFactor]; - [viewLayer setTransform:CATransform3DMakeScale(scaleFactor, scaleFactor, 1)]; -#endif - - [_data->_oldLayerHostingView setLayer:viewLayer]; - [_data->_oldLayerHostingView setWantsLayer:YES]; - - // Parent our root layer in the container layer - [viewLayer addSublayer:rootLayer]; -} - -- (void)_stopAcceleratedCompositing -{ - if (_data->_oldLayerHostingView) { - [_data->_oldLayerHostingView setLayer:nil]; - [_data->_oldLayerHostingView setWantsLayer:NO]; - [_data->_oldLayerHostingView removeFromSuperview]; - _data->_oldLayerHostingView = nil; - } -} - -- (void)_switchToDrawingAreaTypeIfNecessary:(DrawingAreaInfo::Type)type -{ - DrawingAreaInfo::Type existingDrawingAreaType = _data->_page->drawingArea() ? _data->_page->drawingArea()->info().type : DrawingAreaInfo::None; - if (existingDrawingAreaType == type) - return; - - OwnPtr<DrawingAreaProxy> newDrawingArea; - switch (type) { - case DrawingAreaInfo::Impl: - case DrawingAreaInfo::None: - break; - case DrawingAreaInfo::ChunkedUpdate: { - newDrawingArea = ChunkedUpdateDrawingAreaProxy::create(self, _data->_page.get()); - break; - } - case DrawingAreaInfo::LayerBacked: { - newDrawingArea = LayerBackedDrawingAreaProxy::create(self, _data->_page.get()); - break; - } - } - - newDrawingArea->setSize(IntSize([self frame].size), IntSize()); - - _data->_page->drawingArea()->detachCompositingContext(); - _data->_page->setDrawingArea(newDrawingArea.release()); -} - - (void)_enterAcceleratedCompositingMode:(const LayerTreeContext&)layerTreeContext { ASSERT(!_data->_layerHostingView); @@ -1899,6 +1874,9 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I // Create an NSView that will host our layer tree. _data->_layerHostingView.adoptNS([[NSView alloc] initWithFrame:[self bounds]]); [_data->_layerHostingView.get() setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; + + [CATransaction begin]; + [CATransaction setDisableActions:YES]; [self addSubview:_data->_layerHostingView.get()]; // Create a root layer that will back the NSView. @@ -1912,31 +1890,21 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I [_data->_layerHostingView.get() setLayer:rootLayer.get()]; [_data->_layerHostingView.get() setWantsLayer:YES]; + + [CATransaction commit]; } - (void)_exitAcceleratedCompositingMode { ASSERT(_data->_layerHostingView); + [_data->_layerHostingView.get() removeFromSuperview]; [_data->_layerHostingView.get() setLayer:nil]; [_data->_layerHostingView.get() setWantsLayer:NO]; - [_data->_layerHostingView.get() removeFromSuperview]; _data->_layerHostingView = nullptr; } -- (void)_pageDidEnterAcceleratedCompositing -{ - [self _switchToDrawingAreaTypeIfNecessary:DrawingAreaInfo::LayerBacked]; -} - -- (void)_pageDidLeaveAcceleratedCompositing -{ - // FIXME: we may want to avoid flipping back to the non-layer-backed drawing area until the next page load, to avoid thrashing. - [self _switchToDrawingAreaTypeIfNecessary:DrawingAreaInfo::ChunkedUpdate]; -} -#endif // USE(ACCELERATED_COMPOSITING) - - (void)_setAccessibilityWebProcessToken:(NSData *)data { #if !defined(BUILDING_ON_SNOW_LEOPARD) @@ -1978,11 +1946,11 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I _data->_pdfViewController = PDFViewController::create(self); } -- (void)_didFinishLoadingDataForCustomRepresentation:(const CoreIPC::DataReference&)dataReference +- (void)_didFinishLoadingDataForCustomRepresentationWithSuggestedFilename:(const String&)suggestedFilename dataReference:(const CoreIPC::DataReference&)dataReference { ASSERT(_data->_pdfViewController); - _data->_pdfViewController->setPDFDocumentData(_data->_page->mainFrame()->mimeType(), dataReference); + _data->_pdfViewController->setPDFDocumentData(_data->_page->mainFrame()->mimeType(), suggestedFilename, dataReference); } - (double)_customRepresentationZoomFactor @@ -2056,5 +2024,14 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I return _frameSizeUpdatesDisabledCount > 0; } +- (void)performDictionaryLookupAtCurrentMouseLocation +{ + NSPoint thePoint = [NSEvent mouseLocation]; + thePoint = [[self window] convertScreenToBase:thePoint]; + thePoint = [self convertPoint:thePoint fromView:nil]; + + _data->_page->performDictionaryLookupAtLocation(FloatPoint(thePoint.x, thePoint.y)); +} + @end diff --git a/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h b/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h index 9e77e30..4147658 100644 --- a/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h +++ b/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h @@ -52,18 +52,11 @@ namespace WebKit { - (void)_enterAcceleratedCompositingMode:(const WebKit::LayerTreeContext&)layerTreeContext; - (void)_exitAcceleratedCompositingMode; -#if USE(ACCELERATED_COMPOSITING) -- (void)_startAcceleratedCompositing:(CALayer *)rootLayer; -- (void)_stopAcceleratedCompositing; -- (void)_pageDidEnterAcceleratedCompositing; -- (void)_pageDidLeaveAcceleratedCompositing; -#endif - - (void)_setAccessibilityWebProcessToken:(NSData *)data; - (void)_setComplexTextInputEnabled:(BOOL)complexTextInputEnabled pluginComplexTextInputIdentifier:(uint64_t)pluginComplexTextInputIdentifier; - (void)_setPageHasCustomRepresentation:(BOOL)pageHasCustomRepresentation; -- (void)_didFinishLoadingDataForCustomRepresentation:(const CoreIPC::DataReference&)dataReference; +- (void)_didFinishLoadingDataForCustomRepresentationWithSuggestedFilename:(const String&)suggestedFilename dataReference:(const CoreIPC::DataReference&)dataReference; - (double)_customRepresentationZoomFactor; - (void)_setCustomRepresentationZoomFactor:(double)zoomFactor; - (void)_setDragImage:(NSImage *)image at:(NSPoint)clientPoint linkDrag:(BOOL)linkDrag; diff --git a/Source/WebKit2/UIProcess/API/mac/WKViewPrivate.h b/Source/WebKit2/UIProcess/API/mac/WKViewPrivate.h index 5d6125e..cece1c7 100644 --- a/Source/WebKit2/UIProcess/API/mac/WKViewPrivate.h +++ b/Source/WebKit2/UIProcess/API/mac/WKViewPrivate.h @@ -33,4 +33,6 @@ - (void)enableFrameSizeUpdates; - (BOOL)frameSizeUpdatesDisabled; +- (void)performDictionaryLookupAtCurrentMouseLocation; + @end diff --git a/Source/WebKit2/UIProcess/API/qt/qgraphicswkview.cpp b/Source/WebKit2/UIProcess/API/qt/qgraphicswkview.cpp index 748b1bd..0381d73 100644 --- a/Source/WebKit2/UIProcess/API/qt/qgraphicswkview.cpp +++ b/Source/WebKit2/UIProcess/API/qt/qgraphicswkview.cpp @@ -55,7 +55,7 @@ struct QGraphicsWKViewPrivate { QGraphicsWKView* q; QWKPage* page; - QMenu* activeMenu; + QSharedPointer<QMenu> activeMenu; RunLoop::Timer<QGraphicsWKViewPrivate> m_scaleCommitTimer; bool m_isChangingScale; }; @@ -83,7 +83,7 @@ QGraphicsWKView::QGraphicsWKView(QWKContext* context, BackingStoreType backingSt connect(d->page, SIGNAL(urlChanged(const QUrl&)), this, SIGNAL(urlChanged(const QUrl&))); connect(d->page, SIGNAL(cursorChanged(const QCursor&)), this, SLOT(updateCursor(const QCursor&))); connect(d->page, SIGNAL(focusNextPrevChild(bool)), this, SLOT(focusNextPrevChildCallback(bool))); - connect(d->page, SIGNAL(showContextMenu(QMenu*)), this, SLOT(showContextMenu(QMenu*))); + connect(d->page, SIGNAL(showContextMenu(QSharedPointer<QMenu>)), this, SLOT(showContextMenu(QSharedPointer<QMenu>))); } QGraphicsWKView::~QGraphicsWKView() @@ -327,12 +327,22 @@ void QGraphicsWKView::focusOutEvent(QFocusEvent*) page()->d->page->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive); } -void QGraphicsWKView::showContextMenu(QMenu* menu) + +/*! + This slot is called when the engine require a context sensitive menu to be displayed. + + The \a menu passed as a parameter is the menu to be displayed. It is populated with the + actions possible for its current position. The menu is empty if there is no action for the position. +*/ +void QGraphicsWKView::showContextMenu(QSharedPointer<QMenu> menu) { // Remove the active menu in case this function is called twice. if (d->activeMenu) d->activeMenu->hide(); + if (menu->isEmpty()) + return; + d->activeMenu = menu; QWidget* view = 0; @@ -351,14 +361,14 @@ void QGraphicsWKView::showContextMenu(QMenu* menu) menu->setParent(view, menu->windowFlags()); menu->exec(view->mapToGlobal(menu->pos())); if (d->activeMenu == menu) - d->activeMenu = 0; + d->activeMenu.clear(); } void QGraphicsWKView::takeSnapshot(const QSize& size, const QRect& contentsRect) { #if ENABLE(TILED_BACKING_STORE) DrawingAreaProxy* drawingArea = page()->d->page->drawingArea(); - if (drawingArea->info().type != DrawingAreaInfo::Tiled) + if (drawingArea->type() != DrawingAreaTypeTiled) return; TiledDrawingAreaProxy* tiledDrawingArea = static_cast<TiledDrawingAreaProxy*>(drawingArea); tiledDrawingArea->takeSnapshot(size, contentsRect); @@ -419,7 +429,7 @@ void QGraphicsWKViewPrivate::commitScale() #if ENABLE(TILED_BACKING_STORE) DrawingAreaProxy* drawingArea = page->d->page->drawingArea(); float newScale = q->scale(); - if (drawingArea->info().type == DrawingAreaInfo::Tiled) { + if (drawingArea->type() == DrawingAreaTypeTiled) { TiledDrawingAreaProxy* tiledDrawingArea = static_cast<TiledDrawingAreaProxy*>(drawingArea); if (tiledDrawingArea->contentsScale() == newScale) return; diff --git a/Source/WebKit2/UIProcess/API/qt/qgraphicswkview.h b/Source/WebKit2/UIProcess/API/qt/qgraphicswkview.h index caf8e0d..03fc722 100644 --- a/Source/WebKit2/UIProcess/API/qt/qgraphicswkview.h +++ b/Source/WebKit2/UIProcess/API/qt/qgraphicswkview.h @@ -68,6 +68,7 @@ public Q_SLOTS: void forward(); void reload(); void stop(); + void showContextMenu(QSharedPointer<QMenu>); protected: virtual void keyPressEvent(QKeyEvent*); @@ -88,9 +89,6 @@ protected: virtual void focusInEvent(QFocusEvent*); virtual void focusOutEvent(QFocusEvent*); -private Q_SLOTS: - void showContextMenu(QMenu*); - private: Q_PRIVATE_SLOT(d, void onScaleChanged()); diff --git a/Source/WebKit2/UIProcess/API/qt/qwkpage.cpp b/Source/WebKit2/UIProcess/API/qt/qwkpage.cpp index 16e1cdd..05c7b8b 100644 --- a/Source/WebKit2/UIProcess/API/qt/qwkpage.cpp +++ b/Source/WebKit2/UIProcess/API/qt/qwkpage.cpp @@ -34,6 +34,7 @@ #include "FindIndicator.h" #include "LocalizedStrings.h" #include "NativeWebKeyboardEvent.h" +#include "NotImplemented.h" #include "TiledDrawingAreaProxy.h" #include "WebContext.h" #include "WebContextMenuProxyQt.h" @@ -50,6 +51,7 @@ #include <QtDebug> #include <WebCore/Cursor.h> #include <WebCore/FloatRect.h> +#include <WebCore/NotImplemented.h> #include <WebKit2/WKFrame.h> #include <WebKit2/WKPageGroup.h> #include <WebKit2/WKRetainPtr.h> @@ -163,20 +165,17 @@ WebCore::IntSize QWKPagePrivate::viewSize() bool QWKPagePrivate::isViewWindowActive() { - // FIXME: Implement. - return true; + return view && view->isActive(); } bool QWKPagePrivate::isViewFocused() { - // FIXME: Implement. - return true; + return view && view->hasFocus(); } bool QWKPagePrivate::isViewVisible() { - // FIXME: Implement. - return true; + return view && view->isVisible(); } bool QWKPagePrivate::isViewInWindow() @@ -254,10 +253,15 @@ void QWKPagePrivate::didCommitLoadForMainFrame(bool useCustomRepresentation) { } -void QWKPagePrivate::didFinishLoadingDataForCustomRepresentation(const CoreIPC::DataReference&) +void QWKPagePrivate::didFinishLoadingDataForCustomRepresentation(const String& suggestedFilename, const CoreIPC::DataReference&) { } +void QWKPagePrivate::flashBackingStoreUpdates(const Vector<IntRect>&) +{ + notImplemented(); +} + void QWKPagePrivate::paint(QPainter* painter, QRect area) { if (page->isValid() && page->drawingArea()) @@ -325,10 +329,6 @@ void QWKPagePrivate::wheelEvent(QGraphicsSceneWheelEvent* ev) page->handleWheelEvent(wheelEvent); } -void QWKPagePrivate::setEditCommandState(const WTF::String&, bool, int) -{ -} - void QWKPagePrivate::updateAction(QWKPage::WebAction action) { #ifdef QT_NO_ACTION @@ -442,7 +442,8 @@ QWKPage::QWKPage(QWKContext* context) qt_wk_didBecomeUnresponsive, qt_wk_didBecomeResponsive, 0, /* processDidCrash */ - 0 /* didChangeBackForwardList */ + 0, /* didChangeBackForwardList */ + 0 /* shouldGoToBackForwardListItem */ }; WKPageSetPageLoaderClient(pageRef(), &loadClient); diff --git a/Source/WebKit2/UIProcess/API/qt/qwkpage.h b/Source/WebKit2/UIProcess/API/qt/qwkpage.h index cb7933a..48fdd9f 100644 --- a/Source/WebKit2/UIProcess/API/qt/qwkpage.h +++ b/Source/WebKit2/UIProcess/API/qt/qwkpage.h @@ -3,6 +3,7 @@ #include "qwebkitglobal.h" #include <QAction> +#include <QMenu> #include <QObject> #include <QPoint> #include <QRect> @@ -134,7 +135,7 @@ public: Q_SIGNAL void windowCloseRequested(); Q_SIGNAL void zoomableAreaFound(const QRect&); Q_SIGNAL void focusNextPrevChild(bool); - Q_SIGNAL void showContextMenu(QMenu*); + Q_SIGNAL void showContextMenu(QSharedPointer<QMenu>); Q_SIGNAL void engineConnectionChanged(bool connected); protected: diff --git a/Source/WebKit2/UIProcess/API/qt/qwkpage_p.h b/Source/WebKit2/UIProcess/API/qt/qwkpage_p.h index 65f64ff..1a626a1 100644 --- a/Source/WebKit2/UIProcess/API/qt/qwkpage_p.h +++ b/Source/WebKit2/UIProcess/API/qt/qwkpage_p.h @@ -62,8 +62,6 @@ public: #if USE(ACCELERATED_COMPOSITING) virtual void enterAcceleratedCompositingMode(const LayerTreeContext&); virtual void exitAcceleratedCompositingMode(); - void pageDidEnterAcceleratedCompositing() { } - void pageDidLeaveAcceleratedCompositing() { } #endif // USE(ACCELERATED_COMPOSITING) virtual void pageDidRequestScroll(const WebCore::IntSize&); virtual void processDidCrash(); @@ -87,11 +85,13 @@ public: virtual void setFindIndicator(PassRefPtr<WebKit::FindIndicator>, bool fadeOut); virtual void didCommitLoadForMainFrame(bool useCustomRepresentation); - virtual void didFinishLoadingDataForCustomRepresentation(const CoreIPC::DataReference&); + virtual void didFinishLoadingDataForCustomRepresentation(const String& suggestedFilename, const CoreIPC::DataReference&); virtual double customRepresentationZoomFactor() { return 1; } virtual void setCustomRepresentationZoomFactor(double) { } virtual void didChangeScrollbarsForMainFrame() const { } + virtual void flashBackingStoreUpdates(const Vector<WebCore::IntRect>& updateRects); + void paint(QPainter* painter, QRect); void keyPressEvent(QKeyEvent*); @@ -105,7 +105,6 @@ public: void updateAction(QWKPage::WebAction action); void updateNavigationActions(); void updateEditorActions(); - void setEditCommandState(const WTF::String&, bool, int); void _q_webActionTriggered(bool checked); diff --git a/Source/WebKit2/UIProcess/API/qt/qwkpreferences.cpp b/Source/WebKit2/UIProcess/API/qt/qwkpreferences.cpp index 4ba18a3..0f54c00 100644 --- a/Source/WebKit2/UIProcess/API/qt/qwkpreferences.cpp +++ b/Source/WebKit2/UIProcess/API/qt/qwkpreferences.cpp @@ -184,3 +184,36 @@ void QWKPreferences::setAttribute(WebAttribute attr, bool on) ASSERT_NOT_REACHED(); } } + +void QWKPreferences::setFontSize(FontSize type, int size) +{ + switch (type) { + case MinimumFontSize: + WKPreferencesSetMinimumFontSize(d->ref, size); + break; + case DefaultFontSize: + WKPreferencesSetDefaultFontSize(d->ref, size); + break; + case DefaultFixedFontSize: + WKPreferencesSetDefaultFixedFontSize(d->ref, size); + break; + default: + ASSERT_NOT_REACHED(); + } +} + +int QWKPreferences::fontSize(FontSize type) const +{ + switch (type) { + case MinimumFontSize: + return WKPreferencesGetMinimumFontSize(d->ref); + case DefaultFontSize: + return WKPreferencesGetDefaultFontSize(d->ref); + case DefaultFixedFontSize: + return WKPreferencesGetDefaultFixedFontSize(d->ref); + default: + ASSERT_NOT_REACHED(); + return false; + } +} + diff --git a/Source/WebKit2/UIProcess/API/qt/qwkpreferences.h b/Source/WebKit2/UIProcess/API/qt/qwkpreferences.h index d9f7bc0..db22906 100644 --- a/Source/WebKit2/UIProcess/API/qt/qwkpreferences.h +++ b/Source/WebKit2/UIProcess/API/qt/qwkpreferences.h @@ -49,6 +49,12 @@ public: DnsPrefetchEnabled }; + enum FontSize { + MinimumFontSize, + DefaultFontSize, + DefaultFixedFontSize + }; + static QWKPreferences* sharedPreferences(); void setFontFamily(FontFamily which, const QString& family); @@ -57,6 +63,9 @@ public: void setAttribute(WebAttribute attr, bool on); bool testAttribute(WebAttribute attr) const; + void setFontSize(FontSize type, int size); + int fontSize(FontSize type) const; + private: Q_DISABLE_COPY(QWKPreferences) diff --git a/Source/WebKit2/UIProcess/API/qt/tests/html/basic_page.html b/Source/WebKit2/UIProcess/API/qt/tests/html/basic_page.html new file mode 100644 index 0000000..b4eea41 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/html/basic_page.html @@ -0,0 +1 @@ +<h1>Basic page</h1> diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qgraphicswkview/qgraphicswkview.pro b/Source/WebKit2/UIProcess/API/qt/tests/qgraphicswkview/qgraphicswkview.pro new file mode 100644 index 0000000..e99c7f4 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qgraphicswkview/qgraphicswkview.pro @@ -0,0 +1 @@ +include(../tests.pri) diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qgraphicswkview/tst_qgraphicswkview.cpp b/Source/WebKit2/UIProcess/API/qt/tests/qgraphicswkview/tst_qgraphicswkview.cpp new file mode 100644 index 0000000..f26c69d --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qgraphicswkview/tst_qgraphicswkview.cpp @@ -0,0 +1,93 @@ +/* + Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "../util.h" +#include <QGraphicsScene> +#include <QGraphicsView> +#include <QResizeEvent> +#include <QSignalSpy> +#include <QtTest/QtTest> +#include <qgraphicswkview.h> +#include <qwkcontext.h> + +class View; + +class tst_QGraphicsWKView : public QObject { + Q_OBJECT + +private slots: + void init(); + void cleanup(); + + void loadEmptyPage(); + +private: + View* m_view; +}; + +class View : public QGraphicsView { +public: + View(); + QGraphicsWKView* m_webView; + +protected: + void resizeEvent(QResizeEvent*); +}; + +View::View() +{ + QGraphicsScene* const scene = new QGraphicsScene(this); + setScene(scene); + + QWKContext* context = new QWKContext(this); + m_webView = new QGraphicsWKView(context); + scene->addItem(m_webView); +} + +void View::resizeEvent(QResizeEvent* event) +{ + QGraphicsView::resizeEvent(event); + QRectF rect(QPoint(0, 0), event->size()); + m_webView->setGeometry(rect); + scene()->setSceneRect(rect); +} + +void tst_QGraphicsWKView::init() +{ + m_view = new View; +} + +void tst_QGraphicsWKView::cleanup() +{ + delete m_view; + m_view = 0; +} + +void tst_QGraphicsWKView::loadEmptyPage() +{ + m_view->show(); + + m_view->m_webView-> load(QUrl::fromLocalFile(TESTDIR "/html/basic_page.html")); + QVERIFY(waitForSignal(m_view->m_webView, SIGNAL(loadFinished(bool)))); +} + +QTEST_MAIN(tst_QGraphicsWKView) + +#include "tst_qgraphicswkview.moc" + diff --git a/Source/WebKit2/UIProcess/API/qt/tests/tests.pri b/Source/WebKit2/UIProcess/API/qt/tests/tests.pri new file mode 100644 index 0000000..3a2aac1 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/tests.pri @@ -0,0 +1,16 @@ +TEMPLATE = app +CONFIG -= app_bundle + +VPATH += $$_PRO_FILE_PWD_ +# Add the tst_ prefix, In QTDIR_build it's done by qttest_p4.prf +CONFIG(QTDIR_build) { load(qttest_p4) } +ELSE { TARGET = tst_$$TARGET } + +SOURCES += $${TARGET}.cpp +INCLUDEPATH += $$PWD + +include(../../../../../WebKit.pri) +QT += testlib + +QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR +DEFINES += TESTDIR=\\\"$$PWD\\\" diff --git a/Source/WebKit2/UIProcess/API/qt/tests/tests.pro b/Source/WebKit2/UIProcess/API/qt/tests/tests.pro new file mode 100644 index 0000000..eb85021 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/tests.pro @@ -0,0 +1,2 @@ +TEMPLATE = subdirs +SUBDIRS = qgraphicswkview diff --git a/Source/WebKit2/UIProcess/API/qt/tests/util.h b/Source/WebKit2/UIProcess/API/qt/tests/util.h new file mode 100644 index 0000000..08d23a9 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/util.h @@ -0,0 +1,78 @@ +/* + Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ +// Functions and macros that really need to be in QTestLib + +#include <QEventLoop> +#include <QSignalSpy> +#include <QTimer> + +#if !defined(TESTS_SOURCE_DIR) +#define TESTS_SOURCE_DIR "" +#endif + +/** + * Starts an event loop that runs until the given signal is received. + * Optionally the event loop + * can return earlier on a timeout. + * + * \return \p true if the requested signal was received + * \p false on timeout + */ +static bool waitForSignal(QObject* obj, const char* signal, int timeout = 10000) +{ + QEventLoop loop; + QObject::connect(obj, signal, &loop, SLOT(quit())); + QTimer timer; + QSignalSpy timeoutSpy(&timer, SIGNAL(timeout())); + if (timeout > 0) { + QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); + timer.setSingleShot(true); + timer.start(timeout); + } + loop.exec(); + return timeoutSpy.isEmpty(); +} + +// Will try to wait for the condition while allowing event processing +#define QTRY_VERIFY(__expr) \ + do { \ + const int __step = 50; \ + const int __timeout = 5000; \ + if (!(__expr)) { \ + QTest::qWait(0); \ + } \ + for (int __i = 0; __i < __timeout && !(__expr); __i+=__step) { \ + QTest::qWait(__step); \ + } \ + QVERIFY(__expr); \ + } while(0) + +// Will try to wait for the condition while allowing event processing +#define QTRY_COMPARE(__expr, __expected) \ + do { \ + const int __step = 50; \ + const int __timeout = 5000; \ + if ((__expr) != (__expected)) { \ + QTest::qWait(0); \ + } \ + for (int __i = 0; __i < __timeout && ((__expr) != (__expected)); __i+=__step) { \ + QTest::qWait(__step); \ + } \ + QCOMPARE(__expr, __expected); \ + } while(0) |