script: Unify LoadComplete and DOMLoad messages.

See the PR in which this commit landed and also
https://github.com/servo/servo/pull/6415#issuecomment-122294169
This commit is contained in:
Emilio Cobos Álvarez 2016-07-27 10:34:36 -07:00
parent 572b3c31bd
commit 36376461f4
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
3 changed files with 10 additions and 25 deletions

View file

@ -828,11 +828,6 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
debug!("constellation got load complete message"); debug!("constellation got load complete message");
self.handle_load_complete_msg(pipeline_id) self.handle_load_complete_msg(pipeline_id)
} }
// The DOM load event fired on a document
FromScriptMsg::DOMLoad(pipeline_id) => {
debug!("constellation got dom load message");
self.handle_dom_load(pipeline_id)
}
// Handle a forward or back request // Handle a forward or back request
FromScriptMsg::TraverseHistory(pipeline_id, direction) => { FromScriptMsg::TraverseHistory(pipeline_id, direction) => {
debug!("constellation got traverse history message from script"); debug!("constellation got traverse history message from script");
@ -1438,16 +1433,6 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
} }
fn handle_load_complete_msg(&mut self, pipeline_id: PipelineId) { fn handle_load_complete_msg(&mut self, pipeline_id: PipelineId) {
if let Some(frame_id) = self.get_top_level_frame_for_pipeline(Some(pipeline_id)) {
let forward = !self.joint_session_future(frame_id).is_empty();
let back = !self.joint_session_past(frame_id).is_empty();
let root = self.root_frame_id.is_none() || self.root_frame_id == Some(frame_id);
self.compositor_proxy.send(ToCompositorMsg::LoadComplete(back, forward, root));
}
self.handle_subframe_loaded(pipeline_id);
}
fn handle_dom_load(&mut self, pipeline_id: PipelineId) {
let mut webdriver_reset = false; let mut webdriver_reset = false;
if let Some((expected_pipeline_id, ref reply_chan)) = self.webdriver.load_channel { if let Some((expected_pipeline_id, ref reply_chan)) = self.webdriver.load_channel {
debug!("Sending load to WebDriver"); debug!("Sending load to WebDriver");
@ -1459,6 +1444,13 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
if webdriver_reset { if webdriver_reset {
self.webdriver.load_channel = None; self.webdriver.load_channel = None;
} }
if let Some(frame_id) = self.get_top_level_frame_for_pipeline(Some(pipeline_id)) {
let forward = !self.joint_session_future(frame_id).is_empty();
let back = !self.joint_session_past(frame_id).is_empty();
let root = self.root_frame_id.is_none() || self.root_frame_id == Some(frame_id);
self.compositor_proxy.send(ToCompositorMsg::LoadComplete(back, forward, root));
}
self.handle_subframe_loaded(pipeline_id);
} }
fn handle_traverse_history_msg(&mut self, fn handle_traverse_history_msg(&mut self,

View file

@ -1497,14 +1497,10 @@ impl Document {
let window = self.window(); let window = self.window();
window.dom_manipulation_task_source().queue_event(self.upcast(), atom!("DOMContentLoaded"), window.dom_manipulation_task_source().queue_event(self.upcast(), atom!("DOMContentLoaded"),
EventBubbles::Bubbles, EventCancelable::NotCancelable, window); EventBubbles::Bubbles, EventCancelable::NotCancelable, window);
window.reflow(ReflowGoal::ForDisplay, window.reflow(ReflowGoal::ForDisplay,
ReflowQueryType::NoQuery, ReflowQueryType::NoQuery,
ReflowReason::DOMContentLoaded); ReflowReason::DOMContentLoaded);
let pipeline_id = self.window.pipeline();
let event = ConstellationMsg::DOMLoad(pipeline_id);
self.window.constellation_chan().send(event).unwrap();
update_with_current_time_ms(&self.dom_content_loaded_event_end); update_with_current_time_ms(&self.dom_content_loaded_event_end);
} }

View file

@ -70,10 +70,6 @@ pub enum ScriptMsg {
CreateWebGLPaintThread(Size2D<i32>, CreateWebGLPaintThread(Size2D<i32>,
GLContextAttributes, GLContextAttributes,
IpcSender<Result<(IpcSender<CanvasMsg>, GLLimits), String>>), IpcSender<Result<(IpcSender<CanvasMsg>, GLLimits), String>>),
/// Dispatched after the DOM load event has fired on a document
/// Causes a `load` event to be dispatched to any enclosing frame context element
/// for the given pipeline.
DOMLoad(PipelineId),
/// Notifies the constellation that this frame has received focus. /// Notifies the constellation that this frame has received focus.
Focus(PipelineId), Focus(PipelineId),
/// Re-send a mouse button event that was sent to the parent window. /// Re-send a mouse button event that was sent to the parent window.
@ -84,7 +80,8 @@ pub enum ScriptMsg {
GetClipboardContents(IpcSender<String>), GetClipboardContents(IpcSender<String>),
/// <head> tag finished parsing /// <head> tag finished parsing
HeadParsed, HeadParsed,
/// All pending loads are complete. /// All pending loads are complete, and the `load` event for this pipeline
/// has been dispatched.
LoadComplete(PipelineId), LoadComplete(PipelineId),
/// A new load has been requested. /// A new load has been requested.
LoadUrl(PipelineId, LoadData), LoadUrl(PipelineId, LoadData),