mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Auto merge of #16263 - hiikezoe:handle-css-variables-in-animations, r=Manishearth
Make AnimationValue::from_declaration return computed CSS variable. This is a PR of https://bugzilla.mozilla.org/show_bug.cgi?id=1326131 In Gecko, we resolve CSS variables when we generate keyframes for each animations (i.e. when we create script animations, when we create/update CSS animations). AnimationValue::from_declaration is only called in both cases. <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors <!-- Either: --> - [X] These changes do not require tests because it's for stylo. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16263) <!-- Reviewable:end -->
This commit is contained in:
commit
a7e18560e5
1 changed files with 38 additions and 4 deletions
|
@ -301,7 +301,10 @@ impl AnimationValue {
|
||||||
|
|
||||||
/// Construct an AnimationValue from a property declaration
|
/// Construct an AnimationValue from a property declaration
|
||||||
pub fn from_declaration(decl: &PropertyDeclaration, context: &Context, initial: &ComputedValues) -> Option<Self> {
|
pub fn from_declaration(decl: &PropertyDeclaration, context: &Context, initial: &ComputedValues) -> Option<Self> {
|
||||||
|
use error_reporting::StdoutErrorReporter;
|
||||||
use properties::LonghandId;
|
use properties::LonghandId;
|
||||||
|
use properties::DeclaredValue;
|
||||||
|
|
||||||
match *decl {
|
match *decl {
|
||||||
% for prop in data.longhands:
|
% for prop in data.longhands:
|
||||||
% if prop.animatable:
|
% if prop.animatable:
|
||||||
|
@ -344,10 +347,41 @@ impl AnimationValue {
|
||||||
% endif
|
% endif
|
||||||
% endfor
|
% endfor
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
PropertyDeclaration::WithVariables(_, _) => {
|
PropertyDeclaration::WithVariables(id, ref variables) => {
|
||||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1326131
|
let custom_props = context.style().custom_properties();
|
||||||
unimplemented!()
|
let reporter = StdoutErrorReporter;
|
||||||
|
match id {
|
||||||
|
% for prop in data.longhands:
|
||||||
|
% if prop.animatable:
|
||||||
|
LonghandId::${prop.camel_case} => {
|
||||||
|
let mut result = None;
|
||||||
|
::properties::substitute_variables_${prop.ident}_slow(
|
||||||
|
&variables.css,
|
||||||
|
variables.first_token_type,
|
||||||
|
&variables.url_data,
|
||||||
|
variables.from_shorthand,
|
||||||
|
&custom_props,
|
||||||
|
|v| {
|
||||||
|
let declaration = match *v {
|
||||||
|
DeclaredValue::Value(value) => {
|
||||||
|
PropertyDeclaration::${prop.camel_case}(value.clone())
|
||||||
|
},
|
||||||
|
DeclaredValue::CSSWideKeyword(keyword) => {
|
||||||
|
PropertyDeclaration::CSSWideKeyword(id, keyword)
|
||||||
|
},
|
||||||
|
DeclaredValue::WithVariables(_) => unreachable!(),
|
||||||
|
};
|
||||||
|
result = AnimationValue::from_declaration(&declaration, context, initial);
|
||||||
|
},
|
||||||
|
&reporter);
|
||||||
|
result
|
||||||
|
},
|
||||||
|
% else:
|
||||||
|
LonghandId::${prop.camel_case} => None,
|
||||||
|
% endif
|
||||||
|
% endfor
|
||||||
|
}
|
||||||
},
|
},
|
||||||
_ => None // non animatable properties will get included because of shorthands. ignore.
|
_ => None // non animatable properties will get included because of shorthands. ignore.
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue