OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <meta charset="UTF-8"> | 2 <meta charset="UTF-8"> |
3 <style> | 3 <style> |
4 div.wrapper { | 4 .parent { |
5 border: 10px solid black; | 5 -webkit-mask-image: url(../resources/blue-20.png); |
6 width: 100px; | |
7 height: 100px; | |
8 display: inline-block; | |
9 margin-bottom: 10px; | |
10 } | 6 } |
11 .target { | 7 .target { |
12 -webkit-mask-position: top, bottom; | 8 width: 20px; |
13 -webkit-mask-size: 100px 50px; | 9 height: 20px; |
14 -webkit-mask-repeat: no-repeat; | 10 display: inline-block; |
15 background-color: blue; | 11 background-color: black; |
16 height: 100%; | 12 -webkit-mask-image: url(../resources/stripes-20.png); |
17 } | 13 } |
18 div.wrapper:nth-child(2n) { | 14 .expected { |
19 border-color: green; | 15 background-color: green; |
| 16 margin-right: 10px; |
20 } | 17 } |
21 </style> | 18 </style> |
22 <body> | 19 <body> |
23 <template id="target-template"> | |
24 <div class="wrapper"> | |
25 <div class="target"></div> | |
26 </div> | |
27 </template> | |
28 <script src="resources/interpolation-test.js"></script> | 20 <script src="resources/interpolation-test.js"></script> |
29 <script> | 21 <script> |
| 22 function assertCrossfadeInterpolation(options) { |
| 23 var fromComputed = options.fromComputed || options.from; |
| 24 assertInterpolation({ |
| 25 property: '-webkit-mask-image', |
| 26 from: options.from, |
| 27 to: options.to, |
| 28 }, [ |
| 29 {at: -0.3, is: fromComputed}, |
| 30 {at: 0, is: fromComputed}, |
| 31 {at: 0.3, is: '-webkit-cross-fade(' + fromComputed + ', ' + options.to + ',
0.3)'}, |
| 32 {at: 0.5, is: '-webkit-cross-fade(' + fromComputed + ', ' + options.to + ',
0.5)'}, |
| 33 {at: 0.6, is: '-webkit-cross-fade(' + fromComputed + ', ' + options.to + ',
0.6)'}, |
| 34 {at: 1, is: options.to}, |
| 35 {at: 1.5, is: options.to}, |
| 36 ]); |
| 37 } |
| 38 |
| 39 // neutral |
| 40 assertCrossfadeInterpolation({ |
| 41 from: '', |
| 42 fromComputed: 'url(../resources/stripes-20.png)', |
| 43 to: 'url(../resources/green-20.png)', |
| 44 }); |
| 45 |
| 46 // initial |
| 47 assertNoInterpolation({ |
| 48 property: '-webkit-mask-image', |
| 49 from: 'initial', |
| 50 to: 'url(../resources/green-20.png)', |
| 51 }); |
| 52 |
| 53 // inherit |
| 54 assertCrossfadeInterpolation({ |
| 55 from: 'inherit', |
| 56 fromComputed: 'url(../resources/blue-20.png)', |
| 57 to: 'url(../resources/green-20.png)', |
| 58 }); |
| 59 |
| 60 // unset |
| 61 assertNoInterpolation({ |
| 62 property: '-webkit-mask-image', |
| 63 from: 'unset', |
| 64 to: 'url(../resources/stripes-20.png)', |
| 65 }); |
| 66 |
30 // Image to image | 67 // Image to image |
31 var from = 'url(../resources/stripes-100.png)'; | 68 assertCrossfadeInterpolation({ |
32 var to = 'url(../resources/blue-100.png)'; | 69 from: 'url(../resources/stripes-20.png)', |
| 70 to: 'url(../resources/blue-20.png)', |
| 71 }); |
| 72 |
| 73 // Image to gradient |
| 74 assertCrossfadeInterpolation({ |
| 75 from: 'url(../resources/stripes-20.png)', |
| 76 to: 'linear-gradient(45deg, blue, transparent)', |
| 77 }); |
| 78 |
| 79 // Gradient to gradient |
| 80 assertCrossfadeInterpolation({ |
| 81 from: 'linear-gradient(-45deg, blue, transparent)', |
| 82 to: 'linear-gradient(45deg, blue, transparent)', |
| 83 }); |
| 84 |
| 85 // Keyword to image |
| 86 assertNoInterpolation({ |
| 87 property: '-webkit-mask-image', |
| 88 from: 'none', |
| 89 to: 'url(../resources/blue-20.png)', |
| 90 }); |
| 91 |
| 92 // Multiple to multiple |
| 93 var fromA = 'url(../resources/stripes-20.png)'; |
| 94 var fromB = 'linear-gradient(-45deg, blue, transparent)'; |
| 95 var toA = 'url(../resources/blue-20.png)'; |
| 96 var toB = 'url(../resources/stripes-20.png)'; |
| 97 var from = fromA + ', ' + fromB; |
| 98 var to = toA + ', ' + toB; |
33 assertInterpolation({ | 99 assertInterpolation({ |
34 property: '-webkit-mask-image', | 100 property: '-webkit-mask-image', |
35 from: from, | 101 from: from, |
36 to: to, | |
37 }, [ | |
38 {at: -0.3, is: from}, | |
39 {at: 0, is: from}, | |
40 {at: 0.3, is: '-webkit-cross-fade(' + from + ', ' + to + ', 0.3)'}, | |
41 {at: 0.6, is: '-webkit-cross-fade(' + from + ', ' + to + ', 0.6)'}, | |
42 {at: 1, is: to}, | |
43 {at: 1.5, is: to}, | |
44 ]); | |
45 | |
46 // Image to gradient | |
47 from = 'url(../resources/stripes-100.png)'; | |
48 to = 'linear-gradient(45deg, blue, transparent)'; | |
49 assertInterpolation({ | |
50 property: '-webkit-mask-image', | |
51 from: from, | |
52 to: to, | |
53 }, [ | |
54 {at: -0.3, is: from}, | |
55 {at: 0, is: from}, | |
56 {at: 0.3, is: '-webkit-cross-fade(' + from + ', ' + to + ', 0.3)'}, | |
57 {at: 0.6, is: '-webkit-cross-fade(' + from + ', ' + to + ', 0.6)'}, | |
58 {at: 1, is: to}, | |
59 {at: 1.5, is: to}, | |
60 ]); | |
61 | |
62 // Gradient to gradient | |
63 from = 'linear-gradient(-45deg, blue, transparent)'; | |
64 to = 'linear-gradient(45deg, blue, transparent)'; | |
65 assertInterpolation({ | |
66 property: '-webkit-mask-image', | |
67 from: from, | |
68 to: to, | |
69 }, [ | |
70 {at: -0.3, is: from}, | |
71 {at: 0, is: from}, | |
72 {at: 0.3, is: '-webkit-cross-fade(' + from + ', ' + to + ', 0.3)'}, | |
73 {at: 0.6, is: '-webkit-cross-fade(' + from + ', ' + to + ', 0.6)'}, | |
74 {at: 1, is: to}, | |
75 {at: 1.5, is: to}, | |
76 ]); | |
77 | |
78 // Keyword to image | |
79 from = 'none'; | |
80 to = 'url(../resources/blue-100.png)'; | |
81 assertNoInterpolation({ | |
82 property: '-webkit-mask-image', | |
83 from: from, | |
84 to: to, | |
85 }); | |
86 | |
87 // Multiple to multiple | |
88 var fromA = 'url(../resources/stripes-100.png)'; | |
89 var fromB = 'linear-gradient(-45deg, blue, transparent)'; | |
90 var toA = 'url(../resources/blue-100.png)'; | |
91 var toB = 'url(../resources/stripes-100.png)'; | |
92 from = fromA + ', ' + fromB; | |
93 to = toA + ', ' + toB; | |
94 assertInterpolation({ | |
95 property: '-webkit-mask-image', | |
96 from: from, | |
97 to: to, | 102 to: to, |
98 }, [ | 103 }, [ |
99 // The interpolation of different numbers of -webkit-mask-images looks a bit s
trange here. | 104 // The interpolation of different numbers of -webkit-mask-images looks a bit s
trange here. |
100 // Animating -webkit-mask-image is not specified to be possible however we do
it for backwards compatibility. | 105 // Animating -webkit-mask-image is not specified to be possible however we do
it for backwards compatibility. |
101 // With this in mind we kept the implementation simple at the expense of this
corner case because there is | 106 // With this in mind we kept the implementation simple at the expense of this
corner case because there is |
102 // no official specification to support. | 107 // no official specification to support. |
103 {at: -0.3, is: from}, | 108 {at: -0.3, is: from}, |
104 {at: 0, is: from}, | 109 {at: 0, is: from}, |
105 {at: 0.3, is: '-webkit-cross-fade(' + fromA + ', ' + toA + ', 0.3), -webkit-cr
oss-fade(' + fromB + ', ' + toB + ', 0.3)'}, | 110 {at: 0.3, is: '-webkit-cross-fade(' + fromA + ', ' + toA + ', 0.3), -webkit-cr
oss-fade(' + fromB + ', ' + toB + ', 0.3)'}, |
106 {at: 0.6, is: '-webkit-cross-fade(' + fromA + ', ' + toA + ', 0.6), -webkit-cr
oss-fade(' + fromB + ', ' + toB + ', 0.6)'}, | 111 {at: 0.6, is: '-webkit-cross-fade(' + fromA + ', ' + toA + ', 0.6), -webkit-cr
oss-fade(' + fromB + ', ' + toB + ', 0.6)'}, |
107 {at: 1, is: to}, | 112 {at: 1, is: to}, |
108 {at: 1.5, is: to}, | 113 {at: 1.5, is: to}, |
109 ]); | 114 ]); |
110 | 115 |
111 // Single to multiple | 116 // Single to multiple |
112 from = 'url(../resources/blue-100.png)'; | 117 from = 'url(../resources/blue-20.png)'; |
113 var toA = 'url(../resources/stripes-100.png)'; | 118 toA = 'url(../resources/stripes-20.png)'; |
114 var toB = 'url(../resources/blue-100.png)'; | 119 toB = 'url(../resources/blue-20.png)'; |
115 to = toA + ', ' + toB; | 120 to = toA + ', ' + toB; |
116 assertInterpolation({ | 121 assertInterpolation({ |
117 property: '-webkit-mask-image', | 122 property: '-webkit-mask-image', |
118 from: from, | 123 from: from, |
119 to: to, | 124 to: to, |
120 }, [ | 125 }, [ |
121 {at: -0.3, is: from + ', ' + from}, | 126 {at: -0.3, is: from + ', ' + from}, |
122 {at: 0, is: from}, | 127 {at: 0, is: from}, |
123 {at: 0.3, is: '-webkit-cross-fade(' + from + ', ' + toA + ', 0.3), -webkit-cro
ss-fade(' + from + ', ' + toB + ', 0.3)'}, | 128 {at: 0.3, is: '-webkit-cross-fade(' + from + ', ' + toA + ', 0.3), -webkit-cro
ss-fade(' + from + ', ' + toB + ', 0.3)'}, |
124 {at: 0.6, is: '-webkit-cross-fade(' + from + ', ' + toA + ', 0.6), -webkit-cro
ss-fade(' + from + ', ' + toB + ', 0.6)'}, | 129 {at: 0.6, is: '-webkit-cross-fade(' + from + ', ' + toA + ', 0.6), -webkit-cro
ss-fade(' + from + ', ' + toB + ', 0.6)'}, |
125 {at: 1, is: to}, | 130 {at: 1, is: to}, |
126 {at: 1.5, is: to}, | 131 {at: 1.5, is: to}, |
127 ]); | 132 ]); |
128 | 133 |
129 // Multiple mismatched types | 134 // Multiple mismatched types |
130 from = 'url(../resources/blue-100.png), none'; | |
131 to = 'url(../resources/stripes-100.png), url(../resources/blue-100.png)'; | |
132 assertNoInterpolation({ | 135 assertNoInterpolation({ |
133 property: '-webkit-mask-image', | 136 property: '-webkit-mask-image', |
134 from: from, | 137 from: 'url(../resources/blue-20.png), none', |
135 to: to, | 138 to: 'url(../resources/stripes-20.png), url(../resources/blue-20.png)', |
136 }); | 139 }); |
137 </script> | 140 </script> |
138 </body> | 141 </body> |
OLD | NEW |