style: Tidy Stylist::compute_for_declarations.

This commit is contained in:
Emilio Cobos Álvarez 2018-02-10 03:38:23 +01:00
parent 1d8e78720b
commit 8e3da86636
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C

View file

@ -1494,19 +1494,16 @@ 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 // FIXME(emilio): Why do we even need the rule node? We should probably
// just avoid allocating it and calling `apply_declarations` directly, // just avoid allocating it and calling `apply_declarations` directly,
// maybe... // maybe...
//
// Also the `vec!` is super-wasteful.
let v = vec![ApplicableDeclarationBlock::from_declarations(
declarations.clone(),
CascadeLevel::StyleAttributeNormal
)];
let rule_node = let rule_node =
self.rule_tree.insert_ordered_rules(v.into_iter().map(|a| a.order_and_level())); self.rule_tree.insert_ordered_rules(iter::once((
StyleSource::Declarations(declarations),
CascadeLevel::StyleAttributeNormal,
)));
// This currently ignores visited styles. It appears to be used for // This currently ignores visited styles. It appears to be used for
// font styles in <canvas> via Servo_StyleSet_ResolveForDeclarations. // font styles in <canvas> via Servo_StyleSet_ResolveForDeclarations.