author | Anthony Ramine <n.oxyde@gmail.com> |
Fri, 08 Sep 2017 06:01:22 -0500 | |
changeset 379714 | 01b0b8eea73fe9b9db4f2138cdf7d120411fe6d7 |
parent 379713 | 9451690a4f75eb55b391332ad7900e2484216848 |
child 379715 | 915065b1b334373c68e36f583ca35ee7855e05ae |
push id | 32461 |
push user | kwierso@gmail.com |
push date | Fri, 08 Sep 2017 20:15:32 +0000 |
treeherder | mozilla-central@dd3736e98e4e [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | emilio |
milestone | 57.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/servo/components/script/script_thread.rs +++ b/servo/components/script/script_thread.rs @@ -109,22 +109,22 @@ use std::ptr; use std::rc::Rc; use std::result::Result; use std::sync::Arc; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::mpsc::{Receiver, Select, Sender, channel}; use std::thread; use style::context::ReflowGoal; use style::thread_state; -use task_source::dom_manipulation::{DOMManipulationTask, DOMManipulationTaskSource}; +use task_source::dom_manipulation::DOMManipulationTaskSource; use task_source::file_reading::FileReadingTaskSource; use task_source::history_traversal::HistoryTraversalTaskSource; use task_source::networking::NetworkingTaskSource; use task_source::performance_timeline::PerformanceTimelineTaskSource; -use task_source::user_interaction::{UserInteractionTask, UserInteractionTaskSource}; +use task_source::user_interaction::UserInteractionTaskSource; use time::{get_time, precise_time_ns, Tm}; use url::Position; use webdriver_handlers; use webvr_traits::{WebVREvent, WebVRMsg}; pub type ImageCacheMsg = (PipelineId, PendingImageResponse); thread_local!(pub static STACK_ROOTS: Cell<Option<RootCollectionPtr>> = Cell::new(None)); @@ -246,17 +246,19 @@ where if !self.is_cancelled() { self.inner.handler() } } } pub trait Runnable { fn name(&self) -> &'static str { unsafe { intrinsics::type_name::<Self>() } } - fn handler(self: Box<Self>) {} + fn handler(self: Box<Self>) { + panic!("This should probably be redefined.") + } fn main_thread_handler(self: Box<Self>, _script_thread: &ScriptThread) { self.handler(); } } #[derive(Debug)] enum MixedMessage { FromConstellation(ConstellationControlMsg), FromScript(MainThreadScriptMsg), FromDevtools(DevtoolScriptControlMsg), @@ -271,20 +273,16 @@ pub enum MainThreadScriptMsg { Common(CommonScriptMsg), /// Notifies the script that a window associated with a particular pipeline /// should be closed (only dispatched to ScriptThread). ExitWindow(PipelineId), /// Begins a content-initiated load on the specified pipeline (only /// dispatched to ScriptThread). Allows for a replace bool to be passed. If true, /// the current entry will be replaced instead of a new entry being added. Navigate(PipelineId, LoadData, bool), - /// Tasks that originate from the DOM manipulation task source - DOMManipulation(DOMManipulationTask), - /// Tasks that originate from the user interaction task source - UserInteraction(UserInteractionTask), /// Notifies the script thread that a new worklet has been loaded, and thus the page should be /// reflowed. WorkletLoaded(PipelineId), } impl OpaqueSender<CommonScriptMsg> for Box<ScriptChan + Send> { fn send(&self, msg: CommonScriptMsg) { ScriptChan::send(&**self, msg).unwrap(); @@ -1280,33 +1278,31 @@ impl ScriptThread { msg @ ConstellationControlMsg::Resize(..) | msg @ ConstellationControlMsg::ExitScriptThread => panic!("should have handled {:?} already", msg), } } fn handle_msg_from_script(&self, msg: MainThreadScriptMsg) { match msg { - MainThreadScriptMsg::Navigate(parent_pipeline_id, load_data, replace) => - self.handle_navigate(parent_pipeline_id, None, load_data, replace), - MainThreadScriptMsg::ExitWindow(id) => - self.handle_exit_window_msg(id), + MainThreadScriptMsg::Navigate(parent_pipeline_id, load_data, replace) => { + self.handle_navigate(parent_pipeline_id, None, load_data, replace) + }, + MainThreadScriptMsg::ExitWindow(id) => { + self.handle_exit_window_msg(id) + }, MainThreadScriptMsg::Common(CommonScriptMsg::RunnableMsg(_, runnable)) => { - // The category of the runnable is ignored by the pattern, however - // it is still respected by profiling (see categorize_msg). runnable.main_thread_handler(self) } - MainThreadScriptMsg::Common(CommonScriptMsg::CollectReports(reports_chan)) => - self.collect_reports(reports_chan), - MainThreadScriptMsg::WorkletLoaded(pipeline_id) => - self.handle_worklet_loaded(pipeline_id), - MainThreadScriptMsg::DOMManipulation(task) => - task.handle_task(self), - MainThreadScriptMsg::UserInteraction(task) => - task.handle_task(self), + MainThreadScriptMsg::Common(CommonScriptMsg::CollectReports(chan)) => { + self.collect_reports(chan) + }, + MainThreadScriptMsg::WorkletLoaded(pipeline_id) => { + self.handle_worklet_loaded(pipeline_id) + }, } } fn handle_timer_event(&self, timer_event: TimerEvent) { let TimerEvent(source, id) = timer_event; let pipeline_id = match source { TimerSource::FromWindow(pipeline_id) => pipeline_id,
--- a/servo/components/script/task_source/dom_manipulation.rs +++ b/servo/components/script/task_source/dom_manipulation.rs @@ -2,40 +2,47 @@ * 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 dom::bindings::inheritance::Castable; use dom::bindings::refcounted::Trusted; use dom::event::{EventBubbles, EventCancelable, EventRunnable, SimpleEventRunnable}; use dom::eventtarget::EventTarget; use dom::window::Window; -use script_thread::{MainThreadScriptMsg, Runnable, RunnableWrapper, ScriptThread}; +use script_runtime::{CommonScriptMsg, ScriptThreadEventCategory}; +use script_thread::{MainThreadScriptMsg, Runnable, RunnableWrapper}; use servo_atoms::Atom; use std::fmt; use std::result::Result; use std::sync::mpsc::Sender; use task_source::TaskSource; #[derive(Clone, JSTraceable)] pub struct DOMManipulationTaskSource(pub Sender<MainThreadScriptMsg>); impl fmt::Debug for DOMManipulationTaskSource { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "DOMManipulationTaskSource(...)") } } impl TaskSource for DOMManipulationTaskSource { - fn queue_with_wrapper<T>(&self, - msg: Box<T>, - wrapper: &RunnableWrapper) - -> Result<(), ()> - where T: Runnable + Send + 'static { - let msg = DOMManipulationTask(wrapper.wrap_runnable(msg)); - self.0.send(MainThreadScriptMsg::DOMManipulation(msg)).map_err(|_| ()) + fn queue_with_wrapper<T>( + &self, + msg: Box<T>, + wrapper: &RunnableWrapper, + ) -> Result<(), ()> + where + T: Runnable + Send + 'static, + { + let msg = MainThreadScriptMsg::Common(CommonScriptMsg::RunnableMsg( + ScriptThreadEventCategory::ScriptEvent, + wrapper.wrap_runnable(msg), + )); + self.0.send(msg).map_err(|_| ()) } } impl DOMManipulationTaskSource { pub fn queue_event(&self, target: &EventTarget, name: Atom, bubbles: EventBubbles, @@ -55,22 +62,8 @@ impl DOMManipulationTaskSource { let target = Trusted::new(target); let runnable = box SimpleEventRunnable { target: target, name: name, }; let _ = self.queue(runnable, window.upcast()); } } - -pub struct DOMManipulationTask(pub Box<Runnable + Send>); - -impl fmt::Debug for DOMManipulationTask { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "DOMManipulationTask(...)") - } -} - -impl DOMManipulationTask { - pub fn handle_task(self, script_thread: &ScriptThread) { - self.0.main_thread_handler(script_thread); - } -}
--- a/servo/components/script/task_source/user_interaction.rs +++ b/servo/components/script/task_source/user_interaction.rs @@ -2,40 +2,47 @@ * 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 dom::bindings::inheritance::Castable; use dom::bindings::refcounted::Trusted; use dom::event::{EventBubbles, EventCancelable, EventRunnable}; use dom::eventtarget::EventTarget; use dom::window::Window; -use script_thread::{MainThreadScriptMsg, Runnable, RunnableWrapper, ScriptThread}; +use script_runtime::{CommonScriptMsg, ScriptThreadEventCategory}; +use script_thread::{MainThreadScriptMsg, Runnable, RunnableWrapper}; use servo_atoms::Atom; use std::fmt; use std::result::Result; use std::sync::mpsc::Sender; use task_source::TaskSource; #[derive(Clone, JSTraceable)] pub struct UserInteractionTaskSource(pub Sender<MainThreadScriptMsg>); impl fmt::Debug for UserInteractionTaskSource { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "UserInteractionTaskSource(...)") } } impl TaskSource for UserInteractionTaskSource { - fn queue_with_wrapper<T>(&self, - msg: Box<T>, - wrapper: &RunnableWrapper) - -> Result<(), ()> - where T: Runnable + Send + 'static { - let msg = UserInteractionTask(wrapper.wrap_runnable(msg)); - self.0.send(MainThreadScriptMsg::UserInteraction(msg)).map_err(|_| ()) + fn queue_with_wrapper<T>( + &self, + msg: Box<T>, + wrapper: &RunnableWrapper, + ) -> Result<(), ()> + where + T: Runnable + Send + 'static, + { + let msg = MainThreadScriptMsg::Common(CommonScriptMsg::RunnableMsg( + ScriptThreadEventCategory::InputEvent, + wrapper.wrap_runnable(msg), + )); + self.0.send(msg).map_err(|_| ()) } } impl UserInteractionTaskSource { pub fn queue_event(&self, target: &EventTarget, name: Atom, bubbles: EventBubbles, @@ -46,22 +53,8 @@ impl UserInteractionTaskSource { target: target, name: name, bubbles: bubbles, cancelable: cancelable, }; let _ = self.queue(runnable, window.upcast()); } } - -pub struct UserInteractionTask(pub Box<Runnable + Send>); - -impl fmt::Debug for UserInteractionTask { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "UserInteractionTask(...)") - } -} - -impl UserInteractionTask { - pub fn handle_task(self, script_thread: &ScriptThread) { - self.0.main_thread_handler(script_thread); - } -}