mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
style: Generalize resolved style code to deal with all shorthands
This removes the various assumptions that the animation code does. Code size might be a concern, we can optimize if it is a problem, but let's do the obvious thing for now. Differential Revision: https://phabricator.services.mozilla.com/D130017
This commit is contained in:
parent
04776cd116
commit
b702426c99
1 changed files with 29 additions and 1 deletions
|
@ -3086,7 +3086,10 @@ impl ComputedValues {
|
|||
///
|
||||
/// Note that the value will usually be the computed value, except for
|
||||
/// colors, where it's resolved.
|
||||
pub fn get_longhand_property_value<W>(
|
||||
///
|
||||
/// TODO(emilio): We should move all the special resolution from
|
||||
/// nsComputedDOMStyle to ToResolvedValue instead.
|
||||
pub fn get_resolved_value<W>(
|
||||
&self,
|
||||
property_id: LonghandId,
|
||||
dest: &mut CssWriter<W>
|
||||
|
@ -3112,6 +3115,31 @@ impl ComputedValues {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns the given longhand's resolved value as a property declaration.
|
||||
pub fn resolved_declaration(&self, property_id: LonghandId) -> PropertyDeclaration {
|
||||
use crate::values::resolved::ToResolvedValue;
|
||||
use crate::values::computed::ToComputedValue;
|
||||
|
||||
let context = resolved::Context {
|
||||
style: self,
|
||||
};
|
||||
|
||||
match property_id {
|
||||
% for prop in data.longhands:
|
||||
LonghandId::${prop.camel_case} => {
|
||||
let value = self.clone_${prop.ident}();
|
||||
let resolved = value.to_resolved_value(&context);
|
||||
%if prop.boxed:
|
||||
let resolved = Box::new(resolved);
|
||||
%endif
|
||||
let computed = ToResolvedValue::from_resolved_value(resolved);
|
||||
let specified = ToComputedValue::from_computed_value(&computed);
|
||||
PropertyDeclaration::${prop.camel_case}(specified)
|
||||
}
|
||||
% endfor
|
||||
}
|
||||
}
|
||||
|
||||
/// Resolves the currentColor keyword.
|
||||
///
|
||||
/// Any color value from computed values (except for the 'color' property
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue