use std::collections::HashMap;
use std::fmt;
use std::time::Duration;
use base::id::{BrowsingContextId, PipelineId, TopLevelBrowsingContextId, WebViewId};
use base::Epoch;
use embedder_traits::{
Cursor, InputEvent, MediaSessionActionType, Theme, TraversalDirection, WebDriverCommandMsg,
};
use ipc_channel::ipc::IpcSender;
use script_traits::{AnimationTickType, LogEntry, WindowSizeData, WindowSizeType};
use servo_url::ServoUrl;
use webrender_traits::CompositorHitTestResult;
pub enum ConstellationMsg {
Exit,
GetBrowsingContext(PipelineId, IpcSender<Option<BrowsingContextId>>),
GetPipeline(BrowsingContextId, IpcSender<Option<PipelineId>>),
GetFocusTopLevelBrowsingContext(IpcSender<Option<TopLevelBrowsingContextId>>),
IsReadyToSaveImage(HashMap<PipelineId, Epoch>),
AllowNavigationResponse(PipelineId, bool),
LoadUrl(TopLevelBrowsingContextId, ServoUrl),
ClearCache,
TraverseHistory(TopLevelBrowsingContextId, TraversalDirection),
WindowSize(TopLevelBrowsingContextId, WindowSizeData, WindowSizeType),
ThemeChange(Theme),
TickAnimation(PipelineId, AnimationTickType),
WebDriverCommand(WebDriverCommandMsg),
Reload(TopLevelBrowsingContextId),
LogEntry(Option<TopLevelBrowsingContextId>, Option<String>, LogEntry),
NewWebView(ServoUrl, TopLevelBrowsingContextId),
CloseWebView(TopLevelBrowsingContextId),
SendError(Option<TopLevelBrowsingContextId>, String),
FocusWebView(TopLevelBrowsingContextId),
BlurWebView,
ForwardInputEvent(InputEvent, Option<CompositorHitTestResult>),
SetCursor(WebViewId, Cursor),
ToggleProfiler(Duration, Duration),
ExitFullScreen(TopLevelBrowsingContextId),
MediaSessionAction(MediaSessionActionType),
SetWebViewThrottled(TopLevelBrowsingContextId, bool),
}
impl fmt::Debug for ConstellationMsg {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
write!(formatter, "ConstellationMsg::{}", self.variant_name())
}
}
impl ConstellationMsg {
pub fn variant_name(&self) -> &'static str {
use self::ConstellationMsg::*;
match *self {
Exit => "Exit",
GetBrowsingContext(..) => "GetBrowsingContext",
GetPipeline(..) => "GetPipeline",
GetFocusTopLevelBrowsingContext(..) => "GetFocusTopLevelBrowsingContext",
IsReadyToSaveImage(..) => "IsReadyToSaveImage",
AllowNavigationResponse(..) => "AllowNavigationResponse",
LoadUrl(..) => "LoadUrl",
TraverseHistory(..) => "TraverseHistory",
WindowSize(..) => "WindowSize",
ThemeChange(..) => "ThemeChange",
TickAnimation(..) => "TickAnimation",
WebDriverCommand(..) => "WebDriverCommand",
Reload(..) => "Reload",
LogEntry(..) => "LogEntry",
NewWebView(..) => "NewWebView",
CloseWebView(..) => "CloseWebView",
FocusWebView(..) => "FocusWebView",
BlurWebView => "BlurWebView",
SendError(..) => "SendError",
ForwardInputEvent(..) => "ForwardEvent",
SetCursor(..) => "SetCursor",
ToggleProfiler(..) => "EnableProfiler",
ExitFullScreen(..) => "ExitFullScreen",
MediaSessionAction(..) => "MediaSessionAction",
SetWebViewThrottled(..) => "SetWebViewThrottled",
ClearCache => "ClearCache",
}
}
}