diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2017-06-13 10:31:25 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-13 10:31:25 -0700 |
commit | 6db2354b7345a8e9981ebde25806a4597a1e2b4d (patch) | |
tree | aa693d84ed447bffa9259853f08a8579f279a06b /components/script | |
parent | fe573c1ce9a7cbacf69a846ad966c429faa61703 (diff) | |
parent | a47e94c8f6b37de9845c824c6a8a488728a1d0c1 (diff) | |
download | servo-6db2354b7345a8e9981ebde25806a4597a1e2b4d.tar.gz servo-6db2354b7345a8e9981ebde25806a4597a1e2b4d.zip |
Auto merge of #17298 - asajeffrey:script-more-debug-impls, r=mbrubeck
Added Debug implementations.
<!-- Please describe your changes on the following line: -->
Added enough `Debug` implementations to be able to debug script thread message processing.
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes do not require tests because we don't test debugging
<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17298)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script')
-rw-r--r-- | components/script/script_runtime.rs | 10 | ||||
-rw-r--r-- | components/script/script_thread.rs | 3 | ||||
-rw-r--r-- | components/script/task_source/dom_manipulation.rs | 13 | ||||
-rw-r--r-- | components/script/task_source/user_interaction.rs | 13 |
4 files changed, 39 insertions, 0 deletions
diff --git a/components/script/script_runtime.rs b/components/script/script_runtime.rs index 8c243b18695..efbdb6bdc40 100644 --- a/components/script/script_runtime.rs +++ b/components/script/script_runtime.rs @@ -27,6 +27,7 @@ use script_thread::{Runnable, STACK_ROOTS, trace_thread}; use servo_config::opts; use servo_config::prefs::PREFS; use std::cell::Cell; +use std::fmt; use std::io::{Write, stdout}; use std::marker::PhantomData; use std::os; @@ -45,6 +46,15 @@ pub enum CommonScriptMsg { RunnableMsg(ScriptThreadEventCategory, Box<Runnable + Send>), } +impl fmt::Debug for CommonScriptMsg { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + CommonScriptMsg::CollectReports(_) => write!(f, "CollectReports(...)"), + CommonScriptMsg::RunnableMsg(category, _) => write!(f, "RunnableMsg({:?}, ...)", category), + } + } +} + /// A cloneable interface for communicating with an event loop. pub trait ScriptChan: JSTraceable { /// Send a message to the associated event loop. diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 8dabb29c81b..fcb351cebb2 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -232,6 +232,7 @@ pub trait Runnable { fn main_thread_handler(self: Box<Self>, _script_thread: &ScriptThread) { self.handler(); } } +#[derive(Debug)] enum MixedMessage { FromConstellation(ConstellationControlMsg), FromScript(MainThreadScriptMsg), @@ -241,6 +242,7 @@ enum MixedMessage { } /// Messages used to control the script event loop +#[derive(Debug)] pub enum MainThreadScriptMsg { /// Common variants associated with the script messages Common(CommonScriptMsg), @@ -983,6 +985,7 @@ impl ScriptThread { // Process the gathered events. for msg in sequential { + debug!("Processing event {:?}.", msg); let category = self.categorize_msg(&msg); let result = self.profile_event(category, move || { diff --git a/components/script/task_source/dom_manipulation.rs b/components/script/task_source/dom_manipulation.rs index 75fd4021168..12deff1880e 100644 --- a/components/script/task_source/dom_manipulation.rs +++ b/components/script/task_source/dom_manipulation.rs @@ -9,6 +9,7 @@ use dom::eventtarget::EventTarget; use dom::window::Window; use script_thread::{MainThreadScriptMsg, Runnable, RunnableWrapper, ScriptThread}; use servo_atoms::Atom; +use std::fmt; use std::result::Result; use std::sync::mpsc::Sender; use task_source::TaskSource; @@ -16,6 +17,12 @@ use task_source::TaskSource; #[derive(JSTraceable, Clone)] 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>, @@ -56,6 +63,12 @@ impl DOMManipulationTaskSource { 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) { if !self.0.is_cancelled() { diff --git a/components/script/task_source/user_interaction.rs b/components/script/task_source/user_interaction.rs index c97e1e1895a..2878a347eb4 100644 --- a/components/script/task_source/user_interaction.rs +++ b/components/script/task_source/user_interaction.rs @@ -9,6 +9,7 @@ use dom::eventtarget::EventTarget; use dom::window::Window; use script_thread::{MainThreadScriptMsg, Runnable, RunnableWrapper, ScriptThread}; use servo_atoms::Atom; +use std::fmt; use std::result::Result; use std::sync::mpsc::Sender; use task_source::TaskSource; @@ -16,6 +17,12 @@ use task_source::TaskSource; #[derive(JSTraceable, Clone)] 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>, @@ -47,6 +54,12 @@ impl UserInteractionTaskSource { 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) { if !self.0.is_cancelled() { |