aboutsummaryrefslogtreecommitdiffstats
path: root/components/style/stylist.rs
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <emilio@crisal.io>2018-05-03 19:24:05 +0200
committerEmilio Cobos Álvarez <emilio@crisal.io>2018-05-05 16:22:47 +0200
commit6ecc7445fc5fc654cbbf4b818b4549699f07d71a (patch)
treedf4b149778779faca7bff1d5712ea4f2964c5095 /components/style/stylist.rs
parent0ef70d52f22a0f9a3398866a5db9447dd5407c3a (diff)
downloadservo-6ecc7445fc5fc654cbbf4b818b4549699f07d71a.tar.gz
servo-6ecc7445fc5fc654cbbf4b818b4549699f07d71a.zip
style: Make the font canvas code not mess with the rule tree.
Inserting a lot of rules in the root level is super-inefficient. This fixes it by not doing it. It gives the root rule node to the style, but that's fine, since it's useless. All this code-path is already pretty messy. Bug: 1457678 Reviewed-by: xidorn,hiro MozReview-Commit-ID: GoGHI4YJbKr
Diffstat (limited to 'components/style/stylist.rs')
-rw-r--r--components/style/stylist.rs30
1 files changed, 14 insertions, 16 deletions
diff --git a/components/style/stylist.rs b/components/style/stylist.rs
index 732edc212b5..54d006d4ff8 100644
--- a/components/style/stylist.rs
+++ b/components/style/stylist.rs
@@ -1555,27 +1555,25 @@ impl Stylist {
E: TElement,
{
use font_metrics::get_metrics_provider_for_product;
- use std::iter;
-
- // FIXME(emilio): Why do we even need the rule node? We should probably
- // just avoid allocating it and calling `apply_declarations` directly,
- // maybe...
- let rule_node = self.rule_tree.insert_ordered_rules(iter::once((
- StyleSource::from_declarations(declarations),
- CascadeLevel::StyleAttributeNormal,
- )));
-
- // This currently ignores visited styles. It appears to be used for
- // font styles in <canvas> via Servo_StyleSet_ResolveForDeclarations.
- // It is unclear if visited styles are meaningful for this case.
+
+ let block = declarations.read_with(guards.author);
+ let iter_declarations = || {
+ block.declaration_importance_iter().map(|(declaration, importance)| {
+ debug_assert!(!importance.important());
+ (declaration, CascadeLevel::StyleAttributeNormal)
+ })
+ };
+
let metrics = get_metrics_provider_for_product();
- // FIXME(emilio): the pseudo bit looks quite dubious!
- properties::cascade::<E>(
+ // We don't bother inserting these declarations in the rule tree, since
+ // it'd be quite useless and slow.
+ properties::apply_declarations::<E, _, _>(
&self.device,
/* pseudo = */ None,
- &rule_node,
+ self.rule_tree.root(),
guards,
+ iter_declarations,
Some(parent_style),
Some(parent_style),
Some(parent_style),