Title: [121830] trunk
Revision
121830
Author
[email protected]
Date
2012-07-03 23:34:49 -0700 (Tue, 03 Jul 2012)

Log Message

[WK2][EFL] Ewk_View should report the load progress
https://bugs.webkit.org/show_bug.cgi?id=90457

Patch by Christophe Dumez <[email protected]> on 2012-07-03
Reviewed by Kenneth Rohde Christiansen.

Source/WebKit2:

The Ewk_View now reports the estimated load progress
of the page via the new "load,progress".
A method is also added to Ewk_View in order to
retrieve the current load progress.

* UIProcess/API/efl/ewk_view.cpp:
(ewk_view_load_progress_get):
(ewk_view_load_progress_changed):
* UIProcess/API/efl/ewk_view.h:
* UIProcess/API/efl/ewk_view_loader_client.cpp:
(didChangeProgress):
(ewk_view_loader_client_attach):
* UIProcess/API/efl/ewk_view_private.h:

Tools:

Update EFL MiniBrowser so that it listens for the
"load,progress" on the Ewk_View and updates its
window title accordingly.

* MiniBrowser/efl/main.c:
(title_set):
(on_title_changed):
(on_progress):
(browserCreate):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (121829 => 121830)


--- trunk/Source/WebKit2/ChangeLog	2012-07-04 06:18:20 UTC (rev 121829)
+++ trunk/Source/WebKit2/ChangeLog	2012-07-04 06:34:49 UTC (rev 121830)
@@ -1,5 +1,26 @@
 2012-07-03  Christophe Dumez  <[email protected]>
 
+        [WK2][EFL] Ewk_View should report the load progress
+        https://bugs.webkit.org/show_bug.cgi?id=90457
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        The Ewk_View now reports the estimated load progress
+        of the page via the new "load,progress".
+        A method is also added to Ewk_View in order to
+        retrieve the current load progress.
+
+        * UIProcess/API/efl/ewk_view.cpp:
+        (ewk_view_load_progress_get):
+        (ewk_view_load_progress_changed):
+        * UIProcess/API/efl/ewk_view.h:
+        * UIProcess/API/efl/ewk_view_loader_client.cpp:
+        (didChangeProgress):
+        (ewk_view_loader_client_attach):
+        * UIProcess/API/efl/ewk_view_private.h:
+
+2012-07-03  Christophe Dumez  <[email protected]>
+
         [WK2] Add support for Battery Status API
         https://bugs.webkit.org/show_bug.cgi?id=89558
 

Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp (121829 => 121830)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp	2012-07-04 06:18:20 UTC (rev 121829)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp	2012-07-04 06:34:49 UTC (rev 121830)
@@ -569,8 +569,27 @@
     evas_object_smart_callback_call(ewkView, "title,changed", const_cast<char*>(title));
 }
 
+double ewk_view_load_progress_get(const Evas_Object* ewkView)
+{
+    EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
+    EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
+
+    return WKPageGetEstimatedProgress(toAPI(priv->pageClient->page()));
+}
+
 /**
  * @internal
+ * Reports load progress changed.
+ *
+ * Emits signal: "load,progress" with pointer to a double from 0.0 to 1.0.
+ */
+void ewk_view_load_progress_changed(Evas_Object* ewkView, double progress)
+{
+    evas_object_smart_callback_call(ewkView, "load,progress", &progress);
+}
+
+/**
+ * @internal
  * The view received a new intent request.
  *
  * Emits signal: "intent,request,new" with pointer to a Ewk_Intent.

Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.h (121829 => 121830)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.h	2012-07-04 06:18:20 UTC (rev 121829)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.h	2012-07-04 06:34:49 UTC (rev 121830)
@@ -28,6 +28,7 @@
  *
  * - "intent,request,new", Ewk_Intent_Request*: reports new Web intent request.
  * - "intent,service,register", Ewk_Intent_Service*: reports new Web intent service registration.
+ * - "load,progress", double*: load progress has changed (value from 0.0 to 1.0).
  * - "title,changed", const char*: title of the main frame was changed.
  */
 
@@ -253,6 +254,17 @@
  */
 EAPI const char *ewk_view_title_get(const Evas_Object *o);
 
+/**
+ * Gets the current load progress of page.
+ *
+ * The progress estimation from 0.0 to 1.0.
+ *
+ * @param o view object to get the current progress
+ *
+ * @return the load progres of page, value from 0.0 to 1.0.
+ */
+EAPI double ewk_view_load_progress_get(const Evas_Object *o);
+
 #ifdef __cplusplus
 }
 #endif

Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_view_loader_client.cpp (121829 => 121830)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_view_loader_client.cpp	2012-07-04 06:18:20 UTC (rev 121829)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_view_loader_client.cpp	2012-07-04 06:34:49 UTC (rev 121830)
@@ -65,6 +65,12 @@
 }
 #endif
 
+static void didChangeProgress(WKPageRef page, const void* clientInfo)
+{
+    Evas_Object* ewkView = static_cast<Evas_Object*>(const_cast<void*>(clientInfo));
+    ewk_view_load_progress_changed(ewkView, WKPageGetEstimatedProgress(page));
+}
+
 void ewk_view_loader_client_attach(WKPageRef pageRef, Evas_Object* ewkView)
 {
     WKPageLoaderClient loadClient;
@@ -78,5 +84,8 @@
 #if ENABLE(WEB_INTENTS_TAG)
     loadClient.registerIntentServiceForFrame = registerIntentServiceForFrame;
 #endif
+    loadClient.didStartProgress = didChangeProgress;
+    loadClient.didChangeProgress = didChangeProgress;
+    loadClient.didFinishProgress = didChangeProgress;
     WKPageSetPageLoaderClient(pageRef, &loadClient);
 }

Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h (121829 => 121830)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h	2012-07-04 06:18:20 UTC (rev 121829)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h	2012-07-04 06:34:49 UTC (rev 121830)
@@ -39,6 +39,7 @@
 
 void ewk_view_display(Evas_Object* ewkView, const WebCore::IntRect& rect);
 void ewk_view_image_data_set(Evas_Object* ewkView, void* imageData, const WebCore::IntSize& size);
+void ewk_view_load_progress_changed(Evas_Object* ewkView, double progress);
 void ewk_view_title_changed(Evas_Object* ewkView, const char* title);
 
 Evas_Object* ewk_view_base_add(Evas* canvas, WKContextRef, WKPageGroupRef);

Modified: trunk/Tools/ChangeLog (121829 => 121830)


--- trunk/Tools/ChangeLog	2012-07-04 06:18:20 UTC (rev 121829)
+++ trunk/Tools/ChangeLog	2012-07-04 06:34:49 UTC (rev 121830)
@@ -1,3 +1,20 @@
+2012-07-03  Christophe Dumez  <[email protected]>
+
+        [WK2][EFL] Ewk_View should report the load progress
+        https://bugs.webkit.org/show_bug.cgi?id=90457
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Update EFL MiniBrowser so that it listens for the
+        "load,progress" on the Ewk_View and updates its
+        window title accordingly.
+
+        * MiniBrowser/efl/main.c:
+        (title_set):
+        (on_title_changed):
+        (on_progress):
+        (browserCreate):
+
 2012-07-03  Dirk Pranke  <[email protected]>
 
         disable failing mock-chromium-mac python unit tests

Modified: trunk/Tools/MiniBrowser/efl/main.c (121829 => 121830)


--- trunk/Tools/MiniBrowser/efl/main.c	2012-07-04 06:18:20 UTC (rev 121829)
+++ trunk/Tools/MiniBrowser/efl/main.c	2012-07-04 06:34:49 UTC (rev 121830)
@@ -26,6 +26,7 @@
 static const int DEFAULT_WIDTH = 800;
 static const int DEFAULT_HEIGHT = 600;
 static const char DEFAULT_URL[] = "http://www.google.com/";
+static const char APP_NAME[] = "EFL MiniBrowser";
 
 #define info(format, args...)       \
     do {                            \
@@ -87,21 +88,50 @@
 }
 
 static void
+title_set(Ecore_Evas *ee, const char *title, int progress)
+{
+    Eina_Strbuf* buffer;
+
+    if (!title || !*title) {
+        ecore_evas_title_set(ee, APP_NAME);
+        return;
+    }
+
+    buffer = eina_strbuf_new();
+    if (progress < 100)
+        eina_strbuf_append_printf(buffer, "%s (%d%%) - %s", title, progress, APP_NAME);
+    else
+        eina_strbuf_append_printf(buffer, "%s - %s", title, APP_NAME);
+
+    ecore_evas_title_set(ee, eina_strbuf_string_get(buffer));
+    eina_strbuf_free(buffer);
+}
+
+static void
 on_title_changed(void *user_data, Evas_Object *webview, void *event_info)
 {
     MiniBrowser *app = (MiniBrowser *)user_data;
     const char *title = (const char *)event_info;
 
-    ecore_evas_title_set(app->ee, title);
+    title_set(app->ee, title, 100);
 }
 
+static void
+on_progress(void *user_data, Evas_Object *webview, void *event_info)
+{
+    MiniBrowser *app = (MiniBrowser *)user_data;
+    double progress = *(double *)event_info;
+
+    title_set(app->ee, ewk_view_title_get(app->browser), progress * 100);
+}
+
 static MiniBrowser *browserCreate(const char *url)
 {
     MiniBrowser *app = malloc(sizeof(MiniBrowser));
 
     app->ee = ecore_evas_new(0, 0, 0, DEFAULT_WIDTH, DEFAULT_HEIGHT, 0);
 
-    ecore_evas_title_set(app->ee, "EFL MiniBrowser");
+    ecore_evas_title_set(app->ee, APP_NAME);
     ecore_evas_callback_resize_set(app->ee, on_ecore_evas_resize);
     ecore_evas_borderless_set(app->ee, 0);
     ecore_evas_show(app->ee);
@@ -121,6 +151,7 @@
     app->browser = ewk_view_add(app->evas);
     evas_object_name_set(app->browser, "browser");
 
+    evas_object_smart_callback_add(app->browser, "load,progress", on_progress, app);
     evas_object_smart_callback_add(app->browser, "title,changed", on_title_changed, app);
 
     evas_object_event_callback_add(app->browser, EVAS_CALLBACK_KEY_DOWN, on_key_down, app);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to