From 5306c9f8b0f3bd173b7864d1ba284ead4e5ffadd Mon Sep 17 00:00:00 2001 From: Tomas Popela Date: Mon, 5 May 2014 16:15:06 +0200 Subject: EWebView: Allow navigation in page through HTML anchor elements --- e-util/e-web-view.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'e-util') diff --git a/e-util/e-web-view.c b/e-util/e-web-view.c index 47e31dcfb3..00dd6c0ad7 100644 --- a/e-util/e-web-view.c +++ b/e-util/e-web-view.c @@ -542,12 +542,25 @@ web_view_navigation_policy_decision_requested_cb (EWebView *web_view, { EWebViewClass *class; WebKitWebNavigationReason reason; - const gchar *uri; + const gchar *uri, *frame_uri; reason = webkit_web_navigation_action_get_reason (navigation_action); if (reason != WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED) return FALSE; + uri = webkit_network_request_get_uri (request); + frame_uri = webkit_web_frame_get_uri (frame); + + /* Allow navigation through sections in page */ + if (uri && *uri && frame_uri && *frame_uri) { + /* The uri should contain the frame uri and the id of the anchor + * element that is separated from uri by hashtag character */ + if (g_str_has_prefix (uri, frame_uri) && strstr (uri, "#")) { + webkit_web_policy_decision_use (policy_decision); + return TRUE; + } + } + /* XXX WebKitWebView does not provide a class method for * this signal, so we do so we can override the default * behavior from subclasses for special URI types. */ @@ -557,8 +570,6 @@ web_view_navigation_policy_decision_requested_cb (EWebView *web_view, webkit_web_policy_decision_ignore (policy_decision); - uri = webkit_network_request_get_uri (request); - class->link_clicked (web_view, uri); return TRUE; -- cgit v1.2.3