diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index a50b51ebc0e..0d2b7f08b38 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -384,6 +384,10 @@ impl IOCompositor { self.scroll_fragment_to_point(pipeline_id, layer_id, point); } + (Msg::LoadStart(back, forward), ShutdownState::NotShuttingDown) => { + self.window.load_start(back, forward); + } + (Msg::LoadComplete, ShutdownState::NotShuttingDown) => { self.got_load_complete_message = true; diff --git a/components/compositing/compositor_task.rs b/components/compositing/compositor_task.rs index 904e69da83b..1eb4ac215e0 100644 --- a/components/compositing/compositor_task.rs +++ b/components/compositing/compositor_task.rs @@ -160,6 +160,8 @@ pub enum Msg { ChangeRunningAnimationsState(PipelineId, AnimationState), /// Replaces the current frame tree, typically called during main frame navigation. 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, /// Indicates that the scrolling timeout with the given starting timestamp has happened and a @@ -195,6 +197,7 @@ impl Debug for Msg { Msg::ChangePageUrl(..) => write!(f, "ChangePageUrl"), Msg::SetFrameTree(..) => write!(f, "SetFrameTree"), Msg::LoadComplete => write!(f, "LoadComplete"), + Msg::LoadStart(..) => write!(f, "LoadStart"), Msg::ScrollTimeout(..) => write!(f, "ScrollTimeout"), Msg::RecompositeAfterScroll => write!(f, "RecompositeAfterScroll"), Msg::KeyEvent(..) => write!(f, "KeyEvent"), diff --git a/components/compositing/constellation.rs b/components/compositing/constellation.rs index 750c124a13a..59d5c5444fa 100644 --- a/components/compositing/constellation.rs +++ b/components/compositing/constellation.rs @@ -520,6 +520,7 @@ impl Constellation { let window_rect = Rect(Point2D::zero(), self.window_size.visible_viewport); let root_pipeline_id = self.new_pipeline(None, Some(window_rect), None, LoadData::new(url.clone())); + self.handle_load_start_msg(&root_pipeline_id); self.push_pending_frame(root_pipeline_id, None); self.compositor_proxy.send(CompositorMsg::ChangePageUrl(root_pipeline_id, url)); } @@ -630,6 +631,7 @@ impl Constellation { // requested change so it can update its internal state. match self.pipeline(source_id).parent_info { Some((parent_pipeline_id, subpage_id)) => { + self.handle_load_start_msg(&source_id); // Message the constellation to find the script task for this iframe // and issue an iframe load through there. let parent_pipeline = self.pipeline(parent_pipeline_id); @@ -647,6 +649,7 @@ impl Constellation { } } + self.handle_load_start_msg(&source_id); // Being here means either there are no pending frames, or none of the pending // changes would be overridden by changing the subframe associated with source_id. @@ -662,6 +665,22 @@ impl Constellation { } } + fn handle_load_start_msg(&mut self, pipeline_id: &PipelineId) { + let mut back = false; + let mut forward = false; + let frameid = self.pipeline_to_frame_map.get(pipeline_id); + match frameid { + Some(frame_id) => { + forward = if !self.frame(*frame_id).next.is_empty() { true } + else { false }; + back = if !self.frame(*frame_id).prev.is_empty() { true } + else { false }; + }, + None => {} + }; + self.compositor_proxy.send(CompositorMsg::LoadStart(back, forward)); + } + fn handle_load_complete_msg(&mut self) { self.compositor_proxy.send(CompositorMsg::LoadComplete); if let Some(ref reply_chan) = self.webdriver.load_channel { diff --git a/components/compositing/headless.rs b/components/compositing/headless.rs index 2f9aa30e744..e289cc12dd9 100644 --- a/components/compositing/headless.rs +++ b/components/compositing/headless.rs @@ -97,6 +97,7 @@ impl CompositorEventListener for NullCompositor { Msg::AssignPaintedBuffers(..) | Msg::ChangeRunningAnimationsState(..) | Msg::ScrollFragmentPoint(..) | + Msg::LoadStart(..) | Msg::LoadComplete | Msg::ScrollTimeout(..) | Msg::RecompositeAfterScroll | diff --git a/components/compositing/windowing.rs b/components/compositing/windowing.rs index 196e1e2653f..ec215a93edd 100644 --- a/components/compositing/windowing.rs +++ b/components/compositing/windowing.rs @@ -103,6 +103,8 @@ pub trait WindowMethods { fn set_page_title(&self, title: Option); /// Sets the load data for the current page. fn set_page_url(&self, url: Url); + /// 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); diff --git a/ports/cef/window.rs b/ports/cef/window.rs index a5a70cb19d2..f0dac467033 100644 --- a/ports/cef/window.rs +++ b/ports/cef/window.rs @@ -315,6 +315,22 @@ impl WindowMethods for Window { } } + fn load_start(&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(), 1i32, back as i32, forward as i32); + } + } + fn load_end(&self) { // FIXME(pcwalton): The status code 200 is a lie. let browser = self.cef_browser.borrow(); diff --git a/ports/glutin/window.rs b/ports/glutin/window.rs index 8caa33d286e..df7bc24eea0 100644 --- a/ports/glutin/window.rs +++ b/ports/glutin/window.rs @@ -505,6 +505,9 @@ impl WindowMethods for Window { fn set_page_url(&self, _: Url) { } + fn load_start(&self, _: bool, _: bool) { + } + fn load_end(&self) { } diff --git a/ports/gonk/src/window.rs b/ports/gonk/src/window.rs index 632f0257855..8d480dde8e4 100644 --- a/ports/gonk/src/window.rs +++ b/ports/gonk/src/window.rs @@ -802,6 +802,9 @@ impl WindowMethods for Window { fn set_page_url(&self, _: Url) { } + fn load_start(&self, _: bool, _: bool) { + } + fn load_end(&self) { }