mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
style: Avoid walking the rule tree three times from apply_declarations.
Just once is slow enough. Differential Revision: https://phabricator.services.mozilla.com/D6574
This commit is contained in:
parent
3b153af49c
commit
75bebf1618
1 changed files with 6 additions and 3 deletions
|
@ -20,6 +20,7 @@ use selector_parser::PseudoElement;
|
|||
use servo_arc::Arc;
|
||||
use shared_lock::StylesheetGuards;
|
||||
use smallbitvec::SmallBitVec;
|
||||
use smallvec::SmallVec;
|
||||
use std::borrow::Cow;
|
||||
use std::cell::RefCell;
|
||||
use style_adjuster::StyleAdjuster;
|
||||
|
@ -240,10 +241,12 @@ where
|
|||
|
||||
let inherited_style = parent_style.unwrap_or(device.default_computed_values());
|
||||
|
||||
let mut declarations = SmallVec::<[(&_, CascadeLevel); 32]>::new();
|
||||
let custom_properties = {
|
||||
let mut builder = CustomPropertiesBuilder::new(inherited_style.custom_properties());
|
||||
|
||||
for (declaration, _cascade_level) in iter_declarations() {
|
||||
for (declaration, cascade_level) in iter_declarations() {
|
||||
declarations.push((declaration, cascade_level));
|
||||
if let PropertyDeclaration::Custom(ref declaration) = *declaration {
|
||||
builder.cascade(&declaration.name, &declaration.value);
|
||||
}
|
||||
|
@ -278,7 +281,7 @@ where
|
|||
let mut cascade = Cascade::new(&mut context, cascade_mode);
|
||||
|
||||
cascade
|
||||
.apply_properties::<EarlyProperties, I>(ApplyResetProperties::Yes, iter_declarations());
|
||||
.apply_properties::<EarlyProperties, _>(ApplyResetProperties::Yes, declarations.iter().cloned());
|
||||
|
||||
cascade.compute_visited_style_if_needed(
|
||||
element,
|
||||
|
@ -297,7 +300,7 @@ where
|
|||
ApplyResetProperties::Yes
|
||||
};
|
||||
|
||||
cascade.apply_properties::<LateProperties, I>(apply_reset, iter_declarations());
|
||||
cascade.apply_properties::<LateProperties, _>(apply_reset, declarations.iter().cloned());
|
||||
|
||||
using_cached_reset_properties
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue