Skip to content
Permalink
Browse files

Cleanup constellation debug messages

  • Loading branch information
cbrewster committed May 18, 2018
1 parent a8bdd44 commit ee3c26c56c7e352571bc6cc8bb66ab20404bdafa
Showing with 104 additions and 55 deletions.
  1. +4 −54 components/constellation/constellation.rs
  2. +29 −1 components/script_traits/lib.rs
  3. +71 −0 components/script_traits/script_msg.rs
@@ -916,35 +916,30 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
}

fn handle_request_from_compositor(&mut self, message: FromCompositorMsg) {
debug!("constellation got {:?} message", message);
match message {
FromCompositorMsg::Exit => {
debug!("constellation exiting");
self.handle_exit();
}
FromCompositorMsg::GetBrowsingContext(pipeline_id, resp_chan) => {
debug!("constellation got get browsing context message");
self.handle_get_browsing_context(pipeline_id, resp_chan);
}
FromCompositorMsg::GetPipeline(browsing_context_id, resp_chan) => {
debug!("constellation got get pipeline message");
self.handle_get_pipeline(browsing_context_id, resp_chan);
}
FromCompositorMsg::GetFocusTopLevelBrowsingContext(resp_chan) => {
debug!("constellation got get focus browsing context message");
let focus_browsing_context = self.focus_pipeline_id
.and_then(|pipeline_id| self.pipelines.get(&pipeline_id))
.map(|pipeline| pipeline.top_level_browsing_context_id);
let _ = resp_chan.send(focus_browsing_context);
}
FromCompositorMsg::KeyEvent(ch, key, state, modifiers) => {
debug!("constellation got key event message");
self.handle_key_msg(ch, key, state, modifiers);
}
// Load a new page from a typed url
// If there is already a pending page (self.pending_changes), it will not be overridden;
// However, if the id is not encompassed by another change, it will be.
FromCompositorMsg::LoadUrl(top_level_browsing_context_id, url) => {
debug!("constellation got URL load message from compositor");
let load_data = LoadData::new(url, None, None, None);
let ctx_id = BrowsingContextId::from(top_level_browsing_context_id);
let pipeline_id = match self.browsing_contexts.get(&ctx_id) {
@@ -968,12 +963,10 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
// Create a new top level browsing context. Will use response_chan to return
// the browsing context id.
FromCompositorMsg::NewBrowser(url, response_chan) => {
debug!("constellation got NewBrowser message");
self.handle_new_top_level_browsing_context(url, response_chan);
}
// Close a top level browsing context.
FromCompositorMsg::CloseBrowser(top_level_browsing_context_id) => {
debug!("constellation got CloseBrowser message");
self.handle_close_top_level_browsing_context(top_level_browsing_context_id);
}
// Send frame tree to WebRender. Make it visible.
@@ -982,29 +975,24 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
}
// Handle a forward or back request
FromCompositorMsg::TraverseHistory(top_level_browsing_context_id, direction) => {
debug!("constellation got traverse history message from compositor");
self.handle_traverse_history_msg(top_level_browsing_context_id, direction);
}
FromCompositorMsg::WindowSize(top_level_browsing_context_id, new_size, size_type) => {
debug!("constellation got window resize message");
self.handle_window_size_msg(top_level_browsing_context_id, new_size, size_type);
}
FromCompositorMsg::TickAnimation(pipeline_id, tick_type) => {
self.handle_tick_animation(pipeline_id, tick_type)
}
FromCompositorMsg::WebDriverCommand(command) => {
debug!("constellation got webdriver command message");
self.handle_webdriver_msg(command);
}
FromCompositorMsg::Reload(top_level_browsing_context_id) => {
debug!("constellation got reload message");
self.handle_reload_msg(top_level_browsing_context_id);
}
FromCompositorMsg::LogEntry(top_level_browsing_context_id, thread_name, entry) => {
self.handle_log_entry(top_level_browsing_context_id, thread_name, entry);
}
FromCompositorMsg::WebVREvents(pipeline_ids, events) => {
debug!("constellation got {:?} WebVR events", events.len());
self.handle_webvr_events(pipeline_ids, events);
}
FromCompositorMsg::ForwardEvent(destination_pipeline_id, event) => {
@@ -1018,6 +1006,8 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>

fn handle_request_from_script(&mut self, message: (PipelineId, FromScriptMsg)) {
let (source_pipeline_id, content) = message;
debug!("constellation got {:?} message from pipeline {}", content, source_pipeline_id);

let source_top_ctx_id = match self.pipelines.get(&source_pipeline_id)
.map(|pipeline| pipeline.top_level_browsing_context_id) {
None => return warn!("ScriptMsg from closed pipeline {:?}.", source_pipeline_id),
@@ -1037,20 +1027,12 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
self.handle_discard_document(source_top_ctx_id, source_pipeline_id);
}
FromScriptMsg::InitiateNavigateRequest(req_init, cancel_chan) => {
debug!("constellation got initiate navigate request message");
self.handle_navigate_request(source_pipeline_id, req_init, cancel_chan);
}
FromScriptMsg::ScriptLoadedURLInIFrame(load_info) => {
debug!("constellation got iframe URL load message {:?} {:?} {:?}",
load_info.info.parent_pipeline_id,
load_info.old_pipeline_id,
load_info.info.new_pipeline_id);
self.handle_script_loaded_url_in_iframe_msg(load_info);
}
FromScriptMsg::ScriptNewIFrame(load_info, layout_sender) => {
debug!("constellation got loaded `about:blank` in iframe message {:?} {:?}",
load_info.parent_pipeline_id,
load_info.new_pipeline_id);
self.handle_script_new_iframe(load_info, layout_sender);
}
FromScriptMsg::ChangeRunningAnimationsState(animation_state) => {
@@ -1060,58 +1042,47 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
// If there is already a pending page (self.pending_changes), it will not be overridden;
// However, if the id is not encompassed by another change, it will be.
FromScriptMsg::LoadUrl(load_data, replace) => {
debug!("constellation got URL load message from script");
self.handle_load_url_msg(source_top_ctx_id, source_pipeline_id, load_data, replace);
}
FromScriptMsg::AbortLoadUrl => {
debug!("constellation got abort URL load message from script");
self.handle_abort_load_url_msg(source_pipeline_id);
}
// A page loaded has completed all parsing, script, and reflow messages have been sent.
FromScriptMsg::LoadComplete => {
debug!("constellation got load complete message");
self.handle_load_complete_msg(source_top_ctx_id, source_pipeline_id)
}
// Handle a forward or back request
FromScriptMsg::TraverseHistory(direction) => {
debug!("constellation got traverse history message from script");
self.handle_traverse_history_msg(source_top_ctx_id, direction);
}
// Handle a push history state request.
FromScriptMsg::PushHistoryState(history_state_id, url) => {
debug!("constellation got push history state message from script");
self.handle_push_history_state_msg(source_pipeline_id, history_state_id, url);
}
FromScriptMsg::ReplaceHistoryState(history_state_id, url) => {
debug!("constellation got replace history state message from script");
self.handle_replace_history_state_msg(source_pipeline_id, history_state_id, url);
}
// Handle a joint session history length request.
FromScriptMsg::JointSessionHistoryLength(sender) => {
debug!("constellation got joint session history length message from script");
self.handle_joint_session_history_length(source_top_ctx_id, sender);
}
// Notification that the new document is ready to become active
FromScriptMsg::ActivateDocument => {
debug!("constellation got activate document message");
self.handle_activate_document_msg(source_pipeline_id);
}
// Update pipeline url after redirections
FromScriptMsg::SetFinalUrl(final_url) => {
// The script may have finished loading after we already started shutting down.
if let Some(ref mut pipeline) = self.pipelines.get_mut(&source_pipeline_id) {
debug!("constellation got set final url message");
pipeline.url = final_url;
} else {
warn!("constellation got set final url message for dead pipeline");
}
}
FromScriptMsg::PostMessage(browsing_context_id, origin, data) => {
debug!("constellation got postMessage message");
self.handle_post_message_msg(browsing_context_id, origin, data);
}
FromScriptMsg::Focus => {
debug!("constellation got focus message");
self.handle_focus_msg(source_pipeline_id);
}
FromScriptMsg::GetClipboardContents(sender) => {
@@ -1137,57 +1108,45 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
}
}
FromScriptMsg::SetVisible(visible) => {
debug!("constellation got set visible messsage");
self.handle_set_visible_msg(source_pipeline_id, visible);
}
FromScriptMsg::VisibilityChangeComplete(visible) => {
debug!("constellation got set visibility change complete message");
self.handle_visibility_change_complete(source_pipeline_id, visible);
}
FromScriptMsg::RemoveIFrame(browsing_context_id, sender) => {
debug!("constellation got remove iframe message");
let removed_pipeline_ids = self.handle_remove_iframe_msg(browsing_context_id);
if let Err(e) = sender.send(removed_pipeline_ids) {
warn!("Error replying to remove iframe ({})", e);
}
}
FromScriptMsg::NewFavicon(url) => {
debug!("constellation got new favicon message");
if source_is_top_level_pipeline {
self.embedder_proxy.send(EmbedderMsg::NewFavicon(source_top_ctx_id, url));
}
}
FromScriptMsg::HeadParsed => {
debug!("constellation got head parsed message");
if source_is_top_level_pipeline {
self.embedder_proxy.send(EmbedderMsg::HeadParsed(source_top_ctx_id));
}
}
FromScriptMsg::CreateCanvasPaintThread(size, sender) => {
debug!("constellation got create-canvas-paint-thread message");
self.handle_create_canvas_paint_thread_msg(&size, sender)
}
FromScriptMsg::NodeStatus(message) => {
debug!("constellation got NodeStatus message");
self.embedder_proxy.send(EmbedderMsg::Status(source_top_ctx_id, message));
}
FromScriptMsg::SetDocumentState(state) => {
debug!("constellation got SetDocumentState message");
self.document_states.insert(source_pipeline_id, state);
}
FromScriptMsg::Alert(message, sender) => {
debug!("constellation got Alert message");
self.handle_alert(source_top_ctx_id, message, sender);
}

FromScriptMsg::MoveTo(point) => {
self.embedder_proxy.send(EmbedderMsg::MoveTo(source_top_ctx_id, point));
}

FromScriptMsg::ResizeTo(size) => {
self.embedder_proxy.send(EmbedderMsg::ResizeTo(source_top_ctx_id, size));
}

FromScriptMsg::GetClientWindow(send) => {
self.compositor_proxy.send(ToCompositorMsg::GetClientWindow(send));
}
@@ -1197,25 +1156,21 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
FromScriptMsg::GetScreenAvailSize(send) => {
self.compositor_proxy.send(ToCompositorMsg::GetScreenAvailSize(send));
}

FromScriptMsg::Exit => {
self.compositor_proxy.send(ToCompositorMsg::Exit);
}
FromScriptMsg::LogEntry(thread_name, entry) => {
self.handle_log_entry(Some(source_top_ctx_id), thread_name, entry);
}

FromScriptMsg::SetTitle(title) => {
if source_is_top_level_pipeline {
self.embedder_proxy.send(EmbedderMsg::ChangePageTitle(source_top_ctx_id, title))
}
}

FromScriptMsg::SendKeyEvent(ch, key, key_state, key_modifiers) => {
let event = EmbedderMsg::KeyEvent(Some(source_top_ctx_id), ch, key, key_state, key_modifiers);
self.embedder_proxy.send(event);
}

FromScriptMsg::TouchEventProcessed(result) => {
self.compositor_proxy.send(ToCompositorMsg::TouchEventProcessed(result))
}
@@ -1241,7 +1196,6 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
}
}
FromScriptMsg::RegisterServiceWorker(scope_things, scope) => {
debug!("constellation got store registration scope message");
self.handle_register_serviceworker(scope_things, scope);
}
FromScriptMsg::ForwardDOMMessage(msg_vec, scope_url) => {
@@ -1258,36 +1212,32 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
self.embedder_proxy.send(EmbedderMsg::SetFullscreenState(source_top_ctx_id, state));
}
FromScriptMsg::ShowIME(kind) => {
debug!("constellation got ShowIME message");
self.embedder_proxy.send(EmbedderMsg::ShowIME(source_top_ctx_id, kind));
}
FromScriptMsg::HideIME => {
debug!("constellation got HideIME message");
self.embedder_proxy.send(EmbedderMsg::HideIME(source_top_ctx_id));
}
}
}

fn handle_request_from_layout(&mut self, message: FromLayoutMsg) {
debug!("Constellation got {:?} message", message);
match message {
FromLayoutMsg::ChangeRunningAnimationsState(pipeline_id, animation_state) => {
self.handle_change_running_animations_state(pipeline_id, animation_state)
}
// Layout sends new sizes for all subframes. This needs to be reflected by all
// frame trees in the navigation context containing the subframe.
FromLayoutMsg::IFrameSizes(iframe_sizes) => {
debug!("constellation got iframe size message");
self.handle_iframe_size_msg(iframe_sizes);
}
FromLayoutMsg::PendingPaintMetric(pipeline_id, epoch) => {
debug!("constellation got a pending paint metric message");
self.handle_pending_paint_metric(pipeline_id, epoch);
}
FromLayoutMsg::SetCursor(cursor) => {
self.handle_set_cursor_msg(cursor)
}
FromLayoutMsg::ViewportConstrained(pipeline_id, constraints) => {
debug!("constellation got viewport-constrained event message");
self.handle_viewport_constrained_msg(pipeline_id, constraints);
}
}
@@ -364,7 +364,7 @@ impl fmt::Debug for ConstellationControlMsg {
WebVREvents(..) => "WebVREvents",
PaintMetric(..) => "PaintMetric",
};
write!(formatter, "ConstellationMsg::{}", variant)
write!(formatter, "ConstellationControlMsg::{}", variant)
}
}

@@ -710,6 +710,34 @@ pub enum ConstellationMsg {
SetCursor(CursorKind),
}

impl fmt::Debug for ConstellationMsg {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
use self::ConstellationMsg::*;
let variant = match *self {
Exit => "Exit",
GetBrowsingContext(..) => "GetBrowsingContext",
GetPipeline(..) => "GetPipeline",
GetFocusTopLevelBrowsingContext(..) => "GetFocusTopLevelBrowsingContext",
IsReadyToSaveImage(..) => "IsReadyToSaveImage",
KeyEvent(..) => "KeyEvent",
LoadUrl(..) => "LoadUrl",
TraverseHistory(..) => "TraverseHistory",
WindowSize(..) => "WindowSize",
TickAnimation(..) => "TickAnimation",
WebDriverCommand(..) => "WebDriverCommand",
Reload(..) => "Reload",
LogEntry(..) => "LogEntry",
WebVREvents(..) => "WebVREvents",
NewBrowser(..) => "NewBrowser",
CloseBrowser(..) => "CloseBrowser",
SelectBrowser(..) => "SelectBrowser",
ForwardEvent(..) => "ForwardEvent",
SetCursor(..) => "SetCursor",
};
write!(formatter, "ConstellationMsg::{}", variant)
}
}

/// Resources required by workerglobalscopes
#[derive(Clone, Deserialize, Serialize)]
pub struct WorkerGlobalScopeInit {

0 comments on commit ee3c26c

Please sign in to comment.
You can’t perform that action at this time.