Skip to content

Commit

Permalink
Implement parsing for animation-trigger-range-*
Browse files Browse the repository at this point in the history
The spec is currently a work-in-progress[1] but this comment[2]
describes the API.

[1] w3c/csswg-drafts#10128
[2] w3c/csswg-drafts#8942 (comment)

Bug: 390314945
Change-Id: I6ac50730653e70219775895c315f91f771ea7c13
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6182723
Commit-Queue: David Awogbemila <awogbemila@chromium.org>
Reviewed-by: Anders Hartvoll Ruud <andruud@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1409620}
  • Loading branch information
David Awogbemila authored and chromium-wpt-export-bot committed Jan 22, 2025
1 parent 625fea2 commit 78c349f
Show file tree
Hide file tree
Showing 12 changed files with 356 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!DOCTYPE html>
<!-- TODO(crbug.com/390314945): Replace with spec link when the spec lands. -->
<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/8942 ">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/computed-testcommon.js"></script>
<div id="target" style="font-size:10px;"></div>
<script>
test_computed_value("animation-trigger-exit-range-end", "initial", "normal");
test_computed_value("animation-trigger-exit-range-end", "normal");
test_computed_value("animation-trigger-exit-range-end", "cover 0%");
test_computed_value("animation-trigger-exit-range-end", "cover 100%", "cover");
test_computed_value("animation-trigger-exit-range-end", "COVER 0%", "cover 0%");
test_computed_value("animation-trigger-exit-range-end", "COVER 100%", "cover");
test_computed_value("animation-trigger-exit-range-end", "cover 120%");
test_computed_value("animation-trigger-exit-range-end", "0", "0px");
test_computed_value("animation-trigger-exit-range-end", "120%");
test_computed_value("animation-trigger-exit-range-end", "120px");
test_computed_value("animation-trigger-exit-range-end", "cover 42%");
test_computed_value("animation-trigger-exit-range-end", "cover -42%");
test_computed_value("animation-trigger-exit-range-end", "contain 42%");
test_computed_value("animation-trigger-exit-range-end", "exit 42%");
test_computed_value("animation-trigger-exit-range-end", "exit calc(41% + 1%)", "exit 42%");
test_computed_value("animation-trigger-exit-range-end", "exit-crossing 42%");
test_computed_value("animation-trigger-exit-range-end", "exit 1%, cover 2%, contain 0%");
test_computed_value("animation-trigger-exit-range-end", "exit 1%, cover 2%, contain 100%", "exit 1%, cover 2%, contain");
test_computed_value("animation-trigger-exit-range-end", "entry 42px");
test_computed_value("animation-trigger-exit-range-end", "entry-crossing 42px");

test_computed_value("animation-trigger-exit-range-end", "contain calc(10% + 10px)");
test_computed_value("animation-trigger-exit-range-end", "entry 1em", "entry 10px");
test_computed_value("animation-trigger-exit-range-end", "exit calc(1em + 10px)", "exit 20px");
test_computed_value("animation-trigger-exit-range-end", "cover");
test_computed_value("animation-trigger-exit-range-end", "contain");
test_computed_value("animation-trigger-exit-range-end", "entry");
test_computed_value("animation-trigger-exit-range-end", "exit");
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<!-- TODO(crbug.com/390314945): Replace with spec link when the spec lands. -->
<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/8942">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/parsing-testcommon.js"></script>
<script>
test_invalid_value("animation-trigger-exit-range-end", "infinite");
test_invalid_value("animation-trigger-exit-range-end", "1s 2s");
test_invalid_value("animation-trigger-exit-range-end", "1s / 2s");

test_invalid_value("animation-trigger-exit-range-end", "peek 50%");
test_invalid_value("animation-trigger-exit-range-end", "50% contain");
test_invalid_value("animation-trigger-exit-range-end", "50% cover");
test_invalid_value("animation-trigger-exit-range-end", "50% entry");
test_invalid_value("animation-trigger-exit-range-end", "50% enter");
test_invalid_value("animation-trigger-exit-range-end", "50% exit");
test_invalid_value("animation-trigger-exit-range-end", "contain contain");
test_invalid_value("animation-trigger-exit-range-end", "none");
test_invalid_value("animation-trigger-exit-range-end", "cover 50% enter 50%");
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!DOCTYPE html>
<!-- TODO(crbug.com/390314945): Replace with spec link when the spec lands. -->
<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/8942">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/parsing-testcommon.js"></script>
<script>
// https://drafts.csswg.org/scroll-animations-1/#view-timelines-ranges
test_valid_value("animation-trigger-exit-range-end", "normal");
test_valid_value("animation-trigger-exit-range-end", "cover 0%");
test_valid_value("animation-trigger-exit-range-end", "cover 100%", "cover");
test_valid_value("animation-trigger-exit-range-end", "cover 120%");
test_valid_value("animation-trigger-exit-range-end", "cover 42%");
test_valid_value("animation-trigger-exit-range-end", "0", "0px");
test_valid_value("animation-trigger-exit-range-end", "120%");
test_valid_value("animation-trigger-exit-range-end", "120px");
test_valid_value("animation-trigger-exit-range-end", "cover -42%");
test_valid_value("animation-trigger-exit-range-end", "contain 42%");
test_valid_value("animation-trigger-exit-range-end", "exit 42%");
test_valid_value("animation-trigger-exit-range-end", "exit 1%, cover 2%, contain 0%");
test_valid_value("animation-trigger-exit-range-end", "exit 1%, cover 2%, contain 100%", "exit 1%, cover 2%, contain");
test_valid_value("animation-trigger-exit-range-end", "exit-crossing 42%");
test_valid_value("animation-trigger-exit-range-end", "entry 42px");
test_valid_value("animation-trigger-exit-range-end", "entry-crossing 42px");
test_valid_value("animation-trigger-exit-range-end", "contain calc(10px + 10%)", "contain calc(10% + 10px)");
test_valid_value("animation-trigger-exit-range-end", "entry 1em");
test_valid_value("animation-trigger-exit-range-end", "exit calc(1em + 10px)");
test_valid_value("animation-trigger-exit-range-end", "entry 42%");
test_valid_value("animation-trigger-exit-range-end", "cover");
test_valid_value("animation-trigger-exit-range-end", "contain");
test_valid_value("animation-trigger-exit-range-end", "entry");
test_valid_value("animation-trigger-exit-range-end", "exit");
</script>trigger-
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!DOCTYPE html>
<!-- TODO(crbug.com/390314945): Replace with spec link when the spec lands. -->
<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/8942 ">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/computed-testcommon.js"></script>
<div id="target" style="font-size:10px;"></div>
<script>
test_computed_value("animation-trigger-exit-range-start", "initial", "normal");
test_computed_value("animation-trigger-exit-range-start", "normal");
test_computed_value("animation-trigger-exit-range-start", "cover 0%", "cover");
test_computed_value("animation-trigger-exit-range-start", "cover 100%");
test_computed_value("animation-trigger-exit-range-start", "COVER 0%", "cover");
test_computed_value("animation-trigger-exit-range-start", "COVER 100%", "cover 100%");
test_computed_value("animation-trigger-exit-range-start", "cover 120%");
test_computed_value("animation-trigger-exit-range-start", "cover 42%");
test_computed_value("animation-trigger-exit-range-start", "0", "0px");
test_computed_value("animation-trigger-exit-range-start", "120%");
test_computed_value("animation-trigger-exit-range-start", "120px");
test_computed_value("animation-trigger-exit-range-start", "cover -42%");
test_computed_value("animation-trigger-exit-range-start", "contain 42%");
test_computed_value("animation-trigger-exit-range-start", "exit 42%");
test_computed_value("animation-trigger-exit-range-start", "exit calc(41% + 1%)", "exit 42%");
test_computed_value("animation-trigger-exit-range-start", "exit 1%, cover 2%, contain 0%", "exit 1%, cover 2%, contain");
test_computed_value("animation-trigger-exit-range-start", "exit 1%, cover 2%, contain 100%");
test_computed_value("animation-trigger-exit-range-start", "exit-crossing 42%");
test_computed_value("animation-trigger-exit-range-start", "entry 42px");
test_computed_value("animation-trigger-exit-range-start", "entry-crossing 42px");
test_computed_value("animation-trigger-exit-range-start", "contain calc(10% + 10px)");
test_computed_value("animation-trigger-exit-range-start", "entry 1em", "entry 10px");
test_computed_value("animation-trigger-exit-range-start", "exit calc(1em + 10px)", "exit 20px");
test_computed_value("animation-trigger-exit-range-start", "cover");
test_computed_value("animation-trigger-exit-range-start", "contain");
test_computed_value("animation-trigger-exit-range-start", "entry");
test_computed_value("animation-trigger-exit-range-start", "exit");
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<!-- TODO(crbug.com/390314945): Replace with spec link when the spec lands. -->
<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/8942 ">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/parsing-testcommon.js"></script>
<script>
test_invalid_value("animation-trigger-exit-range-start", "peek 50%");
test_invalid_value("animation-trigger-exit-range-start", "50% contain");
test_invalid_value("animation-trigger-exit-range-start", "50% cover");
test_invalid_value("animation-trigger-exit-range-start", "50% entry");
test_invalid_value("animation-trigger-exit-range-start", "50% enter");
test_invalid_value("animation-trigger-exit-range-start", "50% exit");
test_invalid_value("animation-trigger-exit-range-start", "contain contain");
test_invalid_value("animation-trigger-exit-range-start", "none");
test_invalid_value("animation-trigger-exit-range-start", "cover 50% enter 50%");
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!DOCTYPE html>
<!-- TODO(crbug.com/390314945): Replace with spec link when the spec lands. -->
<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/8942">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/parsing-testcommon.js"></script>
<script>
// https://drafts.csswg.org/scroll-animations-1/#view-timelines-ranges
test_valid_value("animation-trigger-exit-range-start", "normal");
test_valid_value("animation-trigger-exit-range-start", "cover 0%", "cover");
test_valid_value("animation-trigger-exit-range-start", "cover 100%");
test_valid_value("animation-trigger-exit-range-start", "cover 120%");
test_valid_value("animation-trigger-exit-range-start", "cover 42%");
test_valid_value("animation-trigger-exit-range-start", "0", "0px");
test_valid_value("animation-trigger-exit-range-start", "120%");
test_valid_value("animation-trigger-exit-range-start", "120px");
test_valid_value("animation-trigger-exit-range-start", "cover -42%");
test_valid_value("animation-trigger-exit-range-start", "contain 42%");
test_valid_value("animation-trigger-exit-range-start", "exit 42%");
test_valid_value("animation-trigger-exit-range-start", "exit 1%, cover 2%, contain 0%", "exit 1%, cover 2%, contain");
test_valid_value("animation-trigger-exit-range-start", "exit 1%, cover 2%, contain 100%");
test_valid_value("animation-trigger-exit-range-start", "exit-crossing 42%");
test_valid_value("animation-trigger-exit-range-start", "entry 42px");
test_valid_value("animation-trigger-exit-range-start", "entry-crossing 42px");
test_valid_value("animation-trigger-exit-range-start", "contain calc(10px + 10%)", "contain calc(10% + 10px)");
test_valid_value("animation-trigger-exit-range-start", "entry 1em");
test_valid_value("animation-trigger-exit-range-start", "exit calc(1em + 10px)");
test_valid_value("animation-trigger-exit-range-start", "entry 42%");
test_valid_value("animation-trigger-exit-range-start", "cover");
test_valid_value("animation-trigger-exit-range-start", "contain");
test_valid_value("animation-trigger-exit-range-start", "entry");
test_valid_value("animation-trigger-exit-range-start", "exit");
test_valid_value("animation-trigger-exit-range-start", "cover calc(sign(100em - 1px) * 1%)");
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!DOCTYPE html>
<!-- TODO(crbug.com/390314945): Replace with spec link when the spec lands. -->
<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/8942 ">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/computed-testcommon.js"></script>
<div id="target" style="font-size:10px;"></div>
<script>
test_computed_value("animation-trigger-range-end", "initial", "normal");
test_computed_value("animation-trigger-range-end", "normal");
test_computed_value("animation-trigger-range-end", "cover 0%");
test_computed_value("animation-trigger-range-end", "cover 100%", "cover");
test_computed_value("animation-trigger-range-end", "COVER 0%", "cover 0%");
test_computed_value("animation-trigger-range-end", "COVER 100%", "cover");
test_computed_value("animation-trigger-range-end", "cover 120%");
test_computed_value("animation-trigger-range-end", "0", "0px");
test_computed_value("animation-trigger-range-end", "120%");
test_computed_value("animation-trigger-range-end", "120px");
test_computed_value("animation-trigger-range-end", "cover 42%");
test_computed_value("animation-trigger-range-end", "cover -42%");
test_computed_value("animation-trigger-range-end", "contain 42%");
test_computed_value("animation-trigger-range-end", "exit 42%");
test_computed_value("animation-trigger-range-end", "exit calc(41% + 1%)", "exit 42%");
test_computed_value("animation-trigger-range-end", "exit-crossing 42%");
test_computed_value("animation-trigger-range-end", "exit 1%, cover 2%, contain 0%");
test_computed_value("animation-trigger-range-end", "exit 1%, cover 2%, contain 100%", "exit 1%, cover 2%, contain");
test_computed_value("animation-trigger-range-end", "entry 42px");
test_computed_value("animation-trigger-range-end", "entry-crossing 42px");

test_computed_value("animation-trigger-range-end", "contain calc(10% + 10px)");
test_computed_value("animation-trigger-range-end", "entry 1em", "entry 10px");
test_computed_value("animation-trigger-range-end", "exit calc(1em + 10px)", "exit 20px");
test_computed_value("animation-trigger-range-end", "cover");
test_computed_value("animation-trigger-range-end", "contain");
test_computed_value("animation-trigger-range-end", "entry");
test_computed_value("animation-trigger-range-end", "exit");
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<!-- TODO(crbug.com/390314945): Replace with spec link when the spec lands. -->
<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/8942">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/parsing-testcommon.js"></script>
<script>
test_invalid_value("animation-trigger-range-end", "infinite");
test_invalid_value("animation-trigger-range-end", "1s 2s");
test_invalid_value("animation-trigger-range-end", "1s / 2s");

test_invalid_value("animation-trigger-range-end", "peek 50%");
test_invalid_value("animation-trigger-range-end", "50% contain");
test_invalid_value("animation-trigger-range-end", "50% cover");
test_invalid_value("animation-trigger-range-end", "50% entry");
test_invalid_value("animation-trigger-range-end", "50% enter");
test_invalid_value("animation-trigger-range-end", "50% exit");
test_invalid_value("animation-trigger-range-end", "contain contain");
test_invalid_value("animation-trigger-range-end", "none");
test_invalid_value("animation-trigger-range-end", "cover 50% enter 50%");
</script>
33 changes: 33 additions & 0 deletions css/css-animations/parsing/animation-trigger-range-end-valid.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!DOCTYPE html>
<!-- TODO(crbug.com/390314945): Replace with spec link when the spec lands. -->
<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/8942">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/parsing-testcommon.js"></script>
<script>
// https://drafts.csswg.org/scroll-animations-1/#view-timelines-ranges
test_valid_value("animation-trigger-range-end", "normal");
test_valid_value("animation-trigger-range-end", "cover 0%");
test_valid_value("animation-trigger-range-end", "cover 100%", "cover");
test_valid_value("animation-trigger-range-end", "cover 120%");
test_valid_value("animation-trigger-range-end", "cover 42%");
test_valid_value("animation-trigger-range-end", "0", "0px");
test_valid_value("animation-trigger-range-end", "120%");
test_valid_value("animation-trigger-range-end", "120px");
test_valid_value("animation-trigger-range-end", "cover -42%");
test_valid_value("animation-trigger-range-end", "contain 42%");
test_valid_value("animation-trigger-range-end", "exit 42%");
test_valid_value("animation-trigger-range-end", "exit 1%, cover 2%, contain 0%");
test_valid_value("animation-trigger-range-end", "exit 1%, cover 2%, contain 100%", "exit 1%, cover 2%, contain");
test_valid_value("animation-trigger-range-end", "exit-crossing 42%");
test_valid_value("animation-trigger-range-end", "entry 42px");
test_valid_value("animation-trigger-range-end", "entry-crossing 42px");
test_valid_value("animation-trigger-range-end", "contain calc(10px + 10%)", "contain calc(10% + 10px)");
test_valid_value("animation-trigger-range-end", "entry 1em");
test_valid_value("animation-trigger-range-end", "exit calc(1em + 10px)");
test_valid_value("animation-trigger-range-end", "entry 42%");
test_valid_value("animation-trigger-range-end", "cover");
test_valid_value("animation-trigger-range-end", "contain");
test_valid_value("animation-trigger-range-end", "entry");
test_valid_value("animation-trigger-range-end", "exit");
</script>trigger-
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!DOCTYPE html>
<!-- TODO(crbug.com/390314945): Replace with spec link when the spec lands. -->
<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/8942 ">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/computed-testcommon.js"></script>
<div id="target" style="font-size:10px;"></div>
<script>
test_computed_value("animation-trigger-range-start", "initial", "normal");
test_computed_value("animation-trigger-range-start", "normal");
test_computed_value("animation-trigger-range-start", "cover 0%", "cover");
test_computed_value("animation-trigger-range-start", "cover 100%");
test_computed_value("animation-trigger-range-start", "COVER 0%", "cover");
test_computed_value("animation-trigger-range-start", "COVER 100%", "cover 100%");
test_computed_value("animation-trigger-range-start", "cover 120%");
test_computed_value("animation-trigger-range-start", "cover 42%");
test_computed_value("animation-trigger-range-start", "0", "0px");
test_computed_value("animation-trigger-range-start", "120%");
test_computed_value("animation-trigger-range-start", "120px");
test_computed_value("animation-trigger-range-start", "cover -42%");
test_computed_value("animation-trigger-range-start", "contain 42%");
test_computed_value("animation-trigger-range-start", "exit 42%");
test_computed_value("animation-trigger-range-start", "exit calc(41% + 1%)", "exit 42%");
test_computed_value("animation-trigger-range-start", "exit 1%, cover 2%, contain 0%", "exit 1%, cover 2%, contain");
test_computed_value("animation-trigger-range-start", "exit 1%, cover 2%, contain 100%");
test_computed_value("animation-trigger-range-start", "exit-crossing 42%");
test_computed_value("animation-trigger-range-start", "entry 42px");
test_computed_value("animation-trigger-range-start", "entry-crossing 42px");
test_computed_value("animation-trigger-range-start", "contain calc(10% + 10px)");
test_computed_value("animation-trigger-range-start", "entry 1em", "entry 10px");
test_computed_value("animation-trigger-range-start", "exit calc(1em + 10px)", "exit 20px");
test_computed_value("animation-trigger-range-start", "cover");
test_computed_value("animation-trigger-range-start", "contain");
test_computed_value("animation-trigger-range-start", "entry");
test_computed_value("animation-trigger-range-start", "exit");
</script>
Loading

0 comments on commit 78c349f

Please sign in to comment.