tor-browser

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

clip-path-interpolation-xywh-rect.html (5959B)


      1 <!DOCTYPE html>
      2 <meta charset="UTF-8">
      3 <title>clip-path-interpolation for basic-shape-rect, xywh and rect</title>
      4 <link rel="help" href="https://drafts.fxtf.org/css-masking-1/#the-clip-path">
      5 <link rel="help" href="https://drafts.csswg.org/css-shapes-1/#funcdef-basic-shape-xywh">
      6 <link rel="help" href="https://drafts.csswg.org/css-shapes-1/#funcdef-basic-shape-rect">
      7 <meta name="assert" content="clip-path supports animation for xywh() and rect()">
      8 
      9 <script src="/resources/testharness.js"></script>
     10 <script src="/resources/testharnessreport.js"></script>
     11 <script src="/css/support/interpolation-testcommon.js"></script>
     12 
     13 <style>
     14 .parent {
     15  clip-path: inset(10px);
     16  padding: 10px;
     17 }
     18 
     19 .target {
     20  display: inline-block;
     21  width: 100px;
     22  height: 100px;
     23  background-color: black;
     24  clip-path: inset(10px);
     25 }
     26 
     27 .expected {
     28  background-color: green;
     29 }
     30 </style>
     31 <body>
     32 <script>
     33 test_no_interpolation({
     34  property: 'clip-path',
     35  from: 'initial',
     36  to: 'xywh(10px 10px 100px 100px)',
     37 });
     38 
     39 test_no_interpolation({
     40  property: 'clip-path',
     41  from: 'unset',
     42  to: 'xywh(10px 10px 100px 100px)',
     43 });
     44 
     45 test_no_interpolation({
     46  property: 'clip-path',
     47  from: 'initial',
     48  to: 'rect(10px 100px 100px 10px)',
     49 });
     50 
     51 test_no_interpolation({
     52  property: 'clip-path',
     53  from: 'unset',
     54  to: 'rect(10px 100px 100px 10px)',
     55 });
     56 
     57 // Note: it's fine to use "rect()"/"xywh()" in "expect" because we always
     58 // convert it into `inset()` when we compare it with the actual animation value.
     59 test_interpolation({
     60  property: 'clip-path',
     61  from: 'xywh(5px 5px 150% 150%)',
     62  to: 'xywh(10px 10px 100% 100%)'
     63 }, [
     64  {at: -1, expect: 'xywh(0px 0px 200% 200%)'},
     65  {at: 0, expect: 'xywh(5px 5px 150% 150%)'},
     66  {at: 0.125, expect: 'xywh(5.63px 5.63px 143.75% 143.75%)'},
     67  {at: 0.875, expect: 'xywh(9.38px 9.38px 106.25% 106.25%)'},
     68  {at: 1, expect: 'xywh(10px 10px 100% 100%)'},
     69  {at: 2, expect: 'xywh(15px 15px 50% 50%)'},
     70 ]);
     71 
     72 test_interpolation({
     73  property: 'clip-path',
     74  from: 'rect(10px 100px 50% 10%)',
     75  to: 'rect(50px 200px 90% 50%)'
     76 }, [
     77  {at: -1, expect: 'rect(-30px 0px 10% -30%)'},
     78  {at: 0, expect: 'rect(10px 100px 50% 10%)'},
     79  {at: 0.125, expect: 'rect(15px 112.5px 55% 15%)'},
     80  {at: 0.875, expect: 'rect(45px 187.5px 85% 45%)'},
     81  {at: 1, expect: 'rect(50px 200px 90% 50%)'},
     82  {at: 2, expect: 'rect(90px 300px 130% 90%)'},
     83 ]);
     84 
     85 test_interpolation({
     86  property: 'clip-path',
     87  from: 'rect(auto auto auto auto)',
     88  to: 'rect(80% 20% 20% 80%)'
     89 }, [
     90  {at: -1, expect: 'inset(-80%)'},
     91  {at: 0, expect: 'inset(0%)'},
     92  {at: 0.125, expect: 'inset(10%)'},
     93  {at: 0.875, expect: 'inset(70%)'},
     94  {at: 1, expect: 'inset(80%)'},
     95  {at: 2, expect: 'inset(160%)'},
     96 ]);
     97 
     98 // All <basic-shape-rect>s compute to the equivalent inset() function, so they
     99 // interpolatable.
    100 // https://drafts.csswg.org/css-shapes-1/#basic-shape-computed-values
    101 test_interpolation({
    102  property: 'clip-path',
    103  from: neutralKeyframe,
    104  // inset(50px calc(80% - 70px) calc(0% - 50px) 20%).
    105  to: 'xywh(20% 50px 70px 100%)',
    106 }, [
    107  {at: -1, expect: 'inset(-30px calc(-80% + 90px) calc(0% + 70px) calc(-20% + 20px)'},
    108  {at: 0, expect: 'inset(10px calc(0% + 10px) calc(0% + 10px))'},
    109  {at: 0.125, expect: 'inset(15px 10% calc(0% + 2.5px) calc(2.5% + 8.75px))'},
    110  {at: 0.875, expect: 'inset(45px calc(70% - 60px) calc(0% - 42.5px) calc(17.5% + 1.25px))'},
    111  {at: 1, expect: 'inset(50px calc(80% - 70px) calc(0% - 50px) 20%)'},
    112  {at: 2, expect: 'inset(90px calc(160% - 150px) calc(0% - 110px) calc(40% - 10px))'},
    113 ]);
    114 
    115 test_interpolation({
    116  property: 'clip-path',
    117  from: neutralKeyframe,
    118  // inset(50px calc(100% - 70px) 20% 20%).
    119  to: 'rect(50px 70px 80% 20%)',
    120 }, [
    121  {at: -1, expect: 'inset(-30px calc(-100% + 90px) calc(-20% + 20px) calc(-20% + 20px)'},
    122  {at: 0, expect: 'inset(10px calc(0% + 10px) calc(0% + 10px))'},
    123  {at: 0.125, expect: 'inset(15px 12.5% calc(2.5% + 8.75px) calc(2.5% + 8.75px))'},
    124  {at: 0.875, expect: 'inset(45px calc(87.5% - 60px) calc(17.5% + 1.25px) calc(17.5% + 1.25px))'},
    125  {at: 1, expect: 'inset(50px calc(100% - 70px) 20% 20%)'},
    126  {at: 2, expect: 'inset(90px calc(200% - 150px) calc(40% - 10px) calc(40% - 10px))'},
    127 ]);
    128 
    129 test_interpolation({
    130  property: 'clip-path',
    131  from: 'inherit',
    132  to: 'xywh(20% 50px 70px 100%)',
    133 }, [
    134  {at: -1, expect: 'inset(-30px calc(-80% + 90px) calc(0% + 70px) calc(-20% + 20px)'},
    135  {at: 0, expect: 'inset(10px calc(0% + 10px) calc(0% + 10px))'},
    136  {at: 0.125, expect: 'inset(15px 10% calc(0% + 2.5px) calc(2.5% + 8.75px))'},
    137  {at: 0.875, expect: 'inset(45px calc(70% - 60px) calc(0% - 42.5px) calc(17.5% + 1.25px))'},
    138  {at: 1, expect: 'inset(50px calc(80% - 70px) calc(0% - 50px) 20%)'},
    139  {at: 2, expect: 'inset(90px calc(160% - 150px) calc(0% - 110px) calc(40% - 10px))'},
    140 ]);
    141 
    142 test_interpolation({
    143  property: 'clip-path',
    144  from: 'inherit',
    145  to: 'rect(50px 70px 80% 20%)',
    146 }, [
    147  {at: -1, expect: 'inset(-30px calc(-100% + 90px) calc(-20% + 20px) calc(-20% + 20px)'},
    148  {at: 0, expect: 'inset(10px calc(0% + 10px) calc(0% + 10px))'},
    149  {at: 0.125, expect: 'inset(15px 12.5% calc(2.5% + 8.75px) calc(2.5% + 8.75px))'},
    150  {at: 0.875, expect: 'inset(45px calc(87.5% - 60px) calc(17.5% + 1.25px) calc(17.5% + 1.25px))'},
    151  {at: 1, expect: 'inset(50px calc(100% - 70px) 20% 20%)'},
    152  {at: 2, expect: 'inset(90px calc(200% - 150px) calc(40% - 10px) calc(40% - 10px))'},
    153 ]);
    154 
    155 test_interpolation({
    156  property: 'clip-path',
    157  from: 'xywh(0px 10% 100px 40% round 20px)',
    158  to: 'rect(20% 50% 200px 20px)',
    159 }, [
    160  {at: -1, expect: 'inset(0% calc(150% - 200px) calc(0% + 200px) -20px round 40px'},
    161  {at: 0, expect: 'inset(10% calc(100% - 100px) 50% 0px round 20px)'},
    162  {at: 0.125, expect: 'inset(11.25% calc(93.75% - 87.5px) calc(56.25% - 25px) 2.5px round 17.5px)'},
    163  {at: 0.875, expect: 'inset(18.75% calc(56.25% - 12.5px) calc(93.75% - 175px) 17.5px round 2.5px)'},
    164  {at: 1, expect: 'inset(20% 50% calc(100% - 200px) 20px)'},
    165  {at: 2, expect: 'inset(30% calc(0% + 100px) calc(150% - 400px) 40px)'},
    166 ]);
    167 
    168 </script>
    169 </body>