diff --git a/ChangeLog b/ChangeLog index d70ac097..b5ab35b3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,9 @@
 2007-05-02:
 	* version ???
+	* hints work on xhtml pages now (you need to reset the 'hinttags' and
+	  'extendedhinttags' settings with :set hinttags& and :set extendedhinttags&
+	* :set option& resets the option to the default value
 	* added :tabonly and :tabrewind and :tablast commands and some futher aliases :tabNext, etc. (by Doug Kearns)
 	* added vimparator.vim for .vimperatorrc syntax highlighting in the XPI (by Doug Kearns)
 	* Added keyword support for bookmarks to the :[tab]open commands
diff --git a/chrome/content/vimperator/commands.js b/chrome/content/vimperator/commands.js
index c13f6f5b..77b6f6ef 100644
--- a/chrome/content/vimperator/commands.js
+++ b/chrome/content/vimperator/commands.js
@@ -338,6 +338,7 @@ var g_commands = [/*{{{*/
         ":set without an argument opens about:config in a new tab to change advanced Firefox options.
"+ ":set! opens the GUI preference panel from Firefox in a new tab.
"+ ":set option? or :set option shows the current value of the option.
"+ + ":set option& resets 'option' to the default value.
"+ ":set option+=foo and :set option-=foo WILL add/remove foo from list options.
", set, function(filter) { return get_settings_completions(filter); } @@ -1488,11 +1489,12 @@ function getCurrentLocation() /* returns the current title or null */ function getCurrentTitle() { - var titles = window.content.document.getElementsByTagName('title'); - if (titles.length >= 1) - return titles[0]; - else - return null; + return window.content.document.title; +// var titles = window.content.document.getElementsByTagName('title'); +// if (titles.length >= 1) +// return titles[0]; +// else +// return null; } @@ -1969,7 +1971,7 @@ function set(args, special) } else { - var matches = args.match(/^\s*(no)?([a-z]+)(\?)?(([+-])?=(.*))?/); + var matches = args.match(/^\s*(no)?([a-z]+)(\?|&)?(([+-])?=(.*))?/); if (!matches) { echoerr("E518: Unknown option: " + args); @@ -1985,13 +1987,20 @@ function set(args, special) return; } - var get = false; if (matches[3] != undefined || + var get = false; if (matches[3] == "?" || (setting[TYPE] != 'boolean' && matches[4] == undefined)) get = true; + var reset = false; if (matches[3] == "&") reset = true; var oper = matches[5]; var val = matches[6]; if (val == undefined) val = ""; + // reset a variable to its default value. + if (reset) + { + var def = setting[DEFAULT]; + setting[SETFUNC].call(this, def); + } // read access - if (get) + else if (get) { var cur_val = setting[GETFUNC].call(this); echo(" " + setting[COMMANDS][0] + "=" + cur_val); @@ -2078,8 +2087,26 @@ function source(filename, silent) } } +// returns an XPathResult object +function evaluateXPath(expression, doc, ordered) +{ + if(!doc) + doc = window.content.document; - + var res = doc.evaluate(expression, doc, + function lookupNamespaceURI(prefix) { + switch (prefix) { + case 'xhtml': + return 'http://www.w3.org/1999/xhtml'; + default: + return null; + } + }, + ordered ? XPathResult.ORDERED_NODE_SNAPSHOT_TYPE : XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, + null + ); + return res; +} @@ -2183,8 +2210,7 @@ function selectInput() // if (! (ev.charCode == 47 /* ord('/') */ && ev.ctrlKey)) // return; - var texts = document.evaluate("//input[@type='text']", document, - null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); + var texts = evaluateXPath("//input[@type='text']"); texts.snapshotItem(0).focus(); } diff --git a/chrome/content/vimperator/hints.js b/chrome/content/vimperator/hints.js index c9eb7cdf..a2aead3e 100644 --- a/chrome/content/vimperator/hints.js +++ b/chrome/content/vimperator/hints.js @@ -78,7 +78,7 @@ function hit_a_hint() wins.push(win); } // logMessage("winId:"+win.winId); - win.res = doc.evaluate(get_pref("hinttags"), doc, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); + win.res = evaluateXPath(get_pref("hinttags"), doc); win.coordLoaderId = window.setTimeout("hah.loadCoord(" + win.winId + ", 0);", 1); } @@ -135,7 +135,7 @@ function hit_a_hint() area[3] = area[1] + win.innerHeight; var doc = win.document; - var res = doc.evaluate(get_pref("hinttags"), doc, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); + var res = evaluateXPath(get_pref("hinttags"), doc); var elem, i; @@ -253,7 +253,7 @@ function hit_a_hint() win = window.content; var doc = win.document; - var res = doc.evaluate("//HINTS/SPAN", doc, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); + var res = evaluateXPath("//HINTS/SPAN", doc) var elem, i; for (i = 0; i < res.snapshotLength; i++) @@ -272,7 +272,7 @@ function hit_a_hint() if(event) doc = event.originalTarget; else - doc = window._content.document; + doc = window.content.document; invalidateCoords(doc); startCoordLoader(doc); diff --git a/chrome/content/vimperator/settings.js b/chrome/content/vimperator/settings.js index d8fdab22..18332880 100644 --- a/chrome/content/vimperator/settings.js +++ b/chrome/content/vimperator/settings.js @@ -98,7 +98,8 @@ var g_settings = [/*{{{*/ null, function(value) { set_pref("extendedhinttags", value); }, function() { return get_pref("extendedhinttags"); }, - "//*[@onclick or @onmouseover or @onmousedown or @onmouseup or @oncommand or @class='lk' or @class='s'] | //input[@type!='hidden' or not(boolean(@type))] | //a | //area | //iframe | //textarea | //button | //select", + "//*[@onclick or @onmouseover or @onmousedown or @onmouseup or @oncommand or @class='lk' or @class='s'] | //input[@type!='hidden' or not(boolean(@type))] | //a | //area | //iframe | //textarea | //button | //select | "+ + "//xhtml:*[@onclick or @onmouseover or @onmousedown or @onmouseup or @oncommand or @class='lk' or @class='s'] | //xhtml:input[@type!='hidden' or not(boolean(@type))] | //xhtml:a | //xhtml:area | //xhtml:iframe | //xhtml:textarea | //xhtml:button | //xhtml:select", null ], [ @@ -170,7 +171,8 @@ var g_settings = [/*{{{*/ null, function(value) { set_pref("hinttags", value); }, function() { return get_pref("hinttags"); }, - "//*[@onclick or @onmouseover or @onmousedown or @onmouseup or @oncommand or @class='lk' or @class='s'] | //input[@type!='hidden'] | //a | //area | //iframe | //textarea | //button | //select", + "//*[@onclick or @onmouseover or @onmousedown or @onmouseup or @oncommand or @class='lk' or @class='s'] | //input[@type!='hidden'] | //a | //area | //iframe | //textarea | //button | //select | "+ + "//xhtml:*[@onclick or @onmouseover or @onmousedown or @onmouseup or @oncommand or @class='lk' or @class='s'] | //xhtml:input[@type!='hidden'] | //xhtml:a | //xhtml:area | //xhtml:iframe | //xhtml:textarea | //xhtml:button | //xhtml:select", null ], [