Gitweb links:

...log 
http://git.netsurf-browser.org/netsurf.git/shortlog/084861a31b885c52d87ea0a3d99ebe42af27a713
...commit 
http://git.netsurf-browser.org/netsurf.git/commit/084861a31b885c52d87ea0a3d99ebe42af27a713
...tree 
http://git.netsurf-browser.org/netsurf.git/tree/084861a31b885c52d87ea0a3d99ebe42af27a713

The branch, master has been updated
       via  084861a31b885c52d87ea0a3d99ebe42af27a713 (commit)
      from  529b94be73a1ba080a72f620c8d1165da02bc66b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=084861a31b885c52d87ea0a3d99ebe42af27a713
commit 084861a31b885c52d87ea0a3d99ebe42af27a713
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>

    Implement javascript scheme url script 
https://wiki.whatwg.org/wiki/URL_schemes

diff --git a/content/handlers/html/html.c b/content/handlers/html/html.c
index f2b898d..e445457 100644
--- a/content/handlers/html/html.c
+++ b/content/handlers/html/html.c
@@ -2707,7 +2707,7 @@ bool html_get_id_offset(hlcache_handle *h, lwc_string 
*frag_id, int *x, int *y)
        return false;
 }
 
-static bool html_exec(struct content *c, const char *src, size_t srclen)
+bool html_exec(struct content *c, const char *src, size_t srclen)
 {
        html_content *htmlc = (html_content *)c;
        bool result = false;
diff --git a/content/handlers/html/html_internal.h 
b/content/handlers/html/html_internal.h
index 7340bd2..d981017 100644
--- a/content/handlers/html/html_internal.h
+++ b/content/handlers/html/html_internal.h
@@ -300,6 +300,9 @@ bool html_redraw_inline_borders(struct box *box, struct 
rect b,
 /* in html/html_script.c */
 dom_hubbub_error html_process_script(void *ctx, dom_node *node);
 
+/* in html/html.c */
+bool html_exec(struct content *c, const char *src, size_t srclen);
+
 /**
  * Attempt script execution for defer and async scripts
  *
diff --git a/content/handlers/html/interaction.c 
b/content/handlers/html/interaction.c
index fc688d1..7c4d54f 100644
--- a/content/handlers/html/interaction.c
+++ b/content/handlers/html/interaction.c
@@ -572,6 +572,7 @@ struct mouse_action_state {
                      ACTION_NOSEND, /**< do not send status and pointer 
message */
                      ACTION_SUBMIT,
                      ACTION_GO,
+                     ACTION_JS,
                } action;
        } result;
 
@@ -1057,6 +1058,28 @@ html_object_mouse_action(html_content *html,
 
 
 /**
+ * determine if a url has a javascript scheme
+ *
+ * \param urm The url to check.
+ * \return true if the url is a javascript scheme else false
+ */
+static bool is_javascript_navigate_url(nsurl *url)
+{
+       bool is_js = false;
+       lwc_string *scheme;
+
+       scheme = nsurl_get_component(url, NSURL_SCHEME);
+       if (scheme != NULL) {
+               if (scheme == corestring_lwc_javascript) {
+                       is_js = true;
+               }
+               lwc_string_unref(scheme);
+       }
+       return is_js;
+}
+
+
+/**
  * process mouse activity on a link
  */
 static nserror
@@ -1125,13 +1148,18 @@ link_mouse_action(html_content *html,
                                  &msg_data);
 
        } else if (mouse & (BROWSER_MOUSE_CLICK_1 | BROWSER_MOUSE_CLICK_2)) {
-               mas->result.action = ACTION_GO;
+               if (is_javascript_navigate_url(mas->link.url)) {
+                       mas->result.action = ACTION_JS;
+               } else {
+                       mas->result.action = ACTION_GO;
+               }
        }
 
        return NSERROR_OK;
 }
 
 
+
 /**
  * process mouse activity if it is not anything else
  */
@@ -1296,10 +1324,11 @@ mouse_action_drag_none(html_content *html,
                       browser_mouse_state mouse,
                       int x, int y)
 {
+       nserror res;
        struct content *c = (struct content *)html;
        union content_msg_data msg_data;
+       lwc_string *path;
 
-       nserror res;
        /**
         * computed state
         *
@@ -1395,6 +1424,16 @@ mouse_action_drag_none(html_content *html,
                                NULL);
                break;
 
+       case ACTION_JS:
+               path = nsurl_get_component(mas.link.url, NSURL_PATH);
+               if (path != NULL) {
+                       html_exec(c,
+                                 lwc_string_data(path),
+                                 lwc_string_length(path));
+                       lwc_string_unref(path);
+               }
+               break;
+
        case ACTION_NOSEND:
        case ACTION_NONE:
                res = NSERROR_OK;
@@ -1462,7 +1501,7 @@ html_mouse_action(struct content *c,
        if (res != NSERROR_OK) {
                NSLOG(netsurf, ERROR, "%s", messages_get_errorcode(res));
        }
-       
+
        return res;
 }
 


-----------------------------------------------------------------------

Summary of changes:
 content/handlers/html/html.c          |    2 +-
 content/handlers/html/html_internal.h |    3 +++
 content/handlers/html/interaction.c   |   45 ++++++++++++++++++++++++++++++---
 3 files changed, 46 insertions(+), 4 deletions(-)

diff --git a/content/handlers/html/html.c b/content/handlers/html/html.c
index f2b898d..e445457 100644
--- a/content/handlers/html/html.c
+++ b/content/handlers/html/html.c
@@ -2707,7 +2707,7 @@ bool html_get_id_offset(hlcache_handle *h, lwc_string 
*frag_id, int *x, int *y)
        return false;
 }
 
-static bool html_exec(struct content *c, const char *src, size_t srclen)
+bool html_exec(struct content *c, const char *src, size_t srclen)
 {
        html_content *htmlc = (html_content *)c;
        bool result = false;
diff --git a/content/handlers/html/html_internal.h 
b/content/handlers/html/html_internal.h
index 7340bd2..d981017 100644
--- a/content/handlers/html/html_internal.h
+++ b/content/handlers/html/html_internal.h
@@ -300,6 +300,9 @@ bool html_redraw_inline_borders(struct box *box, struct 
rect b,
 /* in html/html_script.c */
 dom_hubbub_error html_process_script(void *ctx, dom_node *node);
 
+/* in html/html.c */
+bool html_exec(struct content *c, const char *src, size_t srclen);
+
 /**
  * Attempt script execution for defer and async scripts
  *
diff --git a/content/handlers/html/interaction.c 
b/content/handlers/html/interaction.c
index fc688d1..7c4d54f 100644
--- a/content/handlers/html/interaction.c
+++ b/content/handlers/html/interaction.c
@@ -572,6 +572,7 @@ struct mouse_action_state {
                      ACTION_NOSEND, /**< do not send status and pointer 
message */
                      ACTION_SUBMIT,
                      ACTION_GO,
+                     ACTION_JS,
                } action;
        } result;
 
@@ -1057,6 +1058,28 @@ html_object_mouse_action(html_content *html,
 
 
 /**
+ * determine if a url has a javascript scheme
+ *
+ * \param urm The url to check.
+ * \return true if the url is a javascript scheme else false
+ */
+static bool is_javascript_navigate_url(nsurl *url)
+{
+       bool is_js = false;
+       lwc_string *scheme;
+
+       scheme = nsurl_get_component(url, NSURL_SCHEME);
+       if (scheme != NULL) {
+               if (scheme == corestring_lwc_javascript) {
+                       is_js = true;
+               }
+               lwc_string_unref(scheme);
+       }
+       return is_js;
+}
+
+
+/**
  * process mouse activity on a link
  */
 static nserror
@@ -1125,13 +1148,18 @@ link_mouse_action(html_content *html,
                                  &msg_data);
 
        } else if (mouse & (BROWSER_MOUSE_CLICK_1 | BROWSER_MOUSE_CLICK_2)) {
-               mas->result.action = ACTION_GO;
+               if (is_javascript_navigate_url(mas->link.url)) {
+                       mas->result.action = ACTION_JS;
+               } else {
+                       mas->result.action = ACTION_GO;
+               }
        }
 
        return NSERROR_OK;
 }
 
 
+
 /**
  * process mouse activity if it is not anything else
  */
@@ -1296,10 +1324,11 @@ mouse_action_drag_none(html_content *html,
                       browser_mouse_state mouse,
                       int x, int y)
 {
+       nserror res;
        struct content *c = (struct content *)html;
        union content_msg_data msg_data;
+       lwc_string *path;
 
-       nserror res;
        /**
         * computed state
         *
@@ -1395,6 +1424,16 @@ mouse_action_drag_none(html_content *html,
                                NULL);
                break;
 
+       case ACTION_JS:
+               path = nsurl_get_component(mas.link.url, NSURL_PATH);
+               if (path != NULL) {
+                       html_exec(c,
+                                 lwc_string_data(path),
+                                 lwc_string_length(path));
+                       lwc_string_unref(path);
+               }
+               break;
+
        case ACTION_NOSEND:
        case ACTION_NONE:
                res = NSERROR_OK;
@@ -1462,7 +1501,7 @@ html_mouse_action(struct content *c,
        if (res != NSERROR_OK) {
                NSLOG(netsurf, ERROR, "%s", messages_get_errorcode(res));
        }
-       
+
        return res;
 }
 


-- 
NetSurf Browser

_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org

Reply via email to