tor-browser

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

offset-path-interpolation-006.html (7487B)


      1 <!DOCTYPE html>
      2 <html>
      3  <head>
      4    <meta charset="utf-8">
      5    <title>offset-distance basic-shape interpolation</title>
      6    <link rel="author" title="Daniil Sakhapov" href="mailto:sakhapov@chromium.org">
      7    <link rel="help" href="https://drafts.fxtf.org/motion/#valdef-offset-path-basic-shape">
      8    <meta name="assert" content="offset-path basic shape supports animation.">
      9    <script src="/resources/testharness.js"></script>
     10    <script src="/resources/testharnessreport.js"></script>
     11    <script src="/css/support/interpolation-testcommon.js"></script>
     12  </head>
     13  <style>
     14    .parent {
     15      offset-path: ellipse(10% 10% at 50% 50%);
     16    }
     17    .target {
     18      offset-path: circle(10px);
     19    }
     20  </style>
     21  <body>
     22    <script>
     23      'use strict';
     24 
     25      test_no_interpolation({
     26        property: 'offset-path',
     27        from: "circle(10px)",
     28        to: "inset(20px)",
     29      });
     30 
     31      test_no_interpolation({
     32        property: 'offset-path',
     33        from: "ellipse(at center)",
     34        to: "none",
     35      });
     36 
     37      // Neutral keyframes use the inline style.
     38      test_interpolation({
     39        property: 'offset-path',
     40        from: neutralKeyframe,
     41        to: 'circle(20px)',
     42      }, [
     43        {at: -0.3, expect: 'circle(7px)'},
     44        {at: 0, expect: 'circle(10px)'},
     45        {at: 0.3, expect: 'circle(13px)'},
     46        {at: 0.6, expect: 'circle(16px)'},
     47        {at: 1, expect: 'circle(20px)'},
     48        {at: 1.5, expect: 'circle(25px)'},
     49      ]);
     50 
     51      // No interpolation to an ellipse from the initial value 'none'.
     52      test_no_interpolation({
     53        property: 'offset-path',
     54        from: 'initial',
     55        to: 'ellipse()',
     56      });
     57 
     58      // 'inherit' keyframes use the parent style.
     59      test_interpolation({
     60        property: 'offset-path',
     61        from: 'inherit',
     62        to: 'ellipse(40% 50% at 25% 25%)',
     63      }, [
     64        {at: -0.3, expect: 'ellipse(1% 0% at 57.5% 57.5%)'},
     65        {at: 0, expect: 'ellipse(10% 10% at 50% 50%)'},
     66        {at: 0.3, expect: 'ellipse(19% 22% at 42.5% 42.5%)'},
     67        {at: 0.6, expect: 'ellipse(28% 34% at 35% 35%)'},
     68        {at: 1, expect: 'ellipse(40% 50% at 25% 25%)'},
     69        {at: 1.5, expect: 'ellipse(55% 70% at 12.5% 12.5%)'},
     70      ]);
     71 
     72      // No interpolation to an inset from the initial value 'none'.
     73      test_no_interpolation({
     74        property: 'offset-path',
     75        from: 'unset',
     76        to: 'inset(10%)',
     77      });
     78 
     79      // No interpolation to a rect from the initial value 'none'.
     80      test_no_interpolation({
     81        property: 'offset-path',
     82        from: 'none',
     83        to: 'rect(10px 10px 10px 10px)',
     84      });
     85 
     86      // Interpolation between shapes.
     87      test_interpolation({
     88        property: 'offset-path',
     89        from: 'inset(10px)',
     90        to: 'inset(20px round 50%)'
     91      }, [
     92        {at: -1, expect: 'inset(0px round 0%)'},
     93        {at: 0, expect: 'inset(10px round 0%)'},
     94        {at: 0.125, expect: 'inset(11.25px round 6.25%)'},
     95        {at: 0.875, expect: 'inset(18.75px round 43.75%)'},
     96        {at: 1, expect: 'inset(20px round 50%)'},
     97        {at: 2, expect: 'inset(30px round 100%)'},
     98      ]);
     99 
    100      test_interpolation({
    101        property: 'offset-path',
    102        from: 'xywh(5px 5px 150% 150%)',
    103        to: 'xywh(10px 10px 100% 100%)'
    104      }, [
    105        {at: -1, expect: 'xywh(0px 0px 200% 200%)'},
    106        {at: 0, expect: 'xywh(5px 5px 150% 150%)'},
    107        {at: 0.125, expect: 'xywh(5.63px 5.63px 143.75% 143.75% )'},
    108        {at: 0.875, expect: 'xywh(9.38px 9.38px 106.25% 106.25%)'},
    109        {at: 1, expect: 'xywh(10px 10px 100% 100%)'},
    110        {at: 2, expect: 'xywh(15px 15px 50% 50%)'},
    111      ]);
    112 
    113      test_interpolation({
    114        property: 'offset-path',
    115        from: 'rect(10px 100px 50% 10%)',
    116        to: 'rect(50px 200px 90% 50%)'
    117      }, [
    118        {at: -1, expect: 'rect(-30px 0px 10% -30%)'},
    119        {at: 0, expect: 'rect(10px 100px 50% 10%)'},
    120        {at: 0.125, expect: 'rect(15px 112.5px 55% 15%)'},
    121        {at: 0.875, expect: 'rect(45px 187.5px 85% 45%)'},
    122        {at: 1, expect: 'rect(50px 200px 90% 50%)'},
    123        {at: 2, expect: 'rect(90px 300px 130% 90%)'},
    124      ]);
    125 
    126      test_interpolation({
    127        property: 'offset-path',
    128        from: 'rect(auto auto auto auto)',
    129        to: 'rect(80% 20% 20% 80%)'
    130      }, [
    131        {at: -1, expect: 'inset(-80%)'},
    132        {at: 0, expect: 'inset(0%)'},
    133        {at: 0.125, expect: 'inset(10%)'},
    134        {at: 0.875, expect: 'inset(70%)'},
    135        {at: 1, expect: 'inset(80%)'},
    136        {at: 2, expect: 'inset(160%)'},
    137      ]);
    138 
    139      // All <basic-shape-rect>s compute to the equivalent inset() function, so
    140      // they are interpolatable.
    141      // https://drafts.csswg.org/css-shapes-1/#basic-shape-computed-values
    142      // https://github.com/w3c/csswg-drafts/issues/9053
    143      test_interpolation({
    144        property: 'offset-path',
    145        // The equivalent function is
    146        // "inset(5px calc(100% - 210px) calc(100% - 105px) 10px)".
    147        from: 'xywh(10px 10px 200px 100px)',
    148        to: 'inset(50px)'
    149      }, [
    150        {at: -1, expect: 'inset(-30px calc(200% - 470px) calc(200% - 270px) -30px)'},
    151        {at: 0, expect: 'inset(10px calc(100% - 210px) calc(100% - 110px) 10px)'},
    152        {at: 0.125, expect: 'inset(15px calc(87.5% - 177.5px) calc(87.5% - 90px) 15px)'},
    153        {at: 0.875, expect: 'inset(45px calc(12.5% + 17.5px) calc(12.5% + 30px) 45px)'},
    154        {at: 1, expect: 'inset(50px calc(0% + 50px) calc(0% + 50px) 50px)'},
    155        {at: 2, expect: 'inset(90px calc(-100% + 310px) calc(-100% + 210px) 90px)'},
    156      ]);
    157 
    158      test_interpolation({
    159        property: 'offset-path',
    160        from: 'inset(10px)',
    161        // inset(50px calc(100% - 70px) 20% 20%).
    162        to: 'rect(50px 70px 80% 20%)',
    163      }, [
    164        {at: -1, expect: 'inset(-30px calc(-100% + 90px) calc(-20% + 20px) calc(-20% + 20px)'},
    165        {at: 0, expect: 'inset(10px calc(0% + 10px) calc(0% + 10px))'},
    166        {at: 0.125, expect: 'inset(15px 12.5% calc(2.5% + 8.75px) calc(2.5% + 8.75px))'},
    167        {at: 0.875, expect: 'inset(45px calc(87.5% - 60px) calc(17.5% + 1.25px) calc(17.5% + 1.25px))'},
    168        {at: 1, expect: 'inset(50px calc(100% - 70px) 20% 20%)'},
    169        {at: 2, expect: 'inset(90px calc(200% - 150px) calc(40% - 10px) calc(40% - 10px))'},
    170      ]);
    171 
    172      test_interpolation({
    173        property: 'clip-path',
    174        // inset(10% calc(100% - 100px) 50% 0px round 20px).
    175        from: 'xywh(0px 10% 100px 40% round 20px)',
    176        // inset(20% 50% calc(100% - 200px) 20px).
    177        to: 'rect(20% 50% 200px 20px)',
    178      }, [
    179        {at: -1, expect: 'inset(0% calc(150% - 200px) calc(0% + 200px) -20px round 40px'},
    180        {at: 0, expect: 'inset(10% calc(100% - 100px) 50% 0px round 20px)'},
    181        {at: 0.125, expect: 'inset(11.25% calc(93.75% - 87.5px) calc(56.25% - 25px) 2.5px round 17.5px)'},
    182        {at: 0.875, expect: 'inset(18.75% calc(56.25% - 12.5px) calc(93.75% - 175px) 17.5px round 2.5px)'},
    183        {at: 1, expect: 'inset(20% 50% calc(100% - 200px) 20px)'},
    184        {at: 2, expect: 'inset(30% calc(0% + 100px) calc(150% - 400px) 40px)'},
    185      ]);
    186 
    187      // No interpolation between different radius keywords.
    188      test_no_interpolation({
    189        property: 'offset-path',
    190        from: 'circle(farthest-side)',
    191        to: 'circle(closest-side)'
    192      });
    193      test_no_interpolation({
    194        property: 'offset-path',
    195        from: 'ellipse(closest-side farthest-side)',
    196        to: 'ellipse(closest-side closest-side)'
    197      });
    198    </script>
    199  </body>
    200 </html>