Moved ScriptToCompositorMsg enum and EventResult enum to script_traits

Moved ScriptToCompositorMsg enum and EventResult enum to script_traits
resolving issue #8835.
This commit is contained in:
Beomjin Kim 2015-12-20 00:31:33 +09:00
parent 2a3a7a73b5
commit 2637d30c2a
8 changed files with 45 additions and 32 deletions

View file

@ -13,11 +13,12 @@ use headless;
use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
use layers::layers::{BufferRequest, LayerBufferSet}; use layers::layers::{BufferRequest, LayerBufferSet};
use layers::platform::surface::{NativeDisplay, NativeSurface}; use layers::platform::surface::{NativeDisplay, NativeSurface};
use msg::compositor_msg::{Epoch, EventResult, FrameTreeId, LayerId, LayerProperties, ScriptToCompositorMsg}; use msg::compositor_msg::{Epoch, FrameTreeId, LayerId, LayerProperties};
use msg::constellation_msg::{AnimationState, PipelineId}; use msg::constellation_msg::{AnimationState, PipelineId};
use msg::constellation_msg::{Image, Key, KeyModifiers, KeyState}; use msg::constellation_msg::{Image, Key, KeyModifiers, KeyState};
use profile_traits::mem; use profile_traits::mem;
use profile_traits::time; use profile_traits::time;
use script_traits::{EventResult, ScriptToCompositorMsg};
use std::fmt::{Debug, Error, Formatter}; use std::fmt::{Debug, Error, Formatter};
use std::rc::Rc; use std::rc::Rc;
use std::sync::mpsc::{Receiver, Sender, channel}; use std::sync::mpsc::{Receiver, Sender, channel};

View file

@ -14,7 +14,6 @@ use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
use ipc_channel::router::ROUTER; use ipc_channel::router::ROUTER;
use layers::geometry::DevicePixel; use layers::geometry::DevicePixel;
use layout_traits::{LayoutControlChan, LayoutTaskFactory}; use layout_traits::{LayoutControlChan, LayoutTaskFactory};
use msg::compositor_msg::ScriptToCompositorMsg;
use msg::constellation_msg::PaintMsg; use msg::constellation_msg::PaintMsg;
use msg::constellation_msg::{ConstellationChan, Failure, FrameId, PipelineId, SubpageId}; use msg::constellation_msg::{ConstellationChan, Failure, FrameId, PipelineId, SubpageId};
use msg::constellation_msg::{LoadData, MozBrowserEvent, WindowSizeData}; use msg::constellation_msg::{LoadData, MozBrowserEvent, WindowSizeData};
@ -26,7 +25,7 @@ use profile_traits::mem as profile_mem;
use profile_traits::time; use profile_traits::time;
use script_traits::{ConstellationControlMsg, InitialScriptState}; use script_traits::{ConstellationControlMsg, InitialScriptState};
use script_traits::{LayoutControlMsg, NewLayoutInfo, ScriptMsg as ConstellationMsg}; use script_traits::{LayoutControlMsg, NewLayoutInfo, ScriptMsg as ConstellationMsg};
use script_traits::{ScriptTaskFactory, TimerEventRequest}; use script_traits::{ScriptToCompositorMsg, ScriptTaskFactory, TimerEventRequest};
use std::mem; use std::mem;
use std::sync::mpsc::{Receiver, Sender, channel}; use std::sync::mpsc::{Receiver, Sender, channel};
use std::thread; use std::thread;

View file

@ -5,8 +5,7 @@
use euclid::point::TypedPoint2D; use euclid::point::TypedPoint2D;
use euclid::scale_factor::ScaleFactor; use euclid::scale_factor::ScaleFactor;
use layers::geometry::DevicePixel; use layers::geometry::DevicePixel;
use msg::compositor_msg::EventResult; use script_traits::{EventResult, TouchId};
use script_traits::TouchId;
use self::TouchState::*; use self::TouchState::*;
/// Minimum number of ScreenPx to begin touch scrolling. /// Minimum number of ScreenPx to begin touch scrolling.

View file

@ -4,7 +4,7 @@
use azure::azure_hl::Color; use azure::azure_hl::Color;
use constellation_msg::{Key, KeyModifiers, KeyState, PipelineId}; use constellation_msg::{Key, KeyModifiers, KeyState, PipelineId};
use euclid::{Matrix4, Point2D, Rect, Size2D}; use euclid::{Matrix4, Point2D, Rect};
use ipc_channel::ipc::IpcSender; use ipc_channel::ipc::IpcSender;
use std::fmt::{self, Debug, Formatter}; use std::fmt::{self, Debug, Formatter};
@ -123,21 +123,3 @@ pub struct LayerProperties {
/// Whether this layer scrolls its overflow area. /// Whether this layer scrolls its overflow area.
pub scrolls_overflow_area: bool, pub scrolls_overflow_area: bool,
} }
#[derive(Deserialize, Serialize)]
pub enum ScriptToCompositorMsg {
ScrollFragmentPoint(PipelineId, LayerId, Point2D<f32>, bool),
SetTitle(PipelineId, Option<String>),
SendKeyEvent(Key, KeyState, KeyModifiers),
GetClientWindow(IpcSender<(Size2D<u32>, Point2D<i32>)>),
MoveTo(Point2D<i32>),
ResizeTo(Size2D<u32>),
TouchEventProcessed(EventResult),
Exit,
}
#[derive(Deserialize, Serialize)]
pub enum EventResult {
DefaultAllowed,
DefaultPrevented,
}

View file

@ -80,7 +80,6 @@ use js::jsapi::{JSContext, JSObject, JSRuntime};
use layout_interface::{HitTestResponse, MouseOverResponse}; use layout_interface::{HitTestResponse, MouseOverResponse};
use layout_interface::{LayoutChan, Msg}; use layout_interface::{LayoutChan, Msg};
use layout_interface::{ReflowGoal, ReflowQueryType}; use layout_interface::{ReflowGoal, ReflowQueryType};
use msg::compositor_msg::ScriptToCompositorMsg;
use msg::constellation_msg::{ALT, CONTROL, SHIFT, SUPER}; use msg::constellation_msg::{ALT, CONTROL, SHIFT, SUPER};
use msg::constellation_msg::{AnimationState, PipelineId}; use msg::constellation_msg::{AnimationState, PipelineId};
use msg::constellation_msg::{ConstellationChan, Key, KeyModifiers, KeyState}; use msg::constellation_msg::{ConstellationChan, Key, KeyModifiers, KeyState};
@ -91,7 +90,8 @@ use net_traits::{AsyncResponseTarget, PendingAsyncLoad};
use num::ToPrimitive; use num::ToPrimitive;
use script_task::CSSError; use script_task::CSSError;
use script_task::{MainThreadScriptMsg, Runnable}; use script_task::{MainThreadScriptMsg, Runnable};
use script_traits::{ScriptMsg as ConstellationMsg, TouchEventType, TouchId, UntrustedNodeAddress}; use script_traits::{ScriptMsg as ConstellationMsg, ScriptToCompositorMsg};
use script_traits::{TouchEventType, TouchId, UntrustedNodeAddress};
use std::ascii::AsciiExt; use std::ascii::AsciiExt;
use std::borrow::ToOwned; use std::borrow::ToOwned;
use std::boxed::FnBox; use std::boxed::FnBox;

View file

@ -43,7 +43,7 @@ use layout_interface::{ContentBoxResponse, ContentBoxesResponse, ResolvedStyleRe
use layout_interface::{LayoutChan, LayoutRPC, Msg, Reflow, ReflowGoal, ReflowQueryType}; use layout_interface::{LayoutChan, LayoutRPC, Msg, Reflow, ReflowGoal, ReflowQueryType};
use libc; use libc;
use msg::ParseErrorReporter; use msg::ParseErrorReporter;
use msg::compositor_msg::{LayerId, ScriptToCompositorMsg}; use msg::compositor_msg::LayerId;
use msg::constellation_msg::{ConstellationChan, DocumentState, LoadData}; use msg::constellation_msg::{ConstellationChan, DocumentState, LoadData};
use msg::constellation_msg::{PipelineId, SubpageId, WindowSizeData}; use msg::constellation_msg::{PipelineId, SubpageId, WindowSizeData};
use msg::webdriver_msg::{WebDriverJSError, WebDriverJSResult}; use msg::webdriver_msg::{WebDriverJSError, WebDriverJSResult};
@ -58,7 +58,7 @@ use rustc_serialize::base64::{FromBase64, STANDARD, ToBase64};
use script_task::{ScriptChan, ScriptPort, MainThreadScriptMsg, RunnableWrapper}; use script_task::{ScriptChan, ScriptPort, MainThreadScriptMsg, RunnableWrapper};
use script_task::{SendableMainThreadScriptChan, MainThreadScriptChan}; use script_task::{SendableMainThreadScriptChan, MainThreadScriptChan};
use script_traits::ScriptMsg as ConstellationMsg; use script_traits::ScriptMsg as ConstellationMsg;
use script_traits::{MsDuration, TimerEvent, TimerEventId, TimerEventRequest, TimerSource}; use script_traits::{MsDuration, ScriptToCompositorMsg, TimerEvent, TimerEventId, TimerEventRequest, TimerSource};
use selectors::parser::PseudoElement; use selectors::parser::PseudoElement;
use std::ascii::AsciiExt; use std::ascii::AsciiExt;
use std::borrow::ToOwned; use std::borrow::ToOwned;

View file

@ -61,7 +61,7 @@ use layout_interface::{ReflowQueryType};
use layout_interface::{self, LayoutChan, NewLayoutTaskInfo, ReflowGoal, ScriptLayoutChan}; use layout_interface::{self, LayoutChan, NewLayoutTaskInfo, ReflowGoal, ScriptLayoutChan};
use libc; use libc;
use mem::heap_size_of_self_and_children; use mem::heap_size_of_self_and_children;
use msg::compositor_msg::{EventResult, LayerId, ScriptToCompositorMsg}; use msg::compositor_msg::LayerId;
use msg::constellation_msg::{ConstellationChan, LoadData}; use msg::constellation_msg::{ConstellationChan, LoadData};
use msg::constellation_msg::{MouseButton, MouseEventType, MozBrowserEvent, PipelineId}; use msg::constellation_msg::{MouseButton, MouseEventType, MozBrowserEvent, PipelineId};
use msg::constellation_msg::{PipelineNamespace}; use msg::constellation_msg::{PipelineNamespace};
@ -79,9 +79,9 @@ use profile_traits::mem::{self, OpaqueSender, Report, ReportKind, ReportsChan};
use profile_traits::time::{self, ProfilerCategory, profile}; use profile_traits::time::{self, ProfilerCategory, profile};
use script_traits::CompositorEvent::{KeyEvent, MouseButtonEvent, MouseMoveEvent, ResizeEvent}; use script_traits::CompositorEvent::{KeyEvent, MouseButtonEvent, MouseMoveEvent, ResizeEvent};
use script_traits::CompositorEvent::{TouchEvent}; use script_traits::CompositorEvent::{TouchEvent};
use script_traits::{CompositorEvent, ConstellationControlMsg, InitialScriptState, NewLayoutInfo}; use script_traits::{CompositorEvent, ConstellationControlMsg, EventResult, InitialScriptState, NewLayoutInfo};
use script_traits::{OpaqueScriptLayoutChannel, ScriptMsg as ConstellationMsg}; use script_traits::{OpaqueScriptLayoutChannel, ScriptMsg as ConstellationMsg};
use script_traits::{ScriptTaskFactory, TimerEvent, TimerEventRequest, TimerSource}; use script_traits::{ScriptTaskFactory, ScriptToCompositorMsg, TimerEvent, TimerEventRequest, TimerSource};
use script_traits::{TouchEventType, TouchId}; use script_traits::{TouchEventType, TouchId};
use std::any::Any; use std::any::Any;
use std::borrow::ToOwned; use std::borrow::ToOwned;

View file

@ -30,12 +30,13 @@ mod script_msg;
use app_units::Au; use app_units::Au;
use devtools_traits::ScriptToDevtoolsControlMsg; use devtools_traits::ScriptToDevtoolsControlMsg;
use euclid::Size2D;
use euclid::length::Length; use euclid::length::Length;
use euclid::point::Point2D; use euclid::point::Point2D;
use euclid::rect::Rect; use euclid::rect::Rect;
use ipc_channel::ipc::{IpcReceiver, IpcSender}; use ipc_channel::ipc::{IpcReceiver, IpcSender};
use libc::c_void; use libc::c_void;
use msg::compositor_msg::{Epoch, LayerId, ScriptToCompositorMsg}; use msg::compositor_msg::{Epoch, LayerId};
use msg::constellation_msg::{ConstellationChan, Failure, PipelineId, WindowSizeData}; use msg::constellation_msg::{ConstellationChan, Failure, PipelineId, WindowSizeData};
use msg::constellation_msg::{Key, KeyModifiers, KeyState, LoadData, SubpageId}; use msg::constellation_msg::{Key, KeyModifiers, KeyState, LoadData, SubpageId};
use msg::constellation_msg::{MouseButton, MouseEventType}; use msg::constellation_msg::{MouseButton, MouseEventType};
@ -289,3 +290,34 @@ pub trait ScriptTaskFactory {
fn clone_layout_channel(_phantom: Option<&mut Self>, pair: &OpaqueScriptLayoutChannel) fn clone_layout_channel(_phantom: Option<&mut Self>, pair: &OpaqueScriptLayoutChannel)
-> Box<Any + Send>; -> Box<Any + Send>;
} }
/// Messages sent from the script thread to the compositor
#[derive(Deserialize, Serialize)]
pub enum ScriptToCompositorMsg {
/// Scroll a page in a window
ScrollFragmentPoint(PipelineId, LayerId, Point2D<f32>, bool),
/// Set title of current page
/// https://html.spec.whatwg.org/multipage/#document.title
SetTitle(PipelineId, Option<String>),
/// Send a key event
SendKeyEvent(Key, KeyState, KeyModifiers),
/// Get Window Informations size and position
GetClientWindow(IpcSender<(Size2D<u32>, Point2D<i32>)>),
/// Move the window to a point
MoveTo(Point2D<i32>),
/// Resize the window to size
ResizeTo(Size2D<u32>),
/// Script has handled a touch event, and either prevented or allowed default actions.
TouchEventProcessed(EventResult),
/// Requests that the compositor shut down.
Exit,
}
/// Whether a DOM event was prevented by web content
#[derive(Deserialize, Serialize)]
pub enum EventResult {
/// Allowed by web content
DefaultAllowed,
/// Prevented by web content
DefaultPrevented,
}