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
This commit is contained in:
Emilio Cobos Álvarez 2018-05-03 19:24:05 +02:00
parent 0ef70d52f2
commit 6ecc7445fc
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C

View file

@ -1555,27 +1555,25 @@ impl Stylist {
E: TElement, E: TElement,
{ {
use font_metrics::get_metrics_provider_for_product; use font_metrics::get_metrics_provider_for_product;
use std::iter;
// FIXME(emilio): Why do we even need the rule node? We should probably let block = declarations.read_with(guards.author);
// just avoid allocating it and calling `apply_declarations` directly, let iter_declarations = || {
// maybe... block.declaration_importance_iter().map(|(declaration, importance)| {
let rule_node = self.rule_tree.insert_ordered_rules(iter::once(( debug_assert!(!importance.important());
StyleSource::from_declarations(declarations), (declaration, CascadeLevel::StyleAttributeNormal)
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 metrics = get_metrics_provider_for_product(); let metrics = get_metrics_provider_for_product();
// FIXME(emilio): the pseudo bit looks quite dubious! // We don't bother inserting these declarations in the rule tree, since
properties::cascade::<E>( // it'd be quite useless and slow.
properties::apply_declarations::<E, _, _>(
&self.device, &self.device,
/* pseudo = */ None, /* pseudo = */ None,
&rule_node, self.rule_tree.root(),
guards, guards,
iter_declarations,
Some(parent_style), Some(parent_style),
Some(parent_style), Some(parent_style),
Some(parent_style), Some(parent_style),