[evolution] EWebView: Allow navigation in page through HTML anchor elements



commit 5306c9f8b0f3bd173b7864d1ba284ead4e5ffadd
Author: Tomas Popela <tpopela redhat com>
Date:   Mon May 5 16:15:06 2014 +0200

    EWebView: Allow navigation in page through HTML anchor elements

 e-util/e-web-view.c |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/e-util/e-web-view.c b/e-util/e-web-view.c
index 47e31dc..00dd6c0 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;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]