aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBobby Holley <bobbyholley@gmail.com>2015-11-04 17:14:04 -0800
committerBobby Holley <bobbyholley@gmail.com>2015-11-04 19:01:49 -0800
commit77c253fd43a8ef1723c48709b5fececa742ba4fa (patch)
tree0e4abca346edd6fefe9ff740c4419daff8972dea
parent1dc144d1687cc6d89b29be859454e7ef73fb341d (diff)
downloadservo-77c253fd43a8ef1723c48709b5fececa742ba4fa.tar.gz
servo-77c253fd43a8ef1723c48709b5fececa742ba4fa.zip
Load web fonts synchronously during wpt.
-rw-r--r--components/layout/layout_task.rs16
-rw-r--r--components/util/opts.rs11
-rw-r--r--tests/wpt/harness/wptrunner/executors/executorservo.py2
3 files changed, 24 insertions, 5 deletions
diff --git a/components/layout/layout_task.rs b/components/layout/layout_task.rs
index c86ecdedaff..7a615b02f6b 100644
--- a/components/layout/layout_task.rs
+++ b/components/layout/layout_task.rs
@@ -326,10 +326,18 @@ fn add_font_face_rules(stylesheet: &Stylesheet,
outstanding_web_fonts_counter: &Arc<AtomicUsize>) {
for font_face in stylesheet.effective_rules(&device).font_face() {
for source in &font_face.sources {
- outstanding_web_fonts_counter.fetch_add(1, Ordering::SeqCst);
- font_cache_task.add_web_font(font_face.family.clone(),
- (*source).clone(),
- (*font_cache_sender).clone());
+ if opts::get().load_webfonts_synchronously {
+ let (sender, receiver) = channel();
+ font_cache_task.add_web_font(font_face.family.clone(),
+ (*source).clone(),
+ sender);
+ receiver.recv().unwrap();
+ } else {
+ outstanding_web_fonts_counter.fetch_add(1, Ordering::SeqCst);
+ font_cache_task.add_web_font(font_face.family.clone(),
+ (*source).clone(),
+ (*font_cache_sender).clone());
+ }
}
}
}
diff --git a/components/util/opts.rs b/components/util/opts.rs
index fb68c24964d..6d91e0d6c42 100644
--- a/components/util/opts.rs
+++ b/components/util/opts.rs
@@ -74,6 +74,9 @@ pub struct Opts {
/// Log GC passes and their durations.
pub gc_profile: bool,
+ /// Load web fonts synchronously to avoid non-deterministic network-driven reflows.
+ pub load_webfonts_synchronously: bool,
+
pub headless: bool,
pub hard_fail: bool,
@@ -267,6 +270,9 @@ pub struct DebugOptions {
/// Log GC passes and their durations.
pub gc_profile: bool,
+
+ /// Load web fonts synchronously to avoid non-deterministic network-driven reflows.
+ pub load_webfonts_synchronously: bool,
}
@@ -301,6 +307,7 @@ impl DebugOptions {
"convert-mouse-to-touch" => debug_options.convert_mouse_to_touch = true,
"replace-surrogates" => debug_options.replace_surrogates = true,
"gc-profile" => debug_options.gc_profile = true,
+ "load-webfonts-synchronously" => debug_options.load_webfonts_synchronously = true,
"" => {},
_ => return Err(option)
};
@@ -345,6 +352,8 @@ pub fn print_debug_usage(app: &str) -> ! {
print_option("replace-surrogates", "Replace unpaires surrogates in DOM strings with U+FFFD. \
See https://github.com/servo/servo/issues/6564");
print_option("gc-profile", "Log GC passes and their durations.");
+ print_option("load-webfonts-synchronously",
+ "Load web fonts synchronously to avoid non-deterministic network-driven reflows");
println!("");
@@ -414,6 +423,7 @@ pub fn default_opts() -> Opts {
output_file: None,
replace_surrogates: false,
gc_profile: false,
+ load_webfonts_synchronously: false,
headless: true,
hard_fail: true,
bubble_inline_sizes_separately: false,
@@ -632,6 +642,7 @@ pub fn from_cmdline_args(args: &[String]) {
output_file: opt_match.opt_str("o"),
replace_surrogates: debug_options.replace_surrogates,
gc_profile: debug_options.gc_profile,
+ load_webfonts_synchronously: debug_options.load_webfonts_synchronously,
headless: opt_match.opt_present("z"),
hard_fail: opt_match.opt_present("f"),
bubble_inline_sizes_separately: bubble_inline_sizes_separately,
diff --git a/tests/wpt/harness/wptrunner/executors/executorservo.py b/tests/wpt/harness/wptrunner/executors/executorservo.py
index a1e0ea97b31..b1beea9934a 100644
--- a/tests/wpt/harness/wptrunner/executors/executorservo.py
+++ b/tests/wpt/harness/wptrunner/executors/executorservo.py
@@ -203,7 +203,7 @@ class ServoRefTestExecutor(ProcessTestExecutor):
debug_args, command = browser_command(
self.binary,
[render_arg(self.browser.render_backend), "--hard-fail", "--exit",
- "-u", "Servo/wptrunner", "-Z", "disable-text-aa",
+ "-u", "Servo/wptrunner", "-Z", "disable-text-aa,load-webfonts-synchronously",
"--output=%s" % output_path, full_url],
self.debug_info)