script: Implement Debug on ConstellationControlMsg to simplify script_thread.rs

This commit is contained in:
Emilio Cobos Álvarez 2016-07-08 14:36:38 -07:00
parent ca9bc23b39
commit 2e68821014
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
2 changed files with 38 additions and 10 deletions

View file

@ -61,6 +61,7 @@ use profile_traits::mem;
use profile_traits::time as profile_time;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::collections::HashMap;
use std::fmt;
use std::sync::mpsc::{Sender, Receiver};
use style_traits::{PagePx, ViewportPx};
use url::Url;
@ -207,6 +208,37 @@ pub enum ConstellationControlMsg {
Reload(PipelineId),
}
impl fmt::Debug for ConstellationControlMsg {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
use self::ConstellationControlMsg::*;
write!(formatter, "ConstellationMsg::{}", match *self {
AttachLayout(..) => "AttachLayout",
Resize(..) => "Resize",
ResizeInactive(..) => "ResizeInactive",
ExitPipeline(..) => "ExitPipeline",
SendEvent(..) => "SendEvent",
Viewport(..) => "Viewport",
SetScrollState(..) => "SetScrollState",
GetTitle(..) => "GetTitle",
Freeze(..) => "Freeze",
Thaw(..) => "Thaw",
ChangeFrameVisibilityStatus(..) => "ChangeFrameVisibilityStatus",
NotifyVisibilityChange(..) => "NotifyVisibilityChange",
Navigate(..) => "Navigate",
MozBrowserEvent(..) => "MozBrowserEvent",
UpdateSubpageId(..) => "UpdateSubpageId",
FocusIFrame(..) => "FocusIFrame",
WebDriverScriptCommand(..) => "WebDriverScriptCommand",
TickAllAnimations(..) => "TickAllAnimations",
WebFontLoaded(..) => "WebFontLoaded",
DispatchFrameLoadEvent { .. } => "DispatchFrameLoadEvent",
FramedContentChanged(..) => "FramedContentChanged",
ReportCSSError(..) => "ReportCSSError",
Reload(..) => "Reload",
})
}
}
/// Used to determine if a script has any pending asynchronous activity.
#[derive(Copy, Clone, Debug, PartialEq, Deserialize, Serialize)]
pub enum DocumentState {