mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Implement mouseevent.which (needed for enyojs sampler).
This commit is contained in:
parent
2a2c7e18c0
commit
2e074ce452
3 changed files with 18 additions and 1 deletions
|
@ -6,6 +6,7 @@ use dom::bindings::codegen::Bindings::MouseEventBinding;
|
|||
use dom::bindings::codegen::Bindings::MouseEventBinding::MouseEventMethods;
|
||||
use dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods;
|
||||
use dom::bindings::codegen::InheritTypes::{EventCast, UIEventCast, MouseEventDerived};
|
||||
use dom::bindings::error::Error::NotSupported;
|
||||
use dom::bindings::error::Fallible;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JS, MutNullableHeap, Root, RootedReference};
|
||||
|
@ -14,6 +15,7 @@ use dom::event::{Event, EventTypeId, EventBubbles, EventCancelable};
|
|||
use dom::eventtarget::EventTarget;
|
||||
use dom::uievent::UIEvent;
|
||||
use dom::window::Window;
|
||||
use util::opts;
|
||||
use util::str::DOMString;
|
||||
use std::cell::Cell;
|
||||
use std::default::Default;
|
||||
|
@ -154,6 +156,18 @@ impl<'a> MouseEventMethods for &'a MouseEvent {
|
|||
self.related_target.get().map(Root::from_rooted)
|
||||
}
|
||||
|
||||
// See discussion at:
|
||||
// - https://github.com/servo/servo/issues/6643
|
||||
// - https://bugzilla.mozilla.org/show_bug.cgi?id=1186125
|
||||
// This returns the same result as current gecko.
|
||||
fn GetWhich(self) -> Fallible<i32> {
|
||||
if opts::experimental_enabled() {
|
||||
Ok((self.button.get() + 1) as i32)
|
||||
} else {
|
||||
Err(NotSupported)
|
||||
}
|
||||
}
|
||||
|
||||
fn InitMouseEvent(self,
|
||||
typeArg: DOMString,
|
||||
canBubbleArg: bool,
|
||||
|
|
|
@ -19,6 +19,9 @@ interface MouseEvent : UIEvent {
|
|||
// Introduced in DOM Level 3
|
||||
//readonly attribute unsigned short buttons;
|
||||
//boolean getModifierState (DOMString keyArg);
|
||||
|
||||
[Throws]
|
||||
readonly attribute long which;
|
||||
};
|
||||
|
||||
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#idl-def-MouseEventInit
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue