Skip to content

Commit

Permalink
This fixes #4259. Dispatching the mousemove event for the top most no…
Browse files Browse the repository at this point in the history
…de when the mouse moves while on top of it
  • Loading branch information
mattnenterprise committed Dec 23, 2014
1 parent b83b493 commit 75be44e
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions components/script/script_task.rs
Expand Up @@ -23,6 +23,7 @@ use dom::event::{Event, EventHelpers, EventBubbles, EventCancelable};
use dom::uievent::UIEvent;
use dom::eventtarget::{EventTarget, EventTargetHelpers};
use dom::keyboardevent::KeyboardEvent;
use dom::mouseevent::MouseEvent;
use dom::node::{mod, Node, NodeHelpers, NodeDamage, NodeTypeId};
use dom::window::{Window, WindowHelpers};
use dom::worker::{Worker, TrustedWorkerAddress};
Expand Down Expand Up @@ -1168,6 +1169,33 @@ impl ScriptTask {
None => {}
}

if node_address.len() > 0 {
let top_most_node =
node::from_untrusted_node_address(self.js_runtime.ptr, node_address[0]).root();

if let Some(ref frame) = *page.frame() {
let window = frame.window.root();

let x = point.x.to_i32().unwrap_or(0);
let y = point.y.to_i32().unwrap_or(0);

let mouse_event = MouseEvent::new(*window,
"mousemove".to_string(),
true,
true,
Some(*window),
0i32,
x, y, x, y,
false, false, false, false,
0i16,
None).root();

let event: JSRef<Event> = EventCast::from_ref(*mouse_event);
let target: JSRef<EventTarget> = EventTargetCast::from_ref(*top_most_node);
target.dispatch_event(event);
}
}

for node_address in node_address.iter() {
let temp_node =
node::from_untrusted_node_address(self.js_runtime.ptr, *node_address);
Expand Down

5 comments on commit 75be44e

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from jdm
at mattnenterprise@75be44e

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging mattnenterprise/servo/dispatch-mousemove = 75be44e into auto

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mattnenterprise/servo/dispatch-mousemove = 75be44e merged ok, testing candidate = fb59e79

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = fb59e79

Please sign in to comment.