Skip to content

Commit

Permalink
add window method for notifying when the <head> tag has been parsed
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Blumenkrantz committed Jun 3, 2015
1 parent 612cefa commit ffa2093
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 0 deletions.
4 changes: 4 additions & 0 deletions components/compositing/compositor.rs
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions components/compositing/compositor_task.rs
Expand Up @@ -182,6 +182,8 @@ pub enum Msg {
IsReadyToSaveImageReply(bool),
/// A favicon was detected
NewFavicon(Url),
/// <head> tag finished parsing
HeadParsed,
}

impl Debug for Msg {
Expand Down Expand Up @@ -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"),
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions components/compositing/constellation.rs
Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions components/compositing/headless.rs
Expand Up @@ -110,6 +110,7 @@ impl CompositorEventListener for NullCompositor {
Msg::PaintTaskExited(..) |
Msg::IsReadyToSaveImageReply(..) => {}
Msg::NewFavicon(..) => {}
Msg::HeadParsed => {}
}
true
}
Expand Down
2 changes: 2 additions & 0 deletions components/compositing/windowing.rs
Expand Up @@ -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>;
Expand Down
2 changes: 2 additions & 0 deletions components/msg/constellation_msg.rs
Expand Up @@ -250,6 +250,8 @@ pub enum Msg {
RemoveIFrame(PipelineId, SubpageId),
/// Favicon detected
NewFavicon(Url),
/// <head> tag finished parsing
HeadParsed,
}

#[derive(Clone, Eq, PartialEq)]
Expand Down
5 changes: 5 additions & 0 deletions components/script/dom/htmlbodyelement.rs
Expand Up @@ -17,6 +17,8 @@ use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
use dom::node::{Node, NodeTypeId, window_from_node};
use dom::virtualmethods::VirtualMethods;
use dom::window::WindowHelpers;
use msg::constellation_msg::ConstellationChan;
use msg::constellation_msg::Msg as ConstellationMsg;

use cssparser::RGBA;
use util::str::{self, DOMString};
Expand Down Expand Up @@ -107,6 +109,9 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLBodyElement> {
let window = window_from_node(*self).root();
let document = window.r().Document().root();
document.r().set_reflow_timeout(time::precise_time_ns() + INITIAL_REFLOW_DELAY);
let ConstellationChan(ref chan) = window.r().constellation_chan();
let event = ConstellationMsg::HeadParsed;
chan.send(event).unwrap();
}

fn after_set_attr(&self, attr: JSRef<Attr>) {
Expand Down
3 changes: 3 additions & 0 deletions ports/cef/window.rs
Expand Up @@ -391,6 +391,9 @@ impl WindowMethods for Window {
}
}

fn head_parsed(&self) {
}

fn set_page_title(&self, string: Option<String>) {
let browser = self.cef_browser.borrow();
let browser = match *browser {
Expand Down
5 changes: 5 additions & 0 deletions ports/glutin/window.rs
Expand Up @@ -515,6 +515,9 @@ impl WindowMethods for Window {
fn load_error(&self, _: NetError, _: String) {
}

fn head_parsed(&self) {
}

/// Has no effect on Android.
fn set_cursor(&self, c: Cursor) {
use glutin::MouseCursor;
Expand Down Expand Up @@ -706,6 +709,8 @@ impl WindowMethods for Window {
}
fn load_error(&self, _: NetError, _: String) {
}
fn head_parsed(&self) {
}

fn set_cursor(&self, _: Cursor) {
}
Expand Down
3 changes: 3 additions & 0 deletions ports/gonk/src/window.rs
Expand Up @@ -812,6 +812,9 @@ impl WindowMethods for Window {
fn load_error(&self, _: NetError, _: String) {
}

fn head_parsed(&self) {
}

fn hidpi_factor(&self) -> ScaleFactor<ScreenPx, DevicePixel, f32> {
ScaleFactor::new(1.0)
}
Expand Down

0 comments on commit ffa2093

Please sign in to comment.