diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs index 2d9fbac74d9..d2f045de0d1 100644 --- a/components/constellation/constellation.rs +++ b/components/constellation/constellation.rs @@ -828,11 +828,6 @@ impl Constellation debug!("constellation got load complete message"); 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 FromScriptMsg::TraverseHistory(pipeline_id, direction) => { debug!("constellation got traverse history message from script"); @@ -1438,16 +1433,6 @@ impl Constellation } 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; if let Some((expected_pipeline_id, ref reply_chan)) = self.webdriver.load_channel { debug!("Sending load to WebDriver"); @@ -1459,6 +1444,13 @@ impl Constellation if webdriver_reset { 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, diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 73ca4f16f3c..78ccbbdf1f5 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -1497,14 +1497,10 @@ impl Document { let window = self.window(); window.dom_manipulation_task_source().queue_event(self.upcast(), atom!("DOMContentLoaded"), EventBubbles::Bubbles, EventCancelable::NotCancelable, window); + window.reflow(ReflowGoal::ForDisplay, ReflowQueryType::NoQuery, 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); } diff --git a/components/script_traits/script_msg.rs b/components/script_traits/script_msg.rs index 3ba4494432b..cc8df29d3d5 100644 --- a/components/script_traits/script_msg.rs +++ b/components/script_traits/script_msg.rs @@ -70,10 +70,6 @@ pub enum ScriptMsg { CreateWebGLPaintThread(Size2D, GLContextAttributes, IpcSender, 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. Focus(PipelineId), /// Re-send a mouse button event that was sent to the parent window. @@ -84,7 +80,8 @@ pub enum ScriptMsg { GetClipboardContents(IpcSender), /// tag finished parsing HeadParsed, - /// All pending loads are complete. + /// All pending loads are complete, and the `load` event for this pipeline + /// has been dispatched. LoadComplete(PipelineId), /// A new load has been requested. LoadUrl(PipelineId, LoadData),