summaryrefslogtreecommitdiffstats
path: root/Source/WebKit2/UIProcess/API
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit2/UIProcess/API')
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKAPICast.h51
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKContext.cpp24
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKContext.h12
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKContextPrivate.h7
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKCookieManager.cpp10
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKCookieManager.h11
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKIconDatabase.cpp52
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKIconDatabase.h45
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKMediaCacheManager.cpp52
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKMediaCacheManager.h47
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKPage.cpp2
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKPage.h2
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKPreferences.cpp50
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKPreferences.h5
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h16
-rw-r--r--Source/WebKit2/UIProcess/API/C/cg/WKIconDatabaseCG.cpp41
-rw-r--r--Source/WebKit2/UIProcess/API/C/cg/WKIconDatabaseCG.h (renamed from Source/WebKit2/UIProcess/API/C/win/WKBaseWin.h)21
-rw-r--r--Source/WebKit2/UIProcess/API/C/win/WKAPICastWin.h2
-rw-r--r--Source/WebKit2/UIProcess/API/C/win/WKContextPrivateWin.h4
-rw-r--r--Source/WebKit2/UIProcess/API/C/win/WKContextWin.cpp5
-rw-r--r--Source/WebKit2/UIProcess/API/C/win/WKView.cpp22
-rw-r--r--Source/WebKit2/UIProcess/API/C/win/WKView.h24
-rw-r--r--Source/WebKit2/UIProcess/API/mac/PDFViewController.h6
-rw-r--r--Source/WebKit2/UIProcess/API/mac/PDFViewController.mm46
-rw-r--r--Source/WebKit2/UIProcess/API/mac/PageClientImpl.h18
-rw-r--r--Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm98
-rw-r--r--Source/WebKit2/UIProcess/API/mac/WKPrintingView.h3
-rw-r--r--Source/WebKit2/UIProcess/API/mac/WKPrintingView.mm49
-rw-r--r--Source/WebKit2/UIProcess/API/mac/WKView.mm248
-rw-r--r--Source/WebKit2/UIProcess/API/mac/WKViewInternal.h15
-rw-r--r--Source/WebKit2/UIProcess/API/mac/WKViewPrivate.h2
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwkpage.cpp14
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwkpage_p.h7
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qgraphicswkview/tst_qgraphicswkview.cpp14
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qwkpage/qwkpage.pro1
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qwkpage/tst_qwkpage.cpp59
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/tests.pri2
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/tests.pro2
38 files changed, 945 insertions, 144 deletions
diff --git a/Source/WebKit2/UIProcess/API/C/WKAPICast.h b/Source/WebKit2/UIProcess/API/C/WKAPICast.h
index a2983e9..a440c6f 100644
--- a/Source/WebKit2/UIProcess/API/C/WKAPICast.h
+++ b/Source/WebKit2/UIProcess/API/C/WKAPICast.h
@@ -29,12 +29,16 @@
#include "CacheModel.h"
#include "FontSmoothingLevel.h"
+#include "HTTPCookieAcceptPolicy.h"
+#include "ResourceCachesToClear.h"
#include "WKContext.h"
+#include "WKCookieManager.h"
#include "WKCredentialTypes.h"
#include "WKPage.h"
#include "WKPreferencesPrivate.h"
#include "WKProtectionSpaceTypes.h"
#include "WKSharedAPICast.h"
+#include <WebCore/CookieJar.h>
#include <WebCore/Credential.h>
#include <WebCore/FrameLoaderTypes.h>
#include <WebCore/ProtectionSpace.h>
@@ -58,8 +62,10 @@ class WebFramePolicyListenerProxy;
class WebFrameProxy;
class WebGeolocationManagerProxy;
class WebGeolocationPosition;
+class WebIconDatabase;
class WebInspectorProxy;
class WebKeyValueStorageManagerProxy;
+class WebMediaCacheManagerProxy;
class WebNavigationData;
class WebOpenPanelParameters;
class WebOpenPanelResultListenerProxy;
@@ -86,7 +92,9 @@ 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(WKIconDatabaseRef, WebIconDatabase)
WK_ADD_API_MAPPING(WKKeyValueStorageManagerRef, WebKeyValueStorageManagerProxy)
+WK_ADD_API_MAPPING(WKMediaCacheManagerRef, WebMediaCacheManagerProxy)
WK_ADD_API_MAPPING(WKNavigationDataRef, WebNavigationData)
WK_ADD_API_MAPPING(WKOpenPanelParametersRef, WebOpenPanelParameters)
WK_ADD_API_MAPPING(WKOpenPanelResultListenerRef, WebOpenPanelResultListenerProxy)
@@ -235,6 +243,49 @@ inline WebCore::CredentialPersistence toCredentialPersistence(WKCredentialPersis
}
}
+inline ResourceCachesToClear toResourceCachesToClear(WKResourceCachesToClear wkResourceCachesToClear)
+{
+ switch (wkResourceCachesToClear) {
+ case kWKAllResourceCaches:
+ return AllResourceCaches;
+ case kWKInMemoryResourceCachesOnly:
+ return InMemoryResourceCachesOnly;
+ }
+
+ ASSERT_NOT_REACHED();
+ return AllResourceCaches;
+}
+
+inline HTTPCookieAcceptPolicy toHTTPCookieAcceptPolicy(WKHTTPCookieAcceptPolicy policy)
+{
+ switch (policy) {
+ case kWKHTTPCookieAcceptPolicyAlways:
+ return HTTPCookieAcceptPolicyAlways;
+ case kWKHTTPCookieAcceptPolicyNever:
+ return HTTPCookieAcceptPolicyNever;
+ case kWKHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain:
+ return HTTPCookieAcceptPolicyOnlyFromMainDocumentDomain;
+ }
+
+ ASSERT_NOT_REACHED();
+ return HTTPCookieAcceptPolicyAlways;
+}
+
+inline WKHTTPCookieAcceptPolicy toAPI(HTTPCookieAcceptPolicy policy)
+{
+ switch (policy) {
+ case HTTPCookieAcceptPolicyAlways:
+ return kWKHTTPCookieAcceptPolicyAlways;
+ case HTTPCookieAcceptPolicyNever:
+ return kWKHTTPCookieAcceptPolicyNever;
+ case HTTPCookieAcceptPolicyOnlyFromMainDocumentDomain:
+ return kWKHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain;
+ }
+
+ ASSERT_NOT_REACHED();
+ return kWKHTTPCookieAcceptPolicyAlways;
+}
+
} // namespace WebKit
#if defined(WIN32) || defined(_WIN32)
diff --git a/Source/WebKit2/UIProcess/API/C/WKContext.cpp b/Source/WebKit2/UIProcess/API/C/WKContext.cpp
index 6e4e5e0..bf196b7 100644
--- a/Source/WebKit2/UIProcess/API/C/WKContext.cpp
+++ b/Source/WebKit2/UIProcess/API/C/WKContext.cpp
@@ -148,9 +148,9 @@ void WKContextSetDomainRelaxationForbiddenForURLScheme(WKContextRef contextRef,
toImpl(contextRef)->setDomainRelaxationForbiddenForURLScheme(toImpl(urlScheme)->string());
}
-void WKContextClearResourceCaches(WKContextRef contextRef)
+void WKContextClearResourceCaches(WKContextRef contextRef, WKResourceCachesToClear cachesToClear)
{
- toImpl(contextRef)->clearResourceCaches();
+ toImpl(contextRef)->clearResourceCaches(toResourceCachesToClear(cachesToClear));
}
void WKContextClearApplicationCache(WKContextRef contextRef)
@@ -178,11 +178,21 @@ WKGeolocationManagerRef WKContextGetGeolocationManager(WKContextRef contextRef)
return toAPI(toImpl(contextRef)->geolocationManagerProxy());
}
+WKIconDatabaseRef WKContextGetIconDatabase(WKContextRef contextRef)
+{
+ return toAPI(toImpl(contextRef)->iconDatabase());
+}
+
WKKeyValueStorageManagerRef WKContextGetKeyValueStorageManager(WKContextRef contextRef)
{
return toAPI(toImpl(contextRef)->keyValueStorageManagerProxy());
}
+WKMediaCacheManagerRef WKContextGetMediaCacheManager(WKContextRef contextRef)
+{
+ return toAPI(toImpl(contextRef)->mediaCacheManagerProxy());
+}
+
WKPluginSiteDataManagerRef WKContextGetPluginSiteDataManager(WKContextRef contextRef)
{
return toAPI(toImpl(contextRef)->pluginSiteDataManager());
@@ -203,7 +213,17 @@ void WKContextStopMemorySampler(WKContextRef contextRef)
toImpl(contextRef)->stopMemorySampler();
}
+void WKContextSetIconDatabasePath(WKContextRef contextRef, WKStringRef iconDatabasePath)
+{
+ toImpl(contextRef)->setIconDatabasePath(toImpl(iconDatabasePath)->string());
+}
+
void WKContextSetDatabaseDirectory(WKContextRef contextRef, WKStringRef databaseDirectory)
{
toImpl(contextRef)->setDatabaseDirectory(toImpl(databaseDirectory)->string());
}
+
+void WKContextSetLocalStorageDirectory(WKContextRef contextRef, WKStringRef localStorageDirectory)
+{
+ toImpl(contextRef)->setLocalStorageDirectory(toImpl(localStorageDirectory)->string());
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKContext.h b/Source/WebKit2/UIProcess/API/C/WKContext.h
index f8e7cee..606574f 100644
--- a/Source/WebKit2/UIProcess/API/C/WKContext.h
+++ b/Source/WebKit2/UIProcess/API/C/WKContext.h
@@ -39,6 +39,12 @@ enum {
};
typedef uint32_t WKCacheModel;
+enum {
+ kWKAllResourceCaches = 0,
+ kWKInMemoryResourceCachesOnly = 1
+};
+typedef uint32_t WKResourceCachesToClear;
+
// Injected Bundle Client
typedef void (*WKContextDidReceiveMessageFromInjectedBundleCallback)(WKContextRef page, WKStringRef messageName, WKTypeRef messageBody, const void *clientInfo);
typedef void (*WKContextDidReceiveSynchronousMessageFromInjectedBundleCallback)(WKContextRef page, WKStringRef messageName, WKTypeRef messageBody, WKTypeRef* returnData, const void *clientInfo);
@@ -71,6 +77,7 @@ typedef struct WKContextHistoryClient WKContextHistoryClient;
// Download Client
typedef void (*WKContextDownloadDidStartCallback)(WKContextRef context, WKDownloadRef download, const void *clientInfo);
+typedef void (*WKContextDownloadDidReceiveAuthenticationChallengeCallback)(WKContextRef context, WKDownloadRef download, WKAuthenticationChallengeRef authenticationChallenge, const void *clientInfo);
typedef void (*WKContextDownloadDidReceiveResponseCallback)(WKContextRef context, WKDownloadRef download, WKURLResponseRef response, const void *clientInfo);
typedef void (*WKContextDownloadDidReceiveDataCallback)(WKContextRef context, WKDownloadRef download, uint64_t length, const void *clientInfo);
typedef bool (*WKContextDownloadShouldDecodeSourceDataOfMIMETypeCallback)(WKContextRef context, WKDownloadRef download, WKStringRef mimeType, const void *clientInfo);
@@ -85,6 +92,7 @@ struct WKContextDownloadClient {
int version;
const void * clientInfo;
WKContextDownloadDidStartCallback didStart;
+ WKContextDownloadDidReceiveAuthenticationChallengeCallback didReceiveAuthenticationChallenge;
WKContextDownloadDidReceiveResponseCallback didReceiveResponse;
WKContextDownloadDidReceiveDataCallback didReceiveData;
WKContextDownloadShouldDecodeSourceDataOfMIMETypeCallback shouldDecodeSourceDataOfMIMEType;
@@ -117,7 +125,7 @@ WK_EXPORT void WKContextAddVisitedLink(WKContextRef context, WKStringRef visited
WK_EXPORT void WKContextSetCacheModel(WKContextRef context, WKCacheModel cacheModel);
WK_EXPORT WKCacheModel WKContextGetCacheModel(WKContextRef context);
-WK_EXPORT void WKContextClearResourceCaches(WKContextRef context);
+WK_EXPORT void WKContextClearResourceCaches(WKContextRef context, WKResourceCachesToClear cachesToClear);
WK_EXPORT void WKContextClearApplicationCache(WKContextRef context);
WK_EXPORT void WKContextStartMemorySampler(WKContextRef context, WKDoubleRef interval);
@@ -127,7 +135,9 @@ WK_EXPORT WKApplicationCacheManagerRef WKContextGetApplicationCacheManager(WKCon
WK_EXPORT WKCookieManagerRef WKContextGetCookieManager(WKContextRef context);
WK_EXPORT WKDatabaseManagerRef WKContextGetDatabaseManager(WKContextRef context);
WK_EXPORT WKGeolocationManagerRef WKContextGetGeolocationManager(WKContextRef context);
+WK_EXPORT WKIconDatabaseRef WKContextGetIconDatabase(WKContextRef context);
WK_EXPORT WKKeyValueStorageManagerRef WKContextGetKeyValueStorageManager(WKContextRef context);
+WK_EXPORT WKMediaCacheManagerRef WKContextGetMediaCacheManager(WKContextRef context);
WK_EXPORT WKPluginSiteDataManagerRef WKContextGetPluginSiteDataManager(WKContextRef context);
WK_EXPORT WKResourceCacheManagerRef WKContextGetResourceCacheManager(WKContextRef context);
diff --git a/Source/WebKit2/UIProcess/API/C/WKContextPrivate.h b/Source/WebKit2/UIProcess/API/C/WKContextPrivate.h
index bcd24a5..5fd7dd3 100644
--- a/Source/WebKit2/UIProcess/API/C/WKContextPrivate.h
+++ b/Source/WebKit2/UIProcess/API/C/WKContextPrivate.h
@@ -54,9 +54,12 @@ WK_EXPORT void WKContextRegisterURLSchemeAsSecure(WKContextRef context, WKString
WK_EXPORT void WKContextSetDomainRelaxationForbiddenForURLScheme(WKContextRef context, WKStringRef urlScheme);
-// FIXME: This function is only effective if called before the Web process is launched. But
-// we should really change this setting to be on WebPreferences and changeable at runtime.
+WK_EXPORT void WKContextSetIconDatabasePath(WKContextRef context, WKStringRef iconDatabasePath);
+
+// FIXME: These functions are only effective if called before the Web process is launched. But
+// we should really change these settings to be on WebPreferences and changeable at runtime.
WK_EXPORT void WKContextSetDatabaseDirectory(WKContextRef context, WKStringRef databaseDirectory);
+WK_EXPORT void WKContextSetLocalStorageDirectory(WKContextRef context, WKStringRef localStorageDirectory);
#ifdef __cplusplus
}
diff --git a/Source/WebKit2/UIProcess/API/C/WKCookieManager.cpp b/Source/WebKit2/UIProcess/API/C/WKCookieManager.cpp
index 83578f7..50e2732 100644
--- a/Source/WebKit2/UIProcess/API/C/WKCookieManager.cpp
+++ b/Source/WebKit2/UIProcess/API/C/WKCookieManager.cpp
@@ -58,6 +58,16 @@ void WKCookieManagerDeleteAllCookies(WKCookieManagerRef cookieManagerRef)
toImpl(cookieManagerRef)->deleteAllCookies();
}
+void WKCookieManagerSetHTTPCookieAcceptPolicy(WKCookieManagerRef cookieManager, WKHTTPCookieAcceptPolicy policy)
+{
+ toImpl(cookieManager)->setHTTPCookieAcceptPolicy(toHTTPCookieAcceptPolicy(policy));
+}
+
+void WKCookieManagerGetHTTPCookieAcceptPolicy(WKCookieManagerRef cookieManager, void* context, WKCookieManagerGetHTTPCookieAcceptPolicyFunction callback)
+{
+ toImpl(cookieManager)->getHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicyCallback::create(context, callback));
+}
+
void WKCookieManagerStartObservingCookieChanges(WKCookieManagerRef cookieManager)
{
toImpl(cookieManager)->startObservingCookieChanges();
diff --git a/Source/WebKit2/UIProcess/API/C/WKCookieManager.h b/Source/WebKit2/UIProcess/API/C/WKCookieManager.h
index 75d8ef5..4da60f4 100644
--- a/Source/WebKit2/UIProcess/API/C/WKCookieManager.h
+++ b/Source/WebKit2/UIProcess/API/C/WKCookieManager.h
@@ -32,6 +32,13 @@
extern "C" {
#endif
+enum {
+ kWKHTTPCookieAcceptPolicyAlways = 0,
+ kWKHTTPCookieAcceptPolicyNever = 1,
+ kWKHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain = 2
+};
+typedef uint32_t WKHTTPCookieAcceptPolicy;
+
// Cookie Manager Client
typedef void (*WKCookieManagerCookiesDidChangeCallback)(WKCookieManagerRef cookieManager, const void *clientInfo);
@@ -52,6 +59,10 @@ WK_EXPORT void WKCookieManagerGetHostnamesWithCookies(WKCookieManagerRef cookieM
WK_EXPORT void WKCookieManagerDeleteCookiesForHostname(WKCookieManagerRef cookieManager, WKStringRef hostname);
WK_EXPORT void WKCookieManagerDeleteAllCookies(WKCookieManagerRef cookieManager);
+WK_EXPORT void WKCookieManagerSetHTTPCookieAcceptPolicy(WKCookieManagerRef cookieManager, WKHTTPCookieAcceptPolicy policy);
+typedef void (*WKCookieManagerGetHTTPCookieAcceptPolicyFunction)(WKHTTPCookieAcceptPolicy, WKErrorRef, void*);
+WK_EXPORT void WKCookieManagerGetHTTPCookieAcceptPolicy(WKCookieManagerRef cookieManager, void* context, WKCookieManagerGetHTTPCookieAcceptPolicyFunction callback);
+
WK_EXPORT void WKCookieManagerStartObservingCookieChanges(WKCookieManagerRef cookieManager);
WK_EXPORT void WKCookieManagerStopObservingCookieChanges(WKCookieManagerRef cookieManager);
diff --git a/Source/WebKit2/UIProcess/API/C/WKIconDatabase.cpp b/Source/WebKit2/UIProcess/API/C/WKIconDatabase.cpp
new file mode 100644
index 0000000..c8e87a0
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKIconDatabase.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 "WKIconDatabase.h"
+
+#include "WKAPICast.h"
+#include "WebIconDatabase.h"
+
+using namespace WebKit;
+
+WKTypeID WKIconDatabaseGetTypeID()
+{
+ return toAPI(WebIconDatabase::APIType);
+}
+
+void WKIconDatabaseRetainIconForURL(WKIconDatabaseRef iconDatabaseRef, WKURLRef pageURLRef)
+{
+ toImpl(iconDatabaseRef)->retainIconForPageURL(toWTFString(pageURLRef));
+}
+
+void WKIconDatabaseReleaseIconForURL(WKIconDatabaseRef iconDatabaseRef, WKURLRef pageURLRef)
+{
+ toImpl(iconDatabaseRef)->releaseIconForPageURL(toWTFString(pageURLRef));
+}
+
+void WKIconDatabaseEnableDatabaseCleanup(WKIconDatabaseRef iconDatabaseRef)
+{
+ toImpl(iconDatabaseRef)->enableDatabaseCleanup();
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKIconDatabase.h b/Source/WebKit2/UIProcess/API/C/WKIconDatabase.h
new file mode 100644
index 0000000..1ea1860
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKIconDatabase.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WKIconDatabase_h
+#define WKIconDatabase_h
+
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKIconDatabaseGetTypeID();
+
+WK_EXPORT void WKIconDatabaseRetainIconForURL(WKIconDatabaseRef iconDatabase, WKURLRef pageURL);
+WK_EXPORT void WKIconDatabaseReleaseIconForURL(WKIconDatabaseRef iconDatabase, WKURLRef pageURL);
+WK_EXPORT void WKIconDatabaseEnableDatabaseCleanup(WKIconDatabaseRef iconDatabase);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKIconDatabase_h */
diff --git a/Source/WebKit2/UIProcess/API/C/WKMediaCacheManager.cpp b/Source/WebKit2/UIProcess/API/C/WKMediaCacheManager.cpp
new file mode 100644
index 0000000..6e2ecce
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKMediaCacheManager.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 "WKMediaCacheManager.h"
+
+#include "WKAPICast.h"
+#include "WebMediaCacheManagerProxy.h"
+
+using namespace WebKit;
+
+WKTypeID WKMediaCacheManagerGetTypeID()
+{
+ return toAPI(WebMediaCacheManagerProxy::APIType);
+}
+
+void WKMediaCacheManagerGetHostnamesWithMediaCache(WKMediaCacheManagerRef mediaCacheManagerRef, void* context, WKMediaCacheManagerGetHostnamesWithMediaCacheFunction callback)
+{
+ toImpl(mediaCacheManagerRef)->getHostnamesWithMediaCache(ArrayCallback::create(context, callback));
+}
+
+void WKMediaCacheManagerClearCacheForHostname(WKMediaCacheManagerRef mediaCacheManagerRef, WKStringRef hostname)
+{
+ toImpl(mediaCacheManagerRef)->clearCacheForHostname(toWTFString(hostname));
+}
+
+void WKMediaCacheManagerClearCacheForAllHostnames(WKMediaCacheManagerRef mediaCacheManagerRef)
+{
+ toImpl(mediaCacheManagerRef)->clearCacheForAllHostnames();
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKMediaCacheManager.h b/Source/WebKit2/UIProcess/API/C/WKMediaCacheManager.h
new file mode 100644
index 0000000..eee1b92
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKMediaCacheManager.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 WKMediaCacheManager_h
+#define WKMediaCacheManager_h
+
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKMediaCacheManagerGetTypeID();
+
+typedef void (*WKMediaCacheManagerGetHostnamesWithMediaCacheFunction)(WKArrayRef, WKErrorRef, void*);
+WK_EXPORT void WKMediaCacheManagerGetHostnamesWithMediaCache(WKMediaCacheManagerRef mediaCacheManager, void* context, WKMediaCacheManagerGetHostnamesWithMediaCacheFunction function);
+
+WK_EXPORT void WKMediaCacheManagerClearCacheForHostname(WKMediaCacheManagerRef mediaCacheManager, WKStringRef hostname);
+WK_EXPORT void WKMediaCacheManagerClearCacheForAllHostnames(WKMediaCacheManagerRef mediaCacheManager);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // WKMediaCacheManager_h
diff --git a/Source/WebKit2/UIProcess/API/C/WKPage.cpp b/Source/WebKit2/UIProcess/API/C/WKPage.cpp
index c4e8eae..7061e39 100644
--- a/Source/WebKit2/UIProcess/API/C/WKPage.cpp
+++ b/Source/WebKit2/UIProcess/API/C/WKPage.cpp
@@ -56,7 +56,7 @@ WKPageGroupRef WKPageGetPageGroup(WKPageRef pageRef)
void WKPageLoadURL(WKPageRef pageRef, WKURLRef URLRef)
{
- toImpl(pageRef)->loadURL(toImpl(URLRef)->string());
+ toImpl(pageRef)->loadURL(toWTFString(URLRef));
}
void WKPageLoadURLRequest(WKPageRef pageRef, WKURLRequestRef urlRequestRef)
diff --git a/Source/WebKit2/UIProcess/API/C/WKPage.h b/Source/WebKit2/UIProcess/API/C/WKPage.h
index 655e999..03f49f7 100644
--- a/Source/WebKit2/UIProcess/API/C/WKPage.h
+++ b/Source/WebKit2/UIProcess/API/C/WKPage.h
@@ -173,6 +173,7 @@ typedef void (*WKPageDrawHeaderCallback)(WKPageRef page, WKFrameRef frame, WKRec
typedef void (*WKPageDrawFooterCallback)(WKPageRef page, WKFrameRef frame, WKRect rect, const void* clientInfo);
typedef void (*WKPagePrintFrameCallback)(WKPageRef page, WKFrameRef frame, const void* clientInfo);
typedef void (*WKPageDidCompleteRubberBandForMainFrameCallback)(WKPageRef page, WKSize initialOverhang, const void* clientInfo);
+typedef void (*WKPageSaveDataToFileInDownloadsFolderCallback)(WKPageRef page, WKStringRef suggestedFilename, WKStringRef mimeType, WKURLRef originatingURL, WKDataRef data, const void* clientInfo);
struct WKPageUIClient {
int version;
@@ -210,6 +211,7 @@ struct WKPageUIClient {
WKPagePrintFrameCallback printFrame;
WKPageCallback runModal;
WKPageDidCompleteRubberBandForMainFrameCallback didCompleteRubberBandForMainFrame;
+ WKPageSaveDataToFileInDownloadsFolderCallback saveDataToFileInDownloadsFolder;
};
typedef struct WKPageUIClient WKPageUIClient;
diff --git a/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp b/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp
index 7ba9ba0..0122531 100644
--- a/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp
+++ b/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp
@@ -311,6 +311,16 @@ bool WKPreferencesGetAcceleratedDrawingEnabled(WKPreferencesRef preferencesRef)
return toImpl(preferencesRef)->acceleratedDrawingEnabled();
}
+void WKPreferencesSetCanvasUsesAcceleratedDrawing(WKPreferencesRef preferencesRef, bool flag)
+{
+ toImpl(preferencesRef)->setCanvasUsesAcceleratedDrawing(flag);
+}
+
+bool WKPreferencesGetCanvasUsesAcceleratedDrawing(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->canvasUsesAcceleratedDrawing();
+}
+
void WKPreferencesSetAcceleratedCompositingEnabled(WKPreferencesRef preferencesRef, bool flag)
{
toImpl(preferencesRef)->setAcceleratedCompositingEnabled(flag);
@@ -480,3 +490,43 @@ bool WKPreferencesGetJavaScriptCanAccessClipboard(WKPreferencesRef preferencesRe
{
return toImpl(preferencesRef)->javaScriptCanAccessClipboard();
}
+
+void WKPreferencesSetFullScreenEnabled(WKPreferencesRef preferencesRef, bool enabled)
+{
+ toImpl(preferencesRef)->setFullScreenEnabled(enabled);
+}
+
+bool WKPreferencesGetFullScreenEnabled(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->fullScreenEnabled();
+}
+
+void WKPreferencesSetWebSecurityEnabled(WKPreferencesRef preferencesRef, bool enabled)
+{
+ toImpl(preferencesRef)->setWebSecurityEnabled(enabled);
+}
+
+bool WKPreferencesGetWebSecurityEnabled(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->webSecurityEnabled();
+}
+
+void WKPreferencesSetUniversalAccessFromFileURLsAllowed(WKPreferencesRef preferencesRef, bool allowed)
+{
+ toImpl(preferencesRef)->setAllowUniversalAccessFromFileURLs(allowed);
+}
+
+bool WKPreferencesGetUniversalAccessFromFileURLsAllowed(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->allowUniversalAccessFromFileURLs();
+}
+
+void WKPreferencesSetFileAccessFromFileURLsAllowed(WKPreferencesRef preferencesRef, bool allowed)
+{
+ toImpl(preferencesRef)->setAllowFileAccessFromFileURLs(allowed);
+}
+
+bool WKPreferencesGetFileAccessFromFileURLsAllowed(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->allowFileAccessFromFileURLs();
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKPreferences.h b/Source/WebKit2/UIProcess/API/C/WKPreferences.h
index 5c6c478..f2486bf 100644
--- a/Source/WebKit2/UIProcess/API/C/WKPreferences.h
+++ b/Source/WebKit2/UIProcess/API/C/WKPreferences.h
@@ -150,6 +150,11 @@ WK_EXPORT bool WKPreferencesGetShouldPrintBackgrounds(WKPreferencesRef preferenc
WK_EXPORT void WKPreferencesSetJavaScriptCanAccessClipboard(WKPreferencesRef preferencesRef, bool enabled);
WK_EXPORT bool WKPreferencesGetJavaScriptCanAccessClipboard(WKPreferencesRef preferencesRef);
+// Defaults to false
+WK_EXPORT void WKPreferencesSetFullScreenEnabled(WKPreferencesRef preferencesRef, bool enabled);
+WK_EXPORT bool WKPreferencesGetFullScreenEnabled(WKPreferencesRef preferencesRef);
+
+
#ifdef __cplusplus
}
#endif
diff --git a/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h b/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h
index 426119b..ddf1b9a 100644
--- a/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h
+++ b/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h
@@ -52,6 +52,10 @@ WK_EXPORT void WKPreferencesSetAcceleratedDrawingEnabled(WKPreferencesRef, bool)
WK_EXPORT bool WKPreferencesGetAcceleratedDrawingEnabled(WKPreferencesRef);
// Defaults to true.
+WK_EXPORT void WKPreferencesSetCanvasUsesAcceleratedDrawing(WKPreferencesRef, bool);
+WK_EXPORT bool WKPreferencesGetCanvasUsesAcceleratedDrawing(WKPreferencesRef);
+
+// Defaults to true.
WK_EXPORT void WKPreferencesSetAcceleratedCompositingEnabled(WKPreferencesRef, bool);
WK_EXPORT bool WKPreferencesGetAcceleratedCompositingEnabled(WKPreferencesRef);
@@ -99,6 +103,18 @@ WK_EXPORT bool WKPreferencesGetPaginateDuringLayoutEnabled(WKPreferencesRef pref
WK_EXPORT void WKPreferencesSetDOMPasteAllowed(WKPreferencesRef preferences, bool enabled);
WK_EXPORT bool WKPreferencesGetDOMPasteAllowed(WKPreferencesRef preferences);
+// Defaults to true.
+WK_EXPORT void WKPreferencesSetWebSecurityEnabled(WKPreferencesRef preferences, bool enabled);
+WK_EXPORT bool WKPreferencesGetWebSecurityEnabled(WKPreferencesRef preferences);
+
+// Defaults to false.
+WK_EXPORT void WKPreferencesSetUniversalAccessFromFileURLsAllowed(WKPreferencesRef preferences, bool allowed);
+WK_EXPORT bool WKPreferencesGetUniversalAccessFromFileURLsAllowed(WKPreferencesRef preferences);
+
+// Defaults to false.
+WK_EXPORT void WKPreferencesSetFileAccessFromFileURLsAllowed(WKPreferencesRef preferences, bool allowed);
+WK_EXPORT bool WKPreferencesGetFileAccessFromFileURLsAllowed(WKPreferencesRef preferences);
+
#ifdef __cplusplus
}
#endif
diff --git a/Source/WebKit2/UIProcess/API/C/cg/WKIconDatabaseCG.cpp b/Source/WebKit2/UIProcess/API/C/cg/WKIconDatabaseCG.cpp
new file mode 100644
index 0000000..5e50dd8
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/cg/WKIconDatabaseCG.cpp
@@ -0,0 +1,41 @@
+/*
+ * 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 MERCHANTAwBILITY 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 "WKIconDatabaseCG.h"
+
+#include "WebIconDatabase.h"
+#include "WKAPICast.h"
+#include "WKSharedAPICast.h"
+#include <WebCore/Image.h>
+
+using namespace WebKit;
+using namespace WebCore;
+
+CGImageRef WKIconDatabaseGetCGImageForURL(WKIconDatabaseRef iconDatabaseRef, WKURLRef urlRef)
+{
+ Image* image = toImpl(iconDatabaseRef)->imageForPageURL(toWTFString(urlRef));
+ return image ? image->getCGImageRef() : 0;
+}
diff --git a/Source/WebKit2/UIProcess/API/C/win/WKBaseWin.h b/Source/WebKit2/UIProcess/API/C/cg/WKIconDatabaseCG.h
index e2ee9a7..48cf5bf 100644
--- a/Source/WebKit2/UIProcess/API/C/win/WKBaseWin.h
+++ b/Source/WebKit2/UIProcess/API/C/cg/WKIconDatabaseCG.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * 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
@@ -23,13 +23,20 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef WKBaseWin_h
-#define WKBaseWin_h
+#ifndef WKIconDatabaseCG_h
+#define WKIconDatabaseCG_h
-#ifndef WKBase_h
-#error "Please #include \"WKBase.h\" instead of this file directly."
+#include <CoreGraphics/CGImage.h>
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
#endif
-typedef const struct OpaqueWKView* WKViewRef;
+WK_EXPORT CGImageRef WKIconDatabaseGetCGImageForURL(WKIconDatabaseRef iconDatabase, WKURLRef urlString);
+
+#ifdef __cplusplus
+}
+#endif
-#endif /* WKBaseWin_h */
+#endif /* WKIconDatabaseCG_h */
diff --git a/Source/WebKit2/UIProcess/API/C/win/WKAPICastWin.h b/Source/WebKit2/UIProcess/API/C/win/WKAPICastWin.h
index 6acb1a6..09cf06f 100644
--- a/Source/WebKit2/UIProcess/API/C/win/WKAPICastWin.h
+++ b/Source/WebKit2/UIProcess/API/C/win/WKAPICastWin.h
@@ -33,8 +33,10 @@
namespace WebKit {
class WebView;
+class WebEditCommandProxy;
WK_ADD_API_MAPPING(WKViewRef, WebView)
+WK_ADD_API_MAPPING(WKEditCommandRef, WebEditCommandProxy)
}
diff --git a/Source/WebKit2/UIProcess/API/C/win/WKContextPrivateWin.h b/Source/WebKit2/UIProcess/API/C/win/WKContextPrivateWin.h
index c8a9c34..0d49ac9 100644
--- a/Source/WebKit2/UIProcess/API/C/win/WKContextPrivateWin.h
+++ b/Source/WebKit2/UIProcess/API/C/win/WKContextPrivateWin.h
@@ -28,6 +28,7 @@
#include <WebKit2/WKBase.h>
#include <WebKit2/WKContext.h>
+#include <WebKit2/WKCookieManager.h>
#ifndef __cplusplus
#include <stdbool.h>
@@ -40,6 +41,9 @@ extern "C" {
// Defaults to true.
WK_EXPORT void WKContextSetShouldPaintNativeControls(WKContextRef, bool);
+// Defaults to WKHTTPCookieAcceptPolicyAlways.
+WK_EXPORT void WKContextSetInitialHTTPCookieAcceptPolicy(WKContextRef, WKHTTPCookieAcceptPolicy);
+
#ifdef __cplusplus
}
#endif
diff --git a/Source/WebKit2/UIProcess/API/C/win/WKContextWin.cpp b/Source/WebKit2/UIProcess/API/C/win/WKContextWin.cpp
index 110951f..4971540 100644
--- a/Source/WebKit2/UIProcess/API/C/win/WKContextWin.cpp
+++ b/Source/WebKit2/UIProcess/API/C/win/WKContextWin.cpp
@@ -36,3 +36,8 @@ void WKContextSetShouldPaintNativeControls(WKContextRef contextRef, bool b)
{
toImpl(contextRef)->setShouldPaintNativeControls(b);
}
+
+void WKContextSetInitialHTTPCookieAcceptPolicy(WKContextRef contextRef, WKHTTPCookieAcceptPolicy policy)
+{
+ toImpl(contextRef)->setInitialHTTPCookieAcceptPolicy(toHTTPCookieAcceptPolicy(policy));
+}
diff --git a/Source/WebKit2/UIProcess/API/C/win/WKView.cpp b/Source/WebKit2/UIProcess/API/C/win/WKView.cpp
index 62603fe..05ae0d7 100644
--- a/Source/WebKit2/UIProcess/API/C/win/WKView.cpp
+++ b/Source/WebKit2/UIProcess/API/C/win/WKView.cpp
@@ -72,6 +72,11 @@ void WKViewSetInitialFocus(WKViewRef viewRef, bool forward)
toImpl(viewRef)->setInitialFocus(forward);
}
+void WKViewSetScrollOffsetOnNextResize(WKViewRef viewRef, WKSize scrollOffset)
+{
+ toImpl(viewRef)->setScrollOffsetOnNextResize(toIntSize(scrollOffset));
+}
+
void WKViewSetFindIndicatorCallback(WKViewRef viewRef, WKViewFindIndicatorCallback callback, void* context)
{
toImpl(viewRef)->setFindIndicatorCallback(callback, context);
@@ -81,3 +86,20 @@ WKViewFindIndicatorCallback WKViewGetFindIndicatorCallback(WKViewRef viewRef, vo
{
return toImpl(viewRef)->getFindIndicatorCallback(context);
}
+
+void WKViewSetViewUndoClient(WKViewRef viewRef, const WKViewUndoClient* wkClient)
+{
+ if (wkClient && wkClient->version)
+ return;
+ toImpl(viewRef)->initializeUndoClient(wkClient);
+}
+
+void WKViewReapplyEditCommand(WKViewRef viewRef, WKEditCommandRef command)
+{
+ toImpl(viewRef)->reapplyEditCommand(toImpl(command));
+}
+
+void WKViewUnapplyEditCommand(WKViewRef viewRef, WKEditCommandRef command)
+{
+ toImpl(viewRef)->unapplyEditCommand(toImpl(command));
+}
diff --git a/Source/WebKit2/UIProcess/API/C/win/WKView.h b/Source/WebKit2/UIProcess/API/C/win/WKView.h
index 213897e..c8ac44c 100644
--- a/Source/WebKit2/UIProcess/API/C/win/WKView.h
+++ b/Source/WebKit2/UIProcess/API/C/win/WKView.h
@@ -27,12 +27,31 @@
#define WKView_h
#include <WebKit2/WKBase.h>
+#include <WebKit2/WKGeometry.h>
#include <windows.h>
#ifdef __cplusplus
extern "C" {
#endif
+// Undo Client.
+enum {
+ kWKViewUndo = 0,
+ kWKViewRedo = 1
+};
+typedef uint32_t WKViewUndoType;
+
+typedef void (*WKViewRegisterEditCommandCallback)(WKViewRef, WKEditCommandRef, WKViewUndoType undoOrRedo, const void *clientInfo);
+typedef void (*WKViewClearAllEditCommandsCallback)(WKViewRef, const void *clientInfo);
+
+struct WKViewUndoClient {
+ int version;
+ const void * clientInfo;
+ WKViewRegisterEditCommandCallback registerEditCommand;
+ WKViewClearAllEditCommandsCallback clearAllEditCommands;
+};
+typedef struct WKViewUndoClient WKViewUndoClient;
+
WK_EXPORT WKTypeID WKViewGetTypeID();
WK_EXPORT WKViewRef WKViewCreate(RECT rect, WKContextRef context, WKPageGroupRef pageGroup, HWND parentWindow);
@@ -41,10 +60,15 @@ WK_EXPORT HWND WKViewGetWindow(WKViewRef view);
WK_EXPORT WKPageRef WKViewGetPage(WKViewRef view);
+WK_EXPORT void WKViewSetViewUndoClient(WKViewRef view, const WKViewUndoClient* client);
+WK_EXPORT void WKViewReapplyEditCommand(WKViewRef view, WKEditCommandRef command);
+WK_EXPORT void WKViewUnapplyEditCommand(WKViewRef view, WKEditCommandRef command);
+
WK_EXPORT void WKViewSetParentWindow(WKViewRef view, HWND parentWindow);
WK_EXPORT void WKViewWindowAncestryDidChange(WKViewRef view);
WK_EXPORT void WKViewSetIsInWindow(WKViewRef view, bool isInWindow);
WK_EXPORT void WKViewSetInitialFocus(WKViewRef view, bool forward);
+WK_EXPORT void WKViewSetScrollOffsetOnNextResize(WKViewRef view, WKSize scrollOffset);
typedef void (*WKViewFindIndicatorCallback)(WKViewRef, HBITMAP selectionBitmap, RECT selectionRectInWindowCoordinates, bool fadeout, void*);
WK_EXPORT void WKViewSetFindIndicatorCallback(WKViewRef view, WKViewFindIndicatorCallback callback, void* context);
diff --git a/Source/WebKit2/UIProcess/API/mac/PDFViewController.h b/Source/WebKit2/UIProcess/API/mac/PDFViewController.h
index d22d8b5..dc30f56 100644
--- a/Source/WebKit2/UIProcess/API/mac/PDFViewController.h
+++ b/Source/WebKit2/UIProcess/API/mac/PDFViewController.h
@@ -41,6 +41,8 @@ namespace CoreIPC {
namespace WebKit {
+class WebPageProxy;
+
class PDFViewController {
WTF_MAKE_NONCOPYABLE(PDFViewController);
@@ -49,6 +51,9 @@ public:
~PDFViewController();
WKView* wkView() const { return m_wkView; }
+ WebPageProxy* page() const;
+ NSView* pdfView() const;
+
void setPDFDocumentData(const String& mimeType, const String& suggestedFilename, const CoreIPC::DataReference&);
double zoomFactor() const;
@@ -58,6 +63,7 @@ public:
NSPrintOperation *makePrintOperation(NSPrintInfo *);
void openPDFInFinder();
+ void savePDFToDownloadsFolder();
private:
explicit PDFViewController(WKView *wkView);
diff --git a/Source/WebKit2/UIProcess/API/mac/PDFViewController.mm b/Source/WebKit2/UIProcess/API/mac/PDFViewController.mm
index 5d9b860..5c64000 100644
--- a/Source/WebKit2/UIProcess/API/mac/PDFViewController.mm
+++ b/Source/WebKit2/UIProcess/API/mac/PDFViewController.mm
@@ -29,6 +29,7 @@
#import "DataReference.h"
#import "WKAPICast.h"
#import "WKView.h"
+#import "WebData.h"
#import "WebPageGroup.h"
#import "WebPageProxy.h"
#import "WebPreferences.h"
@@ -116,7 +117,7 @@ extern "C" NSString *_NSPathForSystemFramework(NSString *framework);
if (!_pdfViewController)
return;
- WebPreferences *preferences = toImpl([_pdfViewController->wkView() pageRef])->pageGroup()->preferences();
+ WebPreferences *preferences = _pdfViewController->page()->pageGroup()->preferences();
CGFloat scaleFactor = preferences->pdfScaleFactor();
if (!scaleFactor)
@@ -135,7 +136,7 @@ extern "C" NSString *_NSPathForSystemFramework(NSString *framework);
if (!_pdfViewController)
return;
- WebPreferences* preferences = toImpl([_pdfViewController->wkView() pageRef])->pageGroup()->preferences();
+ WebPreferences* preferences = _pdfViewController->page()->pageGroup()->preferences();
CGFloat scaleFactor = [_pdfView autoScales] ? 0 : [_pdfView scaleFactor];
preferences->setPDFScaleFactor(scaleFactor);
@@ -187,6 +188,11 @@ extern "C" NSString *_NSPathForSystemFramework(NSString *framework);
_pdfViewController->openPDFInFinder();
}
+- (void)PDFViewSavePDFToDownloadFolder:(PDFView *)sender
+{
+ _pdfViewController->savePDFToDownloadsFolder();
+}
+
@end
namespace WebKit {
@@ -212,6 +218,16 @@ PDFViewController::~PDFViewController()
m_wkPDFView = nullptr;
}
+WebPageProxy* PDFViewController::page() const
+{
+ return toImpl([m_wkView pageRef]);
+}
+
+NSView* PDFViewController::pdfView() const
+{
+ return m_wkPDFView.get();
+}
+
static RetainPtr<CFDataRef> convertPostScriptDataSourceToPDF(const CoreIPC::DataReference& dataReference)
{
// Convert PostScript to PDF using Quartz 2D API
@@ -330,6 +346,32 @@ void PDFViewController::openPDFInFinder()
[[NSWorkspace sharedWorkspace] openFile:path];
}
+static void releaseCFData(unsigned char*, const void* data)
+{
+ ASSERT(CFGetTypeID(data) == CFDataGetTypeID());
+
+ // Balanced by CFRetain in savePDFToDownloadsFolder.
+ CFRelease(data);
+}
+
+void PDFViewController::savePDFToDownloadsFolder()
+{
+ // We don't want to write the file until we have a document to write. (see 5267607).
+ if (![m_pdfView document]) {
+ NSBeep();
+ return;
+ }
+
+ ASSERT(m_pdfData);
+
+ // Balanced by CFRelease in releaseCFData.
+ CFRetain(m_pdfData.get());
+
+ RefPtr<WebData> data = WebData::createWithoutCopying(CFDataGetBytePtr(m_pdfData.get()), CFDataGetLength(m_pdfData.get()), releaseCFData, m_pdfData.get());
+
+ page()->saveDataToFileInDownloadsFolder(m_suggestedFilename.get(), page()->mainFrame()->mimeType(), page()->mainFrame()->url(), data.get());
+}
+
static NSString *temporaryPDFDirectoryPath()
{
static NSString *temporaryPDFDirectoryPath;
diff --git a/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h
index e01cf66..e217fc5 100644
--- a/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h
+++ b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h
@@ -26,6 +26,7 @@
#ifndef PageClientImpl_h
#define PageClientImpl_h
+#include "CorrectionPanel.h"
#include "PageClient.h"
#include <wtf/RetainPtr.h>
@@ -62,6 +63,7 @@ private:
virtual void processDidCrash();
virtual void pageClosed();
virtual void didRelaunchProcess();
+ virtual void setFocus(bool focused);
virtual void takeFocus(bool direction);
virtual void toolTipChanged(const String& oldToolTip, const String& newToolTip);
virtual void setCursor(const WebCore::Cursor&);
@@ -70,11 +72,12 @@ private:
virtual void registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo);
virtual void clearAllEditCommands();
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);
+ virtual void setDragImage(const WebCore::IntPoint& clientPosition, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag);
virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&);
virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&);
-
+ virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&);
+
virtual void doneWithKeyEvent(const NativeWebKeyboardEvent&, bool wasEventHandled);
virtual PassRefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy*);
@@ -87,7 +90,6 @@ private:
virtual void accessibilityWebProcessTokenReceived(const CoreIPC::DataReference&);
virtual void setComplexTextInputEnabled(uint64_t pluginComplexTextInputIdentifier, bool complexTextInputEnabled);
- virtual void setAutodisplay(bool);
virtual CGContextRef containingWindowGraphicsContext();
@@ -103,8 +105,18 @@ private:
virtual void didPerformDictionaryLookup(const String&, double scaleFactor, const DictionaryPopupInfo&);
+ virtual void showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelType, const WebCore::FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings);
+ virtual void dismissCorrectionPanel(WebCore::ReasonForDismissingCorrectionPanel);
+ virtual String dismissCorrectionPanelSoon(WebCore::ReasonForDismissingCorrectionPanel);
+ virtual void recordAutocorrectionResponse(WebCore::EditorClient::AutocorrectionResponseType, const String& replacedString, const String& replacementString);
+
+ virtual float userSpaceScaleFactor() const;
+
WKView* m_wkView;
RetainPtr<WebEditorUndoTargetObjC> m_undoTarget;
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+ CorrectionPanel m_correctionPanel;
+#endif
};
} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm
index 88bb9a4..7a0d62d 100644
--- a/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm
+++ b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm
@@ -45,6 +45,7 @@
#import <wtf/PassOwnPtr.h>
#import <wtf/text/CString.h>
#import <wtf/text/WTFString.h>
+#import <WebKitSystemInterface.h>
@interface NSApplication (WebNSApplicationDetails)
- (NSCursor *)_cursorRectCursor;
@@ -195,6 +196,15 @@ void PageClientImpl::didRelaunchProcess()
[m_wkView _didRelaunchProcess];
}
+void PageClientImpl::setFocus(bool focused)
+{
+ if (focused)
+ [[m_wkView window] makeFirstResponder:m_wkView];
+ else
+ // takeFocus in this context means take focus away from the WKView.
+ takeFocus(true);
+}
+
void PageClientImpl::takeFocus(bool direction)
{
[m_wkView _takeFocus:direction];
@@ -287,10 +297,11 @@ void PageClientImpl::interceptKeyEvent(const NativeWebKeyboardEvent& event, Vect
[m_wkView _getTextInputState:selectionStart selectionEnd:selectionEnd underlines:underlines];
}
-void PageClientImpl::setDragImage(const IntPoint& clientPosition, const IntSize& imageSize, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag)
+void PageClientImpl::setDragImage(const IntPoint& clientPosition, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag)
{
- OwnPtr<GraphicsContext> graphicsContext = dragImage->createGraphicsContext();
- RetainPtr<NSImage> dragNSImage(AdoptNS, [[NSImage alloc] initWithCGImage:CGBitmapContextCreateImage(graphicsContext->platformContext()) size:imageSize]);
+ RetainPtr<CGImageRef> dragCGImage = dragImage->makeCGImage();
+ RetainPtr<NSImage> dragNSImage(AdoptNS, [[NSImage alloc] initWithCGImage:dragCGImage.get() size:dragImage->size()]);
+
[m_wkView _setDragImage:dragNSImage.get() at:clientPosition linkDrag:isLinkDrag];
}
@@ -303,6 +314,14 @@ FloatRect PageClientImpl::convertToUserSpace(const FloatRect& rect)
{
return [m_wkView _convertToUserSpace:rect];
}
+
+IntRect PageClientImpl::windowToScreen(const IntRect& rect)
+{
+ NSRect tempRect = rect;
+ tempRect = [m_wkView convertRect:tempRect toView:nil];
+ tempRect.origin = [[m_wkView window] convertBaseToScreen:tempRect.origin];
+ return enclosingIntRect(tempRect);
+}
void PageClientImpl::doneWithKeyEvent(const NativeWebKeyboardEvent& event, bool wasEventHandled)
{
@@ -311,10 +330,8 @@ void PageClientImpl::doneWithKeyEvent(const NativeWebKeyboardEvent& event, bool
return;
if (wasEventHandled)
[NSCursor setHiddenUntilMouseMoves:YES];
- else {
- [m_wkView _setEventBeingResent:nativeEvent];
- [[NSApplication sharedApplication] sendEvent:nativeEvent];
- }
+ else
+ [m_wkView _resendKeyDownEvent:nativeEvent];
}
PassRefPtr<WebPopupMenuProxy> PageClientImpl::createPopupMenuProxy(WebPageProxy* page)
@@ -355,18 +372,6 @@ void PageClientImpl::setComplexTextInputEnabled(uint64_t pluginComplexTextInputI
[m_wkView _setComplexTextInputEnabled:complexTextInputEnabled pluginComplexTextInputIdentifier:pluginComplexTextInputIdentifier];
}
-void PageClientImpl::setAutodisplay(bool newState)
-{
- if (!newState && [[m_wkView window] isAutodisplay])
- [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()
{
NSWindow *window = [m_wkView window];
@@ -419,9 +424,64 @@ void PageClientImpl::didPerformDictionaryLookup(const String& text, double scale
NSPoint textBaselineOrigin = dictionaryPopupInfo.origin;
textBaselineOrigin.y += [font ascender];
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+ // Convert to screen coordinates.
+ textBaselineOrigin = [m_wkView convertPoint:textBaselineOrigin toView:nil];
+ textBaselineOrigin = [m_wkView.window convertRectToScreen:NSMakeRect(textBaselineOrigin.x, textBaselineOrigin.y, 0, 0)].origin;
+
+ WKShowWordDefinitionWindow(attributedString.get(), textBaselineOrigin, (NSDictionary *)dictionaryPopupInfo.options.get());
+#else
// 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; }];
+#endif
+}
+
+void PageClientImpl::showCorrectionPanel(CorrectionPanelInfo::PanelType type, const FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings)
+{
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+ if (!isViewVisible() || !isViewInWindow())
+ return;
+ m_correctionPanel.show(m_wkView, type, boundingBoxOfReplacedString, replacedString, replacementString, alternativeReplacementStrings);
+#endif
+}
+
+void PageClientImpl::dismissCorrectionPanel(ReasonForDismissingCorrectionPanel reason)
+{
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+ m_correctionPanel.dismiss(reason);
+#endif
+}
+
+String PageClientImpl::dismissCorrectionPanelSoon(WebCore::ReasonForDismissingCorrectionPanel reason)
+{
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+ return m_correctionPanel.dismissSoon(reason);
+#else
+ return String();
+#endif
+}
+
+void PageClientImpl::recordAutocorrectionResponse(EditorClient::AutocorrectionResponseType responseType, const String& replacedString, const String& replacementString)
+{
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+ NSCorrectionResponse response = responseType == EditorClient::AutocorrectionReverted ? NSCorrectionResponseReverted : NSCorrectionResponseEdited;
+ CorrectionPanel::recordAutocorrectionResponse(m_wkView, response, replacedString, replacementString);
+#endif
+}
+
+float PageClientImpl::userSpaceScaleFactor() const
+{
+ NSWindow *window = [m_wkView window];
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+ if (window)
+ return [window backingScaleFactor];
+ return [[NSScreen mainScreen] backingScaleFactor];
+#else
+ if (window)
+ return [window userSpaceScaleFactor];
+ return [[NSScreen mainScreen] userSpaceScaleFactor];
+#endif
}
} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/API/mac/WKPrintingView.h b/Source/WebKit2/UIProcess/API/mac/WKPrintingView.h
index 3f7a692..87d81f4 100644
--- a/Source/WebKit2/UIProcess/API/mac/WKPrintingView.h
+++ b/Source/WebKit2/UIProcess/API/mac/WKPrintingView.h
@@ -35,6 +35,7 @@ namespace WebKit {
@interface WKPrintingView : NSView {
@public
NSPrintOperation *_printOperation; // WKPrintingView is owned by the operation.
+ RetainPtr<NSView> _wkView;
RefPtr<WebKit::WebFrameProxy> _webFrame;
Vector<WebCore::IntRect> _printingPageRects;
@@ -56,6 +57,6 @@ namespace WebKit {
NSTimer *_autodisplayResumeTimer;
}
-- (id)initWithFrameProxy:(WebKit::WebFrameProxy*)frame;
+- (id)initWithFrameProxy:(WebKit::WebFrameProxy*)frame view:(NSView *)wkView;
@end
diff --git a/Source/WebKit2/UIProcess/API/mac/WKPrintingView.mm b/Source/WebKit2/UIProcess/API/mac/WKPrintingView.mm
index 28ba153..d5d9de7 100644
--- a/Source/WebKit2/UIProcess/API/mac/WKPrintingView.mm
+++ b/Source/WebKit2/UIProcess/API/mac/WKPrintingView.mm
@@ -43,13 +43,14 @@ static BOOL isForcingPreviewUpdate;
@implementation WKPrintingView
-- (id)initWithFrameProxy:(WebFrameProxy*)frame
+- (id)initWithFrameProxy:(WebKit::WebFrameProxy*)frame view:(NSView *)wkView
{
self = [super init]; // No frame rect to pass to NSView.
if (!self)
return nil;
_webFrame = frame;
+ _wkView = wkView;
return self;
}
@@ -59,6 +60,19 @@ static BOOL isForcingPreviewUpdate;
return YES;
}
+- (void)_setAutodisplay:(BOOL)newState
+{
+ if (!newState && [[_wkView.get() window] isAutodisplay])
+ [_wkView.get() displayIfNeeded];
+
+ [[_wkView.get() window] setAutodisplay:newState];
+
+ // For some reason, painting doesn't happen for a long time without this call, <rdar://problem/8975229>.
+ if (newState)
+ [_wkView.get() displayIfNeeded];
+}
+
+
- (void)_suspendAutodisplay
{
// A drawRect: call on WKView causes a switch to screen mode, which is slow due to relayout, and we want to avoid that.
@@ -67,7 +81,7 @@ static BOOL isForcingPreviewUpdate;
[_autodisplayResumeTimer invalidate];
_autodisplayResumeTimer = nil;
} else
- _webFrame->page()->setAutodisplay(false);
+ [self _setAutodisplay:NO];
}
- (void)_delayedResumeAutodisplayTimerFired
@@ -75,7 +89,7 @@ static BOOL isForcingPreviewUpdate;
ASSERT(isMainThread());
_autodisplayResumeTimer = nil;
- _webFrame->page()->setAutodisplay(true);
+ [self _setAutodisplay:YES];
}
- (void)_delayedResumeAutodisplay
@@ -200,11 +214,12 @@ static void pageDidDrawToPDF(WKDataRef dataRef, WKErrorRef, void* untypedContext
pair<HashMap<WebCore::IntRect, Vector<uint8_t> >::iterator, bool> entry = view->_pagePreviews.add(iter->second, Vector<uint8_t>());
entry.first->second.append(data->bytes(), data->size());
}
- bool receivedResponseToLatestRequest = view->_latestExpectedPreviewCallback == context->callbackID;
- view->_latestExpectedPreviewCallback = 0;
view->_expectedPreviewCallbacks.remove(context->callbackID);
- if (receivedResponseToLatestRequest)
+ bool receivedResponseToLatestRequest = view->_latestExpectedPreviewCallback == context->callbackID;
+ if (receivedResponseToLatestRequest) {
+ view->_latestExpectedPreviewCallback = 0;
[view _updatePreview];
+ }
}
}
}
@@ -264,6 +279,12 @@ static void pageDidComputePageRects(const Vector<WebCore::IntRect>& pageRects, d
view->_printingPageRects = pageRects;
view->_totalScaleFactorForPrinting = totalScaleFactorForPrinting;
+ // Sanitize a response coming from the Web process.
+ if (view->_printingPageRects.isEmpty())
+ view->_printingPageRects.append(IntRect(0, 0, 1, 1));
+ if (view->_totalScaleFactorForPrinting <= 0)
+ view->_totalScaleFactorForPrinting = 1;
+
const IntRect& lastPrintingPageRect = view->_printingPageRects[view->_printingPageRects.size() - 1];
NSRect newFrameSize = NSMakeRect(0, 0,
ceil(lastPrintingPageRect.maxX() * view->_totalScaleFactorForPrinting),
@@ -330,6 +351,11 @@ static void prepareDataForPrintingOnSecondaryThread(void* untypedContext)
if (!isMainThread())
_isPrintingFromSecondaryThread = YES;
+ if (!_webFrame->page()) {
+ *range = NSMakeRange(1, NSIntegerMax);
+ return YES;
+ }
+
[self _suspendAutodisplay];
[self _adjustPrintingMarginsForHeaderAndFooter];
@@ -524,11 +550,22 @@ static void prepareDataForPrintingOnSecondaryThread(void* untypedContext)
ASSERT(_printOperation == [NSPrintOperation currentOperation]);
if (![self _hasPageRects]) {
LOG(View, "-[WKPrintingView %p rectForPage:%d] - data is not yet available", self, (int)page);
+ if (!_webFrame->page()) {
+ // We may have not told AppKit how many pages there are, so it will try to print until a null rect is returned.
+ return NSMakeRect(0, 0, 0, 0);
+ }
// We must be still calculating the page range.
ASSERT(_expectedComputedPagesCallback);
return NSMakeRect(0, 0, 1, 1);
}
+ // If Web process crashes while computing page rects, we never tell AppKit how many pages there are.
+ // Returning a null rect prevents selecting non-existent pages in preview dialog.
+ if (static_cast<unsigned>(page) > _printingPageRects.size()) {
+ ASSERT(!_webFrame->page());
+ return NSMakeRect(0, 0, 0, 0);
+ }
+
IntRect rect = _printingPageRects[page - 1];
rect.scale(_totalScaleFactorForPrinting);
LOG(View, "-[WKPrintingView %p rectForPage:%d] -> x %d, y %d, width %d, height %d", self, (int)page, rect.x(), rect.y(), rect.width(), rect.height());
diff --git a/Source/WebKit2/UIProcess/API/mac/WKView.mm b/Source/WebKit2/UIProcess/API/mac/WKView.mm
index e432549..05693ef 100644
--- a/Source/WebKit2/UIProcess/API/mac/WKView.mm
+++ b/Source/WebKit2/UIProcess/API/mac/WKView.mm
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -42,6 +42,7 @@
#import "TextChecker.h"
#import "TextCheckerState.h"
#import "WKAPICast.h"
+#import "WKFullScreenWindowController.h"
#import "WKPrintingView.h"
#import "WKStringCF.h"
#import "WKTextInputWindowController.h"
@@ -49,6 +50,7 @@
#import "WKViewPrivate.h"
#import "WebContext.h"
#import "WebEventFactory.h"
+#import "WebFullScreenManagerProxy.h"
#import "WebPage.h"
#import "WebPageProxy.h"
#import "WebProcessProxy.h"
@@ -57,6 +59,7 @@
#import <WebCore/ColorMac.h>
#import <WebCore/DragController.h>
#import <WebCore/DragData.h>
+#import <WebCore/LocalizedStrings.h>
#import <WebCore/FloatRect.h>
#import <WebCore/IntRect.h>
#import <WebCore/KeyboardEvent.h>
@@ -66,15 +69,14 @@
#import <wtf/RefPtr.h>
#import <wtf/RetainPtr.h>
-// FIXME (WebKit2) <rdar://problem/8728860> WebKit2 needs to be localized
-#define UI_STRING(__str, __desc) [NSString stringWithUTF8String:__str]
-
-@interface NSApplication (Details)
+@interface NSApplication (WebNSApplicationDetails)
- (void)speakString:(NSString *)string;
+- (void)_setCurrentEvent:(NSEvent *)event;
@end
-@interface NSWindow (Details)
+@interface NSWindow (WebNSWindowDetails)
- (NSRect)_growBoxRect;
+- (id)_growBoxOwner;
- (void)_setShowOpaqueGrowBoxForOwner:(id)owner;
- (BOOL)_updateGrowBoxForWindowFrameChange;
@end
@@ -108,11 +110,6 @@ typedef HashMap<String, ValidationVector> ValidationMap;
RetainPtr<NSView> _layerHostingView;
- // FIXME: Remove _oldLayerHostingView.
-#if USE(ACCELERATED_COMPOSITING)
- NSView *_oldLayerHostingView;
-#endif
-
RetainPtr<id> _remoteAccessibilityChild;
// For asynchronous validation.
@@ -124,7 +121,8 @@ typedef HashMap<String, ValidationVector> ValidationMap;
// We keep here the event when resending it to
// the application to distinguish the case of a new event from one
// that has been already sent to WebCore.
- NSEvent *_keyDownEventBeingResent;
+ RetainPtr<NSEvent> _keyDownEventBeingResent;
+ bool _isInInterpretKeyEvents;
Vector<KeypressCommand> _commandsList;
NSSize _resizeScrollOffset;
@@ -145,6 +143,13 @@ typedef HashMap<String, ValidationVector> ValidationMap;
#if ENABLE(GESTURE_EVENTS)
id _endGestureMonitor;
#endif
+
+#if ENABLE(FULLSCREEN_API)
+ RetainPtr<WKFullScreenWindowController> _fullScreenWindowController;
+#endif
+
+ BOOL _hasSpellCheckerDocumentTag;
+ NSInteger _spellCheckerDocumentTag;
}
@end
@@ -158,12 +163,6 @@ typedef HashMap<String, ValidationVector> ValidationMap;
@implementation WKView
-// FIXME: Remove this once we no longer want to be able to go back to the old drawing area.
-static bool useNewDrawingArea()
-{
- return true;
-}
-
- (id)initWithFrame:(NSRect)frame
{
return [self initWithFrame:frame contextRef:toAPI(WebContext::sharedProcessContext())];
@@ -223,6 +222,9 @@ static bool useNewDrawingArea()
_data->_pageClient = PageClientImpl::create(self);
_data->_page = toImpl(contextRef)->createWebPage(_data->_pageClient.get(), toImpl(pageGroupRef));
_data->_page->initializeWebPage();
+#if ENABLE(FULLSCREEN_API)
+ _data->_page->fullScreenManager()->setWebView(self);
+#endif
_data->_mouseDownEvent = nil;
_data->_ignoringMouseDraggedEvents = NO;
@@ -238,6 +240,7 @@ static bool useNewDrawingArea()
_data->_page->close();
[_data release];
+ _data = nil;
WebContext::statistics().wkViewCount--;
@@ -496,6 +499,8 @@ WEBCORE_COMMAND(yankAndSelect)
#undef WEBCORE_COMMAND
+// This method is needed to support Mac OS X services.
+
- (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pasteboard types:(NSArray *)types
{
Vector<String> pasteboardTypes;
@@ -505,6 +510,8 @@ WEBCORE_COMMAND(yankAndSelect)
return _data->_page->writeSelectionToPasteboard([pasteboard name], pasteboardTypes);
}
+// This method is needed to support Mac OS X services.
+
- (id)validRequestorForSendType:(NSString *)sendType returnType:(NSString *)returnType
{
BOOL isValidSendType = !sendType || ([PasteboardTypes::forSelection() containsObject:sendType] && !_data->_page->selectionState().isNone);
@@ -520,6 +527,13 @@ WEBCORE_COMMAND(yankAndSelect)
return [[self nextResponder] validRequestorForSendType:sendType returnType:returnType];
}
+// This method is needed to support Mac OS X services.
+
+- (BOOL)readSelectionFromPasteboard:(NSPasteboard *)pasteboard
+{
+ return _data->_page->readSelectionFromPasteboard([pasteboard name]);
+}
+
/*
When possible, editing-related methods should be implemented in WebCore with the
@@ -589,12 +603,8 @@ static void validateCommandCallback(WKStringRef commandName, bool isEnabled, int
SEL action = [item action];
if (action == @selector(showGuessPanel:)) {
- if (NSMenuItem *menuItem = ::menuItem(item)) {
- BOOL panelShowing = [[[NSSpellChecker sharedSpellChecker] spellingPanel] isVisible];
- [menuItem setTitle:panelShowing
- ? UI_STRING("Hide Spelling and Grammar", "menu item title")
- : UI_STRING("Show Spelling and Grammar", "menu item title")];
- }
+ if (NSMenuItem *menuItem = ::menuItem(item))
+ [menuItem setTitle:contextMenuItemTagShowSpellingPanel([[[NSSpellChecker sharedSpellChecker] spellingPanel] isVisible])];
return _data->_page->selectionState().isContentEditable;
}
@@ -621,12 +631,8 @@ static void validateCommandCallback(WKStringRef commandName, bool isEnabled, int
}
if (action == @selector(orderFrontSubstitutionsPanel:)) {
- if (NSMenuItem *menuItem = ::menuItem(item)) {
- BOOL panelShowing = [[[NSSpellChecker sharedSpellChecker] substitutionsPanel] isVisible];
- [menuItem setTitle:panelShowing
- ? UI_STRING("Hide Substitutions", "menu item title")
- : UI_STRING("Show Substitutions", "menu item title")];
- }
+ if (NSMenuItem *menuItem = ::menuItem(item))
+ [menuItem setTitle:contextMenuItemTagShowSubstitutions([[[NSSpellChecker sharedSpellChecker] substitutionsPanel] isVisible])];
return _data->_page->selectionState().isContentEditable;
}
@@ -1010,6 +1016,12 @@ static const short kIOHIDEventTypeScroll = 6;
- (void)doCommandBySelector:(SEL)selector
{
+ LOG(TextInput, "doCommandBySelector:\"%s\"", sel_getName(selector));
+
+ if (!_data->_isInInterpretKeyEvents) {
+ [super doCommandBySelector:selector];
+ return;
+ }
if (selector != @selector(noop:))
_data->_commandsList.append(KeypressCommand(commandNameForSelector(selector)));
}
@@ -1034,9 +1046,13 @@ static const short kIOHIDEventTypeScroll = 6;
isFromInputMethod = YES;
} else
text = string;
-
+
String eventText = text;
+ // We'd need a different code path here if we wanted to be able to handle this
+ // outside of interpretKeyEvents.
+ ASSERT(_data->_isInInterpretKeyEvents);
+
if (!isFromInputMethod)
_data->_commandsList.append(KeypressCommand("insertText", text));
else {
@@ -1085,9 +1101,6 @@ static const short kIOHIDEventTypeScroll = 6;
// But don't do it if we have already handled the event.
// Pressing Esc results in a fake event being sent - don't pass it to WebCore.
if (!eventWasSentToWebCore && event == [NSApp currentEvent] && self == [[self window] firstResponder]) {
- [_data->_keyDownEventBeingResent release];
- _data->_keyDownEventBeingResent = nil;
-
_data->_page->handleKeyboardEvent(NativeWebKeyboardEvent(event, self));
return YES;
}
@@ -1102,6 +1115,11 @@ static const short kIOHIDEventTypeScroll = 6;
- (void)keyDown:(NSEvent *)theEvent
{
+ // There's a chance that responding to this event will run a nested event loop, and
+ // fetching a new event might release the old one. Retaining and then autoreleasing
+ // the current event prevents that from causing a problem inside WebKit or AppKit code.
+ [[theEvent retain] autorelease];
+
if (_data->_pluginComplexTextInputIdentifier) {
// Try feeding the keyboard event directly to the plug-in.
NSString *string = nil;
@@ -1120,8 +1138,6 @@ static const short kIOHIDEventTypeScroll = 6;
// there is no range selection).
// If this is the case we should ignore the key down.
if (_data->_keyDownEventBeingResent == theEvent) {
- [_data->_keyDownEventBeingResent release];
- _data->_keyDownEventBeingResent = nil;
[super keyDown:theEvent];
return;
}
@@ -1129,7 +1145,7 @@ static const short kIOHIDEventTypeScroll = 6;
}
- (NSTextInputContext *)inputContext {
- if (_data->_pluginComplexTextInputIdentifier)
+ if (_data->_pluginComplexTextInputIdentifier && !_data->_isInInterpretKeyEvents)
return [[WKTextInputWindowController sharedTextInputWindowController] inputContext];
return [super inputContext];
@@ -1153,7 +1169,11 @@ static const short kIOHIDEventTypeScroll = 6;
- (void)unmarkText
{
LOG(TextInput, "unmarkText");
-
+
+ // We'd need a different code path here if we wanted to be able to handle this
+ // outside of interpretKeyEvents.
+ ASSERT(_data->_isInInterpretKeyEvents);
+
_data->_commandsList.append(KeypressCommand("unmarkText"));
}
@@ -1208,6 +1228,10 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde
extractUnderlines(string, _data->_underlines);
}
+ // We'd need a different code path here if we wanted to be able to handle this
+ // outside of interpretKeyEvents.
+ ASSERT(_data->_isInInterpretKeyEvents);
+
_data->_commandsList.append(KeypressCommand("setMarkedText", text));
_data->_selectionStart = newSelRange.location;
_data->_selectionEnd = NSMaxRange(newSelRange);
@@ -1418,10 +1442,15 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde
- (void)viewWillMoveToWindow:(NSWindow *)window
{
- if (window != [self window]) {
- [self removeWindowObservers];
- [self addWindowObserversForWindow:window];
- }
+ NSWindow *currentWindow = [self window];
+ if (window == currentWindow)
+ return;
+
+ [self removeWindowObservers];
+ [self addWindowObserversForWindow:window];
+
+ if ([currentWindow _growBoxOwner] == self)
+ [currentWindow _setShowOpaqueGrowBoxForOwner:nil];
}
- (void)viewDidMoveToWindow
@@ -1438,7 +1467,7 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde
// Initialize remote accessibility when the window connection has been established.
#if !defined(BUILDING_ON_SNOW_LEOPARD)
NSData *remoteElementToken = WKAXRemoteTokenForElement(self);
- NSData *remoteWindowToken = WKAXRemoteTokenForElement([self window]);
+ NSData *remoteWindowToken = WKAXRemoteTokenForElement([self accessibilityAttributeValue:NSAccessibilityWindowAttribute]);
CoreIPC::DataReference elementToken = CoreIPC::DataReference(reinterpret_cast<const uint8_t*>([remoteElementToken bytes]), [remoteElementToken length]);
CoreIPC::DataReference windowToken = CoreIPC::DataReference(reinterpret_cast<const uint8_t*>([remoteWindowToken bytes]), [remoteWindowToken length]);
_data->_page->registerUIProcessAccessibilityTokens(elementToken, windowToken);
@@ -1454,6 +1483,9 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde
_data->_endGestureMonitor = nil;
}
#endif
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+ WKHideWordDefinitionWindow();
+#endif
}
}
@@ -1510,37 +1542,25 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I
{
LOG(View, "drawRect: x:%g, y:%g, width:%g, height:%g", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
_data->_page->endPrinting();
- if (useNewDrawingArea()) {
- CGContextRef context = static_cast<CGContextRef>([[NSGraphicsContext currentContext] graphicsPort]);
-
- if (DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(_data->_page->drawingArea())) {
- const NSRect *rectsBeingDrawn;
- NSInteger numRectsBeingDrawn;
- [self getRectsBeingDrawn:&rectsBeingDrawn count:&numRectsBeingDrawn];
- for (NSInteger i = 0; i < numRectsBeingDrawn; ++i) {
- Region unpaintedRegion;
- IntRect rect = enclosingIntRect(rectsBeingDrawn[i]);
- drawingArea->paint(context, rect, unpaintedRegion);
-
- Vector<IntRect> unpaintedRects = unpaintedRegion.rects();
- for (size_t i = 0; i < unpaintedRects.size(); ++i)
- drawPageBackground(context, _data->_page.get(), unpaintedRects[i]);
- }
- } else
- drawPageBackground(context, _data->_page.get(), enclosingIntRect(rect));
-
- _data->_page->didDraw();
- return;
- }
+ CGContextRef context = static_cast<CGContextRef>([[NSGraphicsContext currentContext] graphicsPort]);
+
+ if (DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(_data->_page->drawingArea())) {
+ const NSRect *rectsBeingDrawn;
+ NSInteger numRectsBeingDrawn;
+ [self getRectsBeingDrawn:&rectsBeingDrawn count:&numRectsBeingDrawn];
+ for (NSInteger i = 0; i < numRectsBeingDrawn; ++i) {
+ Region unpaintedRegion;
+ IntRect rect = enclosingIntRect(rectsBeingDrawn[i]);
+ drawingArea->paint(context, rect, unpaintedRegion);
+
+ Vector<IntRect> unpaintedRects = unpaintedRegion.rects();
+ for (size_t i = 0; i < unpaintedRects.size(); ++i)
+ drawPageBackground(context, _data->_page.get(), unpaintedRects[i]);
+ }
+ } else
+ drawPageBackground(context, _data->_page.get(), enclosingIntRect(rect));
- if (_data->_page->isValid() && _data->_page->drawingArea()) {
- CGContextRef context = static_cast<CGContextRef>([[NSGraphicsContext currentContext] graphicsPort]);
- _data->_page->drawingArea()->paint(IntRect(rect), context);
- _data->_page->didDraw();
- } else if (_data->_page->drawsBackground()) {
- [_data->_page->drawsTransparentBackground() ? [NSColor clearColor] : [NSColor whiteColor] set];
- NSRectFill(rect);
- }
+ _data->_page->didDraw();
}
- (BOOL)isOpaque
@@ -1567,6 +1587,9 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I
- (id)accessibilityFocusedUIElement
{
+ if (_data->_pdfViewController)
+ return NSAccessibilityUnignoredDescendant(_data->_pdfViewController->pdfView());
+
return _data->_remoteAccessibilityChild.get();
}
@@ -1577,15 +1600,25 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I
- (id)accessibilityHitTest:(NSPoint)point
{
+ if (_data->_pdfViewController)
+ return [_data->_pdfViewController->pdfView() accessibilityHitTest:point];
+
return _data->_remoteAccessibilityChild.get();
}
- (id)accessibilityAttributeValue:(NSString*)attribute
{
if ([attribute isEqualToString:NSAccessibilityChildrenAttribute]) {
- if (!_data->_remoteAccessibilityChild)
+
+ id child = nil;
+ if (_data->_pdfViewController)
+ child = NSAccessibilityUnignoredDescendant(_data->_pdfViewController->pdfView());
+ else if (_data->_remoteAccessibilityChild)
+ child = _data->_remoteAccessibilityChild.get();
+
+ if (!child)
return nil;
- return [NSArray arrayWithObject:_data->_remoteAccessibilityChild.get()];
+ return [NSArray arrayWithObject:child];
}
if ([attribute isEqualToString:NSAccessibilityRoleAttribute])
return NSAccessibilityGroupRole;
@@ -1605,10 +1638,6 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I
if (hitView && _data && hitView == _data->_layerHostingView)
hitView = self;
-#if USE(ACCELERATED_COMPOSITING)
- if (hitView && _data && hitView == _data->_oldLayerHostingView)
- hitView = self;
-#endif
return hitView;
}
@@ -1634,7 +1663,7 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I
return 0;
return _data->_pdfViewController->makePrintOperation(printInfo);
} else {
- RetainPtr<WKPrintingView> printingView(AdoptNS, [[WKPrintingView alloc] initWithFrameProxy:toImpl(frameRef)]);
+ RetainPtr<WKPrintingView> printingView(AdoptNS, [[WKPrintingView alloc] initWithFrameProxy:toImpl(frameRef) view:self]);
// NSPrintOperation takes ownership of the view.
NSPrintOperation *printOperation = [NSPrintOperation printOperationWithView:printingView.get()];
[printOperation setCanSpawnSeparateThread:YES];
@@ -1649,10 +1678,7 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I
- (PassOwnPtr<WebKit::DrawingAreaProxy>)_createDrawingAreaProxy
{
- if (useNewDrawingArea())
- return DrawingAreaProxyImpl::create(_data->_page.get());
-
- return ChunkedUpdateDrawingAreaProxy::create(self, _data->_page.get());
+ return DrawingAreaProxyImpl::create(_data->_page.get());
}
- (BOOL)_isFocused
@@ -1708,21 +1734,33 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I
}
}
-- (void)_setEventBeingResent:(NSEvent *)event
+- (void)_resendKeyDownEvent:(NSEvent *)event
{
- _data->_keyDownEventBeingResent = [event retain];
+ ASSERT(!_data->_keyDownEventBeingResent);
+ _data->_keyDownEventBeingResent = event;
+ [NSApp _setCurrentEvent:event];
+ [NSApp sendEvent:event];
+
+ _data->_keyDownEventBeingResent = nullptr;
}
- (Vector<KeypressCommand>&)_interceptKeyEvent:(NSEvent *)theEvent
{
+ ASSERT(!_data->_isInInterpretKeyEvents);
+
+ _data->_isInInterpretKeyEvents = true;
_data->_commandsList.clear();
- // interpretKeyEvents will trigger one or more calls to doCommandBySelector or setText
+
+ // Calling interpretKeyEvents will trigger one or more calls to doCommandBySelector and insertText
// that will populate the commandsList vector.
[self interpretKeyEvents:[NSArray arrayWithObject:theEvent]];
+
+ _data->_isInInterpretKeyEvents = false;
+
return _data->_commandsList;
}
-- (void)_getTextInputState:(unsigned)start selectionEnd:(unsigned)end underlines:(Vector<WebCore::CompositionUnderline>&)lines
+- (void)_getTextInputState:(unsigned)start selectionEnd:(unsigned)end underlines:(Vector<CompositionUnderline>&)lines
{
start = _data->_selectionStart;
end = _data->_selectionEnd;
@@ -1771,20 +1809,23 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I
- (void)removeTrackingRect:(NSTrackingRectTag)tag
{
+ if (!_data)
+ return;
+
if (tag == 0)
return;
- if (_data && (tag == TRACKING_RECT_TAG)) {
+ if (tag == TRACKING_RECT_TAG) {
_data->_trackingRectOwner = nil;
return;
}
- if (_data && (tag == _data->_lastToolTipTag)) {
+ if (tag == _data->_lastToolTipTag) {
[super removeTrackingRect:tag];
_data->_lastToolTipTag = 0;
return;
}
-
+
// If any other tracking rect is being removed, we don't know how it was created
// and it's possible there's a leak involved (see 3500217)
ASSERT_NOT_REACHED();
@@ -2001,6 +2042,17 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I
[self _updateGrowBoxForWindowFrameChange];
}
+#if ENABLE(FULLSCREEN_API)
+- (WKFullScreenWindowController*)fullScreenWindowController
+{
+ if (!_data->_fullScreenWindowController) {
+ _data->_fullScreenWindowController.adoptNS([[WKFullScreenWindowController alloc] init]);
+ [_data->_fullScreenWindowController.get() setWebView:self];
+ }
+ return _data->_fullScreenWindowController.get();
+}
+#endif
+
@end
@implementation WKView (Private)
@@ -2033,5 +2085,19 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I
_data->_page->performDictionaryLookupAtLocation(FloatPoint(thePoint.x, thePoint.y));
}
+- (NSInteger)spellCheckerDocumentTag
+{
+ if (!_data->_hasSpellCheckerDocumentTag) {
+ _data->_spellCheckerDocumentTag = [NSSpellChecker uniqueSpellDocumentTag];
+ _data->_hasSpellCheckerDocumentTag = YES;
+ }
+ return _data->_spellCheckerDocumentTag;
+}
+
+- (void)handleCorrectionPanelResult:(NSString*)result
+{
+ _data->_page->handleCorrectionPanelResult(result);
+}
+
@end
diff --git a/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h b/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h
index 4147658..e4a40f7 100644
--- a/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h
+++ b/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h
@@ -27,11 +27,20 @@
#import <WebCore/Editor.h>
#import <WebCore/KeyboardEvent.h>
+namespace CoreIPC {
+ class DataReference;
+}
+
namespace WebKit {
class DrawingAreaProxy;
class FindIndicator;
+ class LayerTreeContext;
}
+#if ENABLE(FULLSCREEN_API)
+@class WKFullScreenWindowController;
+#endif
+
@interface WKView (Internal)
- (PassOwnPtr<WebKit::DrawingAreaProxy>)_createDrawingAreaProxy;
- (BOOL)_isFocused;
@@ -44,7 +53,7 @@ namespace WebKit {
- (void)_setUserInterfaceItemState:(NSString *)commandName enabled:(BOOL)isEnabled state:(int)newState;
- (Vector<WebCore::KeypressCommand>&)_interceptKeyEvent:(NSEvent *)theEvent;
- (void)_getTextInputState:(unsigned)start selectionEnd:(unsigned)end underlines:(Vector<WebCore::CompositionUnderline>&)lines;
-- (void)_setEventBeingResent:(NSEvent *)event;
+- (void)_resendKeyDownEvent:(NSEvent *)event;
- (NSRect)_convertToDeviceSpace:(NSRect)rect;
- (NSRect)_convertToUserSpace:(NSRect)rect;
- (void)_setFindIndicator:(PassRefPtr<WebKit::FindIndicator>)findIndicator fadeOut:(BOOL)fadeOut;
@@ -64,4 +73,8 @@ namespace WebKit {
- (void)_setDrawingAreaSize:(NSSize)size;
- (void)_didChangeScrollbarsForMainFrame;
+
+#if ENABLE(FULLSCREEN_API)
+- (WKFullScreenWindowController*)fullScreenWindowController;
+#endif
@end
diff --git a/Source/WebKit2/UIProcess/API/mac/WKViewPrivate.h b/Source/WebKit2/UIProcess/API/mac/WKViewPrivate.h
index cece1c7..37c2d8d 100644
--- a/Source/WebKit2/UIProcess/API/mac/WKViewPrivate.h
+++ b/Source/WebKit2/UIProcess/API/mac/WKViewPrivate.h
@@ -35,4 +35,6 @@
- (void)performDictionaryLookupAtCurrentMouseLocation;
+- (NSInteger)spellCheckerDocumentTag;
+- (void)handleCorrectionPanelResult:(NSString*)result;
@end
diff --git a/Source/WebKit2/UIProcess/API/qt/qwkpage.cpp b/Source/WebKit2/UIProcess/API/qt/qwkpage.cpp
index 05c7b8b..a162918 100644
--- a/Source/WebKit2/UIProcess/API/qt/qwkpage.cpp
+++ b/Source/WebKit2/UIProcess/API/qt/qwkpage.cpp
@@ -194,9 +194,9 @@ void QWKPagePrivate::exitAcceleratedCompositingMode()
// FIXME: Implement.
}
-void QWKPagePrivate::pageDidRequestScroll(const IntSize& delta)
+void QWKPagePrivate::pageDidRequestScroll(const IntPoint& point)
{
- emit q->scrollRequested(delta.width(), delta.height());
+ emit q->scrollRequested(point.x(), point.y());
}
void QWKPagePrivate::didChangeContentsSize(const IntSize& newSize)
@@ -222,6 +222,11 @@ FloatRect QWKPagePrivate::convertToDeviceSpace(const FloatRect& rect)
return rect;
}
+IntRect QWKPagePrivate::windowToScreen(const IntRect& rect)
+{
+ return rect;
+}
+
FloatRect QWKPagePrivate::convertToUserSpace(const FloatRect& rect)
{
return rect;
@@ -482,7 +487,8 @@ QWKPage::QWKPage(QWKContext* context)
0, /* drawFooter */
0, /* printFrame */
0, /* runModal */
- 0 /* didCompleteRubberBandForMainFrame */
+ 0, /* didCompleteRubberBandForMainFrame */
+ 0 /* saveDataToFileInDownloadsFolder */
};
WKPageSetPageUIClient(pageRef(), &uiClient);
}
@@ -561,7 +567,7 @@ QWKPage::ViewportAttributes QWKPage::viewportAttributesForSize(const QSize& avai
result.m_minimumScaleFactor = conf.minimumScale;
result.m_maximumScaleFactor = conf.maximumScale;
result.m_devicePixelRatio = conf.devicePixelRatio;
- result.m_isUserScalable = conf.userScalable;
+ result.m_isUserScalable = static_cast<bool>(conf.userScalable);
return result;
}
diff --git a/Source/WebKit2/UIProcess/API/qt/qwkpage_p.h b/Source/WebKit2/UIProcess/API/qt/qwkpage_p.h
index 1a626a1..ee1fb0e 100644
--- a/Source/WebKit2/UIProcess/API/qt/qwkpage_p.h
+++ b/Source/WebKit2/UIProcess/API/qt/qwkpage_p.h
@@ -63,7 +63,7 @@ public:
virtual void enterAcceleratedCompositingMode(const LayerTreeContext&);
virtual void exitAcceleratedCompositingMode();
#endif // USE(ACCELERATED_COMPOSITING)
- virtual void pageDidRequestScroll(const WebCore::IntSize&);
+ virtual void pageDidRequestScroll(const WebCore::IntPoint&);
virtual void processDidCrash();
virtual void pageClosed() { }
virtual void didRelaunchProcess();
@@ -72,11 +72,14 @@ public:
virtual void setCursor(const WebCore::Cursor&);
virtual void setViewportArguments(const WebCore::ViewportArguments&);
virtual void takeFocus(bool direction);
+ virtual void setFocus(bool focused) { }
virtual void toolTipChanged(const WTF::String&, const WTF::String&);
virtual void registerEditCommand(PassRefPtr<WebKit::WebEditCommandProxy>, WebKit::WebPageProxy::UndoOrRedo);
virtual void clearAllEditCommands();
virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&);
virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&);
+ virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&);
+
virtual void doneWithKeyEvent(const WebKit::NativeWebKeyboardEvent&, bool wasEventHandled);
virtual void selectionChanged(bool, bool, bool, bool);
virtual PassRefPtr<WebKit::WebPopupMenuProxy> createPopupMenuProxy(WebKit::WebPageProxy*);
@@ -92,6 +95,8 @@ public:
virtual void flashBackingStoreUpdates(const Vector<WebCore::IntRect>& updateRects);
+ virtual float userSpaceScaleFactor() const { return 1; }
+
void paint(QPainter* painter, QRect);
void keyPressEvent(QKeyEvent*);
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qgraphicswkview/tst_qgraphicswkview.cpp b/Source/WebKit2/UIProcess/API/qt/tests/qgraphicswkview/tst_qgraphicswkview.cpp
index f26c69d..8cb7263 100644
--- a/Source/WebKit2/UIProcess/API/qt/tests/qgraphicswkview/tst_qgraphicswkview.cpp
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qgraphicswkview/tst_qgraphicswkview.cpp
@@ -35,6 +35,7 @@ private slots:
void init();
void cleanup();
+ void loadEmptyUrl();
void loadEmptyPage();
private:
@@ -83,10 +84,21 @@ void tst_QGraphicsWKView::loadEmptyPage()
{
m_view->show();
- m_view->m_webView-> load(QUrl::fromLocalFile(TESTDIR "/html/basic_page.html"));
+ m_view->m_webView-> load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html")));
QVERIFY(waitForSignal(m_view->m_webView, SIGNAL(loadFinished(bool))));
}
+void tst_QGraphicsWKView::loadEmptyUrl()
+{
+ // That should not crash.
+ m_view->show();
+ m_view->m_webView->load(QUrl());
+ QVERIFY(!waitForSignal(m_view->m_webView->page(), SIGNAL(engineConnectionChanged(bool)), 50));
+
+ m_view->m_webView->load(QUrl(QLatin1String("")));
+ QVERIFY(!waitForSignal(m_view->m_webView->page(), SIGNAL(engineConnectionChanged(bool)), 50));
+}
+
QTEST_MAIN(tst_QGraphicsWKView)
#include "tst_qgraphicswkview.moc"
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qwkpage/qwkpage.pro b/Source/WebKit2/UIProcess/API/qt/tests/qwkpage/qwkpage.pro
new file mode 100644
index 0000000..e99c7f4
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qwkpage/qwkpage.pro
@@ -0,0 +1 @@
+include(../tests.pri)
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qwkpage/tst_qwkpage.cpp b/Source/WebKit2/UIProcess/API/qt/tests/qwkpage/tst_qwkpage.cpp
new file mode 100644
index 0000000..39fcac2
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qwkpage/tst_qwkpage.cpp
@@ -0,0 +1,59 @@
+/*
+ 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 <QScopedPointer>
+#include <QtTest/QtTest>
+#include <qwkcontext.h>
+#include <qwkpage.h>
+
+class tst_QWKPage : public QObject {
+ Q_OBJECT
+
+private slots:
+ void init();
+ void cleanup();
+
+ void loadEmptyUrl();
+
+private:
+ QScopedPointer<QWKContext> m_context;
+ QScopedPointer<QWKPage> m_page;
+};
+
+void tst_QWKPage::init()
+{
+ m_context.reset(new QWKContext);
+ m_page.reset(new QWKPage(m_context.data()));
+}
+
+void tst_QWKPage::cleanup()
+{
+ m_page.reset();
+ m_context.reset();
+}
+
+void tst_QWKPage::loadEmptyUrl()
+{
+ m_page->load(QUrl());
+ m_page->load(QUrl(QLatin1String("")));
+}
+
+QTEST_MAIN(tst_QWKPage)
+
+#include "tst_qwkpage.moc"
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/tests.pri b/Source/WebKit2/UIProcess/API/qt/tests/tests.pri
index 3a2aac1..032acc3 100644
--- a/Source/WebKit2/UIProcess/API/qt/tests/tests.pri
+++ b/Source/WebKit2/UIProcess/API/qt/tests/tests.pri
@@ -13,4 +13,4 @@ include(../../../../../WebKit.pri)
QT += testlib
QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR
-DEFINES += TESTDIR=\\\"$$PWD\\\"
+!symbian: DEFINES += TESTS_SOURCE_DIR=\\\"$$PWD\\\"
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/tests.pro b/Source/WebKit2/UIProcess/API/qt/tests/tests.pro
index eb85021..f8db5a4 100644
--- a/Source/WebKit2/UIProcess/API/qt/tests/tests.pro
+++ b/Source/WebKit2/UIProcess/API/qt/tests/tests.pro
@@ -1,2 +1,2 @@
TEMPLATE = subdirs
-SUBDIRS = qgraphicswkview
+SUBDIRS = qgraphicswkview qwkpage