mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
add CompositorMsg::LoadStart, implement cef_load_handler::on_loading_state_change()
only adds the loading:true callback this time...
This commit is contained in:
parent
cd9dab7b5b
commit
3481c752cd
8 changed files with 51 additions and 0 deletions
|
@ -384,6 +384,10 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
self.scroll_fragment_to_point(pipeline_id, layer_id, point);
|
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) => {
|
(Msg::LoadComplete, ShutdownState::NotShuttingDown) => {
|
||||||
self.got_load_complete_message = true;
|
self.got_load_complete_message = true;
|
||||||
|
|
||||||
|
|
|
@ -160,6 +160,8 @@ pub enum Msg {
|
||||||
ChangeRunningAnimationsState(PipelineId, AnimationState),
|
ChangeRunningAnimationsState(PipelineId, AnimationState),
|
||||||
/// Replaces the current frame tree, typically called during main frame navigation.
|
/// Replaces the current frame tree, typically called during main frame navigation.
|
||||||
SetFrameTree(SendableFrameTree, Sender<()>, ConstellationChan),
|
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.
|
/// The load of a page has completed.
|
||||||
LoadComplete,
|
LoadComplete,
|
||||||
/// Indicates that the scrolling timeout with the given starting timestamp has happened and a
|
/// 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::ChangePageUrl(..) => write!(f, "ChangePageUrl"),
|
||||||
Msg::SetFrameTree(..) => write!(f, "SetFrameTree"),
|
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::ScrollTimeout(..) => write!(f, "ScrollTimeout"),
|
||||||
Msg::RecompositeAfterScroll => write!(f, "RecompositeAfterScroll"),
|
Msg::RecompositeAfterScroll => write!(f, "RecompositeAfterScroll"),
|
||||||
Msg::KeyEvent(..) => write!(f, "KeyEvent"),
|
Msg::KeyEvent(..) => write!(f, "KeyEvent"),
|
||||||
|
|
|
@ -520,6 +520,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
let window_rect = Rect(Point2D::zero(), self.window_size.visible_viewport);
|
let window_rect = Rect(Point2D::zero(), self.window_size.visible_viewport);
|
||||||
let root_pipeline_id =
|
let root_pipeline_id =
|
||||||
self.new_pipeline(None, Some(window_rect), None, LoadData::new(url.clone()));
|
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.push_pending_frame(root_pipeline_id, None);
|
||||||
self.compositor_proxy.send(CompositorMsg::ChangePageUrl(root_pipeline_id, url));
|
self.compositor_proxy.send(CompositorMsg::ChangePageUrl(root_pipeline_id, url));
|
||||||
}
|
}
|
||||||
|
@ -630,6 +631,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
// requested change so it can update its internal state.
|
// requested change so it can update its internal state.
|
||||||
match self.pipeline(source_id).parent_info {
|
match self.pipeline(source_id).parent_info {
|
||||||
Some((parent_pipeline_id, subpage_id)) => {
|
Some((parent_pipeline_id, subpage_id)) => {
|
||||||
|
self.handle_load_start_msg(&source_id);
|
||||||
// Message the constellation to find the script task for this iframe
|
// Message the constellation to find the script task for this iframe
|
||||||
// and issue an iframe load through there.
|
// and issue an iframe load through there.
|
||||||
let parent_pipeline = self.pipeline(parent_pipeline_id);
|
let parent_pipeline = self.pipeline(parent_pipeline_id);
|
||||||
|
@ -647,6 +649,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.handle_load_start_msg(&source_id);
|
||||||
// Being here means either there are no pending frames, or none of the pending
|
// 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.
|
// changes would be overridden by changing the subframe associated with source_id.
|
||||||
|
|
||||||
|
@ -662,6 +665,22 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
fn handle_load_complete_msg(&mut self) {
|
||||||
self.compositor_proxy.send(CompositorMsg::LoadComplete);
|
self.compositor_proxy.send(CompositorMsg::LoadComplete);
|
||||||
if let Some(ref reply_chan) = self.webdriver.load_channel {
|
if let Some(ref reply_chan) = self.webdriver.load_channel {
|
||||||
|
|
|
@ -97,6 +97,7 @@ impl CompositorEventListener for NullCompositor {
|
||||||
Msg::AssignPaintedBuffers(..) |
|
Msg::AssignPaintedBuffers(..) |
|
||||||
Msg::ChangeRunningAnimationsState(..) |
|
Msg::ChangeRunningAnimationsState(..) |
|
||||||
Msg::ScrollFragmentPoint(..) |
|
Msg::ScrollFragmentPoint(..) |
|
||||||
|
Msg::LoadStart(..) |
|
||||||
Msg::LoadComplete |
|
Msg::LoadComplete |
|
||||||
Msg::ScrollTimeout(..) |
|
Msg::ScrollTimeout(..) |
|
||||||
Msg::RecompositeAfterScroll |
|
Msg::RecompositeAfterScroll |
|
||||||
|
|
|
@ -103,6 +103,8 @@ pub trait WindowMethods {
|
||||||
fn set_page_title(&self, title: Option<String>);
|
fn set_page_title(&self, title: Option<String>);
|
||||||
/// Sets the load data for the current page.
|
/// Sets the load data for the current page.
|
||||||
fn set_page_url(&self, url: Url);
|
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.
|
/// Called when the browser is done loading a frame.
|
||||||
fn load_end(&self);
|
fn load_end(&self);
|
||||||
|
|
||||||
|
|
|
@ -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) {
|
fn load_end(&self) {
|
||||||
// FIXME(pcwalton): The status code 200 is a lie.
|
// FIXME(pcwalton): The status code 200 is a lie.
|
||||||
let browser = self.cef_browser.borrow();
|
let browser = self.cef_browser.borrow();
|
||||||
|
|
|
@ -505,6 +505,9 @@ impl WindowMethods for Window {
|
||||||
fn set_page_url(&self, _: Url) {
|
fn set_page_url(&self, _: Url) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn load_start(&self, _: bool, _: bool) {
|
||||||
|
}
|
||||||
|
|
||||||
fn load_end(&self) {
|
fn load_end(&self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -802,6 +802,9 @@ impl WindowMethods for Window {
|
||||||
fn set_page_url(&self, _: Url) {
|
fn set_page_url(&self, _: Url) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn load_start(&self, _: bool, _: bool) {
|
||||||
|
}
|
||||||
|
|
||||||
fn load_end(&self) {
|
fn load_end(&self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue