mirror of
https://github.com/servo/servo.git
synced 2025-07-25 08:10:21 +01:00
Added Debug implementations.
This commit is contained in:
parent
07f6e11485
commit
a47e94c8f6
7 changed files with 53 additions and 6 deletions
|
@ -4,9 +4,10 @@
|
||||||
|
|
||||||
use ipc_channel::ipc::IpcSharedMemory;
|
use ipc_channel::ipc::IpcSharedMemory;
|
||||||
use piston_image::{self, DynamicImage, ImageFormat};
|
use piston_image::{self, DynamicImage, ImageFormat};
|
||||||
|
use std::fmt;
|
||||||
use webrender_traits;
|
use webrender_traits;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Deserialize, Eq, PartialEq, Serialize, HeapSizeOf)]
|
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize, HeapSizeOf)]
|
||||||
pub enum PixelFormat {
|
pub enum PixelFormat {
|
||||||
/// Luminance channel only
|
/// Luminance channel only
|
||||||
K8,
|
K8,
|
||||||
|
@ -29,7 +30,14 @@ pub struct Image {
|
||||||
pub id: Option<webrender_traits::ImageKey>,
|
pub id: Option<webrender_traits::ImageKey>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Deserialize, Eq, PartialEq, Serialize, HeapSizeOf)]
|
impl fmt::Debug for Image {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
write!(f, "Image {{ width: {}, height: {}, format: {:?}, ..., id: {:?} }}",
|
||||||
|
self.width, self.height, self.format, self.id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, HeapSizeOf)]
|
||||||
pub struct ImageMetadata {
|
pub struct ImageMetadata {
|
||||||
pub width: u32,
|
pub width: u32,
|
||||||
pub height: u32,
|
pub height: u32,
|
||||||
|
|
|
@ -60,7 +60,7 @@ impl ImageResponder {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The returned image.
|
/// The returned image.
|
||||||
#[derive(Clone, Deserialize, Serialize, HeapSizeOf)]
|
#[derive(Clone, Debug, Deserialize, Serialize, HeapSizeOf)]
|
||||||
pub enum ImageResponse {
|
pub enum ImageResponse {
|
||||||
/// The requested image was loaded.
|
/// The requested image was loaded.
|
||||||
Loaded(Arc<Image>, ServoUrl),
|
Loaded(Arc<Image>, ServoUrl),
|
||||||
|
@ -84,7 +84,7 @@ pub enum ImageState {
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, Deserialize, Serialize, HeapSizeOf, Hash, Debug)]
|
#[derive(Copy, Clone, PartialEq, Eq, Deserialize, Serialize, HeapSizeOf, Hash, Debug)]
|
||||||
pub struct PendingImageId(pub u64);
|
pub struct PendingImageId(pub u64);
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct PendingImageResponse {
|
pub struct PendingImageResponse {
|
||||||
pub response: ImageResponse,
|
pub response: ImageResponse,
|
||||||
pub id: PendingImageId,
|
pub id: PendingImageId,
|
||||||
|
|
|
@ -27,6 +27,7 @@ use script_thread::{Runnable, STACK_ROOTS, trace_thread};
|
||||||
use servo_config::opts;
|
use servo_config::opts;
|
||||||
use servo_config::prefs::PREFS;
|
use servo_config::prefs::PREFS;
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
|
use std::fmt;
|
||||||
use std::io::{Write, stdout};
|
use std::io::{Write, stdout};
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::os;
|
use std::os;
|
||||||
|
@ -45,6 +46,15 @@ pub enum CommonScriptMsg {
|
||||||
RunnableMsg(ScriptThreadEventCategory, Box<Runnable + Send>),
|
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.
|
/// A cloneable interface for communicating with an event loop.
|
||||||
pub trait ScriptChan: JSTraceable {
|
pub trait ScriptChan: JSTraceable {
|
||||||
/// Send a message to the associated event loop.
|
/// Send a message to the associated event loop.
|
||||||
|
|
|
@ -232,6 +232,7 @@ pub trait Runnable {
|
||||||
fn main_thread_handler(self: Box<Self>, _script_thread: &ScriptThread) { self.handler(); }
|
fn main_thread_handler(self: Box<Self>, _script_thread: &ScriptThread) { self.handler(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
enum MixedMessage {
|
enum MixedMessage {
|
||||||
FromConstellation(ConstellationControlMsg),
|
FromConstellation(ConstellationControlMsg),
|
||||||
FromScript(MainThreadScriptMsg),
|
FromScript(MainThreadScriptMsg),
|
||||||
|
@ -241,6 +242,7 @@ enum MixedMessage {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Messages used to control the script event loop
|
/// Messages used to control the script event loop
|
||||||
|
#[derive(Debug)]
|
||||||
pub enum MainThreadScriptMsg {
|
pub enum MainThreadScriptMsg {
|
||||||
/// Common variants associated with the script messages
|
/// Common variants associated with the script messages
|
||||||
Common(CommonScriptMsg),
|
Common(CommonScriptMsg),
|
||||||
|
@ -983,6 +985,7 @@ impl ScriptThread {
|
||||||
|
|
||||||
// Process the gathered events.
|
// Process the gathered events.
|
||||||
for msg in sequential {
|
for msg in sequential {
|
||||||
|
debug!("Processing event {:?}.", msg);
|
||||||
let category = self.categorize_msg(&msg);
|
let category = self.categorize_msg(&msg);
|
||||||
|
|
||||||
let result = self.profile_event(category, move || {
|
let result = self.profile_event(category, move || {
|
||||||
|
|
|
@ -9,6 +9,7 @@ use dom::eventtarget::EventTarget;
|
||||||
use dom::window::Window;
|
use dom::window::Window;
|
||||||
use script_thread::{MainThreadScriptMsg, Runnable, RunnableWrapper, ScriptThread};
|
use script_thread::{MainThreadScriptMsg, Runnable, RunnableWrapper, ScriptThread};
|
||||||
use servo_atoms::Atom;
|
use servo_atoms::Atom;
|
||||||
|
use std::fmt;
|
||||||
use std::result::Result;
|
use std::result::Result;
|
||||||
use std::sync::mpsc::Sender;
|
use std::sync::mpsc::Sender;
|
||||||
use task_source::TaskSource;
|
use task_source::TaskSource;
|
||||||
|
@ -16,6 +17,12 @@ use task_source::TaskSource;
|
||||||
#[derive(JSTraceable, Clone)]
|
#[derive(JSTraceable, Clone)]
|
||||||
pub struct DOMManipulationTaskSource(pub Sender<MainThreadScriptMsg>);
|
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 {
|
impl TaskSource for DOMManipulationTaskSource {
|
||||||
fn queue_with_wrapper<T>(&self,
|
fn queue_with_wrapper<T>(&self,
|
||||||
msg: Box<T>,
|
msg: Box<T>,
|
||||||
|
@ -56,6 +63,12 @@ impl DOMManipulationTaskSource {
|
||||||
|
|
||||||
pub struct DOMManipulationTask(pub Box<Runnable + Send>);
|
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 {
|
impl DOMManipulationTask {
|
||||||
pub fn handle_task(self, script_thread: &ScriptThread) {
|
pub fn handle_task(self, script_thread: &ScriptThread) {
|
||||||
if !self.0.is_cancelled() {
|
if !self.0.is_cancelled() {
|
||||||
|
|
|
@ -9,6 +9,7 @@ use dom::eventtarget::EventTarget;
|
||||||
use dom::window::Window;
|
use dom::window::Window;
|
||||||
use script_thread::{MainThreadScriptMsg, Runnable, RunnableWrapper, ScriptThread};
|
use script_thread::{MainThreadScriptMsg, Runnable, RunnableWrapper, ScriptThread};
|
||||||
use servo_atoms::Atom;
|
use servo_atoms::Atom;
|
||||||
|
use std::fmt;
|
||||||
use std::result::Result;
|
use std::result::Result;
|
||||||
use std::sync::mpsc::Sender;
|
use std::sync::mpsc::Sender;
|
||||||
use task_source::TaskSource;
|
use task_source::TaskSource;
|
||||||
|
@ -16,6 +17,12 @@ use task_source::TaskSource;
|
||||||
#[derive(JSTraceable, Clone)]
|
#[derive(JSTraceable, Clone)]
|
||||||
pub struct UserInteractionTaskSource(pub Sender<MainThreadScriptMsg>);
|
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 {
|
impl TaskSource for UserInteractionTaskSource {
|
||||||
fn queue_with_wrapper<T>(&self,
|
fn queue_with_wrapper<T>(&self,
|
||||||
msg: Box<T>,
|
msg: Box<T>,
|
||||||
|
@ -47,6 +54,12 @@ impl UserInteractionTaskSource {
|
||||||
|
|
||||||
pub struct UserInteractionTask(pub Box<Runnable + Send>);
|
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 {
|
impl UserInteractionTask {
|
||||||
pub fn handle_task(self, script_thread: &ScriptThread) {
|
pub fn handle_task(self, script_thread: &ScriptThread) {
|
||||||
if !self.0.is_cancelled() {
|
if !self.0.is_cancelled() {
|
||||||
|
|
|
@ -451,11 +451,11 @@ pub enum TimerSchedulerMsg {
|
||||||
/// Notifies the script thread to fire due timers.
|
/// Notifies the script thread to fire due timers.
|
||||||
/// `TimerSource` must be `FromWindow` when dispatched to `ScriptThread` and
|
/// `TimerSource` must be `FromWindow` when dispatched to `ScriptThread` and
|
||||||
/// must be `FromWorker` when dispatched to a `DedicatedGlobalWorkerScope`
|
/// must be `FromWorker` when dispatched to a `DedicatedGlobalWorkerScope`
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct TimerEvent(pub TimerSource, pub TimerEventId);
|
pub struct TimerEvent(pub TimerSource, pub TimerEventId);
|
||||||
|
|
||||||
/// Describes the thread that requested the TimerEvent.
|
/// Describes the thread that requested the TimerEvent.
|
||||||
#[derive(Copy, Clone, HeapSizeOf, Deserialize, Serialize)]
|
#[derive(Copy, Clone, Debug, HeapSizeOf, Deserialize, Serialize)]
|
||||||
pub enum TimerSource {
|
pub enum TimerSource {
|
||||||
/// The event was requested from a window (ScriptThread).
|
/// The event was requested from a window (ScriptThread).
|
||||||
FromWindow(PipelineId),
|
FromWindow(PipelineId),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue