mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-22 09:45:41 +00:00
servo: Merge #6691 - Implement mouseevent.which (needed for enyojs sampler) (from glennw:mouse-which); r=jdm
Source-Repo: https://github.com/servo/servo Source-Revision: ff86e0094cc4d65c5690a9df8e6996c49f9f076f
This commit is contained in:
parent
4014fa34d1
commit
614344b835
@ -647,12 +647,13 @@ impl<'a> DocumentHelpers<'a> for &'a Document {
|
||||
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#event-type-click
|
||||
let x = point.x as i32;
|
||||
let y = point.y as i32;
|
||||
let clickCount = 1;
|
||||
let event = MouseEvent::new(window.r(),
|
||||
mouse_event_type_string,
|
||||
EventBubbles::Bubbles,
|
||||
EventCancelable::Cancelable,
|
||||
Some(window.r()),
|
||||
0i32,
|
||||
clickCount,
|
||||
x, y, x, y,
|
||||
false, false, false, false,
|
||||
0i16,
|
||||
|
@ -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
|
||||
|
@ -45,7 +45,7 @@ use euclid::rect::Rect;
|
||||
/// The address of a node. Layout sends these back. They must be validated via
|
||||
/// `from_untrusted_node_address` before they can be used, because we do not trust layout.
|
||||
#[allow(raw_pointer_derive)]
|
||||
#[derive(Copy, Clone)]
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub struct UntrustedNodeAddress(pub *const c_void);
|
||||
unsafe impl Send for UntrustedNodeAddress {}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user