mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-09 04:25:38 +00:00
Bug 922934 - Hide Metro context menus on touchstart, scroll, or mousedown [r=emtwo]
This commit is contained in:
parent
c501c2ae3e
commit
3c3cb50855
@ -432,9 +432,10 @@ MenuPopup.prototype = {
|
||||
let deferred = Promise.defer();
|
||||
|
||||
window.addEventListener("keypress", this, true);
|
||||
window.addEventListener("click", this, true);
|
||||
window.addEventListener("mousedown", this, true);
|
||||
window.addEventListener("touchstart", this, true);
|
||||
window.addEventListener("scroll", this, true);
|
||||
Elements.stack.addEventListener("PopupChanged", this, false);
|
||||
Elements.browsers.addEventListener("PanBegin", this, false);
|
||||
|
||||
this._panel.hidden = false;
|
||||
let popupFrom = !aPositionOptions.bottomAligned ? "above" : "below";
|
||||
@ -461,9 +462,10 @@ MenuPopup.prototype = {
|
||||
let deferred = Promise.defer();
|
||||
|
||||
window.removeEventListener("keypress", this, true);
|
||||
window.removeEventListener("click", this, true);
|
||||
window.removeEventListener("mousedown", this, true);
|
||||
window.removeEventListener("touchstart", this, true);
|
||||
window.removeEventListener("scroll", this, true);
|
||||
Elements.stack.removeEventListener("PopupChanged", this, false);
|
||||
Elements.browsers.removeEventListener("PanBegin", this, false);
|
||||
|
||||
let self = this;
|
||||
this._panel.addEventListener("transitionend", function popuphidden() {
|
||||
@ -499,7 +501,9 @@ MenuPopup.prototype = {
|
||||
this.hide();
|
||||
}
|
||||
break;
|
||||
case "click":
|
||||
case "mousedown":
|
||||
case "touchstart":
|
||||
case "scroll":
|
||||
if (!this._popup.contains(aEvent.target)) {
|
||||
aEvent.stopPropagation();
|
||||
this.hide();
|
||||
@ -517,9 +521,6 @@ MenuPopup.prototype = {
|
||||
this.hide();
|
||||
}
|
||||
break;
|
||||
case "PanBegin":
|
||||
this.hide();
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -98,9 +98,11 @@ gTests.push({
|
||||
"context-copy-link"]);
|
||||
|
||||
promise = waitForEvent(document, "popuphidden");
|
||||
ContextMenuUI.hide();
|
||||
yield promise;
|
||||
win.scrollBy(0, 1);
|
||||
let hidden = yield promise;
|
||||
ok(hidden && !(hidden instanceof Error), "scrolling hides the context menu");
|
||||
win.getSelection().removeAllRanges();
|
||||
win.scrollBy(0, -1);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Context menu in content on a link
|
||||
|
@ -23,8 +23,8 @@
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<div style="margin: 0; padding: 5px;">
|
||||
<div style="margin: 0; padding: 5px; margin-bottom: 9999px;">
|
||||
<span id="text4">hello, I'm sorry but I must be going.</span>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
@ -91,6 +91,7 @@ gTests.push({
|
||||
tearDown: setUpAndTearDown,
|
||||
run: function test() {
|
||||
gInput.selectionStart = gInput.selectionEnd = gInput.value.length;
|
||||
yield waitForEvent(window, "scroll");
|
||||
|
||||
let promise = waitForEvent(document, "popupshown");
|
||||
sendContextMenuClick(190, 17);
|
||||
@ -137,6 +138,7 @@ gTests.push({
|
||||
tearDown: setUpAndTearDown,
|
||||
run: function test() {
|
||||
gInput.selectionStart = gInput.selectionEnd = 0;
|
||||
yield waitForEvent(window, "scroll");
|
||||
|
||||
let promise = waitForEvent(document, "popupshown");
|
||||
sendContextMenuClick(230, 17);
|
||||
|
Loading…
x
Reference in New Issue
Block a user