mirror of
https://github.com/servo/servo.git
synced 2025-08-17 19:35:33 +01:00
style: remove is_servo(), as_servo() and as_servo_mut()
This commit adds a need_index prop to the style system, and autogenerates iterators, and a get_xxx_mod(i) function from a get_xxx_prop() and get_xxx_at(index) functions. This allows us to (finally!) take rid of the as_servo() hack. There are a few unimplemented clones, but I'm just too lazy for that right now.
This commit is contained in:
parent
ba53c4ea8d
commit
30963dd74d
7 changed files with 296 additions and 81 deletions
|
@ -127,22 +127,17 @@ impl AnimatedProperty {
|
|||
}
|
||||
}
|
||||
|
||||
// NB: Transition properties need clone
|
||||
pub fn from_transition_property<C: ComputedValues>(transition_property: &TransitionProperty,
|
||||
old_style: &C,
|
||||
new_style: &C) -> AnimatedProperty {
|
||||
// TODO: Generalise this for GeckoLib, adding clone_xxx to the
|
||||
// appropiate longhands.
|
||||
let old_style = old_style.as_servo();
|
||||
let new_style = new_style.as_servo();
|
||||
match *transition_property {
|
||||
TransitionProperty::All => panic!("Can't use TransitionProperty::All here."),
|
||||
% for prop in data.longhands:
|
||||
% if prop.animatable:
|
||||
TransitionProperty::${prop.camel_case} => {
|
||||
AnimatedProperty::${prop.camel_case}(
|
||||
old_style.get_${prop.style_struct.ident.strip("_")}().${prop.ident}.clone(),
|
||||
new_style.get_${prop.style_struct.ident.strip("_")}().${prop.ident}.clone())
|
||||
old_style.get_${prop.style_struct.ident.strip("_")}().clone_${prop.ident}(),
|
||||
new_style.get_${prop.style_struct.ident.strip("_")}().clone_${prop.ident}())
|
||||
}
|
||||
% endif
|
||||
% endfor
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue