Diff
Modified: trunk/Source/WebKit2/ChangeLog (99178 => 99179)
--- trunk/Source/WebKit2/ChangeLog 2011-11-03 13:05:25 UTC (rev 99178)
+++ trunk/Source/WebKit2/ChangeLog 2011-11-03 13:26:39 UTC (rev 99179)
@@ -1,3 +1,27 @@
+2011-11-03 Nayan Kumar K <[email protected]>
+
+ [GTK][WEBKIT2] Add support for title property in WebKitWebView.
+ https://bugs.webkit.org/show_bug.cgi?id=68074
+
+ Reviewed by Philippe Normand.
+
+ Support for 'title' property is added in WebKitWebView.
+ Functions to get the value of this property is provided.
+
+ * UIProcess/API/gtk/WebKitWebLoaderClient.cpp:
+ (didReceiveTitleForFrame): LoaderClient titleRecieve callback.
+ (webkitWebLoaderClientAttachLoaderClientToPage): Register didReceiveTitleForFrame callback.
+ * UIProcess/API/gtk/WebKitWebView.cpp:
+ (webkitWebViewGetProperty): 'title' property get function.
+ (webkit_web_view_class_init): Register new property.
+ (webkitWebViewSetTitle): Notify WebKitWebView about title receive.
+ (webkit_web_view_get_title): API to get main frame title.
+ * UIProcess/API/gtk/WebKitWebView.h: webkit_web_view_get_title API expose.
+ * UIProcess/API/gtk/WebKitWebViewPrivate.h: Added private API.
+ * UIProcess/API/gtk/tests/TestWebKitWebLoaderClient.cpp:
+ (testWebViewTitle): Test webkit_web_view_get_title API.
+ (beforeAll): Add testWebViewTitle test.
+
2011-11-03 Jesus Sanchez-Palencia <[email protected]>
[Qt][WK2] Download support and API in UIProcess
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebLoaderClient.cpp (99178 => 99179)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebLoaderClient.cpp 2011-11-03 13:05:25 UTC (rev 99178)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebLoaderClient.cpp 2011-11-03 13:26:39 UTC (rev 99179)
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2011 Igalia S.L.
+ * Portions Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -131,6 +132,14 @@
webkitWebViewUpdateURI(WEBKIT_WEB_VIEW(toImpl(page)->viewWidget()));
}
+static void didReceiveTitleForFrame(WKPageRef page, WKStringRef titleRef, WKFrameRef frameRef, WKTypeRef, const void*)
+{
+ if (!WKFrameIsMainFrame(frameRef))
+ return;
+
+ webkitWebViewSetTitle(WEBKIT_WEB_VIEW(toImpl(page)->viewWidget()), toImpl(titleRef)->string().utf8());
+}
+
static void didChangeProgress(WKPageRef page, const void* clientInfo)
{
WebKitWebView* webView = WEBKIT_WEB_VIEW(toImpl(page)->viewWidget());
@@ -156,7 +165,7 @@
didFinishLoadForFrame,
didFailLoadWithErrorForFrame,
didSameDocumentNavigationForFrame,
- 0, // didReceiveTitleForFrame
+ didReceiveTitleForFrame,
0, // didFirstLayoutForFrame
0, // didFirstVisuallyNonEmptyLayoutForFrame
0, // didRemoveFrameFromHierarchy
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp (99178 => 99179)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp 2011-11-03 13:05:25 UTC (rev 99178)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp 2011-11-03 13:26:39 UTC (rev 99179)
@@ -44,12 +44,14 @@
PROP_0,
PROP_WEB_CONTEXT,
+ PROP_TITLE,
PROP_ESTIMATED_LOAD_PROGRESS,
PROP_URI
};
struct _WebKitWebViewPrivate {
WebKitWebContext* context;
+ CString title;
CString customTextEncoding;
double estimatedLoadProgress;
CString activeURI;
@@ -109,6 +111,9 @@
case PROP_WEB_CONTEXT:
g_value_take_object(value, webView->priv->context);
break;
+ case PROP_TITLE:
+ g_value_set_string(value, webView->priv->title.data());
+ break;
case PROP_ESTIMATED_LOAD_PROGRESS:
g_value_set_double(value, webkit_web_view_get_estimated_load_progress(webView));
break;
@@ -156,7 +161,22 @@
"The web context for the view",
WEBKIT_TYPE_WEB_CONTEXT,
static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)));
+
/**
+ * WebKitWebView:title:
+ *
+ * The main frame document title of this #WebKitWebView. If
+ * the title has not been received yet, it will be %NULL.
+ */
+ g_object_class_install_property(gObjectClass,
+ PROP_TITLE,
+ g_param_spec_string("title",
+ "Title",
+ "Main frame document title",
+ 0,
+ WEBKIT_PARAM_READABLE));
+
+ /**
* WebKitWebView:estimated-load-progress:
*
* An estimate of the percent completion for the current loading operation.
@@ -189,6 +209,16 @@
WEBKIT_PARAM_READABLE));
}
+void webkitWebViewSetTitle(WebKitWebView* webView, const CString& title)
+{
+ WebKitWebViewPrivate* priv = webView->priv;
+ if (priv->title == title)
+ return;
+
+ priv->title = title;
+ g_object_notify(G_OBJECT(webView), "title");
+}
+
void webkitWebViewSetEstimatedLoadProgress(WebKitWebView* webView, double estimatedLoadProgress)
{
if (webView->priv->estimatedLoadProgress == estimatedLoadProgress)
@@ -386,6 +416,23 @@
}
/**
+ * webkit_web_view_get_title:
+ * @web_view: a #WebKitWebView
+ *
+ * Gets the value of #WebKitWebView:title.
+ * You can connect to #WebKitWebView::notify signal of @web_view to
+ * be notified when the title has been received.
+ *
+ * Returns: The main frame document title of @web_view.
+ */
+const gchar* webkit_web_view_get_title(WebKitWebView* webView)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0);
+
+ return webView->priv->title.data();
+}
+
+/**
* webkit_web_view_reload:
* @web_view: a #WebKitWebView
*
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h (99178 => 99179)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h 2011-11-03 13:05:25 UTC (rev 99178)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h 2011-11-03 13:26:39 UTC (rev 99179)
@@ -108,6 +108,9 @@
WEBKIT_API void
webkit_web_view_stop_loading (WebKitWebView *web_view);
+WEBKIT_API const gchar *
+webkit_web_view_get_title (WebKitWebView *web_view);
+
WEBKIT_API void
webkit_web_view_reload (WebKitWebView *web_view);
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h (99178 => 99179)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h 2011-11-03 13:05:25 UTC (rev 99178)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h 2011-11-03 13:26:39 UTC (rev 99179)
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2011 Igalia S.L.
+ * Portions Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -28,8 +29,10 @@
#include "WebKitWebView.h"
#include <WebKit2/WebKit2.h>
+#include <wtf/text/CString.h>
void webkitWebViewSetEstimatedLoadProgress(WebKitWebView*, double estimatedLoadProgress);
+void webkitWebViewSetTitle(WebKitWebView*, const CString&);
void webkitWebViewUpdateURI(WebKitWebView*);
#endif // WebKitWebViewPrivate_h
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt (99178 => 99179)
--- trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt 2011-11-03 13:05:25 UTC (rev 99178)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt 2011-11-03 13:26:39 UTC (rev 99179)
@@ -57,6 +57,7 @@
webkit_web_view_go_back
webkit_web_view_can_go_forward
webkit_web_view_go_forward
+webkit_web_view_get_title
webkit_web_view_reload
webkit_web_view_reload_bypass_cache
webkit_web_view_stop_loading
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebLoaderClient.cpp (99178 => 99179)
--- trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebLoaderClient.cpp 2011-11-03 13:05:25 UTC (rev 99178)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebLoaderClient.cpp 2011-11-03 13:26:39 UTC (rev 99179)
@@ -116,6 +116,14 @@
g_assert_cmpint(events[2], ==, LoadTrackingTest::LoadFailed);
}
+static void testWebViewTitle(LoadTrackingTest* test, gconstpointer)
+{
+ g_assert(!webkit_web_view_get_title(test->m_webView));
+ test->loadHtml("<html><head><title>Welcome to WebKit-GTK+!</title></head></html>", 0);
+ test->waitUntilLoadFinished();
+ g_assert_cmpstr(webkit_web_view_get_title(test->m_webView), ==, "Welcome to WebKit-GTK+!");
+}
+
static void testWebViewReload(LoadTrackingTest* test, gconstpointer)
{
// Check that nothing happens when there's nothing to reload.
@@ -239,6 +247,7 @@
LoadTrackingTest::add("WebKitWebView", "load-plain-text", testLoadPlainText);
LoadTrackingTest::add("WebKitWebLoaderClient", "load-alternate-content", testLoadAlternateContent);
LoadStopTrackingTest::add("WebKitWebView", "stop-loading", testLoadCancelled);
+ LoadTrackingTest::add("WebKitWebView", "title", testWebViewTitle);
LoadTrackingTest::add("WebKitWebView", "progress", testLoadProgress);
LoadTrackingTest::add("WebKitWebView", "reload", testWebViewReload);