aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CREDITS1
-rw-r--r--README.markdown12
-rw-r--r--background_page.html20
-rw-r--r--lib/keyboardUtils.js2
-rw-r--r--linkHints.js1
-rw-r--r--manifest.json4
-rw-r--r--vimiumFrontend.js112
7 files changed, 106 insertions, 46 deletions
diff --git a/CREDITS b/CREDITS
index 9f814f7a..c1ccd981 100644
--- a/CREDITS
+++ b/CREDITS
@@ -17,5 +17,6 @@ Contributors:
Tim Morgan <tim@timmorgan.org> (github: seven1m)
tsigo
Werner Laurensse (github: ab3)
+ Svein-Erik Larsen <feinom@gmail.com> (github: feinom)
Feel free to add real names in addition to GitHub usernames.
diff --git a/README.markdown b/README.markdown
index 449acd6a..8323a5f4 100644
--- a/README.markdown
+++ b/README.markdown
@@ -34,6 +34,8 @@ Navigating the current page:
<c-u>, <c-y> scroll up a page
<c-f> scroll down a full page
<c-b> scroll up a full page
+ zH scroll all the way left
+ zL scroll all the way right
f activate link hints mode to open in current tab
F activate link hints mode to open in new tab
<a-f> activate link hints mode to open multiple links in a new tab
@@ -50,6 +52,7 @@ Navigating the current page:
yy copy the current url to the clipboard
gu go up one level in the URL hierarchy
gf cycle forward to the next frame
+ gi focus the first (or n-th) text input box on the page
Navigating your history:
H go back in history
@@ -83,14 +86,19 @@ When you're done, send us a pull request on Github. Feel free to include a chang
Release Notes
-------------
-1.20 (Unreleased)
+1.21 (10/24/2010)
+
+- Critical bugfix for an excluded URLs regression due to frame support.
+
+1.20 (10/24/2010)
- In link hints mode, holding down the shift key will now toggle between opening in the current tab and opening in a new tab.
- Two new commands (`zH` and `zL`) to scroll to the left and right edges of the page.
- A new command (`gi`) to focus the first (or n-th) text input box on the page.
- A new command (`<a-f>`) to open up multiple links at a time in new tabs.
- Frame support.
-- Bug fixes.
+- More robust support for non-US keyboard layouts.
+- Numerous bug fixes.
1.19 (06/29/2010)
diff --git a/background_page.html b/background_page.html
index e0c1f3ce..c3c9f952 100644
--- a/background_page.html
+++ b/background_page.html
@@ -1,6 +1,7 @@
<html>
<head>
<script type="text/javascript" src="commands.js"></script>
+<script type="text/javascript" src="lib/clipboard.js"></script>
<script type="text/javascript" charset="utf-8">
// Chromium #15242 will make this XHR request to access the manifest unnecessary.
var manifestRequest = new XMLHttpRequest();
@@ -58,7 +59,6 @@
var portHandlers = {
keyDown: handleKeyDown,
returnScrollPosition: handleReturnScrollPosition,
- isEnabledForUrl: isEnabledForUrl,
getCurrentTabUrl: getCurrentTabUrl,
getZoomLevel: getZoomLevel,
saveZoomLevel: saveZoomLevel,
@@ -74,7 +74,9 @@
registerFrame: registerFrame,
frameFocused: handleFrameFocused,
upgradeNotificationClosed: upgradeNotificationClosed,
- updateScrollPosition: handleUpdateScrollPosition
+ updateScrollPosition: handleUpdateScrollPosition,
+ copyToClipboard: copyToClipboard,
+ isEnabledForUrl: isEnabledForUrl
};
// Event handlers
@@ -133,18 +135,17 @@
/*
* Checks the user's preferences in local storage to determine if Vimium is enabled for the given URL.
*/
- function isEnabledForUrl(args, port) {
- var returnPort = chrome.tabs.connect(port.tab.id, { name: "returnIsEnabledForUrl" });
+ function isEnabledForUrl(request) {
// excludedUrls are stored as a series of URL expressions separated by newlines.
var excludedUrls = (localStorage["excludedUrls"] || "").split("\n");
var isEnabled = true;
for (var i = 0; i < excludedUrls.length; i++) {
// The user can add "*" to the URL which means ".*"
var regexp = new RegExp("^" + excludedUrls[i].replace(/\*/g, ".*") + "$");
- if (args.url.match(regexp))
+ if (request.url.match(regexp))
isEnabled = false;
}
- returnPort.postMessage({ isEnabledForUrl: isEnabled });
+ return { isEnabledForUrl: isEnabled };
}
/*
@@ -252,6 +253,13 @@
}
/*
+ * Copies some data (request.data) to the clipboard.
+ */
+ function copyToClipboard(request) {
+ Clipboard.copy(request.data);
+ }
+
+ /*
* Used by the content scripts to get settings from the local storage.
*/
function getSetting(args, port) {
diff --git a/lib/keyboardUtils.js b/lib/keyboardUtils.js
index 60eb487f..5b8b4c84 100644
--- a/lib/keyboardUtils.js
+++ b/lib/keyboardUtils.js
@@ -44,7 +44,7 @@ function getKeyChar(event) {
// https://bugs.webkit.org/show_bug.cgi?id=19906 for more details.
if ((platform == "Windows" || platform == "Linux") && keyIdentifierCorrectionMap[keyIdentifier]) {
correctedIdentifiers = keyIdentifierCorrectionMap[keyIdentifier];
- keyIdentifier = event.shiftKey ? correctedIdentifiers[1] : correctedIdentifiers[0];
+ keyIdentifier = event.shiftKey ? correctedIdentifiers[0] : correctedIdentifiers[1];
}
var unicodeKeyInHex = "0x" + keyIdentifier.substring(2);
return String.fromCharCode(parseInt(unicodeKeyInHex)).toLowerCase();
diff --git a/linkHints.js b/linkHints.js
index 7593a630..16d6fcbf 100644
--- a/linkHints.js
+++ b/linkHints.js
@@ -208,6 +208,7 @@ function updateLinkHints() {
matchedLink.focus();
// When focusing a textbox, put the selection caret at the end of the textbox's contents.
matchedLink.setSelectionRange(matchedLink.value.length, matchedLink.value.length);
+ deactivateLinkHintsMode();
} else {
// When we're opening the link in the current tab, don't navigate to the selected link immediately;
// we want to give the user some feedback depicting which link they've selected by focusing it.
diff --git a/manifest.json b/manifest.json
index b8203717..fa79b82e 100644
--- a/manifest.json
+++ b/manifest.json
@@ -1,6 +1,6 @@
{
"name": "Vimium",
- "version": "1.19",
+ "version": "1.21",
"description": "The Hacker's Browser. Vimium provides keyboard shortcuts for navigation and control in the spirit of Vim.",
"icons": { "16": "icons/icon16.png",
"48": "icons/icon48.png",
@@ -15,7 +15,7 @@
],
"content_scripts": [
{
- "matches": ["http://*/*", "https://*/*", "file://*/*", "ftp://*/*" ],
+ "matches": ["<all_urls>"],
"js": ["lib/keyboardUtils.js",
"lib/clipboard.js",
"linkHints.js",
diff --git a/vimiumFrontend.js b/vimiumFrontend.js
index 9e9ec87a..1b44aecd 100644
--- a/vimiumFrontend.js
+++ b/vimiumFrontend.js
@@ -47,8 +47,7 @@ function setSetting(args) { settings[args.key] = args.value; }
function initializePreDomReady() {
for (var i in settingsToLoad) { getSetting(settingsToLoad[i]); }
- var isEnabledForUrlPort = chrome.extension.connect({ name: "isEnabledForUrl" });
- isEnabledForUrlPort.postMessage({ url: window.location.toString() });
+ checkIfEnabledForUrl();
var getZoomLevelPort = chrome.extension.connect({ name: "getZoomLevel" });
getZoomLevelPort.postMessage({ domain: window.location.host });
@@ -117,15 +116,6 @@ function initializePreDomReady() {
if (isEnabledForUrl)
setPageZoomLevel(currentZoomLevel);
});
- } else if (port.name == "returnIsEnabledForUrl") {
- port.onMessage.addListener(function(args) {
- isEnabledForUrl = args.isEnabledForUrl;
- if (isEnabledForUrl)
- initializeWhenEnabled();
- else if (HUD.isReady())
- // Quickly hide any HUD we might already be showing, e.g. if we entered insertMode on page load.
- HUD.hide();
- });
} else if (port.name == "returnSetting") {
port.onMessage.addListener(setSetting);
} else if (port.name == "refreshCompletionKeys") {
@@ -141,6 +131,7 @@ function initializePreDomReady() {
*/
function initializeWhenEnabled() {
document.addEventListener("keydown", onKeydown, true);
+ document.addEventListener("keypress", onKeypress, true);
document.addEventListener("focus", onFocusCapturePhase, true);
document.addEventListener("blur", onBlurCapturePhase, true);
enterInsertModeIfElementIsFocused();
@@ -286,7 +277,11 @@ function toggleViewSource() {
}
function copyCurrentUrl() {
- getCurrentUrlHandlers.push(function (url) { Clipboard.copy(url); });
+ // TODO(ilya): When the following bug is fixed, revisit this approach of sending back to the background page
+ // to copy.
+ // http://code.google.com/p/chromium/issues/detail?id=55188
+ //getCurrentUrlHandlers.push(function (url) { Clipboard.copy(url); });
+ getCurrentUrlHandlers.push(function (url) { chrome.extension.sendRequest({ handler: "copyToClipboard", data: url }); });
// TODO(ilya): Convert to sendRequest.
var getCurrentUrlPort = chrome.extension.connect({ name: "getCurrentTabUrl" });
@@ -309,7 +304,7 @@ function toggleViewSourceCallback(url) {
*
* Note that some keys will only register keydown events and not keystroke events, e.g. ESC.
*/
-function onKeydown(event) {
+function onKeypress(event) {
var keyChar = "";
if (linkHintsModeActivated || BookmarkMode.isEnabled())
@@ -317,33 +312,61 @@ function onKeydown(event) {
// Ignore modifier keys by themselves.
if (event.keyCode > 31) {
- keyChar = getKeyChar(event);
+ keyChar = String.fromCharCode(event.charCode);
// Enter insert mode when the user enables the native find interface.
- if (keyChar == "f" && !event.shiftKey && isPrimaryModifierKey(event))
- {
+ if (keyChar == "f" && isPrimaryModifierKey(event)) {
enterInsertMode();
return;
}
+ if (keyChar) {
+ if (findMode) {
+ handleKeyCharForFindMode(keyChar);
+
+ // Don't let the space scroll us if we're searching.
+ if (event.keyCode == keyCodes.space)
+ event.preventDefault();
+ } else if (!insertMode && !findMode) {
+ if (currentCompletionKeys.indexOf(keyChar) != -1) {
+ event.preventDefault();
+ event.stopPropagation();
+ }
+
+ keyPort.postMessage({keyChar:keyChar, frameId:frameId});
+ }
+ }
+ }
+}
+
+function onKeydown(event) {
+ var keyChar = "";
+
+ if (linkHintsModeActivated)
+ return;
+
+ // handle modifiers being pressed.don't handle shiftKey alone (to avoid / being interpreted as ?
+ if (event.metaKey && event.keyCode > 31 || event.ctrlKey && event.keyCode > 31 || event.altKey && event.keyCode > 31) {
+ keyChar = getKeyChar(event);
+
if (keyChar != "") // Again, ignore just modifiers. Maybe this should replace the keyCode > 31 condition.
{
var modifiers = [];
if (event.shiftKey)
- keyChar = keyChar.toUpperCase();
+ keyChar = keyChar.toUpperCase();
if (event.metaKey)
- modifiers.push("m");
+ modifiers.push("m");
if (event.ctrlKey)
- modifiers.push("c");
+ modifiers.push("c");
if (event.altKey)
- modifiers.push("a");
+ modifiers.push("a");
for (var i in modifiers)
- keyChar = modifiers[i] + "-" + keyChar;
+ keyChar = modifiers[i] + "-" + keyChar;
if (modifiers.length > 0 || keyChar.length > 1)
- keyChar = "<" + keyChar + ">";
+ keyChar = "<" + keyChar + ">";
}
}
@@ -354,20 +377,16 @@ function onKeydown(event) {
// Remove focus so the user can't just get himself back into insert mode by typing in the same input box.
if (isEditable(event.srcElement)) { event.srcElement.blur(); }
exitInsertMode();
+
+ // Added to prevent Google Instant from reclaiming the keystroke and putting us back into the search box.
+ // TOOD(ilya): Revisit this. Not sure it's the absolute best approach.
+ event.stopPropagation();
}
}
else if (findMode)
{
if (isEscape(event))
exitFindMode();
- else if (keyChar)
- {
- handleKeyCharForFindMode(keyChar);
-
- // Don't let the space scroll us if we're searching.
- if (event.keyCode == keyCodes.space)
- event.preventDefault();
- }
// Don't let backspace take us back in history.
else if (event.keyCode == keyCodes.backspace || event.keyCode == keyCodes.deleteKey)
{
@@ -383,17 +402,40 @@ function onKeydown(event) {
}
else if (!insertMode && !findMode) {
if (keyChar) {
- if (currentCompletionKeys.indexOf(keyChar) != -1) {
- event.preventDefault();
- event.stopPropagation();
- }
+ if (currentCompletionKeys.indexOf(keyChar) != -1) {
+ event.preventDefault();
+ event.stopPropagation();
+ }
- keyPort.postMessage({keyChar:keyChar, frameId:frameId});
+ keyPort.postMessage({keyChar:keyChar, frameId:frameId});
}
else if (isEscape(event)) {
keyPort.postMessage({keyChar:"<ESC>", frameId:frameId});
}
}
+
+ // Added to prevent propagating this event to other listeners if it's one that'll trigger a Vimium command.
+ // The goal is to avoid the scenario where Google Instant Search uses every keydown event to dump us
+ // back into the search box. As a side effect, this should also prevent overriding by other sites.
+ //
+ // Subject to internationalization issues since we're using keyIdentifier instead of charCode (in keypress).
+ //
+ // TOOD(ilya): Revisit this. Not sure it's the absolute best approach.
+ if (keyChar == "" && !insertMode && currentCompletionKeys.indexOf(getKeyChar(event)) != -1)
+ event.stopPropagation();
+}
+
+function checkIfEnabledForUrl() {
+ var url = window.location.toString();
+
+ chrome.extension.sendRequest({ handler: "isEnabledForUrl", url: url }, function (response) {
+ isEnabledForUrl = response.isEnabledForUrl;
+ if (isEnabledForUrl)
+ initializeWhenEnabled();
+ else if (HUD.isReady())
+ // Quickly hide any HUD we might already be showing, e.g. if we entered insertMode on page load.
+ HUD.hide();
+ });
}
function refreshCompletionKeys(completionKeys) {