Bug 333831 - Reimplement click-and-hold access to the back and forward session history menus. r=mconnor, uir=beltzner.

This commit is contained in:
mozilla.mano%sent.com 2006-04-20 22:35:06 +00:00
Родитель 6155ecee0e
Коммит a46dd9fa5d
3 изменённых файлов: 69 добавлений и 4 удалений

Просмотреть файл

@ -119,6 +119,10 @@ var gFormFillEnabled = true;
var gURLBarAutoFillPrefListener = null;
var gAutoHideTabbarPrefListener = null;
#ifdef XP_MACOSX
var gClickAndHoldTimer = null;
#endif
/**
* We can avoid adding multiple load event listeners and save some time by adding
* one listener that calls all real handlers.
@ -195,6 +199,58 @@ function UpdateBackForwardButtons()
}
}
#ifdef XP_MACOSX
/**
* Click-and-Hold implementation for the Back and Forward buttons
* XXXmano: should this live in toolbarbutton.xml?
*/
function ClickAndHoldMouseDownCallback(aButton)
{
aButton.open = true;
gClickAndHoldTimer = null;
}
function ClickAndHoldMouseDown(aEvent)
{
if (aEvent.target.getAttribute("anonid") != "button")
return;
var button = aEvent.target.parentNode.parentNode;
if (!button.disabled)
gClickAndHoldTimer = setTimeout(ClickAndHoldMouseDownCallback, 500, button);
}
function MayStopClickAndHoldTimer(aEvent)
{
// Note passing null here is a no-op
clearTimeout(gClickAndHoldTimer);
}
function SetClickAndHoldHandlers()
{
function _addClickAndHoldListenersOnElement(aElm)
{
aElm.addEventListener("mousedown",
ClickAndHoldMouseDown,
false);
aElm.addEventListener("mouseup",
MayStopClickAndHoldTimer,
false);
aElm.addEventListener("mouseout",
MayStopClickAndHoldTimer,
false);
}
// The click-and-hold area does not include the dropmarkers of the buttons
var backButton = document.getAnonymousElementByAttribute
(document.getElementById("back-button"), "anonid", "button");
var forwardButton = document.getAnonymousElementByAttribute
(document.getElementById("forward-button"), "anonid", "button");
_addClickAndHoldListenersOnElement(backButton);
_addClickAndHoldListenersOnElement(forwardButton);
}
#endif
#ifndef MOZ_PLACES
function UpdateBookmarkAllTabsMenuitem()
{
@ -1015,6 +1071,13 @@ function delayedStartup()
document.getElementById("textfieldDirection-separator").hidden = false;
document.getElementById("textfieldDirection-swap").hidden = false;
}
#ifdef XP_MACOSX
// Setup click-and-hold gestures access to the session history
// menus if global click-and-hold isn't turned on
if (!getBoolPref("ui.click_hold_context_menus", false))
SetClickAndHoldHandlers();
#endif
}
function BrowserShutdown()

Просмотреть файл

@ -163,7 +163,7 @@
<toolbarbutton id="back-button" type="menu-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
chromedir="&locale.dir;"
label="&backCmd.label;"
oncommand="BrowserBack(event)"
oncommand="if (!this.open) BrowserBack(event)"
onclick="checkForMiddleClick(this, event);"
context="backMenu"
tooltiptext="&backButton.tooltip;">
@ -177,7 +177,7 @@
<toolbarbutton id="forward-button" type="menu-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
chromedir="&locale.dir;"
label="&forwardCmd.label;"
oncommand="BrowserForward(event)"
oncommand="if (!this.open) BrowserForward(event)"
onclick="checkForMiddleClick(this, event);"
context="forwardMenu"
tooltiptext="&forwardButton.tooltip;">

Просмотреть файл

@ -274,7 +274,8 @@ menubutton:not([disabled="true"]):hover:active {
#back-button {
-moz-image-region: rect(0px 32px 32px 0px);
}
#back-button[buttondown="true"] {
#back-button[buttondown="true"],
#back-button[open="true"] {
-moz-image-region: rect(32px 32px 64px 0px);
}
#back-button[disabled="true"] {
@ -284,7 +285,8 @@ menubutton:not([disabled="true"]):hover:active {
#forward-button {
-moz-image-region: rect(0px 64px 32px 32px);
}
#forward-button[buttondown="true"] {
#forward-button[buttondown="true"],
#forward-button[open="true"] {
-moz-image-region: rect(32px 64px 64px 32px);
}
#forward-button[disabled="true"] {