Changeset 132647 in webkit


Ignore:
Timestamp:
Oct 26, 2012, 6:43:35 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[EFL][WK2] Clean up construction/destruction code in Ewk_view
https://bugs.webkit.org/show_bug.cgi?id=100232

Patch by Mikhail Pozdnyakov <mikhail.pozdnyakov@intel.com> on 2012-10-26
Reviewed by Kenneth Rohde Christiansen.

Simplified a lot of initialization and destruction code of Ewk_view and EwkViewImpl
put all the impl stuff to its constructor and destructor, also made EwkViewImpl member
variables private.

  • UIProcess/API/efl/EwkViewImpl.cpp:

(pageViewMap):
(EwkViewImpl::addToPageViewMap):
(EwkViewImpl::removeFromPageViewMap):
(EwkViewImpl::viewFromPageViewMap):
(EwkViewImpl::EwkViewImpl):
(EwkViewImpl::~EwkViewImpl):
(EwkViewImpl::wkPage):
(EwkViewImpl::title):
(EwkViewImpl::setThemePath):
(EwkViewImpl::customTextEncodingName):
(EwkViewImpl::setCustomTextEncodingName):
(EwkViewImpl::informIconChange):
(EwkViewImpl::informWebProcessCrashed):
(EwkViewImpl::updateTextInputState):
(EwkViewImpl::informURLChange):
(EwkViewImpl::onFaviconChanged):

  • UIProcess/API/efl/EwkViewImpl.h:

(WebKit):
(EwkViewImpl):
(EwkViewImpl::view):
(EwkViewImpl::page):
(EwkViewImpl::ewkContext):
(EwkViewImpl::backForwardList):

  • UIProcess/API/efl/ewk_settings.cpp:

(Ewk_Settings::preferences):

  • UIProcess/API/efl/ewk_view.cpp:

(_ewk_view_smart_focus_in):
(_ewk_view_smart_focus_out):
(_ewk_view_smart_mouse_wheel):
(_ewk_view_smart_mouse_down):
(_ewk_view_smart_mouse_up):
(_ewk_view_smart_mouse_move):
(_ewk_view_smart_key_down):
(_ewk_view_smart_key_up):
(_ewk_view_on_show):
(_ewk_view_on_hide):
(_ewk_view_smart_add):
(_ewk_view_smart_del):
(_ewk_view_smart_calculate):
(_ewk_view_smart_color_set):
(createEwkViewSmartClass):
(createEwkView):
(ewk_view_base_add):
(ewk_view_smart_add):
(ewk_view_add_with_context):
(ewk_view_url_set):
(ewk_view_reload):
(ewk_view_reload_bypass_cache):
(ewk_view_stop):
(ewk_view_load_progress_get):
(ewk_view_scale_set):
(ewk_view_scale_get):
(ewk_view_device_pixel_ratio_set):
(ewk_view_device_pixel_ratio_get):
(ewk_view_back):
(ewk_view_forward):
(ewk_view_intent_deliver):
(ewk_view_back_possible):
(ewk_view_forward_possible):
(ewk_view_back_forward_list_get):
(ewk_view_html_string_load):
(ewk_view_text_find):
(ewk_view_text_find_highlight_clear):
(ewk_view_text_matches_count):
(ewk_view_feed_touch_event):
(ewk_view_inspector_show):
(ewk_view_inspector_close):
(ewk_view_pagination_mode_set):
(ewk_view_pagination_mode_get):

Location:
trunk/Source/WebKit2
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r132643 r132647  
     12012-10-26  Mikhail Pozdnyakov  <mikhail.pozdnyakov@intel.com>
     2
     3        [EFL][WK2] Clean up construction/destruction code in Ewk_view
     4        https://bugs.webkit.org/show_bug.cgi?id=100232
     5
     6        Reviewed by Kenneth Rohde Christiansen.
     7
     8        Simplified a lot of initialization and destruction code of Ewk_view and EwkViewImpl
     9        put all the impl stuff to its constructor and destructor, also made EwkViewImpl member
     10        variables private.
     11
     12        * UIProcess/API/efl/EwkViewImpl.cpp:
     13        (pageViewMap):
     14        (EwkViewImpl::addToPageViewMap):
     15        (EwkViewImpl::removeFromPageViewMap):
     16        (EwkViewImpl::viewFromPageViewMap):
     17        (EwkViewImpl::EwkViewImpl):
     18        (EwkViewImpl::~EwkViewImpl):
     19        (EwkViewImpl::wkPage):
     20        (EwkViewImpl::title):
     21        (EwkViewImpl::setThemePath):
     22        (EwkViewImpl::customTextEncodingName):
     23        (EwkViewImpl::setCustomTextEncodingName):
     24        (EwkViewImpl::informIconChange):
     25        (EwkViewImpl::informWebProcessCrashed):
     26        (EwkViewImpl::updateTextInputState):
     27        (EwkViewImpl::informURLChange):
     28        (EwkViewImpl::onFaviconChanged):
     29        * UIProcess/API/efl/EwkViewImpl.h:
     30        (WebKit):
     31        (EwkViewImpl):
     32        (EwkViewImpl::view):
     33        (EwkViewImpl::page):
     34        (EwkViewImpl::ewkContext):
     35        (EwkViewImpl::backForwardList):
     36        * UIProcess/API/efl/ewk_settings.cpp:
     37        (Ewk_Settings::preferences):
     38        * UIProcess/API/efl/ewk_view.cpp:
     39        (_ewk_view_smart_focus_in):
     40        (_ewk_view_smart_focus_out):
     41        (_ewk_view_smart_mouse_wheel):
     42        (_ewk_view_smart_mouse_down):
     43        (_ewk_view_smart_mouse_up):
     44        (_ewk_view_smart_mouse_move):
     45        (_ewk_view_smart_key_down):
     46        (_ewk_view_smart_key_up):
     47        (_ewk_view_on_show):
     48        (_ewk_view_on_hide):
     49        (_ewk_view_smart_add):
     50        (_ewk_view_smart_del):
     51        (_ewk_view_smart_calculate):
     52        (_ewk_view_smart_color_set):
     53        (createEwkViewSmartClass):
     54        (createEwkView):
     55        (ewk_view_base_add):
     56        (ewk_view_smart_add):
     57        (ewk_view_add_with_context):
     58        (ewk_view_url_set):
     59        (ewk_view_reload):
     60        (ewk_view_reload_bypass_cache):
     61        (ewk_view_stop):
     62        (ewk_view_load_progress_get):
     63        (ewk_view_scale_set):
     64        (ewk_view_scale_get):
     65        (ewk_view_device_pixel_ratio_set):
     66        (ewk_view_device_pixel_ratio_get):
     67        (ewk_view_back):
     68        (ewk_view_forward):
     69        (ewk_view_intent_deliver):
     70        (ewk_view_back_possible):
     71        (ewk_view_forward_possible):
     72        (ewk_view_back_forward_list_get):
     73        (ewk_view_html_string_load):
     74        (ewk_view_text_find):
     75        (ewk_view_text_find_highlight_clear):
     76        (ewk_view_text_matches_count):
     77        (ewk_view_feed_touch_event):
     78        (ewk_view_inspector_show):
     79        (ewk_view_inspector_close):
     80        (ewk_view_pagination_mode_set):
     81        (ewk_view_pagination_mode_get):
     82
    1832012-10-26  Christophe Dumez  <christophe.dumez@intel.com>
    284
  • trunk/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.cpp

    r132617 r132647  
    3434#include "ResourceLoadClientEfl.h"
    3535#include "WKString.h"
     36#include "WebContext.h"
     37#include "WebPageGroup.h"
    3638#include "WebPageProxy.h"
    3739#include "WebPopupMenuProxyEfl.h"
     40#include "WebPreferences.h"
    3841#include "ewk_back_forward_list_private.h"
    3942#include "ewk_color_picker_private.h"
     
    5053#include <WebCore/Cursor.h>
    5154
     55
     56#if ENABLE(FULLSCREEN_API)
     57#include "WebFullScreenManagerProxy.h"
     58#endif
     59
    5260using namespace WebCore;
    5361using namespace WebKit;
     
    5563static const int defaultCursorSize = 16;
    5664
    57 EwkViewImpl::PageViewMap EwkViewImpl::pageViewMap;
    58 
    59 void EwkViewImpl::addToPageViewMap(const Evas_Object* ewkView)
    60 {
    61     EwkViewImpl* viewImpl = EwkViewImpl::fromEvasObject(ewkView);
    62 
    63     PageViewMap::AddResult result = pageViewMap.add(viewImpl->wkPage(), ewkView);
     65typedef HashMap<WKPageRef, Evas_Object*> PageViewMap;
     66
     67static inline PageViewMap& pageViewMap()
     68{
     69    DEFINE_STATIC_LOCAL(PageViewMap, map, ());
     70    return map;
     71}
     72
     73void EwkViewImpl::addToPageViewMap(EwkViewImpl* viewImpl)
     74{
     75    PageViewMap::AddResult result = pageViewMap().add(viewImpl->wkPage(), viewImpl->view());
    6476    ASSERT_UNUSED(result, result.isNewEntry);
    6577}
    6678
    67 void EwkViewImpl::removeFromPageViewMap(const Evas_Object* ewkView)
    68 {
    69     EwkViewImpl* viewImpl = EwkViewImpl::fromEvasObject(ewkView);
    70 
    71     ASSERT(pageViewMap.contains(viewImpl->wkPage()));
    72     pageViewMap.remove(viewImpl->wkPage());
     79void EwkViewImpl::removeFromPageViewMap(EwkViewImpl* viewImpl)
     80{
     81    ASSERT(pageViewMap().contains(viewImpl->wkPage()));
     82    pageViewMap().remove(viewImpl->wkPage());
    7383}
    7484
     
    7787    ASSERT(page);
    7888
    79     return pageViewMap.get(page);
    80 }
    81 
    82 EwkViewImpl::EwkViewImpl(Evas_Object* view)
     89    return pageViewMap().get(page);
     90}
     91
     92EwkViewImpl::EwkViewImpl(Evas_Object* view, PassRefPtr<Ewk_Context> context, PassRefPtr<WebPageGroup> pageGroup)
     93    : m_view(view)
     94    , m_context(context)
     95    , m_pageClient(PageClientImpl::create(this))
     96    , m_pageProxy(toImpl(m_context->wkContext())->createWebPage(m_pageClient.get(), pageGroup.get()))
     97    , m_pageLoadClient(PageLoadClientEfl::create(this))
     98    , m_pagePolicyClient(PagePolicyClientEfl::create(this))
     99    , m_pageUIClient(PageUIClientEfl::create(this))
     100    , m_resourceLoadClient(ResourceLoadClientEfl::create(this))
     101    , m_findClient(FindClientEfl::create(this))
     102    , m_formClient(FormClientEfl::create(this))
     103    , m_backForwardList(Ewk_Back_Forward_List::create(toAPI(m_pageProxy->backForwardList())))
     104#if USE(TILED_BACKING_STORE)
     105    , m_pageViewportControllerClient(PageViewportControllerClientEfl::create(this))
     106    , m_pageViewportController(adoptPtr(new PageViewportController(m_pageProxy.get(), m_pageViewportControllerClient.get())))
     107#endif
    83108#if USE(ACCELERATED_COMPOSITING)
    84     : evasGl(0)
    85     , evasGlContext(0)
    86     , evasGlSurface(0)
    87     , m_view(view)
    88 #else
    89     : m_view(view)
     109    , m_evasGl(0)
     110    , m_evasGlContext(0)
     111    , m_evasGlSurface(0)
    90112#endif
    91113    , m_settings(Ewk_Settings::create(this))
     
    97119    , m_inputMethodContext(InputMethodContextEfl::create(this, smartData()->base.evas))
    98120{
    99     ASSERT(view);
     121    ASSERT(m_view);
     122    ASSERT(m_context);
     123    ASSERT(m_pageProxy);
     124
     125#if USE(COORDINATED_GRAPHICS)
     126    m_pageProxy->pageGroup()->preferences()->setAcceleratedCompositingEnabled(true);
     127    m_pageProxy->pageGroup()->preferences()->setForceCompositingMode(true);
     128    m_pageProxy->setUseFixedLayout(true);
     129#endif
     130
     131    m_pageProxy->initializeWebPage();
     132
     133#if USE(TILED_BACKING_STORE)
     134    pageClient->setPageViewportController(pageViewportController.get());
     135#endif
     136
     137#if ENABLE(FULLSCREEN_API)
     138    m_pageProxy->fullScreenManager()->setWebView(m_view);
     139    m_pageProxy->pageGroup()->preferences()->setFullScreenEnabled(true);
     140#endif
    100141
    101142    // Enable mouse events by default
    102143    setMouseEventsEnabled(true);
     144
     145    // Listen for favicon changes.
     146    Ewk_Favicon_Database* iconDatabase = m_context->faviconDatabase();
     147    ASSERT(iconDatabase);
     148
     149    iconDatabase->watchChanges(IconChangeCallbackData(EwkViewImpl::onFaviconChanged, this));
     150
     151    EwkViewImpl::addToPageViewMap(this);
    103152}
    104153
    105154EwkViewImpl::~EwkViewImpl()
    106155{
     156    // Unregister icon change callback.
     157    Ewk_Favicon_Database* iconDatabase = m_context->faviconDatabase();
     158    ASSERT(iconDatabase);
     159
     160    iconDatabase->unwatchChanges(EwkViewImpl::onFaviconChanged);
     161
     162    EwkViewImpl::removeFromPageViewMap(this);
    107163}
    108164
     
    127183WKPageRef EwkViewImpl::wkPage()
    128184{
    129     return toAPI(pageProxy.get());
     185    return toAPI(m_pageProxy.get());
    130186}
    131187
     
    523579const char* EwkViewImpl::title() const
    524580{
    525     m_title = pageProxy->pageTitle().utf8().data();
     581    m_title = m_pageProxy->pageTitle().utf8().data();
    526582
    527583    return m_title;
     
    546602    if (m_theme != theme) {
    547603        m_theme = theme;
    548         pageProxy->setThemePath(theme);
     604        m_pageProxy->setThemePath(theme);
    549605    }
    550606}
     
    552608const char* EwkViewImpl::customTextEncodingName() const
    553609{
    554     String customEncoding = pageProxy->customTextEncodingName();
     610    String customEncoding = m_pageProxy->customTextEncodingName();
    555611    if (customEncoding.isEmpty())
    556612        return 0;
     
    564620{
    565621    m_customEncoding = encoding;
    566     pageProxy->setCustomTextEncodingName(encoding ? encoding : String());
     622    m_pageProxy->setCustomTextEncodingName(encoding ? encoding : String());
    567623}
    568624
     
    627683void EwkViewImpl::informIconChange()
    628684{
    629     Ewk_Favicon_Database* iconDatabase = context->faviconDatabase();
     685    Ewk_Favicon_Database* iconDatabase = m_context->faviconDatabase();
    630686    ASSERT(iconDatabase);
    631687
     
    801857
    802858    if (!handled) {
    803         CString url = pageProxy->urlAtProcessExit().utf8();
     859        CString url = m_pageProxy->urlAtProcessExit().utf8();
    804860        WARN("WARNING: The web process experienced a crash on '%s'.\n", url.data());
    805861
     
    924980void EwkViewImpl::informURLChange()
    925981{
    926     String activeURL = pageProxy->activeURL();
     982    String activeURL = m_pageProxy->activeURL();
    927983    if (activeURL.isEmpty())
    928984        return;
     
    10291085}
    10301086#endif
     1087
     1088void EwkViewImpl::onFaviconChanged(const char* pageURL, void* eventInfo)
     1089{
     1090    EwkViewImpl* viewImpl = static_cast<EwkViewImpl*>(eventInfo);
     1091
     1092    if (!viewImpl->url() || strcasecmp(viewImpl->url(), pageURL))
     1093        return;
     1094
     1095    viewImpl->informIconChange();
     1096}
  • trunk/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.h

    r132617 r132647  
    7070class PageViewportController;
    7171class ResourceLoadClientEfl;
     72class WebPageGroup;
    7273class WebPageProxy;
    7374class WebPopupItem;
     
    101102class EwkViewImpl {
    102103public:
    103     explicit EwkViewImpl(Evas_Object* view);
     104    EwkViewImpl(Evas_Object* view, PassRefPtr<Ewk_Context> context, PassRefPtr<WebKit::WebPageGroup> pageGroup);
    104105    ~EwkViewImpl();
    105106
    106107    static EwkViewImpl* fromEvasObject(const Evas_Object* view);
    107108
    108     inline Evas_Object* view() { return m_view; }
     109    Evas_Object* view() { return m_view; }
    109110    WKPageRef wkPage();
    110     inline WebKit::WebPageProxy* page() { return pageProxy.get(); }
    111     Ewk_Context* ewkContext() { return context.get(); }
     111    WebKit::WebPageProxy* page() { return m_pageProxy.get(); }
     112    Ewk_Context* ewkContext() { return m_context.get(); }
    112113    Ewk_Settings* settings() { return m_settings.get(); }
     114    Ewk_Back_Forward_List* backForwardList() { return m_backForwardList.get(); }
    113115
    114116    WebCore::IntSize size() const;
     
    137139    void setImageData(void* imageData, const WebCore::IntSize& size);
    138140
    139     static void addToPageViewMap(const Evas_Object* ewkView);
    140     static void removeFromPageViewMap(const Evas_Object* ewkView);
     141    static void addToPageViewMap(EwkViewImpl* viewImpl);
     142    static void removeFromPageViewMap(EwkViewImpl* viewImpl);
    141143    static const Evas_Object* viewFromPageViewMap(const WKPageRef);
    142144
     
    211213#endif
    212214
    213     // FIXME: Make members private for encapsulation.
    214     OwnPtr<WebKit::PageClientImpl> pageClient;
    215 #if USE(TILED_BACKING_STORE)
    216     OwnPtr<WebKit::PageViewportControllerClientEfl> pageViewportControllerClient;
    217     OwnPtr<WebKit::PageViewportController> pageViewportController;
    218 #endif
    219     RefPtr<WebKit::WebPageProxy> pageProxy;
    220     OwnPtr<WebKit::PageLoadClientEfl> pageLoadClient;
    221     OwnPtr<WebKit::PagePolicyClientEfl> pagePolicyClient;
    222     OwnPtr<WebKit::PageUIClientEfl> pageUIClient;
    223     OwnPtr<WebKit::ResourceLoadClientEfl> resourceLoadClient;
    224     OwnPtr<WebKit::FindClientEfl> findClient;
    225     OwnPtr<WebKit::FormClientEfl> formClient;
    226 
    227     OwnPtr<Ewk_Back_Forward_List> backForwardList;
    228     RefPtr<Ewk_Context> context;
    229 
    230 #if USE(ACCELERATED_COMPOSITING)
    231     Evas_GL* evasGl;
    232     Evas_GL_Context* evasGlContext;
    233     Evas_GL_Surface* evasGlSurface;
    234 #endif
    235 
    236215private:
    237216    inline Ewk_View_Smart_Data* smartData();
     
    247226    static void onTouchMove(void* /* data */, Evas* /* canvas */, Evas_Object* ewkView, void* /* eventInfo */);
    248227#endif
    249 
     228    static void onFaviconChanged(const char* pageURL, void* eventInfo);
     229
     230    // Note, initialization matters.
    250231    Evas_Object* m_view;
     232    RefPtr<Ewk_Context> m_context;
     233    OwnPtr<WebKit::PageClientImpl> m_pageClient;
     234    RefPtr<WebKit::WebPageProxy> m_pageProxy;
     235    OwnPtr<WebKit::PageLoadClientEfl> m_pageLoadClient;
     236    OwnPtr<WebKit::PagePolicyClientEfl> m_pagePolicyClient;
     237    OwnPtr<WebKit::PageUIClientEfl> m_pageUIClient;
     238    OwnPtr<WebKit::ResourceLoadClientEfl> m_resourceLoadClient;
     239    OwnPtr<WebKit::FindClientEfl> m_findClient;
     240    OwnPtr<WebKit::FormClientEfl> m_formClient;
     241    OwnPtr<Ewk_Back_Forward_List> m_backForwardList;
     242#if USE(TILED_BACKING_STORE)
     243    OwnPtr<WebKit::PageViewportControllerClientEfl> m_pageViewportControllerClient;
     244    OwnPtr<WebKit::PageViewportController> m_pageViewportController;
     245#endif
     246#if USE(ACCELERATED_COMPOSITING)
     247    Evas_GL* m_evasGl;
     248    Evas_GL_Context* m_evasGlContext;
     249    Evas_GL_Surface* m_evasGlSurface;
     250#endif
    251251    OwnPtr<Ewk_Settings> m_settings;
    252252    RefPtr<Evas_Object> m_cursorObject;
     
    266266    OwnPtr<WebKit::InputMethodContextEfl> m_inputMethodContext;
    267267    OwnPtr<Ewk_Color_Picker> m_colorPicker;
    268 
    269     typedef HashMap<WKPageRef, const Evas_Object*> PageViewMap;
    270     static PageViewMap pageViewMap;
    271268};
    272269
  • trunk/Source/WebKit2/UIProcess/API/efl/ewk_settings.cpp

    r132354 r132647  
    4646const WebKit::WebPreferences* Ewk_Settings::preferences() const
    4747{
    48     return m_viewImpl->pageProxy->pageGroup()->preferences();
     48    return m_viewImpl->page()->pageGroup()->preferences();
    4949}
    5050
    5151WebKit::WebPreferences* Ewk_Settings::preferences()
    5252{
    53     return m_viewImpl->pageProxy->pageGroup()->preferences();
     53    return m_viewImpl->page()->pageGroup()->preferences();
    5454}
    5555
  • trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp

    r132627 r132647  
    5353#include <WebKit2/WKPageGroup.h>
    5454#include <wtf/text/CString.h>
    55 
    56 #if ENABLE(FULLSCREEN_API)
    57 #include "WebFullScreenManagerProxy.h"
    58 #endif
    5955
    6056#if ENABLE(INSPECTOR)
     
    130126}
    131127
    132 static void _ewk_view_on_favicon_changed(const char* pageURL, void* eventInfo)
    133 {
    134     Evas_Object* ewkView = static_cast<Evas_Object*>(eventInfo);
    135     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
    136     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
    137 
    138     const char* viewURL = ewk_view_url_get(ewkView);
    139     if (!viewURL || strcasecmp(viewURL, pageURL))
    140         return;
    141 
    142     impl->informIconChange();
    143 }
    144 
    145128// Default Event Handling.
    146129static Eina_Bool _ewk_view_smart_focus_in(Ewk_View_Smart_Data* smartData)
     
    148131    EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
    149132
    150     impl->pageProxy->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive);
     133    impl->page()->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive);
    151134    return true;
    152135}
     
    156139    EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
    157140
    158     impl->pageProxy->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive);
     141    impl->page()->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive);
    159142    return true;
    160143}
     
    180163    Evas_Event_Mouse_Wheel event(*wheelEvent);
    181164    event.canvas = mapToWebContent(smartData, event.canvas);
    182     impl->pageProxy->handleWheelEvent(NativeWebWheelEvent(&event, &position));
     165    impl->page()->handleWheelEvent(NativeWebWheelEvent(&event, &position));
    183166#else
    184     impl->pageProxy->handleWheelEvent(NativeWebWheelEvent(wheelEvent, &position));
     167    impl->page()->handleWheelEvent(NativeWebWheelEvent(wheelEvent, &position));
    185168#endif
    186169    return true;
     
    195178    Evas_Event_Mouse_Down event(*downEvent);
    196179    event.canvas = mapToWebContent(smartData, event.canvas);
    197     impl->pageProxy->handleMouseEvent(NativeWebMouseEvent(&event, &position));
     180    impl->page()->handleMouseEvent(NativeWebMouseEvent(&event, &position));
    198181#else
    199     impl->pageProxy->handleMouseEvent(NativeWebMouseEvent(downEvent, &position));
     182    impl->page()->handleMouseEvent(NativeWebMouseEvent(downEvent, &position));
    200183#endif
    201184    return true;
     
    210193    Evas_Event_Mouse_Up event(*upEvent);
    211194    event.canvas = mapToWebContent(smartData, event.canvas);
    212     impl->pageProxy->handleMouseEvent(NativeWebMouseEvent(&event, &position));
     195    impl->page()->handleMouseEvent(NativeWebMouseEvent(&event, &position));
    213196#else
    214     impl->pageProxy->handleMouseEvent(NativeWebMouseEvent(upEvent, &position));
     197    impl->page()->handleMouseEvent(NativeWebMouseEvent(upEvent, &position));
    215198#endif
    216199
     
    230213    Evas_Event_Mouse_Move event(*moveEvent);
    231214    event.cur.canvas = mapToWebContent(smartData, event.cur.canvas);
    232     impl->pageProxy->handleMouseEvent(NativeWebMouseEvent(&event, &position));
     215    impl->page()->handleMouseEvent(NativeWebMouseEvent(&event, &position));
    233216#else
    234     impl->pageProxy->handleMouseEvent(NativeWebMouseEvent(moveEvent, &position));
     217    impl->page()->handleMouseEvent(NativeWebMouseEvent(moveEvent, &position));
    235218#endif
    236219    return true;
     
    246229        inputMethodContext->handleKeyDownEvent(downEvent, &isFiltered);
    247230
    248     impl->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(downEvent, isFiltered));
     231    impl->page()->handleKeyboardEvent(NativeWebKeyboardEvent(downEvent, isFiltered));
    249232    return true;
    250233}
     
    254237    EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
    255238
    256     impl->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(upEvent));
     239    impl->page()->handleKeyboardEvent(NativeWebKeyboardEvent(upEvent));
    257240    return true;
    258241}
     
    306289    Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
    307290    EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
    308     impl->pageProxy->viewStateDidChange(WebPageProxy::ViewIsVisible);
     291    impl->page()->viewStateDidChange(WebPageProxy::ViewIsVisible);
    309292}
    310293
     
    317300    // viewStateDidChange() itself is responsible for actually setting the visibility to Visible or Hidden
    318301    // depending on what WebPageProxy::isViewVisible() returns, this simply triggers the process.
    319     impl->pageProxy->viewStateDidChange(WebPageProxy::ViewIsVisible);
     302    impl->page()->viewStateDidChange(WebPageProxy::ViewIsVisible);
    320303}
    321304
    322305static Evas_Smart_Class g_parentSmartClass = EVAS_SMART_CLASS_INIT_NULL;
    323 
    324 static void _ewk_view_impl_del(EwkViewImpl* impl)
    325 {
    326     /* Unregister icon change callback */
    327     Ewk_Favicon_Database* iconDatabase = impl->context->faviconDatabase();
    328     iconDatabase->unwatchChanges(_ewk_view_on_favicon_changed);
    329 
    330     delete impl;
    331 }
    332306
    333307static void _ewk_view_smart_add(Evas_Object* ewkView)
     
    352326    g_parentSmartClass.add(ewkView);
    353327
    354     smartData->priv = new EwkViewImpl(ewkView);
    355     if (!smartData->priv) {
    356         EINA_LOG_CRIT("could not allocate EwkViewImpl");
    357         evas_object_smart_data_set(ewkView, 0);
    358         free(smartData);
    359         return;
    360     }
     328    smartData->priv = 0;
    361329
    362330    // Create evas_object_image to draw web contents.
     
    380348static void _ewk_view_smart_del(Evas_Object* ewkView)
    381349{
    382     EwkViewImpl::removeFromPageViewMap(ewkView);
    383350    EWK_VIEW_SD_GET(ewkView, smartData);
    384     if (smartData && smartData->priv)
    385         _ewk_view_impl_del(smartData->priv);
     351    if (smartData)
     352        delete smartData->priv;
    386353
    387354    g_parentSmartClass.del(ewkView);
     
    430397#endif
    431398
    432         if (impl->pageProxy->drawingArea())
    433             impl->pageProxy->drawingArea()->setSize(IntSize(width, height), IntSize());
     399        if (impl->page()->drawingArea())
     400            impl->page()->drawingArea()->setSize(IntSize(width, height), IntSize());
    434401
    435402        smartData->view.w = width;
     
    493460
    494461    evas_object_image_alpha_set(smartData->image, alpha < 255);
    495     impl->pageProxy->setDrawsBackground(red || green || blue);
    496     impl->pageProxy->setDrawsTransparentBackground(alpha < 255);
     462    impl->page()->setDrawsBackground(red || green || blue);
     463    impl->page()->setDrawsTransparentBackground(alpha < 255);
    497464
    498465    g_parentSmartClass.color_set(ewkView, red, green, blue, alpha);
     
    538505}
    539506
    540 static inline Evas_Smart* _ewk_view_smart_class_new(void)
     507static inline Evas_Smart* createEwkViewSmartClass(void)
    541508{
    542509    static Ewk_View_Smart_Class api = EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION("Ewk_View");
     
    551518}
    552519
    553 static void _ewk_view_initialize(Evas_Object* ewkView, PassRefPtr<Ewk_Context> context, WKPageGroupRef pageGroupRef)
    554 {
    555     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
    556     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
    557     EINA_SAFETY_ON_NULL_RETURN(context);
    558 
    559     if (impl->pageClient)
    560         return;
    561 
    562     impl->pageClient = PageClientImpl::create(impl);
    563 
    564     if (pageGroupRef)
    565         impl->pageProxy = toImpl(context->wkContext())->createWebPage(impl->pageClient.get(), toImpl(pageGroupRef));
    566     else
    567         impl->pageProxy = toImpl(context->wkContext())->createWebPage(impl->pageClient.get(), WebPageGroup::create().get());
    568 
    569     EwkViewImpl::addToPageViewMap(ewkView);
    570 
    571 #if USE(COORDINATED_GRAPHICS)
    572     impl->pageProxy->pageGroup()->preferences()->setAcceleratedCompositingEnabled(true);
    573     impl->pageProxy->pageGroup()->preferences()->setForceCompositingMode(true);
    574     impl->pageProxy->setUseFixedLayout(true);
    575 #if ENABLE(WEBGL)
    576     impl->pageProxy->pageGroup()->preferences()->setWebGLEnabled(true);
    577 #endif
    578 #endif
    579     impl->pageProxy->initializeWebPage();
    580 
    581     impl->backForwardList = Ewk_Back_Forward_List::create(toAPI(impl->pageProxy->backForwardList()));
    582 
    583     impl->context = context;
    584 
    585 #if USE(TILED_BACKING_STORE)
    586     impl->pageViewportControllerClient = PageViewportControllerClientEfl::create(impl);
    587     impl->pageViewportController = adoptPtr(new PageViewportController(impl->pageProxy.get(), impl->pageViewportControllerClient.get()));
    588     impl->pageClient->setPageViewportController(impl->pageViewportController.get());
    589 #endif
    590 
    591 #if ENABLE(FULLSCREEN_API)
    592     impl->pageProxy->fullScreenManager()->setWebView(ewkView);
    593     impl->pageProxy->pageGroup()->preferences()->setFullScreenEnabled(true);
    594 #endif
    595 
    596     // Initialize page clients.
    597     impl->pageLoadClient = PageLoadClientEfl::create(impl);
    598     impl->pagePolicyClient = PagePolicyClientEfl::create(impl);
    599     impl->pageUIClient = PageUIClientEfl::create(impl);
    600     impl->resourceLoadClient = ResourceLoadClientEfl::create(impl);
    601     impl->findClient = FindClientEfl::create(impl);
    602     impl->formClient = FormClientEfl::create(impl);
    603 
    604     /* Listen for favicon changes */
    605     Ewk_Favicon_Database* iconDatabase = impl->context->faviconDatabase();
    606     iconDatabase->watchChanges(IconChangeCallbackData(_ewk_view_on_favicon_changed, ewkView));
    607 }
    608 
    609 static Evas_Object* _ewk_view_add_with_smart(Evas* canvas, Evas_Smart* smart)
     520static inline Evas_Object* createEwkView(Evas* canvas, Evas_Smart* smart, PassRefPtr<Ewk_Context> context, WKPageGroupRef pageGroupRef = 0)
    610521{
    611522    EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
    612523    EINA_SAFETY_ON_NULL_RETURN_VAL(smart, 0);
     524    EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
    613525
    614526    Evas_Object* ewkView = evas_object_smart_add(canvas, smart);
    615     if (!ewkView)
    616         return 0;
     527    EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, 0);
    617528
    618529    EWK_VIEW_SD_GET(ewkView, smartData);
     
    622533    }
    623534
    624     EWK_VIEW_IMPL_GET(smartData, impl);
    625     if (!impl) {
    626         evas_object_del(ewkView);
    627         return 0;
    628     }
     535    ASSERT(!smartData->priv);
     536    RefPtr<WebPageGroup> pageGroup = pageGroupRef ? toImpl(pageGroupRef) : WebPageGroup::create();
     537    smartData->priv = new EwkViewImpl(ewkView, context, pageGroup);
    629538
    630539    return ewkView;
     
    637546Evas_Object* ewk_view_base_add(Evas* canvas, WKContextRef contextRef, WKPageGroupRef pageGroupRef)
    638547{
    639     EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
    640     EINA_SAFETY_ON_NULL_RETURN_VAL(contextRef, 0);
    641     Evas_Object* ewkView = _ewk_view_add_with_smart(canvas, _ewk_view_smart_class_new());
    642     if (!ewkView)
    643         return 0;
    644 
    645     _ewk_view_initialize(ewkView, Ewk_Context::create(contextRef), pageGroupRef);
    646 
    647     return ewkView;
     548    return createEwkView(canvas, createEwkViewSmartClass(), Ewk_Context::create(contextRef), pageGroupRef);
    648549}
    649550
    650551Evas_Object* ewk_view_smart_add(Evas* canvas, Evas_Smart* smart, Ewk_Context* context)
    651552{
    652     EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
    653     EINA_SAFETY_ON_NULL_RETURN_VAL(smart, 0);
    654     EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
    655 
    656     Evas_Object* ewkView = _ewk_view_add_with_smart(canvas, smart);
    657     if (!ewkView)
    658         return 0;
    659 
    660     _ewk_view_initialize(ewkView, context, 0);
    661 
    662     return ewkView;
     553    return createEwkView(canvas, smart, context);
    663554}
    664555
    665556Evas_Object* ewk_view_add_with_context(Evas* canvas, Ewk_Context* context)
    666557{
    667     EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
    668     return ewk_view_smart_add(canvas, _ewk_view_smart_class_new(), context);
     558    return ewk_view_smart_add(canvas, createEwkViewSmartClass(), context);
    669559}
    670560
     
    688578    EINA_SAFETY_ON_NULL_RETURN_VAL(url, false);
    689579
    690     impl->pageProxy->loadURL(url);
     580    impl->page()->loadURL(url);
    691581    impl->informURLChange();
    692582
     
    715605    EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
    716606
    717     impl->pageProxy->reload(/*reloadFromOrigin*/ false);
     607    impl->page()->reload(/*reloadFromOrigin*/ false);
    718608    impl->informURLChange();
    719609
     
    726616    EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
    727617
    728     impl->pageProxy->reload(/*reloadFromOrigin*/ true);
     618    impl->page()->reload(/*reloadFromOrigin*/ true);
    729619    impl->informURLChange();
    730620
     
    737627    EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
    738628
    739     impl->pageProxy->stopLoading();
     629    impl->page()->stopLoading();
    740630
    741631    return true;
     
    774664    EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, -1.0);
    775665
    776     return impl->pageProxy->estimatedProgress();
     666    return impl->page()->estimatedProgress();
    777667}
    778668
     
    782672    EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
    783673
    784     impl->pageProxy->scalePage(scaleFactor, IntPoint(x, y));
     674    impl->page()->scalePage(scaleFactor, IntPoint(x, y));
    785675    return true;
    786676}
     
    791681    EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, -1);
    792682
    793     return impl->pageProxy->pageScaleFactor();
     683    return impl->page()->pageScaleFactor();
    794684}
    795685
     
    799689    EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
    800690
    801     impl->pageProxy->setCustomDeviceScaleFactor(ratio);
     691    impl->page()->setCustomDeviceScaleFactor(ratio);
    802692
    803693    return true;
     
    809699    EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, -1.0);
    810700
    811     return impl->pageProxy->deviceScaleFactor();
     701    return impl->page()->deviceScaleFactor();
    812702}
    813703
     
    833723    EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
    834724
    835     WebPageProxy* page = impl->pageProxy.get();
     725    WebPageProxy* page = impl->page();
    836726    if (page->canGoBack()) {
    837727        page->goBack();
     
    847737    EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
    848738
    849     WebPageProxy* page = impl->pageProxy.get();
     739    WebPageProxy* page = impl->page();
    850740    if (page->canGoForward()) {
    851741        page->goForward();
     
    863753    EINA_SAFETY_ON_NULL_RETURN_VAL(intent, false);
    864754
    865     WebPageProxy* page = impl->pageProxy.get();
     755    WebPageProxy* page = impl->page();
    866756    page->deliverIntentToFrame(page->mainFrame(), intent->webIntentData());
    867757
     
    877767    EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
    878768
    879     return impl->pageProxy->canGoBack();
     769    return impl->page()->canGoBack();
    880770}
    881771
     
    885775    EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
    886776
    887     return impl->pageProxy->canGoForward();
     777    return impl->page()->canGoForward();
    888778}
    889779
     
    893783    EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
    894784
    895     return impl->backForwardList.get();
     785    return impl->backForwardList();
    896786}
    897787
     
    903793
    904794    if (unreachableUrl && *unreachableUrl)
    905         impl->pageProxy->loadAlternateHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : "", String::fromUTF8(unreachableUrl));
     795        impl->page()->loadAlternateHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : "", String::fromUTF8(unreachableUrl));
    906796    else
    907         impl->pageProxy->loadHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : "");
     797        impl->page()->loadHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : "");
    908798
    909799    impl->informURLChange();
     
    946836    EINA_SAFETY_ON_NULL_RETURN_VAL(text, false);
    947837
    948     impl->pageProxy->findString(String::fromUTF8(text), static_cast<WebKit::FindOptions>(options), maxMatchCount);
     838    impl->page()->findString(String::fromUTF8(text), static_cast<WebKit::FindOptions>(options), maxMatchCount);
    949839
    950840    return true;
     
    956846    EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
    957847
    958     impl->pageProxy->hideFindUI();
     848    impl->page()->hideFindUI();
    959849
    960850    return true;
     
    967857    EINA_SAFETY_ON_NULL_RETURN_VAL(text, false);
    968858
    969     impl->pageProxy->countStringMatches(String::fromUTF8(text), static_cast<WebKit::FindOptions>(options), maxMatchCount);
     859    impl->page()->countStringMatches(String::fromUTF8(text), static_cast<WebKit::FindOptions>(options), maxMatchCount);
    970860
    971861    return true;
     
    1000890    // FIXME: Touch points do not take scroll position and scale into account when
    1001891    // TILED_BACKING_STORE is enabled.
    1002     impl->pageProxy->handleTouchEvent(NativeWebTouchEvent(type, points, modifiers, &position, ecore_time_get()));
     892    impl->page()->handleTouchEvent(NativeWebTouchEvent(type, points, modifiers, &position, ecore_time_get()));
    1003893
    1004894    return true;
     
    1040930    EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
    1041931
    1042     WebInspectorProxy* inspector = impl->pageProxy->inspector();
     932    WebInspectorProxy* inspector = impl->page()->inspector();
    1043933    if (inspector)
    1044934        inspector->show();
     
    1056946    EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
    1057947
    1058     WebInspectorProxy* inspector = impl->pageProxy->inspector();
     948    WebInspectorProxy* inspector = impl->page()->inspector();
    1059949    if (inspector)
    1060950        inspector->close();
     
    1078968    EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
    1079969   
    1080     impl->pageProxy->setPaginationMode(static_cast<WebCore::Pagination::Mode>(mode));
     970    impl->page()->setPaginationMode(static_cast<WebCore::Pagination::Mode>(mode));
    1081971
    1082972    return true;
     
    1088978    EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, EWK_PAGINATION_MODE_INVALID);
    1089979
    1090     return static_cast<Ewk_Pagination_Mode>(impl->pageProxy->paginationMode());
    1091 }
     980    return static_cast<Ewk_Pagination_Mode>(impl->page()->paginationMode());
     981}
Note: See TracChangeset for help on using the changeset viewer.