@@ -82,25 +82,6 @@ impl<'i> ToCss for AnimationName<'i> {
8282 }
8383}
8484
85- impl < ' i > AnimationName < ' i > {
86- fn write_as_string < W > ( & self , dest : & mut Printer < W > ) -> Result < ( ) , PrinterError >
87- where
88- W : std:: fmt:: Write ,
89- {
90- match self {
91- AnimationName :: None => dest. write_str ( "none" ) ,
92- AnimationName :: Ident ( CustomIdent ( s) ) | AnimationName :: String ( s) => {
93- if let Some ( css_module) = & mut dest. css_module {
94- css_module. reference ( & s, dest. loc . source_index )
95- }
96-
97- serialize_string ( & s, dest) ?;
98- Ok ( ( ) )
99- }
100- }
101- }
102- }
103-
10485/// A list of animation names.
10586pub type AnimationNameList < ' i > = SmallVec < [ AnimationName < ' i > ; 1 ] > ;
10687
@@ -280,13 +261,13 @@ impl<'i> ToCss for Animation<'i> {
280261 {
281262 match & self . name {
282263 AnimationName :: None => { }
283- _ => {
264+ AnimationName :: Ident ( CustomIdent ( name ) ) | AnimationName :: String ( name ) => {
284265 if !self . duration . is_zero ( ) || !self . delay . is_zero ( ) {
285266 self . duration . to_css ( dest) ?;
286267 dest. write_char ( ' ' ) ?;
287268 }
288269
289- if !self . is_default_easing ( ) {
270+ if !self . is_default_easing ( ) || EasingFunction :: is_ident ( & name ) {
290271 self . timing_function . to_css ( dest) ?;
291272 dest. write_char ( ' ' ) ?;
292273 }
@@ -296,33 +277,33 @@ impl<'i> ToCss for Animation<'i> {
296277 dest. write_char ( ' ' ) ?;
297278 }
298279
299- if self . iteration_count != AnimationIterationCount :: default ( ) {
280+ if self . iteration_count != AnimationIterationCount :: default ( ) || name . as_ref ( ) == "infinite" {
300281 self . iteration_count . to_css ( dest) ?;
301282 dest. write_char ( ' ' ) ?;
302283 }
303284
304- if self . direction != AnimationDirection :: default ( ) {
285+ if self . direction != AnimationDirection :: default ( ) || AnimationDirection :: parse_string ( & name ) . is_ok ( ) {
305286 self . direction . to_css ( dest) ?;
306287 dest. write_char ( ' ' ) ?;
307288 }
308289
309- if self . fill_mode != AnimationFillMode :: default ( ) {
290+ if self . fill_mode != AnimationFillMode :: default ( )
291+ || ( !name. eq_ignore_ascii_case ( "none" ) && AnimationFillMode :: parse_string ( & name) . is_ok ( ) )
292+ {
310293 self . fill_mode . to_css ( dest) ?;
311294 dest. write_char ( ' ' ) ?;
312295 }
313296
314- if self . play_state != AnimationPlayState :: default ( ) {
297+ if self . play_state != AnimationPlayState :: default ( ) || AnimationPlayState :: parse_string ( & name ) . is_ok ( ) {
315298 self . play_state . to_css ( dest) ?;
316299 dest. write_char ( ' ' ) ?;
317300 }
318301 }
319302 }
320303
321- if self . name_conflicts_with_keyword ( ) {
322- self . name . write_as_string ( dest) ?;
323- } else {
324- self . name . to_css ( dest) ?;
325- } ;
304+ // Eventually we could output a string here to avoid duplicating some properties above.
305+ // Chrome does not yet support strings, however.
306+ self . name . to_css ( dest) ?;
326307
327308 Ok ( ( ) )
328309 }
@@ -333,35 +314,6 @@ impl<'i> Animation<'i> {
333314 self . timing_function == EasingFunction :: Ease
334315 || self . timing_function == EasingFunction :: CubicBezier ( 0.25 , 0.1 , 0.25 , 1.0 )
335316 }
336-
337- fn name_conflicts_with_keyword ( & self ) -> bool {
338- match & self . name {
339- AnimationName :: Ident ( CustomIdent ( name) ) | AnimationName :: String ( name) => {
340- if self . is_default_easing ( ) && EasingFunction :: is_ident ( & name) {
341- return true ;
342- }
343-
344- if self . iteration_count == AnimationIterationCount :: default ( ) && name. as_ref ( ) == "infinite" {
345- return true ;
346- }
347-
348- if self . direction == AnimationDirection :: default ( ) && AnimationDirection :: parse_string ( & name) . is_ok ( ) {
349- return true ;
350- }
351-
352- if self . fill_mode == AnimationFillMode :: default ( ) && AnimationFillMode :: parse_string ( & name) . is_ok ( ) {
353- return true ;
354- }
355-
356- if self . play_state == AnimationPlayState :: default ( ) && AnimationPlayState :: parse_string ( & name) . is_ok ( ) {
357- return true ;
358- }
359- }
360- _ => { }
361- }
362-
363- false
364- }
365317}
366318
367319/// A list of animations.
0 commit comments