Changeset 143190 in webkit


Ignore:
Timestamp:
Feb 18, 2013 3:24:35 AM (11 years ago)
Author:
Christophe Dumez
Message:

[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.

Source/WebKit2:

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.

Tools:

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):

Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r143146 r143190  
     12013-02-18  Christophe Dumez  <ch.dumez@sisa.samsung.com>
     2
     3        [EFL][WK2] Refactor Ewk_Favicon code and stop relying on internal C++ API
     4        https://bugs.webkit.org/show_bug.cgi?id=108598
     5
     6        Reviewed by Kenneth Rohde Christiansen.
     7
     8        Refactor the Ewk_Favicon code so that it no longer relies on internal
     9        C++ API and so that it is based solely on the C API. The API is changed
     10        a little as well so that the Favicon URL is no longer exposed to the
     11        client. Also the client is now only notified of icon changes once the
     12        favicon data is actually available.
     13
     14        The API is covered by existing API tests and by MiniBrowser which are
     15        both updated accordingly in this patch.
     16
     17        * UIProcess/API/efl/EwkView.cpp:
     18        (EwkView::informURLChange):
     19        (EwkView::createFavicon):
     20        (EwkView::onFaviconChanged):
     21        * UIProcess/API/efl/EwkView.h:
     22        (EwkView):
     23        * UIProcess/API/efl/EwkViewCallbacks.h:
     24        * UIProcess/API/efl/ewk_favicon_database.cpp:
     25        Client are now notified of favicon changes only when the favicon data
     26        becomes available and make API to retrieve a favicon synchronous. NULL
     27        is returned if the favicon data is not available.
     28
     29        (EwkFaviconDatabase::EwkFaviconDatabase):
     30        (EwkFaviconDatabase::getIconSurfaceSynchronously):
     31        (EwkFaviconDatabase::iconDataReadyForPageURL):
     32        (ewk_favicon_database_icon_get):
     33        * UIProcess/API/efl/ewk_favicon_database.h:
     34        * UIProcess/API/efl/ewk_favicon_database_private.h:
     35        (EwkFaviconDatabase):
     36        * UIProcess/API/efl/ewk_view.cpp:
     37        (ewk_view_favicon_get):
     38        * UIProcess/API/efl/ewk_view.h:
     39        Rename 'icon,changed' signal to 'favicon,changed' for clarity and
     40        consistency with the rest of the favicon API. Remove API to retrieve
     41        the favicon URL and replace it by one to retrieve the favicon image as
     42        an Evas_Object instead.
     43
     44        * UIProcess/API/efl/tests/test_ewk2_favicon_database.cpp:
     45        Update API tests to use the new favicon API.
     46
    1472013-02-17  Jae Hyun Park  <jae.park@company100.net>
    248
  • trunk/Source/WebKit2/UIProcess/API/efl/EwkView.cpp

    r143007 r143190  
    780780#endif
    781781
    782 /**
    783  * @internal
    784  * Update the view's favicon and emits a "icon,changed" signal if it has
    785  * changed.
    786  *
    787  * This function is called whenever the URL has changed or when the icon for
    788  * the current page URL has changed.
    789  */
    790 void EwkView::informIconChange()
    791 {
    792     EwkFaviconDatabase* iconDatabase = m_context->faviconDatabase();
    793     ASSERT(iconDatabase);
    794 
    795     m_faviconURL = ewk_favicon_database_icon_url_get(iconDatabase, m_url);
    796     smartCallback<IconChanged>().call();
    797 }
    798 
    799782bool EwkView::createGLSurface()
    800783{
     
    10451028
    10461029    // Update the view's favicon.
    1047     informIconChange();
     1030    smartCallback<FaviconChanged>().call();
     1031}
     1032
     1033Evas_Object* EwkView::createFavicon() const
     1034{
     1035    EwkFaviconDatabase* iconDatabase = m_context->faviconDatabase();
     1036    ASSERT(iconDatabase);
     1037
     1038    return ewk_favicon_database_icon_get(iconDatabase, m_url, smartData()->base.evas);
    10481039}
    10491040
     
    13391330        return;
    13401331
    1341     view->informIconChange();
     1332    view->smartCallback<FaviconChanged>().call();
    13421333}
    13431334
  • trunk/Source/WebKit2/UIProcess/API/efl/EwkView.h

    r143007 r143190  
    147147
    148148    const char* url() const { return m_url; }
    149     const char* faviconURL() const { return m_faviconURL; }
     149    Evas_Object* createFavicon() const;
    150150    const char* title() const;
    151151    WebKit::InputMethodContextEfl* inputMethodContext();
     
    232232
    233233    WebCore::CoordinatedGraphicsScene* coordinatedGraphicsScene();
    234 
    235     void informIconChange();
    236234
    237235    // Evas_Smart_Class callback interface:
     
    290288    RefPtr<EwkWindowFeatures> m_windowFeatures;
    291289    const void* m_cursorIdentifier; // This is an address, do not free it.
    292     WKEinaSharedString m_faviconURL;
    293290    WKEinaSharedString m_url;
    294291    mutable WKEinaSharedString m_title;
  • trunk/Source/WebKit2/UIProcess/API/efl/EwkViewCallbacks.h

    r142750 r143190  
    5555    FileChooserRequest,
    5656    NewFormSubmissionRequest,
    57     IconChanged,
     57    FaviconChanged,
    5858    LoadError,
    5959    LoadFinished,
     
    165165DECLARE_EWK_VIEW_CALLBACK(FileChooserRequest, "file,chooser,request", Ewk_File_Chooser_Request*);
    166166DECLARE_EWK_VIEW_CALLBACK(NewFormSubmissionRequest, "form,submission,request", Ewk_Form_Submission_Request*);
    167 DECLARE_EWK_VIEW_CALLBACK(IconChanged, "icon,changed", void);
     167DECLARE_EWK_VIEW_CALLBACK(FaviconChanged, "favicon,changed", void);
    168168DECLARE_EWK_VIEW_CALLBACK(LoadError, "load,error", Ewk_Error*);
    169169DECLARE_EWK_VIEW_CALLBACK(LoadFinished, "load,finished", void);
  • trunk/Source/WebKit2/UIProcess/API/efl/ewk_favicon_database.cpp

    r140952 r143190  
    11/*
    22 * Copyright (C) 2012 Intel Corporation. All rights reserved.
     3 * Copyright (C) 2013 Samsung Electronics. All rights reserved.
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    3132#include "WKIconDatabaseCairo.h"
    3233#include "WKURL.h"
    33 #include "WebIconDatabase.h"
    3434#include "ewk_favicon_database_private.h"
    3535#include <WebCore/CairoUtilitiesEfl.h>
     
    4747    iconDatabaseClient.version = kWKIconDatabaseClientCurrentVersion;
    4848    iconDatabaseClient.clientInfo = this;
    49     iconDatabaseClient.didChangeIconForPageURL = didChangeIconForPageURL;
    5049    iconDatabaseClient.iconDataReadyForPageURL = iconDataReadyForPageURL;
    5150    WKIconDatabaseSetIconDatabaseClient(m_iconDatabase.get(), &iconDatabaseClient);
     
    5554{
    5655    WKIconDatabaseSetIconDatabaseClient(m_iconDatabase.get(), 0);
    57 }
    58 
    59 String EwkFaviconDatabase::iconURLForPageURL(const String& pageURL) const
    60 {
    61     String iconURL;
    62     toImpl(m_iconDatabase.get())->synchronousIconURLForPageURL(pageURL, iconURL);
    63 
    64     return iconURL;
    6556}
    6657
     
    8071}
    8172
    82 struct AsyncIconRequestResponse {
    83     String pageURL;
    84     RefPtr<cairo_surface_t> surface;
    85     IconRequestCallbackData callbackData;
    86 
    87     AsyncIconRequestResponse(const String& pageURL, PassRefPtr<cairo_surface_t> surface, const IconRequestCallbackData& callbackData)
    88         : pageURL(pageURL)
    89         , surface(surface)
    90         , callbackData(callbackData)
    91     { }
    92 };
    93 
    94 static Eina_Bool respond_icon_request_idle(void* data)
    95 {
    96     AsyncIconRequestResponse* response = static_cast<AsyncIconRequestResponse*>(data);
    97 
    98     RefPtr<Evas_Object> icon = response->surface ? WebCore::evasObjectFromCairoImageSurface(response->callbackData.evas, response->surface.get()) : 0;
    99     response->callbackData.callback(response->pageURL.utf8().data(), icon.get(), response->callbackData.userData);
    100 
    101     delete response;
    102 
    103     return ECORE_CALLBACK_DONE;
    104 }
    105 
    106 void EwkFaviconDatabase::iconForPageURL(const char* pageURL, const IconRequestCallbackData& callbackData)
    107 {
    108     // We ask for the icon directly. If we don't get the icon data now,
    109     // we'll be notified later (even if the database is still importing icons).
    110     WKRetainPtr<WKURLRef> wkPageURL(AdoptWK, WKURLCreateWithUTF8CString(pageURL));
    111     RefPtr<cairo_surface_t> surface = getIconSurfaceSynchronously(wkPageURL.get());
    112 
    113     // If there's no valid icon, but there's an iconURL registered,
    114     // or it's still not registered but the import process hasn't
    115     // finished yet, we need to wait for iconDataReadyForPageURL to be
    116     // called before making and informed decision.
    117     String pageURLString = String::fromUTF8(pageURL);
    118     String iconURL = iconURLForPageURL(pageURLString);
    119     if (!surface && (!iconURL.isEmpty() || !toImpl(m_iconDatabase.get())->isUrlImportCompleted())) {
    120         PendingIconRequestVector requests = m_iconRequests.get(pageURLString);
    121         requests.append(callbackData);
    122         m_iconRequests.set(pageURLString, requests);
    123         return;
    124     }
    125 
    126     // Respond when idle.
    127     AsyncIconRequestResponse* response = new AsyncIconRequestResponse(pageURLString, surface.release(), callbackData);
    128     ecore_idler_add(respond_icon_request_idle, response);
    129 }
    130 
    13173void EwkFaviconDatabase::didChangeIconForPageURL(WKIconDatabaseRef, WKURLRef pageURLRef, const void* clientInfo)
    13274{
     
    14486}
    14587
    146 PassRefPtr<cairo_surface_t> EwkFaviconDatabase::getIconSurfaceSynchronously(WKURLRef pageURL) const
     88PassRefPtr<cairo_surface_t> EwkFaviconDatabase::getIconSurfaceSynchronously(const char* pageURL) const
    14789{
    148     WKIconDatabaseRetainIconForURL(m_iconDatabase.get(), pageURL);
     90    WKRetainPtr<WKURLRef> wkPageURL(AdoptWK, WKURLCreateWithUTF8CString(pageURL));
    14991
    150     RefPtr<cairo_surface_t> surface = WKIconDatabaseTryGetCairoSurfaceForURL(m_iconDatabase.get(), pageURL);
    151     if (!surface) {
    152         WKIconDatabaseReleaseIconForURL(m_iconDatabase.get(), pageURL);
     92    RefPtr<cairo_surface_t> surface = WKIconDatabaseTryGetCairoSurfaceForURL(m_iconDatabase.get(), wkPageURL.get());
     93    if (!surface)
    15394        return 0;
    154     }
    15595
    15696    return surface.release();
     
    161101    EwkFaviconDatabase* ewkIconDatabase = const_cast<EwkFaviconDatabase*>(static_cast<const EwkFaviconDatabase*>(clientInfo));
    162102
    163     String urlString = toWTFString(pageURL);
    164     if (!ewkIconDatabase->m_iconRequests.contains(urlString))
    165         return;
     103    WKIconDatabaseRetainIconForURL(ewkIconDatabase->m_iconDatabase.get(), pageURL);
    166104
    167     RefPtr<cairo_surface_t> surface = ewkIconDatabase->getIconSurfaceSynchronously(pageURL);
    168 
    169     PendingIconRequestVector requestsForURL = ewkIconDatabase->m_iconRequests.take(urlString);
    170     size_t requestCount = requestsForURL.size();
    171     for (size_t i = 0; i < requestCount; ++i) {
    172         const IconRequestCallbackData& callbackData = requestsForURL[i];
    173         RefPtr<Evas_Object> icon = surface ? WebCore::evasObjectFromCairoImageSurface(callbackData.evas, surface.get()) : 0;
    174         callbackData.callback(urlString.utf8().data(), icon.get(), callbackData.userData);
    175     }
     105    CString urlString = toWTFString(pageURL).utf8();
     106    ChangeListenerMap::const_iterator it = ewkIconDatabase->m_changeListeners.begin();
     107    ChangeListenerMap::const_iterator end = ewkIconDatabase->m_changeListeners.end();
     108    for (; it != end; ++it)
     109        it->value.callback(urlString.data(), it->value.userData);
    176110}
    177111
    178 const char* ewk_favicon_database_icon_url_get(Ewk_Favicon_Database* ewkIconDatabase, const char* pageURL)
     112Evas_Object* ewk_favicon_database_icon_get(Ewk_Favicon_Database* ewkIconDatabase, const char* pageURL, Evas* evas)
    179113{
    180114    EINA_SAFETY_ON_NULL_RETURN_VAL(ewkIconDatabase, 0);
    181115    EINA_SAFETY_ON_NULL_RETURN_VAL(pageURL, 0);
     116    EINA_SAFETY_ON_NULL_RETURN_VAL(evas, 0);
    182117
    183     String iconURL = ewkIconDatabase->iconURLForPageURL(String::fromUTF8(pageURL));
     118    RefPtr<cairo_surface_t> surface = ewkIconDatabase->getIconSurfaceSynchronously(pageURL);
     119    if (!surface)
     120        return 0;
    184121
    185     return eina_stringshare_add(iconURL.utf8().data());
    186 }
    187 
    188 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)
    189 {
    190     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkIconDatabase, false);
    191     EINA_SAFETY_ON_NULL_RETURN_VAL(page_url, false);
    192     EINA_SAFETY_ON_NULL_RETURN_VAL(evas, false);
    193     EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
    194 
    195     ewkIconDatabase->iconForPageURL(page_url, IconRequestCallbackData(callback, userData, evas));
    196 
    197     return true;
     122    return WebCore::evasObjectFromCairoImageSurface(evas, surface.get()).leakRef();
    198123}
    199124
  • trunk/Source/WebKit2/UIProcess/API/efl/ewk_favicon_database.h

    r135117 r143190  
    11/*
    22 * Copyright (C) 2012 Intel Corporation. All rights reserved.
     3 * Copyright (C) 2013 Samsung Electronics. All rights reserved.
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    4849
    4950/**
    50  * @typedef Ewk_Favicon_Database_Async_Icon_Get_Cb Ewk_Favicon_Database_Async_Icon_Get_Cb
    51  * @brief Callback type for use with ewk_favicon_database_async_icon_get
    52  *
    53  * The @a icon may be NULL if there is no favicon associated to the given @a page_url.
    54  *
    55  * You need to call evas_object_ref() on the @a icon if you wish to keep it after the
    56  * callback is executed.
    57  */
    58 typedef void (*Ewk_Favicon_Database_Async_Icon_Get_Cb)(const char *page_url, Evas_Object *icon, void *event_info);
    59 
    60 /**
    61  * Retrieves from the database the favicon URL for the given @a page_url
    62  *
    63  * @param database database object to query
    64  * @param page_url URL of the page to get the favicon URL for
    65  *
    66  * @return a newly allocated string guaranteed to be eina_stringshare
    67  *         or @c NULL in case of error or if the key does not exist.
    68  *         You need to call eina_stringshare_del() after use.
    69  */
    70 EAPI const char *ewk_favicon_database_icon_url_get(Ewk_Favicon_Database *database, const char *page_url);
    71 
    72 /**
    73  * Retrieves asynchronously from the database the favicon for the given @a page_url
     51 * Retrieves from the database the favicon for the given @a page_url
    7452 *
    7553 * @param database database object to query
    7654 * @param page_url URL of the page to get the favicon for
    7755 * @param evas The canvas to add the favicon to
    78  * @param callback callback function to be called when the icon is retrieved
    79  * @param data the data pointer that was to be passed to the callback
    8056 *
    81  * @return @c EINA_TRUE if the icon was successfuly requested, @c EINA_FALSE otherwise
     57 * @return The favicon as an Evas_Object if successful, @c NULL otherwise.
     58 * The returned Evas_Object needs to be freed after use.
    8259 */
    83 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);
     60EAPI Evas_Object *ewk_favicon_database_icon_get(Ewk_Favicon_Database *database, const char *page_url, Evas *evas);
    8461
    8562/**
  • trunk/Source/WebKit2/UIProcess/API/efl/ewk_favicon_database_private.h

    r140692 r143190  
    11/*
    22 * Copyright (C) 2012 Intel Corporation. All rights reserved.
     3 * Copyright (C) 2013 Samsung Electronics. All rights reserved.
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    4748};
    4849
    49 struct IconRequestCallbackData {
    50     Ewk_Favicon_Database_Async_Icon_Get_Cb callback;
    51     void* userData;
    52     Evas* evas;
    53 
    54     IconRequestCallbackData()
    55         : callback(0)
    56         , userData(0)
    57         , evas(0)
    58     { }
    59 
    60     IconRequestCallbackData(Ewk_Favicon_Database_Async_Icon_Get_Cb _callback, void* _userData, Evas* _evas)
    61         : callback(_callback)
    62         , userData(_userData)
    63         , evas(_evas)
    64     { }
    65 };
    66 
    6750typedef HashMap<Ewk_Favicon_Database_Icon_Change_Cb, IconChangeCallbackData> ChangeListenerMap;
    68 typedef Vector<IconRequestCallbackData> PendingIconRequestVector;
    69 typedef HashMap<String /* pageURL */, PendingIconRequestVector> PendingIconRequestMap;
    7051
    7152class EwkFaviconDatabase {
     
    7758    ~EwkFaviconDatabase();
    7859
    79     String iconURLForPageURL(const String& pageURL) const;
    80     void iconForPageURL(const char* pageURL, const IconRequestCallbackData& callbackData);
    81 
     60    PassRefPtr<cairo_surface_t> getIconSurfaceSynchronously(const char* pageURL) const;
    8261    void watchChanges(const IconChangeCallbackData& callbackData);
    8362    void unwatchChanges(Ewk_Favicon_Database_Icon_Change_Cb callback);
     
    8665    explicit EwkFaviconDatabase(WKIconDatabaseRef iconDatabase);
    8766
    88     PassRefPtr<cairo_surface_t> getIconSurfaceSynchronously(WKURLRef pageURL) const;
    89 
    9067    static void didChangeIconForPageURL(WKIconDatabaseRef iconDatabase, WKURLRef pageURL, const void* clientInfo);
    9168    static void iconDataReadyForPageURL(WKIconDatabaseRef iconDatabase, WKURLRef pageURL, const void* clientInfo);
     
    9370    WKRetainPtr<WKIconDatabaseRef> m_iconDatabase;
    9471    ChangeListenerMap m_changeListeners;
    95     PendingIconRequestMap m_iconRequests;
    9672};
    9773
  • trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp

    r143007 r143190  
    132132}
    133133
    134 const char *ewk_view_icon_url_get(const Evas_Object *ewkView)
    135 {
    136     EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, 0);
    137 
    138     return impl->faviconURL();
     134Evas_Object* ewk_view_favicon_get(const Evas_Object* ewkView)
     135{
     136    EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, 0);
     137
     138    return impl->createFavicon();
    139139}
    140140
  • trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.h

    r141439 r143190  
    4949 *   #Ewk_Form_Submission_Request and the form has not been submitted yet,
    5050 *   ewk_form_submission_request_submit() will be called automatically.
    51  * - "icon,changed", void: reports that the view's favicon has changed.
     51 * - "favicon,changed", void: reports that the view's favicon has changed.
     52 *   The favicon can be queried using ewk_view_favicon_get().
    5253 * - "load,error", const Ewk_Error*: reports main frame load failed.
    5354 * - "load,finished", void: reports load finished.
     
    373374
    374375/**
    375  * Returns the current icon URL of view object.
    376  *
    377  * It returns an internal string and should not
    378  * be modified. The string is guaranteed to be stringshared.
     376 * Returns the current favicon of view object.
    379377 *
    380378 * @param o view object to get current icon URL
    381379 *
    382  * @return current icon URL on success or @c NULL if unavailable or on failure
    383  */
    384 EAPI const char *ewk_view_icon_url_get(const Evas_Object *o);
     380 * @return current favicon on success or @c NULL if unavailable or on failure.
     381 * The returned Evas_Object needs to be freed after use.
     382 */
     383EAPI Evas_Object *ewk_view_favicon_get(const Evas_Object *o);
    385384
    386385/**
  • trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_favicon_database.cpp

    r135349 r143190  
    7676}
    7777
    78 static void onIconChanged(void* userData, Evas_Object*, void* eventInfo)
    79 {
    80     bool* iconChanged = static_cast<bool*>(userData);
    81     *iconChanged = true;
    82 }
    83 
    84 TEST_F(EWK2UnitTestBase, ewk_favicon_database_url_get)
    85 {
    86     OwnPtr<EWK2UnitTestServer> httpServer = adoptPtr(new EWK2UnitTestServer);
    87     httpServer->run(serverCallback);
    88 
    89     // Set favicon database path and enable functionality.
    90     Ewk_Context* context = ewk_view_context_get(webView());
    91     ewk_context_favicon_database_directory_set(context, 0);
    92 
    93     bool iconChanged = false;
    94     evas_object_smart_callback_add(webView(), "icon,changed", onIconChanged, &iconChanged);
    95 
    96     // We need to load the page first to ensure the icon data will be
    97     // in the database in case there's an associated favicon.
    98     ASSERT_TRUE(loadUrlSync(httpServer->getURLForPath("/").data()));
    99 
    100     while (!iconChanged)
    101         ecore_main_loop_iterate();
    102 
    103     ASSERT_TRUE(iconChanged);
    104     evas_object_smart_callback_del(webView(), "icon,changed", onIconChanged);
    105 
    106     // Check the API retrieving a favicon URL.
    107     Ewk_Favicon_Database* faviconDatabase = ewk_context_favicon_database_get(context);
    108     ASSERT_TRUE(faviconDatabase);
    109 
    110     CString expectedFaviconURL = httpServer->getURLForPath("/favicon.ico");
    111     WKEinaSharedString iconURL = ewk_favicon_database_icon_url_get(faviconDatabase, ewk_view_url_get(webView()));
    112     EXPECT_STREQ(expectedFaviconURL.data(), iconURL);
    113 
    114     const char* viewIconURL = ewk_view_icon_url_get(webView());
    115     EXPECT_STREQ(expectedFaviconURL.data(), viewIconURL);
    116 }
    117 
    118 static void onIconDataReady(const char* page_url, Evas_Object* icon, void* event_info)
    119 {
    120     Evas_Object** returnIcon = static_cast<Evas_Object**>(event_info);
    121     if (icon)
    122         evas_object_ref(icon);
    123     *returnIcon = icon;
    124 }
    125 
    12678struct IconRequestData {
    12779    Evas_Object* view;
     
    13385    IconRequestData* data = static_cast<IconRequestData*>(userData);
    13486
    135     // Check the API retrieving a valid favicon.
     87    // Check the API retrieving a valid favicon from icon database.
    13688    Ewk_Context* context = ewk_view_context_get(data->view);
    13789    Ewk_Favicon_Database* faviconDatabase = ewk_context_favicon_database_get(context);
     
    13991
    14092    Evas* evas = evas_object_evas_get(data->view);
    141     ASSERT_TRUE(ewk_favicon_database_async_icon_get(faviconDatabase, ewk_view_url_get(data->view), evas, onIconDataReady, &data->icon));
     93    data->icon = ewk_favicon_database_icon_get(faviconDatabase, ewk_view_url_get(data->view), evas);
    14294}
    14395
     
    152104
    153105    IconRequestData data = { webView(), 0 };
    154     evas_object_smart_callback_add(webView(), "icon,changed", requestFaviconData, &data);
     106    evas_object_smart_callback_add(webView(), "favicon,changed", requestFaviconData, &data);
    155107
    156108    // We need to load the page first to ensure the icon data will be
     
    162114
    163115    ASSERT_TRUE(data.icon);
    164     evas_object_smart_callback_del(webView(), "icon,changed", requestFaviconData);
     116    evas_object_smart_callback_del(webView(), "favicon,changed", requestFaviconData);
    165117
    166118    // It is a 16x16 favicon.
     
    169121    EXPECT_EQ(16, width);
    170122    EXPECT_EQ(16, height);
     123    evas_object_unref(data.icon);
    171124
    172     evas_object_unref(data.icon);
     125    // Test API to request favicon from the view
     126    Evas_Object* favicon = ewk_view_favicon_get(webView());
     127    ASSERT_TRUE(favicon);
     128    evas_object_image_size_get(favicon, &width, &height);
     129    EXPECT_EQ(16, width);
     130    EXPECT_EQ(16, height);
     131    evas_object_unref(favicon);
    173132}
  • trunk/Tools/ChangeLog

    r143176 r143190  
     12013-02-18  Christophe Dumez  <ch.dumez@sisa.samsung.com>
     2
     3        [EFL][WK2] Refactor Ewk_Favicon code and stop relying on internal C++ API
     4        https://bugs.webkit.org/show_bug.cgi?id=108598
     5
     6        Reviewed by Kenneth Rohde Christiansen.
     7
     8        Update EFL's MiniBrowser to make use of new Ewk_Favicon API.
     9
     10        * MiniBrowser/efl/main.c:
     11        (update_view_favicon):
     12        (on_view_favicon_changed):
     13        (window_create):
     14
    1152013-02-18  Zoltan Arvai  <zarvai@inf.u-szeged.hu>
    216
  • trunk/Tools/MiniBrowser/efl/main.c

    r142252 r143190  
    540540
    541541static void
    542 on_favicon_received(const char *page_url, Evas_Object *icon, void *event_info)
    543 {
    544     Browser_Window *window = (Browser_Window *)event_info;
    545     if (strcmp(page_url, ewk_view_url_get(window->ewk_view)))
    546         return;
    547 
     542update_view_favicon(Browser_Window *window, Evas_Object *icon)
     543{
    548544    /* Remove previous icon from URL bar */
    549545    Evas_Object *old_icon = elm_object_part_content_unset(window->url_bar, "icon");
     
    566562
    567563static void
    568 on_view_icon_changed(void *user_data, Evas_Object *ewk_view, void *event_info)
    569 {
    570     Browser_Window *window = (Browser_Window *)user_data;
    571     /* Retrieve the view's favicon */
    572     Ewk_Context *context = ewk_view_context_get(ewk_view);
    573     Ewk_Favicon_Database *icon_database = ewk_context_favicon_database_get(context);
    574 
    575     const char *page_url = ewk_view_url_get(ewk_view);
    576     Evas *evas = evas_object_evas_get(ewk_view);
    577     ewk_favicon_database_async_icon_get(icon_database, page_url, evas, on_favicon_received, window);
     564on_view_favicon_changed(void *user_data, Evas_Object *ewk_view, void *event_info)
     565{
     566    Browser_Window *window = (Browser_Window *)user_data;
     567
     568    Evas_Object* favicon = ewk_view_favicon_get(ewk_view);
     569    update_view_favicon(window, favicon);
     570
     571    if (favicon)
     572        evas_object_unref(favicon);
    578573}
    579574
     
    12191214    evas_object_smart_callback_add(window->ewk_view, "download,request", on_download_request, window);
    12201215    evas_object_smart_callback_add(window->ewk_view, "file,chooser,request", on_file_chooser_request, window);
    1221     evas_object_smart_callback_add(window->ewk_view, "icon,changed", on_view_icon_changed, window);
     1216    evas_object_smart_callback_add(window->ewk_view, "favicon,changed", on_view_favicon_changed, window);
    12221217    evas_object_smart_callback_add(window->ewk_view, "load,error", on_error, window);
    12231218    evas_object_smart_callback_add(window->ewk_view, "load,progress", on_progress, window);
Note: See TracChangeset for help on using the changeset viewer.