diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index 0d2b7f08b38..18f6618a58c 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -388,7 +388,7 @@ impl IOCompositor { self.window.load_start(back, forward); } - (Msg::LoadComplete, ShutdownState::NotShuttingDown) => { + (Msg::LoadComplete(back, forward), ShutdownState::NotShuttingDown) => { self.got_load_complete_message = true; // If we're painting in headless mode, schedule a recomposite. @@ -399,7 +399,7 @@ impl IOCompositor { // Inform the embedder that the load has finished. // // TODO(pcwalton): Specify which frame's load completed. - self.window.load_end(); + self.window.load_end(back, forward); } (Msg::ScrollTimeout(timestamp), ShutdownState::NotShuttingDown) => { diff --git a/components/compositing/compositor_task.rs b/components/compositing/compositor_task.rs index 1eb4ac215e0..9a47fce1600 100644 --- a/components/compositing/compositor_task.rs +++ b/components/compositing/compositor_task.rs @@ -162,8 +162,8 @@ pub enum Msg { SetFrameTree(SendableFrameTree, Sender<()>, ConstellationChan), /// The load of a page has begun: (can go back, can go forward). LoadStart(bool, bool), - /// The load of a page has completed. - LoadComplete, + /// The load of a page has completed: (can go back, can go forward). + LoadComplete(bool, bool), /// Indicates that the scrolling timeout with the given starting timestamp has happened and a /// composite should happen. (See the `scrolling` module.) ScrollTimeout(u64), @@ -196,7 +196,7 @@ impl Debug for Msg { Msg::ChangePageTitle(..) => write!(f, "ChangePageTitle"), Msg::ChangePageUrl(..) => write!(f, "ChangePageUrl"), Msg::SetFrameTree(..) => write!(f, "SetFrameTree"), - Msg::LoadComplete => write!(f, "LoadComplete"), + Msg::LoadComplete(..) => write!(f, "LoadComplete"), Msg::LoadStart(..) => write!(f, "LoadStart"), Msg::ScrollTimeout(..) => write!(f, "ScrollTimeout"), Msg::RecompositeAfterScroll => write!(f, "RecompositeAfterScroll"), diff --git a/components/compositing/constellation.rs b/components/compositing/constellation.rs index 59d5c5444fa..bfcb0693c1e 100644 --- a/components/compositing/constellation.rs +++ b/components/compositing/constellation.rs @@ -391,9 +391,9 @@ impl Constellation { } // A page loaded through one of several methods above has completed all parsing, // script, and reflow messages have been sent. - ConstellationMsg::LoadComplete => { + ConstellationMsg::LoadComplete(pipeline_id) => { debug!("constellation got load complete message"); - self.handle_load_complete_msg() + self.handle_load_complete_msg(&pipeline_id) } // Handle a forward or back request ConstellationMsg::Navigate(pipeline_info, direction) => { @@ -681,8 +681,12 @@ impl Constellation { self.compositor_proxy.send(CompositorMsg::LoadStart(back, forward)); } - fn handle_load_complete_msg(&mut self) { - self.compositor_proxy.send(CompositorMsg::LoadComplete); + fn handle_load_complete_msg(&mut self, pipeline_id: &PipelineId) { + let frame_id = *self.pipeline_to_frame_map.get(pipeline_id).unwrap(); + + let forward = !self.mut_frame(frame_id).next.is_empty(); + let back = !self.mut_frame(frame_id).prev.is_empty(); + self.compositor_proxy.send(CompositorMsg::LoadComplete(back, forward)); if let Some(ref reply_chan) = self.webdriver.load_channel { reply_chan.send(webdriver_traits::LoadComplete).unwrap(); } diff --git a/components/compositing/headless.rs b/components/compositing/headless.rs index e289cc12dd9..c58532e81ed 100644 --- a/components/compositing/headless.rs +++ b/components/compositing/headless.rs @@ -98,7 +98,7 @@ impl CompositorEventListener for NullCompositor { Msg::ChangeRunningAnimationsState(..) | Msg::ScrollFragmentPoint(..) | Msg::LoadStart(..) | - Msg::LoadComplete | + Msg::LoadComplete(..) | Msg::ScrollTimeout(..) | Msg::RecompositeAfterScroll | Msg::ChangePageTitle(..) | diff --git a/components/compositing/windowing.rs b/components/compositing/windowing.rs index ec215a93edd..51a97ec86f4 100644 --- a/components/compositing/windowing.rs +++ b/components/compositing/windowing.rs @@ -106,7 +106,7 @@ pub trait WindowMethods { /// Called when the browser has started loading a frame. fn load_start(&self, back: bool, forward: bool); /// Called when the browser is done loading a frame. - fn load_end(&self); + fn load_end(&self, back: bool, forward: bool); /// Returns the hidpi factor of the monitor. fn hidpi_factor(&self) -> ScaleFactor; diff --git a/components/msg/constellation_msg.rs b/components/msg/constellation_msg.rs index 623f801ddb4..8706a807cab 100644 --- a/components/msg/constellation_msg.rs +++ b/components/msg/constellation_msg.rs @@ -211,7 +211,7 @@ pub enum Msg { Exit, Failure(Failure), InitLoadUrl(Url), - LoadComplete, + LoadComplete(PipelineId), FrameRect(PipelineId, SubpageId, Rect), LoadUrl(PipelineId, LoadData), ScriptLoadedURLInIFrame(Url, PipelineId, SubpageId, Option, IFrameSandboxState), diff --git a/components/script/script_task.rs b/components/script/script_task.rs index 573827cc267..cad737b4af4 100644 --- a/components/script/script_task.rs +++ b/components/script/script_task.rs @@ -960,7 +960,7 @@ impl ScriptTask { self.chan.send(ScriptMsg::RunnableMsg(handler)).unwrap(); let ConstellationChan(ref chan) = self.constellation_chan; - chan.send(ConstellationMsg::LoadComplete).unwrap(); + chan.send(ConstellationMsg::LoadComplete(pipeline)).unwrap(); } /// Handles a timer that fired. diff --git a/ports/cef/window.rs b/ports/cef/window.rs index f0dac467033..7fc1222efa2 100644 --- a/ports/cef/window.rs +++ b/ports/cef/window.rs @@ -331,13 +331,20 @@ impl WindowMethods for Window { } } - fn load_end(&self) { + fn load_end(&self, back: bool, forward: bool) { // FIXME(pcwalton): The status code 200 is a lie. let browser = self.cef_browser.borrow(); let browser = match *browser { None => return, Some(ref browser) => browser, }; + if check_ptr_exist!(browser.get_host().get_client(), get_load_handler) && + check_ptr_exist!(browser.get_host().get_client().get_load_handler(), on_loading_state_change) { + browser.get_host() + .get_client() + .get_load_handler() + .on_loading_state_change((*browser).clone(), 0i32, back as i32, forward as i32); + } if check_ptr_exist!(browser.get_host().get_client(), get_load_handler) && check_ptr_exist!(browser.get_host().get_client().get_load_handler(), on_load_end) { browser.get_host() diff --git a/ports/glutin/window.rs b/ports/glutin/window.rs index df7bc24eea0..16d8c509317 100644 --- a/ports/glutin/window.rs +++ b/ports/glutin/window.rs @@ -508,7 +508,7 @@ impl WindowMethods for Window { fn load_start(&self, _: bool, _: bool) { } - fn load_end(&self) { + fn load_end(&self, _: bool, _: bool) { } /// Has no effect on Android. diff --git a/ports/gonk/src/window.rs b/ports/gonk/src/window.rs index 8d480dde8e4..f751d239e42 100644 --- a/ports/gonk/src/window.rs +++ b/ports/gonk/src/window.rs @@ -805,7 +805,7 @@ impl WindowMethods for Window { fn load_start(&self, _: bool, _: bool) { } - fn load_end(&self) { + fn load_end(&self, _: bool, _: bool) { } fn hidpi_factor(&self) -> ScaleFactor {