aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
Diffstat (limited to 'components/script')
-rw-r--r--components/script/dom/window.rs2
-rw-r--r--components/script/layout_interface.rs7
-rw-r--r--components/script/script_task.rs11
3 files changed, 20 insertions, 0 deletions
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index a510dd544cf..4cec46c7814 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -100,6 +100,7 @@ pub enum ReflowReason {
DocumentLoaded,
ImageLoaded,
RequestAnimationFrame,
+ WebFontLoaded,
}
pub type ScrollPoint = Point2D<Au>;
@@ -1378,6 +1379,7 @@ fn debug_reflow_events(goal: &ReflowGoal, query_type: &ReflowQueryType, reason:
ReflowReason::DocumentLoaded => "\tDocumentLoaded",
ReflowReason::ImageLoaded => "\tImageLoaded",
ReflowReason::RequestAnimationFrame => "\tRequestAnimationFrame",
+ ReflowReason::WebFontLoaded => "\tWebFontLoaded",
});
println!("{}", debug_msg);
diff --git a/components/script/layout_interface.rs b/components/script/layout_interface.rs
index 9a461a4b1b0..702cce2d0b0 100644
--- a/components/script/layout_interface.rs
+++ b/components/script/layout_interface.rs
@@ -51,6 +51,9 @@ pub enum Msg {
/// Requests that the layout task render the next frame of all animations.
TickAnimations,
+ /// Requests that the layout task reflow with a newly-loaded Web font.
+ ReflowWithNewlyLoadedWebFont,
+
/// Updates the layout visible rects, affecting the area that display lists will be constructed
/// for.
SetVisibleRects(Vec<(LayerId, Rect<Au>)>),
@@ -76,6 +79,10 @@ pub enum Msg {
/// Get the last epoch counter for this layout task.
GetCurrentEpoch(IpcSender<Epoch>),
+ /// Asks the layout task whether any Web fonts have yet to load (if true, loads are pending;
+ /// false otherwise).
+ GetWebFontLoadState(IpcSender<bool>),
+
/// Creates a new layout task.
///
/// This basically exists to keep the script-layout dependency one-way.
diff --git a/components/script/script_task.rs b/components/script/script_task.rs
index 30684e0ee00..a935e4b91f5 100644
--- a/components/script/script_task.rs
+++ b/components/script/script_task.rs
@@ -942,6 +942,8 @@ impl ScriptTask {
self.handle_webdriver_msg(pipeline_id, msg),
ConstellationControlMsg::TickAllAnimations(pipeline_id) =>
self.handle_tick_all_animations(pipeline_id),
+ ConstellationControlMsg::WebFontLoaded(pipeline_id) =>
+ self.handle_web_font_loaded(pipeline_id),
ConstellationControlMsg::StylesheetLoadComplete(id, url, responder) => {
responder.respond();
self.handle_resource_loaded(id, LoadType::Stylesheet(url));
@@ -1478,6 +1480,15 @@ impl ScriptTask {
document.r().run_the_animation_frame_callbacks();
}
+ /// Handles a Web font being loaded. Does nothing if the page no longer exists.
+ fn handle_web_font_loaded(&self, pipeline_id: PipelineId) {
+ if let Some(page) = self.page.borrow().as_ref() {
+ if let Some(page) = page.find(pipeline_id) {
+ self.rebuild_and_force_reflow(&*page, ReflowReason::WebFontLoaded);
+ }
+ }
+ }
+
/// The entry point to document loading. Defines bindings, sets up the window and document
/// objects, parses HTML and CSS, and kicks off initial layout.
fn load(&self, metadata: Metadata, incomplete: InProgressLoad) -> Root<ServoHTMLParser> {