mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-22 02:09:28 +00:00
Bug 1090906, no context menu when pointer is locked, r=masayuki
This commit is contained in:
parent
f4f29192d3
commit
b840ddbb12
@ -529,6 +529,11 @@ EventStateManager::PreHandleEvent(nsPresContext* aPresContext,
|
||||
WheelTransaction::OnEvent(aEvent);
|
||||
|
||||
switch (aEvent->message) {
|
||||
case NS_CONTEXTMENU:
|
||||
if (sIsPointerLocked) {
|
||||
return NS_ERROR_DOM_INVALID_STATE_ERR;
|
||||
}
|
||||
break;
|
||||
case NS_MOUSE_BUTTON_DOWN: {
|
||||
switch (mouseEvent->button) {
|
||||
case WidgetMouseEvent::eLeftButton:
|
||||
@ -1273,8 +1278,11 @@ EventStateManager::CreateClickHoldTimer(nsPresContext* inPresContext,
|
||||
nsIFrame* inDownFrame,
|
||||
WidgetGUIEvent* inMouseDownEvent)
|
||||
{
|
||||
if (!inMouseDownEvent->mFlags.mIsTrusted || IsRemoteTarget(mGestureDownContent))
|
||||
if (!inMouseDownEvent->mFlags.mIsTrusted ||
|
||||
IsRemoteTarget(mGestureDownContent) ||
|
||||
sIsPointerLocked) {
|
||||
return;
|
||||
}
|
||||
|
||||
// just to be anal (er, safe)
|
||||
if (mClickHoldTimer) {
|
||||
@ -1356,7 +1364,7 @@ EventStateManager::sClickHoldCallback(nsITimer* aTimer, void* aESM)
|
||||
void
|
||||
EventStateManager::FireContextClick()
|
||||
{
|
||||
if (!mGestureDownContent || !mPresContext) {
|
||||
if (!mGestureDownContent || !mPresContext || sIsPointerLocked) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,7 @@
|
||||
pointerLockElement = false,
|
||||
hasMovementX = false,
|
||||
hasMovementY = false;
|
||||
gotContextMenuEvent = false;
|
||||
|
||||
function runTests () {
|
||||
ok(hasRequestPointerLock, "Element should have mozRequestPointerLock.");
|
||||
@ -44,6 +45,7 @@
|
||||
ok(pointerLockElement, "Document should keep track of correct pointer locked element");
|
||||
ok(hasMovementX, "Mouse Event should have mozMovementX.");
|
||||
ok(hasMovementY, "Mouse Event should have mozMovementY.");
|
||||
ok(!gotContextMenuEvent, "Shouldn't have got a contextmenu event.");
|
||||
}
|
||||
|
||||
function mouseMoveHandler(e) {
|
||||
@ -62,6 +64,14 @@
|
||||
if (document.mozPointerLockElement) {
|
||||
pointerLocked = true;
|
||||
pointerLockElement = document.mozPointerLockElement === div;
|
||||
|
||||
window.addEventListener("contextmenu",
|
||||
function() { gotContextMenuEvent = true; },
|
||||
true);
|
||||
synthesizeMouse(document.body, 4, 4,
|
||||
{ type: "contextmenu", button: 2 },
|
||||
window);
|
||||
|
||||
document.addEventListener("mousemove", mouseMoveHandler, false);
|
||||
synthesizeMouseAtCenter(div, {type: "mousemove"}, window);
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user