Changeset 141836 in webkit


Ignore:
Timestamp:
Feb 4, 2013 5:20:10 PM (11 years ago)
Author:
kenneth@webkit.org
Message:

[EFL][WK2] Introduce a WebView class as counterpart for WKViewRef
https://bugs.webkit.org/show_bug.cgi?id=107931

Reviewed by Anders Carlsson.

Source/WebKit2:

This is just one step of the new plan for the EFL API.

The plan is to move the public EFL-like API on top of the shared
WK2 C API, plus a few EFL extensions (WKView class mostly).

The EFL-like API can be seen as a convenience API which ties
well into EFL and which makes it easy to add web experiences
to existing and new EFL applications. It provides a smart object
like API and a Evas_Object based view.

For more advanced use cases, such as browser and runtime, it is
possible to use the WK* C API, which is gives more flexibility
while being more low level.

The idea is that the WKView class will not depend on Evas_Object
and X11 (future plan) unlike the current EFL-like API. This should
make it possible to use it for cases where none of these are
available.

This patch introduces the WebView class which serves as our
counterpart for the WKView class, and adds a few needed methods.

The EwkView owns the WebView class (and will be constructing it
in the near future when the EwkView class has been changed to
handle all smart object related code)

The clean up of the smart object related code as the proper
construction of EwkView and WebView will be done in follow-up
patches.

  • UIProcess/API/C/efl/WKAPICastEfl.h:

(WebKit):

The WKView API is not based on WebView and not Evas_Object*

  • UIProcess/API/C/efl/WKView.cpp:

(WKViewCreate):
(WKViewCreateWithFixedLayout):
(WKViewInitialize):
(WKViewGetPage):
(WKViewSetThemePath):
(WKViewSuspendActiveDOMObjectsAndAnimations):
(WKViewResumeActiveDOMObjectsAndAnimations):
(WKViewGetEvasObject):
(WKViewCreateSnapshot):

Add a few new WKView EFL C methods, and update existing
methods to reflect that the WKViewRef is now a WebView*

The construction methods will be rewritten when the smart
object construction has been solved.

  • UIProcess/API/C/efl/WKView.h:
  • UIProcess/efl/WebView.cpp: Added.

(WebKit):
(WebKit::WebView::WebView):
(WebKit::WebView::~WebView):
(WebKit::WebView::initialize):
(WebKit::WebView::setThemePath):
(WebKit::WebView::suspendActiveDOMObjectsAndAnimations):
(WebKit::WebView::resumeActiveDOMObjectsAndAnimations):

  • UIProcess/efl/WebView.h: Added.

(WebKit):
(WebView):
(WebKit::WebView::pageRef):
(WebKit::WebView::evasObject):
(WebKit::WebView::page):
(WebKit::WebView::type):

Add a new WebKit::WebView class for EFL.

  • UIProcess/API/efl/EwkView.cpp:

(EwkView::EwkView):
(EwkView::~EwkView):
(EwkView::wkPage):
(EwkView::setThemePath):
(EwkView::createGLSurface):

Base methods on C API instead of internal API as much
as currently possible.

  • UIProcess/API/efl/EwkView.h:

(WebKit):
(WebView):
(EwkView):
(EwkView::wkView):
(EwkView::page):

  • UIProcess/API/efl/ewk_view.cpp:

(createEwkView):
(ewk_view_base_add):
(ewk_view_smart_add):

Modify to return the EwkView class for now.

  • UIProcess/API/efl/ewk_view_private.h:
  • UIProcess/efl/WebInspectorProxyEfl.cpp:

(WebKit::WebInspectorProxy::platformCreateInspectorPage):

Updated due to changed API.

Tools:

Change platformView to be a WKView and use WKViewGetEvasObject
for the places where an Evas_Object is needed.

Instead of extracting the Ecore_Evas* from the m_view we use
the m_window instead, which actually holds the it.

  • TestWebKitAPI/PlatformWebView.h:
  • 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::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::windowFrame):
(WTR::PlatformWebView::setWindowFrame):
(WTR::PlatformWebView::windowSnapshotImage):

Location:
trunk
Files:
2 added
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r141834 r141836  
     12013-02-04  Kenneth Rohde Christiansen  <kenneth@webkit.org>
     2
     3        [EFL][WK2] Introduce a WebView class as counterpart for WKViewRef
     4        https://bugs.webkit.org/show_bug.cgi?id=107931
     5
     6        Reviewed by Anders Carlsson.
     7
     8        This is just one step of the new plan for the EFL API.
     9
     10        The plan is to move the public EFL-like API on top of the shared
     11        WK2 C API, plus a few EFL extensions (WKView class mostly).
     12
     13        The EFL-like API can be seen as a convenience API which ties
     14        well into EFL and which makes it easy to add web experiences
     15        to existing and new EFL applications. It provides a smart object
     16        like API and a Evas_Object based view.
     17
     18        For more advanced use cases, such as browser and runtime, it is
     19        possible to use the WK* C API, which is gives more flexibility
     20        while being more low level.
     21
     22        The idea is that the WKView class will not depend on Evas_Object
     23        and X11 (future plan) unlike the current EFL-like API. This should
     24        make it possible to use it for cases where none of these are
     25        available.
     26
     27        This patch introduces the WebView class which serves as our
     28        counterpart for the WKView class, and adds a few needed methods.
     29
     30        The EwkView owns the WebView class (and will be constructing it
     31        in the near future when the EwkView class has been changed to
     32        handle all smart object related code)
     33
     34        The clean up of the smart object related code as the proper
     35        construction of EwkView and WebView will be done in follow-up
     36        patches.
     37
     38        * UIProcess/API/C/efl/WKAPICastEfl.h:
     39        (WebKit):
     40
     41            The WKView API is not based on WebView and not Evas_Object*
     42
     43        * UIProcess/API/C/efl/WKView.cpp:
     44        (WKViewCreate):
     45        (WKViewCreateWithFixedLayout):
     46        (WKViewInitialize):
     47        (WKViewGetPage):
     48        (WKViewSetThemePath):
     49        (WKViewSuspendActiveDOMObjectsAndAnimations):
     50        (WKViewResumeActiveDOMObjectsAndAnimations):
     51        (WKViewGetEvasObject):
     52        (WKViewCreateSnapshot):
     53
     54            Add a few new WKView EFL C methods, and update existing
     55            methods to reflect that the WKViewRef is now a WebView*
     56
     57            The construction methods will be rewritten when the smart
     58            object construction has been solved.
     59
     60        * UIProcess/API/C/efl/WKView.h:
     61        * UIProcess/efl/WebView.cpp: Added.
     62        (WebKit):
     63        (WebKit::WebView::WebView):
     64        (WebKit::WebView::~WebView):
     65        (WebKit::WebView::initialize):
     66        (WebKit::WebView::setThemePath):
     67        (WebKit::WebView::suspendActiveDOMObjectsAndAnimations):
     68        (WebKit::WebView::resumeActiveDOMObjectsAndAnimations):
     69        * UIProcess/efl/WebView.h: Added.
     70        (WebKit):
     71        (WebView):
     72        (WebKit::WebView::pageRef):
     73        (WebKit::WebView::evasObject):
     74        (WebKit::WebView::page):
     75        (WebKit::WebView::type):
     76
     77            Add a new WebKit::WebView class for EFL.
     78
     79        * UIProcess/API/efl/EwkView.cpp:
     80        (EwkView::EwkView):
     81        (EwkView::~EwkView):
     82        (EwkView::wkPage):
     83        (EwkView::setThemePath):
     84        (EwkView::createGLSurface):
     85
     86            Base methods on C API instead of internal API as much
     87            as currently possible.
     88
     89        * UIProcess/API/efl/EwkView.h:
     90        (WebKit):
     91        (WebView):
     92        (EwkView):
     93        (EwkView::wkView):
     94        (EwkView::page):
     95        * UIProcess/API/efl/ewk_view.cpp:
     96        (createEwkView):
     97        (ewk_view_base_add):
     98        (ewk_view_smart_add):
     99
     100            Modify to return the EwkView class for now.
     101
     102        * UIProcess/API/efl/ewk_view_private.h:
     103        * UIProcess/efl/WebInspectorProxyEfl.cpp:
     104        (WebKit::WebInspectorProxy::platformCreateInspectorPage):
     105
     106            Updated due to changed API.
     107
    11082013-02-04  Anders Carlsson  <andersca@apple.com>
    2109
  • trunk/Source/WebKit2/PlatformEfl.cmake

    r141439 r141836  
    108108    UIProcess/efl/WebPreferencesEfl.cpp
    109109    UIProcess/efl/WebProcessProxyEfl.cpp
     110    UIProcess/efl/WebView.cpp
    110111
    111112    UIProcess/InspectorServer/efl/WebInspectorServerEfl.cpp
  • trunk/Source/WebKit2/UIProcess/API/C/efl/WKAPICastEfl.h

    r138326 r141836  
    2525#endif
    2626
    27 #if USE(EO)
    28 typedef struct _Eo Evas_Object;
    29 #else
    30 typedef struct _Evas_Object Evas_Object;
    31 #endif
    32 
    3327namespace WebKit {
    3428
    35 WK_ADD_API_MAPPING(WKViewRef, Evas_Object)
     29class WebView;
     30
     31WK_ADD_API_MAPPING(WKViewRef, WebView)
    3632
    3733}
  • trunk/Source/WebKit2/UIProcess/API/C/efl/WKView.cpp

    r140686 r141836  
    3030WKViewRef WKViewCreate(Evas* canvas, WKContextRef contextRef, WKPageGroupRef pageGroupRef)
    3131{
    32     return toAPI(ewk_view_base_add(canvas, contextRef, pageGroupRef, EwkView::LegacyBehavior));
     32    EwkView* ewkView = ewk_view_base_add(canvas, contextRef, pageGroupRef, EwkView::LegacyBehavior);
     33    if (!ewkView)
     34        return 0;
     35
     36    return static_cast<WKViewRef>(WKRetain(ewkView->wkView()));
    3337}
    3438
    3539WKViewRef WKViewCreateWithFixedLayout(Evas* canvas, WKContextRef contextRef, WKPageGroupRef pageGroupRef)
    3640{
    37     return toAPI(ewk_view_base_add(canvas, contextRef, pageGroupRef, EwkView::DefaultBehavior));
     41    EwkView* ewkView = ewk_view_base_add(canvas, contextRef, pageGroupRef, EwkView::DefaultBehavior);
     42    if (!ewkView)
     43        return 0;
     44
     45    return static_cast<WKViewRef>(WKRetain(ewkView->wkView()));
     46}
     47
     48void WKViewInitialize(WKViewRef viewRef)
     49{
     50    toImpl(viewRef)->initialize();
    3851}
    3952
    4053WKPageRef WKViewGetPage(WKViewRef viewRef)
    4154{
    42     EwkView* view = EwkView::fromEvasObject(toImpl(viewRef));
     55    return toImpl(viewRef)->pageRef();
     56}
    4357
    44     return view->wkPage();
     58void WKViewSetThemePath(WKViewRef viewRef, WKStringRef theme)
     59{
     60    toImpl(viewRef)->setThemePath(theme);
     61}
     62
     63void WKViewSuspendActiveDOMObjectsAndAnimations(WKViewRef viewRef)
     64{
     65    toImpl(viewRef)->suspendActiveDOMObjectsAndAnimations();
     66}
     67
     68void WKViewResumeActiveDOMObjectsAndAnimations(WKViewRef viewRef)
     69{
     70    toImpl(viewRef)->resumeActiveDOMObjectsAndAnimations();
     71}
     72
     73Evas_Object* WKViewGetEvasObject(WKViewRef viewRef)
     74{
     75    return toImpl(viewRef)->evasObject();
    4576}
    4677
    4778WKImageRef WKViewCreateSnapshot(WKViewRef viewRef)
    4879{
    49     EwkView* view = EwkView::fromEvasObject(toImpl(viewRef));
    50 
    51     return WKImageCreateFromCairoSurface(view->takeSnapshot().get(), 0 /* options */);
     80    EwkView* ewkView = EwkView::fromEvasObject(toImpl(viewRef)->evasObject());
     81    return WKImageCreateFromCairoSurface(ewkView->takeSnapshot().get(), 0 /* options */);
    5282}
  • trunk/Source/WebKit2/UIProcess/API/C/efl/WKView.h

    r138462 r141836  
    2525#if USE(EO)
    2626typedef struct _Eo Evas;
     27typedef struct _Eo Evas_Object;
    2728#else
    2829typedef struct _Evas Evas;
     30typedef struct _Evas_Object Evas_Object;
    2931#endif
    3032
     
    3739WK_EXPORT WKViewRef WKViewCreateWithFixedLayout(Evas* canvas, WKContextRef context, WKPageGroupRef pageGroup);
    3840
    39 WK_EXPORT WKPageRef WKViewGetPage(WKViewRef view);
     41WK_EXPORT void WKViewInitialize(WKViewRef);
    4042
    41 WK_EXPORT WKImageRef WKViewCreateSnapshot(WKViewRef viewRef);
     43WK_EXPORT WKPageRef WKViewGetPage(WKViewRef);
     44
     45WK_EXPORT void WKViewSetThemePath(WKViewRef, WKStringRef);
     46
     47WK_EXPORT void WKViewSuspendActiveDOMObjectsAndAnimations(WKViewRef);
     48WK_EXPORT void WKViewResumeActiveDOMObjectsAndAnimations(WKViewRef);
     49
     50// FIXME: The long term plan is to get rid of this, so keep usage to a bare minimum.
     51WK_EXPORT Evas_Object* WKViewGetEvasObject(WKViewRef);
     52
     53WK_EXPORT WKImageRef WKViewCreateSnapshot(WKViewRef);
    4254
    4355#ifdef __cplusplus
  • trunk/Source/WebKit2/UIProcess/API/efl/EwkView.cpp

    r141827 r141836  
    4040#include "WKPageGroup.h"
    4141#include "WKString.h"
     42#include "WKView.h"
    4243#include "WebContext.h"
    4344#include "WebImage.h"
     
    112113}
    113114
    114 EwkView::EwkView(Evas_Object* evasObject, PassRefPtr<EwkContext> context, PassRefPtr<WebPageGroup> pageGroup, ViewBehavior behavior)
    115     : m_evasObject(evasObject)
     115EwkView::EwkView(Evas_Object* view, PassRefPtr<EwkContext> context, WebPageGroup* pageGroup, ViewBehavior behavior)
     116    : m_evasObject(view)
    116117    , m_context(context)
    117118#if USE(ACCELERATED_COMPOSITING)
     
    119120#endif
    120121    , m_pageClient(behavior == DefaultBehavior ? PageClientDefaultImpl::create(this) : PageClientLegacyImpl::create(this))
    121     , m_pageProxy(toImpl(m_context->wkContext())->createWebPage(m_pageClient.get(), pageGroup.get()))
     122    , m_webView(adoptRef(new WebView(toImpl(m_context->wkContext()), m_pageClient.get(), pageGroup, view)))
    122123    , m_pageLoadClient(PageLoadClientEfl::create(this))
    123124    , m_pagePolicyClient(PagePolicyClientEfl::create(this))
     
    129130    , m_vibrationClient(VibrationClientEfl::create(this))
    130131#endif
    131     , m_backForwardList(EwkBackForwardList::create(toAPI(m_pageProxy->backForwardList())))
     132    , m_backForwardList(EwkBackForwardList::create(WKPageGetBackForwardList(wkPage())))
    132133#if USE(TILED_BACKING_STORE)
    133134    , m_pageScaleFactor(1)
     
    146147    ASSERT(m_evasObject);
    147148    ASSERT(m_context);
    148     ASSERT(m_pageProxy);
     149
     150    WKViewInitialize(wkView());
    149151
    150152    WKPageSetUseFixedLayout(wkPage(), behavior == DefaultBehavior);
     
    158160    WKPreferencesSetOfflineWebApplicationCacheEnabled(wkPreferences, true);
    159161
    160 #if USE(COORDINATED_GRAPHICS)
    161     m_pageProxy->pageGroup()->preferences()->setAcceleratedCompositingEnabled(true);
    162     m_pageProxy->pageGroup()->preferences()->setForceCompositingMode(true);
    163     char* debugVisualsEnvironment = getenv("WEBKIT_SHOW_COMPOSITING_DEBUG_VISUALS");
    164     bool showDebugVisuals = debugVisualsEnvironment && !strcmp(debugVisualsEnvironment, "1");
    165     m_pageProxy->pageGroup()->preferences()->setCompositingBordersVisible(showDebugVisuals);
    166     m_pageProxy->pageGroup()->preferences()->setCompositingRepaintCountersVisible(showDebugVisuals);
    167 #endif
    168 
    169     m_pageProxy->initializeWebPage();
    170 
    171 #if ENABLE(FULLSCREEN_API)
    172     m_pageProxy->fullScreenManager()->setWebView(m_evasObject);
    173 #endif
    174 
    175162    // Enable mouse events by default
    176163    setMouseEventsEnabled(true);
     
    187174EwkView::~EwkView()
    188175{
    189     m_pageProxy->close();
    190 
    191176    // Unregister icon change callback.
    192177    EwkFaviconDatabase* iconDatabase = m_context->faviconDatabase();
     
    214199WKPageRef EwkView::wkPage() const
    215200{
    216     return toAPI(m_pageProxy.get());
     201    return WKViewGetPage(wkView());
    217202}
    218203
     
    547532    if (m_theme != theme) {
    548533        m_theme = theme;
    549         m_pageProxy->setThemePath(theme);
     534        WKRetainPtr<WKStringRef> wkTheme = adoptWK(WKStringCreateWithUTF8CString(theme));
     535        WKViewSetThemePath(wkView(), wkTheme.get());
    550536    }
    551537}
     
    647633            WARN("Failed to create Evas_GL, falling back to software mode.");
    648634            m_isHardwareAccelerated = false;
    649 #if ENABLE(WEBGL)
    650             m_pageProxy->pageGroup()->preferences()->setWebGLEnabled(false);
    651 #endif
    652635            return false;
    653636        }
     
    10301013{
    10311014    // Suspend all animations before taking the snapshot.
    1032     m_pageProxy->suspendActiveDOMObjectsAndAnimations();
     1015    WKViewSuspendActiveDOMObjectsAndAnimations(wkView());
    10331016
    10341017    // Wait for the pending repaint events to be processed.
     
    10421025        RefPtr<cairo_surface_t> snapshot = createSurfaceForImage(sd->image);
    10431026        // Resume all animations.
    1044         m_pageProxy->resumeActiveDOMObjectsAndAnimations();
     1027        WKViewResumeActiveDOMObjectsAndAnimations(wkView());
    10451028
    10461029        return snapshot.release();
     
    10501033    RefPtr<cairo_surface_t> snapshot = getImageSurfaceFromFrameBuffer(0, 0, sd->view.w, sd->view.h);
    10511034    // Resume all animations.
    1052     m_pageProxy->resumeActiveDOMObjectsAndAnimations();
     1035    WKViewResumeActiveDOMObjectsAndAnimations(wkView());
    10531036
    10541037    return snapshot.release();
  • trunk/Source/WebKit2/UIProcess/API/efl/EwkView.h

    r141827 r141836  
    2828#include "WKGeometry.h"
    2929#include "WKRetainPtr.h"
     30#include "WebView.h"
    3031#include "ewk_url_request_private.h"
    3132#include <Evas.h>
     
    4950#include "EvasGLSurface.h"
    5051#endif
     52
     53#include "WebContext.h"
     54#include "WebPageGroup.h"
     55#include "WebPreferences.h"
    5156
    5257namespace WebKit {
     
    103108        DefaultBehavior
    104109    };
    105     EwkView(Evas_Object* view, PassRefPtr<EwkContext> context, PassRefPtr<WebKit::WebPageGroup> pageGroup, ViewBehavior);
     110    EwkView(Evas_Object* view, PassRefPtr<EwkContext> context, WebKit::WebPageGroup* pageGroup, ViewBehavior);
    106111    ~EwkView();
    107112
     
    109114    Evas_Object* view() { return m_evasObject; }
    110115
     116    WKViewRef wkView() const { return toAPI(m_webView.get()); }
    111117    WKPageRef wkPage() const;
    112     WebKit::WebPageProxy* page() { return m_pageProxy.get(); }
     118
     119    WebKit::WebPageProxy* page() { return m_webView->page(); }
    113120    EwkContext* ewkContext() { return m_context.get(); }
    114121    EwkSettings* settings() { return m_settings.get(); }
     
    245252#endif
    246253    OwnPtr<WebKit::PageClientBase> m_pageClient;
    247     RefPtr<WebKit::WebPageProxy> m_pageProxy;
     254    RefPtr<WebKit::WebView> m_webView;
    248255    OwnPtr<WebKit::PageLoadClientEfl> m_pageLoadClient;
    249256    OwnPtr<WebKit::PagePolicyClientEfl> m_pagePolicyClient;
  • trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp

    r141583 r141836  
    505505}
    506506
    507 static inline Evas_Object* createEwkView(Evas* canvas, Evas_Smart* smart, PassRefPtr<EwkContext> context, WKPageGroupRef pageGroupRef = 0, EwkView::ViewBehavior behavior = EwkView::DefaultBehavior)
     507static inline EwkView* createEwkView(Evas* canvas, Evas_Smart* smart, PassRefPtr<EwkContext> context, WKPageGroupRef pageGroupRef = 0, EwkView::ViewBehavior behavior = EwkView::DefaultBehavior)
    508508{
    509509    EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
     
    525525    // so we do not need to create it here.
    526526    smartData->priv = new EwkView(ewkView, context, toImpl(pageGroupRef), behavior);
    527     return ewkView;
     527    return smartData->priv;
    528528}
    529529
     
    532532 * Constructs a ewk_view Evas_Object with WKType parameters.
    533533 */
    534 Evas_Object* ewk_view_base_add(Evas* canvas, WKContextRef contextRef, WKPageGroupRef pageGroupRef, EwkView::ViewBehavior behavior)
     534EwkView* ewk_view_base_add(Evas* canvas, WKContextRef contextRef, WKPageGroupRef pageGroupRef, EwkView::ViewBehavior behavior)
    535535{
    536536    return createEwkView(canvas, createEwkViewSmartClass(), contextRef ? EwkContext::create(contextRef) : EwkContext::defaultContext(), pageGroupRef, behavior);
     
    539539Evas_Object* ewk_view_smart_add(Evas* canvas, Evas_Smart* smart, Ewk_Context* context)
    540540{
    541     return createEwkView(canvas, smart, ewk_object_cast<EwkContext*>(context));
     541    EwkView* ewkView = createEwkView(canvas, smart, ewk_object_cast<EwkContext*>(context));
     542    if (!ewkView)
     543        return 0;
     544
     545    return ewkView->view();
    542546}
    543547
  • trunk/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h

    r140686 r141836  
    2626#include <WebKit2/WKBase.h>
    2727
    28 Evas_Object* ewk_view_base_add(Evas* canvas, WKContextRef, WKPageGroupRef, EwkView::ViewBehavior);
     28EwkView* ewk_view_base_add(Evas* canvas, WKContextRef, WKPageGroupRef, EwkView::ViewBehavior);
    2929
    3030#endif // ewk_view_private_h
  • trunk/Source/WebKit2/UIProcess/efl/WebInspectorProxyEfl.cpp

    r140686 r141836  
    9999        return 0;
    100100
    101     m_inspectorView = ewk_view_base_add(ecore_evas_get(m_inspectorWindow), toAPI(page()->process()->context()), toAPI(inspectorPageGroup()), EwkView::LegacyBehavior);
    102     EwkView* inspectorViewImpl = EwkView::fromEvasObject(m_inspectorView);
    103     inspectorViewImpl->setThemePath(TEST_THEME_DIR "/default.edj");
    104 
    105     Ewk_Settings* settings = inspectorViewImpl->settings();
     101    // FIXME: Refactor to use WKViewRef.
     102    EwkView* ewkView = ewk_view_base_add(ecore_evas_get(m_inspectorWindow), toAPI(page()->process()->context()), toAPI(inspectorPageGroup()), EwkView::LegacyBehavior);
     103    if (!ewkView)
     104        return 0;
     105
     106    m_inspectorView = ewkView->view();
     107
     108    ewkView->setThemePath(TEST_THEME_DIR "/default.edj");
     109
     110    Ewk_Settings* settings = ewkView->settings();
    106111    ewk_settings_file_access_from_file_urls_allowed_set(settings, true);
    107112
    108     return inspectorViewImpl->page();
     113    return ewkView->page();
    109114}
    110115
  • trunk/Tools/ChangeLog

    r141829 r141836  
     12013-02-04  Kenneth Rohde Christiansen  <kenneth@webkit.org>
     2
     3        [EFL][WK2] Introduce a WebView class as counterpart for WKViewRef
     4        https://bugs.webkit.org/show_bug.cgi?id=107931
     5
     6        Reviewed by Anders Carlsson.
     7
     8        Change platformView to be a WKView and use WKViewGetEvasObject
     9        for the places where an Evas_Object is needed.
     10
     11        Instead of extracting the Ecore_Evas* from the m_view we use
     12        the m_window instead, which actually holds the it.
     13
     14        * TestWebKitAPI/PlatformWebView.h:
     15        * TestWebKitAPI/efl/PlatformWebView.cpp:
     16        (TestWebKitAPI::PlatformWebView::PlatformWebView):
     17        (TestWebKitAPI::PlatformWebView::~PlatformWebView):
     18        (TestWebKitAPI::PlatformWebView::resizeTo):
     19        (TestWebKitAPI::PlatformWebView::page):
     20        (TestWebKitAPI::PlatformWebView::simulateSpacebarKeyPress):
     21        (TestWebKitAPI::PlatformWebView::simulateMouseMove):
     22        (TestWebKitAPI::PlatformWebView::simulateRightClick):
     23        * WebKitTestRunner/PlatformWebView.h:
     24        * WebKitTestRunner/efl/EventSenderProxyEfl.cpp:
     25        (WTR::EventSenderProxy::sendTouchEvent):
     26        (WTR::EventSenderProxy::setTouchModifier):
     27        * WebKitTestRunner/efl/PlatformWebViewEfl.cpp:
     28        (WTR::PlatformWebView::PlatformWebView):
     29        (WTR::PlatformWebView::~PlatformWebView):
     30        (WTR::PlatformWebView::resizeTo):
     31        (WTR::PlatformWebView::page):
     32        (WTR::PlatformWebView::focus):
     33        (WTR::PlatformWebView::windowFrame):
     34        (WTR::PlatformWebView::setWindowFrame):
     35        (WTR::PlatformWebView::windowSnapshotImage):
     36
    1372013-02-04  Timothy Loh  <timloh@chromium.com>
    238
  • trunk/Tools/TestWebKitAPI/PlatformWebView.h

    r138326 r141836  
    4848typedef GtkWidget *PlatformWindow;
    4949#elif PLATFORM(EFL)
    50 #if USE(EO)
    51 typedef struct _Eo Evas_Object;
    52 #else
    53 typedef struct _Evas_Object Evas_Object;
    54 #endif
    5550typedef struct _Ecore_Evas Ecore_Evas;
    56 typedef Evas_Object* PlatformWKView;
     51typedef WKViewRef PlatformWKView;
    5752typedef Ecore_Evas* PlatformWindow;
    5853#endif
  • trunk/Tools/TestWebKitAPI/efl/PlatformWebView.cpp

    r140004 r141836  
    6666    m_window = initEcoreEvas();
    6767    Evas* evas = ecore_evas_get(m_window);
    68     m_view = toImpl(WKViewCreate(evas, contextRef, pageGroupRef));
    69     ewk_view_theme_set(m_view, THEME_DIR"/default.edj");
    70     evas_object_smart_callback_add(m_view, "webprocess,crashed", onWebProcessCrashed, 0);
     68    m_view = WKViewCreate(evas, contextRef, pageGroupRef);
     69    ewk_view_theme_set(WKViewGetEvasObject(m_view), THEME_DIR"/default.edj");
     70    evas_object_smart_callback_add(WKViewGetEvasObject(m_view), "webprocess,crashed", onWebProcessCrashed, 0);
    7171    resizeTo(600, 800);
    7272}
     
    7474PlatformWebView::~PlatformWebView()
    7575{
    76     evas_object_del(m_view);
     76    Evas_Object* evasObject = WKViewGetEvasObject(m_view);
     77
     78    // Release first. WebView should not live longer than EwkView, as EwkView owns objects that page proxy refers to.
     79    WKRelease(m_view);
     80
     81    // FIXME: The C WKView API currently creates the Evas_Object, so we have to destruct it
     82    // (and its dependencies EwkView and WebKit::WebView) this way, until this get fixed.
     83    evas_object_del(evasObject);
     84
    7785    ecore_evas_free(m_window);
    7886    ecore_evas_shutdown();
     
    8189void PlatformWebView::resizeTo(unsigned width, unsigned height)
    8290{
    83     evas_object_resize(m_view, width, height);
     91    evas_object_resize(WKViewGetEvasObject(m_view), width, height);
    8492}
    8593
    8694WKPageRef PlatformWebView::page() const
    8795{
    88     return WKViewGetPage(toAPI(m_view));
     96    return WKViewGetPage(m_view);
    8997}
    9098
     
    92100{
    93101    Evas* evas = ecore_evas_get(m_window);
    94     evas_object_focus_set(m_view, true);
     102    evas_object_focus_set(WKViewGetEvasObject(m_view), true);
    95103    evas_event_feed_key_down(evas, "space", "space", " ", 0, 0, 0);
    96104    evas_event_feed_key_up(evas, "space", "space", " ", 0, 1, 0);
     
    100108{
    101109    Evas* evas = ecore_evas_get(m_window);
    102     evas_object_show(m_view);
     110    evas_object_show(WKViewGetEvasObject(m_view));
    103111    evas_event_feed_mouse_move(evas, x, y, 0, 0);
    104112}
     
    107115{
    108116    Evas* evas = ecore_evas_get(m_window);
    109     evas_object_show(m_view);
     117    evas_object_show(WKViewGetEvasObject(m_view));
    110118    evas_event_feed_mouse_move(evas, x, y, 0, 0);
    111119    evas_event_feed_mouse_down(evas, 3, EVAS_BUTTON_NONE, 0, 0);
  • trunk/Tools/WebKitTestRunner/PlatformWebView.h

    r138326 r141836  
    5555typedef GtkWidget* PlatformWindow;
    5656#elif PLATFORM(EFL)
    57 #if USE(EO)
    58 typedef struct _Eo Evas_Object;
    59 #else
    60 typedef struct _Evas_Object Evas_Object;
    61 #endif
    6257typedef struct _Ecore_Evas Ecore_Evas;
    63 typedef Evas_Object* PlatformWKView;
     58typedef WKViewRef PlatformWKView;
    6459typedef Ecore_Evas* PlatformWindow;
    6560#endif
  • trunk/Tools/WebKitTestRunner/efl/EventSenderProxyEfl.cpp

    r133597 r141836  
    439439    ASSERT(m_touchPoints);
    440440
    441     Evas_Object* ewkView = m_testController->mainWebView()->platformView();
     441    Evas_Object* ewkView = WKViewGetEvasObject(m_testController->mainWebView()->platformView());
    442442    ewk_view_feed_touch_event(ewkView, eventType, m_touchPoints, evas_key_modifier_get(evas_object_evas_get(ewkView)));
    443443
     
    491491void EventSenderProxy::setTouchModifier(WKEventModifiers modifier, bool enable)
    492492{
     493    Evas_Object* ewkView = WKViewGetEvasObject(m_testController->mainWebView()->platformView());
     494
    493495    for (unsigned index = 0; index < (sizeof(modifierNames) / sizeof(char*)); ++index) {
    494496        if (modifier & (1 << index)) {
    495497            if (enable)
    496                 evas_key_modifier_on(evas_object_evas_get(m_testController->mainWebView()->platformView()), modifierNames[index]);
     498                evas_key_modifier_on(evas_object_evas_get(ewkView), modifierNames[index]);
    497499            else
    498                 evas_key_modifier_off(evas_object_evas_get(m_testController->mainWebView()->platformView()), modifierNames[index]);
     500                evas_key_modifier_off(evas_object_evas_get(ewkView), modifierNames[index]);
    499501        }
    500502    }
  • trunk/Tools/WebKitTestRunner/efl/PlatformWebViewEfl.cpp

    r138462 r141836  
    6262
    6363    if (m_usingFixedLayout) {
    64         m_view = toImpl(WKViewCreateWithFixedLayout(evas, context, pageGroup));
    65         evas_object_resize(m_view, 800, 600);
     64        m_view = WKViewCreateWithFixedLayout(evas, context, pageGroup);
     65        evas_object_resize(WKViewGetEvasObject(m_view), 800, 600);
    6666    } else
    67         m_view = toImpl(WKViewCreate(evas, context, pageGroup));
     67        m_view = WKViewCreate(evas, context, pageGroup);
    6868
    69     ewk_view_theme_set(m_view, THEME_DIR"/default.edj");
     69    ewk_view_theme_set(WKViewGetEvasObject(m_view), THEME_DIR"/default.edj");
    7070    m_windowIsKey = false;
    71     evas_object_show(m_view);
     71    evas_object_show(WKViewGetEvasObject(m_view));
    7272}
    7373
    7474PlatformWebView::~PlatformWebView()
    7575{
    76     evas_object_del(m_view);
     76    Evas_Object* evasObject = WKViewGetEvasObject(m_view);
     77
     78    // Release first. WebView should not live longer than EwkView, as EwkView owns objects that page proxy refers to.
     79    WKRelease(m_view);
     80
     81    // FIXME: The C WKView API currently creates the Evas_Object, so we have to destruct it
     82    // (and its dependencies EwkView and WebKit::WebView) this way, until this get fixed.
     83    evas_object_del(evasObject);
     84
    7785    ecore_evas_free(m_window);
    7886}
     
    8088void PlatformWebView::resizeTo(unsigned width, unsigned height)
    8189{
    82     evas_object_resize(m_view, width, height);
     90    evas_object_resize(WKViewGetEvasObject(m_view), width, height);
    8391}
    8492
    8593WKPageRef PlatformWebView::page()
    8694{
    87     return WKViewGetPage(toAPI(m_view));
     95    return WKViewGetPage(m_view);
    8896}
    8997
    9098void PlatformWebView::focus()
    9199{
     100    Evas_Object* evasObject = WKViewGetEvasObject(m_view);
    92101    // In a few cases, an iframe might receive focus from JavaScript and Evas is not aware of it at all
    93102    // (WebCoreSupport::focusedFrameChanged() does not emit any notification). We then manually remove the
    94103    // focus from the view to make the call give focus to evas_object_focus_set(..., true) to be effectful.
    95     if (WKPageGetFocusedFrame(page()) != WKPageGetMainFrame(page()))
    96         evas_object_focus_set(m_view, false);
    97     evas_object_focus_set(m_view, true);
     104    evas_object_focus_set(WKViewGetEvasObject(m_view), WKPageGetFocusedFrame(page()) == WKPageGetMainFrame(page()));
    98105}
    99106
     
    102109    int x, y, width, height;
    103110
    104     Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_view));
    105     ecore_evas_request_geometry_get(ee, &x, &y, &width, &height);
     111    ecore_evas_request_geometry_get(m_window, &x, &y, &width, &height);
    106112
    107113    return WKRectMake(x, y, width, height);
     
    110116void PlatformWebView::setWindowFrame(WKRect frame)
    111117{
    112     Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_view));
    113     ecore_evas_move_resize(ee, frame.origin.x, frame.origin.y, frame.size.width, frame.size.height);
     118    ecore_evas_move_resize(m_window, frame.origin.x, frame.origin.y, frame.size.width, frame.size.height);
    114119}
    115120
     
    128133WKRetainPtr<WKImageRef> PlatformWebView::windowSnapshotImage()
    129134{
    130     Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_view));
    131     ASSERT(ee);
    132 
    133135    int width;
    134136    int height;
    135     ecore_evas_geometry_get(ee, 0, 0, &width, &height);
     137    ecore_evas_geometry_get(m_window, 0, 0, &width, &height);
    136138    ASSERT(width > 0 && height > 0);
    137139
    138     return adoptWK(WKViewCreateSnapshot(toAPI(m_view)));
     140    return adoptWK(WKViewCreateSnapshot(m_view));
    139141}
    140142
Note: See TracChangeset for help on using the changeset viewer.