summaryrefslogtreecommitdiff
path: root/Source/WebKit2/UIProcess/API
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-08-12 09:27:39 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-08-12 09:27:39 +0200
commit3749d61e1f7a59f5ec5067e560af1eb610c82015 (patch)
tree73dc228333948738bbe02976cacca8cd382bc978 /Source/WebKit2/UIProcess/API
parentb32b4dcd9a51ab8de6afc53d9e17f8707e1f7a5e (diff)
downloadqtwebkit-3749d61e1f7a59f5ec5067e560af1eb610c82015.tar.gz
Imported WebKit commit a77350243e054f3460d1137301d8b3faee3d2052 (http://svn.webkit.org/repository/webkit/trunk@125365)
New snapshot with build fixes for latest API changes in Qt and all WK1 Win MSVC fixes upstream
Diffstat (limited to 'Source/WebKit2/UIProcess/API')
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKContext.cpp10
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKContext.h1
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKContextPrivate.h2
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKPage.cpp7
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKPage.h3
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKPreferences.cpp50
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKPreferences.h4
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h16
-rw-r--r--Source/WebKit2/UIProcess/API/C/WebKit2_C.h (renamed from Source/WebKit2/UIProcess/API/C/WebKit2.h)6
-rw-r--r--Source/WebKit2/UIProcess/API/cpp/efl/WKEinaSharedString.cpp102
-rw-r--r--Source/WebKit2/UIProcess/API/cpp/efl/WKEinaSharedString.h69
-rw-r--r--Source/WebKit2/UIProcess/API/efl/EWebKit2.h2
-rw-r--r--Source/WebKit2/UIProcess/API/efl/EflViewportHandler.cpp99
-rw-r--r--Source/WebKit2/UIProcess/API/efl/EflViewportHandler.h66
-rw-r--r--Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp14
-rw-r--r--Source/WebKit2/UIProcess/API/efl/PageClientImpl.h2
-rw-r--r--Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list.cpp161
-rw-r--r--Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list.h92
-rw-r--r--Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_item.cpp102
-rw-r--r--Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_item.h107
-rw-r--r--Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_item_private.h35
-rw-r--r--Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_private.h37
-rw-r--r--Source/WebKit2/UIProcess/API/efl/ewk_context.cpp13
-rw-r--r--Source/WebKit2/UIProcess/API/efl/ewk_context_private.h1
-rw-r--r--Source/WebKit2/UIProcess/API/efl/ewk_view.cpp181
-rw-r--r--Source/WebKit2/UIProcess/API/efl/ewk_view.h96
-rw-r--r--Source/WebKit2/UIProcess/API/efl/ewk_view_find_client.cpp50
-rw-r--r--Source/WebKit2/UIProcess/API/efl/ewk_view_find_client_private.h34
-rw-r--r--Source/WebKit2/UIProcess/API/efl/ewk_view_loader_client.cpp11
-rw-r--r--Source/WebKit2/UIProcess/API/efl/ewk_view_private.h4
-rw-r--r--Source/WebKit2/UIProcess/API/efl/ewk_view_ui_client.cpp55
-rw-r--r--Source/WebKit2/UIProcess/API/efl/ewk_view_ui_client_private.h34
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp3
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardListPrivate.h2
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitLoaderClient.cpp11
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitPolicyDecisionPrivate.h2
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h2
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitSettingsPrivate.h2
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.cpp14
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.h7
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp36
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebResource.cpp5
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebResourcePrivate.h1
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp268
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h36
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp9
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h2
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt5
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.cpp23
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.h2
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/tests/TestInspector.cpp5
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/tests/TestLoaderClient.cpp23
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp41
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp98
-rw-r--r--Source/WebKit2/UIProcess/API/mac/WKBrowsingContextController.h3
-rw-r--r--Source/WebKit2/UIProcess/API/mac/WKBrowsingContextController.mm13
-rw-r--r--Source/WebKit2/UIProcess/API/mac/WebKit2.h31
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp4
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp123
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h20
-rw-r--r--Source/WebKit2/UIProcess/API/qt/raw/qrawwebview.cpp4
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/publicapi/tst_publicapi.cpp4
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_devicePixelRatio.qml63
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_favIconLoad.qml4
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/tests.pri15
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/util.cpp10
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/util.h2
67 files changed, 2098 insertions, 261 deletions
diff --git a/Source/WebKit2/UIProcess/API/C/WKContext.cpp b/Source/WebKit2/UIProcess/API/C/WKContext.cpp
index e90d1129a..f802e9374 100644
--- a/Source/WebKit2/UIProcess/API/C/WKContext.cpp
+++ b/Source/WebKit2/UIProcess/API/C/WKContext.cpp
@@ -61,16 +61,6 @@ WKContextRef WKContextCreateWithInjectedBundlePath(WKStringRef pathRef)
return toAPI(context.release().leakRef());
}
-WKContextRef WKContextGetSharedProcessContext()
-{
- return toAPI(WebContext::sharedProcessContext());
-}
-
-WKContextRef WKContextGetSharedThreadContext()
-{
- return toAPI(WebContext::sharedThreadContext());
-}
-
void WKContextSetInjectedBundleClient(WKContextRef contextRef, const WKContextInjectedBundleClient* wkClient)
{
toImpl(contextRef)->initializeInjectedBundleClient(wkClient);
diff --git a/Source/WebKit2/UIProcess/API/C/WKContext.h b/Source/WebKit2/UIProcess/API/C/WKContext.h
index 412227de7..967daea79 100644
--- a/Source/WebKit2/UIProcess/API/C/WKContext.h
+++ b/Source/WebKit2/UIProcess/API/C/WKContext.h
@@ -127,7 +127,6 @@ WK_EXPORT WKTypeID WKContextGetTypeID();
WK_EXPORT WKContextRef WKContextCreate();
WK_EXPORT WKContextRef WKContextCreateWithInjectedBundlePath(WKStringRef path);
-WK_EXPORT WKContextRef WKContextGetSharedProcessContext();
WK_EXPORT void WKContextSetInjectedBundleClient(WKContextRef context, const WKContextInjectedBundleClient* client);
WK_EXPORT void WKContextSetHistoryClient(WKContextRef context, const WKContextHistoryClient* client);
diff --git a/Source/WebKit2/UIProcess/API/C/WKContextPrivate.h b/Source/WebKit2/UIProcess/API/C/WKContextPrivate.h
index 01dac4b01..49aec7f53 100644
--- a/Source/WebKit2/UIProcess/API/C/WKContextPrivate.h
+++ b/Source/WebKit2/UIProcess/API/C/WKContextPrivate.h
@@ -42,8 +42,6 @@ typedef struct WKContextStatistics WKContextStatistics;
WK_EXPORT void WKContextGetGlobalStatistics(WKContextStatistics* statistics);
-WK_EXPORT WKContextRef WKContextGetSharedThreadContext();
-
WK_EXPORT void WKContextSetAdditionalPluginsDirectory(WKContextRef context, WKStringRef pluginsDirectory);
WK_EXPORT void WKContextRegisterURLSchemeAsEmptyDocument(WKContextRef context, WKStringRef urlScheme);
diff --git a/Source/WebKit2/UIProcess/API/C/WKPage.cpp b/Source/WebKit2/UIProcess/API/C/WKPage.cpp
index 5c600350a..a53a83161 100644
--- a/Source/WebKit2/UIProcess/API/C/WKPage.cpp
+++ b/Source/WebKit2/UIProcess/API/C/WKPage.cpp
@@ -582,6 +582,13 @@ void WKPageGetContentsAsString_b(WKPageRef pageRef, WKPageGetSourceForFrameBlock
}
#endif
+void WKPageGetContentsAsMHTMLData(WKPageRef pageRef, bool useBinaryEncoding, void* context, WKPageGetContentsAsMHTMLDataFunction callback)
+{
+#if ENABLE(MHTML)
+ toImpl(pageRef)->getContentsAsMHTMLData(DataCallback::create(context, callback), useBinaryEncoding);
+#endif
+}
+
void WKPageForceRepaint(WKPageRef pageRef, void* context, WKPageForceRepaintFunction callback)
{
toImpl(pageRef)->forceRepaint(VoidCallback::create(context, callback));
diff --git a/Source/WebKit2/UIProcess/API/C/WKPage.h b/Source/WebKit2/UIProcess/API/C/WKPage.h
index fdacf8b4d..ab3b8eede 100644
--- a/Source/WebKit2/UIProcess/API/C/WKPage.h
+++ b/Source/WebKit2/UIProcess/API/C/WKPage.h
@@ -465,6 +465,9 @@ typedef void (^WKPageGetContentsAsStringBlock)(WKStringRef, WKErrorRef);
WK_EXPORT void WKPageGetContentsAsString_b(WKPageRef page, WKPageGetContentsAsStringBlock block);
#endif
+typedef void (*WKPageGetContentsAsMHTMLDataFunction)(WKDataRef, WKErrorRef, void*);
+WK_EXPORT void WKPageGetContentsAsMHTMLData(WKPageRef page, bool useBinaryEncoding, void* context, WKPageGetContentsAsMHTMLDataFunction function);
+
typedef void (*WKPageForceRepaintFunction)(WKErrorRef, void*);
WK_EXPORT void WKPageForceRepaint(WKPageRef page, void* context, WKPageForceRepaintFunction function);
diff --git a/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp b/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp
index 243a17369..66d4dcd98 100644
--- a/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp
+++ b/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp
@@ -817,6 +817,16 @@ bool WKPreferencesGetRequestAnimationFrameEnabled(WKPreferencesRef preferencesRe
return toImpl(preferencesRef)->requestAnimationFrameEnabled();
}
+void WKPreferencesSetThirdPartyStorageBlockingEnabled(WKPreferencesRef preferencesRef, bool flag)
+{
+ toImpl(preferencesRef)->setThirdPartyStorageBlockingEnabled(flag);
+}
+
+bool WKPreferencesGetThirdPartyStorageBlockingEnabled(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->thirdPartyStorageBlockingEnabled();
+}
+
void WKPreferencesResetTestRunnerOverrides(WKPreferencesRef preferencesRef)
{
// Currently we reset the overrides on the web process when preferencesDidChange() is called. Since WTR preferences
@@ -833,3 +843,43 @@ bool WKPreferencesGetDiagnosticLoggingEnabled(WKPreferencesRef preferencesRef)
{
return toImpl(preferencesRef)->diagnosticLoggingEnabled();
}
+
+void WKPreferencesSetAsynchronousPluginInitializationEnabled(WKPreferencesRef preferencesRef, bool enabled)
+{
+ toImpl(preferencesRef)->setAsynchronousPluginInitializationEnabled(enabled);
+}
+
+bool WKPreferencesGetAsynchronousPluginInitializationEnabled(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->asynchronousPluginInitializationEnabled();
+}
+
+void WKPreferencesSetAsynchronousPluginInitializationEnabledForAllPlugins(WKPreferencesRef preferencesRef, bool enabled)
+{
+ toImpl(preferencesRef)->setAsynchronousPluginInitializationEnabledForAllPlugins(enabled);
+}
+
+bool WKPreferencesGetAsynchronousPluginInitializationEnabledForAllPlugins(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->asynchronousPluginInitializationEnabledForAllPlugins();
+}
+
+void WKPreferencesSetArtificialPluginInitializationDelayEnabled(WKPreferencesRef preferencesRef, bool enabled)
+{
+ toImpl(preferencesRef)->setArtificialPluginInitializationDelayEnabled(enabled);
+}
+
+bool WKPreferencesGetArtificialPluginInitializationDelayEnabled(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->artificialPluginInitializationDelayEnabled();
+}
+
+void WKPreferencesSetScrollingPerformanceLoggingEnabled(WKPreferencesRef preferencesRef, bool enabled)
+{
+ toImpl(preferencesRef)->setScrollingPerformanceLoggingEnabled(enabled);
+}
+
+bool WKPreferencesGetScrollingPerformanceLoggingEnabled(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->scrollingPerformanceLoggingEnabled();
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKPreferences.h b/Source/WebKit2/UIProcess/API/C/WKPreferences.h
index 42f94957e..883fbff61 100644
--- a/Source/WebKit2/UIProcess/API/C/WKPreferences.h
+++ b/Source/WebKit2/UIProcess/API/C/WKPreferences.h
@@ -205,6 +205,10 @@ WK_EXPORT bool WKPreferencesGetNotificationsEnabled(WKPreferencesRef preferences
WK_EXPORT void WKPreferencesSetShouldRespectImageOrientation(WKPreferencesRef preferencesRef, bool enabled);
WK_EXPORT bool WKPreferencesGetShouldRespectImageOrientation(WKPreferencesRef preferencesRef);
+// Defaults to false
+WK_EXPORT void WKPreferencesSetThirdPartyStorageBlockingEnabled(WKPreferencesRef preferencesRef, bool enabled);
+WK_EXPORT bool WKPreferencesGetThirdPartyStorageBlockingEnabled(WKPreferencesRef preferencesRef);
+
#ifdef __cplusplus
}
#endif
diff --git a/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h b/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h
index 371c539a1..b469d7aca 100644
--- a/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h
+++ b/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h
@@ -191,6 +191,22 @@ WK_EXPORT bool WKPreferencesGetRequestAnimationFrameEnabled(WKPreferencesRef);
WK_EXPORT void WKPreferencesSetDiagnosticLoggingEnabled(WKPreferencesRef preferencesRef, bool enabled);
WK_EXPORT bool WKPreferencesGetDiagnosticLoggingEnabled(WKPreferencesRef preferencesRef);
+// Defaults to false
+WK_EXPORT void WKPreferencesSetAsynchronousPluginInitializationEnabled(WKPreferencesRef preferencesRef, bool enabled);
+WK_EXPORT bool WKPreferencesGetAsynchronousPluginInitializationEnabled(WKPreferencesRef preferencesRef);
+
+// Defaults to false
+WK_EXPORT void WKPreferencesSetAsynchronousPluginInitializationEnabledForAllPlugins(WKPreferencesRef preferencesRef, bool enabled);
+WK_EXPORT bool WKPreferencesGetAsynchronousPluginInitializationEnabledForAllPlugins(WKPreferencesRef preferencesRef);
+
+// Defaults to false
+WK_EXPORT void WKPreferencesSetArtificialPluginInitializationDelayEnabled(WKPreferencesRef preferencesRef, bool enabled);
+WK_EXPORT bool WKPreferencesGetArtificialPluginInitializationDelayEnabled(WKPreferencesRef preferencesRef);
+
+// Defaults to false
+WK_EXPORT void WKPreferencesSetScrollingPerformanceLoggingEnabled(WKPreferencesRef preferencesRef, bool enabled);
+WK_EXPORT bool WKPreferencesGetScrollingPerformanceLoggingEnabled(WKPreferencesRef preferencesRef);
+
WK_EXPORT void WKPreferencesResetTestRunnerOverrides(WKPreferencesRef preferencesRef);
#ifdef __cplusplus
diff --git a/Source/WebKit2/UIProcess/API/C/WebKit2.h b/Source/WebKit2/UIProcess/API/C/WebKit2_C.h
index 5209e794f..981d52027 100644
--- a/Source/WebKit2/UIProcess/API/C/WebKit2.h
+++ b/Source/WebKit2/UIProcess/API/C/WebKit2_C.h
@@ -23,8 +23,8 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef WebKit2_h
-#define WebKit2_h
+#ifndef WebKit2_C_h
+#define WebKit2_C_h
#include <WebKit2/WKBase.h>
#include <WebKit2/WKType.h>
@@ -65,4 +65,4 @@
#include <WebKit2/WKView.h>
#endif
-#endif /* WebKit2_h */
+#endif /* WebKit2_C_h */
diff --git a/Source/WebKit2/UIProcess/API/cpp/efl/WKEinaSharedString.cpp b/Source/WebKit2/UIProcess/API/cpp/efl/WKEinaSharedString.cpp
new file mode 100644
index 000000000..d2681203c
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/cpp/efl/WKEinaSharedString.cpp
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. 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 "WKEinaSharedString.h"
+
+#include <WebKit2/WKAPICast.h>
+#include <WebKit2/WKString.h>
+#include <WebKit2/WKURL.h>
+#include <wtf/text/CString.h>
+
+using namespace WebKit;
+
+template <typename WKRefType>
+ALWAYS_INLINE const char* fromRefType(WKRefType strRef, bool adopt = false)
+{
+ const char* res = 0;
+ if (strRef) {
+ res = eina_stringshare_add(toImpl(strRef)->string().utf8().data());
+ ASSERT(res);
+ if (adopt)
+ WKRelease(strRef);
+ }
+
+ return res;
+}
+
+WKEinaSharedString::WKEinaSharedString(const WKEinaSharedString& other)
+ : m_string(eina_stringshare_ref(other.m_string))
+{
+}
+
+WKEinaSharedString::WKEinaSharedString(const char* str)
+ : m_string(eina_stringshare_add(str))
+{
+}
+
+WKEinaSharedString::WKEinaSharedString(WKAdoptTag adoptTag, WKStringRef stringRef)
+ : m_string(fromRefType(stringRef, /*adopt*/ true))
+{
+ ASSERT(adoptTag == AdoptWK); // Guard for future enum changes.
+}
+
+WKEinaSharedString::WKEinaSharedString(WKStringRef stringRef)
+ : m_string(fromRefType(stringRef))
+{
+}
+
+WKEinaSharedString::WKEinaSharedString(WKAdoptTag adoptTag, WKURLRef urlRef)
+ : m_string(fromRefType(urlRef, /*adopt*/ true))
+{
+ ASSERT(adoptTag == AdoptWK); // Guard for future enum changes.
+}
+
+WKEinaSharedString::WKEinaSharedString(WKURLRef urlRef)
+ : m_string(fromRefType(urlRef))
+{
+}
+
+WKEinaSharedString::~WKEinaSharedString()
+{
+ if (m_string)
+ eina_stringshare_del(m_string);
+}
+
+WKEinaSharedString& WKEinaSharedString::operator=(const WKEinaSharedString& other)
+{
+ if (this != &other) {
+ if (m_string)
+ eina_stringshare_del(m_string);
+ m_string = eina_stringshare_ref(other.m_string);
+ }
+ return *this;
+}
+
+WKEinaSharedString& WKEinaSharedString::operator=(const char* str)
+{
+ eina_stringshare_replace(&m_string, str);
+ return *this;
+}
diff --git a/Source/WebKit2/UIProcess/API/cpp/efl/WKEinaSharedString.h b/Source/WebKit2/UIProcess/API/cpp/efl/WKEinaSharedString.h
new file mode 100644
index 000000000..83f661418
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/cpp/efl/WKEinaSharedString.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. 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 WKEinaSharedString_h
+#define WKEinaSharedString_h
+
+#include <Eina.h>
+#include <WebKit2/WKBase.h>
+#include <WebKit2/WKRetainPtr.h>
+
+namespace WebKit {
+
+class WK_EXPORT WKEinaSharedString {
+public:
+ ALWAYS_INLINE WKEinaSharedString() : m_string(0) { }
+ WKEinaSharedString(const WKEinaSharedString& other);
+ WKEinaSharedString(const char* str);
+
+ WKEinaSharedString(WKAdoptTag, WKStringRef);
+ WKEinaSharedString(WKStringRef);
+
+ WKEinaSharedString(WKAdoptTag, WKURLRef);
+ WKEinaSharedString(WKURLRef);
+
+ ~WKEinaSharedString();
+
+ WKEinaSharedString& operator=(const WKEinaSharedString& other);
+ WKEinaSharedString& operator=(const char* str);
+
+ ALWAYS_INLINE bool operator==(const WKEinaSharedString& other) const { return this->m_string == other.m_string; }
+ ALWAYS_INLINE bool operator!=(const WKEinaSharedString& other) const { return !(*this == other); }
+
+ ALWAYS_INLINE operator const char* () const { return m_string; }
+
+ ALWAYS_INLINE bool isNull() const { return !m_string; }
+
+ ALWAYS_INLINE size_t length() const { return m_string ? static_cast<size_t>(eina_stringshare_strlen(m_string)) : 0; }
+
+private:
+ const char* m_string;
+};
+
+} // namespace WebKit
+
+using WebKit::WKEinaSharedString;
+
+#endif // WKEinaSharedString_h
diff --git a/Source/WebKit2/UIProcess/API/efl/EWebKit2.h b/Source/WebKit2/UIProcess/API/efl/EWebKit2.h
index 9a052da4b..d98023de6 100644
--- a/Source/WebKit2/UIProcess/API/efl/EWebKit2.h
+++ b/Source/WebKit2/UIProcess/API/efl/EWebKit2.h
@@ -28,6 +28,8 @@
#ifndef EWebKit2_h
#define EWebKit2_h
+#include "ewk_back_forward_list.h"
+#include "ewk_back_forward_list_item.h"
#include "ewk_context.h"
#include "ewk_cookie_manager.h"
#include "ewk_download_job.h"
diff --git a/Source/WebKit2/UIProcess/API/efl/EflViewportHandler.cpp b/Source/WebKit2/UIProcess/API/efl/EflViewportHandler.cpp
new file mode 100644
index 000000000..f5740822e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/efl/EflViewportHandler.cpp
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2012 Samsung Electronics. 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 "EflViewportHandler.h"
+
+#if USE(COORDINATED_GRAPHICS)
+
+#include "LayerTreeCoordinatorProxy.h"
+#include "LayerTreeRenderer.h"
+#include "TransformationMatrix.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+EflViewportHandler::EflViewportHandler(PageClientImpl* pageClientImpl)
+ : m_pageClientImpl(pageClientImpl)
+ , m_scaleFactor(1)
+{
+ ASSERT(m_pageClientImpl);
+}
+
+EflViewportHandler::~EflViewportHandler()
+{
+}
+
+void EflViewportHandler::display(const IntRect& rect)
+{
+ WebCore::TransformationMatrix matrix;
+ matrix.setMatrix(m_scaleFactor, 0, 0, m_scaleFactor, -m_visibleContentRect.x(), -m_visibleContentRect.y());
+
+ LayerTreeRenderer* renderer = drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer();
+ renderer->setActive(true);
+ renderer->syncRemoteContent();
+ renderer->paintToCurrentGLContext(matrix, 1, rect);
+}
+
+void EflViewportHandler::updateViewportSize(const IntSize& viewportSize)
+{
+ m_viewportSize = viewportSize;
+ m_pageClientImpl->page()->setViewportSize(viewportSize);
+ setVisibleContentsRect(m_visibleContentRect.location(), m_scaleFactor, FloatPoint());
+}
+
+void EflViewportHandler::setVisibleContentsRect(const IntPoint& newScrollPosition, float newScale, const FloatPoint& trajectory)
+{
+ m_scaleFactor = newScale;
+ m_visibleContentRect = IntRect(newScrollPosition, m_viewportSize);
+
+ // Move visibleContentRect inside contentsRect when visibleContentRect goes outside contentsRect.
+ IntSize contentsSize = m_contentsSize;
+ contentsSize.scale(m_scaleFactor);
+ if (m_visibleContentRect.x() > contentsSize.width() - m_visibleContentRect.width())
+ m_visibleContentRect.setX(contentsSize.width() - m_visibleContentRect.width());
+ if (m_visibleContentRect.x() < 0)
+ m_visibleContentRect.setX(0);
+ if (m_visibleContentRect.y() > contentsSize.height() - m_visibleContentRect.height())
+ m_visibleContentRect.setY(contentsSize.height() - m_visibleContentRect.height());
+ if (m_visibleContentRect.y() < 0)
+ m_visibleContentRect.setY(0);
+
+ FloatRect mapRectToWebContent = m_visibleContentRect;
+ mapRectToWebContent.scale(1 / m_scaleFactor);
+ drawingArea()->setVisibleContentsRect(enclosingIntRect(mapRectToWebContent), m_scaleFactor, trajectory);
+}
+
+void EflViewportHandler::didChangeContentsSize(const WebCore::IntSize& size)
+{
+ m_contentsSize = size;
+ setVisibleContentsRect(m_visibleContentRect.location(), m_scaleFactor, FloatPoint());
+ drawingArea()->layerTreeCoordinatorProxy()->setContentsSize(WebCore::FloatSize(size.width(), size.height()));
+}
+
+} // namespace WebKit
+#endif // USE(COORDINATED_GRAPHICS)
+
diff --git a/Source/WebKit2/UIProcess/API/efl/EflViewportHandler.h b/Source/WebKit2/UIProcess/API/efl/EflViewportHandler.h
new file mode 100644
index 000000000..cc6b3d957
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/efl/EflViewportHandler.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2012 Samsung Electronics. 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 EflViewportHandler_h
+#define EflViewportHandler_h
+
+#if USE(COORDINATED_GRAPHICS)
+
+#include "PageClientImpl.h"
+#include <wtf/PassOwnPtr.h>
+
+namespace WebKit {
+
+class EflViewportHandler {
+public:
+ static PassOwnPtr<EflViewportHandler> create(PageClientImpl* pageClientImpl)
+ {
+ return adoptPtr(new EflViewportHandler(pageClientImpl));
+ }
+ ~EflViewportHandler();
+
+ DrawingAreaProxy* drawingArea() const { return m_pageClientImpl->page()->drawingArea(); }
+ WebCore::IntSize viewSize() { return m_viewportSize; }
+
+ void display(const WebCore::IntRect& rect);
+ void updateViewportSize(const WebCore::IntSize& viewportSize);
+ void setVisibleContentsRect(const WebCore::IntPoint&, float, const WebCore::FloatPoint&);
+ void didChangeContentsSize(const WebCore::IntSize& size);
+
+private:
+ explicit EflViewportHandler(PageClientImpl*);
+
+ PageClientImpl* m_pageClientImpl;
+ WebCore::IntRect m_visibleContentRect;
+ WebCore::IntSize m_contentsSize;
+ WebCore::IntSize m_viewportSize;
+ float m_scaleFactor;
+};
+
+} // namespace WebKit
+
+#endif
+
+#endif // EflViewportHandler_h
diff --git a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp
index 79d20a17d..726caaae1 100644
--- a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp
+++ b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp
@@ -31,7 +31,9 @@
#include "NotImplemented.h"
#include "WebContext.h"
#include "WebContextMenuProxy.h"
+#include "WebPageGroup.h"
#include "WebPageProxy.h"
+#include "WebPreferences.h"
#include "ewk_context.h"
#include "ewk_context_private.h"
#include "ewk_download_job.h"
@@ -46,6 +48,13 @@ PageClientImpl::PageClientImpl(WebContext* context, WebPageGroup* pageGroup, Eva
: m_viewWidget(viewWidget)
{
m_page = context->createWebPage(this, pageGroup);
+
+#if USE(COORDINATED_GRAPHICS)
+ m_page->pageGroup()->preferences()->setAcceleratedCompositingEnabled(true);
+ m_page->pageGroup()->preferences()->setForceCompositingMode(true);
+ m_page->setUseFixedLayout(true);
+#endif
+
m_page->initializeWebPage();
}
@@ -295,4 +304,9 @@ void PageClientImpl::pageDidRequestScroll(const IntPoint&)
}
#endif
+void PageClientImpl::didChangeContentsSize(const WebCore::IntSize& size)
+{
+ ewk_view_contents_size_changed(m_viewWidget, size);
+}
+
} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.h b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.h
index 1bd22934a..861850263 100644
--- a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.h
+++ b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.h
@@ -112,6 +112,8 @@ private:
virtual void pageDidRequestScroll(const WebCore::IntPoint&);
#endif
+ virtual void didChangeContentsSize(const WebCore::IntSize&);
+
private:
RefPtr<WebPageProxy> m_page;
Evas_Object* m_viewWidget;
diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list.cpp
new file mode 100644
index 000000000..5b8e2d7ea
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list.cpp
@@ -0,0 +1,161 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. 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 "ewk_back_forward_list.h"
+
+#include "WKAPICast.h"
+#include "WKArray.h"
+#include "WKBackForwardList.h"
+#include "WKRetainPtr.h"
+#include "ewk_back_forward_list_item_private.h"
+#include <wtf/text/CString.h>
+
+using namespace WebKit;
+
+typedef HashMap<WKBackForwardListItemRef, Ewk_Back_Forward_List_Item*> ItemsMap;
+
+/**
+ * \struct _Ewk_Back_Forward_List
+ * @brief Contains the Back Forward List data.
+ */
+struct _Ewk_Back_Forward_List {
+ WKRetainPtr<WKBackForwardListRef> wkList;
+ mutable ItemsMap wrapperCache;
+
+ _Ewk_Back_Forward_List(WKBackForwardListRef listRef)
+ : wkList(listRef)
+ { }
+
+ ~_Ewk_Back_Forward_List()
+ {
+ ItemsMap::iterator it = wrapperCache.begin();
+ ItemsMap::iterator end = wrapperCache.end();
+ for (; it != end; ++it)
+ ewk_back_forward_list_item_unref(it->second);
+ }
+};
+
+#define EWK_BACK_FORWARD_LIST_WK_GET_OR_RETURN(list, wkList_, ...) \
+ if (!(list)) { \
+ EINA_LOG_CRIT("list is NULL."); \
+ return __VA_ARGS__; \
+ } \
+ if (!(list)->wkList) { \
+ EINA_LOG_CRIT("list->wkList is NULL."); \
+ return __VA_ARGS__; \
+ } \
+ WKBackForwardListRef wkList_ = (list)->wkList.get()
+
+
+static inline Ewk_Back_Forward_List_Item* addItemToWrapperCache(const Ewk_Back_Forward_List* list, WKBackForwardListItemRef wkItem)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(list, 0);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wkItem, 0);
+
+ Ewk_Back_Forward_List_Item* item = list->wrapperCache.get(wkItem);
+ if (!item) {
+ item = ewk_back_forward_list_item_new(wkItem);
+ list->wrapperCache.set(wkItem, item);
+ }
+
+ return item;
+}
+
+Ewk_Back_Forward_List_Item* ewk_back_forward_list_current_item_get(const Ewk_Back_Forward_List* list)
+{
+ EWK_BACK_FORWARD_LIST_WK_GET_OR_RETURN(list, wkList, 0);
+
+ return addItemToWrapperCache(list, WKBackForwardListGetCurrentItem(wkList));
+}
+
+Ewk_Back_Forward_List_Item* ewk_back_forward_list_previous_item_get(const Ewk_Back_Forward_List* list)
+{
+ EWK_BACK_FORWARD_LIST_WK_GET_OR_RETURN(list, wkList, 0);
+
+ return addItemToWrapperCache(list, WKBackForwardListGetBackItem(wkList));
+}
+
+Ewk_Back_Forward_List_Item* ewk_back_forward_list_next_item_get(const Ewk_Back_Forward_List* list)
+{
+ EWK_BACK_FORWARD_LIST_WK_GET_OR_RETURN(list, wkList, 0);
+
+ return addItemToWrapperCache(list, WKBackForwardListGetForwardItem(wkList));
+}
+
+Ewk_Back_Forward_List_Item* ewk_back_forward_list_item_at_index_get(const Ewk_Back_Forward_List* list, int index)
+{
+ EWK_BACK_FORWARD_LIST_WK_GET_OR_RETURN(list, wkList, 0);
+
+ return addItemToWrapperCache(list, WKBackForwardListGetItemAtIndex(wkList, index));
+}
+
+unsigned ewk_back_forward_list_count(Ewk_Back_Forward_List* list)
+{
+ EWK_BACK_FORWARD_LIST_WK_GET_OR_RETURN(list, wkList, 0);
+
+ const unsigned currentItem = ewk_back_forward_list_current_item_get(list) ? 1 : 0;
+
+ return WKBackForwardListGetBackListCount(wkList) + WKBackForwardListGetForwardListCount(wkList) + currentItem;
+}
+
+
+/**
+ * @internal
+ * Updates items cache.
+ */
+void ewk_back_forward_list_changed(Ewk_Back_Forward_List* list, WKBackForwardListItemRef wkAddedItem, WKArrayRef wkRemovedItems)
+{
+ addItemToWrapperCache(list, wkAddedItem); // Puts new item to the cache.
+
+ const size_t removedItemsSize = wkRemovedItems ? WKArrayGetSize(wkRemovedItems) : 0;
+ for (size_t i = 0; i < removedItemsSize; ++i) {
+ WKBackForwardListItemRef wkItem = static_cast<WKBackForwardListItemRef>(WKArrayGetItemAtIndex(wkRemovedItems, i));
+ if (Ewk_Back_Forward_List_Item* item = list->wrapperCache.take(wkItem))
+ ewk_back_forward_list_item_unref(item);
+ }
+}
+
+/**
+ * @internal
+ * Constructs a Ewk_Back_Forward_List from a WKBackForwardListRef.
+ */
+Ewk_Back_Forward_List* ewk_back_forward_list_new(WKBackForwardListRef wkBackForwardListRef)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wkBackForwardListRef, 0);
+
+ return new Ewk_Back_Forward_List(wkBackForwardListRef);
+}
+
+/**
+ * @internal
+ * Frees a Ewk_Back_Forward_List object.
+ */
+void ewk_back_forward_list_free(Ewk_Back_Forward_List* list)
+{
+ EINA_SAFETY_ON_NULL_RETURN(list);
+
+ delete list;
+}
diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list.h b/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list.h
new file mode 100644
index 000000000..5b9cca726
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list.h
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. 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.
+ */
+
+/**
+ * @file ewk_back_forward_list.h
+ * @brief Describes the Ewk Back Forward List API.
+ */
+
+#ifndef ewk_back_forward_list_h
+#define ewk_back_forward_list_h
+
+#include "ewk_back_forward_list_item.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** Creates a type name for _Ewk_Back_Forward_List */
+typedef struct _Ewk_Back_Forward_List Ewk_Back_Forward_List;
+
+/**
+ * Returns the current item in the @a list.
+ *
+ * @param list the back-forward list instance
+ *
+ * @return the current item in the @a list or @c NULL in case of error
+ */
+EAPI Ewk_Back_Forward_List_Item *ewk_back_forward_list_current_item_get(const Ewk_Back_Forward_List *list);
+
+/**
+ * Returns the item that precedes the current item in the @a list.
+ *
+ * @param list the back-forward list instance
+ *
+ * @return the item that precedes the current item the @a list or @c NULL in case of error
+ */
+EAPI Ewk_Back_Forward_List_Item *ewk_back_forward_list_previous_item_get(const Ewk_Back_Forward_List *list);
+
+/**
+ * Returns the item that follows the current item in the @a list.
+ *
+ * @param list the back-forward list instance
+ *
+ * @return the item that follows the current item in the @a list or @c NULL in case of error
+ */
+EAPI Ewk_Back_Forward_List_Item *ewk_back_forward_list_next_item_get(const Ewk_Back_Forward_List *list);
+
+/**
+ * Returns the item at a given @a index relative to the current item.
+ *
+ * @param list the back-forward list instance
+ * @param index the index of the item
+ *
+ * @return the item at a given @a index relative to the current item or @c NULL in case of error
+ */
+EAPI Ewk_Back_Forward_List_Item *ewk_back_forward_list_item_at_index_get(const Ewk_Back_Forward_List *list, int index);
+
+/**
+ * Returns the length of the back-forward list including current item.
+ *
+ * @param list the back-forward list instance
+ *
+ * @return the length of the back-forward list including current item or @c 0 in case of error
+ */
+EAPI unsigned ewk_back_forward_list_count(Ewk_Back_Forward_List *list);
+
+#ifdef __cplusplus
+}
+#endif
+#endif // ewk_back_forward_list_h
diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_item.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_item.cpp
new file mode 100644
index 000000000..a8586b23d
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_item.cpp
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. 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 item of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this item 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 "ewk_back_forward_list_item.h"
+
+#include "WKAPICast.h"
+#include "WKBackForwardListItem.h"
+#include "WKEinaSharedString.h"
+
+using namespace WebKit;
+
+/**
+ * \struct _Ewk_Back_Forward_List
+ * @brief Contains the Back Forward List data.
+ */
+struct _Ewk_Back_Forward_List_Item {
+ unsigned int __ref; /**< the reference count of the object */
+ WKRetainPtr<WKBackForwardListItemRef> wkItem;
+ WKEinaSharedString uri;
+ WKEinaSharedString title;
+ WKEinaSharedString originalUri;
+
+ _Ewk_Back_Forward_List_Item(WKBackForwardListItemRef itemRef)
+ : __ref(1)
+ , wkItem(itemRef)
+ , uri(AdoptWK, WKBackForwardListItemCopyURL(itemRef))
+ , title(AdoptWK, WKBackForwardListItemCopyTitle(itemRef))
+ , originalUri(AdoptWK, WKBackForwardListItemCopyOriginalURL(itemRef))
+ { }
+
+ ~_Ewk_Back_Forward_List_Item()
+ {
+ ASSERT(!__ref);
+ }
+};
+
+void ewk_back_forward_list_item_ref(Ewk_Back_Forward_List_Item* item)
+{
+ EINA_SAFETY_ON_NULL_RETURN(item);
+ ++item->__ref;
+}
+
+void ewk_back_forward_list_item_unref(Ewk_Back_Forward_List_Item* item)
+{
+ EINA_SAFETY_ON_NULL_RETURN(item);
+
+ if (--item->__ref)
+ return;
+
+ delete item;
+}
+
+const char* ewk_back_forward_list_item_uri_get(const Ewk_Back_Forward_List_Item* item)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(item, 0);
+
+ return item->uri;
+}
+
+const char* ewk_back_forward_list_item_title_get(const Ewk_Back_Forward_List_Item* item)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(item, 0);
+
+ return item->title;
+}
+
+const char* ewk_back_forward_list_item_original_uri_get(const Ewk_Back_Forward_List_Item* item)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(item, 0);
+
+ return item->originalUri;
+}
+
+Ewk_Back_Forward_List_Item* ewk_back_forward_list_item_new(WKBackForwardListItemRef backForwardListItemData)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(backForwardListItemData, 0);
+
+ return new Ewk_Back_Forward_List_Item(backForwardListItemData);
+}
diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_item.h b/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_item.h
new file mode 100644
index 000000000..811f0e104
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_item.h
@@ -0,0 +1,107 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. 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.
+ */
+
+/**
+ * @file ewk_back_forward_list_item.h
+ * @brief Describes the Ewk Back Forward List Item API.
+ */
+
+#ifndef ewk_back_forward_list_item_h
+#define ewk_back_forward_list_item_h
+
+#include <Eina.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** Creates a type name for _Ewk_Back_Forward_List_Item */
+typedef struct _Ewk_Back_Forward_List_Item Ewk_Back_Forward_List_Item;
+
+/**
+ * Increases the reference count of the given object.
+ *
+ * @param item the back-forward list item instance to increase the reference count
+ */
+EAPI void ewk_back_forward_list_item_ref(Ewk_Back_Forward_List_Item *item);
+
+/**
+ * Decreases the reference count of the given object, possibly freeing it.
+ *
+ * When the reference count reaches 0, the item is freed.
+ *
+ * @param item the back-forward list item instance to decrease the reference count
+ */
+EAPI void ewk_back_forward_list_item_unref(Ewk_Back_Forward_List_Item *item);
+
+/**
+ * Returns URI of the item.
+ *
+ * The returned URI may differ from the original URI (For example if the page was redirected).
+ *
+ * @see ewk_back_forward_list_item_original_uri_get()
+ *
+ * @param item the back-forward list item instance
+ *
+ * @return the URI of the @a item or @c NULL in case of error. This pointer is
+ * guaranteed to be eina_stringshare, so whenever possible
+ * save yourself some cpu cycles and use
+ * eina_stringshare_ref() instead of eina_stringshare_add() or
+ * strdup()
+ */
+EAPI const char *ewk_back_forward_list_item_uri_get(const Ewk_Back_Forward_List_Item *item);
+
+/**
+ * Returns title of the item.
+ *
+ * @param item the back-forward list item instance
+ *
+ * @return the title of the @a item or @c NULL in case of error. This pointer is
+ * guaranteed to be eina_stringshare, so whenever possible
+ * save yourself some cpu cycles and use
+ * eina_stringshare_ref() instead of eina_stringshare_add() or
+ * strdup()
+ */
+EAPI const char *ewk_back_forward_list_item_title_get(const Ewk_Back_Forward_List_Item *item);
+
+/**
+ * Returns original URI of the item.
+ *
+ * @see ewk_back_forward_list_item_uri_get()
+ *
+ * @param item the back-forward list item instance
+ *
+ * @return the original URI of the @a item or @c NULL in case of error. This pointer is
+ * guaranteed to be eina_stringshare, so whenever possible
+ * save yourself some cpu cycles and use
+ * eina_stringshare_ref() instead of eina_stringshare_add() or
+ * strdup()
+ */
+EAPI const char *ewk_back_forward_list_item_original_uri_get(const Ewk_Back_Forward_List_Item *item);
+
+#ifdef __cplusplus
+}
+#endif
+#endif // ewk_back_forward_list_item_h
diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_item_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_item_private.h
new file mode 100644
index 000000000..8c2c684d4
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_item_private.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. 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 item of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this item 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 ewk_back_forward_list_item_private_h
+#define ewk_back_forward_list_item_private_h
+
+#include <WebKit2/WKBase.h>
+
+typedef struct _Ewk_Back_Forward_List_Item Ewk_Back_Forward_List_Item;
+
+Ewk_Back_Forward_List_Item* ewk_back_forward_list_item_new(WKBackForwardListItemRef wkBackForwardListItemRef);
+
+#endif // ewk_back_forward_list_private_h
diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_private.h
new file mode 100644
index 000000000..592a4f48d
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_private.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. 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 ewk_back_forward_list_private_h
+#define ewk_back_forward_list_private_h
+
+#include <WebKit2/WKBase.h>
+
+typedef struct _Ewk_Back_Forward_List Ewk_Back_Forward_List;
+
+void ewk_back_forward_list_changed(Ewk_Back_Forward_List*, WKBackForwardListItemRef wkAddedItem, WKArrayRef wkRemovedItems);
+Ewk_Back_Forward_List* ewk_back_forward_list_new(WKBackForwardListRef wkBackForwardListRef);
+void ewk_back_forward_list_free(Ewk_Back_Forward_List* list);
+
+#endif // ewk_back_forward_list_private_h
diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp
index f2ed417fc..d6453757e 100644
--- a/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp
+++ b/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp
@@ -118,6 +118,17 @@ WKContextRef ewk_context_WKContext_get(const Ewk_Context* ewkContext)
/**
* @internal
+ * Create Ewk_Context from WKContext.
+ */
+Ewk_Context* ewk_context_new_from_WKContext(WKContextRef contextRef)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(contextRef, 0);
+
+ return new Ewk_Context(contextRef);
+}
+
+/**
+ * @internal
* Registers that a new download has been requested.
*/
void ewk_context_download_job_add(Ewk_Context* ewkContext, Ewk_Download_Job* ewkDownload)
@@ -189,7 +200,7 @@ void ewk_context_url_scheme_request_received(Ewk_Context* ewkContext, Ewk_Url_Sc
static inline Ewk_Context* createDefaultEwkContext()
{
- return new Ewk_Context(WKContextGetSharedProcessContext());
+ return new Ewk_Context(WKContextCreate());
}
Ewk_Context* ewk_context_default_get()
diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_context_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_context_private.h
index db9e911d2..d1b695e0c 100644
--- a/Source/WebKit2/UIProcess/API/efl/ewk_context_private.h
+++ b/Source/WebKit2/UIProcess/API/efl/ewk_context_private.h
@@ -27,6 +27,7 @@ typedef struct _Ewk_Download_Job Ewk_Download_Job;
typedef struct _Ewk_Url_Scheme_Request Ewk_Url_Scheme_Request;
WKContextRef ewk_context_WKContext_get(const Ewk_Context*);
+Ewk_Context* ewk_context_new_from_WKContext(WKContextRef);
WKSoupRequestManagerRef ewk_context_request_manager_get(const Ewk_Context*);
void ewk_context_url_scheme_request_received(Ewk_Context*, Ewk_Url_Scheme_Request*);
diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp
index b1b1bcc08..7d8b1ce05 100644
--- a/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp
+++ b/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp
@@ -26,17 +26,22 @@
#include "NativeWebWheelEvent.h"
#include "PageClientImpl.h"
#include "WKAPICast.h"
+#include "WKFindOptions.h"
#include "WKRetainPtr.h"
#include "WKString.h"
#include "WKURL.h"
+#include "ewk_back_forward_list_private.h"
#include "ewk_context.h"
#include "ewk_context_private.h"
#include "ewk_intent_private.h"
+#include "ewk_private.h"
+#include "ewk_view_find_client_private.h"
#include "ewk_view_form_client_private.h"
#include "ewk_view_loader_client_private.h"
#include "ewk_view_policy_client_private.h"
#include "ewk_view_private.h"
#include "ewk_view_resource_load_client_private.h"
+#include "ewk_view_ui_client_private.h"
#include "ewk_web_resource.h"
#include <Ecore_Evas.h>
#include <Edje.h>
@@ -48,6 +53,10 @@
#include <Evas_GL.h>
#endif
+#if USE(COORDINATED_GRAPHICS)
+#include "EflViewportHandler.h"
+#endif
+
using namespace WebKit;
using namespace WebCore;
@@ -60,6 +69,10 @@ static void _ewk_view_priv_loading_resources_clear(LoadingResourcesMap& loadingR
struct _Ewk_View_Private_Data {
OwnPtr<PageClientImpl> pageClient;
+#if USE(COORDINATED_GRAPHICS)
+ OwnPtr<EflViewportHandler> viewportHandler;
+#endif
+
const char* uri;
const char* title;
const char* theme;
@@ -67,6 +80,7 @@ struct _Ewk_View_Private_Data {
const char* cursorGroup;
Evas_Object* cursorObject;
LoadingResourcesMap loadingResourcesMap;
+ Ewk_Back_Forward_List* backForwardList;
#ifdef HAVE_ECORE_X
bool isUsingEcoreX;
@@ -85,6 +99,7 @@ struct _Ewk_View_Private_Data {
, customEncoding(0)
, cursorGroup(0)
, cursorObject(0)
+ , backForwardList(0)
#ifdef HAVE_ECORE_X
, isUsingEcoreX(false)
#endif
@@ -105,6 +120,8 @@ struct _Ewk_View_Private_Data {
if (cursorObject)
evas_object_del(cursorObject);
+
+ ewk_back_forward_list_free(backForwardList);
}
};
@@ -521,6 +538,10 @@ static void _ewk_view_smart_calculate(Evas_Object* ewkView)
evas_object_geometry_get(ewkView, &x, &y, &width, &height);
if (smartData->changed.size) {
+#if USE(COORDINATED_GRAPHICS)
+ priv->viewportHandler->updateViewportSize(IntSize(width, height));
+#endif
+
if (priv->pageClient->page()->drawingArea())
priv->pageClient->page()->drawingArea()->setSize(IntSize(width, height), IntSize());
@@ -590,7 +611,7 @@ static void _ewk_view_smart_color_set(Evas_Object* ewkView, int red, int green,
g_parentSmartClass.color_set(ewkView, red, green, blue, alpha);
}
-Eina_Bool ewk_view_smart_class_init(Ewk_View_Smart_Class* api)
+Eina_Bool ewk_view_smart_class_set(Ewk_View_Smart_Class* api)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(api, false);
@@ -635,16 +656,46 @@ static inline Evas_Smart* _ewk_view_smart_class_new(void)
static Evas_Smart* smart = 0;
if (EINA_UNLIKELY(!smart)) {
- ewk_view_smart_class_init(&api);
+ ewk_view_smart_class_set(&api);
smart = evas_smart_class_new(&api.sc);
}
return smart;
}
-Evas_Object* ewk_view_base_add(Evas* canvas, WKContextRef contextRef, WKPageGroupRef pageGroupRef)
+static void _ewk_view_initialize(Evas_Object* ewkView, Ewk_Context* context, WKPageGroupRef pageGroupRef)
+{
+ EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
+ EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
+ EINA_SAFETY_ON_NULL_RETURN(context);
+
+ if (priv->pageClient)
+ return;
+
+ priv->pageClient = PageClientImpl::create(toImpl(ewk_context_WKContext_get(context)), toImpl(pageGroupRef), ewkView);
+ priv->backForwardList = ewk_back_forward_list_new(toAPI(priv->pageClient->page()->backForwardList()));
+
+#if USE(COORDINATED_GRAPHICS)
+ priv->viewportHandler = EflViewportHandler::create(priv->pageClient.get());
+#endif
+
+ WKPageRef wkPage = toAPI(priv->pageClient->page());
+ ewk_view_find_client_attach(wkPage, ewkView);
+ ewk_view_form_client_attach(wkPage, ewkView);
+ ewk_view_loader_client_attach(wkPage, ewkView);
+ ewk_view_policy_client_attach(wkPage, ewkView);
+ ewk_view_resource_load_client_attach(wkPage, ewkView);
+ ewk_view_ui_client_attach(wkPage, ewkView);
+
+ ewk_view_theme_set(ewkView, DEFAULT_THEME_PATH"/default.edj");
+}
+
+static Evas_Object* _ewk_view_add_with_smart(Evas* canvas, Evas_Smart* smart)
{
- Evas_Object* ewkView = evas_object_smart_add(canvas, _ewk_view_smart_class_new());
+ EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(smart, 0);
+
+ Evas_Object* ewkView = evas_object_smart_add(canvas, smart);
if (!ewkView)
return 0;
@@ -660,22 +711,44 @@ Evas_Object* ewk_view_base_add(Evas* canvas, WKContextRef contextRef, WKPageGrou
return 0;
}
- priv->pageClient = PageClientImpl::create(toImpl(contextRef), toImpl(pageGroupRef), ewkView);
+ return ewkView;
+}
- WKPageRef wkPage = toAPI(priv->pageClient->page());
- ewk_view_form_client_attach(wkPage, ewkView);
- ewk_view_loader_client_attach(wkPage, ewkView);
- ewk_view_policy_client_attach(wkPage, ewkView);
- ewk_view_resource_load_client_attach(wkPage, ewkView);
+/**
+ * @internal
+ * Constructs a ewk_view Evas_Object with WKType parameters.
+ */
+Evas_Object* ewk_view_base_add(Evas* canvas, WKContextRef contextRef, WKPageGroupRef pageGroupRef)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(contextRef, 0);
+ Evas_Object* ewkView = _ewk_view_add_with_smart(canvas, _ewk_view_smart_class_new());
+ if (!ewkView)
+ return 0;
- ewk_view_theme_set(ewkView, DEFAULT_THEME_PATH"/default.edj");
+ _ewk_view_initialize(ewkView, ewk_context_new_from_WKContext(contextRef), pageGroupRef);
+
+ return ewkView;
+}
+
+Evas_Object* ewk_view_smart_add(Evas* canvas, Evas_Smart* smart, Ewk_Context* context)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(smart, 0);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
+
+ Evas_Object* ewkView = _ewk_view_add_with_smart(canvas, smart);
+ if (!ewkView)
+ return 0;
+
+ _ewk_view_initialize(ewkView, context, 0);
return ewkView;
}
Evas_Object* ewk_view_add_with_context(Evas* canvas, Ewk_Context* context)
{
- return ewk_view_base_add(canvas, ewk_context_WKContext_get(context), 0);
+ return ewk_view_smart_add(canvas, _ewk_view_smart_class_new(), context);
}
Evas_Object* ewk_view_add(Evas* canvas)
@@ -867,6 +940,17 @@ const char* ewk_view_title_get(const Evas_Object* ewkView)
/**
* @internal
+ * Reports that the requested text was found.
+ *
+ * Emits signal: "text,found" with the number of matches.
+ */
+void ewk_view_text_found(Evas_Object* ewkView, unsigned int matchCount)
+{
+ evas_object_smart_callback_call(ewkView, "text,found", &matchCount);
+}
+
+/**
+ * @internal
* The view title was changed by the frame loader.
*
* Emits signal: "title,changed" with pointer to new title string.
@@ -1020,6 +1104,13 @@ void ewk_view_display(Evas_Object* ewkView, const IntRect& rect)
if (!smartData->image)
return;
+#if USE(COORDINATED_GRAPHICS)
+ EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
+
+ evas_gl_make_current(priv->evasGl, priv->evasGlSurface, priv->evasGlContext);
+ priv->viewportHandler->display(rect);
+#endif
+
evas_object_image_data_update_add(smartData->image, rect.x(), rect.y(), rect.width(), rect.height());
}
@@ -1128,6 +1219,14 @@ Eina_Bool ewk_view_forward_possible(Evas_Object* ewkView)
return priv->pageClient->page()->canGoForward();
}
+Ewk_Back_Forward_List* ewk_view_back_forward_list_get(const Evas_Object* ewkView)
+{
+ EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
+ EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
+
+ return priv->backForwardList;
+}
+
void ewk_view_image_data_set(Evas_Object* ewkView, void* imageData, const IntSize& size)
{
EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
@@ -1297,3 +1396,61 @@ Eina_Bool ewk_view_setting_encoding_custom_set(Evas_Object* ewkView, const char*
return true;
}
+
+void ewk_view_page_close(Evas_Object* ewkView)
+{
+ evas_object_smart_callback_call(ewkView, "close,window", 0);
+}
+
+WKPageRef ewk_view_page_create(Evas_Object* ewkView)
+{
+ Evas_Object* newEwkView = 0;
+ evas_object_smart_callback_call(ewkView, "create,window", &newEwkView);
+
+ if (!newEwkView)
+ return 0;
+
+ return static_cast<WKPageRef>(WKRetain(ewk_view_page_get(newEwkView)));
+}
+
+// EwkFindOptions should be matched up orders with WkFindOptions.
+COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_CASE_INSENSITIVE, kWKFindOptionsCaseInsensitive);
+COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_AT_WORD_STARTS, kWKFindOptionsAtWordStarts);
+COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_TREAT_MEDIAL_CAPITAL_AS_WORD_START, kWKFindOptionsTreatMedialCapitalAsWordStart);
+COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_BACKWARDS, kWKFindOptionsBackwards);
+COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_WRAP_AROUND, kWKFindOptionsWrapAround);
+COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_SHOW_OVERLAY, kWKFindOptionsShowOverlay);
+COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_SHOW_FIND_INDICATOR, kWKFindOptionsShowFindIndicator);
+COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_SHOW_HIGHLIGHT, kWKFindOptionsShowHighlight);
+
+Eina_Bool ewk_view_text_find(Evas_Object* ewkView, const char* text, Ewk_Find_Options options, unsigned int maxMatchCount)
+{
+ EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
+ EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(text, false);
+
+ WKRetainPtr<WKStringRef> findText(AdoptWK, WKStringCreateWithUTF8CString(text));
+ WKPageFindString(toAPI(priv->pageClient->page()), findText.get(), static_cast<WKFindOptions>(options), maxMatchCount);
+
+ return true;
+}
+
+Eina_Bool ewk_view_text_find_highlight_clear(Evas_Object* ewkView)
+{
+ EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
+ EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
+
+ WKPageHideFindUI(toAPI(priv->pageClient->page()));
+
+ return true;
+}
+
+void ewk_view_contents_size_changed(const Evas_Object* ewkView, const IntSize& size)
+{
+#if USE(COORDINATED_GRAPHICS)
+ EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
+ EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
+
+ priv->viewportHandler->didChangeContentsSize(size);
+#endif
+}
diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view.h b/Source/WebKit2/UIProcess/API/efl/ewk_view.h
index 057f725bd..423f9e143 100644
--- a/Source/WebKit2/UIProcess/API/efl/ewk_view.h
+++ b/Source/WebKit2/UIProcess/API/efl/ewk_view.h
@@ -26,6 +26,8 @@
*
* The following signals (see evas_object_smart_callback_add()) are emitted:
*
+ * - "close,window", void: window is closed.
+ * - "create,window", Evas_Object**: a new window is created.
* - "download,cancelled", Ewk_Download_Job*: reports that a download was effectively cancelled.
* - "download,failed", Ewk_Download_Job_Error*: reports that a download failed with the given error.
* - "download,finished", Ewk_Download_Job*: reports that a download completed successfully.
@@ -59,6 +61,7 @@
* - "resource,request,new", const Ewk_Web_Resource_Request*: a resource request was initiated.
* - "resource,request,response", Ewk_Web_Resource_Load_Response*: a response to a resource request was received.
* - "resource,request,sent", const Ewk_Web_Resource_Request*: a resource request was sent.
+ * - "text,found", unsigned int*: the requested text was found and it gives the number of matches.
* - "title,changed", const char*: title of the main frame was changed.
* - "uri,changed", const char*: uri of the main frame was changed.
*/
@@ -66,6 +69,7 @@
#ifndef ewk_view_h
#define ewk_view_h
+#include "ewk_back_forward_list.h"
#include "ewk_context.h"
#include "ewk_download_job.h"
#include "ewk_intent.h"
@@ -216,6 +220,62 @@ struct _Ewk_Download_Job_Error {
};
/**
+ * Enum values used to specify search options.
+ * @brief Provides option to find text
+ * @info Keep this in sync with WKFindOptions.h
+ */
+enum _Ewk_Find_Options {
+ EWK_FIND_OPTIONS_NONE, /**< no search flags, this means a case sensitive, no wrap, forward only search. */
+ EWK_FIND_OPTIONS_CASE_INSENSITIVE = 1 << 0, /**< case insensitive search. */
+ EWK_FIND_OPTIONS_AT_WORD_STARTS = 1 << 1, /**< search text only at the beginning of the words. */
+ EWK_FIND_OPTIONS_TREAT_MEDIAL_CAPITAL_AS_WORD_START = 1 << 2, /**< treat capital letters in the middle of words as word start. */
+ EWK_FIND_OPTIONS_BACKWARDS = 1 << 3, /**< search backwards. */
+ EWK_FIND_OPTIONS_WRAP_AROUND = 1 << 4, /**< if not present search will stop at the end of the document. */
+ EWK_FIND_OPTIONS_SHOW_OVERLAY = 1 << 5, /**< show overlay */
+ EWK_FIND_OPTIONS_SHOW_FIND_INDICATOR = 1 << 6, /**< show indicator */
+ EWK_FIND_OPTIONS_SHOW_HIGHLIGHT = 1 << 7 /**< show highlight */
+};
+typedef enum _Ewk_Find_Options Ewk_Find_Options;
+
+/**
+ * Sets the smart class APIs, enabling view to be inherited.
+ *
+ * @param api class definition to set, all members with the
+ * exception of @a Evas_Smart_Class->data may be overridden, must
+ * @b not be @c NULL
+ *
+ * @note @a Evas_Smart_Class->data is used to implement type checking and
+ * is not supposed to be changed/overridden. If you need extra
+ * data for your smart class to work, just extend
+ * Ewk_View_Smart_Class instead.
+ * The Evas_Object which inherits the ewk_view should use
+ * ewk_view_smart_add() to create Evas_Object instead of
+ * evas_object_smart_add() because it performs additional initialization
+ * for the ewk_view.
+ *
+ * @return @c EINA_TRUE on success or @c EINA_FALSE on failure (probably
+ * version mismatch)
+ *
+ * @see ewk_view_smart_add()
+ */
+EAPI Eina_Bool ewk_view_smart_class_set(Ewk_View_Smart_Class *api);
+
+/**
+ * Creates a new EFL WebKit view object with Evas_Smart and Ewk_Context.
+ *
+ * @note The Evas_Object which inherits the ewk_view should create its
+ * Evas_Object using this API instead of evas_object_smart_add()
+ * because the default initialization for ewk_view is done in this API.
+ *
+ * @param e canvas object where to create the view object
+ * @param smart Evas_Smart object. Its type should be EWK_VIEW_TYPE_STR
+ * @param context Ewk_Context object which is used for initializing
+ *
+ * @return view object on success or @c NULL on failure
+ */
+Evas_Object *ewk_view_smart_add(Evas *e, Evas_Smart *smart, Ewk_Context *context);
+
+/**
* Creates a new EFL WebKit view object.
*
* @param e canvas object where to create the view object
@@ -336,6 +396,21 @@ EAPI Eina_Bool ewk_view_back_possible(Evas_Object *o);
EAPI Eina_Bool ewk_view_forward_possible(Evas_Object *o);
/**
+ * Gets the back-forward list associated with this view.
+ *
+ * The returned instance is unique for this view and thus multiple calls
+ * to this function with the same view as parameter returns the same
+ * handle. This handle is alive while view is alive, thus one
+ * might want to listen for EVAS_CALLBACK_DEL on given view
+ * (@a o) to know when to stop using returned handle.
+ *
+ * @param o view object to get navigation back-forward list
+ *
+ * @return the back-forward list instance handle associated with this view
+ */
+EAPI Ewk_Back_Forward_List *ewk_view_back_forward_list_get(const Evas_Object *o);
+
+/**
* Gets the current title of the main frame.
*
* It returns an internal string and should not
@@ -494,6 +569,27 @@ EAPI const char *ewk_view_setting_encoding_custom_get(const Evas_Object *o);
*/
EAPI Eina_Bool ewk_view_setting_encoding_custom_set(Evas_Object *o, const char *encoding);
+/**
+* Searches the given string in the document.
+*
+* @param o view object to find text
+* @param text text to find
+* @param options options to find
+* @param max count to find, unlimited if 0
+*
+* @return @c EINA_TRUE on success, @c EINA_FALSE on errors
+*/
+EAPI Eina_Bool ewk_view_text_find(Evas_Object *o, const char *text, Ewk_Find_Options options, unsigned int max_match_count);
+
+/**
+* Clears the highlight of searched text.
+*
+* @param o view object to find text
+*
+* @return @c EINA_TRUE on success, @c EINA_FALSE on errors
+*/
+EAPI Eina_Bool ewk_view_text_find_highlight_clear(Evas_Object *o);
+
#ifdef __cplusplus
}
#endif
diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view_find_client.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_view_find_client.cpp
new file mode 100644
index 000000000..2a0dacaa3
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/efl/ewk_view_find_client.cpp
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2012 Samsung Electronics. 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 "WKPage.h"
+#include "ewk_view_find_client_private.h"
+#include "ewk_view_private.h"
+
+static inline Evas_Object* toEwkView(const void* clientInfo)
+{
+ return static_cast<Evas_Object*>(const_cast<void*>(clientInfo));
+}
+
+static void didFindString(WKPageRef page, WKStringRef string, unsigned matchCount, const void* clientInfo)
+{
+ ewk_view_text_found(toEwkView(clientInfo), static_cast<unsigned int>(matchCount));
+}
+
+void ewk_view_find_client_attach(WKPageRef pageRef, Evas_Object* ewkView)
+{
+ WKPageFindClient findClient;
+ memset(&findClient, 0, sizeof(WKPageFindClient));
+ findClient.version = kWKPageFindClientCurrentVersion;
+ findClient.clientInfo = ewkView;
+ findClient.didFindString = didFindString;
+ WKPageSetPageFindClient(pageRef, &findClient);
+}
diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view_find_client_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_view_find_client_private.h
new file mode 100644
index 000000000..c17143360
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/efl/ewk_view_find_client_private.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2012 Samsung Electronics. 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 ewk_view_find_client_private_h
+#define ewk_view_find_client_private_h
+
+#include <Evas.h>
+#include <WebKit2/WKBase.h>
+
+void ewk_view_find_client_attach(WKPageRef pageRef, Evas_Object* ewkView);
+
+#endif // ewk_view_find_client_private_h
diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view_loader_client.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_view_loader_client.cpp
index cc8b120cd..2deb38e19 100644
--- a/Source/WebKit2/UIProcess/API/efl/ewk_view_loader_client.cpp
+++ b/Source/WebKit2/UIProcess/API/efl/ewk_view_loader_client.cpp
@@ -24,8 +24,10 @@
*/
#include "config.h"
+#include "ewk_view.h"
#include "WKFrame.h"
+#include "ewk_back_forward_list_private.h"
#include "ewk_intent.h"
#include "ewk_intent_private.h"
#include "ewk_intent_service.h"
@@ -123,6 +125,14 @@ static void didFailProvisionalLoadWithErrorForFrame(WKPageRef page, WKFrameRef f
ewk_web_error_free(ewkError);
}
+static void didChangeBackForwardList(WKPageRef page, WKBackForwardListItemRef addedItem, WKArrayRef removedItems, const void* clientInfo)
+{
+ Evas_Object* ewkView = static_cast<Evas_Object*>(const_cast<void*>(clientInfo));
+ ASSERT(ewkView);
+
+ ewk_back_forward_list_changed(ewk_view_back_forward_list_get(ewkView), addedItem, removedItems);
+}
+
void ewk_view_loader_client_attach(WKPageRef pageRef, Evas_Object* ewkView)
{
WKPageLoaderClient loadClient;
@@ -144,5 +154,6 @@ void ewk_view_loader_client_attach(WKPageRef pageRef, Evas_Object* ewkView)
loadClient.didStartProvisionalLoadForFrame = didStartProvisionalLoadForFrame;
loadClient.didReceiveServerRedirectForProvisionalLoadForFrame = didReceiveServerRedirectForProvisionalLoadForFrame;
loadClient.didFailProvisionalLoadWithErrorForFrame = didFailProvisionalLoadWithErrorForFrame;
+ loadClient.didChangeBackForwardList = didChangeBackForwardList;
WKPageSetPageLoaderClient(pageRef, &loadClient);
}
diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h
index 3b57a7618..f40298587 100644
--- a/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h
+++ b/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h
@@ -61,12 +61,16 @@ void ewk_view_load_provisional_redirect(Evas_Object* ewkView);
void ewk_view_load_provisional_started(Evas_Object* ewkView);
void ewk_view_navigation_policy_decision(Evas_Object* ewkView, Ewk_Navigation_Policy_Decision* decision);
void ewk_view_new_window_policy_decision(Evas_Object* ewkView, Ewk_Navigation_Policy_Decision* decision);
+void ewk_view_page_close(Evas_Object* ewkView);
+WKPageRef ewk_view_page_create(Evas_Object* ewkView);
void ewk_view_title_changed(Evas_Object* ewkView, const char* title);
void ewk_view_resource_load_failed(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Web_Error* error);
void ewk_view_resource_load_finished(Evas_Object* ewkView, uint64_t resourceIdentifier);
void ewk_view_resource_load_initiated(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Web_Resource* resource, Ewk_Url_Request* request);
void ewk_view_resource_load_response(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Url_Response* response);
void ewk_view_resource_request_sent(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Url_Request* request, Ewk_Url_Response* redirectResponse);
+void ewk_view_text_found(Evas_Object* ewkView, unsigned int matchCount);
+void ewk_view_contents_size_changed(const Evas_Object* ewkView, const WebCore::IntSize&);
Evas_Object* ewk_view_base_add(Evas* canvas, WKContextRef, WKPageGroupRef);
diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view_ui_client.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_view_ui_client.cpp
new file mode 100644
index 000000000..18ede08a1
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/efl/ewk_view_ui_client.cpp
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2012 Samsung Electronics. 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 "ewk_view_private.h"
+#include "ewk_view_ui_client_private.h"
+
+static inline Evas_Object* toEwkView(const void* clientInfo)
+{
+ return static_cast<Evas_Object*>(const_cast<void*>(clientInfo));
+}
+
+static void closePage(WKPageRef, const void* clientInfo)
+{
+ ewk_view_page_close(toEwkView(clientInfo));
+}
+
+static WKPageRef createNewPage(WKPageRef, WKURLRequestRef, WKDictionaryRef, WKEventModifiers, WKEventMouseButton, const void* clientInfo)
+{
+ return ewk_view_page_create(toEwkView(clientInfo));
+}
+
+void ewk_view_ui_client_attach(WKPageRef pageRef, Evas_Object* ewkView)
+{
+ WKPageUIClient uiClient;
+ memset(&uiClient, 0, sizeof(WKPageUIClient));
+ uiClient.version = kWKPageUIClientCurrentVersion;
+ uiClient.clientInfo = ewkView;
+ uiClient.close = closePage;
+ uiClient.createNewPage = createNewPage;
+ WKPageSetPageUIClient(pageRef, &uiClient);
+}
diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view_ui_client_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_view_ui_client_private.h
new file mode 100644
index 000000000..4c9c492a5
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/efl/ewk_view_ui_client_private.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2012 Samsung Electronics. 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 ewk_view_ui_client_private_h
+#define ewk_view_ui_client_private_h
+
+#include <Evas.h>
+#include <WebKit2/WKBase.h>
+
+void ewk_view_ui_client_attach(WKPageRef pageRef, Evas_Object* ewkView);
+
+#endif // ewk_view_ui_client_private_h
diff --git a/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp b/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp
index 8ecd480e5..5a6adae0a 100644
--- a/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp
@@ -142,6 +142,9 @@ void PageClientImpl::toolTipChanged(const String&, const String& newToolTip)
void PageClientImpl::setCursor(const Cursor& cursor)
{
+ if (!gtk_widget_get_realized(m_viewWidget))
+ return;
+
// [GTK] Widget::setCursor() gets called frequently
// http://bugs.webkit.org/show_bug.cgi?id=16388
// Setting the cursor may be an expensive operation in some backends,
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardListPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardListPrivate.h
index e01909201..333e68d18 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardListPrivate.h
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardListPrivate.h
@@ -28,7 +28,7 @@
#include "WebBackForwardList.h"
#include "WebKitBackForwardList.h"
-#include <WebKit2/WebKit2.h>
+#include <WebKit2/WebKit2_C.h>
WebKitBackForwardList* webkitBackForwardListCreate(WKBackForwardListRef);
WebKitBackForwardListItem* webkitBackForwardListItemGetOrCreate(WKBackForwardListItemRef);
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitLoaderClient.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitLoaderClient.cpp
index 8cd149c5b..6c3bf920a 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitLoaderClient.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitLoaderClient.cpp
@@ -65,16 +65,7 @@ static void didCommitLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef us
if (!WKFrameIsMainFrame(frame))
return;
- WebKitWebView* webView = WEBKIT_WEB_VIEW(clientInfo);
- WebKitWebResource* resource = webkit_web_view_get_main_resource(webView);
- if (resource) {
- // We might not have a resource if this load is a content replacement.
- // FIXME: For some reason, when going back/forward this callback is emitted even before
- // didInitiateLoadForResource(), so we don't have a main resource at this point either.
- webkitURIResponseSetCertificateInfo(webkit_web_resource_get_response(resource), WKFrameGetCertificateInfo(frame));
- }
-
- webkitWebViewLoadChanged(webView, WEBKIT_LOAD_COMMITTED);
+ webkitWebViewLoadChanged(WEBKIT_WEB_VIEW(clientInfo), WEBKIT_LOAD_COMMITTED);
}
static void didFinishLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitPolicyDecisionPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitPolicyDecisionPrivate.h
index 62580c83e..e02caab64 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitPolicyDecisionPrivate.h
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitPolicyDecisionPrivate.h
@@ -21,7 +21,7 @@
#define WebKitPolicyDecisionPrivate_h
#include "WebKitPolicyDecision.h"
-#include <WebKit2/WebKit2.h>
+#include <WebKit2/WebKit2_C.h>
void webkitPolicyDecisionSetListener(WebKitPolicyDecision*, WKFramePolicyListenerRef);
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h
index aa8a71bf9..8fede827f 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h
@@ -41,7 +41,7 @@
#include <WebKit2/WKSoupRequestManager.h>
#include <WebKit2/WKString.h>
#include <WebKit2/WKTextChecker.h>
-#include <WebKit2/WebKit2.h>
+#include <WebKit2/WebKit2_C.h>
#include <glib.h>
#include <wtf/Assertions.h>
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitSettingsPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitSettingsPrivate.h
index a47ac7f74..4e5d23217 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitSettingsPrivate.h
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitSettingsPrivate.h
@@ -27,7 +27,7 @@
#define WebKitSettingsPrivate_h
#include "WebKitSettings.h"
-#include <WebKit2/WebKit2.h>
+#include <WebKit2/WebKit2_C.h>
void webkitSettingsAttachSettingsToPage(WebKitSettings*, WKPageRef);
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.cpp
index 5676bb6d7..5ae62c6fd 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.cpp
@@ -140,13 +140,15 @@ void WebKitTextChecker::setSpellCheckingEnabled(bool enabled)
WKTextCheckerContinuousSpellCheckingEnabledStateChanged(enabled);
}
-void WebKitTextChecker::setSpellCheckingLanguages(const String& languages)
+const CString& WebKitTextChecker::getSpellCheckingLanguages()
{
- if (m_spellCheckingLanguages == languages)
- return;
- m_spellCheckingLanguages = languages;
+ String spellCheckingLanguages = m_textChecker->getSpellCheckingLanguages();
+ m_spellCheckingLanguages = spellCheckingLanguages.isEmpty() ? CString() : spellCheckingLanguages.utf8();
+ return m_spellCheckingLanguages;
+}
- // We need to update the languages in the enchant-based checker too.
- m_textChecker->updateSpellCheckingLanguages(languages);
+void WebKitTextChecker::setSpellCheckingLanguages(const CString& languages)
+{
+ m_textChecker->updateSpellCheckingLanguages(String::fromUTF8(languages.data()));
}
#endif // ENABLE(SPELLCHECK)
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.h b/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.h
index dd7583a3a..3cca5622a 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.h
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.h
@@ -26,6 +26,7 @@
#include <wtf/FastAllocBase.h>
#include <wtf/PassOwnPtr.h>
#include <wtf/Vector.h>
+#include <wtf/text/CString.h>
class WebKitTextChecker {
WTF_MAKE_FAST_ALLOCATED;
@@ -43,14 +44,14 @@ public:
void ignoreWord(const String& word);
// To be called from WebKitWebContext only.
- const String getSpellCheckingLanguages() { return m_spellCheckingLanguages; }
- void setSpellCheckingLanguages(const String& spellCheckingLanguages);
+ const CString& getSpellCheckingLanguages();
+ void setSpellCheckingLanguages(const CString& spellCheckingLanguages);
private:
WebKitTextChecker();
OwnPtr<WebCore::TextCheckerEnchant> m_textChecker;
- String m_spellCheckingLanguages;
+ CString m_spellCheckingLanguages;
bool m_spellCheckingEnabled;
};
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp
index 4008e865f..fe9df9f75 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp
@@ -77,7 +77,6 @@ struct _WebKitWebContextPrivate {
#endif
#if ENABLE(SPELLCHECK)
OwnPtr<WebKitTextChecker> textChecker;
- GOwnPtr<gchar> spellCheckingLanguages;
#endif
};
@@ -125,7 +124,7 @@ static void webkit_web_context_class_init(WebKitWebContextClass* webContextClass
static gpointer createDefaultWebContext(gpointer)
{
static GRefPtr<WebKitWebContext> webContext = adoptGRef(WEBKIT_WEB_CONTEXT(g_object_new(WEBKIT_TYPE_WEB_CONTEXT, NULL)));
- webContext->priv->context = WKContextGetSharedProcessContext();
+ webContext->priv->context = WKContextCreate();
webContext->priv->requestManager = WKContextGetSoupRequestManager(webContext->priv->context.get());
WKContextSetCacheModel(webContext->priv->context.get(), kWKCacheModelPrimaryWebBrowser);
attachDownloadClientToContext(webContext.get());
@@ -432,7 +431,7 @@ void webkit_web_context_register_uri_scheme(WebKitWebContext* context, const cha
* webkit_web_context_get_spell_checking_enabled:
* @context: a #WebKitWebContext
*
- * Get the current status of the spell checking feature.
+ * Get whether spell checking feature is currently enabled.
*
* Returns: %TRUE If spell checking is enabled, or %FALSE otherwise.
*/
@@ -468,18 +467,24 @@ void webkit_web_context_set_spell_checking_enabled(WebKitWebContext* context, gb
* @context: a #WebKitWebContext
*
* Get the the list of spell checking languages associated with
- * @context, separated by commas. See
- * webkit_web_context_set_spell_checking_languages() for more details
- * on the format of the languages in the list.
+ * @context separated by commas, or %NULL if no languages have been
+ * previously set.
+
+ * See webkit_web_context_set_spell_checking_languages() for more
+ * details on the format of the languages in the list.
*
- * Returns: (transfer none): A comma separated list of languages.
+ * Returns: (transfer none): A comma separated list of languages if
+ * available, or %NULL otherwise.
*/
const gchar* webkit_web_context_get_spell_checking_languages(WebKitWebContext* context)
{
g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), 0);
#if ENABLE(SPELLCHECK)
- return context->priv->spellCheckingLanguages.get();
+ CString spellCheckingLanguages = context->priv->textChecker->getSpellCheckingLanguages();
+ if (spellCheckingLanguages.isNull())
+ return 0;
+ return spellCheckingLanguages.data();
#else
return 0;
#endif
@@ -488,25 +493,28 @@ const gchar* webkit_web_context_get_spell_checking_languages(WebKitWebContext* c
/**
* webkit_web_context_set_spell_checking_languages:
* @context: a #WebKitWebContext
- * @languages: (allow-none): new list of spell checking
- * languages separated by commas, or %NULL
+ * @languages: new list of spell checking languages separated by
+ * commas
*
* Set the list of spell checking languages to be used for spell
- * checking, separated by commas. In case %NULL is passed, the default
- * value as returned by gtk_get_default_language() will be used.
+ * checking, separated by commas.
*
* The locale string typically is in the form lang_COUNTRY, where lang
* is an ISO-639 language code, and COUNTRY is an ISO-3166 country code.
* For instance, sv_FI for Swedish as written in Finland or pt_BR
* for Portuguese as written in Brazil.
+ *
+ * You need to call this function with a valid list of languages at
+ * least once in order to properly enable the spell checking feature
+ * in WebKit.
*/
void webkit_web_context_set_spell_checking_languages(WebKitWebContext* context, const gchar* languages)
{
g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context));
+ g_return_if_fail(languages);
#if ENABLE(SPELLCHECK)
- context->priv->textChecker->setSpellCheckingLanguages(String(languages));
- context->priv->spellCheckingLanguages.set(g_strdup(languages));
+ context->priv->textChecker->setSpellCheckingLanguages(languages);
#endif
}
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebResource.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebResource.cpp
index 7fbe28a0a..5ca5e989d 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebResource.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebResource.cpp
@@ -243,6 +243,11 @@ void webkitWebResourceFailed(WebKitWebResource* resource, GError* error)
g_signal_emit(resource, signals[FINISHED], 0, NULL);
}
+WKFrameRef webkitWebResourceGetFrame(WebKitWebResource* resource)
+{
+ return resource->priv->wkFrame.get();
+}
+
/**
* webkit_web_resource_get_uri:
* @resource: a #WebKitWebResource
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebResourcePrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebResourcePrivate.h
index 5011ae4dd..ed1fe02f1 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebResourcePrivate.h
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebResourcePrivate.h
@@ -29,6 +29,7 @@ void webkitWebResourceSetResponse(WebKitWebResource*, WebKitURIResponse*);
void webkitWebResourceNotifyProgress(WebKitWebResource*, guint64 bytesReceived);
void webkitWebResourceFinished(WebKitWebResource*);
void webkitWebResourceFailed(WebKitWebResource*, GError*);
+WKFrameRef webkitWebResourceGetFrame(WebKitWebResource*);
#endif // WebKitWebResourcePrivate_h
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
index 8bf4d8fe0..80e5fff23 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
@@ -124,6 +124,10 @@ struct _WebKitWebViewPrivate {
CString activeURI;
ReplaceContentStatus replaceContentStatus;
+ bool waitingForMainResource;
+ gulong mainResourceResponseHandlerID;
+ WebKitLoadEvent lastDelayedEvent;
+
GRefPtr<WebKitBackForwardList> backForwardList;
GRefPtr<WebKitSettings> settings;
GRefPtr<WebKitWindowProperties> windowProperties;
@@ -268,6 +272,14 @@ static void webkitWebViewDisconnectSettingsSignalHandlers(WebKitWebView* webView
}
+static void webkitWebViewDisconnectMainResourceResponseChangedSignalHandler(WebKitWebView* webView)
+{
+ WebKitWebViewPrivate* priv = webView->priv;
+ if (priv->mainResourceResponseHandlerID)
+ g_signal_handler_disconnect(priv->mainResource.get(), priv->mainResourceResponseHandlerID);
+ priv->mainResourceResponseHandlerID = 0;
+}
+
static void fileChooserDialogResponseCallback(GtkDialog* dialog, gint responseID, WebKitFileChooserRequest* request)
{
GRefPtr<WebKitFileChooserRequest> adoptedRequest = adoptGRef(request);
@@ -382,7 +394,8 @@ static void webkitWebViewGetProperty(GObject* object, guint propId, GValue* valu
static void webkitWebViewFinalize(GObject* object)
{
- WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW(object)->priv;
+ WebKitWebView* webView = WEBKIT_WEB_VIEW(object);
+ WebKitWebViewPrivate* priv = webView->priv;
if (priv->javascriptGlobalContext)
JSGlobalContextRelease(priv->javascriptGlobalContext);
@@ -391,7 +404,8 @@ static void webkitWebViewFinalize(GObject* object)
if (priv->modalLoop && g_main_loop_is_running(priv->modalLoop.get()))
g_main_loop_quit(priv->modalLoop.get());
- webkitWebViewDisconnectSettingsSignalHandlers(WEBKIT_WEB_VIEW(object));
+ webkitWebViewDisconnectMainResourceResponseChangedSignalHandler(webView);
+ webkitWebViewDisconnectSettingsSignalHandlers(webView);
priv->~WebKitWebViewPrivate();
G_OBJECT_CLASS(webkit_web_view_parent_class)->finalize(object);
@@ -1112,20 +1126,68 @@ static bool updateReplaceContentStatus(WebKitWebView* webView, WebKitLoadEvent l
return false;
}
+static void setCertificateToMainResource(WebKitWebView* webView)
+{
+ WebKitWebViewPrivate* priv = webView->priv;
+ ASSERT(priv->mainResource.get());
+
+ webkitURIResponseSetCertificateInfo(webkit_web_resource_get_response(priv->mainResource.get()),
+ WKFrameGetCertificateInfo(webkitWebResourceGetFrame(priv->mainResource.get())));
+}
+
+static void webkitWebViewEmitLoadChanged(WebKitWebView* webView, WebKitLoadEvent loadEvent)
+{
+ if (loadEvent == WEBKIT_LOAD_FINISHED) {
+ webView->priv->waitingForMainResource = false;
+ webkitWebViewDisconnectMainResourceResponseChangedSignalHandler(webView);
+ } else
+ webkitWebViewUpdateURI(webView);
+ g_signal_emit(webView, signals[LOAD_CHANGED], 0, loadEvent);
+}
+
+static void webkitWebViewEmitDelayedLoadEvents(WebKitWebView* webView)
+{
+ WebKitWebViewPrivate* priv = webView->priv;
+ if (!priv->waitingForMainResource)
+ return;
+ ASSERT(priv->lastDelayedEvent == WEBKIT_LOAD_COMMITTED || priv->lastDelayedEvent == WEBKIT_LOAD_FINISHED);
+
+ if (priv->lastDelayedEvent == WEBKIT_LOAD_FINISHED)
+ webkitWebViewEmitLoadChanged(webView, WEBKIT_LOAD_COMMITTED);
+ webkitWebViewEmitLoadChanged(webView, priv->lastDelayedEvent);
+ priv->waitingForMainResource = false;
+}
+
void webkitWebViewLoadChanged(WebKitWebView* webView, WebKitLoadEvent loadEvent)
{
if (loadEvent == WEBKIT_LOAD_STARTED) {
+ // Finish a possible previous load waiting for main resource.
+ webkitWebViewEmitDelayedLoadEvents(webView);
+
webView->priv->loadingResourcesMap.clear();
webView->priv->mainResource = 0;
- } else if (loadEvent == WEBKIT_LOAD_COMMITTED)
+ webView->priv->waitingForMainResource = false;
+ } else if (loadEvent == WEBKIT_LOAD_COMMITTED) {
webView->priv->subresourcesMap.clear();
+ if (webView->priv->replaceContentStatus != ReplacingContent) {
+ if (!webView->priv->mainResource) {
+ // When a page is loaded from the history cache, the main resource load callbacks
+ // are called when the main frame load is finished. We want to make sure there's a
+ // main resource available when load has been committed, so we delay the emission of
+ // load-changed signal until main resource object has been created.
+ webView->priv->waitingForMainResource = true;
+ } else
+ setCertificateToMainResource(webView);
+ }
+ }
if (updateReplaceContentStatus(webView, loadEvent))
return;
- if (loadEvent != WEBKIT_LOAD_FINISHED)
- webkitWebViewUpdateURI(webView);
- g_signal_emit(webView, signals[LOAD_CHANGED], 0, loadEvent);
+ if (webView->priv->waitingForMainResource)
+ webView->priv->lastDelayedEvent = loadEvent;
+ else
+ webkitWebViewEmitLoadChanged(webView, loadEvent);
}
void webkitWebViewLoadFailed(WebKitWebView* webView, WebKitLoadEvent loadEvent, const char* failingURI, GError *error)
@@ -1197,9 +1259,9 @@ void webkitWebViewRunAsModal(WebKitWebView* webView)
g_signal_emit(webView, signals[RUN_AS_MODAL], 0, NULL);
webView->priv->modalLoop = adoptGRef(g_main_loop_new(0, FALSE));
- GDK_THREADS_ENTER();
+ gdk_threads_leave();
g_main_loop_run(webView->priv->modalLoop.get());
- GDK_THREADS_LEAVE();
+ gdk_threads_enter();
}
void webkitWebViewClosePage(WebKitWebView* webView)
@@ -1269,6 +1331,24 @@ void webkitWebViewPrintFrame(WebKitWebView* webView, WKFrameRef wkFrame)
g_signal_connect(printOperation.leakRef(), "finished", G_CALLBACK(g_object_unref), 0);
}
+static void mainResourceResponseChangedCallback(WebKitWebResource*, GParamSpec*, WebKitWebView* webView)
+{
+ webkitWebViewDisconnectMainResourceResponseChangedSignalHandler(webView);
+ setCertificateToMainResource(webView);
+ webkitWebViewEmitDelayedLoadEvents(webView);
+}
+
+static void waitForMainResourceResponseIfWaitingForResource(WebKitWebView* webView)
+{
+ WebKitWebViewPrivate* priv = webView->priv;
+ if (!priv->waitingForMainResource)
+ return;
+
+ webkitWebViewDisconnectMainResourceResponseChangedSignalHandler(webView);
+ priv->mainResourceResponseHandlerID =
+ g_signal_connect(priv->mainResource.get(), "notify::response", G_CALLBACK(mainResourceResponseChangedCallback), webView);
+}
+
static inline bool webkitWebViewIsReplacingContentOrDidReplaceContent(WebKitWebView* webView)
{
return (webView->priv->replaceContentStatus == ReplacingContent || webView->priv->replaceContentStatus == DidReplaceContent);
@@ -1281,8 +1361,10 @@ void webkitWebViewResourceLoadStarted(WebKitWebView* webView, WKFrameRef wkFrame
WebKitWebViewPrivate* priv = webView->priv;
WebKitWebResource* resource = webkitWebResourceCreate(wkFrame, request, isMainResource);
- if (WKFrameIsMainFrame(wkFrame) && (isMainResource || !priv->mainResource))
+ if (WKFrameIsMainFrame(wkFrame) && (isMainResource || !priv->mainResource)) {
priv->mainResource = resource;
+ waitForMainResourceResponseIfWaitingForResource(webView);
+ }
priv->loadingResourcesMap.set(resourceIdentifier, adoptGRef(resource));
g_signal_emit(webView, signals[RESOURCE_LOAD_STARTED], 0, resource, request);
}
@@ -2318,3 +2400,171 @@ gboolean webkit_web_view_can_show_mime_type(WebKitWebView* webView, const char*
WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView));
return page->canShowMIMEType(String::fromUTF8(mimeType));
}
+
+struct ViewSaveAsyncData {
+ WKRetainPtr<WKDataRef> wkData;
+ GRefPtr<GFile> file;
+ GRefPtr<GCancellable> cancellable;
+};
+WEBKIT_DEFINE_ASYNC_DATA_STRUCT(ViewSaveAsyncData)
+
+static void fileReplaceContentsCallback(GObject* object, GAsyncResult* result, gpointer data)
+{
+ GFile* file = G_FILE(object);
+ GRefPtr<GSimpleAsyncResult> savedToFileResult = adoptGRef(G_SIMPLE_ASYNC_RESULT(data));
+
+ GError* error = 0;
+ if (!g_file_replace_contents_finish(file, result, 0, &error))
+ g_simple_async_result_take_error(savedToFileResult.get(), error);
+
+ g_simple_async_result_complete(savedToFileResult.get());
+}
+
+static void getContentsAsMHTMLDataCallback(WKDataRef wkData, WKErrorRef, void* context)
+{
+ GRefPtr<GSimpleAsyncResult> result = adoptGRef(G_SIMPLE_ASYNC_RESULT(context));
+ ViewSaveAsyncData* data = static_cast<ViewSaveAsyncData*>(g_simple_async_result_get_op_res_gpointer(result.get()));
+ GError* error = 0;
+
+ if (g_cancellable_set_error_if_cancelled(data->cancellable.get(), &error))
+ g_simple_async_result_take_error(result.get(), error);
+ else {
+ // We need to retain the data until the asyncronous process
+ // initiated by the user has finished completely.
+ data->wkData = wkData;
+
+ // If we are saving to a file we need to write the data on disk before finishing.
+ if (g_simple_async_result_get_source_tag(result.get()) == webkit_web_view_save_to_file) {
+ ASSERT(G_IS_FILE(data->file.get()));
+ g_file_replace_contents_async(data->file.get(), reinterpret_cast<const gchar*>(WKDataGetBytes(data->wkData.get())), WKDataGetSize(data->wkData.get()), 0, FALSE, G_FILE_CREATE_REPLACE_DESTINATION,
+ data->cancellable.get(), fileReplaceContentsCallback, g_object_ref(result.get()));
+ return;
+ }
+ }
+
+ g_simple_async_result_complete(result.get());
+}
+
+/**
+ * webkit_web_view_save:
+ * @web_view: a #WebKitWebView
+ * @save_mode: the #WebKitSaveMode specifying how the web page should be saved.
+ * @cancellable: (allow-none): a #GCancellable or %NULL to ignore
+ * @callback: (scope async): a #GAsyncReadyCallback to call when the request is satisfied
+ * @user_data: (closure): the data to pass to callback function
+ *
+ * Asynchronously save the current web page associated to the
+ * #WebKitWebView into a self-contained format using the mode
+ * specified in @save_mode.
+ *
+ * When the operation is finished, @callback will be called. You can
+ * then call webkit_web_view_save_finish() to get the result of the
+ * operation.
+ */
+void webkit_web_view_save(WebKitWebView* webView, WebKitSaveMode saveMode, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer userData)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+
+ // We only support MHTML at the moment.
+ g_return_if_fail(saveMode == WEBKIT_SAVE_MODE_MHTML);
+
+ GSimpleAsyncResult* result = g_simple_async_result_new(G_OBJECT(webView), callback, userData,
+ reinterpret_cast<gpointer>(webkit_web_view_save));
+ ViewSaveAsyncData* data = createViewSaveAsyncData();
+ data->cancellable = cancellable;
+ g_simple_async_result_set_op_res_gpointer(result, data, reinterpret_cast<GDestroyNotify>(destroyViewSaveAsyncData));
+
+ WKPageRef wkPage = toAPI(webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView)));
+ WKPageGetContentsAsMHTMLData(wkPage, false, result, getContentsAsMHTMLDataCallback);
+}
+
+/**
+ * webkit_web_view_save_finish:
+ * @web_view: a #WebKitWebView
+ * @result: a #GAsyncResult
+ * @error: return location for error or %NULL to ignore
+ *
+ * Finish an asynchronous operation started with webkit_web_view_save().
+ *
+ * Returns: (transfer full): a #GInputStream with the result of saving
+ * the current web page or %NULL in case of error.
+ */
+GInputStream* webkit_web_view_save_finish(WebKitWebView* webView, GAsyncResult* result, GError** error)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0);
+ g_return_val_if_fail(G_IS_ASYNC_RESULT(result), 0);
+
+ GSimpleAsyncResult* simple = G_SIMPLE_ASYNC_RESULT(result);
+ g_warn_if_fail(g_simple_async_result_get_source_tag(simple) == webkit_web_view_save);
+
+ if (g_simple_async_result_propagate_error(simple, error))
+ return 0;
+
+ GInputStream* dataStream = g_memory_input_stream_new();
+ ViewSaveAsyncData* data = static_cast<ViewSaveAsyncData*>(g_simple_async_result_get_op_res_gpointer(simple));
+ gsize length = WKDataGetSize(data->wkData.get());
+ if (length)
+ g_memory_input_stream_add_data(G_MEMORY_INPUT_STREAM(dataStream), g_memdup(WKDataGetBytes(data->wkData.get()), length), length, g_free);
+
+ return dataStream;
+}
+
+/**
+ * webkit_web_view_save_to_file:
+ * @web_view: a #WebKitWebView
+ * @file: the #GFile where the current web page should be saved to.
+ * @save_mode: the #WebKitSaveMode specifying how the web page should be saved.
+ * @cancellable: (allow-none): a #GCancellable or %NULL to ignore
+ * @callback: (scope async): a #GAsyncReadyCallback to call when the request is satisfied
+ * @user_data: (closure): the data to pass to callback function
+ *
+ * Asynchronously save the current web page associated to the
+ * #WebKitWebView into a self-contained format using the mode
+ * specified in @save_mode and writing it to @file.
+ *
+ * When the operation is finished, @callback will be called. You can
+ * then call webkit_web_view_save_to_file_finish() to get the result of the
+ * operation.
+ */
+void webkit_web_view_save_to_file(WebKitWebView* webView, GFile* file, WebKitSaveMode saveMode, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer userData)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+ g_return_if_fail(G_IS_FILE(file));
+
+ // We only support MHTML at the moment.
+ g_return_if_fail(saveMode == WEBKIT_SAVE_MODE_MHTML);
+
+ GSimpleAsyncResult* result = g_simple_async_result_new(G_OBJECT(webView), callback, userData,
+ reinterpret_cast<gpointer>(webkit_web_view_save_to_file));
+ ViewSaveAsyncData* data = createViewSaveAsyncData();
+ data->file = file;
+ data->cancellable = cancellable;
+ g_simple_async_result_set_op_res_gpointer(result, data, reinterpret_cast<GDestroyNotify>(destroyViewSaveAsyncData));
+
+ WKPageRef wkPage = toAPI(webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView)));
+ WKPageGetContentsAsMHTMLData(wkPage, false, result, getContentsAsMHTMLDataCallback);
+}
+
+/**
+ * webkit_web_view_save_to_file_finish:
+ * @web_view: a #WebKitWebView
+ * @result: a #GAsyncResult
+ * @error: return location for error or %NULL to ignore
+ *
+ * Finish an asynchronous operation started with webkit_web_view_save_to_file().
+ *
+ * Returns: %TRUE if the web page was successfully saved to a file or %FALSE otherwise.
+ */
+gboolean webkit_web_view_save_to_file_finish(WebKitWebView* webView, GAsyncResult* result, GError** error)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE);
+ g_return_val_if_fail(G_IS_ASYNC_RESULT(result), FALSE);
+
+ GSimpleAsyncResult* simple = G_SIMPLE_ASYNC_RESULT(result);
+ g_warn_if_fail(g_simple_async_result_get_source_tag(simple) == webkit_web_view_save_to_file);
+
+ if (g_simple_async_result_propagate_error(simple, error))
+ return FALSE;
+
+ return TRUE;
+}
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h
index 2553b1840..6ebd17f04 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h
@@ -118,6 +118,17 @@ typedef enum {
WEBKIT_LOAD_FINISHED
} WebKitLoadEvent;
+/**
+ * WebKitSaveMode:
+ * @WEBKIT_SAVE_MODE_MHTML: Save the current page using the MHTML format.
+ *
+ * Enum values to specify the different ways in which a #WebKitWebView
+ * can save its current web page into a self-contained file.
+ */
+typedef enum {
+ WEBKIT_SAVE_MODE_MHTML
+} WebKitSaveMode;
+
struct _WebKitWebView {
WebKitWebViewBase parent;
@@ -319,6 +330,31 @@ WEBKIT_API gboolean
webkit_web_view_can_show_mime_type (WebKitWebView *web_view,
const gchar *mime_type);
+WEBKIT_API void
+webkit_web_view_save (WebKitWebView *web_view,
+ WebKitSaveMode save_mode,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+WEBKIT_API GInputStream *
+webkit_web_view_save_finish (WebKitWebView *web_view,
+ GAsyncResult *result,
+ GError **error);
+
+WEBKIT_API void
+webkit_web_view_save_to_file (WebKitWebView *web_view,
+ GFile *file,
+ WebKitSaveMode save_mode,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+WEBKIT_API gboolean
+webkit_web_view_save_to_file_finish (WebKitWebView *web_view,
+ GAsyncResult *result,
+ GError **error);
+
G_END_DECLS
#endif
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp
index f65fa97ed..4925b5a7c 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp
@@ -101,9 +101,6 @@ struct _WebKitWebViewBasePrivate {
G_DEFINE_TYPE(WebKitWebViewBase, webkit_web_view_base, GTK_TYPE_CONTAINER)
-// Keep this in sync with the value minimumAttachedHeight in WebInspectorProxy.
-static const unsigned gMinimumAttachedInspectorHeight = 250;
-
static void webkitWebViewBaseNotifyResizerSizeForWindow(WebKitWebViewBase* webViewBase, GtkWindow* window)
{
gboolean resizerVisible;
@@ -190,7 +187,6 @@ static void webkitWebViewBaseContainerAdd(GtkContainer* container, GtkWidget* wi
&& WebInspectorProxy::isInspectorPage(WEBKIT_WEB_VIEW_BASE(widget)->priv->pageProxy.get())) {
ASSERT(!priv->inspectorView);
priv->inspectorView = widget;
- priv->inspectorViewHeight = gMinimumAttachedInspectorHeight;
} else {
GtkAllocation childAllocation;
gtk_widget_get_allocation(widget, &childAllocation);
@@ -773,12 +769,11 @@ void webkitWebViewBaseInitializeFullScreenClient(WebKitWebViewBase* webkitWebVie
void webkitWebViewBaseSetInspectorViewHeight(WebKitWebViewBase* webkitWebViewBase, unsigned height)
{
- if (!webkitWebViewBase->priv->inspectorView)
- return;
if (webkitWebViewBase->priv->inspectorViewHeight == height)
return;
webkitWebViewBase->priv->inspectorViewHeight = height;
- gtk_widget_queue_resize_no_redraw(GTK_WIDGET(webkitWebViewBase));
+ if (webkitWebViewBase->priv->inspectorView)
+ gtk_widget_queue_resize_no_redraw(GTK_WIDGET(webkitWebViewBase));
}
void webkitWebViewBaseSetActiveContextMenuProxy(WebKitWebViewBase* webkitWebViewBase, WebContextMenuProxyGtk* contextMenuProxy)
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h
index 1833fb111..f2986d1f9 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h
@@ -28,7 +28,7 @@
#define WebKitWebViewPrivate_h
#include "WebKitWebView.h"
-#include <WebKit2/WebKit2.h>
+#include <WebKit2/WebKit2_C.h>
#include <wtf/text/CString.h>
void webkitWebViewLoadChanged(WebKitWebView*, WebKitLoadEvent);
diff --git a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt
index 73f09d5d3..92da1ebe5 100644
--- a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt
+++ b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt
@@ -62,6 +62,7 @@ webkit_web_context_get_type
WebKitWebView
WebKitLoadEvent
WebKitPolicyDecisionType
+WebKitSaveMode
<SUBSECTION Editing Commands>
WEBKIT_EDITING_COMMAND_CUT
@@ -105,6 +106,10 @@ webkit_web_view_get_javascript_global_context
webkit_web_view_run_javascript
webkit_web_view_run_javascript_finish
webkit_web_view_can_show_mime_type
+webkit_web_view_save
+webkit_web_view_save_finish
+webkit_web_view_save_to_file
+webkit_web_view_save_to_file_finish
<SUBSECTION WebKitJavascriptResult>
WebKitJavascriptResult
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.cpp
index a35c8745b..d370de938 100644
--- a/Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.cpp
@@ -35,10 +35,17 @@ static void loadChangedCallback(WebKitWebView* webView, WebKitLoadEvent loadEven
g_assert_cmpstr(test->m_redirectURI.data(), ==, test->m_activeURI.data());
test->provisionalLoadReceivedServerRedirect();
break;
- case WEBKIT_LOAD_COMMITTED:
+ case WEBKIT_LOAD_COMMITTED: {
g_assert_cmpstr(test->m_activeURI.data(), ==, webkit_web_view_get_uri(webView));
+
+ // Check that on committed we always have a main resource with a response.
+ WebKitWebResource* resource = webkit_web_view_get_main_resource(webView);
+ g_assert(resource);
+ g_assert(webkit_web_resource_get_response(resource));
+
test->loadCommitted();
break;
+ }
case WEBKIT_LOAD_FINISHED:
if (!test->m_loadFailed)
g_assert_cmpstr(test->m_activeURI.data(), ==, webkit_web_view_get_uri(webView));
@@ -170,3 +177,17 @@ void LoadTrackingTest::reload()
m_estimatedProgress = 0;
webkit_web_view_reload(m_webView);
}
+
+void LoadTrackingTest::goBack()
+{
+ m_loadEvents.clear();
+ m_estimatedProgress = 0;
+ WebViewTest::goBack();
+}
+
+void LoadTrackingTest::goForward()
+{
+ m_loadEvents.clear();
+ m_estimatedProgress = 0;
+ WebViewTest::goForward();
+}
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.h b/Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.h
index 2d95c48f4..562f7f038 100644
--- a/Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.h
+++ b/Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.h
@@ -44,6 +44,8 @@ public:
void loadPlainText(const char* plainText);
void loadRequest(WebKitURIRequest*);
void reload();
+ void goBack();
+ void goForward();
void setRedirectURI(const char* uri) { m_redirectURI = uri; }
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestInspector.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestInspector.cpp
index 9b023f3ed..673749411 100644
--- a/Source/WebKit2/UIProcess/API/gtk/tests/TestInspector.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestInspector.cpp
@@ -22,8 +22,6 @@
#include "WebViewTest.h"
#include <wtf/gobject/GRefPtr.h>
-static const unsigned gMinimumAttachedInspectorHeight = 250;
-
class InspectorTest: public WebViewTest {
public:
MAKE_GLIB_TEST_FIXTURE(InspectorTest);
@@ -181,6 +179,7 @@ static void testInspectorDefault(InspectorTest* test, gconstpointer)
test->resizeViewAndAttach();
g_assert(webkit_web_inspector_is_attached(test->m_inspector));
+ g_assert_cmpuint(webkit_web_inspector_get_attached_height(test->m_inspector), >=, InspectorTest::gMinimumAttachedInspectorHeight);
events = test->m_events;
g_assert_cmpint(events.size(), ==, 1);
g_assert_cmpint(events[0], ==, InspectorTest::Attach);
@@ -258,6 +257,7 @@ public:
gtk_widget_show_all(pane);
} else
pane = gtk_bin_get_child(GTK_BIN(m_parentWindow));
+ gtk_paned_set_position(GTK_PANED(pane), webkit_web_inspector_get_attached_height(m_inspector));
gtk_paned_add2(GTK_PANED(pane), GTK_WIDGET(inspectorView.get()));
return InspectorTest::attach();
@@ -301,6 +301,7 @@ static void testInspectorManualAttachDetach(CustomInspectorTest* test, gconstpoi
test->resizeViewAndAttach();
g_assert(webkit_web_inspector_is_attached(test->m_inspector));
+ g_assert_cmpuint(webkit_web_inspector_get_attached_height(test->m_inspector), >=, InspectorTest::gMinimumAttachedInspectorHeight);
events = test->m_events;
g_assert_cmpint(events.size(), ==, 1);
g_assert_cmpint(events[0], ==, InspectorTest::Attach);
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestLoaderClient.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestLoaderClient.cpp
index 3afa2b96f..59eed7658 100644
--- a/Source/WebKit2/UIProcess/API/gtk/tests/TestLoaderClient.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestLoaderClient.cpp
@@ -144,6 +144,26 @@ static void testLoadProgress(LoadTrackingTest* test, gconstpointer)
g_assert_cmpfloat(test->m_estimatedProgress, ==, 1);
}
+static void testWebViewHistoryLoad(LoadTrackingTest* test, gconstpointer)
+{
+ test->loadURI(kServer->getURIForPath("/normal").data());
+ test->waitUntilLoadFinished();
+ assertNormalLoadHappened(test->m_loadEvents);
+
+ test->loadURI(kServer->getURIForPath("/normal2").data());
+ test->waitUntilLoadFinished();
+ assertNormalLoadHappened(test->m_loadEvents);
+
+ // Check that load process is the same for pages loaded from history cache.
+ test->goBack();
+ test->waitUntilLoadFinished();
+ assertNormalLoadHappened(test->m_loadEvents);
+
+ test->goForward();
+ test->waitUntilLoadFinished();
+ assertNormalLoadHappened(test->m_loadEvents);
+}
+
class ViewURITrackingTest: public LoadTrackingTest {
public:
MAKE_GLIB_TEST_FIXTURE(ViewURITrackingTest);
@@ -217,7 +237,7 @@ static void serverCallback(SoupServer* server, SoupMessage* message, const char*
soup_message_set_status(message, SOUP_STATUS_OK);
- if (g_str_equal(path, "/normal"))
+ if (g_str_has_prefix(path, "/normal"))
soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, responseString, strlen(responseString));
else if (g_str_equal(path, "/error"))
soup_message_set_status(message, SOUP_STATUS_CANT_CONNECT);
@@ -248,6 +268,7 @@ void beforeAll()
LoadTrackingTest::add("WebKitWebView", "title", testWebViewTitle);
LoadTrackingTest::add("WebKitWebView", "progress", testLoadProgress);
LoadTrackingTest::add("WebKitWebView", "reload", testWebViewReload);
+ LoadTrackingTest::add("WebKitWebView", "history-load", testWebViewHistoryLoad);
// This test checks that web view notify::uri signal is correctly emitted
// and the uri is already updated when loader client signals are emitted.
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp
index f42feafb7..1b172dfee 100644
--- a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp
@@ -233,28 +233,37 @@ static void testWebContextURIScheme(URISchemeTest* test, gconstpointer)
static void testWebContextSpellChecker(Test* test, gconstpointer)
{
- GRefPtr<WebKitWebContext> webContext(webkit_web_context_get_default());
+ WebKitWebContext* webContext = webkit_web_context_get_default();
- // Set the language to a specific one, an empty one and a list of them.
- webkit_web_context_set_spell_checking_languages(webContext.get(), "en_US");
- const gchar* currentLanguage(webkit_web_context_get_spell_checking_languages(webContext.get()));
+ // Check what happens if no spell checking language has been set.
+ const gchar* currentLanguage = webkit_web_context_get_spell_checking_languages(webContext);
+ g_assert(!currentLanguage);
+
+ // Set the language to a specific one.
+ webkit_web_context_set_spell_checking_languages(webContext, "en_US");
+ currentLanguage = webkit_web_context_get_spell_checking_languages(webContext);
g_assert_cmpstr(currentLanguage, ==, "en_US");
- webkit_web_context_set_spell_checking_languages(webContext.get(), 0);
- currentLanguage = webkit_web_context_get_spell_checking_languages(webContext.get());
- g_assert_cmpstr(currentLanguage, ==, 0);
+ // Set the language string to list of valid languages.
+ webkit_web_context_set_spell_checking_languages(webContext, "en_GB,en_US");
+ currentLanguage = webkit_web_context_get_spell_checking_languages(webContext);
+ g_assert_cmpstr(currentLanguage, ==, "en_GB,en_US");
+
+ // Try passing a wrong language along with good ones.
+ webkit_web_context_set_spell_checking_languages(webContext, "bd_WR,en_US,en_GB");
+ currentLanguage = webkit_web_context_get_spell_checking_languages(webContext);
+ g_assert_cmpstr(currentLanguage, ==, "en_US,en_GB");
- webkit_web_context_set_spell_checking_languages(webContext.get(), "es_ES,en_US");
- currentLanguage = webkit_web_context_get_spell_checking_languages(webContext.get());
- g_assert_cmpstr(currentLanguage, ==, "es_ES,en_US");
+ // Try passing a list with only wrong languages.
+ webkit_web_context_set_spell_checking_languages(webContext, "bd_WR,wr_BD");
+ currentLanguage = webkit_web_context_get_spell_checking_languages(webContext);
+ g_assert(!currentLanguage);
// Check disabling and re-enabling spell checking.
- webkit_web_context_set_spell_checking_enabled(webContext.get(), FALSE);
- gboolean isSpellCheckingEnabled = webkit_web_context_get_spell_checking_enabled(webContext.get());
- g_assert(!isSpellCheckingEnabled);
- webkit_web_context_set_spell_checking_enabled(webContext.get(), TRUE);
- isSpellCheckingEnabled = webkit_web_context_get_spell_checking_enabled(webContext.get());
- g_assert(isSpellCheckingEnabled);
+ webkit_web_context_set_spell_checking_enabled(webContext, FALSE);
+ g_assert(!webkit_web_context_get_spell_checking_enabled(webContext));
+ webkit_web_context_set_spell_checking_enabled(webContext, TRUE);
+ g_assert(webkit_web_context_get_spell_checking_enabled(webContext));
}
void beforeAll()
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp
index eec6fc786..22796bf73 100644
--- a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp
@@ -21,6 +21,7 @@
#include "WebViewTest.h"
#include <JavaScriptCore/JSStringRef.h>
#include <JavaScriptCore/JSValueRef.h>
+#include <glib/gstdio.h>
#include <wtf/HashSet.h>
#include <wtf/gobject/GRefPtr.h>
#include <wtf/text/StringHash.h>
@@ -946,6 +947,102 @@ static void testWebViewSubmitForm(FormClientTest* test, gconstpointer)
g_assert_cmpstr(static_cast<char*>(g_hash_table_lookup(values, "password")), ==, "secret");
}
+class SaveWebViewTest: public WebViewTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(SaveWebViewTest);
+
+ SaveWebViewTest()
+ : m_tempDirectory(g_dir_make_tmp("WebKit2SaveViewTest-XXXXXX", 0))
+ {
+ }
+
+ ~SaveWebViewTest()
+ {
+ if (G_IS_FILE(m_file.get()))
+ g_file_delete(m_file.get(), 0, 0);
+
+ if (G_IS_INPUT_STREAM(m_inputStream.get()))
+ g_input_stream_close(m_inputStream.get(), 0, 0);
+
+ if (m_tempDirectory)
+ g_rmdir(m_tempDirectory.get());
+ }
+
+ static void webViewSavedToStreamCallback(GObject* object, GAsyncResult* result, SaveWebViewTest* test)
+ {
+ GOwnPtr<GError> error;
+ test->m_inputStream = adoptGRef(webkit_web_view_save_finish(test->m_webView, result, &error.outPtr()));
+ g_assert(G_IS_INPUT_STREAM(test->m_inputStream.get()));
+ g_assert(!error);
+
+ test->quitMainLoop();
+ }
+
+ static void webViewSavedToFileCallback(GObject* object, GAsyncResult* result, SaveWebViewTest* test)
+ {
+ GOwnPtr<GError> error;
+ g_assert(webkit_web_view_save_to_file_finish(test->m_webView, result, &error.outPtr()));
+ g_assert(!error);
+
+ test->quitMainLoop();
+ }
+
+ void saveAndWaitForStream()
+ {
+ webkit_web_view_save(m_webView, WEBKIT_SAVE_MODE_MHTML, 0, reinterpret_cast<GAsyncReadyCallback>(webViewSavedToStreamCallback), this);
+ g_main_loop_run(m_mainLoop);
+ }
+
+ void saveAndWaitForFile()
+ {
+ m_saveDestinationFilePath.set(g_build_filename(m_tempDirectory.get(), "testWebViewSaveResult.mht", NULL));
+ m_file = adoptGRef(g_file_new_for_path(m_saveDestinationFilePath.get()));
+ webkit_web_view_save_to_file(m_webView, m_file.get(), WEBKIT_SAVE_MODE_MHTML, 0, reinterpret_cast<GAsyncReadyCallback>(webViewSavedToFileCallback), this);
+ g_main_loop_run(m_mainLoop);
+ }
+
+ GOwnPtr<char> m_tempDirectory;
+ GOwnPtr<char> m_saveDestinationFilePath;
+ GRefPtr<GInputStream> m_inputStream;
+ GRefPtr<GFile> m_file;
+};
+
+static void testWebViewSave(SaveWebViewTest* test, gconstpointer)
+{
+ test->loadHtml("<html>"
+ "<body>"
+ " <p>A paragraph with plain text</p>"
+ " <p>"
+ " A red box: <img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAIAAAD91JpzAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3AYWDTMVwnSZnwAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAAAFklEQVQI12P8z8DAwMDAxMDAwMDAAAANHQEDK+mmyAAAAABJRU5ErkJggg=='></br>"
+ " A blue box: <img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAIAAAD91JpzAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3AYWDTMvBHhALQAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAAAFklEQVQI12Nk4PnPwMDAxMDAwMDAAAALrwEPPIs1pgAAAABJRU5ErkJggg=='>"
+ " </p>"
+ "</body>"
+ "</html>", 0);
+ test->waitUntilLoadFinished();
+
+ // Write to a file and to an input stream.
+ test->saveAndWaitForFile();
+ test->saveAndWaitForStream();
+
+ // We should have exactly the same amount of bytes in the file
+ // than those coming from the GInputStream. We don't compare the
+ // strings read since the 'Date' field and the boundaries will be
+ // different on each case. MHTML functionality will be tested by
+ // Layout tests, so checking the amount of bytes is enough.
+ GOwnPtr<GError> error;
+ gchar buffer[512] = { 0 };
+ gssize readBytes = 0;
+ gssize totalBytesFromStream = 0;
+ while (readBytes = g_input_stream_read(test->m_inputStream.get(), &buffer, 512, 0, &error.outPtr())) {
+ g_assert(!error);
+ totalBytesFromStream += readBytes;
+ }
+
+ // Check that the file exists and that it contains the same amount of bytes.
+ GRefPtr<GFileInfo> fileInfo = adoptGRef(g_file_query_info(test->m_file.get(), G_FILE_ATTRIBUTE_STANDARD_SIZE, static_cast<GFileQueryInfoFlags>(0), 0, 0));
+ g_assert_cmpint(g_file_info_get_size(fileInfo.get()), ==, totalBytesFromStream);
+}
+
void beforeAll()
{
WebViewTest::add("WebKitWebView", "default-context", testWebViewDefaultContext);
@@ -965,6 +1062,7 @@ void beforeAll()
FullScreenClientTest::add("WebKitWebView", "fullscreen", testWebViewFullScreen);
WebViewTest::add("WebKitWebView", "can-show-mime-type", testWebViewCanShowMIMEType);
FormClientTest::add("WebKitWebView", "submit-form", testWebViewSubmitForm);
+ SaveWebViewTest::add("WebKitWebView", "save", testWebViewSave);
}
void afterAll()
diff --git a/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextController.h b/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextController.h
index a79fc6afc..c053ae664 100644
--- a/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextController.h
+++ b/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextController.h
@@ -53,6 +53,9 @@ WK_EXPORT
*/
- (void)loadFileURL:(NSURL *)URL restrictToFilesWithin:(NSURL *)allowedDirectory;
+/* Load a page using the passed in string as its contents. */
+- (void)loadHTMLString:(NSString *)HTMLString baseURL:(NSURL *)baseURL;
+
/* Stops the load associated with the active URL. */
- (void)stopLoading;
diff --git a/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextController.mm b/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextController.mm
index 3daa08c37..2d4a94400 100644
--- a/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextController.mm
+++ b/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextController.mm
@@ -120,6 +120,19 @@ static inline NSURL *autoreleased(WKURLRef url)
WKPageLoadURL(self._pageRef, wkURL.get());
}
+- (void)loadHTMLString:(NSString *)HTMLString baseURL:(NSURL *)baseURL
+{
+ WKRetainPtr<WKStringRef> wkHTMLString;
+ if (HTMLString)
+ wkHTMLString = adoptWK(WKStringCreateWithCFString((CFStringRef)HTMLString));
+
+ WKRetainPtr<WKURLRef> wkBaseURL;
+ if (baseURL)
+ wkBaseURL = adoptWK(WKURLCreateWithCFURL((CFURLRef)baseURL));
+
+ WKPageLoadHTMLString(self._pageRef, wkHTMLString.get(), wkBaseURL.get());
+}
+
- (void)stopLoading
{
WKPageStopLoading(self._pageRef);
diff --git a/Source/WebKit2/UIProcess/API/mac/WebKit2.h b/Source/WebKit2/UIProcess/API/mac/WebKit2.h
new file mode 100644
index 000000000..7a2bd1a23
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/mac/WebKit2.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <WebKit2/WKBrowsingContextController.h>
+#import <WebKit2/WKBrowsingContextGroup.h>
+#import <WebKit2/WKBrowsingContextLoadDelegate.h>
+#import <WebKit2/WKConnection.h>
+#import <WebKit2/WKProcessGroup.h>
+#import <WebKit2/WKView.h>
diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp b/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp
index 99c5ffb40..7911f167c 100644
--- a/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp
+++ b/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp
@@ -22,10 +22,10 @@
#include "qquickwebpage_p.h"
#include "LayerTreeCoordinatorProxy.h"
+#include "LayerTreeRenderer.h"
#include "QtWebPageEventHandler.h"
#include "QtWebPageSGNode.h"
#include "TransformationMatrix.h"
-#include "WebLayerTreeRenderer.h"
#include "WebPageProxy.h"
#include "qquickwebpage_p_p.h"
#include "qquickwebview_p.h"
@@ -82,7 +82,7 @@ QSGNode* QQuickWebPage::updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData*)
return oldNode;
LayerTreeCoordinatorProxy* layerTreeCoordinatorProxy = d->webPageProxy->drawingArea()->layerTreeCoordinatorProxy();
- WebLayerTreeRenderer* renderer = layerTreeCoordinatorProxy->layerTreeRenderer();
+ LayerTreeRenderer* renderer = layerTreeCoordinatorProxy->layerTreeRenderer();
QtWebPageSGNode* node = static_cast<QtWebPageSGNode*>(oldNode);
if (!node)
diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp b/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp
index fa0446fec..6ca413f66 100644
--- a/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp
+++ b/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp
@@ -32,7 +32,6 @@
#include "QtWebPageEventHandler.h"
#include "QtWebPageLoadClient.h"
#include "QtWebPagePolicyClient.h"
-#include "UtilsQt.h"
#include "WebBackForwardList.h"
#include "WebInspectorProxy.h"
#include "WebInspectorServer.h"
@@ -185,7 +184,7 @@ static QQuickWebViewPrivate* createPrivateObject(QQuickWebView* publicObject)
QQuickWebViewPrivate::FlickableAxisLocker::FlickableAxisLocker()
: m_allowedDirection(QQuickFlickable::AutoFlickDirection)
- , m_sampleCount(0)
+ , m_time(0), m_sampleCount(0)
{
}
@@ -197,8 +196,8 @@ QVector2D QQuickWebViewPrivate::FlickableAxisLocker::touchVelocity(const QTouchE
if (touchVelocityAvailable)
return touchPoint.velocity();
- const QLineF movementLine(touchPoint.screenPos(), m_initialScreenPosition);
- const qint64 elapsed = m_time.elapsed();
+ const QLineF movementLine(touchPoint.pos(), m_initialPosition);
+ const ulong elapsed = event->timestamp() - m_time;
if (!elapsed)
return QVector2D(0, 0);
@@ -215,8 +214,8 @@ void QQuickWebViewPrivate::FlickableAxisLocker::update(const QTouchEvent* event)
++m_sampleCount;
if (m_sampleCount == 1) {
- m_initialScreenPosition = touchPoint.screenPos();
- m_time.restart();
+ m_initialPosition = touchPoint.pos();
+ m_time = event->timestamp();
return;
}
@@ -270,7 +269,6 @@ QQuickWebViewPrivate::QQuickWebViewPrivate(QQuickWebView* viewport)
, m_useDefaultContentItemSize(true)
, m_navigatorQtObjectEnabled(false)
, m_renderToOffscreenBuffer(false)
- , m_dialogActive(false)
, m_allowAnyHTTPSCertificateForLocalHost(false)
, m_loadProgress(0)
{
@@ -297,6 +295,7 @@ void QQuickWebViewPrivate::initialize(WKContextRef contextRef, WKPageGroupRef pa
context = contextRef ? QtWebContext::create(toImpl(contextRef)) : QtWebContext::defaultContext();
webPageProxy = context->createWebPage(&pageClient, pageGroup.get());
+ webPageProxy->setUseFixedLayout(s_flickableViewportEnabled);
#if ENABLE(FULLSCREEN_API)
webPageProxy->fullScreenManager()->setWebView(q_ptr);
#endif
@@ -321,6 +320,13 @@ void QQuickWebViewPrivate::initialize(WKContextRef contextRef, WKPageGroupRef pa
webPageProxy->initializeWebPage();
}
+void QQuickWebViewPrivate::onComponentComplete()
+{
+ Q_Q(QQuickWebView);
+ m_viewportHandler.reset(new QtViewportHandler(webPageProxy.get(), q, pageView.data()));
+ pageView->eventHandler()->setViewportHandler(m_viewportHandler.data());
+}
+
void QQuickWebViewPrivate::setTransparentBackground(bool enable)
{
webPageProxy->setDrawsTransparentBackground(enable);
@@ -408,6 +414,27 @@ void QQuickWebViewPrivate::loadDidFail(const QtWebError& error)
emit q->loadingChanged(&loadRequest);
}
+void QQuickWebViewPrivate::handleMouseEvent(QMouseEvent* event)
+{
+ switch (event->type()) {
+ case QEvent::MouseButtonPress:
+ case QEvent::MouseButtonDblClick:
+ // If a MouseButtonDblClick was received then we got a MouseButtonPress before
+ // handleMousePressEvent will take care of double clicks.
+ pageView->eventHandler()->handleMousePressEvent(event);
+ break;
+ case QEvent::MouseMove:
+ pageView->eventHandler()->handleMouseMoveEvent(event);
+ break;
+ case QEvent::MouseButtonRelease:
+ pageView->eventHandler()->handleMouseReleaseEvent(event);
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ break;
+ }
+}
+
void QQuickWebViewPrivate::setNeedsDisplay()
{
Q_Q(QQuickWebView);
@@ -767,8 +794,11 @@ QQuickWebViewLegacyPrivate::QQuickWebViewLegacyPrivate(QQuickWebView* viewport)
void QQuickWebViewLegacyPrivate::initialize(WKContextRef contextRef, WKPageGroupRef pageGroupRef)
{
+ Q_Q(QQuickWebView);
QQuickWebViewPrivate::initialize(contextRef, pageGroupRef);
- enableMouseEvents();
+
+ q->setAcceptedMouseButtons(Qt::MouseButtonMask);
+ q->setAcceptHoverEvents(true);
// Trigger setting of correct visibility flags after everything was allocated and initialized.
_q_onVisibleChanged();
@@ -777,29 +807,15 @@ void QQuickWebViewLegacyPrivate::initialize(WKContextRef contextRef, WKPageGroup
void QQuickWebViewLegacyPrivate::updateViewportSize()
{
Q_Q(QQuickWebView);
- QSize viewportSize = q->boundingRect().size().toSize();
+ QSizeF viewportSize = q->boundingRect().size();
if (viewportSize.isEmpty())
return;
pageView->setContentsSize(viewportSize);
// The fixed layout is handled by the FrameView and the drawing area doesn't behave differently
// whether its fixed or not. We still need to tell the drawing area which part of it
// has to be rendered on tiles, and in desktop mode it's all of it.
- webPageProxy->drawingArea()->setSize(viewportSize, IntSize());
- webPageProxy->drawingArea()->setVisibleContentsRect(IntRect(IntPoint(), viewportSize), 1, FloatPoint());
-}
-
-void QQuickWebViewLegacyPrivate::enableMouseEvents()
-{
- Q_Q(QQuickWebView);
- q->setAcceptedMouseButtons(Qt::MouseButtonMask);
- q->setAcceptHoverEvents(true);
-}
-
-void QQuickWebViewLegacyPrivate::disableMouseEvents()
-{
- Q_Q(QQuickWebView);
- q->setAcceptedMouseButtons(Qt::NoButton);
- q->setAcceptHoverEvents(false);
+ webPageProxy->drawingArea()->setSize(viewportSize.toSize(), IntSize());
+ webPageProxy->drawingArea()->setVisibleContentsRect(FloatRect(FloatPoint(), viewportSize), 1, FloatPoint());
}
qreal QQuickWebViewLegacyPrivate::zoomFactor() const
@@ -815,12 +831,6 @@ void QQuickWebViewLegacyPrivate::setZoomFactor(qreal factor)
QQuickWebViewFlickablePrivate::QQuickWebViewFlickablePrivate(QQuickWebView* viewport)
: QQuickWebViewPrivate(viewport)
{
- // Disable mouse events on the flickable web view so we do not
- // select text during pan gestures on platforms which send both
- // touch and mouse events simultaneously.
- // FIXME: Temporary workaround code which should be removed when
- // bug http://codereview.qt-project.org/21896 is fixed.
- viewport->setAcceptedMouseButtons(Qt::NoButton);
viewport->setAcceptHoverEvents(false);
}
@@ -832,15 +842,11 @@ QQuickWebViewFlickablePrivate::~QQuickWebViewFlickablePrivate()
void QQuickWebViewFlickablePrivate::initialize(WKContextRef contextRef, WKPageGroupRef pageGroupRef)
{
QQuickWebViewPrivate::initialize(contextRef, pageGroupRef);
- webPageProxy->setUseFixedLayout(true);
}
void QQuickWebViewFlickablePrivate::onComponentComplete()
{
- Q_Q(QQuickWebView);
-
- m_viewportHandler.reset(new QtViewportHandler(webPageProxy.get(), q, pageView.data()));
- pageView->eventHandler()->setViewportHandler(m_viewportHandler.data());
+ QQuickWebViewPrivate::onComponentComplete();
// Trigger setting of correct visibility flags after everything was allocated and initialized.
_q_onVisibleChanged();
@@ -872,6 +878,15 @@ void QQuickWebViewFlickablePrivate::didChangeContentsSize(const QSize& newSize)
m_viewportHandler->pageContentsSizeChanged(newSize, q->boundingRect().size().toSize());
}
+void QQuickWebViewFlickablePrivate::handleMouseEvent(QMouseEvent* event)
+{
+ if (!pageView->eventHandler())
+ return;
+
+ // FIXME: Update the axis locker for mouse events as well.
+ pageView->eventHandler()->handleInputEvent(event);
+}
+
/*!
\qmlsignal WebView::onNavigationRequested(WebNavigationRequest request)
@@ -1657,36 +1672,25 @@ void QQuickWebView::platformInitialize()
bool QQuickWebView::childMouseEventFilter(QQuickItem* item, QEvent* event)
{
- if (!isVisible() || !isEnabled() || !s_flickableViewportEnabled)
- return QQuickFlickable::childMouseEventFilter(item, event);
-
- Q_D(QQuickWebView);
- if (d->m_dialogActive) {
- event->ignore();
+ if (!isVisible() || !isEnabled())
return false;
- }
// This function is used by MultiPointTouchArea and PinchArea to filter
// touch events, thus to hinder the canvas from sending synthesized
// mouse events to the Flickable implementation we need to reimplement
- // childMouseEventFilter and filter incoming touch events as well.
+ // childMouseEventFilter to ignore touch and mouse events.
switch (event->type()) {
case QEvent::MouseButtonPress:
- mousePressEvent(static_cast<QMouseEvent*>(event));
- return event->isAccepted();
case QEvent::MouseMove:
- mouseMoveEvent(static_cast<QMouseEvent*>(event));
- return event->isAccepted();
case QEvent::MouseButtonRelease:
- mouseReleaseEvent(static_cast<QMouseEvent*>(event));
- return event->isAccepted();
case QEvent::TouchBegin:
case QEvent::TouchUpdate:
case QEvent::TouchEnd:
- touchEvent(static_cast<QTouchEvent*>(event));
- return event->isAccepted();
+ // Force all mouse and touch events through the default propagation path.
+ return false;
default:
+ ASSERT(event->type() == QEvent::UngrabMouse);
break;
}
@@ -1743,10 +1747,6 @@ void QQuickWebView::focusOutEvent(QFocusEvent* event)
void QQuickWebView::touchEvent(QTouchEvent* event)
{
Q_D(QQuickWebView);
- if (d->m_dialogActive) {
- event->ignore();
- return;
- }
bool lockingDisabled = flickableDirection() != AutoFlickDirection
|| event->touchPoints().size() != 1
@@ -1766,29 +1766,26 @@ void QQuickWebView::mousePressEvent(QMouseEvent* event)
{
Q_D(QQuickWebView);
forceActiveFocus();
- d->pageView->eventHandler()->handleMousePressEvent(event);
+ d->handleMouseEvent(event);
}
void QQuickWebView::mouseMoveEvent(QMouseEvent* event)
{
Q_D(QQuickWebView);
- d->pageView->eventHandler()->handleMouseMoveEvent(event);
+ d->handleMouseEvent(event);
}
void QQuickWebView::mouseReleaseEvent(QMouseEvent* event)
{
Q_D(QQuickWebView);
- d->pageView->eventHandler()->handleMouseReleaseEvent(event);
+ d->handleMouseEvent(event);
}
void QQuickWebView::mouseDoubleClickEvent(QMouseEvent* event)
{
Q_D(QQuickWebView);
-
forceActiveFocus();
- // If a MouseButtonDblClick was received then we got a MouseButtonPress before
- // handleMousePressEvent will take care of double clicks.
- d->pageView->eventHandler()->handleMousePressEvent(event);
+ d->handleMouseEvent(event);
}
void QQuickWebView::wheelEvent(QWheelEvent* event)
diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h
index f102f6030..d8a88f8c9 100644
--- a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h
+++ b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h
@@ -69,10 +69,7 @@ public:
virtual void initialize(WKContextRef contextRef = 0, WKPageGroupRef pageGroupRef = 0);
- virtual void onComponentComplete() { }
-
- virtual void enableMouseEvents() { }
- virtual void disableMouseEvents() { }
+ virtual void onComponentComplete();
virtual void provisionalLoadDidStart(const WTF::String& url);
virtual void didReceiveServerRedirectForProvisionalLoad(const WTF::String& url);
@@ -83,6 +80,7 @@ public:
virtual void backForwardListDidChange();
virtual void loadDidSucceed();
virtual void loadDidFail(const WebKit::QtWebError& error);
+ virtual void handleMouseEvent(QMouseEvent*);
virtual void didChangeViewportProperties(const WebCore::ViewportAttributes& attr) { }
@@ -124,8 +122,6 @@ public:
QPointF contentPos() const;
void setContentPos(const QPointF&);
- void setDialogActive(bool active) { m_dialogActive = active; }
-
void updateIcon();
// PageClient.
@@ -142,8 +138,8 @@ protected:
class FlickableAxisLocker {
QQuickFlickable::FlickableDirection m_allowedDirection;
- QElapsedTimer m_time;
- QPointF m_initialScreenPosition;
+ ulong m_time;
+ QPointF m_initialPosition;
QPointF m_lockReferencePosition;
int m_sampleCount;
@@ -174,6 +170,7 @@ protected:
QScopedPointer<QQuickWebPage> pageView;
QQuickWebView* q_ptr;
+ QScopedPointer<WebKit::QtViewportHandler> m_viewportHandler;
FlickableAxisLocker axisLocker;
QQmlComponent* alertDialog;
@@ -192,7 +189,6 @@ protected:
bool m_useDefaultContentItemSize;
bool m_navigatorQtObjectEnabled;
bool m_renderToOffscreenBuffer;
- bool m_dialogActive;
bool m_allowAnyHTTPSCertificateForLocalHost;
WTF::String m_iconUrl;
int m_loadProgress;
@@ -206,8 +202,6 @@ public:
virtual void initialize(WKContextRef contextRef = 0, WKPageGroupRef pageGroupRef = 0);
virtual void updateViewportSize();
- virtual void enableMouseEvents();
- virtual void disableMouseEvents();
qreal zoomFactor() const;
void setZoomFactor(qreal);
@@ -228,9 +222,7 @@ public:
virtual void pageDidRequestScroll(const QPoint& pos);
virtual void didChangeContentsSize(const QSize& newSize);
-
-private:
- QScopedPointer<WebKit::QtViewportHandler> m_viewportHandler;
+ virtual void handleMouseEvent(QMouseEvent*);
};
#endif // qquickwebview_p_p_h
diff --git a/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview.cpp b/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview.cpp
index 121f90d88..0aed5d948 100644
--- a/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview.cpp
+++ b/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview.cpp
@@ -23,6 +23,7 @@
#include "Cursor.h"
#include "DrawingAreaProxyImpl.h"
#include "LayerTreeCoordinatorProxy.h"
+#include "LayerTreeRenderer.h"
#include "NativeWebKeyboardEvent.h"
#include "NativeWebMouseEvent.h"
#if ENABLE(TOUCH_EVENTS)
@@ -31,7 +32,6 @@
#include "NativeWebWheelEvent.h"
#include "NotImplemented.h"
#include "WebContext.h"
-#include "WebLayerTreeRenderer.h"
#include "WebPageGroup.h"
#include "WebPreferences.h"
#include "qrawwebview_p_p.h"
@@ -353,7 +353,7 @@ void QRawWebView::paint(const QMatrix4x4& transform, float opacity, unsigned pai
if (!coordinatorProxy)
return;
- WebKit::WebLayerTreeRenderer* renderer = coordinatorProxy->layerTreeRenderer();
+ WebKit::LayerTreeRenderer* renderer = coordinatorProxy->layerTreeRenderer();
if (!renderer)
return;
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/publicapi/tst_publicapi.cpp b/Source/WebKit2/UIProcess/API/qt/tests/publicapi/tst_publicapi.cpp
index 0e3b33cf7..12e0ab903 100644
--- a/Source/WebKit2/UIProcess/API/qt/tests/publicapi/tst_publicapi.cpp
+++ b/Source/WebKit2/UIProcess/API/qt/tests/publicapi/tst_publicapi.cpp
@@ -144,11 +144,7 @@ static void gatherAPI(const QString& prefix, const QMetaMethod& method, QStringL
{
if (method.access() != QMetaMethod::Private) {
const char* methodTypeName = !!strlen(method.typeName()) ? method.typeName() : "void";
-#if HAVE(QT5)
*output << QString::fromLatin1("%1%2 --> %3").arg(prefix).arg(QString::fromLatin1(method.methodSignature())).arg(QString::fromLatin1(methodTypeName));
-#else
- *output << QString::fromLatin1("%1%2 --> %3").arg(prefix).arg(method.signature()).arg(methodTypeName);
-#endif
checkKnownType(methodTypeName);
foreach (QByteArray paramType, method.parameterTypes())
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_devicePixelRatio.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_devicePixelRatio.qml
deleted file mode 100644
index 643c721da..000000000
--- a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_devicePixelRatio.qml
+++ /dev/null
@@ -1,63 +0,0 @@
-import QtQuick 2.0
-import QtTest 1.0
-import QtWebKit 3.0
-import QtWebKit.experimental 1.0
-import "../common"
-
-Item {
- TestWebView {
- id: webView
- property variant lastResult
- }
-
- SignalSpy {
- id: resultSpy
- target: webView
- signalName: "lastResultChanged"
- }
-
- TestCase {
- name: "DevicePixelRatio"
-
- function init() {
- resultSpy.clear()
- webView.lastResult = null
- }
-
- function test_devicePixelRatio() {
- expectFail("", "This currently fails since window.devicePixelRatio doesn't return the updated value.")
-
- resultSpy.clear()
- webView.url = "about:blank"
- webView.experimental.devicePixelRatio = 2.0
- verify(webView.waitForLoadSucceeded())
-
- webView.experimental.evaluateJavaScript(
- "(function() { return window.devicePixelRatio })()",
- function(result) {
- webView.lastResult = result
- })
-
- resultSpy.wait()
- compare(webView.lastResult, 2.0)
- compare(webView.lastResult, webView.experimental.devicePixelRatio)
- }
-
- function test_devicePixelRatioMediaQuery() {
- expectFail("", "This currently fails since the devicePixelRatio from the QML API isn't propagated correctly.")
- resultSpy.clear()
- webView.url = "about:blank"
- webView.experimental.devicePixelRatio = 2.0
- verify(webView.waitForLoadSucceeded())
-
- webView.experimental.evaluateJavaScript(
- "(function() { return window.matchMedia('-webkit-device-pixel-ratio: 2').matches })()",
- function(result) {
- webView.lastResult = result
- })
-
- resultSpy.wait()
- verify(webView.lastResult)
- }
- }
-}
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_favIconLoad.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_favIconLoad.qml
index f6ed4b261..6f0858696 100644
--- a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_favIconLoad.qml
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_favIconLoad.qml
@@ -36,7 +36,7 @@ TestWebView {
compare(spy.count, 0)
var url = Qt.resolvedUrl("../common/favicon.html")
webView.url = url
- verify(webView.waitForLoadSucceeded())
+ spy.wait()
compare(spy.count, 1)
compare(favicon.width, 48)
compare(favicon.height, 48)
@@ -46,7 +46,7 @@ TestWebView {
compare(spy.count, 0)
var url = Qt.resolvedUrl("../common/favicon2.html?favicon=load should work with#whitespace!")
webView.url = url
- verify(webView.waitForLoadSucceeded())
+ spy.wait()
compare(spy.count, 1)
compare(favicon.width, 16)
compare(favicon.height, 16)
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/tests.pri b/Source/WebKit2/UIProcess/API/qt/tests/tests.pri
index 2704efe4a..b87659bf3 100644
--- a/Source/WebKit2/UIProcess/API/qt/tests/tests.pri
+++ b/Source/WebKit2/UIProcess/API/qt/tests/tests.pri
@@ -3,14 +3,17 @@ TEMPLATE = app
VPATH += $$_PRO_FILE_PWD_
TARGET = tst_$$TARGET
-HEADERS += ../bytearraytestdata.h \
- ../util.h
-
-SOURCES += ../util.cpp \
- ../bytearraytestdata.cpp
INCLUDEPATH += $$PWD
+SOURCES += ../util.cpp
+
+QT += testlib webkit
+contains(DEFINES, HAVE_QTQUICK=1) {
+ QT += qml quick quick-private
+ HEADERS += ../bytearraytestdata.h \
+ ../util.h
-QT += testlib qml quick quick-private webkit
+ SOURCES += ../bytearraytestdata.cpp
+}
WEBKIT += wtf # For platform macros
DEFINES += TESTS_SOURCE_DIR=\\\"$$PWD\\\" \
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/util.cpp b/Source/WebKit2/UIProcess/API/qt/tests/util.cpp
index 2582848aa..cdd1f9961 100644
--- a/Source/WebKit2/UIProcess/API/qt/tests/util.cpp
+++ b/Source/WebKit2/UIProcess/API/qt/tests/util.cpp
@@ -18,11 +18,15 @@
*/
#include "util.h"
-#include "private/qquickwebview_p.h"
-#include "private/qwebloadrequest_p.h"
+
#include <QtTest/QtTest>
#include <stdio.h>
+#if defined(HAVE_QTQUICK) && HAVE_QTQUICK
+#include "private/qquickwebview_p.h"
+#include "private/qwebloadrequest_p.h"
+#endif
+
void addQtWebProcessToPath()
{
// Since tests won't find ./QtWebProcess, add it to PATH (at the end to prevent surprises).
@@ -53,6 +57,7 @@ bool waitForSignal(QObject* obj, const char* signal, int timeout)
return timeoutSpy.isEmpty();
}
+#if defined(HAVE_QTQUICK) && HAVE_QTQUICK
class LoadSpy : public QEventLoop {
Q_OBJECT
public:
@@ -136,5 +141,6 @@ void LoadStartedCatcher::onLoadingChanged(QWebLoadRequest* loadRequest)
QCOMPARE(m_webView->loading(), true);
}
}
+#endif
#include "util.moc"
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/util.h b/Source/WebKit2/UIProcess/API/qt/tests/util.h
index 9d076f1b4..907ddb05f 100644
--- a/Source/WebKit2/UIProcess/API/qt/tests/util.h
+++ b/Source/WebKit2/UIProcess/API/qt/tests/util.h
@@ -30,6 +30,7 @@ class QWebLoadRequest;
#endif
void addQtWebProcessToPath();
+#if defined(HAVE_QTQUICK) && HAVE_QTQUICK
bool waitForSignal(QObject*, const char* signal, int timeout = 10000);
bool waitForLoadSucceeded(QQuickWebView* webView, int timeout = 10000);
bool waitForLoadFailed(QQuickWebView* webView, int timeout = 10000);
@@ -46,3 +47,4 @@ signals:
private:
QQuickWebView* m_webView;
};
+#endif