Diff
Modified: trunk/Source/WebKit2/ChangeLog (143189 => 143190)
--- trunk/Source/WebKit2/ChangeLog 2013-02-18 11:22:32 UTC (rev 143189)
+++ trunk/Source/WebKit2/ChangeLog 2013-02-18 11:24:35 UTC (rev 143190)
@@ -1,3 +1,49 @@
+2013-02-18 Christophe Dumez <[email protected]>
+
+ [EFL][WK2] Refactor Ewk_Favicon code and stop relying on internal C++ API
+ https://bugs.webkit.org/show_bug.cgi?id=108598
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ Refactor the Ewk_Favicon code so that it no longer relies on internal
+ C++ API and so that it is based solely on the C API. The API is changed
+ a little as well so that the Favicon URL is no longer exposed to the
+ client. Also the client is now only notified of icon changes once the
+ favicon data is actually available.
+
+ The API is covered by existing API tests and by MiniBrowser which are
+ both updated accordingly in this patch.
+
+ * UIProcess/API/efl/EwkView.cpp:
+ (EwkView::informURLChange):
+ (EwkView::createFavicon):
+ (EwkView::onFaviconChanged):
+ * UIProcess/API/efl/EwkView.h:
+ (EwkView):
+ * UIProcess/API/efl/EwkViewCallbacks.h:
+ * UIProcess/API/efl/ewk_favicon_database.cpp:
+ Client are now notified of favicon changes only when the favicon data
+ becomes available and make API to retrieve a favicon synchronous. NULL
+ is returned if the favicon data is not available.
+
+ (EwkFaviconDatabase::EwkFaviconDatabase):
+ (EwkFaviconDatabase::getIconSurfaceSynchronously):
+ (EwkFaviconDatabase::iconDataReadyForPageURL):
+ (ewk_favicon_database_icon_get):
+ * UIProcess/API/efl/ewk_favicon_database.h:
+ * UIProcess/API/efl/ewk_favicon_database_private.h:
+ (EwkFaviconDatabase):
+ * UIProcess/API/efl/ewk_view.cpp:
+ (ewk_view_favicon_get):
+ * UIProcess/API/efl/ewk_view.h:
+ Rename 'icon,changed' signal to 'favicon,changed' for clarity and
+ consistency with the rest of the favicon API. Remove API to retrieve
+ the favicon URL and replace it by one to retrieve the favicon image as
+ an Evas_Object instead.
+
+ * UIProcess/API/efl/tests/test_ewk2_favicon_database.cpp:
+ Update API tests to use the new favicon API.
+
2013-02-17 Jae Hyun Park <[email protected]>
Remove unnecessary public method DrawingAreaImpl::createGraphicsContext()
Modified: trunk/Source/WebKit2/UIProcess/API/efl/EwkView.cpp (143189 => 143190)
--- trunk/Source/WebKit2/UIProcess/API/efl/EwkView.cpp 2013-02-18 11:22:32 UTC (rev 143189)
+++ trunk/Source/WebKit2/UIProcess/API/efl/EwkView.cpp 2013-02-18 11:24:35 UTC (rev 143190)
@@ -779,23 +779,6 @@
}
#endif
-/**
- * @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 EwkView::informIconChange()
-{
- EwkFaviconDatabase* iconDatabase = m_context->faviconDatabase();
- ASSERT(iconDatabase);
-
- m_faviconURL = ewk_favicon_database_icon_url_get(iconDatabase, m_url);
- smartCallback<IconChanged>().call();
-}
-
bool EwkView::createGLSurface()
{
if (!m_isAccelerated)
@@ -1044,9 +1027,17 @@
smartCallback<URLChanged>().call(m_url);
// Update the view's favicon.
- informIconChange();
+ smartCallback<FaviconChanged>().call();
}
+Evas_Object* EwkView::createFavicon() const
+{
+ EwkFaviconDatabase* iconDatabase = m_context->faviconDatabase();
+ ASSERT(iconDatabase);
+
+ return ewk_favicon_database_icon_get(iconDatabase, m_url, smartData()->base.evas);
+}
+
EwkWindowFeatures* EwkView::windowFeatures()
{
if (!m_windowFeatures)
@@ -1338,7 +1329,7 @@
if (!view->url() || strcasecmp(view->url(), pageURL))
return;
- view->informIconChange();
+ view->smartCallback<FaviconChanged>().call();
}
PassRefPtr<cairo_surface_t> EwkView::takeSnapshot()
Modified: trunk/Source/WebKit2/UIProcess/API/efl/EwkView.h (143189 => 143190)
--- trunk/Source/WebKit2/UIProcess/API/efl/EwkView.h 2013-02-18 11:22:32 UTC (rev 143189)
+++ trunk/Source/WebKit2/UIProcess/API/efl/EwkView.h 2013-02-18 11:24:35 UTC (rev 143190)
@@ -146,7 +146,7 @@
void paintToCairoSurface(cairo_surface_t*);
const char* url() const { return m_url; }
- const char* faviconURL() const { return m_faviconURL; }
+ Evas_Object* createFavicon() const;
const char* title() const;
WebKit::InputMethodContextEfl* inputMethodContext();
@@ -232,8 +232,6 @@
WebCore::CoordinatedGraphicsScene* coordinatedGraphicsScene();
- void informIconChange();
-
// Evas_Smart_Class callback interface:
static void handleEvasObjectAdd(Evas_Object*);
static void handleEvasObjectDelete(Evas_Object*);
@@ -289,7 +287,6 @@
OwnPtr<EwkSettings> m_settings;
RefPtr<EwkWindowFeatures> m_windowFeatures;
const void* m_cursorIdentifier; // This is an address, do not free it.
- WKEinaSharedString m_faviconURL;
WKEinaSharedString m_url;
mutable WKEinaSharedString m_title;
WKEinaSharedString m_theme;
Modified: trunk/Source/WebKit2/UIProcess/API/efl/EwkViewCallbacks.h (143189 => 143190)
--- trunk/Source/WebKit2/UIProcess/API/efl/EwkViewCallbacks.h 2013-02-18 11:22:32 UTC (rev 143189)
+++ trunk/Source/WebKit2/UIProcess/API/efl/EwkViewCallbacks.h 2013-02-18 11:24:35 UTC (rev 143190)
@@ -54,7 +54,7 @@
DownloadJobRequested,
FileChooserRequest,
NewFormSubmissionRequest,
- IconChanged,
+ FaviconChanged,
LoadError,
LoadFinished,
LoadProgress,
@@ -164,7 +164,7 @@
DECLARE_EWK_VIEW_CALLBACK(DownloadJobRequested, "download,request", Ewk_Download_Job*);
DECLARE_EWK_VIEW_CALLBACK(FileChooserRequest, "file,chooser,request", Ewk_File_Chooser_Request*);
DECLARE_EWK_VIEW_CALLBACK(NewFormSubmissionRequest, "form,submission,request", Ewk_Form_Submission_Request*);
-DECLARE_EWK_VIEW_CALLBACK(IconChanged, "icon,changed", void);
+DECLARE_EWK_VIEW_CALLBACK(FaviconChanged, "favicon,changed", void);
DECLARE_EWK_VIEW_CALLBACK(LoadError, "load,error", Ewk_Error*);
DECLARE_EWK_VIEW_CALLBACK(LoadFinished, "load,finished", void);
DECLARE_EWK_VIEW_CALLBACK(LoadProgress, "load,progress", double*);
Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_favicon_database.cpp (143189 => 143190)
--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_favicon_database.cpp 2013-02-18 11:22:32 UTC (rev 143189)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_favicon_database.cpp 2013-02-18 11:24:35 UTC (rev 143190)
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2012 Intel Corporation. All rights reserved.
+ * Copyright (C) 2013 Samsung Electronics. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -30,7 +31,6 @@
#include "WKIconDatabase.h"
#include "WKIconDatabaseCairo.h"
#include "WKURL.h"
-#include "WebIconDatabase.h"
#include "ewk_favicon_database_private.h"
#include <WebCore/CairoUtilitiesEfl.h>
#include <WebCore/RefPtrCairo.h>
@@ -46,7 +46,6 @@
memset(&iconDatabaseClient, 0, sizeof(WKIconDatabaseClient));
iconDatabaseClient.version = kWKIconDatabaseClientCurrentVersion;
iconDatabaseClient.clientInfo = this;
- iconDatabaseClient.didChangeIconForPageURL = didChangeIconForPageURL;
iconDatabaseClient.iconDataReadyForPageURL = iconDataReadyForPageURL;
WKIconDatabaseSetIconDatabaseClient(m_iconDatabase.get(), &iconDatabaseClient);
}
@@ -56,14 +55,6 @@
WKIconDatabaseSetIconDatabaseClient(m_iconDatabase.get(), 0);
}
-String EwkFaviconDatabase::iconURLForPageURL(const String& pageURL) const
-{
- String iconURL;
- toImpl(m_iconDatabase.get())->synchronousIconURLForPageURL(pageURL, iconURL);
-
- return iconURL;
-}
-
void EwkFaviconDatabase::watchChanges(const IconChangeCallbackData& callbackData)
{
ASSERT(callbackData.callback);
@@ -79,55 +70,6 @@
m_changeListeners.remove(callback);
}
-struct AsyncIconRequestResponse {
- String pageURL;
- RefPtr<cairo_surface_t> surface;
- IconRequestCallbackData callbackData;
-
- AsyncIconRequestResponse(const String& pageURL, PassRefPtr<cairo_surface_t> surface, const IconRequestCallbackData& callbackData)
- : pageURL(pageURL)
- , surface(surface)
- , callbackData(callbackData)
- { }
-};
-
-static Eina_Bool respond_icon_request_idle(void* data)
-{
- AsyncIconRequestResponse* response = static_cast<AsyncIconRequestResponse*>(data);
-
- RefPtr<Evas_Object> icon = response->surface ? WebCore::evasObjectFromCairoImageSurface(response->callbackData.evas, response->surface.get()) : 0;
- response->callbackData.callback(response->pageURL.utf8().data(), icon.get(), response->callbackData.userData);
-
- delete response;
-
- return ECORE_CALLBACK_DONE;
-}
-
-void EwkFaviconDatabase::iconForPageURL(const char* pageURL, const IconRequestCallbackData& callbackData)
-{
- // We ask for the icon directly. If we don't get the icon data now,
- // we'll be notified later (even if the database is still importing icons).
- WKRetainPtr<WKURLRef> wkPageURL(AdoptWK, WKURLCreateWithUTF8CString(pageURL));
- RefPtr<cairo_surface_t> surface = getIconSurfaceSynchronously(wkPageURL.get());
-
- // If there's no valid icon, but there's an iconURL registered,
- // or it's still not registered but the import process hasn't
- // finished yet, we need to wait for iconDataReadyForPageURL to be
- // called before making and informed decision.
- String pageURLString = String::fromUTF8(pageURL);
- String iconURL = iconURLForPageURL(pageURLString);
- if (!surface && (!iconURL.isEmpty() || !toImpl(m_iconDatabase.get())->isUrlImportCompleted())) {
- PendingIconRequestVector requests = m_iconRequests.get(pageURLString);
- requests.append(callbackData);
- m_iconRequests.set(pageURLString, requests);
- return;
- }
-
- // Respond when idle.
- AsyncIconRequestResponse* response = new AsyncIconRequestResponse(pageURLString, surface.release(), callbackData);
- ecore_idler_add(respond_icon_request_idle, response);
-}
-
void EwkFaviconDatabase::didChangeIconForPageURL(WKIconDatabaseRef, WKURLRef pageURLRef, const void* clientInfo)
{
const EwkFaviconDatabase* ewkIconDatabase = static_cast<const EwkFaviconDatabase*>(clientInfo);
@@ -143,15 +85,13 @@
it->value.callback(pageURL.data(), it->value.userData);
}
-PassRefPtr<cairo_surface_t> EwkFaviconDatabase::getIconSurfaceSynchronously(WKURLRef pageURL) const
+PassRefPtr<cairo_surface_t> EwkFaviconDatabase::getIconSurfaceSynchronously(const char* pageURL) const
{
- WKIconDatabaseRetainIconForURL(m_iconDatabase.get(), pageURL);
+ WKRetainPtr<WKURLRef> wkPageURL(AdoptWK, WKURLCreateWithUTF8CString(pageURL));
- RefPtr<cairo_surface_t> surface = WKIconDatabaseTryGetCairoSurfaceForURL(m_iconDatabase.get(), pageURL);
- if (!surface) {
- WKIconDatabaseReleaseIconForURL(m_iconDatabase.get(), pageURL);
+ RefPtr<cairo_surface_t> surface = WKIconDatabaseTryGetCairoSurfaceForURL(m_iconDatabase.get(), wkPageURL.get());
+ if (!surface)
return 0;
- }
return surface.release();
}
@@ -160,43 +100,28 @@
{
EwkFaviconDatabase* ewkIconDatabase = const_cast<EwkFaviconDatabase*>(static_cast<const EwkFaviconDatabase*>(clientInfo));
- String urlString = toWTFString(pageURL);
- if (!ewkIconDatabase->m_iconRequests.contains(urlString))
- return;
+ WKIconDatabaseRetainIconForURL(ewkIconDatabase->m_iconDatabase.get(), pageURL);
- RefPtr<cairo_surface_t> surface = ewkIconDatabase->getIconSurfaceSynchronously(pageURL);
-
- PendingIconRequestVector requestsForURL = ewkIconDatabase->m_iconRequests.take(urlString);
- size_t requestCount = requestsForURL.size();
- for (size_t i = 0; i < requestCount; ++i) {
- const IconRequestCallbackData& callbackData = requestsForURL[i];
- RefPtr<Evas_Object> icon = surface ? WebCore::evasObjectFromCairoImageSurface(callbackData.evas, surface.get()) : 0;
- callbackData.callback(urlString.utf8().data(), icon.get(), callbackData.userData);
- }
+ CString urlString = toWTFString(pageURL).utf8();
+ ChangeListenerMap::const_iterator it = ewkIconDatabase->m_changeListeners.begin();
+ ChangeListenerMap::const_iterator end = ewkIconDatabase->m_changeListeners.end();
+ for (; it != end; ++it)
+ it->value.callback(urlString.data(), it->value.userData);
}
-const char* ewk_favicon_database_icon_url_get(Ewk_Favicon_Database* ewkIconDatabase, const char* pageURL)
+Evas_Object* ewk_favicon_database_icon_get(Ewk_Favicon_Database* ewkIconDatabase, const char* pageURL, Evas* evas)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(ewkIconDatabase, 0);
EINA_SAFETY_ON_NULL_RETURN_VAL(pageURL, 0);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(evas, 0);
- String iconURL = ewkIconDatabase->iconURLForPageURL(String::fromUTF8(pageURL));
+ RefPtr<cairo_surface_t> surface = ewkIconDatabase->getIconSurfaceSynchronously(pageURL);
+ if (!surface)
+ return 0;
- return eina_stringshare_add(iconURL.utf8().data());
+ return WebCore::evasObjectFromCairoImageSurface(evas, surface.get()).leakRef();
}
-Eina_Bool ewk_favicon_database_async_icon_get(Ewk_Favicon_Database* ewkIconDatabase, const char* page_url, Evas* evas, Ewk_Favicon_Database_Async_Icon_Get_Cb callback, void* userData)
-{
- EINA_SAFETY_ON_NULL_RETURN_VAL(ewkIconDatabase, false);
- EINA_SAFETY_ON_NULL_RETURN_VAL(page_url, false);
- EINA_SAFETY_ON_NULL_RETURN_VAL(evas, false);
- EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
-
- ewkIconDatabase->iconForPageURL(page_url, IconRequestCallbackData(callback, userData, evas));
-
- return true;
-}
-
void ewk_favicon_database_icon_change_callback_add(Ewk_Favicon_Database* ewkIconDatabase, Ewk_Favicon_Database_Icon_Change_Cb callback, void* userData)
{
EINA_SAFETY_ON_NULL_RETURN(ewkIconDatabase);
Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_favicon_database.h (143189 => 143190)
--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_favicon_database.h 2013-02-18 11:22:32 UTC (rev 143189)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_favicon_database.h 2013-02-18 11:24:35 UTC (rev 143190)
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2012 Intel Corporation. All rights reserved.
+ * Copyright (C) 2013 Samsung Electronics. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -47,40 +48,16 @@
typedef void (*Ewk_Favicon_Database_Icon_Change_Cb)(const char *page_url, void *event_info);
/**
- * @typedef Ewk_Favicon_Database_Async_Icon_Get_Cb Ewk_Favicon_Database_Async_Icon_Get_Cb
- * @brief Callback type for use with ewk_favicon_database_async_icon_get
+ * Retrieves from the database the favicon for the given @a page_url
*
- * The @a icon may be NULL if there is no favicon associated to the given @a page_url.
- *
- * You need to call evas_object_ref() on the @a icon if you wish to keep it after the
- * callback is executed.
- */
-typedef void (*Ewk_Favicon_Database_Async_Icon_Get_Cb)(const char *page_url, Evas_Object *icon, void *event_info);
-
-/**
- * Retrieves from the database the favicon URL for the given @a page_url
- *
* @param database database object to query
- * @param page_url URL of the page to get the favicon URL for
- *
- * @return a newly allocated string guaranteed to be eina_stringshare
- * or @c NULL in case of error or if the key does not exist.
- * You need to call eina_stringshare_del() after use.
- */
-EAPI const char *ewk_favicon_database_icon_url_get(Ewk_Favicon_Database *database, const char *page_url);
-
-/**
- * Retrieves asynchronously from the database the favicon for the given @a page_url
- *
- * @param database database object to query
* @param page_url URL of the page to get the favicon for
* @param evas The canvas to add the favicon to
- * @param callback callback function to be called when the icon is retrieved
- * @param data the data pointer that was to be passed to the callback
*
- * @return @c EINA_TRUE if the icon was successfuly requested, @c EINA_FALSE otherwise
+ * @return The favicon as an Evas_Object if successful, @c NULL otherwise.
+ * The returned Evas_Object needs to be freed after use.
*/
-EAPI Eina_Bool ewk_favicon_database_async_icon_get(Ewk_Favicon_Database *database, const char *page_url, Evas *evas, Ewk_Favicon_Database_Async_Icon_Get_Cb callback, void *data);
+EAPI Evas_Object *ewk_favicon_database_icon_get(Ewk_Favicon_Database *database, const char *page_url, Evas *evas);
/**
* Add (register) a callback function to a icon change event
Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_favicon_database_private.h (143189 => 143190)
--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_favicon_database_private.h 2013-02-18 11:22:32 UTC (rev 143189)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_favicon_database_private.h 2013-02-18 11:24:35 UTC (rev 143190)
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2012 Intel Corporation. All rights reserved.
+ * Copyright (C) 2013 Samsung Electronics. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -46,27 +47,7 @@
{ }
};
-struct IconRequestCallbackData {
- Ewk_Favicon_Database_Async_Icon_Get_Cb callback;
- void* userData;
- Evas* evas;
-
- IconRequestCallbackData()
- : callback(0)
- , userData(0)
- , evas(0)
- { }
-
- IconRequestCallbackData(Ewk_Favicon_Database_Async_Icon_Get_Cb _callback, void* _userData, Evas* _evas)
- : callback(_callback)
- , userData(_userData)
- , evas(_evas)
- { }
-};
-
typedef HashMap<Ewk_Favicon_Database_Icon_Change_Cb, IconChangeCallbackData> ChangeListenerMap;
-typedef Vector<IconRequestCallbackData> PendingIconRequestVector;
-typedef HashMap<String /* pageURL */, PendingIconRequestVector> PendingIconRequestMap;
class EwkFaviconDatabase {
public:
@@ -76,23 +57,18 @@
}
~EwkFaviconDatabase();
- String iconURLForPageURL(const String& pageURL) const;
- void iconForPageURL(const char* pageURL, const IconRequestCallbackData& callbackData);
-
+ PassRefPtr<cairo_surface_t> getIconSurfaceSynchronously(const char* pageURL) const;
void watchChanges(const IconChangeCallbackData& callbackData);
void unwatchChanges(Ewk_Favicon_Database_Icon_Change_Cb callback);
private:
explicit EwkFaviconDatabase(WKIconDatabaseRef iconDatabase);
- PassRefPtr<cairo_surface_t> getIconSurfaceSynchronously(WKURLRef pageURL) const;
-
static void didChangeIconForPageURL(WKIconDatabaseRef iconDatabase, WKURLRef pageURL, const void* clientInfo);
static void iconDataReadyForPageURL(WKIconDatabaseRef iconDatabase, WKURLRef pageURL, const void* clientInfo);
WKRetainPtr<WKIconDatabaseRef> m_iconDatabase;
ChangeListenerMap m_changeListeners;
- PendingIconRequestMap m_iconRequests;
};
#endif // ewk_favicon_database_private_h
Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp (143189 => 143190)
--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp 2013-02-18 11:22:32 UTC (rev 143189)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp 2013-02-18 11:24:35 UTC (rev 143190)
@@ -131,11 +131,11 @@
return impl->url();
}
-const char *ewk_view_icon_url_get(const Evas_Object *ewkView)
+Evas_Object* ewk_view_favicon_get(const Evas_Object* ewkView)
{
EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, 0);
- return impl->faviconURL();
+ return impl->createFavicon();
}
Eina_Bool ewk_view_reload(Evas_Object* ewkView)
Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.h (143189 => 143190)
--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.h 2013-02-18 11:22:32 UTC (rev 143189)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.h 2013-02-18 11:24:35 UTC (rev 143190)
@@ -48,7 +48,8 @@
* when done to continue with the form submission. If the last reference is removed on a
* #Ewk_Form_Submission_Request and the form has not been submitted yet,
* ewk_form_submission_request_submit() will be called automatically.
- * - "icon,changed", void: reports that the view's favicon has changed.
+ * - "favicon,changed", void: reports that the view's favicon has changed.
+ * The favicon can be queried using ewk_view_favicon_get().
* - "load,error", const Ewk_Error*: reports main frame load failed.
* - "load,finished", void: reports load finished.
* - "load,progress", double*: load progress has changed (value from 0.0 to 1.0).
@@ -372,16 +373,14 @@
EAPI const char *ewk_view_url_get(const Evas_Object *o);
/**
- * Returns the current icon URL of view object.
+ * Returns the current favicon of view object.
*
- * It returns an internal string and should not
- * be modified. The string is guaranteed to be stringshared.
- *
* @param o view object to get current icon URL
*
- * @return current icon URL on success or @c NULL if unavailable or on failure
+ * @return current favicon on success or @c NULL if unavailable or on failure.
+ * The returned Evas_Object needs to be freed after use.
*/
-EAPI const char *ewk_view_icon_url_get(const Evas_Object *o);
+EAPI Evas_Object *ewk_view_favicon_get(const Evas_Object *o);
/**
* Asks the main frame to reload the current document.
Modified: trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_favicon_database.cpp (143189 => 143190)
--- trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_favicon_database.cpp 2013-02-18 11:22:32 UTC (rev 143189)
+++ trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_favicon_database.cpp 2013-02-18 11:24:35 UTC (rev 143190)
@@ -75,54 +75,6 @@
soup_message_body_complete(message->response_body);
}
-static void onIconChanged(void* userData, Evas_Object*, void* eventInfo)
-{
- bool* iconChanged = static_cast<bool*>(userData);
- *iconChanged = true;
-}
-
-TEST_F(EWK2UnitTestBase, ewk_favicon_database_url_get)
-{
- OwnPtr<EWK2UnitTestServer> httpServer = adoptPtr(new EWK2UnitTestServer);
- httpServer->run(serverCallback);
-
- // Set favicon database path and enable functionality.
- Ewk_Context* context = ewk_view_context_get(webView());
- ewk_context_favicon_database_directory_set(context, 0);
-
- bool iconChanged = false;
- evas_object_smart_callback_add(webView(), "icon,changed", onIconChanged, &iconChanged);
-
- // We need to load the page first to ensure the icon data will be
- // in the database in case there's an associated favicon.
- ASSERT_TRUE(loadUrlSync(httpServer->getURLForPath("/").data()));
-
- while (!iconChanged)
- ecore_main_loop_iterate();
-
- ASSERT_TRUE(iconChanged);
- evas_object_smart_callback_del(webView(), "icon,changed", onIconChanged);
-
- // Check the API retrieving a favicon URL.
- Ewk_Favicon_Database* faviconDatabase = ewk_context_favicon_database_get(context);
- ASSERT_TRUE(faviconDatabase);
-
- CString expectedFaviconURL = httpServer->getURLForPath("/favicon.ico");
- WKEinaSharedString iconURL = ewk_favicon_database_icon_url_get(faviconDatabase, ewk_view_url_get(webView()));
- EXPECT_STREQ(expectedFaviconURL.data(), iconURL);
-
- const char* viewIconURL = ewk_view_icon_url_get(webView());
- EXPECT_STREQ(expectedFaviconURL.data(), viewIconURL);
-}
-
-static void onIconDataReady(const char* page_url, Evas_Object* icon, void* event_info)
-{
- Evas_Object** returnIcon = static_cast<Evas_Object**>(event_info);
- if (icon)
- evas_object_ref(icon);
- *returnIcon = icon;
-}
-
struct IconRequestData {
Evas_Object* view;
Evas_Object* icon;
@@ -132,13 +84,13 @@
{
IconRequestData* data = ""
- // Check the API retrieving a valid favicon.
+ // Check the API retrieving a valid favicon from icon database.
Ewk_Context* context = ewk_view_context_get(data->view);
Ewk_Favicon_Database* faviconDatabase = ewk_context_favicon_database_get(context);
ASSERT_TRUE(faviconDatabase);
Evas* evas = evas_object_evas_get(data->view);
- ASSERT_TRUE(ewk_favicon_database_async_icon_get(faviconDatabase, ewk_view_url_get(data->view), evas, onIconDataReady, &data->icon));
+ data->icon = ewk_favicon_database_icon_get(faviconDatabase, ewk_view_url_get(data->view), evas);
}
TEST_F(EWK2UnitTestBase, ewk_favicon_database_async_icon_get)
@@ -151,7 +103,7 @@
ewk_context_favicon_database_directory_set(context, 0);
IconRequestData data = { webView(), 0 };
- evas_object_smart_callback_add(webView(), "icon,changed", requestFaviconData, &data);
+ evas_object_smart_callback_add(webView(), "favicon,changed", requestFaviconData, &data);
// We need to load the page first to ensure the icon data will be
// in the database in case there's an associated favicon.
@@ -161,13 +113,20 @@
ecore_main_loop_iterate();
ASSERT_TRUE(data.icon);
- evas_object_smart_callback_del(webView(), "icon,changed", requestFaviconData);
+ evas_object_smart_callback_del(webView(), "favicon,changed", requestFaviconData);
// It is a 16x16 favicon.
int width, height;
evas_object_image_size_get(data.icon, &width, &height);
EXPECT_EQ(16, width);
EXPECT_EQ(16, height);
-
evas_object_unref(data.icon);
+
+ // Test API to request favicon from the view
+ Evas_Object* favicon = ewk_view_favicon_get(webView());
+ ASSERT_TRUE(favicon);
+ evas_object_image_size_get(favicon, &width, &height);
+ EXPECT_EQ(16, width);
+ EXPECT_EQ(16, height);
+ evas_object_unref(favicon);
}
Modified: trunk/Tools/ChangeLog (143189 => 143190)
--- trunk/Tools/ChangeLog 2013-02-18 11:22:32 UTC (rev 143189)
+++ trunk/Tools/ChangeLog 2013-02-18 11:24:35 UTC (rev 143190)
@@ -1,3 +1,17 @@
+2013-02-18 Christophe Dumez <[email protected]>
+
+ [EFL][WK2] Refactor Ewk_Favicon code and stop relying on internal C++ API
+ https://bugs.webkit.org/show_bug.cgi?id=108598
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ Update EFL's MiniBrowser to make use of new Ewk_Favicon API.
+
+ * MiniBrowser/efl/main.c:
+ (update_view_favicon):
+ (on_view_favicon_changed):
+ (window_create):
+
2013-02-18 Zoltan Arvai <[email protected]>
Unreviewed. Add myself as a committer.
Modified: trunk/Tools/MiniBrowser/efl/main.c (143189 => 143190)
--- trunk/Tools/MiniBrowser/efl/main.c 2013-02-18 11:22:32 UTC (rev 143189)
+++ trunk/Tools/MiniBrowser/efl/main.c 2013-02-18 11:24:35 UTC (rev 143190)
@@ -539,12 +539,8 @@
}
static void
-on_favicon_received(const char *page_url, Evas_Object *icon, void *event_info)
+update_view_favicon(Browser_Window *window, Evas_Object *icon)
{
- Browser_Window *window = (Browser_Window *)event_info;
- if (strcmp(page_url, ewk_view_url_get(window->ewk_view)))
- return;
-
/* Remove previous icon from URL bar */
Evas_Object *old_icon = elm_object_part_content_unset(window->url_bar, "icon");
if (old_icon) {
@@ -565,16 +561,15 @@
}
static void
-on_view_icon_changed(void *user_data, Evas_Object *ewk_view, void *event_info)
+on_view_favicon_changed(void *user_data, Evas_Object *ewk_view, void *event_info)
{
Browser_Window *window = (Browser_Window *)user_data;
- /* Retrieve the view's favicon */
- Ewk_Context *context = ewk_view_context_get(ewk_view);
- Ewk_Favicon_Database *icon_database = ewk_context_favicon_database_get(context);
- const char *page_url = ewk_view_url_get(ewk_view);
- Evas *evas = evas_object_evas_get(ewk_view);
- ewk_favicon_database_async_icon_get(icon_database, page_url, evas, on_favicon_received, window);
+ Evas_Object* favicon = ewk_view_favicon_get(ewk_view);
+ update_view_favicon(window, favicon);
+
+ if (favicon)
+ evas_object_unref(favicon);
}
static int
@@ -1218,7 +1213,7 @@
evas_object_smart_callback_add(window->ewk_view, "download,finished", on_download_finished, window);
evas_object_smart_callback_add(window->ewk_view, "download,request", on_download_request, window);
evas_object_smart_callback_add(window->ewk_view, "file,chooser,request", on_file_chooser_request, window);
- evas_object_smart_callback_add(window->ewk_view, "icon,changed", on_view_icon_changed, window);
+ evas_object_smart_callback_add(window->ewk_view, "favicon,changed", on_view_favicon_changed, window);
evas_object_smart_callback_add(window->ewk_view, "load,error", on_error, window);
evas_object_smart_callback_add(window->ewk_view, "load,progress", on_progress, window);
evas_object_smart_callback_add(window->ewk_view, "title,changed", on_title_changed, window);