@@ -272,23 +272,55 @@ bool ConsumeAnimationRangeItemInto(CSSParserTokenStream& stream,
272
272
return true ;
273
273
}
274
274
275
- } // namespace
275
+ const CSSValue* AnimationRangeCSSValueFromComputedStyle (
276
+ const ComputedStyle& style,
277
+ const Vector<std::optional<TimelineOffset>>& range_start_list,
278
+ const Vector<std::optional<TimelineOffset>>& range_end_list) {
279
+ if (range_start_list.size () != range_end_list.size ()) {
280
+ return nullptr ;
281
+ }
276
282
277
- bool AnimationRange::ParseShorthand (
283
+ TimelineOffset default_start (TimelineOffset::NamedRange::kNone ,
284
+ Length::Percent (0 ));
285
+ TimelineOffset default_end (TimelineOffset::NamedRange::kNone ,
286
+ Length::Percent (100 ));
287
+ auto * outer_list = CSSValueList::CreateCommaSeparated ();
288
+
289
+ for (wtf_size_t i = 0 ; i < range_start_list.size (); ++i) {
290
+ const std::optional<TimelineOffset>& start = range_start_list[i];
291
+ const std::optional<TimelineOffset>& end = range_end_list[i];
292
+
293
+ auto * inner_list = CSSValueList::CreateSpaceSeparated ();
294
+ inner_list->Append (*ComputedStyleUtils::ValueForAnimationRange (
295
+ start, style, Length::Percent (0.0 )));
296
+
297
+ // The form "name X name 100%" must contract to "name X".
298
+ //
299
+ // https://github.com/w3c/csswg-drafts/issues/8438
300
+ TimelineOffset omittable_end (start.value_or (default_start).name ,
301
+ Length::Percent (100 ));
302
+ if (end.value_or (default_end) != omittable_end) {
303
+ inner_list->Append (*ComputedStyleUtils::ValueForAnimationRange (
304
+ end, style, Length::Percent (100.0 )));
305
+ }
306
+ outer_list->Append (*inner_list);
307
+ }
308
+
309
+ return outer_list;
310
+ }
311
+
312
+ bool ParseAnimationRangeShorthand (
313
+ const StylePropertyShorthand& shorthand,
314
+ CSSPropertyID start_longhand_id,
315
+ CSSPropertyID end_longhand_id,
278
316
bool important,
279
317
CSSParserTokenStream& stream,
280
318
const CSSParserContext& context,
281
- const CSSParserLocalContext& local_context,
282
- HeapVector<CSSPropertyValue, 64 >& properties) const {
319
+ HeapVector<CSSPropertyValue, 64 >& properties) {
283
320
using css_parsing_utils::AddProperty;
284
321
using css_parsing_utils::ConsumeCommaIncludingWhitespace;
285
322
using css_parsing_utils::IsImplicitProperty;
286
323
287
- const StylePropertyShorthand shorthand = animationRangeShorthand ();
288
- DCHECK_EQ (2u , shorthand.length ());
289
- DCHECK_EQ (&GetCSSPropertyAnimationRangeStart (), shorthand.properties ()[0 ]);
290
- DCHECK_EQ (&GetCSSPropertyAnimationRangeEnd (), shorthand.properties ()[1 ]);
291
-
292
324
CSSValueList* start_list = CSSValueList::CreateCommaSeparated ();
293
325
CSSValueList* end_list = CSSValueList::CreateCommaSeparated ();
294
326
@@ -302,16 +334,32 @@ bool AnimationRange::ParseShorthand(
302
334
DCHECK (end_list->length ());
303
335
DCHECK_EQ (start_list->length (), end_list->length ());
304
336
305
- AddProperty (CSSPropertyID::kAnimationRangeStart ,
306
- CSSPropertyID::kAnimationRange , *start_list, important,
337
+ AddProperty (start_longhand_id, shorthand.id (), *start_list, important,
338
+ IsImplicitProperty::kNotImplicit , properties);
339
+ AddProperty (end_longhand_id, shorthand.id (), *end_list, important,
307
340
IsImplicitProperty::kNotImplicit , properties);
308
- AddProperty (CSSPropertyID::kAnimationRangeEnd , CSSPropertyID::kAnimationRange ,
309
- *end_list, important, IsImplicitProperty::kNotImplicit ,
310
- properties);
311
341
312
342
return true ;
313
343
}
314
344
345
+ } // namespace
346
+
347
+ bool AnimationRange::ParseShorthand (
348
+ bool important,
349
+ CSSParserTokenStream& stream,
350
+ const CSSParserContext& context,
351
+ const CSSParserLocalContext& local_context,
352
+ HeapVector<CSSPropertyValue, 64 >& properties) const {
353
+ const StylePropertyShorthand shorthand = animationRangeShorthand ();
354
+ DCHECK_EQ (2u , shorthand.length ());
355
+ DCHECK_EQ (&GetCSSPropertyAnimationRangeStart (), shorthand.properties ()[0 ]);
356
+ DCHECK_EQ (&GetCSSPropertyAnimationRangeEnd (), shorthand.properties ()[1 ]);
357
+ return ParseAnimationRangeShorthand (shorthand,
358
+ CSSPropertyID::kAnimationRangeStart ,
359
+ CSSPropertyID::kAnimationRangeEnd ,
360
+ important, stream, context, properties);
361
+ }
362
+
315
363
const CSSValue* AnimationRange::CSSValueFromComputedStyleInternal (
316
364
const ComputedStyle& style,
317
365
const LayoutObject*,
@@ -326,38 +374,81 @@ const CSSValue* AnimationRange::CSSValueFromComputedStyleInternal(
326
374
: Vector<std::optional<TimelineOffset>>{
327
375
CSSAnimationData::InitialRangeEnd ()};
328
376
329
- if (range_start_list. size () != range_end_list. size ()) {
330
- return nullptr ;
331
- }
377
+ return AnimationRangeCSSValueFromComputedStyle (style, range_start_list,
378
+ range_end_list) ;
379
+ }
332
380
333
- TimelineOffset default_start (TimelineOffset::NamedRange::kNone ,
334
- Length::Percent (0 ));
335
- TimelineOffset default_end (TimelineOffset::NamedRange::kNone ,
336
- Length::Percent (100 ));
381
+ bool AnimationTriggerRange::ParseShorthand (
382
+ bool important,
383
+ CSSParserTokenStream& stream,
384
+ const CSSParserContext& context,
385
+ const CSSParserLocalContext& local_context,
386
+ HeapVector<CSSPropertyValue, 64 >& properties) const {
387
+ const StylePropertyShorthand shorthand = animationTriggerRangeShorthand ();
388
+ DCHECK_EQ (2u , shorthand.length ());
389
+ DCHECK_EQ (&GetCSSPropertyAnimationTriggerRangeStart (),
390
+ shorthand.properties ()[0 ]);
391
+ DCHECK_EQ (&GetCSSPropertyAnimationTriggerRangeEnd (),
392
+ shorthand.properties ()[1 ]);
393
+ return ParseAnimationRangeShorthand (
394
+ shorthand, CSSPropertyID::kAnimationTriggerRangeStart ,
395
+ CSSPropertyID::kAnimationTriggerRangeEnd , important, stream, context,
396
+ properties);
397
+ }
337
398
338
- auto * outer_list = CSSValueList::CreateCommaSeparated ();
399
+ const CSSValue* AnimationTriggerRange::CSSValueFromComputedStyleInternal (
400
+ const ComputedStyle& style,
401
+ const LayoutObject*,
402
+ bool allow_visited_style,
403
+ CSSValuePhase value_phase) const {
404
+ const Vector<std::optional<TimelineOffset>>& range_start_list =
405
+ style.Animations () ? style.Animations ()->TriggerRangeStartList ()
406
+ : Vector<std::optional<TimelineOffset>>{
407
+ CSSAnimationData::InitialTriggerRangeStart ()};
408
+ const Vector<std::optional<TimelineOffset>>& range_end_list =
409
+ style.Animations () ? style.Animations ()->TriggerRangeEndList ()
410
+ : Vector<std::optional<TimelineOffset>>{
411
+ CSSAnimationData::InitialTriggerRangeEnd ()};
339
412
340
- for ( wtf_size_t i = 0 ; i < range_start_list. size (); ++i) {
341
- const std::optional<TimelineOffset>& start = range_start_list[i] ;
342
- const std::optional<TimelineOffset>& end = range_end_list[i];
413
+ return AnimationRangeCSSValueFromComputedStyle (style, range_start_list,
414
+ range_end_list) ;
415
+ }
343
416
344
- auto * inner_list = CSSValueList::CreateSpaceSeparated ();
345
- inner_list->Append (
346
- *ComputedStyleUtils::ValueForAnimationRangeStart (start, style));
417
+ bool AnimationTriggerExitRange::ParseShorthand (
418
+ bool important,
419
+ CSSParserTokenStream& stream,
420
+ const CSSParserContext& context,
421
+ const CSSParserLocalContext& local_context,
422
+ HeapVector<CSSPropertyValue, 64 >& properties) const {
423
+ const StylePropertyShorthand shorthand = animationTriggerExitRangeShorthand ();
424
+ DCHECK_EQ (2u , shorthand.length ());
425
+ DCHECK_EQ (&GetCSSPropertyAnimationTriggerExitRangeStart (),
426
+ shorthand.properties ()[0 ]);
427
+ DCHECK_EQ (&GetCSSPropertyAnimationTriggerExitRangeEnd (),
428
+ shorthand.properties ()[1 ]);
429
+ return ParseAnimationRangeShorthand (
430
+ shorthand, CSSPropertyID::kAnimationTriggerExitRangeStart ,
431
+ CSSPropertyID::kAnimationTriggerExitRangeEnd , important, stream, context,
432
+ properties);
433
+ }
347
434
348
- // The form "name X name 100%" must contract to "name X".
349
- //
350
- // https://github.com/w3c/csswg-drafts/issues/8438
351
- TimelineOffset omittable_end (start.value_or (default_start).name ,
352
- Length::Percent (100 ));
353
- if (end.value_or (default_end) != omittable_end) {
354
- inner_list->Append (
355
5024
code>
- *ComputedStyleUtils::ValueForAnimationRangeEnd (end, style));
356
- }
357
- outer_list->Append (*inner_list);
358
- }
435
+ const CSSValue* AnimationTriggerExitRange::CSSValueFromComputedStyleInternal (
436
+ const ComputedStyle& style,
437
+ const LayoutObject*,
438
+ bool allow_visited_style,
439
+ CSSValuePhase value_phase) const {
440
+ const Vector<std::optional<TimelineOffset>>& range_start_list =
441
+ style.Animations ()
442
+ ? style.Animations ()->TriggerExitRangeStartList ()
443
+ : Vector<std::optional<TimelineOffset>>{
444
+ CSSAnimationData::InitialTriggerExitRangeStart ()};
445
+ const Vector<std::optional<TimelineOffset>>& range_end_list =
446
+ style.Animations () ? style.Animations ()->TriggerExitRangeEndList ()
447
+ : Vector<std::optional<TimelineOffset>>{
448
+ CSSAnimationData::InitialTriggerExitRangeEnd ()};
359
449
360
- return outer_list;
450
+ return AnimationRangeCSSValueFromComputedStyle (style, range_start_list,
451
+ range_end_list);
361
452
}
362
453
363
454
bool Background::ParseShorthand (
0 commit comments