aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/mouseevent.rs
diff options
context:
space:
mode:
authorbors-servo <metajack+bors@gmail.com>2014-11-13 10:57:33 -0700
committerbors-servo <metajack+bors@gmail.com>2014-11-13 10:57:33 -0700
commit2ffa845cf463b14b19322d477a77ffd20efa89a9 (patch)
tree64428ac6615df95fabb298f0aeb274fc10f947c7 /components/script/dom/mouseevent.rs
parentc5e1b0d32e17fad29799023c85e2e73ac89c3af7 (diff)
parentc23edf6f5a020f24008c84957c1a290241632c6d (diff)
downloadservo-2ffa845cf463b14b19322d477a77ffd20efa89a9.tar.gz
servo-2ffa845cf463b14b19322d477a77ffd20efa89a9.zip
auto merge of #3585 : jdm/servo/input, r=gw
This attempts to implement a bunch of the DOM Level 3 Events spec by implementing the KeyboardEvent interface, the document focus context, and dispatching keyup/keydown/keypress events appropriately. There's also some support for multiline text input that's untested.
Diffstat (limited to 'components/script/dom/mouseevent.rs')
-rw-r--r--components/script/dom/mouseevent.rs26
1 files changed, 15 insertions, 11 deletions
diff --git a/components/script/dom/mouseevent.rs b/components/script/dom/mouseevent.rs
index a4d3a0a9e09..81d23bf8afb 100644
--- a/components/script/dom/mouseevent.rs
+++ b/components/script/dom/mouseevent.rs
@@ -5,7 +5,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::{UIEventCast, MouseEventDerived};
+use dom::bindings::codegen::InheritTypes::{EventCast, UIEventCast, MouseEventDerived};
use dom::bindings::error::Fallible;
use dom::bindings::global::GlobalRef;
use dom::bindings::global;
@@ -21,7 +21,7 @@ use std::default::Default;
#[dom_struct]
pub struct MouseEvent {
- mouseevent: UIEvent,
+ uievent: UIEvent,
screen_x: Cell<i32>,
screen_y: Cell<i32>,
client_x: Cell<i32>,
@@ -43,7 +43,7 @@ impl MouseEventDerived for Event {
impl MouseEvent {
fn new_inherited() -> MouseEvent {
MouseEvent {
- mouseevent: UIEvent::new_inherited(MouseEventTypeId),
+ uievent: UIEvent::new_inherited(MouseEventTypeId),
screen_x: Cell::new(0),
screen_y: Cell::new(0),
client_x: Cell::new(0),
@@ -91,13 +91,13 @@ impl MouseEvent {
type_: DOMString,
init: &MouseEventBinding::MouseEventInit) -> Fallible<Temporary<MouseEvent>> {
let event = MouseEvent::new(global.as_window(), type_,
- init.parent.parent.bubbles,
- init.parent.parent.cancelable,
- init.parent.view.root_ref(),
- init.parent.detail,
+ init.parent.parent.parent.bubbles,
+ init.parent.parent.parent.cancelable,
+ init.parent.parent.view.root_ref(),
+ init.parent.parent.detail,
init.screenX, init.screenY,
- init.clientX, init.clientY, init.ctrlKey,
- init.altKey, init.shiftKey, init.metaKey,
+ init.clientX, init.clientY, init.parent.ctrlKey,
+ init.parent.altKey, init.parent.shiftKey, init.parent.metaKey,
init.button, init.relatedTarget.root_ref());
Ok(event)
}
@@ -160,6 +160,11 @@ impl<'a> MouseEventMethods for JSRef<'a, MouseEvent> {
metaKeyArg: bool,
buttonArg: i16,
relatedTargetArg: Option<JSRef<EventTarget>>) {
+ let event: JSRef<Event> = EventCast::from_ref(self);
+ if event.dispatching() {
+ return;
+ }
+
let uievent: JSRef<UIEvent> = UIEventCast::from_ref(self);
uievent.InitUIEvent(typeArg, canBubbleArg, cancelableArg, viewArg, detailArg);
self.screen_x.set(screenXArg);
@@ -175,9 +180,8 @@ impl<'a> MouseEventMethods for JSRef<'a, MouseEvent> {
}
}
-
impl Reflectable for MouseEvent {
fn reflector<'a>(&'a self) -> &'a Reflector {
- self.mouseevent.reflector()
+ self.uievent.reflector()
}
}