]> spindle.queued.net Git - midori/commitdiff
Show access keys distinct from numbers in link search
authorAlexander Friesen <a_06357@fastmail.fm>
Mon, 4 Apr 2011 22:40:15 +0000 (00:40 +0200)
committerChristian Dywan <christian@twotoasts.de>
Mon, 4 Apr 2011 22:40:15 +0000 (00:40 +0200)
Keys are invoked with Alt+key.

Numeric access keys don't work and are not shown as such.

midori/midori-view.c

index 750305f3822d46fa052257f87e72aae4845a3d9b..2a5862594a9270f474f9ffc6c4a30a891631dbe8 100644 (file)
@@ -991,6 +991,14 @@ midori_view_web_view_navigation_decision_cb (WebKitWebView*             web_view
         "       parent.removeChild(links[i]); } }",
         NULL);
     g_free (result);
+    result = sokoke_js_script_eval (js_context,
+        "var links = document.getElementsByClassName ('midori_access_key_fc04de');"
+        "if (links != undefined && links.length > 0) {"
+        "   for (var i = links.length - 1; i >= 0; i--) {"
+        "       var parent = links[i].parentNode;"
+        "       parent.removeChild(links[i]); } }",
+        NULL);
+    g_free (result);
     view->find_links = -1;
 
     return FALSE;
@@ -1886,28 +1894,38 @@ gtk_widget_key_press_event_cb (WebKitWebView* web_view,
         if (view->find_links == -1)
         {
             result = sokoke_js_script_eval (js_context,
-                "(function (selector, rule) { "
+                " var style_func = (function (selector, rule) { "
                 " var style = document.createElement ('style');"
                 " style.setAttribute ('type', 'text/css');"
                 " var heads = document.getElementsByTagName ('head');"
                 " heads[0].appendChild (style);"
                 " document.styleSheets[0].insertRule (selector + ' ' + rule);"
-                " } )"
-                " ('.midoriHKD87346', '{ "
+                " } );"
+                " style_func ('.midoriHKD87346', '{ "
                 " font-size:small !important; font-weight:bold !important;"
                 " z-index:500; border-radius:0.3em; line-height:1 !important;"
                 " background: white !important; color: black !important;"
                 " border:1px solid gray; padding:0 0.1em !important;"
                 " position:absolute; display:inline !important; }');"
-                "var links = document.getElementsByTagName ('a');"
-                "var label_count = 0;"
-                "for (i in links) {"
-                "  if (links[i].insertBefore && links[i].href) { "
-                "    var child = document.createElement ('span');"
-                "    child.setAttribute ('class', 'midoriHKD87346');"
-                "    child.appendChild (document.createTextNode (label_count));"
-                "    links[i].insertBefore (child);"
-                "    label_count++; } }",
+                " style_func ('.midori_access_key_fc04de', '{ "
+                " font-size:small !important; font-weight:bold !important;"
+                " z-index:500; border-radius:0.3em; line-height:1 !important;"
+                " background: black !important; color: white !important;"
+                " border:1px solid gray; padding:0 0.1em 0.2em 0.1em !important;"
+                " position:absolute; display:inline !important; }');"
+                " var label_count = 0;"
+                " for (i in document.links) {"
+                "   if (document.links[i].href && document.links[i].insertBefore) {"
+                "       var child = document.createElement ('span');"
+                "       if (document.links[i].accessKey && isNaN (document.links[i].accessKey)) {"
+                "           child.setAttribute ('class', 'midori_access_key_fc04de');"
+                "           child.appendChild (document.createTextNode (document.links[i].accessKey));"
+                "       } else {"
+                "         child.setAttribute ('class', 'midoriHKD87346');"
+                "         child.appendChild (document.createTextNode (label_count));"
+                "         label_count++;"
+                "       }"
+                "       document.links[i].insertBefore (child); } }",
                 NULL);
             view->find_links = 0;
         }
@@ -1957,6 +1975,14 @@ gtk_widget_key_press_event_cb (WebKitWebView* web_view,
                 "   parent.removeChild(links[i]); }",
                 NULL);
             g_free (result);
+            result = sokoke_js_script_eval (js_context,
+                "var links = document.getElementsByClassName ('midori_access_key_fc04de');"
+                "if (links != undefined && links.length > 0) {"
+                "   for (var i = links.length - 1; i >= 0; i--) {"
+                "       var parent = links[i].parentNode;"
+                "       parent.removeChild(links[i]); } }",
+                NULL);
+            g_free (result);
             view->find_links = -1;
         }
         return FALSE;