Closed
Bug 258193
Opened 20 years ago
Closed 20 years ago
nsIDOMMouseEvent::GetButton() broken with contextmenu event
Categories
(Core :: DOM: Events, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: crispin, Assigned: jwkbugzilla)
References
Details
Attachments
(1 file, 1 obsolete file)
1.58 KB,
patch
|
jst
:
review+
bzbarsky
:
superreview+
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8a3) Gecko/20040903 Galeon/1.3.17.99
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8a3) Gecko/20040903 Galeon/1.3.17.99
If you capture a contextmenu event, using the nsIDOMContextMenuListener
interface, and then call do:
PRUint16 btn;
rv = aMouseEvent->GetButton (&btn);
NS_ENSURE_SUCCESS (rv, rv);
the GetButton() call succeeds, but btn isn't initialized. I believe this is
because |mEvent->message| is NS_CONTEXTMENU, which isn't handled in the switch
statement.
Reproducible: Always
Steps to Reproduce:
Comment 1•20 years ago
|
||
Wladimir, do you have time for this one?
Assignee | ||
Comment 2•20 years ago
|
||
NS_CONTEXTMENU could be created by a keyboard action, so we can't return a
mouse button here (unless changes are made in the event creation code, which
shouldn't be worth it). I made GetButton() return -1 for mouse events that
don't have a mouse button associated with them (e.g. NS_MOUSE_MOVE). Decided
that we don't need a warning here, for mouse events this call should be always
legal. Fixed the wrong mButton check while there, but mButton is never used
anyway.
Assignee | ||
Updated•20 years ago
|
Assignee: events → trev
Status: UNCONFIRMED → ASSIGNED
Reporter | ||
Comment 3•20 years ago
|
||
Won't this make the (mouse generated) NS_CONTEXTMENU event have a mouse button
of -1 ? I would assume that it should be 2 (as it was generated by a right mouse
button) ?
Assignee | ||
Updated•20 years ago
|
Attachment #158089 -
Flags: review?(jst)
Assignee | ||
Comment 4•20 years ago
|
||
Just saw it - keyboard generated context menu events produce
NS_CONTEXTMENU_KEY, not NS_CONTEXTMENU. Looking through the plattform specific
code it seems to be safe to assume, that NS_CONTEXTMENU has been triggered by
the right mouse button (even on MacOS).
Attachment #158089 -
Attachment is obsolete: true
Assignee | ||
Updated•20 years ago
|
Attachment #158089 -
Flags: review?(jst)
Assignee | ||
Updated•20 years ago
|
Attachment #158091 -
Flags: review?(jst)
Comment 5•20 years ago
|
||
Comment on attachment 158091 [details] [diff] [review]
Patch (mouse button set to 2 for NS_CONTEXTMENU now)
Seems reasonable to me. r=jst
Bz, what say you?
Attachment #158091 -
Flags: superreview?(bzbarsky)
Attachment #158091 -
Flags: review?(jst)
Attachment #158091 -
Flags: review+
Comment 6•20 years ago
|
||
Comment on attachment 158091 [details] [diff] [review]
Patch (mouse button set to 2 for NS_CONTEXTMENU now)
sr=bzbarsky. Seems ok.
Attachment #158091 -
Flags: superreview?(bzbarsky) → superreview+
Checking in nsDOMMouseEvent.cpp;
/cvsroot/mozilla/content/events/src/nsDOMMouseEvent.cpp,v <-- nsDOMMouseEvent.cpp
new revision: 1.4; previous revision: 1.3
done
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Comment 8•20 years ago
|
||
When I have this: document.onmousemove=function(e){window.status=e.button;}
then I get before this fix: 0 , after this fix: 65535
So the former behavior is wrong and the latter behavior is right, then?
Comment 9•20 years ago
|
||
> So the former behavior is wrong and the latter behavior is right, then?
The behavior of .button for non-button-related events like mousemove is undefined...
Comment 10•20 years ago
|
||
Ok, does the same for apply e.which?
document.onmousemove=function(e){window.status=e.which;}
Before the fix returns 19, after the fix 65536.
Comment 11•20 years ago
|
||
That seems odd... which should be button + 1. That is, the 65536 is "correct",
but the 19 confuses me... Or rather, it shouldn't have been consistently 19.
It should have been a random number...
Comment 12•19 years ago
|
||
I don't understand what this patch actually fixed.
Do we have a testcase for this?
This patch actually broke backwards compatibility with other browsers in the mouse move case.
Comment 13•19 years ago
|
||
Incidentally, it was consistenly 19 in a release build, random in a debug build.
Comment 14•19 years ago
|
||
And incidentally it is wrong to hardcode context menu to 2 - what if a platform displays the context menu using a different button?
Depends on: 297919
You need to log in
before you can comment on or make changes to this bug.
Description
•