servo: Merge #9263 - Moved MouseButton from msg to script_traits (from DarinM223:move_mousebutton); r=KiChjang
authorDarin Minamoto <darinm223@gmail.com>
Sat, 16 Jan 2016 19:05:21 +0500
changeset 384590 c011d36dd9561930682a779664be6af369f77978
parent 384589 3b51e5de68ddee64f3201fabc6923427eda26c92
child 384591 7c8af29db045984757501e5a3f95d76051980dc7
push id7198
push userjlorenzo@mozilla.com
push dateTue, 18 Apr 2017 12:07:49 +0000
treeherdermozilla-beta@d57aa49c3948 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersKiChjang
servo: Merge #9263 - Moved MouseButton from msg to script_traits (from DarinM223:move_mousebutton); r=KiChjang Fixes #9250 Source-Repo: https://github.com/servo/servo Source-Revision: 9118b64b4b610a95f48a88a198baac4eb31a04a0
servo/components/compositing/compositor.rs
servo/components/compositing/windowing.rs
servo/components/msg/constellation_msg.rs
servo/components/script/dom/document.rs
servo/components/script/script_thread.rs
servo/components/script_traits/lib.rs
servo/components/script_traits/script_msg.rs
servo/ports/cef/browser_host.rs
servo/ports/glutin/window.rs
servo/ports/gonk/Cargo.lock
servo/ports/gonk/Cargo.toml
servo/ports/gonk/src/input.rs
servo/ports/gonk/src/main.rs
--- a/servo/components/compositing/compositor.rs
+++ b/servo/components/compositing/compositor.rs
@@ -23,24 +23,24 @@ use ipc_channel::router::ROUTER;
 use layers::geometry::{DevicePixel, LayerPixel};
 use layers::layers::{BufferRequest, Layer, LayerBuffer, LayerBufferSet};
 use layers::platform::surface::NativeDisplay;
 use layers::rendergl;
 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};
 use std::fs::File;
 use std::mem as std_mem;
 use std::rc::Rc;
 use std::sync::mpsc::Sender;
 use style_traits::viewport::ViewportConstraints;
--- a/servo/components/compositing/windowing.rs
+++ b/servo/components/compositing/windowing.rs
@@ -6,19 +6,19 @@
 
 use compositor_thread::{CompositorProxy, CompositorReceiver};
 use euclid::point::TypedPoint2D;
 use euclid::scale_factor::ScaleFactor;
 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;
 use util::cursor::Cursor;
 use util::geometry::ScreenPx;
 
 #[derive(Clone)]
 pub enum MouseWindowEvent {
--- a/servo/components/msg/constellation_msg.rs
+++ b/servo/components/msg/constellation_msg.rs
@@ -195,27 +195,16 @@ bitflags! {
         const NONE = 0x00,
         const SHIFT = 0x01,
         const CONTROL = 0x02,
         const ALT = 0x04,
         const SUPER = 0x08,
     }
 }
 
-/// 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<LoadStatus>),
     Refresh(PipelineId, IpcSender<LoadStatus>),
     ScriptCommand(PipelineId, WebDriverScriptCommand),
     SendKeys(PipelineId, Vec<(Key, KeyModifiers, KeyState)>),
     TakeScreenshot(PipelineId, IpcSender<Option<Image>>),
 }
--- a/servo/components/script/dom/document.rs
+++ b/servo/components/script/dom/document.rs
@@ -77,23 +77,23 @@ use dom::window::{ReflowReason, Window};
 use euclid::point::Point2D;
 use html5ever::tree_builder::{LimitedQuirks, NoQuirks, Quirks, QuirksMode};
 use ipc_channel::ipc::{self, IpcSender};
 use js::jsapi::{JSContext, JSObject, JSRuntime};
 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;
 use std::borrow::ToOwned;
 use std::boxed::FnBox;
 use std::cell::{Cell, Ref, RefMut};
 use std::collections::HashMap;
 use std::collections::hash_map::Entry::{Occupied, Vacant};
--- a/servo/components/script/script_thread.rs
+++ b/servo/components/script/script_thread.rs
@@ -59,34 +59,33 @@ use js::jsapi::{JSContext, JSRuntime, JS
 use js::jsapi::{JSObject, SetPreserveWrapperCallback};
 use js::jsval::UndefinedValue;
 use js::rust::Runtime;
 use layout_interface::{ReflowQueryType};
 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;
 use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheResult, ImageCacheThread};
 use net_traits::storage_thread::StorageThread;
 use net_traits::{AsyncResponseTarget, ControlMsg, LoadConsumer, LoadContext, Metadata, ResourceThread};
 use network_listener::NetworkListener;
 use page::{Frame, IterablePage, Page};
 use parse::html::{ParseContext, parse_html};
 use parse::xml::{self, parse_xml};
 use profile_traits::mem::{self, OpaqueSender, Report, ReportKind, ReportsChan};
 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};
 use std::any::Any;
 use std::borrow::ToOwned;
 use std::cell::{Cell, RefCell};
 use std::collections::HashSet;
 use std::io::{Write, stdout};
--- a/servo/components/script_traits/lib.rs
+++ b/servo/components/script_traits/lib.rs
@@ -35,17 +35,17 @@ use euclid::Size2D;
 use euclid::length::Length;
 use euclid::point::Point2D;
 use euclid::rect::Rect;
 use gfx_traits::Epoch;
 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;
 use net_traits::image_cache_thread::ImageCacheThread;
 use net_traits::storage_thread::StorageThread;
 use profile_traits::mem;
 use std::any::Any;
 use url::Url;
@@ -184,16 +184,27 @@ pub enum TouchEventType {
 }
 
 /// An opaque identifier for a touch point.
 ///
 /// http://w3c.github.io/touch-events/#widl-Touch-identifier
 #[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 {
     /// Mouse button clicked
     Click,
     /// Mouse button down
     MouseDown,
     /// Mouse button up
--- a/servo/components/script_traits/script_msg.rs
+++ b/servo/components/script_traits/script_msg.rs
@@ -1,23 +1,24 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 use AnimationState;
 use DocumentState;
 use IFrameLoadInfo;
+use MouseButton;
 use MouseEventType;
 use MozBrowserEvent;
 use canvas_traits::CanvasMsg;
 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;
 use util::cursor::Cursor;
 
 /// Messages from the layout to the constellation.
 #[derive(Deserialize, Serialize)]
 pub enum LayoutMsg {
--- a/servo/ports/cef/browser_host.rs
+++ b/servo/ports/cef/browser_host.rs
@@ -9,17 +9,18 @@ use types::cef_event_flags_t::{EVENTFLAG
 use types::cef_key_event_type_t::{KEYEVENT_CHAR, KEYEVENT_KEYDOWN, KEYEVENT_KEYUP, KEYEVENT_RAWKEYDOWN};
 use types::{cef_mouse_button_type_t, cef_mouse_event, cef_rect_t, cef_key_event, cef_window_handle_t};
 use wrappers::CefWrap;
 
 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 {
     /// A reference to the browser.
     pub browser: RefCell<Option<CefBrowser>>,
     /// A reference to the client.
     pub client: CefClient,
     /// flag for return value of prepare_for_composite
--- a/servo/ports/glutin/window.rs
+++ b/servo/ports/glutin/window.rs
@@ -248,17 +248,17 @@ impl Window {
         let mouse_pos = self.mouse_pos.get();
         let event = WindowEvent::Scroll(Point2D::typed(dx as f32, dy as f32),
                                         Point2D::typed(mouse_pos.x as i32, mouse_pos.y as i32));
         self.event_queue.borrow_mut().push(event);
     }
 
     /// 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;
         let event = match action {
             ElementState::Pressed => {
                 self.mouse_down_point.set(Point2D::new(x, y));
                 self.mouse_down_button.set(Some(button));
                 MouseWindowEvent::MouseDown(MouseButton::Left, Point2D::typed(x as f32, y as f32))
--- a/servo/ports/gonk/Cargo.lock
+++ b/servo/ports/gonk/Cargo.lock
@@ -11,16 +11,17 @@ dependencies = [
  "gleam 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "layers 0.2.0 (git+https://github.com/servo/rust-layers)",
  "layout 0.0.1",
  "libc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "msg 0.0.1",
  "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)",
  "url 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "util 0.0.1",
 ]
 
 [[package]]
--- a/servo/ports/gonk/Cargo.toml
+++ b/servo/ports/gonk/Cargo.toml
@@ -13,16 +13,19 @@ git = "https://github.com/servo/rust-lay
 features = ["plugins"]
 
 [dependencies.msg]
 path = "../../components/msg"
 
 [dependencies.script]
 path = "../../components/script"
 
+[dependencies.script_traits]
+path = "../../components/script_traits"
+
 [dependencies.net_traits]
 path = "../../components/net_traits"
 
 [dependencies.gfx]
 path = "../../components/gfx"
 
 [dependencies.layout]
 path = "../../components/layout"
--- a/servo/ports/gonk/src/input.rs
+++ b/servo/ports/gonk/src/input.rs
@@ -1,17 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 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};
 use std::os::unix::io::AsRawFd;
 use std::path::Path;
 use std::sync::mpsc::Sender;
 use std::thread;
 
--- a/servo/ports/gonk/src/main.rs
+++ b/servo/ports/gonk/src/main.rs
@@ -28,16 +28,17 @@ extern crate egl;
 extern crate env_logger;
 extern crate errno;
 extern crate euclid;
 extern crate gleam;
 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;
 extern crate util;
 
 #[link(name = "stlport")]
 extern {}