1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
use Atom;
use cssparser::Parser;
use parser::{Parse, ParserContext};
use std::fmt;
use style_traits::{ParseError, ToCss};
use values::CustomIdent;
use values::KeyframesName;
use values::generics::box_::AnimationIterationCount as GenericAnimationIterationCount;
use values::generics::box_::VerticalAlign as GenericVerticalAlign;
use values::specified::{AllowQuirks, Number};
use values::specified::length::LengthOrPercentage;
pub type VerticalAlign = GenericVerticalAlign<LengthOrPercentage>;
impl Parse for VerticalAlign {
fn parse<'i, 't>(
context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> {
if let Ok(lop) = input.try(|i| LengthOrPercentage::parse_quirky(context, i, AllowQuirks::Yes)) {
return Ok(GenericVerticalAlign::Length(lop));
}
try_match_ident_ignore_ascii_case! { input,
"baseline" => Ok(GenericVerticalAlign::Baseline),
"sub" => Ok(GenericVerticalAlign::Sub),
"super" => Ok(GenericVerticalAlign::Super),
"top" => Ok(GenericVerticalAlign::Top),
"text-top" => Ok(GenericVerticalAlign::TextTop),
"middle" => Ok(GenericVerticalAlign::Middle),
"bottom" => Ok(GenericVerticalAlign::Bottom),
"text-bottom" => Ok(GenericVerticalAlign::TextBottom),
#[cfg(feature = "gecko")]
"-moz-middle-with-baseline" => {
Ok(GenericVerticalAlign::MozMiddleWithBaseline)
},
}
}
}
pub type AnimationIterationCount = GenericAnimationIterationCount<Number>;
impl Parse for AnimationIterationCount {
fn parse<'i, 't>(
context: &ParserContext,
input: &mut ::cssparser::Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> {
if input.try(|input| input.expect_ident_matching("infinite")).is_ok() {
return Ok(GenericAnimationIterationCount::Infinite)
}
let number = Number::parse_non_negative(context, input)?;
Ok(GenericAnimationIterationCount::Number(number))
}
}
impl AnimationIterationCount {
#[inline]
pub fn one() -> Self {
GenericAnimationIterationCount::Number(Number::new(1.0))
}
}
#[derive(Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToComputedValue)]
pub struct AnimationName(pub Option<KeyframesName>);
impl AnimationName {
pub fn as_atom(&self) -> Option<&Atom> {
self.0.as_ref().map(|n| n.as_atom())
}
pub fn none() -> Self {
AnimationName(None)
}
}
impl ToCss for AnimationName {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result
where
W: fmt::Write,
{
match self.0 {
Some(ref name) => name.to_css(dest),
None => dest.write_str("none"),
}
}
}
impl Parse for AnimationName {
fn parse<'i, 't>(
context: &ParserContext,
input: &mut Parser<'i, 't>
) -> Result<Self, ParseError<'i>> {
if let Ok(name) = input.try(|input| KeyframesName::parse(context, input)) {
return Ok(AnimationName(Some(name)));
}
input.expect_ident_matching("none")?;
Ok(AnimationName(None))
}
}
define_css_keyword_enum! { ScrollSnapType:
"none" => None,
"mandatory" => Mandatory,
"proximity" => Proximity,
}
add_impls_for_keyword_enum!(ScrollSnapType);
define_css_keyword_enum! { OverscrollBehavior:
"auto" => Auto,
"contain" => Contain,
"none" => None,
}
add_impls_for_keyword_enum!(OverscrollBehavior);
define_css_keyword_enum! { OverflowClipBox:
"padding-box" => PaddingBox,
"content-box" => ContentBox,
}
add_impls_for_keyword_enum!(OverflowClipBox);
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)]
pub enum WillChange {
Auto,
#[css(comma, iterable)]
AnimateableFeatures(Box<[CustomIdent]>),
}
impl WillChange {
#[inline]
pub fn auto() -> WillChange {
WillChange::Auto
}
}
impl Parse for WillChange {
fn parse<'i, 't>(
_context: &ParserContext,
input: &mut Parser<'i, 't>
) -> Result<WillChange, ParseError<'i>> {
if input.try(|input| input.expect_ident_matching("auto")).is_ok() {
return Ok(WillChange::Auto);
}
let custom_idents = input.parse_comma_separated(|i| {
let location = i.current_source_location();
CustomIdent::from_ident(location, i.expect_ident()?, &[
"will-change",
"none",
"all",
"auto",
])
})?;
Ok(WillChange::AnimateableFeatures(custom_idents.into_boxed_slice()))
}
}