mirror of
https://github.com/servo/servo.git
synced 2025-06-25 01:24:37 +01:00
style: parse the remaining animation longhands.
This commit is contained in:
parent
f529786700
commit
818bc6d4a2
5 changed files with 94 additions and 3 deletions
|
@ -336,4 +336,12 @@ partial interface CSSStyleDeclaration {
|
|||
[SetterThrows, TreatNullAs=EmptyString] attribute DOMString animationTimingFunction;
|
||||
[SetterThrows, TreatNullAs=EmptyString] attribute DOMString animation-iteration-count;
|
||||
[SetterThrows, TreatNullAs=EmptyString] attribute DOMString animationIterationCount;
|
||||
[SetterThrows, TreatNullAs=EmptyString] attribute DOMString animation-direction;
|
||||
[SetterThrows, TreatNullAs=EmptyString] attribute DOMString animationDirection;
|
||||
[SetterThrows, TreatNullAs=EmptyString] attribute DOMString animation-play-state;
|
||||
[SetterThrows, TreatNullAs=EmptyString] attribute DOMString animationPlayState;
|
||||
[SetterThrows, TreatNullAs=EmptyString] attribute DOMString animation-fill-mode;
|
||||
[SetterThrows, TreatNullAs=EmptyString] attribute DOMString animationFillMode;
|
||||
[SetterThrows, TreatNullAs=EmptyString] attribute DOMString animation-delay;
|
||||
[SetterThrows, TreatNullAs=EmptyString] attribute DOMString animationDelay;
|
||||
};
|
||||
|
|
|
@ -13,7 +13,7 @@ def to_rust_ident(name):
|
|||
|
||||
|
||||
def to_camel_case(ident):
|
||||
return re.sub("_([a-z])", lambda m: m.group(1).upper(), ident.strip("_").capitalize())
|
||||
return re.sub("(^|_|-)([a-z])", lambda m: m.group(2).upper(), ident.strip("_").strip("-"))
|
||||
|
||||
|
||||
class Keyword(object):
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
<%! from data import Keyword, to_rust_ident %>
|
||||
<%! from data import Keyword, to_rust_ident, to_camel_case %>
|
||||
|
||||
<%def name="longhand(name, **kwargs)">
|
||||
<%call expr="raw_longhand(name, **kwargs)">
|
||||
|
@ -181,9 +181,11 @@
|
|||
% endfor
|
||||
}
|
||||
}
|
||||
#[inline] pub fn get_initial_value() -> computed_value::T {
|
||||
#[inline]
|
||||
pub fn get_initial_value() -> computed_value::T {
|
||||
computed_value::T::${to_rust_ident(values.split()[0])}
|
||||
}
|
||||
#[inline]
|
||||
pub fn parse(_context: &ParserContext, input: &mut Parser)
|
||||
-> Result<SpecifiedValue, ()> {
|
||||
computed_value::T::parse(input)
|
||||
|
@ -191,6 +193,63 @@
|
|||
</%call>
|
||||
</%def>
|
||||
|
||||
<%def name="keyword_list(name, values, **kwargs)">
|
||||
<%
|
||||
keyword_kwargs = {a: kwargs.pop(a, None) for a in [
|
||||
'gecko_constant_prefix', 'extra_gecko_values', 'extra_servo_values'
|
||||
]}
|
||||
%>
|
||||
<%call expr="longhand(name, keyword=Keyword(name, values, **keyword_kwargs), **kwargs)">
|
||||
use values::computed::ComputedValueAsSpecified;
|
||||
pub use self::computed_value::T as SpecifiedValue;
|
||||
pub mod computed_value {
|
||||
use cssparser::ToCss;
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, HeapSizeOf)]
|
||||
pub struct T(pub Vec<${to_camel_case(name)}>);
|
||||
|
||||
impl ToCss for T {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
debug_assert!(!self.0.is_empty(), "Always parses at least one");
|
||||
|
||||
for (index, item) in self.0.iter().enumerate() {
|
||||
if index != 0 {
|
||||
try!(dest.write_str(", "));
|
||||
}
|
||||
|
||||
try!(item.to_css(dest));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
define_css_keyword_enum! { ${to_camel_case(name)}:
|
||||
% for value in data.longhands_by_name[name].keyword.values_for(product):
|
||||
"${value}" => ${to_rust_ident(value)},
|
||||
% endfor
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn get_initial_value() -> computed_value::T {
|
||||
computed_value::T(vec![
|
||||
computed_value::${to_camel_case(name)}::${to_rust_ident(values.split()[0])}
|
||||
])
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn parse(_context: &ParserContext, input: &mut Parser)
|
||||
-> Result<SpecifiedValue, ()> {
|
||||
Ok(SpecifiedValue(try!(
|
||||
input.parse_comma_separated(computed_value::${to_camel_case(name)}::parse))))
|
||||
}
|
||||
|
||||
impl ComputedValueAsSpecified for SpecifiedValue {}
|
||||
</%call>
|
||||
</%def>
|
||||
|
||||
<%def name="shorthand(name, sub_properties, experimental=False, **kwargs)">
|
||||
<%
|
||||
shorthand = data.declare_shorthand(name, sub_properties.split(), experimental=experimental,
|
||||
|
|
|
@ -949,6 +949,24 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto", need_clone=
|
|||
impl ComputedValueAsSpecified for SpecifiedValue {}
|
||||
</%helpers:longhand>
|
||||
|
||||
${helpers.keyword_list("animation-direction",
|
||||
"normal reverse alternate alternate-reverse",
|
||||
experimental=True)}
|
||||
|
||||
${helpers.keyword_list("animation-play-state",
|
||||
"running paused",
|
||||
experimental=True)}
|
||||
|
||||
${helpers.keyword_list("animation-fill-mode",
|
||||
"none forwards backwards both",
|
||||
experimental=True)}
|
||||
|
||||
<%helpers:longhand name="animation-delay" experimental="True">
|
||||
pub use super::transition_duration::computed_value;
|
||||
pub use super::transition_duration::{parse, get_initial_value};
|
||||
pub use super::transition_duration::SpecifiedValue;
|
||||
</%helpers:longhand>
|
||||
|
||||
// CSSOM View Module
|
||||
// https://www.w3.org/TR/cssom-view-1/
|
||||
${helpers.single_keyword("scroll-behavior",
|
||||
|
|
|
@ -389,6 +389,12 @@ impl Debug for ${style_struct.gecko_struct_name} {
|
|||
force_stub += ["list-style-type", "text-overflow"]
|
||||
# These are booleans.
|
||||
force_stub += ["page-break-after", "page-break-before"]
|
||||
# In a nsTArray, have to be done manually, but probably not too much work
|
||||
# (the "filling them", not the "making them work")
|
||||
force_stub += ["animation-name", "animation-duration",
|
||||
"animation-timing-function", "animation-iteration-count",
|
||||
"animation-direction", "animation-play-state",
|
||||
"animation-fill-mode", "animation-delay"]
|
||||
|
||||
# Types used with predefined_type()-defined properties that we can auto-generate.
|
||||
predefined_types = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue