Bug 395426, Contextmenu opened using keyboard should have .button == 0, r=enndeakin,sr+a=jst

This commit is contained in:
Olli.Pettay@helsinki.fi 2007-09-18 00:25:49 -07:00
parent cd16ec9fa2
commit ae89765af6
6 changed files with 17 additions and 8 deletions

View File

@ -708,6 +708,7 @@ NS_METHOD nsDOMEvent::DuplicatePrivateData()
isInputEvent = PR_TRUE;
mouseEvent->clickCount = oldMouseEvent->clickCount;
mouseEvent->acceptActivation = oldMouseEvent->acceptActivation;
mouseEvent->context = oldMouseEvent->context;
mouseEvent->relatedTarget = oldMouseEvent->relatedTarget;
mouseEvent->button = oldMouseEvent->button;
newEvent = mouseEvent;

View File

@ -198,6 +198,7 @@ nsDOMWindowUtils::SendMouseEvent(const nsAString& aType,
return NS_ERROR_FAILURE;
PRInt32 msg;
PRBool contextMenuKey = PR_FALSE;
if (aType.EqualsLiteral("mousedown"))
msg = NS_MOUSE_BUTTON_DOWN;
else if (aType.EqualsLiteral("mouseup"))
@ -208,12 +209,15 @@ nsDOMWindowUtils::SendMouseEvent(const nsAString& aType,
msg = NS_MOUSE_ENTER;
else if (aType.EqualsLiteral("mouseout"))
msg = NS_MOUSE_EXIT;
else if (aType.EqualsLiteral("contextmenu"))
else if (aType.EqualsLiteral("contextmenu")) {
msg = NS_CONTEXTMENU;
else
contextMenuKey = (aButton == 0);
} else
return NS_ERROR_FAILURE;
nsMouseEvent event(PR_TRUE, msg, widget, nsMouseEvent::eReal);
nsMouseEvent event(PR_TRUE, msg, widget, nsMouseEvent::eReal,
contextMenuKey ?
nsMouseEvent::eContextMenuKey : nsMouseEvent::eNormal);
event.isShift = (aModifiers & nsIDOMNSEvent::SHIFT_MASK) ? PR_TRUE : PR_FALSE;
event.isControl = (aModifiers & nsIDOMNSEvent::CONTROL_MASK) ? PR_TRUE : PR_FALSE;
event.isAlt = (aModifiers & nsIDOMNSEvent::ALT_MASK) ? PR_TRUE : PR_FALSE;

View File

@ -645,12 +645,14 @@ public:
if (msg == NS_MOUSE_MOVE) {
flags |= NS_EVENT_FLAG_CANT_CANCEL;
} else if (msg == NS_CONTEXTMENU) {
button = eRightButton;
button = (context == eNormal) ? eRightButton : eLeftButton;
}
}
#ifdef NS_DEBUG
~nsMouseEvent() {
NS_WARN_IF_FALSE(message != NS_CONTEXTMENU || button == eRightButton,
NS_WARN_IF_FALSE(message != NS_CONTEXTMENU ||
button ==
((context == eNormal) ? eRightButton : eLeftButton),
"Wrong button set to NS_CONTEXTMENU event?");
}
#endif

View File

@ -4902,7 +4902,7 @@ key_event_to_context_menu_event(const nsKeyEvent* aKeyEvent,
aCMEvent->eventStructType = NS_MOUSE_EVENT;
aCMEvent->message = NS_CONTEXTMENU;
aCMEvent->context = nsMouseEvent::eContextMenuKey;
aCMEvent->button = nsMouseEvent::eRightButton;
aCMEvent->button = nsMouseEvent::eLeftButton;
aCMEvent->isShift = aCMEvent->isControl = PR_FALSE;
aCMEvent->isAlt = aCMEvent->isMeta = PR_FALSE;
aCMEvent->clickCount = 0;

View File

@ -2755,7 +2755,7 @@ PRBool nsWindow::ProcessMessage( ULONG msg, MPARAM mp1, MPARAM mp2, MRESULT &rc)
WinSendMsg(hwndCurrFocus, msg, mp1, mp2);
} else {
result = DispatchMouseEvent(NS_CONTEXTMENU, mp1, mp2, PR_TRUE,
nsMouseEvent::eRightButton);
nsMouseEvent::eLeftButton);
}
} else {
result = DispatchMouseEvent(NS_CONTEXTMENU, mp1, mp2, PR_FALSE,

View File

@ -4510,7 +4510,9 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
pos = lParamToClient(lParam);
}
result = DispatchMouseEvent(NS_CONTEXTMENU, wParam, pos, contextMenukey,
nsMouseEvent::eRightButton);
contextMenukey ?
nsMouseEvent::eLeftButton :
nsMouseEvent::eRightButton);
}
break;