File: offset-path-coord-box-interpolation.html

package info (click to toggle)
firefox 147.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,683,320 kB
  • sloc: cpp: 7,607,359; javascript: 6,533,295; ansic: 3,775,223; python: 1,415,500; xml: 634,561; asm: 438,949; java: 186,241; sh: 62,752; makefile: 18,079; objc: 13,092; perl: 12,808; yacc: 4,583; cs: 3,846; pascal: 3,448; lex: 1,720; ruby: 1,003; php: 436; lisp: 258; awk: 247; sql: 66; sed: 54; csh: 10; exp: 6
file content (102 lines) | stat: -rw-r--r-- 4,395 bytes parent folder | download | duplicates (2)
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
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Motion Path: offset-path coord-box interpolation with allow-discrete</title>
<link rel="help" href="https://drafts.fxtf.org/motion-1/#offset-path-property">
<link rel="help" href="https://drafts.csswg.org/css-shapes-2/#shape-function">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/interpolation-testcommon.js"></script>

<body>
  <script>
    // Same shape(), different coord-box: should switch discretely at 0.5 (no interpolation of shape params)
    test_interpolation({
      property: 'offset-path',
      behavior: 'allow-discrete',
      from: 'shape(from 0px 0px, line to 10px 10px) border-box',
      to: 'shape(from 1px 1px, line to 20px 20px) content-box',
    }, [
      { at: -0.1, expect: 'shape(from 0px 0px, line to 10px 10px)' },
      { at: 0, expect: 'shape(from 0px 0px, line to 10px 10px)' },
      { at: 0.4, expect: 'shape(from 0px 0px, line to 10px 10px)' },
      { at: 0.5, expect: 'shape(from 1px 1px, line to 20px 20px) content-box' },
      { at: 1, expect: 'shape(from 1px 1px, line to 20px 20px) content-box' },
      { at: 1.5, expect: 'shape(from 1px 1px, line to 20px 20px) content-box' },
    ]);

    // Omitted coord-box defaults to border-box.
    test_interpolation({
      property: 'offset-path',
      behavior: 'allow-discrete',
      from: 'shape(from 0px 0px, line to 10px 10px)', // defaults to border-box
      to: 'shape(from 0px 0px, line to 20px 20px) padding-box',
    }, [
      { at: -0.1, expect: 'shape(from 0px 0px, line to 10px 10px)' },
      { at: 0, expect: 'shape(from 0px 0px, line to 10px 10px)' },
      { at: 0.4, expect: 'shape(from 0px 0px, line to 10px 10px)' },
      { at: 0.5, expect: 'shape(from 0px 0px, line to 20px 20px) padding-box' },
      { at: 1, expect: 'shape(from 0px 0px, line to 20px 20px) padding-box' },
      { at: 1.5, expect: 'shape(from 0px 0px, line to 20px 20px) padding-box' },
    ]);

    // Same shape(), same coord-box.
    test_interpolation({
      property: 'offset-path',
      behavior: 'allow-discrete',
      from: 'shape(from 0px 0px, line to 10px 10px) view-box',
      to: 'shape(from 10px 10px, line to 20px 20px) view-box',
    }, [
      { at: -0.1, expect: 'shape(from -1px -1px, line to 9px 9px) view-box' },
      { at: 0, expect: 'shape(from 0px 0px, line to 10px 10px) view-box' },
      { at: 0.4, expect: 'shape(from 4px 4px, line to 14px 14px) view-box' },
      { at: 0.5, expect: 'shape(from 5px 5px, line to 15px 15px) view-box' },
      { at: 1, expect: 'shape(from 10px 10px, line to 20px 20px) view-box' },
      { at: 1.5, expect: 'shape(from 15px 15px, line to 25px 25px) view-box' },
    ]);

    // circle(), different coord-box should switch discretely.
    test_interpolation({
      property: 'offset-path',
      behavior: 'allow-discrete',
      from: 'circle(10px) border-box',
      to: 'circle(30px) content-box',
    }, [
      { at: -0.1, expect: 'circle(10px)' },
      { at: 0, expect: 'circle(10px)' },
      { at: 0.4, expect: 'circle(10px)' },
      { at: 0.5, expect: 'circle(30px) content-box' },
      { at: 1, expect: 'circle(30px) content-box' },
      { at: 1.5, expect: 'circle(30px) content-box' },
    ]);

    // circle(), omitted coord-box defaults to border-box.
    test_interpolation({
      property: 'offset-path',
      behavior: 'allow-discrete',
      from: 'circle(20px)',
      to: 'circle(20px) padding-box',
    }, [
      { at: -0.1, expect: 'circle(20px)' },
      { at: 0, expect: 'circle(20px)' },
      { at: 0.4, expect: 'circle(20px)' },
      { at: 0.5, expect: 'circle(20px) padding-box' },
      { at: 1, expect: 'circle(20px) padding-box' },
      { at: 1.5, expect: 'circle(20px) padding-box' },
    ]);

    // circle(), same coord-box should interpolate radius smoothly.
    test_interpolation({
      property: 'offset-path',
      behavior: 'allow-discrete',
      from: 'circle(10px) view-box',
      to: 'circle(30px) view-box',
    }, [
      { at: -0.1, expect: 'circle(8px) view-box' },
      { at: 0, expect: 'circle(10px) view-box' },
      { at: 0.4, expect: 'circle(18px) view-box' },
      { at: 0.5, expect: 'circle(20px) view-box' },
      { at: 1, expect: 'circle(30px) view-box' },
      { at: 1.5, expect: 'circle(40px) view-box' },
    ]);
  </script>
</body>