зеркало из https://github.com/mozilla/pjs.git
Bug 335675 - Shortcomings of the click-and-hold implementation of bug 333831. patch from Simon Bnzli <zeniko@gmail.com>, r=me.
This commit is contained in:
Родитель
89257db6ee
Коммит
a5febf48d8
|
@ -216,10 +216,11 @@ function ClickAndHoldMouseDownCallback(aButton)
|
||||||
|
|
||||||
function ClickAndHoldMouseDown(aEvent)
|
function ClickAndHoldMouseDown(aEvent)
|
||||||
{
|
{
|
||||||
if (aEvent.target.getAttribute("anonid") != "button")
|
if (aEvent.button != 0 || aEvent.target.getAttribute("anonid") != "button")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var button = aEvent.target.parentNode.parentNode;
|
// relying on button.xml#menu-button-base internals for improved theme compatibility
|
||||||
|
var button = aEvent.target._menubuttonParent;
|
||||||
if (!button.disabled)
|
if (!button.disabled)
|
||||||
gClickAndHoldTimer = setTimeout(ClickAndHoldMouseDownCallback, 500, button);
|
gClickAndHoldTimer = setTimeout(ClickAndHoldMouseDownCallback, 500, button);
|
||||||
}
|
}
|
||||||
|
@ -230,6 +231,12 @@ function MayStopClickAndHoldTimer(aEvent)
|
||||||
clearTimeout(gClickAndHoldTimer);
|
clearTimeout(gClickAndHoldTimer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ClickAndHoldStopEvent(aEvent)
|
||||||
|
{
|
||||||
|
if (aEvent.target._menubuttonParent.open)
|
||||||
|
aEvent.stopPropagation();
|
||||||
|
}
|
||||||
|
|
||||||
function SetClickAndHoldHandlers()
|
function SetClickAndHoldHandlers()
|
||||||
{
|
{
|
||||||
function _addClickAndHoldListenersOnElement(aElm)
|
function _addClickAndHoldListenersOnElement(aElm)
|
||||||
|
@ -243,15 +250,26 @@ function SetClickAndHoldHandlers()
|
||||||
aElm.addEventListener("mouseout",
|
aElm.addEventListener("mouseout",
|
||||||
MayStopClickAndHoldTimer,
|
MayStopClickAndHoldTimer,
|
||||||
false);
|
false);
|
||||||
|
|
||||||
|
// don't propagate onclick and oncommand events after
|
||||||
|
// click-and-hold opened the drop-down menu
|
||||||
|
aElm.addEventListener("command",
|
||||||
|
ClickAndHoldStopEvent,
|
||||||
|
false);
|
||||||
|
aElm.addEventListener("click",
|
||||||
|
ClickAndHoldStopEvent,
|
||||||
|
false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The click-and-hold area does not include the dropmarkers of the buttons
|
// The click-and-hold area does not include the dropmarkers of the buttons
|
||||||
var backButton = document.getAnonymousElementByAttribute
|
var backButton = document.getAnonymousElementByAttribute
|
||||||
(document.getElementById("back-button"), "anonid", "button");
|
(document.getElementById("back-button"), "anonid", "button");
|
||||||
|
if (backButton)
|
||||||
|
_addClickAndHoldListenersOnElement(backButton);
|
||||||
var forwardButton = document.getAnonymousElementByAttribute
|
var forwardButton = document.getAnonymousElementByAttribute
|
||||||
(document.getElementById("forward-button"), "anonid", "button");
|
(document.getElementById("forward-button"), "anonid", "button");
|
||||||
_addClickAndHoldListenersOnElement(backButton);
|
if (forwardButton)
|
||||||
_addClickAndHoldListenersOnElement(forwardButton);
|
_addClickAndHoldListenersOnElement(forwardButton);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -3296,6 +3314,12 @@ function BrowserToolboxCustomizeDone(aToolboxChanged)
|
||||||
document.getElementById("Browser:Reload").getAttribute("disabled") == "true";
|
document.getElementById("Browser:Reload").getAttribute("disabled") == "true";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef XP_MACOSX
|
||||||
|
// make sure to re-enable click-and-hold
|
||||||
|
if (!getBoolPref("ui.click_hold_context_menus", false))
|
||||||
|
SetClickAndHoldHandlers();
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef MOZ_PLACES
|
#ifndef MOZ_PLACES
|
||||||
// fix up the personal toolbar folder
|
// fix up the personal toolbar folder
|
||||||
var bt = document.getElementById("bookmarks-ptf");
|
var bt = document.getElementById("bookmarks-ptf");
|
||||||
|
|
|
@ -163,7 +163,7 @@
|
||||||
<toolbarbutton id="back-button" type="menu-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
|
<toolbarbutton id="back-button" type="menu-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
|
||||||
chromedir="&locale.dir;"
|
chromedir="&locale.dir;"
|
||||||
label="&backCmd.label;"
|
label="&backCmd.label;"
|
||||||
oncommand="if (!this.open) BrowserBack(event)"
|
oncommand="BrowserBack(event)"
|
||||||
onclick="checkForMiddleClick(this, event);"
|
onclick="checkForMiddleClick(this, event);"
|
||||||
context="backMenu"
|
context="backMenu"
|
||||||
tooltiptext="&backButton.tooltip;">
|
tooltiptext="&backButton.tooltip;">
|
||||||
|
@ -177,7 +177,7 @@
|
||||||
<toolbarbutton id="forward-button" type="menu-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
|
<toolbarbutton id="forward-button" type="menu-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
|
||||||
chromedir="&locale.dir;"
|
chromedir="&locale.dir;"
|
||||||
label="&forwardCmd.label;"
|
label="&forwardCmd.label;"
|
||||||
oncommand="if (!this.open) BrowserForward(event)"
|
oncommand="BrowserForward(event)"
|
||||||
onclick="checkForMiddleClick(this, event);"
|
onclick="checkForMiddleClick(this, event);"
|
||||||
context="forwardMenu"
|
context="forwardMenu"
|
||||||
tooltiptext="&forwardButton.tooltip;">
|
tooltiptext="&forwardButton.tooltip;">
|
||||||
|
|
Загрузка…
Ссылка в новой задаче