tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

list-interpolation.html (5494B)


      1 <!doctype html>
      2 <html>
      3 <head>
      4 <meta charset="utf-8">
      5 <title>Transform list interpolation</title>
      6 <link rel="help" href="https://drafts.csswg.org/css-transforms-1/#interpolation-of-transforms">
      7 <meta name="assert" content="Interpolation of transform function lists is performed as follows">
      8 <script src="/resources/testharness.js"></script>
      9 <script src="/resources/testharnessreport.js"></script>
     10 <script src="/css/support/interpolation-testcommon.js"></script>
     11 </head>
     12 <body>
     13 <script>
     14 test_interpolation(
     15  {
     16    property: 'transform',
     17    from: 'none',
     18    to: 'none',
     19  },
     20  [{ at: 0.25, expect: 'none' }],
     21  'none -> none'
     22 );
     23 
     24 test_interpolation(
     25  {
     26    property: 'transform',
     27    from: 'none',
     28    to: 'translate(200px) rotate(720deg)',
     29  },
     30  [{ at: 0.25, expect: 'translate(50px) rotate(180deg)' }],
     31  'none -> something'
     32 );
     33 
     34 test_interpolation(
     35  {
     36    property: 'transform',
     37    from: 'translate(200px) rotate(720deg)',
     38    to: 'none',
     39  },
     40  [{ at: 0.25, expect: 'translate(150px) rotate(540deg)' }],
     41  'something -> none'
     42 );
     43 
     44 test_interpolation(
     45  {
     46    property: 'transform',
     47    from: 'translate(100px)',
     48    to: 'translate(200px) rotate(720deg)',
     49  },
     50  [{ at: 0.25, expect: 'translate(125px) rotate(180deg)' }],
     51  'Mismatched lengths (from is shorter), common part matches'
     52 );
     53 
     54 test_interpolation(
     55  {
     56    property: 'transform',
     57    from: 'translate(100px) rotate(720deg)',
     58    to: 'translate(200px)',
     59  },
     60  [{ at: 0.25, expect: 'translate(125px) rotate(540deg)' }],
     61  'Mismatched lengths (to is shorter), common part matches'
     62 );
     63 
     64 test_interpolation(
     65  {
     66    property: 'transform',
     67    from: 'scale(2) rotate(360deg) translate(100px) matrix(1, 0, 0, 1, 100, 0) skew(0deg)',
     68    to: 'scale(3) rotate(1080deg) translate(200px) matrix(1, 0, 0, 1, 0, 200) skew(720deg)',
     69  },
     70  [
     71    {
     72      at: 0.25,
     73      expect: 'scale(2.25) rotate(540deg) translate(125px) matrix(1, 0, 0, 1, 75, 50) skew(180deg)',
     74    },
     75  ],
     76  'Perfect match'
     77 );
     78 
     79 test_interpolation(
     80  {
     81    property: 'transform',
     82    from: 'translateX(100px) scaleX(3) translate(500px) scale(2)',
     83    to: 'translateY(200px) scale(5) translateX(100px) scaleY(3)',
     84  },
     85  [{ at: 0.25, expect: 'translate(75px, 50px) scale(3.5, 2) translate(400px, 0px) scale(1.75, 2.25)' }],
     86  'Matches on primitives'
     87 );
     88 
     89 test_interpolation(
     90  {
     91    property: 'transform',
     92    from: 'rotateX(90deg) translateX(100px)',
     93    to: 'rotate3d(50, 0, 0, 180deg) translateY(200px)',
     94  },
     95  [{ at: 0.25, expect: 'rotateX(112.5deg) translate(75px, 50px)' }],
     96  'Match on rotation vector'
     97 );
     98 
     99 test_interpolation(
    100  {
    101    property: 'transform',
    102    from: 'rotateX(90deg) translateX(100px)',
    103    to: 'rotateY(0deg) translateY(200px)',
    104  },
    105  [{ at: 0.25, expect: 'rotateX(67.5deg) translate(75px, 50px)' }],
    106  'Match on rotation due to 0deg angle'
    107 );
    108 
    109 test_interpolation(
    110  {
    111    property: 'transform',
    112    from: 'rotate3d(1, 1, 1, -60deg) translateX(100px)',
    113    to: 'rotate3d(2, 2, 2, 60deg) translateY(200px)',
    114  }, [{ at: 0.25, expect: 'rotate3d(1, 1, 1, -30deg) translate(75px, 50px)' }],
    115  'Match on rotation using collinear rotation axes'
    116 );
    117 
    118 test_interpolation(
    119  {
    120    property: 'transform',
    121    from: 'rotate3d(1, 0, 0, 360deg) translateX(100px)',
    122    to: 'rotate3d(0, 1, 0, -720deg) translateY(200px)',
    123  }, [{ at: 0.25, expect: 'rotate3d(0, 0, 1, 0deg) translate(75px, 50px)' }],
    124  'Match on rotation with spherical interpolation'
    125 );
    126 
    127 test_interpolation(
    128  {
    129    property: 'transform',
    130    from: 'rotate(0deg) translate(100px)',
    131    to: 'rotate(720deg) scale(2) translate(200px)',
    132  },
    133  [{ at: 0.25, expect: 'rotate(180deg) matrix(1.25, 0, 0, 1.25, 175, 0)' }],
    134  'Common prefix'
    135 );
    136 
    137 test_interpolation(
    138  {
    139    property: 'transform',
    140    from: 'scale(2) rotate(0deg) translate(100px)',
    141    to: 'rotate(720deg) scale(2) translate(200px)',
    142  },
    143  [{ at: 0.25, expect: 'matrix(2, 0, 0, 2, 250, 0)' }],
    144  'Complete mismatch (except length)'
    145 );
    146 
    147 test_interpolation(
    148  {
    149    property: 'transform',
    150    from: 'scale(2) rotate(0deg)',
    151    to: 'rotate(720deg) scale(2) translate(200px)',
    152  },
    153  [{ at: 0.25, expect: 'matrix(2, 0, 0, 2, 100, 0)' }],
    154  'Complete mismatch including length'
    155 );
    156 
    157 test_interpolation(
    158  {
    159    property: 'transform',
    160    from: 'rotate(0deg) scaleX(1)',
    161    to: 'rotate(720deg) translateX(0px) scaleX(2)'
    162  },
    163  [{at: 0.25, expect: 'rotate(180deg) matrix(1.25, 0, 0, 1, 0, 0)'}],
    164  'Mismatched lengths (from is shorter), partial match'
    165 );
    166 
    167 test_interpolation(
    168  {
    169    property: 'transform',
    170    from: 'rotate(720deg) translateX(0px) scaleX(2)',
    171    to: 'rotate(0deg) scaleX(1)'
    172  },
    173  [{at: 0.25, expect: 'rotate(540deg) matrix(1.75, 0, 0, 1, 0, 0)'}],
    174  'Mismatched lengths (to is shorter), partial match'
    175 );
    176 
    177 test_interpolation(
    178  {
    179    property: 'transform',
    180    from: 'scaleX(-3) scaleY(2)',
    181    to: 'scaleY(-3) translateX(0px) scaleX(2)'
    182  },
    183  [{at: 0.25, expect: 'scale(-2, 0) matrix(1.25, 0, 0, 1.75, 0, 0)'}],
    184  'Mismatched lengths (from is shorter), partial match on primitive'
    185 );
    186 
    187 test_interpolation(
    188  {
    189    property: 'transform',
    190    from: 'scaleY(-3) translateX(0px) scaleX(2)',
    191    to: 'scaleX(-3) scaleY(2)'
    192  },
    193  [{at: 0.25, expect: 'scale(0, -2) matrix(1.75, 0, 0, 1.25, 0, 0)'}],
    194  'Mismatched lengths (to is shorter), partial match on primitive'
    195 );
    196 
    197 test_interpolation(
    198  {
    199    property: 'transform',
    200    from: 'scaleY(-3) translateX(0px)',
    201    to: 'scaleX(-3) scaleY(2)'
    202  },
    203  [{at: 0.25, expect: 'scale(0, -2) matrix(1, 0, 0, 1.25, 0, 0)'}],
    204  'Common prefix on primitive'
    205 );
    206 </script>
    207 </body>
    208 </html>