⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 120442 in webkit


Ignore:
Timestamp:
Jun 15, 2012, 5:16:55 AM (14 years ago)
Author:
commit-queue@webkit.org
Message:

[EFL][WK2] Add title support to Ewk_View
https://bugs.webkit.org/show_bug.cgi?id=89095

Patch by Christophe Dumez <Christophe Dumez> on 2012-06-15
Reviewed by Kenneth Rohde Christiansen.

Source/WebKit2:

Add a method to get the title of the main frame in
an Ewk_View. A "title,changed" signal is now emitted
on the view to notify clients that the main frame
title was changed.

  • PlatformEfl.cmake:
  • UIProcess/API/efl/ewk_view.cpp:

(_Ewk_View_Private_Data):
(_ewk_view_priv_del):
(ewk_view_base_add):
(ewk_view_title_get):
(ewk_view_title_changed):

  • UIProcess/API/efl/ewk_view.h:
  • UIProcess/API/efl/ewk_view_loader_client.cpp: Added.

(didReceiveTitleForFrame):
(ewk_view_loader_client_attach):

  • UIProcess/API/efl/ewk_view_loader_client_private.h: Added.
  • UIProcess/API/efl/ewk_view_private.h:

Tools:

Update the MiniBrowser so it listens for the "title,change"
signal on the view and keeps the browser window title
up-to-date.

  • MiniBrowser/efl/main.c:

(on_title_changed):
(browserCreate):

Location:
trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r120437 r120442  
     12012-06-15  Christophe Dumez  <christophe.dumez@intel.com>
     2
     3        [EFL][WK2] Add title support to Ewk_View
     4        https://bugs.webkit.org/show_bug.cgi?id=89095
     5
     6        Reviewed by Kenneth Rohde Christiansen.
     7
     8        Add a method to get the title of the main frame in
     9        an Ewk_View. A "title,changed" signal is now emitted
     10        on the view to notify clients that the main frame
     11        title was changed.
     12
     13        * PlatformEfl.cmake:
     14        * UIProcess/API/efl/ewk_view.cpp:
     15        (_Ewk_View_Private_Data):
     16        (_ewk_view_priv_del):
     17        (ewk_view_base_add):
     18        (ewk_view_title_get):
     19        (ewk_view_title_changed):
     20        * UIProcess/API/efl/ewk_view.h:
     21        * UIProcess/API/efl/ewk_view_loader_client.cpp: Added.
     22        (didReceiveTitleForFrame):
     23        (ewk_view_loader_client_attach):
     24        * UIProcess/API/efl/ewk_view_loader_client_private.h: Added.
     25        * UIProcess/API/efl/ewk_view_private.h:
     26
    1272012-06-15  Christophe Dumez  <christophe.dumez@intel.com>
    228
  • trunk/Source/WebKit2/PlatformEfl.cmake

    r119928 r120442  
    3232    UIProcess/API/efl/ewk_context.cpp
    3333    UIProcess/API/efl/ewk_view.cpp
     34    UIProcess/API/efl/ewk_view_loader_client.cpp
    3435
    3536    UIProcess/cairo/BackingStoreCairo.cpp
  • trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp

    r120437 r120442  
    3131#include "ewk_context.h"
    3232#include "ewk_context_private.h"
     33#include "ewk_view_loader_client_private.h"
    3334#include "ewk_view_private.h"
    3435#include <wtf/text/CString.h>
     
    4243    OwnPtr<PageClientImpl> pageClient;
    4344    const char* uri;
     45    const char* title;
    4446};
    4547
     
    269271    priv->pageClient = nullptr;
    270272    eina_stringshare_del(priv->uri);
     273    eina_stringshare_del(priv->title);
    271274    free(priv);
    272275}
     
    490493
    491494    priv->pageClient = PageClientImpl::create(toImpl(contextRef), toImpl(pageGroupRef), ewkView);
     495    ewk_view_loader_client_attach(toAPI(priv->pageClient->page()), ewkView);
    492496
    493497    return ewkView;
     
    541545    WKPageStopLoading(toAPI(priv->pageClient->page()));
    542546    return true;
     547}
     548
     549const char* ewk_view_title_get(const Evas_Object* ewkView)
     550{
     551    EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
     552    EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
     553
     554    CString title = priv->pageClient->page()->pageTitle().utf8();
     555    eina_stringshare_replace(&priv->title, title.data());
     556
     557    return priv->title;
     558}
     559
     560/**
     561 * @internal
     562 * The view title was changed by the frame loader.
     563 *
     564 * Emits signal: "title,changed" with pointer to new title string.
     565 */
     566void ewk_view_title_changed(Evas_Object* ewkView, const char* title)
     567{
     568    evas_object_smart_callback_call(ewkView, "title,changed", const_cast<char*>(title));
    543569}
    544570
  • trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.h

    r120437 r120442  
    2424 *
    2525 * This object provides view related APIs of WebKit2 to EFL object.
     26 *
     27 * The following signals (see evas_object_smart_callback_add()) are emitted:
     28 *
     29 * - "title,changed", const char*: title of the main frame was changed.
    2630 */
    2731
     
    226230EAPI Eina_Bool    ewk_view_forward_possible(Evas_Object *o);
    227231
     232/**
     233 * Gets the current title of the main frame.
     234 *
     235 * It returns an internal string and should not
     236 * be modified. The string is guaranteed to be stringshared.
     237 *
     238 * @param o view object to get current title
     239 *
     240 * @return current title on success or @c 0 on failure
     241 */
     242EAPI const char *ewk_view_title_get(const Evas_Object *o);
     243
    228244#ifdef __cplusplus
    229245}
  • trunk/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h

    r119928 r120442  
    3333void ewk_view_display(Evas_Object* ewkView, const WebCore::IntRect& rect);
    3434void ewk_view_image_data_set(Evas_Object* ewkView, void* imageData, const WebCore::IntSize& size);
     35void ewk_view_title_changed(Evas_Object* ewkView, const char* title);
    3536
    3637Evas_Object* ewk_view_base_add(Evas* canvas, WKContextRef, WKPageGroupRef);
  • trunk/Tools/ChangeLog

    r120437 r120442  
     12012-06-15  Christophe Dumez  <christophe.dumez@intel.com>
     2
     3        [EFL][WK2] Add title support to Ewk_View
     4        https://bugs.webkit.org/show_bug.cgi?id=89095
     5
     6        Reviewed by Kenneth Rohde Christiansen.
     7
     8        Update the MiniBrowser so it listens for the "title,change"
     9        signal on the view and keeps the browser window title
     10        up-to-date.
     11
     12        * MiniBrowser/efl/main.c:
     13        (on_title_changed):
     14        (browserCreate):
     15
    1162012-06-15  Christophe Dumez  <christophe.dumez@intel.com>
    217
  • trunk/Tools/MiniBrowser/efl/main.c

    r120437 r120442  
    8787}
    8888
     89static void
     90on_title_changed(void *user_data, Evas_Object *webview, void *event_info)
     91{
     92    MiniBrowser *app = (MiniBrowser *)user_data;
     93    const char *title = (const char *)event_info;
     94
     95    ecore_evas_title_set(app->ee, title);
     96}
     97
    8998static MiniBrowser *browserCreate(const char *url)
    9099{
     
    112121    app->browser = ewk_view_add(app->evas);
    113122    evas_object_name_set(app->browser, "browser");
     123
     124    evas_object_smart_callback_add(app->browser, "title,changed", on_title_changed, app);
    114125
    115126    evas_object_event_callback_add(app->browser, EVAS_CALLBACK_KEY_DOWN, on_key_down, app);
Note: See TracChangeset for help on using the changeset viewer.