diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2012-10-17 16:21:14 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2012-10-17 16:21:14 +0200 |
commit | 8995b83bcbfbb68245f779b64e5517627c6cc6ea (patch) | |
tree | 17985605dab9263cc2444bd4d45f189e142cca7c /Source/WebKit2/UIProcess/API/efl/ewk_view.cpp | |
parent | b9c9652036d5e9f1e29c574f40bc73a35c81ace6 (diff) | |
download | qtwebkit-8995b83bcbfbb68245f779b64e5517627c6cc6ea.tar.gz |
Imported WebKit commit cf4f8fc6f19b0629f51860cb2d4b25e139d07e00 (http://svn.webkit.org/repository/webkit/trunk@131592)
New snapshot that includes the build fixes for Mac OS X 10.6 and earlier as well
as the previously cherry-picked changes
Diffstat (limited to 'Source/WebKit2/UIProcess/API/efl/ewk_view.cpp')
-rw-r--r-- | Source/WebKit2/UIProcess/API/efl/ewk_view.cpp | 437 |
1 files changed, 356 insertions, 81 deletions
diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp index 10a68c404..95b084e10 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp @@ -44,6 +44,8 @@ #include "ewk_popup_menu_item.h" #include "ewk_popup_menu_item_private.h" #include "ewk_private.h" +#include "ewk_resource.h" +#include "ewk_resource_private.h" #include "ewk_settings_private.h" #include "ewk_view_find_client_private.h" #include "ewk_view_form_client_private.h" @@ -52,7 +54,6 @@ #include "ewk_view_private.h" #include "ewk_view_resource_load_client_private.h" #include "ewk_view_ui_client_private.h" -#include "ewk_web_resource.h" #include <Ecore_Evas.h> #include <Edje.h> #include <WebCore/Cursor.h> @@ -64,6 +65,10 @@ #include "WebFullScreenManagerProxy.h" #endif +#if ENABLE(INSPECTOR) +#include "WebInspectorProxy.h" +#endif + #if USE(ACCELERATED_COMPOSITING) #include <Evas_GL.h> #endif @@ -79,8 +84,32 @@ static const char EWK_VIEW_TYPE_STR[] = "EWK2_View"; static const int defaultCursorSize = 16; -typedef HashMap<uint64_t, Ewk_Web_Resource*> LoadingResourcesMap; -static void _ewk_view_priv_loading_resources_clear(LoadingResourcesMap& loadingResourcesMap); +typedef HashMap< uint64_t, RefPtr<Ewk_Resource> > LoadingResourcesMap; +static void _ewk_view_on_favicon_changed(const char* pageURL, void* eventInfo); + +typedef HashMap<const WebPageProxy*, const Evas_Object*> PageViewMap; + +static inline PageViewMap& pageViewMap() +{ + DEFINE_STATIC_LOCAL(PageViewMap, map, ()); + return map; +} + +static inline void addToPageViewMap(const Evas_Object* ewkView) +{ + ASSERT(ewkView); + ASSERT(ewk_view_page_get(ewkView)); + PageViewMap::AddResult result = pageViewMap().add(ewk_view_page_get(ewkView), ewkView); + ASSERT_UNUSED(result, result.isNewEntry); +} + +static inline void removeFromPageViewMap(const Evas_Object* ewkView) +{ + ASSERT(ewkView); + ASSERT(ewk_view_page_get(ewkView)); + ASSERT(pageViewMap().contains(ewk_view_page_get(ewkView))); + pageViewMap().remove(ewk_view_page_get(ewkView)); +} struct _Ewk_View_Private_Data { OwnPtr<PageClientImpl> pageClient; @@ -89,18 +118,22 @@ struct _Ewk_View_Private_Data { #endif RefPtr<WebPageProxy> pageProxy; - WKEinaSharedString uri; + WKEinaSharedString url; WKEinaSharedString title; WKEinaSharedString theme; WKEinaSharedString customEncoding; WKEinaSharedString cursorGroup; + WKEinaSharedString faviconURL; Evas_Object* cursorObject; LoadingResourcesMap loadingResourcesMap; - Ewk_Back_Forward_List* backForwardList; + OwnPtr<Ewk_Back_Forward_List> backForwardList; OwnPtr<Ewk_Settings> settings; bool areMouseEventsEnabled; WKColorPickerResultListenerRef colorPickerResultListener; Ewk_Context* context; +#if ENABLE(TOUCH_EVENTS) + bool areTouchEventsEnabled; +#endif WebPopupMenuProxyEfl* popupMenuProxy; Eina_List* popupMenuItems; @@ -117,10 +150,12 @@ struct _Ewk_View_Private_Data { _Ewk_View_Private_Data() : cursorObject(0) - , backForwardList(0) , areMouseEventsEnabled(false) , colorPickerResultListener(0) , context(0) +#if ENABLE(TOUCH_EVENTS) + , areTouchEventsEnabled(false) +#endif , popupMenuProxy(0) , popupMenuItems(0) #ifdef HAVE_ECORE_X @@ -135,16 +170,16 @@ struct _Ewk_View_Private_Data { ~_Ewk_View_Private_Data() { - _ewk_view_priv_loading_resources_clear(loadingResourcesMap); + /* Unregister icon change callback */ + Ewk_Favicon_Database* iconDatabase = ewk_context_favicon_database_get(context); + ewk_favicon_database_icon_change_callback_del(iconDatabase, _ewk_view_on_favicon_changed); if (cursorObject) evas_object_del(cursorObject); - ewk_back_forward_list_free(backForwardList); - void* item; EINA_LIST_FREE(popupMenuItems, item) - ewk_popup_menu_item_free(static_cast<Ewk_Popup_Menu_Item*>(item)); + delete static_cast<Ewk_Popup_Menu_Item*>(item); } }; @@ -216,6 +251,17 @@ static void _ewk_view_smart_changed(Ewk_View_Smart_Data* smartData) evas_object_smart_changed(smartData->self); } +static void _ewk_view_on_favicon_changed(const char* pageURL, void* eventInfo) +{ + Evas_Object* ewkView = static_cast<Evas_Object*>(eventInfo); + + const char* view_url = ewk_view_url_get(ewkView); + if (!view_url || strcasecmp(view_url, pageURL)) + return; + + ewk_view_update_icon(ewkView); +} + // Default Event Handling. static Eina_Bool _ewk_view_smart_focus_in(Ewk_View_Smart_Data* smartData) { @@ -356,6 +402,65 @@ static void _ewk_view_on_key_up(void* data, Evas*, Evas_Object*, void* eventInfo smartData->api->key_up(smartData, upEvent); } +static void _ewk_view_on_show(void* data, Evas*, Evas_Object*, void* /*eventInfo*/) +{ + Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data); + EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv); + priv->pageProxy->viewStateDidChange(WebPageProxy::ViewIsVisible); +} + +static void _ewk_view_on_hide(void* data, Evas*, Evas_Object*, void* /*eventInfo*/) +{ + Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data); + EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv); + + // This call may look wrong, but we really need to pass ViewIsVisible here. + // viewStateDidChange() itself is responsible for actually setting the visibility to Visible or Hidden + // depending on what WebPageProxy::isViewVisible() returns, this simply triggers the process. + priv->pageProxy->viewStateDidChange(WebPageProxy::ViewIsVisible); +} + +#if ENABLE(TOUCH_EVENTS) +static inline void _ewk_view_feed_touch_event_using_touch_point_list_of_evas(Evas_Object* ewkView, Ewk_Touch_Event_Type type) +{ + EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); + + unsigned count = evas_touch_point_list_count(smartData->base.evas); + if (!count) + return; + + Eina_List* points = 0; + for (unsigned i = 0; i < count; ++i) { + Ewk_Touch_Point* point = new Ewk_Touch_Point; + point->id = evas_touch_point_list_nth_id_get(smartData->base.evas, i); + evas_touch_point_list_nth_xy_get(smartData->base.evas, i, &point->x, &point->y); + point->state = evas_touch_point_list_nth_state_get(smartData->base.evas, i); + points = eina_list_append(points, point); + } + + ewk_view_feed_touch_event(ewkView, type, points, evas_key_modifier_get(smartData->base.evas)); + + void* data; + EINA_LIST_FREE(points, data) + delete static_cast<Ewk_Touch_Point*>(data); +} + +static void _ewk_view_on_touch_down(void* /* data */, Evas* /* canvas */, Evas_Object* ewkView, void* /* eventInfo */) +{ + _ewk_view_feed_touch_event_using_touch_point_list_of_evas(ewkView, EWK_TOUCH_START); +} + +static void _ewk_view_on_touch_up(void* /* data */, Evas* /* canvas */, Evas_Object* ewkView, void* /* eventInfo */) +{ + _ewk_view_feed_touch_event_using_touch_point_list_of_evas(ewkView, EWK_TOUCH_END); +} + +static void _ewk_view_on_touch_move(void* /* data */, Evas* /* canvas */, Evas_Object* ewkView, void* /* eventInfo */) +{ + _ewk_view_feed_touch_event_using_touch_point_list_of_evas(ewkView, EWK_TOUCH_MOVE); +} +#endif + static Evas_Smart_Class g_parentSmartClass = EVAS_SMART_CLASS_INIT_NULL; static Ewk_View_Private_Data* _ewk_view_priv_new(Ewk_View_Smart_Data* smartData) @@ -373,17 +478,6 @@ static Ewk_View_Private_Data* _ewk_view_priv_new(Ewk_View_Smart_Data* smartData) return priv; } -static void _ewk_view_priv_loading_resources_clear(LoadingResourcesMap& loadingResourcesMap) -{ - // Clear the loadingResources HashMap. - LoadingResourcesMap::iterator it = loadingResourcesMap.begin(); - LoadingResourcesMap::iterator end = loadingResourcesMap.end(); - for ( ; it != end; ++it) - ewk_web_resource_unref(it->second); - - loadingResourcesMap.clear(); -} - static void _ewk_view_priv_del(Ewk_View_Private_Data* priv) { ewk_context_unref(priv->context); @@ -434,11 +528,14 @@ static void _ewk_view_smart_add(Evas_Object* ewkView) CONNECT(EVAS_CALLBACK_MOUSE_WHEEL, _ewk_view_on_mouse_wheel); CONNECT(EVAS_CALLBACK_KEY_DOWN, _ewk_view_on_key_down); CONNECT(EVAS_CALLBACK_KEY_UP, _ewk_view_on_key_up); + CONNECT(EVAS_CALLBACK_SHOW, _ewk_view_on_show); + CONNECT(EVAS_CALLBACK_HIDE, _ewk_view_on_hide); #undef CONNECT } static void _ewk_view_smart_del(Evas_Object* ewkView) { + removeFromPageViewMap(ewkView); EWK_VIEW_SD_GET(ewkView, smartData); if (smartData && smartData->priv) _ewk_view_priv_del(smartData->priv); @@ -530,6 +627,7 @@ bool ewk_view_accelerated_compositing_mode_enter(const Evas_Object* ewkView) return false; } + priv->viewportHandler->setRendererActive(true); return true; } @@ -562,6 +660,7 @@ static void _ewk_view_smart_calculate(Evas_Object* ewkView) EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv); Evas_Coord x, y, width, height; + bool needsNewSurface = false; smartData->changed.any = false; @@ -571,19 +670,13 @@ static void _ewk_view_smart_calculate(Evas_Object* ewkView) #if USE(COORDINATED_GRAPHICS) priv->viewportHandler->updateViewportSize(IntSize(width, height)); #endif +#if USE(ACCELERATED_COMPOSITING) + needsNewSurface = priv->evasGlSurface; +#endif if (priv->pageProxy->drawingArea()) priv->pageProxy->drawingArea()->setSize(IntSize(width, height), IntSize()); -#if USE(ACCELERATED_COMPOSITING) - if (!priv->evasGlSurface) - return; - evas_gl_surface_destroy(priv->evasGl, priv->evasGlSurface); - priv->evasGlSurface = 0; - ewk_view_create_gl_surface(ewkView, IntSize(width, height)); - ewk_view_display(ewkView, IntRect(IntPoint(), IntSize(width, height))); -#endif - smartData->view.w = width; smartData->view.h = height; smartData->changed.size = false; @@ -595,6 +688,15 @@ static void _ewk_view_smart_calculate(Evas_Object* ewkView) smartData->view.y = y; smartData->changed.position = false; } + +#if USE(ACCELERATED_COMPOSITING) + if (needsNewSurface) { + evas_gl_surface_destroy(priv->evasGl, priv->evasGlSurface); + priv->evasGlSurface = 0; + ewk_view_create_gl_surface(ewkView, IntSize(width, height)); + ewk_view_display(ewkView, IntRect(IntPoint(), IntSize(width, height))); + } +#endif } static void _ewk_view_smart_show(Evas_Object* ewkView) @@ -708,6 +810,9 @@ static void _ewk_view_initialize(Evas_Object* ewkView, Ewk_Context* context, WKP priv->pageProxy = toImpl(ewk_context_WKContext_get(context))->createWebPage(priv->pageClient.get(), toImpl(pageGroupRef)); else priv->pageProxy = toImpl(ewk_context_WKContext_get(context))->createWebPage(priv->pageClient.get(), WebPageGroup::create().get()); + + addToPageViewMap(ewkView); + #if USE(COORDINATED_GRAPHICS) priv->pageProxy->pageGroup()->preferences()->setAcceleratedCompositingEnabled(true); priv->pageProxy->pageGroup()->preferences()->setForceCompositingMode(true); @@ -715,7 +820,7 @@ static void _ewk_view_initialize(Evas_Object* ewkView, Ewk_Context* context, WKP #endif priv->pageProxy->initializeWebPage(); - priv->backForwardList = ewk_back_forward_list_new(toAPI(priv->pageProxy->backForwardList())); + priv->backForwardList = Ewk_Back_Forward_List::create(toAPI(priv->pageProxy->backForwardList())); priv->settings = adoptPtr(new Ewk_Settings(WKPageGroupGetPreferences(WKPageGetPageGroup(toAPI(priv->pageProxy.get()))))); priv->context = ewk_context_ref(context); @@ -734,6 +839,10 @@ static void _ewk_view_initialize(Evas_Object* ewkView, Ewk_Context* context, WKP priv->pageProxy->fullScreenManager()->setWebView(ewkView); ewk_settings_fullscreen_enabled_set(priv->settings.get(), true); #endif + + /* Listen for favicon changes */ + Ewk_Favicon_Database* iconDatabase = ewk_context_favicon_database_get(priv->context); + ewk_favicon_database_icon_change_callback_add(iconDatabase, _ewk_view_on_favicon_changed, ewkView); } static Evas_Object* _ewk_view_add_with_smart(Evas* canvas, Evas_Smart* smart) @@ -812,11 +921,11 @@ Ewk_Context* ewk_view_context_get(const Evas_Object* ewkView) /** * @internal - * The uri of view was changed by the frame loader. + * The url of view was changed by the frame loader. * - * Emits signal: "uri,changed" with pointer to new uri string. + * Emits signal: "url,changed" with pointer to new url string. */ -void ewk_view_uri_update(Evas_Object* ewkView) +void ewk_view_url_update(Evas_Object* ewkView) { EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv); @@ -825,32 +934,43 @@ void ewk_view_uri_update(Evas_Object* ewkView) if (activeURL.isEmpty()) return; - if (priv->uri == activeURL.utf8().data()) + if (priv->url == activeURL.utf8().data()) return; - priv->uri = activeURL.utf8().data(); - const char* callbackArgument = static_cast<const char*>(priv->uri); - evas_object_smart_callback_call(ewkView, "uri,changed", const_cast<char*>(callbackArgument)); + priv->url = activeURL.utf8().data(); + const char* callbackArgument = static_cast<const char*>(priv->url); + evas_object_smart_callback_call(ewkView, "url,changed", const_cast<char*>(callbackArgument)); + + // Update the view's favicon. + ewk_view_update_icon(ewkView); } -Eina_Bool ewk_view_uri_set(Evas_Object* ewkView, const char* uri) +Eina_Bool ewk_view_url_set(Evas_Object* ewkView, const char* url) { EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); - EINA_SAFETY_ON_NULL_RETURN_VAL(uri, false); + EINA_SAFETY_ON_NULL_RETURN_VAL(url, false); - priv->pageProxy->loadURL(uri); - ewk_view_uri_update(ewkView); + priv->pageProxy->loadURL(url); + ewk_view_url_update(ewkView); return true; } -const char* ewk_view_uri_get(const Evas_Object* ewkView) +const char* ewk_view_url_get(const Evas_Object* ewkView) { EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0); EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0); - return priv->uri; + return priv->url; +} + +const char *ewk_view_icon_url_get(const Evas_Object *ewkView) +{ + EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0); + EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0); + + return priv->faviconURL; } Eina_Bool ewk_view_reload(Evas_Object* ewkView) @@ -859,7 +979,7 @@ Eina_Bool ewk_view_reload(Evas_Object* ewkView) EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); priv->pageProxy->reload(/*reloadFromOrigin*/ false); - ewk_view_uri_update(ewkView); + ewk_view_url_update(ewkView); return true; } @@ -870,7 +990,7 @@ Eina_Bool ewk_view_reload_bypass_cache(Evas_Object* ewkView) EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); priv->pageProxy->reload(/*reloadFromOrigin*/ true); - ewk_view_uri_update(ewkView); + ewk_view_url_update(ewkView); return true; } @@ -899,15 +1019,15 @@ Ewk_Settings* ewk_view_settings_get(const Evas_Object* ewkView) * * Emits signal: "resource,request,new" with pointer to resource request. */ -void ewk_view_resource_load_initiated(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Web_Resource* resource, Ewk_Url_Request* request) +void ewk_view_resource_load_initiated(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Resource* resource, Ewk_Url_Request* request) { EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv); - Ewk_Web_Resource_Request resourceRequest = {resource, request, 0}; + Ewk_Resource_Request resourceRequest = {resource, request, 0}; // Keep the resource internally to reuse it later. - priv->loadingResourcesMap.add(resourceIdentifier, ewk_web_resource_ref(resource)); + priv->loadingResourcesMap.add(resourceIdentifier, resource); evas_object_smart_callback_call(ewkView, "resource,request,new", &resourceRequest); } @@ -926,8 +1046,8 @@ void ewk_view_resource_load_response(Evas_Object* ewkView, uint64_t resourceIden if (!priv->loadingResourcesMap.contains(resourceIdentifier)) return; - Ewk_Web_Resource* resource = priv->loadingResourcesMap.get(resourceIdentifier); - Ewk_Web_Resource_Load_Response resourceLoadResponse = {resource, response}; + RefPtr<Ewk_Resource> resource = priv->loadingResourcesMap.get(resourceIdentifier); + Ewk_Resource_Load_Response resourceLoadResponse = {resource.get(), response}; evas_object_smart_callback_call(ewkView, "resource,request,response", &resourceLoadResponse); } @@ -937,7 +1057,7 @@ void ewk_view_resource_load_response(Evas_Object* ewkView, uint64_t resourceIden * * Emits signal: "resource,request,finished" with pointer to the resource load error. */ -void ewk_view_resource_load_failed(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Web_Error* error) +void ewk_view_resource_load_failed(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Error* error) { EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv); @@ -945,8 +1065,8 @@ void ewk_view_resource_load_failed(Evas_Object* ewkView, uint64_t resourceIdenti if (!priv->loadingResourcesMap.contains(resourceIdentifier)) return; - Ewk_Web_Resource* resource = priv->loadingResourcesMap.get(resourceIdentifier); - Ewk_Web_Resource_Load_Error resourceLoadError = {resource, error}; + RefPtr<Ewk_Resource> resource = priv->loadingResourcesMap.get(resourceIdentifier); + Ewk_Resource_Load_Error resourceLoadError = {resource.get(), error}; evas_object_smart_callback_call(ewkView, "resource,request,failed", &resourceLoadError); } @@ -964,10 +1084,8 @@ void ewk_view_resource_load_finished(Evas_Object* ewkView, uint64_t resourceIden if (!priv->loadingResourcesMap.contains(resourceIdentifier)) return; - Ewk_Web_Resource* resource = priv->loadingResourcesMap.take(resourceIdentifier); - evas_object_smart_callback_call(ewkView, "resource,request,finished", resource); - - ewk_web_resource_unref(resource); + RefPtr<Ewk_Resource> resource = priv->loadingResourcesMap.take(resourceIdentifier); + evas_object_smart_callback_call(ewkView, "resource,request,finished", resource.get()); } /** @@ -984,8 +1102,8 @@ void ewk_view_resource_request_sent(Evas_Object* ewkView, uint64_t resourceIdent if (!priv->loadingResourcesMap.contains(resourceIdentifier)) return; - Ewk_Web_Resource* resource = priv->loadingResourcesMap.get(resourceIdentifier); - Ewk_Web_Resource_Request resourceRequest = {resource, request, redirectResponse}; + RefPtr<Ewk_Resource> resource = priv->loadingResourcesMap.get(resourceIdentifier); + Ewk_Resource_Request resourceRequest = {resource.get(), request, redirectResponse}; evas_object_smart_callback_call(ewkView, "resource,request,sent", &resourceRequest); } @@ -1023,6 +1141,17 @@ void ewk_view_title_changed(Evas_Object* ewkView, const char* title) evas_object_smart_callback_call(ewkView, "title,changed", const_cast<char*>(title)); } +/** + * @internal + */ +void ewk_view_tooltip_text_set(Evas_Object* ewkView, const char* text) +{ + if (text && *text) + evas_object_smart_callback_call(ewkView, "tooltip,text,set", const_cast<char*>(text)); + else + evas_object_smart_callback_call(ewkView, "tooltip,text,unset", 0); +} + double ewk_view_load_progress_get(const Evas_Object* ewkView) { EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0); @@ -1171,7 +1300,7 @@ void ewk_view_display(Evas_Object* ewkView, const IntRect& rect) EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv); evas_gl_make_current(priv->evasGl, priv->evasGlSurface, priv->evasGlContext); - priv->viewportHandler->display(rect); + priv->viewportHandler->display(rect, IntPoint(smartData->view.x, smartData->view.y)); #endif evas_object_image_data_update_add(smartData->image, rect.x(), rect.y(), rect.width(), rect.height()); @@ -1207,6 +1336,22 @@ void ewk_view_full_screen_exit(Evas_Object* ewkView) } #endif +#if ENABLE(SQL_DATABASE) +/** + * @internal + * Calls exceeded_database_quota callback or falls back to default behavior returns default database quota. + */ +unsigned long long ewk_view_database_quota_exceeded(Evas_Object* ewkView, const char* databaseName, const char* displayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentDatabaseUsage, unsigned long long expectedUsage) +{ + EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0); + + static const unsigned long long defaultQuota = 5 * 1024 * 1204; // 5 MB + if (smartData->api->exceeded_database_quota) + return smartData->api->exceeded_database_quota(smartData, databaseName, displayName, currentQuota, currentOriginUsage, currentDatabaseUsage, expectedUsage); + + return defaultQuota; +} +#endif /** * @internal @@ -1236,7 +1381,7 @@ void ewk_view_download_job_requested(Evas_Object* ewkView, Ewk_Download_Job* dow * * Emits signal: "download,failed" with pointer to a Ewk_Download_Job_Error. */ -void ewk_view_download_job_failed(Evas_Object* ewkView, Ewk_Download_Job* download, Ewk_Web_Error* error) +void ewk_view_download_job_failed(Evas_Object* ewkView, Ewk_Download_Job* download, Ewk_Error* error) { Ewk_Download_Job_Error downloadError = { download, error }; evas_object_smart_callback_call(ewkView, "download,failed", &downloadError); @@ -1289,7 +1434,7 @@ Eina_Bool ewk_view_intent_deliver(Evas_Object* ewkView, Ewk_Intent* intent) EINA_SAFETY_ON_NULL_RETURN_VAL(intent, false); WebPageProxy* page = priv->pageProxy.get(); - page->deliverIntentToFrame(page->mainFrame(), toImpl(ewk_intent_WKIntentDataRef_get(intent))); + page->deliverIntentToFrame(page->mainFrame(), toImpl(intent->wkIntent.get())); return true; #else @@ -1318,7 +1463,7 @@ Ewk_Back_Forward_List* ewk_view_back_forward_list_get(const Evas_Object* ewkView EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0); EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0); - return priv->backForwardList; + return priv->backForwardList.get(); } void ewk_view_image_data_set(Evas_Object* ewkView, void* imageData, const IntSize& size) @@ -1347,11 +1492,11 @@ void ewk_view_form_submission_request_new(Evas_Object* ewkView, Ewk_Form_Submiss * @internal * Reports load failed with error information. * - * Emits signal: "load,error" with pointer to Ewk_Web_Error. + * Emits signal: "load,error" with pointer to Ewk_Error. */ -void ewk_view_load_error(Evas_Object* ewkView, const Ewk_Web_Error* error) +void ewk_view_load_error(Evas_Object* ewkView, const Ewk_Error* error) { - evas_object_smart_callback_call(ewkView, "load,error", const_cast<Ewk_Web_Error*>(error)); + evas_object_smart_callback_call(ewkView, "load,error", const_cast<Ewk_Error*>(error)); } /** @@ -1362,7 +1507,7 @@ void ewk_view_load_error(Evas_Object* ewkView, const Ewk_Web_Error* error) */ void ewk_view_load_finished(Evas_Object* ewkView) { - ewk_view_uri_update(ewkView); + ewk_view_url_update(ewkView); evas_object_smart_callback_call(ewkView, "load,finished", 0); } @@ -1370,11 +1515,11 @@ void ewk_view_load_finished(Evas_Object* ewkView) * @internal * Reports view provisional load failed with error information. * - * Emits signal: "load,provisional,failed" with pointer to Ewk_Web_Error. + * Emits signal: "load,provisional,failed" with pointer to Ewk_Error. */ -void ewk_view_load_provisional_failed(Evas_Object* ewkView, const Ewk_Web_Error* error) +void ewk_view_load_provisional_failed(Evas_Object* ewkView, const Ewk_Error* error) { - evas_object_smart_callback_call(ewkView, "load,provisional,failed", const_cast<Ewk_Web_Error*>(error)); + evas_object_smart_callback_call(ewkView, "load,provisional,failed", const_cast<Ewk_Error*>(error)); } /** @@ -1385,7 +1530,7 @@ void ewk_view_load_provisional_failed(Evas_Object* ewkView, const Ewk_Web_Error* */ void ewk_view_load_provisional_redirect(Evas_Object* ewkView) { - ewk_view_uri_update(ewkView); + ewk_view_url_update(ewkView); evas_object_smart_callback_call(ewkView, "load,provisional,redirect", 0); } @@ -1402,14 +1547,45 @@ void ewk_view_load_provisional_started(Evas_Object* ewkView) // The main frame started provisional load, we should clear // the loadingResources HashMap to start clean. - _ewk_view_priv_loading_resources_clear(priv->loadingResourcesMap); + priv->loadingResourcesMap.clear(); - ewk_view_uri_update(ewkView); + ewk_view_url_update(ewkView); evas_object_smart_callback_call(ewkView, "load,provisional,started", 0); } /** * @internal + * Reports that the view's back / forward list has changed. + * + * Emits signal: "back,forward,list,changed". + */ +void ewk_view_back_forward_list_changed(Evas_Object* ewkView) +{ + evas_object_smart_callback_call(ewkView, "back,forward,list,changed", 0); +} + +/** + * @internal + * Update the view's favicon and emits a "icon,changed" signal if it has + * changed. + * + * This function is called whenever the URL has changed or when the icon for + * the current page URL has changed. + */ +void ewk_view_update_icon(Evas_Object* ewkView) +{ + EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); + EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv); + + Ewk_Favicon_Database* iconDatabase = ewk_context_favicon_database_get(priv->context); + ASSERT(iconDatabase); + + priv->faviconURL = ewk_favicon_database_icon_url_get(iconDatabase, priv->url); + evas_object_smart_callback_call(ewkView, "icon,changed", 0); +} + +/** + * @internal * Reports that a navigation policy decision should be taken. * * Emits signal: "policy,decision,navigation". @@ -1440,7 +1616,7 @@ Eina_Bool ewk_view_html_string_load(Evas_Object* ewkView, const char* html, cons priv->pageProxy->loadAlternateHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : "", String::fromUTF8(unreachableUrl)); else priv->pageProxy->loadHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : ""); - ewk_view_uri_update(ewkView); + ewk_view_url_update(ewkView); return true; } @@ -1458,6 +1634,13 @@ void ewk_view_intent_service_register(Evas_Object* ewkView, const Ewk_Intent_Ser } #endif // ENABLE(WEB_INTENTS_TAG) +const Evas_Object* ewk_view_from_page_get(const WebKit::WebPageProxy* page) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(page, 0); + + return pageViewMap().get(page); +} + WebPageProxy* ewk_view_page_get(const Evas_Object* ewkView) { EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0); @@ -1517,14 +1700,13 @@ COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_SHOW_OVERLAY, kWKFindOptionsShowOv COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_SHOW_FIND_INDICATOR, kWKFindOptionsShowFindIndicator); COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_SHOW_HIGHLIGHT, kWKFindOptionsShowHighlight); -Eina_Bool ewk_view_text_find(Evas_Object* ewkView, const char* text, Ewk_Find_Options options, unsigned int maxMatchCount) +Eina_Bool ewk_view_text_find(Evas_Object* ewkView, const char* text, Ewk_Find_Options options, unsigned maxMatchCount) { EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); EINA_SAFETY_ON_NULL_RETURN_VAL(text, false); - WKRetainPtr<WKStringRef> findText(AdoptWK, WKStringCreateWithUTF8CString(text)); - WKPageFindString(toAPI(priv->pageProxy.get()), findText.get(), static_cast<WKFindOptions>(options), maxMatchCount); + priv->pageProxy->findString(String::fromUTF8(text), static_cast<WebKit::FindOptions>(options), maxMatchCount); return true; } @@ -1534,7 +1716,18 @@ Eina_Bool ewk_view_text_find_highlight_clear(Evas_Object* ewkView) EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); - WKPageHideFindUI(toAPI(priv->pageProxy.get())); + priv->pageProxy->hideFindUI(); + + return true; +} + +Eina_Bool ewk_view_text_matches_count(Evas_Object* ewkView, const char* text, Ewk_Find_Options options, unsigned maxMatchCount) +{ + EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); + EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + EINA_SAFETY_ON_NULL_RETURN_VAL(text, false); + + priv->pageProxy->countStringMatches(String::fromUTF8(text), static_cast<WebKit::FindOptions>(options), maxMatchCount); return true; } @@ -1573,7 +1766,7 @@ void ewk_view_popup_menu_request(Evas_Object* ewkView, WebPopupMenuProxyEfl* pop Eina_List* popupItems = 0; size_t size = items.size(); for (size_t i = 0; i < size; ++i) - popupItems = eina_list_append(popupItems, ewk_popup_menu_item_new(items[i])); + popupItems = eina_list_append(popupItems, Ewk_Popup_Menu_Item::create(items[i]).leakPtr()); priv->popupMenuItems = popupItems; smartData->api->popup_menu_show(smartData, rect, static_cast<Ewk_Text_Direction>(textDirection), pageScaleFactor, popupItems, selectedIndex); @@ -1595,7 +1788,7 @@ Eina_Bool ewk_view_popup_menu_close(Evas_Object* ewkView) void* item; EINA_LIST_FREE(priv->popupMenuItems, item) - ewk_popup_menu_item_free(static_cast<Ewk_Popup_Menu_Item*>(item)); + delete static_cast<Ewk_Popup_Menu_Item*>(item); return true; } @@ -1778,3 +1971,85 @@ Eina_Bool ewk_view_feed_touch_event(Evas_Object* ewkView, Ewk_Touch_Event_Type t return false; #endif } + +Eina_Bool ewk_view_touch_events_enabled_set(Evas_Object* ewkView, Eina_Bool enabled) +{ +#if ENABLE(TOUCH_EVENTS) + EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); + EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + + enabled = !!enabled; + if (priv->areTouchEventsEnabled == enabled) + return true; + + priv->areTouchEventsEnabled = enabled; + if (enabled) { + // FIXME: We have to connect touch callbacks with mouse and multi events + // because the Evas creates mouse events for first touch and multi events + // for second and third touches. Below codes should be fixed when the Evas + // supports the touch events. + // See https://bugs.webkit.org/show_bug.cgi?id=97785 for details. + evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_touch_down, smartData); + evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_touch_up, smartData); + evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_touch_move, smartData); + evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MULTI_DOWN, _ewk_view_on_touch_down, smartData); + evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MULTI_UP, _ewk_view_on_touch_up, smartData); + evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MULTI_MOVE, _ewk_view_on_touch_move, smartData); + } else { + evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_touch_down); + evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_touch_up); + evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_touch_move); + evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MULTI_DOWN, _ewk_view_on_touch_down); + evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MULTI_UP, _ewk_view_on_touch_up); + evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MULTI_MOVE, _ewk_view_on_touch_move); + } + + return true; +#else + return false; +#endif +} + +Eina_Bool ewk_view_touch_events_enabled_get(const Evas_Object* ewkView) +{ +#if ENABLE(TOUCH_EVENTS) + EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); + EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + + return priv->areTouchEventsEnabled; +#else + return false; +#endif +} + +Eina_Bool ewk_view_inspector_show(Evas_Object* ewkView) +{ +#if ENABLE(INSPECTOR) + EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); + EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + + WebInspectorProxy* inspector = priv->pageProxy->inspector(); + if (inspector) + inspector->show(); + + return true; +#else + return false; +#endif +} + +Eina_Bool ewk_view_inspector_close(Evas_Object* ewkView) +{ +#if ENABLE(INSPECTOR) + EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); + EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + + WebInspectorProxy* inspector = priv->pageProxy->inspector(); + if (inspector) + inspector->close(); + + return true; +#else + return false; +#endif +} |