mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
style: Introduce CustomPropertiesBuilder.
I'm about to introduce more state here to implement optimizations for custom property cascading, so this abstraction is useful to encapsulate that state.
This commit is contained in:
parent
47efcd5e52
commit
d0f080d5dd
4 changed files with 73 additions and 63 deletions
|
@ -4,7 +4,7 @@
|
|||
|
||||
use cssparser::{Parser, ParserInput};
|
||||
use servo_arc::Arc;
|
||||
use style::custom_properties::{self, Name, SpecifiedValue, CustomPropertiesMap};
|
||||
use style::custom_properties::{Name, SpecifiedValue, CustomPropertiesMap, CustomPropertiesBuilder};
|
||||
use style::properties::DeclaredValue;
|
||||
use test::{self, Bencher};
|
||||
|
||||
|
@ -18,19 +18,13 @@ fn cascade(
|
|||
(Name::from(name), SpecifiedValue::parse(&mut parser).unwrap())
|
||||
}).collect::<Vec<_>>();
|
||||
|
||||
let mut custom_properties = None;
|
||||
let mut seen = Default::default();
|
||||
let mut builder = CustomPropertiesBuilder::new(inherited);
|
||||
|
||||
for &(ref name, ref val) in &values {
|
||||
custom_properties::cascade(
|
||||
&mut custom_properties,
|
||||
inherited,
|
||||
&mut seen,
|
||||
name,
|
||||
DeclaredValue::Value(val)
|
||||
)
|
||||
builder.cascade(name, DeclaredValue::Value(val));
|
||||
}
|
||||
|
||||
custom_properties::finish_cascade(custom_properties, inherited)
|
||||
builder.build()
|
||||
}
|
||||
|
||||
#[bench]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue