From ffa20930120f60fdf76fdca5e0c286c4bdcaa298 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Fri, 29 May 2015 18:27:00 -0400 Subject: [PATCH] add window method for notifying when the tag has been parsed --- components/compositing/compositor.rs | 4 ++++ components/compositing/compositor_task.rs | 3 +++ components/compositing/constellation.rs | 4 ++++ components/compositing/headless.rs | 1 + components/compositing/windowing.rs | 2 ++ components/msg/constellation_msg.rs | 2 ++ components/script/dom/htmlbodyelement.rs | 5 +++++ ports/cef/window.rs | 3 +++ ports/glutin/window.rs | 5 +++++ ports/gonk/src/window.rs | 3 +++ 10 files changed, 32 insertions(+) diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index d481f9f63b2..e76fe4f4aa5 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -458,6 +458,10 @@ impl IOCompositor { 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. diff --git a/components/compositing/compositor_task.rs b/components/compositing/compositor_task.rs index a58f838ec8c..9e7b172cc80 100644 --- a/components/compositing/compositor_task.rs +++ b/components/compositing/compositor_task.rs @@ -182,6 +182,8 @@ pub enum Msg { IsReadyToSaveImageReply(bool), /// A favicon was detected NewFavicon(Url), + /// 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"), } } } diff --git a/components/compositing/constellation.rs b/components/compositing/constellation.rs index 9c1d07510c7..6ab1e3d749e 100644 --- a/components/compositing/constellation.rs +++ b/components/compositing/constellation.rs @@ -472,6 +472,10 @@ impl Constellation { 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 } diff --git a/components/compositing/headless.rs b/components/compositing/headless.rs index 075dcf7ba32..ed3afa6a4b0 100644 --- a/components/compositing/headless.rs +++ b/components/compositing/headless.rs @@ -110,6 +110,7 @@ impl CompositorEventListener for NullCompositor { Msg::PaintTaskExited(..) | Msg::IsReadyToSaveImageReply(..) => {} Msg::NewFavicon(..) => {} + Msg::HeadParsed => {} } true } diff --git a/components/compositing/windowing.rs b/components/compositing/windowing.rs index 9c85611fa34..17ce9f43434 100644 --- a/components/compositing/windowing.rs +++ b/components/compositing/windowing.rs @@ -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 tag has finished parsing + fn head_parsed(&self); /// 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 001d020ef42..b0f7ddeb344 100644 --- a/components/msg/constellation_msg.rs +++ b/components/msg/constellation_msg.rs @@ -250,6 +250,8 @@ pub enum Msg { RemoveIFrame(PipelineId, SubpageId), /// Favicon detected NewFavicon(Url), + /// tag finished parsing + HeadParsed, } #[derive(Clone, Eq, PartialEq)] diff --git a/components/script/dom/htmlbodyelement.rs b/components/script/dom/htmlbodyelement.rs index 97cd615f910..fc2b0cf1d57 100644 --- a/components/script/dom/htmlbodyelement.rs +++ b/components/script/dom/htmlbodyelement.rs @@ -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}; @@ -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) { diff --git a/ports/cef/window.rs b/ports/cef/window.rs index 95987fa7fcc..c21f61fb9d6 100644 --- a/ports/cef/window.rs +++ b/ports/cef/window.rs @@ -391,6 +391,9 @@ impl WindowMethods for Window { } } + fn head_parsed(&self) { + } + fn set_page_title(&self, string: Option) { let browser = self.cef_browser.borrow(); let browser = match *browser { diff --git a/ports/glutin/window.rs b/ports/glutin/window.rs index 635aed4c46e..04a4276f856 100644 --- a/ports/glutin/window.rs +++ b/ports/glutin/window.rs @@ -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; @@ -706,6 +709,8 @@ impl WindowMethods for Window { } fn load_error(&self, _: NetError, _: String) { } + fn head_parsed(&self) { + } fn set_cursor(&self, _: Cursor) { } diff --git a/ports/gonk/src/window.rs b/ports/gonk/src/window.rs index 10734fa6cbb..f874545bd20 100644 --- a/ports/gonk/src/window.rs +++ b/ports/gonk/src/window.rs @@ -812,6 +812,9 @@ impl WindowMethods for Window { fn load_error(&self, _: NetError, _: String) { } + fn head_parsed(&self) { + } + fn hidpi_factor(&self) -> ScaleFactor { ScaleFactor::new(1.0) }