From def44f37109c2cd120893060e95551fd9a64c4ac Mon Sep 17 00:00:00 2001 From: Ilya Sukhar Date: Tue, 14 Dec 2010 02:24:32 -0800 Subject: Expand the XPath used to find DOM elements for focusInput(). Closes #250. --- vimiumFrontend.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'vimiumFrontend.js') 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 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; -- cgit v1.2.3