diff --git a/servo/components/compositing/compositor.rs b/servo/components/compositing/compositor.rs index 524f59585c22..c2c38f7bc97f 100644 --- a/servo/components/compositing/compositor.rs +++ b/servo/components/compositing/compositor.rs @@ -28,14 +28,14 @@ use layers::rendergl::RenderContext; use layers::scene::Scene; use layout_traits::LayoutControlChan; use msg::constellation_msg::{Image, PixelFormat}; -use msg::constellation_msg::{Key, KeyModifiers, KeyState, LoadData, MouseButton}; +use msg::constellation_msg::{Key, KeyModifiers, KeyState, LoadData}; use msg::constellation_msg::{NavigationDirection, PipelineId, WindowSizeData}; use pipeline::CompositionPipeline; use profile_traits::mem::{self, ReportKind, Reporter, ReporterRequest}; use profile_traits::time::{self, ProfilerCategory, profile}; use script_traits::CompositorEvent::{MouseMoveEvent, TouchEvent}; use script_traits::{AnimationState, ConstellationControlMsg, LayoutControlMsg}; -use script_traits::{TouchEventType, TouchId}; +use script_traits::{MouseButton, TouchEventType, TouchId}; use scrolling::ScrollingTimerProxy; use std::collections::hash_map::Entry::{Occupied, Vacant}; use std::collections::{HashMap, HashSet}; diff --git a/servo/components/compositing/windowing.rs b/servo/components/compositing/windowing.rs index 0dc4e1e46c8b..181d7433f0fc 100644 --- a/servo/components/compositing/windowing.rs +++ b/servo/components/compositing/windowing.rs @@ -11,9 +11,9 @@ use euclid::size::TypedSize2D; use euclid::{Point2D, Size2D}; use layers::geometry::DevicePixel; use layers::platform::surface::NativeDisplay; -use msg::constellation_msg::{Key, KeyModifiers, KeyState, MouseButton}; +use msg::constellation_msg::{Key, KeyModifiers, KeyState}; use net_traits::net_error_list::NetError; -use script_traits::{TouchEventType, TouchId}; +use script_traits::{MouseButton, TouchEventType, TouchId}; use std::fmt::{Debug, Error, Formatter}; use std::rc::Rc; use url::Url; diff --git a/servo/components/msg/constellation_msg.rs b/servo/components/msg/constellation_msg.rs index 5794453cccb9..1fdb333da3b6 100644 --- a/servo/components/msg/constellation_msg.rs +++ b/servo/components/msg/constellation_msg.rs @@ -200,17 +200,6 @@ bitflags! { } } -/// The mouse button involved in the event. -#[derive(Clone, Copy, Debug, Deserialize, Serialize)] -pub enum MouseButton { - /// The left mouse button. - Left, - /// The middle mouse button. - Middle, - /// The right mouse button. - Right, -} - #[derive(Deserialize, Serialize)] pub enum WebDriverCommandMsg { LoadUrl(PipelineId, LoadData, IpcSender), diff --git a/servo/components/script/dom/document.rs b/servo/components/script/dom/document.rs index 45918e7fe53c..aeceb32cf8bd 100644 --- a/servo/components/script/dom/document.rs +++ b/servo/components/script/dom/document.rs @@ -82,13 +82,13 @@ use layout_interface::{HitTestResponse, MouseOverResponse}; use layout_interface::{LayoutChan, Msg, ReflowQueryType}; use msg::constellation_msg::{ALT, CONTROL, SHIFT, SUPER}; use msg::constellation_msg::{ConstellationChan, Key, KeyModifiers, KeyState}; -use msg::constellation_msg::{MouseButton, PipelineId, SubpageId}; +use msg::constellation_msg::{PipelineId, SubpageId}; use net_traits::ControlMsg::{GetCookiesForUrl, SetCookiesForUrl}; use net_traits::CookieSource::NonHTTP; use net_traits::{AsyncResponseTarget, PendingAsyncLoad}; use num::ToPrimitive; use script_thread::{MainThreadScriptMsg, Runnable}; -use script_traits::{AnimationState, MouseEventType, MozBrowserEvent}; +use script_traits::{AnimationState, MouseButton, MouseEventType, MozBrowserEvent}; use script_traits::{ScriptMsg as ConstellationMsg, ScriptToCompositorMsg}; use script_traits::{TouchEventType, TouchId, UntrustedNodeAddress}; use std::ascii::AsciiExt; diff --git a/servo/components/script/script_thread.rs b/servo/components/script/script_thread.rs index 96b5fb993491..d4339cb2b05a 100644 --- a/servo/components/script/script_thread.rs +++ b/servo/components/script/script_thread.rs @@ -64,8 +64,7 @@ use layout_interface::{self, LayoutChan, NewLayoutThreadInfo, ScriptLayoutChan}; use libc; use mem::heap_size_of_self_and_children; use msg::constellation_msg::{ConstellationChan, LoadData}; -use msg::constellation_msg::{MouseButton, PipelineId}; -use msg::constellation_msg::{PipelineNamespace}; +use msg::constellation_msg::{PipelineId, PipelineNamespace}; use msg::constellation_msg::{SubpageId, WindowSizeData}; use msg::webdriver_msg::WebDriverScriptCommand; use net_traits::LoadData as NetLoadData; @@ -81,7 +80,7 @@ use profile_traits::time::{self, ProfilerCategory, profile}; use script_traits::CompositorEvent::{KeyEvent, MouseButtonEvent, MouseMoveEvent, ResizeEvent}; use script_traits::CompositorEvent::{TouchEvent}; use script_traits::{CompositorEvent, ConstellationControlMsg, EventResult}; -use script_traits::{InitialScriptState, MouseEventType, MozBrowserEvent, NewLayoutInfo}; +use script_traits::{InitialScriptState, MouseButton, MouseEventType, MozBrowserEvent, NewLayoutInfo}; use script_traits::{LayoutMsg, OpaqueScriptLayoutChannel, ScriptMsg as ConstellationMsg}; use script_traits::{ScriptThreadFactory, ScriptToCompositorMsg, TimerEvent, TimerEventRequest, TimerSource}; use script_traits::{TouchEventType, TouchId}; diff --git a/servo/components/script_traits/lib.rs b/servo/components/script_traits/lib.rs index 93db6cd52d26..a4d07966028e 100644 --- a/servo/components/script_traits/lib.rs +++ b/servo/components/script_traits/lib.rs @@ -40,7 +40,7 @@ use gfx_traits::LayerId; use ipc_channel::ipc::{IpcReceiver, IpcSender}; use libc::c_void; use msg::constellation_msg::{ConstellationChan, Failure, PipelineId, WindowSizeData}; -use msg::constellation_msg::{Key, KeyModifiers, KeyState, LoadData, MouseButton}; +use msg::constellation_msg::{Key, KeyModifiers, KeyState, LoadData}; use msg::constellation_msg::{PipelineNamespaceId, SubpageId}; use msg::webdriver_msg::WebDriverScriptCommand; use net_traits::ResourceThread; @@ -189,6 +189,17 @@ pub enum TouchEventType { #[derive(Clone, Copy, Debug, Eq, PartialEq, Deserialize, Serialize)] pub struct TouchId(pub i32); +/// The mouse button involved in the event. +#[derive(Clone, Copy, Debug, Deserialize, Serialize)] +pub enum MouseButton { + /// The left mouse button. + Left, + /// The middle mouse button. + Middle, + /// The right mouse button. + Right, +} + /// The types of mouse events #[derive(Deserialize, HeapSizeOf, Serialize)] pub enum MouseEventType { diff --git a/servo/components/script_traits/script_msg.rs b/servo/components/script_traits/script_msg.rs index cc2104daf711..03a925c166ef 100644 --- a/servo/components/script_traits/script_msg.rs +++ b/servo/components/script_traits/script_msg.rs @@ -5,6 +5,7 @@ use AnimationState; use DocumentState; use IFrameLoadInfo; +use MouseButton; use MouseEventType; use MozBrowserEvent; use canvas_traits::CanvasMsg; @@ -12,7 +13,7 @@ use euclid::point::Point2D; use euclid::size::Size2D; use ipc_channel::ipc::IpcSender; use msg::constellation_msg::{Failure, NavigationDirection, PipelineId}; -use msg::constellation_msg::{LoadData, MouseButton, SubpageId}; +use msg::constellation_msg::{LoadData, SubpageId}; use offscreen_gl_context::GLContextAttributes; use style_traits::viewport::ViewportConstraints; use url::Url; diff --git a/servo/ports/cef/browser_host.rs b/servo/ports/cef/browser_host.rs index 7dd6830fda1a..73ddfdb06761 100644 --- a/servo/ports/cef/browser_host.rs +++ b/servo/ports/cef/browser_host.rs @@ -14,7 +14,8 @@ use compositing::windowing::{WindowEvent, MouseWindowEvent}; use euclid::point::Point2D; use euclid::size::Size2D; use libc::{c_double, c_int}; -use msg::constellation_msg::{self, KeyModifiers, KeyState, MouseButton}; +use msg::constellation_msg::{self, KeyModifiers, KeyState}; +use script_traits::MouseButton; use std::cell::{Cell, RefCell}; pub struct ServoCefBrowserHost { diff --git a/servo/ports/glutin/window.rs b/servo/ports/glutin/window.rs index 217fd7c51575..542ab5d45977 100644 --- a/servo/ports/glutin/window.rs +++ b/servo/ports/glutin/window.rs @@ -253,7 +253,7 @@ impl Window { /// Helper function to handle a click fn handle_mouse(&self, button: glutin::MouseButton, action: glutin::ElementState, x: i32, y: i32) { - use msg::constellation_msg::MouseButton; + use script_traits::MouseButton; // FIXME(tkuehn): max pixel dist should be based on pixel density let max_pixel_dist = 10f64; diff --git a/servo/ports/gonk/Cargo.lock b/servo/ports/gonk/Cargo.lock index 65a246abad50..a8d0d0bc0c4a 100644 --- a/servo/ports/gonk/Cargo.lock +++ b/servo/ports/gonk/Cargo.lock @@ -16,6 +16,7 @@ dependencies = [ "net_traits 0.0.1", "profile 0.0.1", "script 0.0.1", + "script_traits 0.0.1", "servo 0.0.1", "servo-egl 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/servo/ports/gonk/Cargo.toml b/servo/ports/gonk/Cargo.toml index 6e6eac6cf97e..ac810b8faa9f 100644 --- a/servo/ports/gonk/Cargo.toml +++ b/servo/ports/gonk/Cargo.toml @@ -18,6 +18,9 @@ path = "../../components/msg" [dependencies.script] path = "../../components/script" +[dependencies.script_traits] +path = "../../components/script_traits" + [dependencies.net_traits] path = "../../components/net_traits" diff --git a/servo/ports/gonk/src/input.rs b/servo/ports/gonk/src/input.rs index b296db77583b..e40900f7acf5 100644 --- a/servo/ports/gonk/src/input.rs +++ b/servo/ports/gonk/src/input.rs @@ -6,7 +6,7 @@ use compositing::windowing::{WindowEvent, MouseWindowEvent}; use errno::errno; use euclid::point::Point2D; use libc::{c_int, c_long, time_t}; -use msg::constellation_msg::MouseButton; +use script_traits::MouseButton; use std::fs::File; use std::io::Read; use std::mem::{size_of, transmute, zeroed}; diff --git a/servo/ports/gonk/src/main.rs b/servo/ports/gonk/src/main.rs index 57728f92f816..75b31dfa71a3 100644 --- a/servo/ports/gonk/src/main.rs +++ b/servo/ports/gonk/src/main.rs @@ -33,6 +33,7 @@ extern crate layers; extern crate libc; extern crate msg; extern crate net_traits; +extern crate script_traits; extern crate servo; extern crate time; extern crate url;