interpolate-size-max-width-interpolation.html (2708B)
1 <!DOCTYPE html> 2 <meta charset="UTF-8"> 3 <title>max-width interpolation with interpolate-size: allow-keywords</title> 4 <link rel="help" href="https://drafts.csswg.org/css-sizing-3/#propdef-max-width"> 5 <link rel="help" href="https://drafts.csswg.org/css-values-5/#interpolate-size"> 6 7 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharnessreport.js"></script> 9 <script src="/css/support/interpolation-testcommon.js"></script> 10 11 <style> 12 :root { 13 interpolate-size: allow-keywords; 14 } 15 .parent { 16 max-width: 200px; 17 } 18 .target { 19 width: 175px; 20 height: 10px; 21 max-width: 150px; 22 } 23 .target::before { 24 display: block; 25 content: ""; 26 width: 100px; 27 height: 50px; 28 } 29 </style> 30 31 <body></body> 32 33 <script> 34 35 test_no_interpolation({ 36 property: 'max-width', 37 from: 'initial', 38 to: '20px', 39 }); 40 41 test_no_interpolation({ 42 property: 'max-width', 43 from: 'unset', 44 to: '20px', 45 }); 46 47 test_no_interpolation({ 48 property: 'max-width', 49 from: 'none', 50 to: '20px', 51 }); 52 53 test_no_interpolation({ 54 property: 'max-width', 55 from: 'stretch', 56 to: 'none', 57 }); 58 59 test_interpolation({ 60 property: 'max-width', 61 from: 'fit-content', /* (100px) */ 62 to: '50px', 63 }, [ 64 {at: -0.3, expect: 'calc-size(fit-content, -15px + size * 1.3)'}, 65 {at: 0, expect: 'calc-size(fit-content, 0px + size * 1)'}, 66 {at: 0.3, expect: 'calc-size(fit-content, 15px + size * 0.7)'}, 67 {at: 0.6, expect: 'calc-size(fit-content, 30px + size * 0.4)'}, 68 {at: 1, expect: 'calc-size(fit-content, 50px + size * 0)'}, 69 {at: 1.5, expect: 'calc-size(fit-content, 75px + size * -0.5)'} 70 ]); 71 72 test_no_interpolation({ 73 property: 'max-width', 74 from: 'max-content', 75 to: 'min-content', 76 }); 77 78 test_interpolation({ 79 property: 'max-width', 80 from: 'min-content', /* (100px) */ 81 to: neutralKeyframe, /* 150px */ 82 }, [ 83 {at: -0.3, expect: 'calc-size(min-content, -45px + size * 1.3)'}, 84 {at: 0, expect: 'calc-size(min-content, 0px + size * 1)'}, 85 {at: 0.3, expect: 'calc-size(min-content, 45px + size * 0.7)'}, 86 {at: 0.6, expect: 'calc-size(min-content, 90px + size * 0.4)'}, 87 {at: 1, expect: 'calc-size(min-content, 150px + size * 0)'}, 88 {at: 1.5, expect: 'calc-size(min-content, 225px + size * -0.5)'} 89 ]); 90 91 test_interpolation({ 92 property: 'max-width', 93 from: neutralKeyframe, /* 150px */ 94 to: 'fit-content', /* (100px) */ 95 }, [ 96 {at: -0.3, expect: 'calc-size(fit-content, 195px + size * -0.3)'}, 97 {at: 0, expect: 'calc-size(fit-content, 150px + size * 0)'}, 98 {at: 0.3, expect: 'calc-size(fit-content, 105px + size * 0.3)'}, 99 {at: 0.6, expect: 'calc-size(fit-content, 60px + size * 0.6)'}, 100 {at: 1, expect: 'calc-size(fit-content, 0px + size * 1)'}, 101 {at: 1.5, expect: 'calc-size(fit-content, -75px + size * 1.5)'} 102 ]); 103 104 </script>