interpolate-size-min-width-interpolation.html (3659B)
1 <!DOCTYPE html> 2 <meta charset="UTF-8"> 3 <title>min-width interpolation with interpolate-size: allow-keywords</title> 4 <link rel="help" href="https://drafts.csswg.org/css-sizing-3/#propdef-min-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 min-width: 30px; 17 } 18 .target { 19 width: 0px; 20 height: 10px; 21 min-width: 10px; 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_interpolation({ 36 property: 'min-width', 37 from: 'initial', 38 to: '20px', 39 }, [ 40 {at: -0.3, expect: 'calc-size(auto, -6px + size * 1.3)'}, 41 {at: 0, expect: 'calc-size(auto, 0px + size * 1)'}, 42 {at: 0.3, expect: 'calc-size(auto, 6px + size * 0.7)'}, 43 {at: 0.6, expect: 'calc-size(auto, 12px + size * 0.4)'}, 44 {at: 1, expect: 'calc-size(auto, 20px + size * 0)'}, 45 {at: 1.5, expect: 'calc-size(auto, 30px + size * -0.5)'} 46 ]); 47 48 test_interpolation({ 49 property: 'min-width', 50 from: 'unset', 51 to: '20px', 52 }, [ 53 {at: -0.3, expect: 'calc-size(auto, -6px + size * 1.3)'}, 54 {at: 0, expect: 'calc-size(auto, 0px + size * 1)'}, 55 {at: 0.3, expect: 'calc-size(auto, 6px + size * 0.7)'}, 56 {at: 0.6, expect: 'calc-size(auto, 12px + size * 0.4)'}, 57 {at: 1, expect: 'calc-size(auto, 20px + size * 0)'}, 58 {at: 1.5, expect: 'calc-size(auto, 30px + size * -0.5)'} 59 ]); 60 61 test_interpolation({ 62 property: 'min-width', 63 from: 'auto', 64 to: '20px', 65 }, [ 66 {at: -0.3, expect: 'calc-size(auto, -6px + size * 1.3)'}, 67 {at: 0, expect: 'calc-size(auto, 0px + size * 1)'}, 68 {at: 0.3, expect: 'calc-size(auto, 6px + size * 0.7)'}, 69 {at: 0.6, expect: 'calc-size(auto, 12px + size * 0.4)'}, 70 {at: 1, expect: 'calc-size(auto, 20px + size * 0)'}, 71 {at: 1.5, expect: 'calc-size(auto, 30px + size * -0.5)'} 72 ]); 73 74 test_interpolation({ 75 property: 'min-width', 76 from: '0px', 77 to: 'stretch', 78 }, [ 79 {at: -0.3, expect: 'calc-size(stretch, 0px + size * -0.3)'}, 80 {at: 0, expect: 'calc-size(stretch, 0px + size * 0)'}, 81 {at: 0.3, expect: 'calc-size(stretch, 0px + size * 0.3)'}, 82 {at: 0.6, expect: 'calc-size(stretch, 0px + size * 0.6)'}, 83 {at: 1, expect: 'calc-size(stretch, 0px + size * 1)'}, 84 {at: 1.5, expect: 'calc-size(stretch, 0px + size * 1.5)'} 85 ]); 86 87 test_no_interpolation({ 88 property: 'min-width', 89 from: 'min-content', 90 to: 'fit-content', 91 }); 92 93 test_no_interpolation({ 94 property: 'min-width', 95 from: 'auto', 96 to: 'max-content', 97 }); 98 99 test_interpolation({ 100 property: 'min-width', 101 from: 'fit-content', 102 to: neutralKeyframe, /* 10px */ 103 }, [ 104 {at: -0.3, expect: 'calc-size(fit-content, -3px + size * 1.3)'}, 105 {at: 0, expect: 'calc-size(fit-content, 0px + size * 1)'}, 106 {at: 0.3, expect: 'calc-size(fit-content, 3px + size * 0.7)'}, 107 {at: 0.6, expect: 'calc-size(fit-content, 6px + size * 0.4)'}, 108 {at: 1, expect: 'calc-size(fit-content, 10px + size * 0)'}, 109 {at: 1.5, expect: 'calc-size(fit-content, 15px + size * -0.5)'} 110 ]); 111 112 test_interpolation({ 113 property: 'min-width', 114 from: neutralKeyframe, /* 10px */ 115 to: 'max-content', 116 }, [ 117 {at: -0.3, expect: 'calc-size(max-content, 13px + size * -0.3)'}, 118 {at: 0, expect: 'calc-size(max-content, 10px + size * 0)'}, 119 {at: 0.3, expect: 'calc-size(max-content, 7px + size * 0.3)'}, 120 {at: 0.6, expect: 'calc-size(max-content, 4px + size * 0.6)'}, 121 {at: 1, expect: 'calc-size(max-content, 0px + size * 1)'}, 122 {at: 1.5, expect: 'calc-size(max-content, -5px + size * 1.5)'} 123 ]); 124 125 </script>