mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-30 21:55:31 +00:00
bug 441794: address review comments
This commit is contained in:
parent
0191b34e4c
commit
d5224b9c4e
@ -1,3 +1,4 @@
|
|||||||
|
// -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; js2-basic-offset: 2; js2-skip-preprocessor-directives: t; -*-
|
||||||
/* ***** BEGIN LICENSE BLOCK *****
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
*
|
*
|
||||||
@ -47,6 +48,7 @@ const PANELMODE_BOOKMARKLIST = 4;
|
|||||||
const PANELMODE_SIDEBAR = 5;
|
const PANELMODE_SIDEBAR = 5;
|
||||||
const PANELMODE_TABLIST = 6;
|
const PANELMODE_TABLIST = 6;
|
||||||
const PANELMODE_FULL = 7;
|
const PANELMODE_FULL = 7;
|
||||||
|
const PANELMODE_SHORTCUTS = 8;
|
||||||
|
|
||||||
var BrowserUI = {
|
var BrowserUI = {
|
||||||
_panel : null,
|
_panel : null,
|
||||||
@ -151,7 +153,6 @@ var BrowserUI = {
|
|||||||
getBrowser().addEventListener("DOMLinkAdded", this, true);
|
getBrowser().addEventListener("DOMLinkAdded", this, true);
|
||||||
|
|
||||||
Shortcuts.restore();
|
Shortcuts.restore();
|
||||||
Shortcuts.test();
|
|
||||||
|
|
||||||
Browser.content.addEventListener("overpan", this, false);
|
Browser.content.addEventListener("overpan", this, false);
|
||||||
Browser.content.addEventListener("pan", this, true);
|
Browser.content.addEventListener("pan", this, true);
|
||||||
@ -316,26 +317,47 @@ var BrowserUI = {
|
|||||||
sidebar.left = toolbar.width = container.boxObject.width;
|
sidebar.left = toolbar.width = container.boxObject.width;
|
||||||
sidebar.height = tablist.height = container.boxObject.height - toolbar.boxObject.height;
|
sidebar.height = tablist.height = container.boxObject.height - toolbar.boxObject.height;
|
||||||
|
|
||||||
if (aMode == PANELMODE_URLVIEW || aMode == PANELMODE_SIDEBAR ||
|
function doTheStuff()
|
||||||
aMode == PANELMODE_TABLIST || aMode == PANELMODE_FULL)
|
|
||||||
{
|
{
|
||||||
toolbar.setAttribute("mode", "view");
|
|
||||||
toolbar.top = 0;
|
|
||||||
|
|
||||||
this._edit.hidden = true;
|
this._edit.hidden = true;
|
||||||
this._edit.reallyClosePopup();
|
this._edit.reallyClosePopup();
|
||||||
this._caption.hidden = false;
|
this._caption.hidden = false;
|
||||||
bookmark.hidden = true;
|
}
|
||||||
urllist.hidden = true;
|
|
||||||
|
function viewURL() { toolbar.setAttribute("mode", "view"); }
|
||||||
|
function editURL() { toolbar.setAttribute("mode", "edit"); }
|
||||||
|
|
||||||
|
function showToolbar() { toolbar.top = 0; }
|
||||||
|
function hideToolbar() { toolbar.top = -toolbar.boxobject.height; }
|
||||||
|
|
||||||
|
function showSidebar() { sidebar.left = toolbar.boxObject.width - sidebar.boxObject.width; }
|
||||||
|
function hideSidebar() { sidebar.left = toolbar.boxObject.width; }
|
||||||
|
|
||||||
|
function showTablist() { tablist.left = 0; }
|
||||||
|
function hideTablist() { tablist.left = -tablist.boxObject.width; }
|
||||||
|
|
||||||
|
function showPane(id)
|
||||||
|
{
|
||||||
|
var nodes = container.childNodes;
|
||||||
|
Array.forEach(container.childNodes, function(n)
|
||||||
|
{
|
||||||
|
var nid = n.getAttribute("id");
|
||||||
|
if (nid != "browser")
|
||||||
|
n.hidden = !(nid == id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aMode == PANELMODE_URLVIEW || aMode == PANELMODE_SIDEBAR ||
|
||||||
|
aMode == PANELMODE_TABLIST || aMode == PANELMODE_FULL)
|
||||||
|
{
|
||||||
|
doTheStuff();
|
||||||
|
viewURL();
|
||||||
|
showToolbar();
|
||||||
|
|
||||||
let sidebarTo = toolbar.boxObject.width;
|
|
||||||
let tablistTo = -tablist.boxObject.width;
|
|
||||||
if (aMode == PANELMODE_SIDEBAR || aMode == PANELMODE_FULL)
|
if (aMode == PANELMODE_SIDEBAR || aMode == PANELMODE_FULL)
|
||||||
sidebarTo -= sidebar.boxObject.width;
|
showSidebar();
|
||||||
if (aMode == PANELMODE_TABLIST || aMode == PANELMODE_FULL)
|
if (aMode == PANELMODE_TABLIST || aMode == PANELMODE_FULL)
|
||||||
tablistTo = 0;
|
showTablist();
|
||||||
sidebar.left = sidebarTo;
|
|
||||||
tablist.left = tablistTo;
|
|
||||||
}
|
}
|
||||||
else if (aMode == PANELMODE_URLEDIT) {
|
else if (aMode == PANELMODE_URLEDIT) {
|
||||||
toolbar.setAttribute("mode", "edit");
|
toolbar.setAttribute("mode", "edit");
|
||||||
@ -378,6 +400,19 @@ var BrowserUI = {
|
|||||||
urllist.width = container.boxObject.width;
|
urllist.width = container.boxObject.width;
|
||||||
urllist.height = container.boxObject.height - toolbar.boxObject.height;
|
urllist.height = container.boxObject.height - toolbar.boxObject.height;
|
||||||
}
|
}
|
||||||
|
else if (aMode == PANELMODE_SHORTCUTS) {
|
||||||
|
this._edit.hidden = true;
|
||||||
|
this._edit.reallyClosePopup();
|
||||||
|
this._caption.hidden = false;
|
||||||
|
|
||||||
|
bookmark.hidden = true;
|
||||||
|
urllist.hidden = true;
|
||||||
|
toolbar.top = -toolbar.boxObject.height;
|
||||||
|
sidebar.left = toolbar.boxObject.width;
|
||||||
|
tablist.left = -tablist.boxObject.width;
|
||||||
|
|
||||||
|
document.getElementById("shortcuts-container").hidden = false;
|
||||||
|
}
|
||||||
else if (aMode == PANELMODE_NONE) {
|
else if (aMode == PANELMODE_NONE) {
|
||||||
toolbar.top = -toolbar.boxObject.height;
|
toolbar.top = -toolbar.boxObject.height;
|
||||||
sidebar.left = toolbar.boxObject.width;
|
sidebar.left = toolbar.boxObject.width;
|
||||||
|
@ -66,10 +66,13 @@
|
|||||||
<stringbundleset id="stringbundleset">
|
<stringbundleset id="stringbundleset">
|
||||||
<stringbundle id="bundle_browser" src="chrome://browser/locale/browser.properties"/>
|
<stringbundle id="bundle_browser" src="chrome://browser/locale/browser.properties"/>
|
||||||
<stringbundle id="bundle_brand" src="chrome://branding/locale/brand.properties"/>
|
<stringbundle id="bundle_brand" src="chrome://branding/locale/brand.properties"/>
|
||||||
<stringbundle id="bundle-keys" src="chrome://global/locale/keys.properties"/>
|
<stringbundle id="bundle_keys" src="chrome://global/locale/keys.properties"/>
|
||||||
<stringbundle id="bundle-platformKeys" src="chrome://global-platform/locale/platformKeys.properties"/>
|
<stringbundle id="bundle_platformKeys" src="chrome://global-platform/locale/platformKeys.properties"/>
|
||||||
</stringbundleset>
|
</stringbundleset>
|
||||||
|
|
||||||
|
<!-- if your extension adds a new command, overlay a new string
|
||||||
|
bundle into this set, and the shortcut editor will look in it for a
|
||||||
|
proper name to call the command. -->
|
||||||
<stringbundleset id="shortcut-bundles">
|
<stringbundleset id="shortcut-bundles">
|
||||||
<stringbundle src="chrome://browser/locale/shortcuts.properties"/>
|
<stringbundle src="chrome://browser/locale/shortcuts.properties"/>
|
||||||
</stringbundleset>
|
</stringbundleset>
|
||||||
|
@ -82,7 +82,7 @@ function ShortcutEditor()
|
|||||||
return command in keys && keys[command];
|
return command in keys && keys[command];
|
||||||
}
|
}
|
||||||
|
|
||||||
function findCommandForKey(keySpec)
|
function findKeyForSpec(keySpec)
|
||||||
{
|
{
|
||||||
// TODO: This is a bit simplistic as yet. For example, we should match
|
// TODO: This is a bit simplistic as yet. For example, we should match
|
||||||
// a key with an optional modifier even if that modifier isn't
|
// a key with an optional modifier even if that modifier isn't
|
||||||
@ -98,6 +98,8 @@ function ShortcutEditor()
|
|||||||
keys[i].getAttribute("keycode") == keySpec.keycode)
|
keys[i].getAttribute("keycode") == keySpec.keycode)
|
||||||
return keys[i];
|
return keys[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function addKey(command, keySpec)
|
function addKey(command, keySpec)
|
||||||
@ -114,7 +116,7 @@ function ShortcutEditor()
|
|||||||
var key = findKeyForCommand(command);
|
var key = findKeyForCommand(command);
|
||||||
if (keySpec.exists)
|
if (keySpec.exists)
|
||||||
{
|
{
|
||||||
if (findCommandForKey(keySpec))
|
if (findKeyForSpec(keySpec))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (key)
|
if (key)
|
||||||
@ -306,7 +308,7 @@ function ShortcutEditor()
|
|||||||
// TODO: write some tests
|
// TODO: write some tests
|
||||||
|
|
||||||
// first, we need to look up the right names of the various modifier keys.
|
// first, we need to look up the right names of the various modifier keys.
|
||||||
var platformBundle = document.getElementById("bundle-platformKeys");
|
var platformBundle = document.getElementById("bundle_platformKeys");
|
||||||
function doGetString(n) { try { return platformBundle.getString(n); } catch (ex) { dump(">>"+ex+"\n"); return undefined; } };
|
function doGetString(n) { try { return platformBundle.getString(n); } catch (ex) { dump(">>"+ex+"\n"); return undefined; } };
|
||||||
var platformKeys = {
|
var platformKeys = {
|
||||||
shift: doGetString("VK_SHIFT") || "Shift",
|
shift: doGetString("VK_SHIFT") || "Shift",
|
||||||
@ -344,7 +346,7 @@ function ShortcutEditor()
|
|||||||
return "";
|
return "";
|
||||||
|
|
||||||
var accel = [];
|
var accel = [];
|
||||||
var keybundle = document.getElementById("bundle-keys");
|
var keybundle = document.getElementById("bundle_keys");
|
||||||
|
|
||||||
// this is sorta dumb, but whatever
|
// this is sorta dumb, but whatever
|
||||||
var modifiers = [], i = 1;
|
var modifiers = [], i = 1;
|
||||||
@ -411,11 +413,6 @@ function ShortcutEditor()
|
|||||||
{
|
{
|
||||||
tree = document.getElementById("shortcuts");
|
tree = document.getElementById("shortcuts");
|
||||||
|
|
||||||
var nodes = document.getElementById("browser-container").childNodes;
|
|
||||||
Array.forEach(nodes, function(n) { if (n.getAttribute("id") != "browser-container") n.hidden = true; });
|
|
||||||
document.getElementById("shortcuts-container").hidden = false;
|
|
||||||
fillShortcutList();
|
|
||||||
|
|
||||||
var textbox = document.getAnonymousElementByAttribute(tree, "anonid", "input");
|
var textbox = document.getAnonymousElementByAttribute(tree, "anonid", "input");
|
||||||
textbox.addEventListener("keypress", keyListener, true);
|
textbox.addEventListener("keypress", keyListener, true);
|
||||||
textbox.addEventListener("reset", resetListener, true);
|
textbox.addEventListener("reset", resetListener, true);
|
||||||
@ -522,7 +519,7 @@ function ShortcutEditor()
|
|||||||
this.test = function()
|
this.test = function()
|
||||||
{
|
{
|
||||||
// TODO: write a mochitest .xul file, and add it to the build
|
// TODO: write a mochitest .xul file, and add it to the build
|
||||||
// TODO: test findCommandForKey() and findKeyForCommand()
|
// TODO: test findKeyForSpec() and findKeyForCommand()
|
||||||
function eq(a, b)
|
function eq(a, b)
|
||||||
{
|
{
|
||||||
for (p in a)
|
for (p in a)
|
||||||
@ -556,6 +553,7 @@ function ShortcutEditor()
|
|||||||
[["meta shift alt control", undefined, "VK_A"], {exists: true, modifiers: 15, key: false, keycode: "VK_A"}, "Ctrl+Alt+Meta+Shift+A"],
|
[["meta shift alt control", undefined, "VK_A"], {exists: true, modifiers: 15, key: false, keycode: "VK_A"}, "Ctrl+Alt+Meta+Shift+A"],
|
||||||
[[], {exists: false, modifiers: 0, key: false, keycode: false}, ""],
|
[[], {exists: false, modifiers: 0, key: false, keycode: false}, ""],
|
||||||
[["control"], {exists: false, modifiers: 2, key: false, keycode: false}, ""],
|
[["control"], {exists: false, modifiers: 2, key: false, keycode: false}, ""],
|
||||||
|
[["foobar", "a"], {exists: true, modifiers: 2, key: "a", keycode: false}, "A"],
|
||||||
[["alt", "α"], {exists: true, modifiers: 1, key: "α", keycode: false}, "Alt+Α"],
|
[["alt", "α"], {exists: true, modifiers: 1, key: "α", keycode: false}, "Alt+Α"],
|
||||||
[["alt", "א"], {exists: true, modifiers: 1, key: "א", keycode: false}, "Alt+א"]
|
[["alt", "א"], {exists: true, modifiers: 1, key: "א", keycode: false}, "Alt+א"]
|
||||||
].forEach(function doTests(t)
|
].forEach(function doTests(t)
|
||||||
|
Loading…
Reference in New Issue
Block a user