[EFL][WK2] Separate WebView further from EwkView
authormikhail.pozdnyakov@intel.com <mikhail.pozdnyakov@intel.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Mar 2013 21:55:48 +0000 (21:55 +0000)
committermikhail.pozdnyakov@intel.com <mikhail.pozdnyakov@intel.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Mar 2013 21:55:48 +0000 (21:55 +0000)
https://bugs.webkit.org/show_bug.cgi?id=111591

Reviewed by Caio Marcelo de Oliveira Filho.

Source/WebKit2:

Main points are:
- WKView API has no dependency on EFL types
- WebView class does not store the Evas_Object

* UIProcess/API/C/efl/WKView.cpp:
(WKViewCreate):

    WKView creation does not require any EFL objects to be passed.

* UIProcess/API/C/efl/WKView.h:
* UIProcess/API/efl/EwkView.cpp:
(EwkView::EwkView):
(EwkView::create):

    WKViewRef is passed to EwkView constructor from outside rather than
    created inside.

(EwkView::webView):
* UIProcess/API/efl/EwkView.h:
(EwkView):
(EwkView::wkView):
(EwkView::page):

    EwkView keeps WKViewRef rather than pointer to WebView class.

* UIProcess/API/efl/ewk_view_private.h: Added.
(EWKViewCreate):
(EWKViewGetWKView):

    Added private API to create ewk view evas object and return its WKViewRef.

* UIProcess/API/efl/ewk_view.cpp:
(ewkCreateEvasObject):
(ewk_view_smart_add):
(ewk_view_add):
(ewk_view_add_with_context):
* UIProcess/efl/WebInspectorProxyEfl.cpp:
(WebKit::WebInspectorProxy::platformCreateInspectorPage):

    Updated accordingly to the new APIs.

* UIProcess/efl/WebView.cpp:
(WebKit::WebView::WebView):
(WebKit::WebView::create):
(WebKit):
(WebKit::WebView::setEwkView):
(WebKit::WebView::isViewFocused):
(WebKit::WebView::isViewVisible):
* UIProcess/efl/WebView.h:
(WebView):

    Implementation of updated WKView API.

Tools:

Updated EFL PlatformWebView to meet the new WKView API and ewk view private API.
PlatformWKView is pointer to Evas_Object for EFL, as this is more natural and
since we can afford it having EWKViewGetWKView() private API to access WKView.

* TestWebKitAPI/PlatformWebView.h:
* TestWebKitAPI/Tests/WebKit2/efl/WKViewClientWebProcessCallbacks.cpp:
(TestWebKitAPI::TEST):
* TestWebKitAPI/efl/PlatformWebView.cpp:
(TestWebKitAPI::PlatformWebView::PlatformWebView):
(TestWebKitAPI::PlatformWebView::~PlatformWebView):
(TestWebKitAPI::PlatformWebView::resizeTo):
(TestWebKitAPI::PlatformWebView::page):
(TestWebKitAPI::PlatformWebView::simulateSpacebarKeyPress):
(TestWebKitAPI::PlatformWebView::simulateMouseMove):
(TestWebKitAPI::PlatformWebView::simulateRightClick):
* WebKitTestRunner/PlatformWebView.h:
* WebKitTestRunner/efl/EventSenderProxyEfl.cpp:
(WTR::EventSenderProxy::dispatchEvent):
(WTR::EventSenderProxy::keyDown):
(WTR::EventSenderProxy::sendTouchEvent):
(WTR::EventSenderProxy::setTouchModifier):
* WebKitTestRunner/efl/PlatformWebViewEfl.cpp:
(WTR::PlatformWebView::PlatformWebView):
(WTR::PlatformWebView::~PlatformWebView):
(WTR::PlatformWebView::resizeTo):
(WTR::PlatformWebView::page):
(WTR::PlatformWebView::focus):
(WTR::PlatformWebView::windowSnapshotImage):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@146265 268f45cc-cd09-0410-ab3c-d52691b4dbfc

17 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/C/efl/WKView.cpp
Source/WebKit2/UIProcess/API/C/efl/WKView.h
Source/WebKit2/UIProcess/API/efl/EwkView.cpp
Source/WebKit2/UIProcess/API/efl/EwkView.h
Source/WebKit2/UIProcess/API/efl/ewk_view.cpp
Source/WebKit2/UIProcess/API/efl/ewk_view_private.h [new file with mode: 0644]
Source/WebKit2/UIProcess/efl/WebInspectorProxyEfl.cpp
Source/WebKit2/UIProcess/efl/WebView.cpp
Source/WebKit2/UIProcess/efl/WebView.h
Tools/ChangeLog
Tools/TestWebKitAPI/PlatformWebView.h
Tools/TestWebKitAPI/Tests/WebKit2/efl/WKViewClientWebProcessCallbacks.cpp
Tools/TestWebKitAPI/efl/PlatformWebView.cpp
Tools/WebKitTestRunner/PlatformWebView.h
Tools/WebKitTestRunner/efl/EventSenderProxyEfl.cpp
Tools/WebKitTestRunner/efl/PlatformWebViewEfl.cpp

index f1a3a66..dccbbcb 100644 (file)
@@ -1,3 +1,63 @@
+2013-03-19  Kenneth Rohde Christiansen  <kenneth@webkit.org> and Mikhail Pozdnyakov  <mikhail.pozdnyakov@intel.com>
+
+        [EFL][WK2] Separate WebView further from EwkView
+        https://bugs.webkit.org/show_bug.cgi?id=111591
+
+        Reviewed by Caio Marcelo de Oliveira Filho.
+
+        Main points are:
+        - WKView API has no dependency on EFL types
+        - WebView class does not store the Evas_Object
+
+        * UIProcess/API/C/efl/WKView.cpp:
+        (WKViewCreate):
+
+            WKView creation does not require any EFL objects to be passed.
+
+        * UIProcess/API/C/efl/WKView.h:
+        * UIProcess/API/efl/EwkView.cpp:
+        (EwkView::EwkView):
+        (EwkView::create):
+
+            WKViewRef is passed to EwkView constructor from outside rather than
+            created inside.
+
+        (EwkView::webView):
+        * UIProcess/API/efl/EwkView.h:
+        (EwkView):
+        (EwkView::wkView):
+        (EwkView::page):
+
+            EwkView keeps WKViewRef rather than pointer to WebView class.
+
+        * UIProcess/API/efl/ewk_view_private.h: Added.
+        (EWKViewCreate):
+        (EWKViewGetWKView):
+
+            Added private API to create ewk view evas object and return its WKViewRef.
+
+        * UIProcess/API/efl/ewk_view.cpp:
+        (ewkCreateEvasObject):
+        (ewk_view_smart_add):
+        (ewk_view_add):
+        (ewk_view_add_with_context):
+        * UIProcess/efl/WebInspectorProxyEfl.cpp:
+        (WebKit::WebInspectorProxy::platformCreateInspectorPage):
+
+            Updated accordingly to the new APIs.
+
+        * UIProcess/efl/WebView.cpp:
+        (WebKit::WebView::WebView):
+        (WebKit::WebView::create):
+        (WebKit):
+        (WebKit::WebView::setEwkView):
+        (WebKit::WebView::isViewFocused):
+        (WebKit::WebView::isViewVisible):
+        * UIProcess/efl/WebView.h:
+        (WebView):
+
+            Implementation of updated WKView API.
+
 2013-03-19  Dean Jackson  <dino@apple.com>
 
         Allow PlugIn Snapshotting to be tested
index 699015a..691f6a1 100644 (file)
 
 using namespace WebKit;
 
-static inline WKViewRef createWKView(Evas* canvas, WKContextRef contextRef, WKPageGroupRef pageGroupRef, EwkView::ViewBehavior behavior)
+WKViewRef WKViewCreate(WKContextRef contextRef, WKPageGroupRef pageGroupRef)
 {
-    RefPtr<EwkContext> context = contextRef ? EwkContext::findOrCreateWrapper(contextRef) : EwkContext::defaultContext();
-    RefPtr<EwkPageGroup> pageGroup = pageGroupRef ? EwkPageGroup::findOrCreateWrapper(pageGroupRef) : 0;
-
-    Evas_Object* evasObject = EwkView::createEvasObject(canvas, context, pageGroup, behavior);
-    if (!evasObject)
-        return 0;
-
-    return static_cast<WKViewRef>(WKRetain(toEwkView(evasObject)->wkView()));
-}
-
-WKViewRef WKViewCreate(Evas* canvas, WKContextRef contextRef, WKPageGroupRef pageGroupRef)
-{
-    return createWKView(canvas, contextRef, pageGroupRef, EwkView::LegacyBehavior);
-}
-
-WKViewRef WKViewCreateWithFixedLayout(Evas* canvas, WKContextRef contextRef, WKPageGroupRef pageGroupRef)
-{
-    return createWKView(canvas, contextRef, pageGroupRef, EwkView::DefaultBehavior);
+    RefPtr<WebView> webView = WebView::create(toImpl(contextRef), toImpl(pageGroupRef));
+    return toAPI(webView.release().leakRef());
 }
 
 void WKViewInitialize(WKViewRef viewRef)
@@ -141,11 +125,6 @@ void WKViewExitFullScreen(WKViewRef viewRef)
 #endif
 }
 
-Evas_Object* WKViewGetEvasObject(WKViewRef viewRef)
-{
-    return toImpl(viewRef)->evasObject();
-}
-
 WKImageRef WKViewCreateSnapshot(WKViewRef viewRef)
 {
     EwkView* ewkView = toEwkView(toImpl(viewRef)->evasObject());
index a709b48..ca34ba4 100644 (file)
 #include <WebKit2/WKBase.h>
 #include <WebKit2/WKGeometry.h>
 
-#if USE(EO)
-typedef struct _Eo Evas;
-typedef struct _Eo Evas_Object;
-#else
-typedef struct _Evas Evas;
-typedef struct _Evas_Object Evas_Object;
-#endif
-
 typedef struct _cairo_surface cairo_surface_t;
 
 #ifdef __cplusplus
@@ -57,9 +49,7 @@ typedef struct WKViewClient WKViewClient;
 
 enum { kWKViewClientCurrentVersion = 0 };
 
-WK_EXPORT WKViewRef WKViewCreate(Evas* canvas, WKContextRef context, WKPageGroupRef pageGroup);
-
-WK_EXPORT WKViewRef WKViewCreateWithFixedLayout(Evas* canvas, WKContextRef context, WKPageGroupRef pageGroup);
+WK_EXPORT WKViewRef WKViewCreate(WKContextRef context, WKPageGroupRef pageGroup);
 
 WK_EXPORT void WKViewInitialize(WKViewRef);
 WK_EXPORT void WKViewSetViewClient(WKViewRef, const WKViewClient*);
@@ -88,9 +78,6 @@ WK_EXPORT bool WKViewGetShowsAsSource(WKViewRef);
 
 WK_EXPORT void WKViewExitFullScreen(WKViewRef);
 
-// FIXME: The long term plan is to get rid of this, so keep usage to a bare minimum.
-WK_EXPORT Evas_Object* WKViewGetEvasObject(WKViewRef);
-
 WK_EXPORT WKImageRef WKViewCreateSnapshot(WKViewRef);
 
 #ifdef __cplusplus
index 81eb115..062a392 100644 (file)
@@ -237,12 +237,12 @@ static inline WKPageToEvasObjectMap& wkPageToEvasObjectMap()
 
 // EwkView implementation.
 
-EwkView::EwkView(Evas_Object* evasObject, PassRefPtr<EwkContext> context, PassRefPtr<EwkPageGroup> pageGroup, ViewBehavior behavior)
-    : m_evasObject(evasObject)
-    , m_context(context)
-    , m_webView(adoptRef(new WebView(toImpl(m_context->wkContext()), pageGroup ? toImpl(pageGroup->wkPageGroup()) : 0, this)))
+EwkView::EwkView(WKViewRef view, Evas_Object* evasObject)
+    : m_webView(view)
+    , m_evasObject(evasObject)
+    , m_context(EwkContext::findOrCreateWrapper(WKPageGetContext(wkPage())))
     , m_pageGroup(EwkPageGroup::findOrCreateWrapper(WKPageGetPageGroup(wkPage())))
-    , m_pendingSurfaceResize(false)    
+    , m_pendingSurfaceResize(false)
     , m_pageLoadClient(PageLoadClientEfl::create(this))
     , m_pagePolicyClient(PagePolicyClientEfl::create(this))
     , m_pageUIClient(PageUIClientEfl::create(this))
@@ -270,6 +270,9 @@ EwkView::EwkView(Evas_Object* evasObject, PassRefPtr<EwkContext> context, PassRe
     ASSERT(m_evasObject);
     ASSERT(m_context);
 
+    // FIXME: Remove when possible.
+    webView()->setEwkView(this);
+
     m_evasGL = adoptPtr(evas_gl_new(evas_object_evas_get(m_evasObject)));
     if (m_evasGL)
         m_evasGLContext = EvasGLContext::create(m_evasGL.get());
@@ -281,8 +284,6 @@ EwkView::EwkView(Evas_Object* evasObject, PassRefPtr<EwkContext> context, PassRe
 
     WKViewInitialize(wkView());
 
-    WKPageSetUseFixedLayout(wkPage(), behavior == DefaultBehavior);
-
     WKPageGroupRef wkPageGroup = WKPageGetPageGroup(wkPage());
     WKPreferencesRef wkPreferences = WKPageGroupGetPreferences(wkPageGroup);
 
@@ -320,13 +321,11 @@ EwkView::~EwkView()
     wkPageToEvasObjectMap().remove(wkPage());
 }
 
-Evas_Object* EwkView::createEvasObject(Evas* canvas, Evas_Smart* smart, PassRefPtr<EwkContext> context, PassRefPtr<EwkPageGroup> pageGroup, ViewBehavior behavior)
+EwkView* EwkView::create(WKViewRef webView, Evas* canvas, Evas_Smart* smart)
 {
     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* evasObject = evas_object_smart_add(canvas, smart);
+    Evas_Object* evasObject = evas_object_smart_add(canvas, smart ? smart : defaultSmartClassInstance());
     EINA_SAFETY_ON_NULL_RETURN_VAL(evasObject, 0);
 
     Ewk_View_Smart_Data* smartData = toSmartData(evasObject);
@@ -337,14 +336,9 @@ Evas_Object* EwkView::createEvasObject(Evas* canvas, Evas_Smart* smart, PassRefP
 
     ASSERT(!smartData->priv);
 
-    smartData->priv = new EwkView(evasObject, context, pageGroup, behavior);
+    smartData->priv = new EwkView(webView, evasObject);
 
-    return evasObject;
-}
-
-Evas_Object* EwkView::createEvasObject(Evas* canvas, PassRefPtr<EwkContext> context, PassRefPtr<EwkPageGroup> pageGroup, ViewBehavior behavior)
-{
-    return createEvasObject(canvas, defaultSmartClassInstance(), context, pageGroup, behavior);
+    return smartData->priv;
 }
 
 bool EwkView::initSmartClassInterface(Ewk_View_Smart_Class& api)
@@ -960,6 +954,11 @@ unsigned long long EwkView::informDatabaseQuotaReached(const String& databaseNam
 }
 #endif
 
+WebView* EwkView::webView()
+{
+    return toImpl(m_webView.get());
+}
+
 /**
  * @internal
  * The url of view was changed by the frame loader.
index 6626197..01ec548 100644 (file)
@@ -98,17 +98,9 @@ typedef struct _Evas_GL_Surface Evas_GL_Surface;
 typedef struct Ewk_View_Smart_Data Ewk_View_Smart_Data;
 typedef struct Ewk_View_Smart_Class Ewk_View_Smart_Class;
 
-// EwkView object is owned by the evas object, obtained from EwkView::createEvasObject().
 class EwkView {
 public:
-
-    enum ViewBehavior {
-        LegacyBehavior,
-        DefaultBehavior
-    };
-
-    static Evas_Object* createEvasObject(Evas* canvas, Evas_Smart* smart, PassRefPtr<EwkContext> context,  PassRefPtr<EwkPageGroup> pageGroup = 0, ViewBehavior behavior = EwkView::DefaultBehavior);
-    static Evas_Object* createEvasObject(Evas* canvas, PassRefPtr<EwkContext> context, PassRefPtr<EwkPageGroup> pageGroup = 0, ViewBehavior behavior = EwkView::DefaultBehavior);
+    static EwkView* create(WKViewRef, Evas* canvas, Evas_Smart* smart = 0);
 
     static bool initSmartClassInterface(Ewk_View_Smart_Class&);
 
@@ -116,10 +108,10 @@ public:
 
     Evas_Object* evasObject() { return m_evasObject; }
 
-    WKViewRef wkView() const { return toAPI(m_webView.get()); }
+    WKViewRef wkView() const { return m_webView.get(); }
     WKPageRef wkPage() const;
 
-    WebKit::WebPageProxy* page() { return m_webView->page(); }
+    WebKit::WebPageProxy* page() { return webView()->page(); }
     EwkContext* ewkContext() { return m_context.get(); }
     EwkPageGroup* ewkPageGroup() { return m_pageGroup.get(); }
     EwkSettings* settings() { return m_settings.get(); }
@@ -200,7 +192,7 @@ public:
     unsigned long long informDatabaseQuotaReached(const String& databaseName, const String& displayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentDatabaseUsage, unsigned long long expectedUsage);
 
     // FIXME: Remove when possible.
-    WebKit::WebView* webView() { return m_webView.get(); }
+    WebKit::WebView* webView();
 
     void setPageScaleFactor(float scaleFactor) { m_pageScaleFactor = scaleFactor; }
     float pageScaleFactor() const { return m_pageScaleFactor; }
@@ -214,7 +206,7 @@ public:
     PassRefPtr<cairo_surface_t> takeSnapshot();
 
 private:
-    EwkView(Evas_Object* evasObject, PassRefPtr<EwkContext> context, PassRefPtr<EwkPageGroup> pageGroup, ViewBehavior);
+    EwkView(WKViewRef, Evas_Object*);
     ~EwkView();
 
     void setDeviceSize(const WebCore::IntSize&);
@@ -252,9 +244,9 @@ private:
 
 private:
     // Note, initialization order matters.
+    WKRetainPtr<WKViewRef> m_webView;
     Evas_Object* m_evasObject;
     RefPtr<EwkContext> m_context;
-    RefPtr<WebKit::WebView> m_webView;
     RefPtr<EwkPageGroup> m_pageGroup;
     OwnPtr<Evas_GL> m_evasGL;
     OwnPtr<WebKit::EvasGLContext> m_evasGLContext;
index 7ae18c7..c15b8da 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "config.h"
 #include "ewk_view.h"
+#include "ewk_view_private.h"
 
 #include "EwkView.h"
 #include "FindClientEfl.h"
@@ -88,19 +89,48 @@ Eina_Bool ewk_view_smart_class_set(Ewk_View_Smart_Class* api)
     return EwkView::initSmartClassInterface(*api);
 }
 
-Evas_Object* ewk_view_smart_add(Evas* canvas, Evas_Smart* smart, Ewk_Context* context, Ewk_Page_Group* pageGroup)
+Evas_Object* EWKViewCreate(WKContextRef context, WKPageGroupRef pageGroup, Evas* canvas, Evas_Smart* smart)
 {
-    return EwkView::createEvasObject(canvas, smart, ewk_object_cast<EwkContext*>(context), ewk_object_cast<EwkPageGroup*>(pageGroup));
+    WKRetainPtr<WKViewRef> wkView = adoptWK(WKViewCreate(context, pageGroup));
+    WKPageSetUseFixedLayout(WKViewGetPage(wkView.get()), true);
+    if (EwkView* ewkView = EwkView::create(wkView.get(), canvas, smart))
+        return ewkView->evasObject();
+
+    return 0;
 }
 
-Evas_Object* ewk_view_add_with_context(Evas* canvas, Ewk_Context* context)
+WKViewRef EWKViewGetWKView(Evas_Object* ewkView)
+{
+    EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, 0);
+
+    return impl->wkView();
+}
+
+Evas_Object* ewk_view_smart_add(Evas* canvas, Evas_Smart* smart, Ewk_Context* context, Ewk_Page_Group* pageGroup)
 {
-    return EwkView::createEvasObject(canvas, ewk_object_cast<EwkContext*>(context));
+    EwkContext* ewkContext = ewk_object_cast<EwkContext*>(context);
+    EwkPageGroup* ewkPageGroup = ewk_object_cast<EwkPageGroup*>(pageGroup);
+
+    EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, 0);
+    EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext->wkContext(), 0);
+    EINA_SAFETY_ON_NULL_RETURN_VAL(ewkPageGroup, 0);
+    EINA_SAFETY_ON_NULL_RETURN_VAL(ewkPageGroup->wkPageGroup(), 0);
+
+    return EWKViewCreate(ewkContext->wkContext(), ewkPageGroup->wkPageGroup(), canvas, smart);
 }
 
 Evas_Object* ewk_view_add(Evas* canvas)
 {
-    return ewk_view_add_with_context(canvas, ewk_context_default_get());
+    return EWKViewCreate(adoptWK(WKContextCreate()).get(), 0, canvas, 0);
+}
+
+Evas_Object* ewk_view_add_with_context(Evas* canvas, Ewk_Context* context)
+{
+    EwkContext* ewkContext = ewk_object_cast<EwkContext*>(context);
+    EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, 0);
+    EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext->wkContext(), 0);
+
+    return EWKViewCreate(ewkContext->wkContext(), 0, canvas, 0);
 }
 
 Ewk_Context* ewk_view_context_get(const Evas_Object* ewkView)
diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h
new file mode 100644 (file)
index 0000000..6de35d9
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2013 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_view_private_h
+#define ewk_view_private_h
+
+#include <Evas.h>
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+EAPI Evas_Object* EWKViewCreate(WKContextRef, WKPageGroupRef, Evas*, Evas_Smart*);
+EAPI WKViewRef EWKViewGetWKView(Evas_Object*);
+
+#ifdef __cplusplus
+}
+#endif
+#endif // ewk_view_private_h
index 6d12dfa..da083cf 100644 (file)
 #include "ewk_page_group_private.h"
 #include "ewk_settings.h"
 #include "ewk_view.h"
+#include "ewk_view_private.h"
 #include <WebCore/EflInspectorUtilities.h>
 #include <WebCore/NotImplemented.h>
+#include <WebKit2/WKPage.h>
+#include <WebKit2/WKPageGroup.h>
+#include <WebKit2/WKPreferencesPrivate.h>
+#include <WebKit2/WKString.h>
 #include <wtf/text/CString.h>
 #include <wtf/text/StringBuilder.h>
 #include <wtf/text/WTFString.h>
@@ -99,20 +104,19 @@ WebPageProxy* WebInspectorProxy::platformCreateInspectorPage()
     if (!m_inspectorWindow)
         return 0;
 
-    // FIXME: Refactor to use WKViewRef.
-    WKContextRef contextRef = toAPI(page()->process()->context());
-    m_inspectorView = EwkView::createEvasObject(ecore_evas_get(m_inspectorWindow), EwkContext::findOrCreateWrapper(contextRef), EwkPageGroup::findOrCreateWrapper(toAPI(inspectorPageGroup())), EwkView::LegacyBehavior);
-    if (!m_inspectorView)
-        return 0;
+    WKContextRef wkContext = toAPI(page()->process()->context());
+    WKPageGroupRef wkPageGroup = toAPI(inspectorPageGroup());
+
+    m_inspectorView = EWKViewCreate(wkContext, wkPageGroup, ecore_evas_get(m_inspectorWindow), /* smart */ 0);
+    WKViewRef wkView = EWKViewGetWKView(m_inspectorView);
 
-    EwkView* ewkView = toEwkView(m_inspectorView);
-    ASSERT(ewkView);
-    ewkView->setThemePath(TEST_THEME_DIR "/default.edj");
+    WKRetainPtr<WKStringRef> wkTheme = adoptWK(WKStringCreateWithUTF8CString(TEST_THEME_DIR "/default.edj"));
+    WKViewSetThemePath(wkView, wkTheme.get());
 
-    Ewk_Settings* settings = ewkView->settings();
-    ewk_settings_file_access_from_file_urls_allowed_set(settings, true);
+    WKPreferencesRef wkPreferences = WKPageGroupGetPreferences(wkPageGroup);
+    WKPreferencesSetFileAccessFromFileURLsAllowed(wkPreferences, true);
 
-    return ewkView->page();
+    return toImpl(WKViewGetPage(wkView));
 }
 
 void WebInspectorProxy::platformOpen()
index 5c2b3ba..e5e80c2 100644 (file)
@@ -51,8 +51,8 @@ using namespace WebCore;
 
 namespace WebKit {
 
-WebView::WebView(WebContext* context, WebPageGroup* pageGroup, EwkView* ewkView)
-    : m_ewkView(ewkView)
+WebView::WebView(WebContext* context, WebPageGroup* pageGroup)
+    : m_ewkView(0)
     , m_page(context->createWebPage(this, pageGroup))
 {
     m_page->pageGroup()->preferences()->setAcceleratedCompositingEnabled(true);
@@ -62,10 +62,6 @@ WebView::WebView(WebContext* context, WebPageGroup* pageGroup, EwkView* ewkView)
     bool showDebugVisuals = debugVisualsEnvironment && !strcmp(debugVisualsEnvironment, "1");
     m_page->pageGroup()->preferences()->setCompositingBordersVisible(showDebugVisuals);
     m_page->pageGroup()->preferences()->setCompositingRepaintCountersVisible(showDebugVisuals);
-
-#if ENABLE(FULLSCREEN_API)
-    m_page->fullScreenManager()->setWebView(evasObject());
-#endif
 }
 
 WebView::~WebView()
@@ -76,6 +72,22 @@ WebView::~WebView()
     m_page->close();
 }
 
+PassRefPtr<WebView> WebView::create(WebContext* context, WebPageGroup* pageGroup)
+{
+    return adoptRef(new WebView(context, pageGroup));
+}
+
+// FIXME: Remove when possible.
+void WebView::setEwkView(EwkView* ewkView)
+{
+    m_ewkView = ewkView;
+
+#if ENABLE(FULLSCREEN_API)
+    m_page->fullScreenManager()->setWebView(ewkView->evasObject());
+#endif
+
+}
+
 void WebView::initialize()
 {
     m_page->initializeWebPage();
@@ -276,11 +288,19 @@ bool WebView::isViewWindowActive()
 
 bool WebView::isViewFocused()
 {
+    // FIXME: Unneeded after webkit.org/b/110877
+    if (!m_ewkView)
+        return false;
+
     return m_ewkView->isFocused();
 }
 
 bool WebView::isViewVisible()
 {
+    // FIXME: Unneeded after webkit.org/b/110877
+    if (!m_ewkView)
+        return false;
+
     return m_ewkView->isVisible();
 }
 
index 9f5f6f4..0a82268 100644 (file)
@@ -50,9 +50,13 @@ class WebView : public APIObject, public PageClient {
 public:
     static const Type APIType = TypeView;
 
-    WebView(WebContext*, WebPageGroup*, EwkView*);
     virtual ~WebView();
 
+    static PassRefPtr<WebView> create(WebContext*, WebPageGroup*);
+
+    // FIXME: Remove when possible.
+    void setEwkView(EwkView*);
+
     void initialize();
 
     void setUserViewportTranslation(double tx, double ty);
@@ -96,6 +100,7 @@ public:
     WebCore::AffineTransform transformToScene() const;
 
 private:
+    WebView(WebContext*, WebPageGroup*);
     WebCore::CoordinatedGraphicsScene* coordinatedGraphicsScene();
 
     // PageClient
index 7adabf8..f441605 100644 (file)
@@ -1,3 +1,39 @@
+2013-03-19  Kenneth Rohde Christiansen  <kenneth@webkit.org> and Mikhail Pozdnyakov  <mikhail.pozdnyakov@intel.com>
+
+        [EFL][WK2] Separate WebView further from EwkView
+        https://bugs.webkit.org/show_bug.cgi?id=111591
+
+        Reviewed by Caio Marcelo de Oliveira Filho.
+
+        Updated EFL PlatformWebView to meet the new WKView API and ewk view private API.
+        PlatformWKView is pointer to Evas_Object for EFL, as this is more natural and
+        since we can afford it having EWKViewGetWKView() private API to access WKView.
+
+        * TestWebKitAPI/PlatformWebView.h:
+        * TestWebKitAPI/Tests/WebKit2/efl/WKViewClientWebProcessCallbacks.cpp:
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/efl/PlatformWebView.cpp:
+        (TestWebKitAPI::PlatformWebView::PlatformWebView):
+        (TestWebKitAPI::PlatformWebView::~PlatformWebView):
+        (TestWebKitAPI::PlatformWebView::resizeTo):
+        (TestWebKitAPI::PlatformWebView::page):
+        (TestWebKitAPI::PlatformWebView::simulateSpacebarKeyPress):
+        (TestWebKitAPI::PlatformWebView::simulateMouseMove):
+        (TestWebKitAPI::PlatformWebView::simulateRightClick):
+        * WebKitTestRunner/PlatformWebView.h:
+        * WebKitTestRunner/efl/EventSenderProxyEfl.cpp:
+        (WTR::EventSenderProxy::dispatchEvent):
+        (WTR::EventSenderProxy::keyDown):
+        (WTR::EventSenderProxy::sendTouchEvent):
+        (WTR::EventSenderProxy::setTouchModifier):
+        * WebKitTestRunner/efl/PlatformWebViewEfl.cpp:
+        (WTR::PlatformWebView::PlatformWebView):
+        (WTR::PlatformWebView::~PlatformWebView):
+        (WTR::PlatformWebView::resizeTo):
+        (WTR::PlatformWebView::page):
+        (WTR::PlatformWebView::focus):
+        (WTR::PlatformWebView::windowSnapshotImage):
+
 2013-03-19  Roger Fong  <roger_fong@apple.com>
 
         Changes to VS2010 project files should only trigger builds on Windows bots.
index b56c096..5594ee4 100644 (file)
@@ -48,7 +48,8 @@ typedef WKViewRef PlatformWKView;
 typedef GtkWidget *PlatformWindow;
 #elif PLATFORM(EFL)
 typedef struct _Ecore_Evas Ecore_Evas;
-typedef WKViewRef PlatformWKView;
+typedef struct _Evas_Object Evas_Object;
+typedef Evas_Object* PlatformWKView;
 typedef Ecore_Evas* PlatformWindow;
 #elif PLATFORM(QT)
 QT_BEGIN_NAMESPACE
index c4b67aa..450dcf1 100644 (file)
@@ -24,6 +24,7 @@
  */
 
 #include "config.h"
+#include "ewk_view_private.h"
 #include "PlatformUtilities.h"
 #include "PlatformWebView.h"
 #include "Test.h"
@@ -104,11 +105,12 @@ TEST(WebKit2, WKViewClientWebProcessCallbacks)
     WKRetainPtr<WKURLRef> url(AdoptWK, Util::createURLForResource("simple", "html"));
 
     PlatformWebView view(context.get());
+    WKViewRef wkView = EWKViewGetWKView(view.platformView());
 
-    TestStatesData states = TestStatesData(view.platformView(), url.get());
+    TestStatesData states = TestStatesData(wkView, url.get());
 
     setPageLoaderClient(view.page(), &states);
-    setViewClient(view.platformView(), &states);
+    setViewClient(wkView, &states);
 
     WKPageLoadURL(view.page(), url.get());
     Util::run(&states.didFinishLoad);
index 8a035f3..be29f0e 100644 (file)
  */
 
 #include "config.h"
+#include "ewk_view_private.h"
 #include "PlatformWebView.h"
 
 #include "EWebKit2.h"
-#include "WebKit2/WKAPICast.h"
+#include <WebKit2/WKAPICast.h>
+#include <WebKit2/WKRetainPtr.h>
 #include <Ecore_Evas.h>
 
 extern bool useX11Window;
@@ -64,23 +66,19 @@ static void onWebProcessCrashed(void*, Evas_Object*, void* eventInfo)
 PlatformWebView::PlatformWebView(WKContextRef contextRef, WKPageGroupRef pageGroupRef)
 {
     m_window = initEcoreEvas();
-    Evas* evas = ecore_evas_get(m_window);
-    m_view = WKViewCreate(evas, contextRef, pageGroupRef);
-    ewk_view_theme_set(WKViewGetEvasObject(m_view), THEME_DIR"/default.edj");
-    evas_object_smart_callback_add(WKViewGetEvasObject(m_view), "webprocess,crashed", onWebProcessCrashed, 0);
+
+    m_view = EWKViewCreate(contextRef, pageGroupRef, ecore_evas_get(m_window), /* smart */ 0);
+
+    WKRetainPtr<WKStringRef> wkTheme = adoptWK(WKStringCreateWithUTF8CString(THEME_DIR "/default.edj"));
+    WKViewSetThemePath(EWKViewGetWKView(m_view), wkTheme.get());
+
+    evas_object_smart_callback_add(m_view, "webprocess,crashed", onWebProcessCrashed, 0);
     resizeTo(600, 800);
 }
 
 PlatformWebView::~PlatformWebView()
 {
-    Evas_Object* evasObject = WKViewGetEvasObject(m_view);
-
-    // Release first. WebView should not live longer than EwkView, as EwkView owns objects that page proxy refers to.
-    WKRelease(m_view);
-
-    // FIXME: The C WKView API currently creates the Evas_Object, so we have to destruct it
-    // (and its dependencies EwkView and WebKit::WebView) this way, until this get fixed.
-    evas_object_del(evasObject);
+    evas_object_del(m_view);
 
     ecore_evas_free(m_window);
     ecore_evas_shutdown();
@@ -88,33 +86,33 @@ PlatformWebView::~PlatformWebView()
 
 void PlatformWebView::resizeTo(unsigned width, unsigned height)
 {
-    evas_object_resize(WKViewGetEvasObject(m_view), width, height);
+    evas_object_resize(m_view, width, height);
 }
 
 WKPageRef PlatformWebView::page() const
 {
-    return WKViewGetPage(m_view);
+    return WKViewGetPage(EWKViewGetWKView(m_view));
 }
 
 void PlatformWebView::simulateSpacebarKeyPress()
 {
-    Evas* evas = ecore_evas_get(m_window);
-    evas_object_focus_set(WKViewGetEvasObject(m_view), true);
+    Evas* evas = evas_object_evas_get(m_view);
+    evas_object_focus_set(m_view, true);
     evas_event_feed_key_down(evas, "space", "space", " ", 0, 0, 0);
     evas_event_feed_key_up(evas, "space", "space", " ", 0, 1, 0);
 }
 
 void PlatformWebView::simulateMouseMove(unsigned x, unsigned y)
 {
-    Evas* evas = ecore_evas_get(m_window);
-    evas_object_show(WKViewGetEvasObject(m_view));
+    Evas* evas = evas_object_evas_get(m_view);
+    evas_object_show(m_view);
     evas_event_feed_mouse_move(evas, x, y, 0, 0);
 }
 
 void PlatformWebView::simulateRightClick(unsigned x, unsigned y)
 {
-    Evas* evas = ecore_evas_get(m_window);
-    evas_object_show(WKViewGetEvasObject(m_view));
+    Evas* evas = evas_object_evas_get(m_view);
+    evas_object_show(m_view);
     evas_event_feed_mouse_move(evas, x, y, 0, 0);
     evas_event_feed_mouse_down(evas, 3, EVAS_BUTTON_NONE, 0, 0);
     evas_event_feed_mouse_up(evas, 3, EVAS_BUTTON_NONE, 0, 0);
index b9fa678..8df1144 100644 (file)
@@ -55,7 +55,8 @@ typedef WKViewRef PlatformWKView;
 typedef GtkWidget* PlatformWindow;
 #elif PLATFORM(EFL)
 typedef struct _Ecore_Evas Ecore_Evas;
-typedef WKViewRef PlatformWKView;
+typedef struct _Evas_Object Evas_Object;
+typedef Evas_Object* PlatformWKView;
 typedef Ecore_Evas* PlatformWindow;
 #endif
 
index 13920ec..424974d 100644 (file)
@@ -314,14 +314,16 @@ void EventSenderProxy::updateClickCountForButton(int button)
 
 void EventSenderProxy::dispatchEvent(const WTREvent& event)
 {
+    Evas* evas = evas_object_evas_get(m_testController->mainWebView()->platformView());
+
     if (event.eventType == WTREventTypeMouseDown)
-        dispatchMouseDownEvent(ecore_evas_get(m_testController->mainWebView()->platformWindow()), event.button, event.modifiers, m_clickCount);
+        dispatchMouseDownEvent(evas, event.button, event.modifiers, m_clickCount);
     else if (event.eventType == WTREventTypeMouseUp)
-        dispatchMouseUpEvent(ecore_evas_get(m_testController->mainWebView()->platformWindow()), event.button, event.modifiers);
+        dispatchMouseUpEvent(evas, event.button, event.modifiers);
     else if (event.eventType == WTREventTypeMouseMove)
-        dispatchMouseMoveEvent(ecore_evas_get(m_testController->mainWebView()->platformWindow()), static_cast<int>(m_position.x), static_cast<int>(m_position.y));
+        dispatchMouseMoveEvent(evas, static_cast<int>(m_position.x), static_cast<int>(m_position.y));
     else if (event.eventType == WTREventTypeMouseScrollBy)
-        dispatchMouseScrollByEvent(ecore_evas_get(m_testController->mainWebView()->platformWindow()), event.horizontal, event.vertical);
+        dispatchMouseScrollByEvent(evas, event.horizontal, event.vertical);
 }
 
 void EventSenderProxy::replaySavedEvents()
@@ -412,7 +414,7 @@ void EventSenderProxy::keyDown(WKStringRef keyRef, WKEventModifiers wkModifiers,
     if ((strlen(keyName) == 1) && (keyName[0] >= 'A' && keyName[0] <= 'Z'))
         wkModifiers |= kWKEventModifiersShiftKey;
 
-    Evas* evas = ecore_evas_get(m_testController->mainWebView()->platformWindow());
+    Evas* evas = evas_object_evas_get(m_testController->mainWebView()->platformView());
 
     int eventIndex = 0;
     // Mimic the emacs ctrl-o binding by inserting a paragraph
@@ -438,7 +440,7 @@ void EventSenderProxy::sendTouchEvent(Ewk_Touch_Event_Type eventType)
 {
     ASSERT(m_touchPoints);
 
-    Evas_Object* ewkView = WKViewGetEvasObject(m_testController->mainWebView()->platformView());
+    Evas_Object* ewkView = m_testController->mainWebView()->platformView();
     ewk_view_feed_touch_event(ewkView, eventType, m_touchPoints, evas_key_modifier_get(evas_object_evas_get(ewkView)));
 
     Eina_List* list;
@@ -490,7 +492,7 @@ void EventSenderProxy::updateTouchPoint(int index, int x, int y)
 
 void EventSenderProxy::setTouchModifier(WKEventModifiers modifier, bool enable)
 {
-    Evas_Object* ewkView = WKViewGetEvasObject(m_testController->mainWebView()->platformView());
+    Evas_Object* ewkView = m_testController->mainWebView()->platformView();
 
     for (unsigned index = 0; index < (sizeof(modifierNames) / sizeof(char*)); ++index) {
         if (modifier & (1 << index)) {
index f6e4745..bda1b08 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 #include "config.h"
+#include "ewk_view_private.h"
 #include "PlatformWebView.h"
 
 #include "EWebKit2.h"
@@ -59,52 +60,44 @@ PlatformWebView::PlatformWebView(WKContextRef context, WKPageGroupRef pageGroup,
     m_usingFixedLayout = options ? WKBooleanGetValue(static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(options, useFixedLayoutKey.get()))) : false;
 
     m_window = initEcoreEvas();
-    Evas* evas = ecore_evas_get(m_window);
 
-    if (m_usingFixedLayout) {
-        m_view = WKViewCreateWithFixedLayout(evas, context, pageGroup);
-        evas_object_resize(WKViewGetEvasObject(m_view), 800, 600);
-    } else
-        m_view = WKViewCreate(evas, context, pageGroup);
+    m_view = EWKViewCreate(context, pageGroup, ecore_evas_get(m_window), /* smart */ 0);
 
-    ewk_view_theme_set(WKViewGetEvasObject(m_view), THEME_DIR"/default.edj");
+    WKPageSetUseFixedLayout(WKViewGetPage(EWKViewGetWKView(m_view)), m_usingFixedLayout);
+
+    if (m_usingFixedLayout)
+        resizeTo(800, 600);
+
+    ewk_view_theme_set(m_view, THEME_DIR"/default.edj");
     m_windowIsKey = false;
-    evas_object_show(WKViewGetEvasObject(m_view));
+    evas_object_show(m_view);
 }
 
 PlatformWebView::~PlatformWebView()
 {
-    Evas_Object* evasObject = WKViewGetEvasObject(m_view);
-
-    // Release first. WebView should not live longer than EwkView, as EwkView owns objects that page proxy refers to.
-    WKRelease(m_view);
-
-    // FIXME: The C WKView API currently creates the Evas_Object, so we have to destruct it
-    // (and its dependencies EwkView and WebKit::WebView) this way, until this get fixed.
-    evas_object_del(evasObject);
+    evas_object_del(m_view);
 
     ecore_evas_free(m_window);
 }
 
 void PlatformWebView::resizeTo(unsigned width, unsigned height)
 {
-    evas_object_resize(WKViewGetEvasObject(m_view), width, height);
+    evas_object_resize(m_view, width, height);
 }
 
 WKPageRef PlatformWebView::page()
 {
-    return WKViewGetPage(m_view);
+    return WKViewGetPage(EWKViewGetWKView(m_view));
 }
 
 void PlatformWebView::focus()
 {
-    Evas_Object* evasObject = WKViewGetEvasObject(m_view);
     // In a few cases, an iframe might receive focus from JavaScript and Evas is not aware of it at all
     // (WebCoreSupport::focusedFrameChanged() does not emit any notification). We then manually remove the
     // focus from the view to make the call give focus to evas_object_focus_set(..., true) to be effectful.
     if (WKPageGetFocusedFrame(page()) != WKPageGetMainFrame(page()))
-        evas_object_focus_set(evasObject, false);
-    evas_object_focus_set(evasObject, true);
+        evas_object_focus_set(m_view, false);
+    evas_object_focus_set(m_view, true);
 }
 
 WKRect PlatformWebView::windowFrame()
@@ -140,7 +133,7 @@ WKRetainPtr<WKImageRef> PlatformWebView::windowSnapshotImage()
     ecore_evas_geometry_get(m_window, 0, 0, &width, &height);
     ASSERT(width > 0 && height > 0);
 
-    return adoptWK(WKViewCreateSnapshot(m_view));
+    return adoptWK(WKViewCreateSnapshot(EWKViewGetWKView(m_view)));
 }
 
 bool PlatformWebView::viewSupportsOptions(WKDictionaryRef options) const