add window method for notifying when the <head> tag has been parsed

This commit is contained in:
Mike Blumenkrantz 2015-05-29 18:27:00 -04:00
parent 612cefa02d
commit ffa2093012
10 changed files with 32 additions and 0 deletions

View file

@ -458,6 +458,10 @@ impl<Window: WindowMethods> IOCompositor<Window> {
self.window.set_favicon(url);
}
(Msg::HeadParsed, ShutdownState::NotShuttingDown) => {
self.window.head_parsed();
}
// When we are shutting_down, we need to avoid performing operations
// such as Paint that may crash because we have begun tearing down
// the rest of our resources.

View file

@ -182,6 +182,8 @@ pub enum Msg {
IsReadyToSaveImageReply(bool),
/// A favicon was detected
NewFavicon(Url),
/// <head> tag finished parsing
HeadParsed,
}
impl Debug for Msg {
@ -209,6 +211,7 @@ impl Debug for Msg {
Msg::ViewportConstrained(..) => write!(f, "ViewportConstrained"),
Msg::IsReadyToSaveImageReply(..) => write!(f, "IsReadyToSaveImageReply"),
Msg::NewFavicon(..) => write!(f, "NewFavicon"),
Msg::HeadParsed => write!(f, "HeadParsed"),
}
}
}

View file

@ -472,6 +472,10 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
debug!("constellation got new favicon message");
self.compositor_proxy.send(CompositorMsg::NewFavicon(url));
}
ConstellationMsg::HeadParsed => {
debug!("constellation got head parsed message");
self.compositor_proxy.send(CompositorMsg::HeadParsed);
}
}
true
}

View file

@ -110,6 +110,7 @@ impl CompositorEventListener for NullCompositor {
Msg::PaintTaskExited(..) |
Msg::IsReadyToSaveImageReply(..) => {}
Msg::NewFavicon(..) => {}
Msg::HeadParsed => {}
}
true
}

View file

@ -110,6 +110,8 @@ pub trait WindowMethods {
fn load_end(&self, back: bool, forward: bool);
/// Called when the browser encounters an error while loading a URL
fn load_error(&self, code: NetError, url: String);
/// Called when the <head> tag has finished parsing
fn head_parsed(&self);
/// Returns the hidpi factor of the monitor.
fn hidpi_factor(&self) -> ScaleFactor<ScreenPx, DevicePixel, f32>;