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:
Emilio Cobos Álvarez 2017-10-08 14:58:14 +02:00
parent 47efcd5e52
commit d0f080d5dd
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
4 changed files with 73 additions and 63 deletions

View file

@ -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]