Added Debug implementations.

This commit is contained in:
Alan Jeffrey 2017-06-13 10:46:59 -05:00
parent 07f6e11485
commit a47e94c8f6
7 changed files with 53 additions and 6 deletions

View file

@ -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.

View file

@ -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 || {

View file

@ -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() {

View file

@ -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() {