diff options
| author | Ilya Sukhar | 2010-12-14 02:24:32 -0800 | 
|---|---|---|
| committer | Ilya Sukhar | 2010-12-14 02:24:32 -0800 | 
| commit | def44f37109c2cd120893060e95551fd9a64c4ac (patch) | |
| tree | a60ca4a05300b393f9294bc02f1b14c52622bf41 | |
| parent | 031b3453f1f34df0a6b3bc83d5e920d869b329e9 (diff) | |
| download | vimium-def44f37109c2cd120893060e95551fd9a64c4ac.tar.bz2 | |
Expand the XPath used to find DOM elements for focusInput(). Closes #250.
| -rw-r--r-- | test_harnesses/form.html | 2 | ||||
| -rw-r--r-- | vimiumFrontend.js | 15 | 
2 files changed, 15 insertions, 2 deletions
| diff --git a/test_harnesses/form.html b/test_harnesses/form.html index 740edb46..d7104ac2 100644 --- a/test_harnesses/form.html +++ b/test_harnesses/form.html @@ -10,6 +10,8 @@      <p>        Text: <input type="text" name="text" value="" />        Text 2: <input type="text" name="text" value="" /> +      Email: <input type="email" name="text" value="" /> +      No Type: <input name="text" value="" />      </p>      <p>        Search: <input type="search" /> diff --git a/vimiumFrontend.js b/vimiumFrontend.js index b108d141..16f0fdde 100644 --- a/vimiumFrontend.js +++ b/vimiumFrontend.js @@ -26,6 +26,17 @@ var linkHintCss;  // TODO(philc): This should be pulled from the extension's storage when the page loads.  var currentZoomLevel = 100; +// The types in <input type="..."> that we consider for focusInput command. Right now this is recalculated in +// each content script. Alternatively we could calculate it once in the background page and use a request to +// fetch it each time. +// +// Should we include the HTML5 date pickers here? +var textInputTypes = ["text", "search", "email", "url", "number"]; +// The corresponding XPath for such elements. +var textInputXPath = '//input[' + +                     textInputTypes.map(function (type) { return '@type="' + type + '"'; }).join(" or ") + +                     ' or not(@type)]'; +  /*   * Give this frame a unique id.   */ @@ -232,8 +243,8 @@ function scrollLeft() { window.scrollBy(-1 * settings["scrollStepSize"], 0); }  function scrollRight() { window.scrollBy(settings["scrollStepSize"], 0); }  function focusInput(count) { -  var xpath = '//input[@type="text" or @type="search"]'; -  var results = document.evaluate(xpath, document.documentElement, null, +  var results = document.evaluate(textInputXPath, +                                  document.documentElement, null,                                    XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);    var lastInputBox; | 
