Auto merge of #20011 - emilio:cleanup-for-declarations-stuff, r=Manishearth

style: Tidy Stylist::compute_for_declarations.

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/20011)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2018-02-10 06:45:52 -05:00 committed by GitHub
commit 0098d51903
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1494,19 +1494,16 @@ 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...
//
// Also the `vec!` is super-wasteful.
let v = vec![ApplicableDeclarationBlock::from_declarations(
declarations.clone(),
CascadeLevel::StyleAttributeNormal
)];
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
// font styles in <canvas> via Servo_StyleSet_ResolveForDeclarations.