-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
css_table.go
361 lines (346 loc) · 12.5 KB
/
css_table.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
// This file was automatically generated by "css_table.ts"
package compat
import (
"github.com/evanw/esbuild/internal/css_ast"
)
type CSSFeature uint16
const (
ColorFunctions CSSFeature = 1 << iota
GradientDoublePosition
GradientInterpolation
GradientMidpoints
HWB
HexRGBA
InlineStyle
InsetProperty
IsPseudoClass
Modern_RGB_HSL
Nesting
RebeccaPurple
)
var StringToCSSFeature = map[string]CSSFeature{
"color-functions": ColorFunctions,
"gradient-double-position": GradientDoublePosition,
"gradient-interpolation": GradientInterpolation,
"gradient-midpoints": GradientMidpoints,
"hwb": HWB,
"hex-rgba": HexRGBA,
"inline-style": InlineStyle,
"inset-property": InsetProperty,
"is-pseudo-class": IsPseudoClass,
"modern-rgb-hsl": Modern_RGB_HSL,
"nesting": Nesting,
"rebecca-purple": RebeccaPurple,
}
func (features CSSFeature) Has(feature CSSFeature) bool {
return (features & feature) != 0
}
func (features CSSFeature) ApplyOverrides(overrides CSSFeature, mask CSSFeature) CSSFeature {
return (features & ^mask) | (overrides & mask)
}
var cssTable = map[CSSFeature]map[Engine][]versionRange{
ColorFunctions: {
Chrome: {{start: v{111, 0, 0}}},
Edge: {{start: v{111, 0, 0}}},
Firefox: {{start: v{113, 0, 0}}},
IOS: {{start: v{15, 4, 0}}},
Opera: {{start: v{97, 0, 0}}},
Safari: {{start: v{15, 4, 0}}},
},
GradientDoublePosition: {
Chrome: {{start: v{72, 0, 0}}},
Edge: {{start: v{79, 0, 0}}},
Firefox: {{start: v{83, 0, 0}}},
IOS: {{start: v{12, 2, 0}}},
Opera: {{start: v{60, 0, 0}}},
Safari: {{start: v{12, 1, 0}}},
},
GradientInterpolation: {
Chrome: {{start: v{111, 0, 0}}},
Edge: {{start: v{111, 0, 0}}},
IOS: {{start: v{16, 2, 0}}},
Opera: {{start: v{97, 0, 0}}},
Safari: {{start: v{16, 2, 0}}},
},
GradientMidpoints: {
Chrome: {{start: v{40, 0, 0}}},
Edge: {{start: v{79, 0, 0}}},
Firefox: {{start: v{36, 0, 0}}},
IOS: {{start: v{7, 0, 0}}},
Opera: {{start: v{27, 0, 0}}},
Safari: {{start: v{7, 0, 0}}},
},
HWB: {
Chrome: {{start: v{101, 0, 0}}},
Edge: {{start: v{101, 0, 0}}},
Firefox: {{start: v{96, 0, 0}}},
IOS: {{start: v{15, 0, 0}}},
Opera: {{start: v{87, 0, 0}}},
Safari: {{start: v{15, 0, 0}}},
},
HexRGBA: {
Chrome: {{start: v{62, 0, 0}}},
Edge: {{start: v{79, 0, 0}}},
Firefox: {{start: v{49, 0, 0}}},
IOS: {{start: v{9, 3, 0}}},
Opera: {{start: v{49, 0, 0}}},
Safari: {{start: v{10, 0, 0}}},
},
InlineStyle: {},
InsetProperty: {
Chrome: {{start: v{87, 0, 0}}},
Edge: {{start: v{87, 0, 0}}},
Firefox: {{start: v{66, 0, 0}}},
IOS: {{start: v{14, 5, 0}}},
Opera: {{start: v{73, 0, 0}}},
Safari: {{start: v{14, 1, 0}}},
},
IsPseudoClass: {
Chrome: {{start: v{88, 0, 0}}},
Edge: {{start: v{88, 0, 0}}},
Firefox: {{start: v{78, 0, 0}}},
IOS: {{start: v{14, 0, 0}}},
Opera: {{start: v{75, 0, 0}}},
Safari: {{start: v{14, 0, 0}}},
},
Modern_RGB_HSL: {
Chrome: {{start: v{66, 0, 0}}},
Edge: {{start: v{79, 0, 0}}},
Firefox: {{start: v{52, 0, 0}}},
IOS: {{start: v{12, 2, 0}}},
Opera: {{start: v{53, 0, 0}}},
Safari: {{start: v{12, 1, 0}}},
},
Nesting: {
Chrome: {{start: v{120, 0, 0}}},
Edge: {{start: v{120, 0, 0}}},
Firefox: {{start: v{117, 0, 0}}},
IOS: {{start: v{17, 2, 0}}},
Opera: {{start: v{106, 0, 0}}},
Safari: {{start: v{17, 2, 0}}},
},
RebeccaPurple: {
Chrome: {{start: v{38, 0, 0}}},
Edge: {{start: v{12, 0, 0}}},
Firefox: {{start: v{33, 0, 0}}},
IE: {{start: v{11, 0, 0}}},
IOS: {{start: v{8, 0, 0}}},
Opera: {{start: v{25, 0, 0}}},
Safari: {{start: v{9, 0, 0}}},
},
}
// Return all features that are not available in at least one environment
func UnsupportedCSSFeatures(constraints map[Engine]Semver) (unsupported CSSFeature) {
for feature, engines := range cssTable {
if feature == InlineStyle {
continue // This is purely user-specified
}
for engine, version := range constraints {
if !engine.IsBrowser() {
// Specifying "--target=es2020" shouldn't affect CSS
continue
}
if versionRanges, ok := engines[engine]; !ok || !isVersionSupported(versionRanges, version) {
unsupported |= feature
}
}
}
return
}
type CSSPrefix uint8
const (
KhtmlPrefix CSSPrefix = 1 << iota
MozPrefix
MsPrefix
OPrefix
WebkitPrefix
NoPrefix CSSPrefix = 0
)
type prefixData struct {
// Note: In some cases, earlier versions did not require a prefix but later
// ones do. This is the case for Microsoft Edge for example, which switched
// the underlying browser engine from a custom one to the one from Chrome.
// However, we assume that users specifying a browser version for CSS mean
// "works in this version or newer", so we still add a prefix when a target
// is an old Edge version.
engine Engine
withoutPrefix v
prefix CSSPrefix
}
var cssPrefixTable = map[css_ast.D][]prefixData{
css_ast.DAppearance: {
{engine: Chrome, prefix: WebkitPrefix, withoutPrefix: v{84, 0, 0}},
{engine: Edge, prefix: WebkitPrefix, withoutPrefix: v{84, 0, 0}},
{engine: Firefox, prefix: MozPrefix, withoutPrefix: v{80, 0, 0}},
{engine: IOS, prefix: WebkitPrefix, withoutPrefix: v{15, 4, 0}},
{engine: Opera, prefix: WebkitPrefix, withoutPrefix: v{73, 0, 0}},
{engine: Safari, prefix: WebkitPrefix, withoutPrefix: v{15, 4, 0}},
},
css_ast.DBackdropFilter: {
{engine: IOS, prefix: WebkitPrefix},
{engine: Safari, prefix: WebkitPrefix},
},
css_ast.DBackgroundClip: {
{engine: Chrome, prefix: WebkitPrefix, withoutPrefix: v{120, 0, 0}},
{engine: Edge, prefix: MsPrefix, withoutPrefix: v{15, 0, 0}},
{engine: Edge, prefix: WebkitPrefix, withoutPrefix: v{120, 0, 0}},
{engine: IOS, prefix: WebkitPrefix, withoutPrefix: v{14, 0, 0}},
{engine: Opera, prefix: WebkitPrefix, withoutPrefix: v{106, 0, 0}},
{engine: Safari, prefix: WebkitPrefix, withoutPrefix: v{14, 0, 0}},
},
css_ast.DBoxDecorationBreak: {
{engine: Chrome, prefix: WebkitPrefix},
{engine: Edge, prefix: WebkitPrefix},
{engine: IOS, prefix: WebkitPrefix},
{engine: Opera, prefix: WebkitPrefix},
{engine: Safari, prefix: WebkitPrefix},
},
css_ast.DClipPath: {
{engine: Chrome, prefix: WebkitPrefix, withoutPrefix: v{55, 0, 0}},
{engine: IOS, prefix: WebkitPrefix, withoutPrefix: v{13, 0, 0}},
{engine: Opera, prefix: WebkitPrefix, withoutPrefix: v{42, 0, 0}},
{engine: Safari, prefix: WebkitPrefix, withoutPrefix: v{13, 1, 0}},
},
css_ast.DFontKerning: {
{engine: Chrome, prefix: WebkitPrefix, withoutPrefix: v{33, 0, 0}},
{engine: IOS, prefix: WebkitPrefix, withoutPrefix: v{12, 0, 0}},
{engine: Opera, prefix: WebkitPrefix, withoutPrefix: v{20, 0, 0}},
{engine: Safari, prefix: WebkitPrefix, withoutPrefix: v{9, 1, 0}},
},
css_ast.DHyphens: {
{engine: Edge, prefix: MsPrefix, withoutPrefix: v{79, 0, 0}},
{engine: Firefox, prefix: MozPrefix, withoutPrefix: v{43, 0, 0}},
{engine: IE, prefix: MsPrefix},
{engine: IOS, prefix: WebkitPrefix, withoutPrefix: v{17, 0, 0}},
{engine: Safari, prefix: WebkitPrefix, withoutPrefix: v{17, 0, 0}},
},
css_ast.DInitialLetter: {
{engine: IOS, prefix: WebkitPrefix},
{engine: Safari, prefix: WebkitPrefix},
},
css_ast.DMaskComposite: {
{engine: Chrome, prefix: WebkitPrefix, withoutPrefix: v{120, 0, 0}},
{engine: Edge, prefix: WebkitPrefix, withoutPrefix: v{120, 0, 0}},
{engine: IOS, prefix: WebkitPrefix, withoutPrefix: v{15, 4, 0}},
{engine: Opera, prefix: WebkitPrefix, withoutPrefix: v{106, 0, 0}},
{engine: Safari, prefix: WebkitPrefix, withoutPrefix: v{15, 4, 0}},
},
css_ast.DMaskImage: {
{engine: Chrome, prefix: WebkitPrefix, withoutPrefix: v{120, 0, 0}},
{engine: Edge, prefix: WebkitPrefix},
{engine: IOS, prefix: WebkitPrefix, withoutPrefix: v{15, 4, 0}},
{engine: Opera, prefix: WebkitPrefix},
{engine: Safari, prefix: WebkitPrefix, withoutPrefix: v{15, 4, 0}},
},
css_ast.DMaskOrigin: {
{engine: Chrome, prefix: WebkitPrefix, withoutPrefix: v{120, 0, 0}},
{engine: Edge, prefix: WebkitPrefix, withoutPrefix: v{120, 0, 0}},
{engine: IOS, prefix: WebkitPrefix, withoutPrefix: v{15, 4, 0}},
{engine: Opera, prefix: WebkitPrefix, withoutPrefix: v{106, 0, 0}},
{engine: Safari, prefix: WebkitPrefix, withoutPrefix: v{15, 4, 0}},
},
css_ast.DMaskPosition: {
{engine: Chrome, prefix: WebkitPrefix, withoutPrefix: v{120, 0, 0}},
{engine: Edge, prefix: WebkitPrefix},
{engine: IOS, prefix: WebkitPrefix, withoutPrefix: v{15, 4, 0}},
{engine: Opera, prefix: WebkitPrefix, withoutPrefix: v{106, 0, 0}},
{engine: Safari, prefix: WebkitPrefix, withoutPrefix: v{15, 4, 0}},
},
css_ast.DMaskRepeat: {
{engine: Chrome, prefix: WebkitPrefix, withoutPrefix: v{120, 0, 0}},
{engine: Edge, prefix: WebkitPrefix},
{engine: IOS, prefix: WebkitPrefix, withoutPrefix: v{15, 4, 0}},
{engine: Opera, prefix: WebkitPrefix, withoutPrefix: v{106, 0, 0}},
{engine: Safari, prefix: WebkitPrefix, withoutPrefix: v{15, 4, 0}},
},
css_ast.DMaskSize: {
{engine: Chrome, prefix: WebkitPrefix, withoutPrefix: v{120, 0, 0}},
{engine: Edge, prefix: WebkitPrefix},
{engine: IOS, prefix: WebkitPrefix, withoutPrefix: v{15, 4, 0}},
{engine: Opera, prefix: WebkitPrefix, withoutPrefix: v{106, 0, 0}},
{engine: Safari, prefix: WebkitPrefix, withoutPrefix: v{15, 4, 0}},
},
css_ast.DPosition: {
{engine: IOS, prefix: WebkitPrefix, withoutPrefix: v{13, 0, 0}},
{engine: Safari, prefix: WebkitPrefix, withoutPrefix: v{13, 0, 0}},
},
css_ast.DPrintColorAdjust: {
{engine: Chrome, prefix: WebkitPrefix},
{engine: Edge, prefix: WebkitPrefix},
{engine: Opera, prefix: WebkitPrefix},
{engine: Safari, prefix: WebkitPrefix, withoutPrefix: v{15, 4, 0}},
},
css_ast.DTabSize: {
{engine: Firefox, prefix: MozPrefix, withoutPrefix: v{91, 0, 0}},
{engine: Opera, prefix: OPrefix, withoutPrefix: v{15, 0, 0}},
},
css_ast.DTextDecorationColor: {
{engine: Firefox, prefix: MozPrefix, withoutPrefix: v{36, 0, 0}},
{engine: IOS, prefix: WebkitPrefix, withoutPrefix: v{12, 2, 0}},
{engine: Safari, prefix: WebkitPrefix, withoutPrefix: v{12, 1, 0}},
},
css_ast.DTextDecorationLine: {
{engine: Firefox, prefix: MozPrefix, withoutPrefix: v{36, 0, 0}},
{engine: IOS, prefix: WebkitPrefix, withoutPrefix: v{12, 2, 0}},
{engine: Safari, prefix: WebkitPrefix, withoutPrefix: v{12, 1, 0}},
},
css_ast.DTextDecorationSkip: {
{engine: IOS, prefix: WebkitPrefix, withoutPrefix: v{12, 2, 0}},
{engine: Safari, prefix: WebkitPrefix, withoutPrefix: v{12, 1, 0}},
},
css_ast.DTextEmphasisColor: {
{engine: Chrome, prefix: WebkitPrefix, withoutPrefix: v{99, 0, 0}},
{engine: Edge, prefix: WebkitPrefix, withoutPrefix: v{99, 0, 0}},
{engine: Opera, prefix: WebkitPrefix, withoutPrefix: v{85, 0, 0}},
},
css_ast.DTextEmphasisPosition: {
{engine: Chrome, prefix: WebkitPrefix, withoutPrefix: v{99, 0, 0}},
{engine: Edge, prefix: WebkitPrefix, withoutPrefix: v{99, 0, 0}},
{engine: Opera, prefix: WebkitPrefix, withoutPrefix: v{85, 0, 0}},
},
css_ast.DTextEmphasisStyle: {
{engine: Chrome, prefix: WebkitPrefix, withoutPrefix: v{99, 0, 0}},
{engine: Edge, prefix: WebkitPrefix, withoutPrefix: v{99, 0, 0}},
{engine: Opera, prefix: WebkitPrefix, withoutPrefix: v{85, 0, 0}},
},
css_ast.DTextOrientation: {
{engine: Safari, prefix: WebkitPrefix, withoutPrefix: v{14, 0, 0}},
},
css_ast.DTextSizeAdjust: {
{engine: Edge, prefix: MsPrefix, withoutPrefix: v{79, 0, 0}},
{engine: IOS, prefix: WebkitPrefix},
},
css_ast.DUserSelect: {
{engine: Chrome, prefix: WebkitPrefix, withoutPrefix: v{54, 0, 0}},
{engine: Edge, prefix: MsPrefix, withoutPrefix: v{79, 0, 0}},
{engine: Firefox, prefix: MozPrefix, withoutPrefix: v{69, 0, 0}},
{engine: IE, prefix: MsPrefix},
{engine: IOS, prefix: WebkitPrefix},
{engine: Opera, prefix: WebkitPrefix, withoutPrefix: v{41, 0, 0}},
{engine: Safari, prefix: KhtmlPrefix, withoutPrefix: v{3, 0, 0}},
{engine: Safari, prefix: WebkitPrefix},
},
}
func CSSPrefixData(constraints map[Engine]Semver) (entries map[css_ast.D]CSSPrefix) {
for property, items := range cssPrefixTable {
prefixes := NoPrefix
for engine, version := range constraints {
if !engine.IsBrowser() {
// Specifying "--target=es2020" shouldn't affect CSS
continue
}
for _, item := range items {
if item.engine == engine && (item.withoutPrefix == v{} || compareVersions(item.withoutPrefix, version) > 0) {
prefixes |= item.prefix
}
}
}
if prefixes != NoPrefix {
if entries == nil {
entries = make(map[css_ast.D]CSSPrefix)
}
entries[property] = prefixes
}
}
return
}