mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Introduce a MouseButton enum.
This commit is contained in:
parent
85808c1cdd
commit
6b127a8df8
16 changed files with 57 additions and 20 deletions
|
@ -13,6 +13,7 @@ use layers::geometry::DevicePixel;
|
|||
use layers::platform::surface::NativeGraphicsMetadata;
|
||||
use msg::compositor_msg::{PaintState, ReadyState};
|
||||
use msg::constellation_msg::{Key, KeyState, KeyModifiers};
|
||||
use script_traits::MouseButton;
|
||||
use url::Url;
|
||||
use util::cursor::Cursor;
|
||||
use util::geometry::ScreenPx;
|
||||
|
@ -21,9 +22,9 @@ use std::rc::Rc;
|
|||
|
||||
#[derive(Clone)]
|
||||
pub enum MouseWindowEvent {
|
||||
Click(uint, TypedPoint2D<DevicePixel, f32>),
|
||||
MouseDown(uint, TypedPoint2D<DevicePixel, f32>),
|
||||
MouseUp(uint, TypedPoint2D<DevicePixel, f32>),
|
||||
Click(MouseButton, TypedPoint2D<DevicePixel, f32>),
|
||||
MouseDown(MouseButton, TypedPoint2D<DevicePixel, f32>),
|
||||
MouseUp(MouseButton, TypedPoint2D<DevicePixel, f32>),
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
|
|
|
@ -66,7 +66,7 @@ use msg::constellation_msg::{SUPER, ALT, SHIFT, CONTROL};
|
|||
use net::resource_task::ControlMsg::{SetCookiesForUrl, GetCookiesForUrl};
|
||||
use net::cookie_storage::CookieSource::NonHTTP;
|
||||
use script_task::Runnable;
|
||||
use script_traits::UntrustedNodeAddress;
|
||||
use script_traits::{MouseButton, UntrustedNodeAddress};
|
||||
use util::{opts, namespace};
|
||||
use util::str::{DOMString, split_html_space_chars};
|
||||
use layout_interface::{ReflowGoal, ReflowQueryType};
|
||||
|
@ -216,7 +216,8 @@ pub trait DocumentHelpers<'a> {
|
|||
fn title_changed(self);
|
||||
fn send_title_to_compositor(self);
|
||||
fn dirty_all_nodes(self);
|
||||
fn handle_click_event(self, js_runtime: *mut JSRuntime, _button: uint, point: Point2D<f32>);
|
||||
fn handle_click_event(self, js_runtime: *mut JSRuntime,
|
||||
button: MouseButton, point: Point2D<f32>);
|
||||
fn dispatch_key_event(self, key: Key, state: KeyState,
|
||||
modifiers: KeyModifiers, compositor: &mut Box<ScriptListener+'static>);
|
||||
|
||||
|
@ -483,7 +484,8 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
|
|||
}
|
||||
}
|
||||
|
||||
fn handle_click_event(self, js_runtime: *mut JSRuntime, _button: uint, point: Point2D<f32>) {
|
||||
fn handle_click_event(self, js_runtime: *mut JSRuntime,
|
||||
_button: MouseButton, point: Point2D<f32>) {
|
||||
debug!("ClickEvent: clicked at {:?}", point);
|
||||
let node = match self.hit_test(&point) {
|
||||
Some(node_address) => {
|
||||
|
|
|
@ -1205,10 +1205,10 @@ impl ScriptTask {
|
|||
self.handle_reflow_event(pipeline_id);
|
||||
}
|
||||
|
||||
ClickEvent(_button, point) => {
|
||||
ClickEvent(button, point) => {
|
||||
let page = get_page(&self.root_page(), pipeline_id);
|
||||
let document = page.document().root();
|
||||
document.r().handle_click_event(self.js_runtime.ptr, _button, point);
|
||||
document.r().handle_click_event(self.js_runtime.ptr, button, point);
|
||||
}
|
||||
|
||||
MouseDownEvent(..) => {}
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#![feature(int_uint)]
|
||||
|
||||
extern crate devtools_traits;
|
||||
extern crate geom;
|
||||
extern crate libc;
|
||||
|
@ -81,13 +79,21 @@ pub enum ConstellationControlMsg {
|
|||
unsafe impl Send for ConstellationControlMsg {
|
||||
}
|
||||
|
||||
/// The mouse button involved in the event.
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum MouseButton {
|
||||
Left,
|
||||
Middle,
|
||||
Right,
|
||||
}
|
||||
|
||||
/// Events from the compositor that the script task needs to know about
|
||||
pub enum CompositorEvent {
|
||||
ResizeEvent(WindowSizeData),
|
||||
ReflowEvent(SmallVec1<UntrustedNodeAddress>),
|
||||
ClickEvent(uint, Point2D<f32>),
|
||||
MouseDownEvent(uint, Point2D<f32>),
|
||||
MouseUpEvent(uint, Point2D<f32>),
|
||||
ClickEvent(MouseButton, Point2D<f32>),
|
||||
MouseDownEvent(MouseButton, Point2D<f32>),
|
||||
MouseUpEvent(MouseButton, Point2D<f32>),
|
||||
MouseMoveEvent(Point2D<f32>),
|
||||
KeyEvent(Key, KeyState, KeyModifiers),
|
||||
}
|
||||
|
|
1
components/servo/Cargo.lock
generated
1
components/servo/Cargo.lock
generated
|
@ -398,6 +398,7 @@ dependencies = [
|
|||
"layers 0.1.0 (git+https://github.com/servo/rust-layers)",
|
||||
"libc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"msg 0.0.1",
|
||||
"script_traits 0.0.1",
|
||||
"time 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"url 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"util 0.0.1",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue