diff --git a/src/bitflags.zig b/src/bitflags.zig deleted file mode 100644 index 908179686a..0000000000 --- a/src/bitflags.zig +++ /dev/null @@ -1,116 +0,0 @@ -const std = @import("std"); - -pub fn Bitflags(comptime T: type) type { - const tyinfo = @typeInfo(T); - const IntType = tyinfo.@"struct".backing_integer.?; - const IntTypeInfo = @typeInfo(IntType); - const IntRepresentingNumOfBits = std.math.IntFittingRange(0, IntTypeInfo.int.bits); - - return struct { - pub const IMPL_BITFLAGS: u0 = 0; - - pub inline fn empty() T { - return @bitCast(@as(IntType, 0)); - } - - pub inline fn intersects(lhs: T, rhs: T) bool { - return asBits(lhs) & asBits(rhs) != 0; - } - - pub inline fn fromName(comptime name: []const u8) T { - var this: T = .{}; - @field(this, name) = true; - return this; - } - - pub inline fn fromNames(comptime names: []const []const u8) T { - var this: T = .{}; - inline for (names) |name| { - @field(this, name) = true; - } - return this; - } - - pub fn bitwiseOr(lhs: T, rhs: T) T { - return @bitCast(@as(IntType, @bitCast(lhs)) | @as(IntType, @bitCast(rhs))); - } - - pub fn bitwiseAnd(lhs: T, rhs: T) T { - return @bitCast(@as(IntType, asBits(lhs) & asBits(rhs))); - } - - pub inline fn intersect(lhs: T, rhs: T) T { - return bitwiseAnd(lhs, rhs); - } - - pub inline fn insert(this: *T, other: T) void { - this.* = bitwiseOr(this.*, other); - } - - pub inline fn remove(this: *T, other: T) void { - this.* = @bitCast(asBits(this.*) & ~asBits(other)); - } - - pub inline fn maskOut(this: T, other: T) T { - return @bitCast(asBits(this) & ~asBits(other)); - } - - pub fn contains(lhs: T, rhs: T) bool { - return @as(IntType, @bitCast(lhs)) & @as(IntType, @bitCast(rhs)) != 0; - } - - pub inline fn leadingZeroes(this: T) IntRepresentingNumOfBits { - return @clz(asBits(this)); - } - - pub inline fn all() T { - var ret: T = @bitCast(@as(IntType, 0)); - @setEvalBranchQuota(5000); - inline for (std.meta.fields(T)) |field| { - if (comptime !std.mem.eql(u8, field.name, "__unused")) { - @field(ret, field.name) = true; - } - } - return ret; - } - - pub inline fn not(this: T) T { - return fromBitsTruncate(~asBits(this)); - } - - pub inline fn difference(lhs: T, rhs: T) T { - // 1100 1100 1100 - // 1010 0101 0100 - return @bitCast(asBits(lhs) & asBits(not(rhs))); - } - - /// Convert from a bits value, unsetting any unknown bits. - pub inline fn fromBitsTruncate(bits: IntType) T { - return bitwiseAnd(@bitCast(bits), all()); - } - - pub inline fn asBits(this: T) IntType { - return @as(IntType, @bitCast(this)); - } - - pub fn isEmpty(this: T) bool { - return asBits(this) == 0; - } - - pub fn eq(lhs: T, rhs: T) bool { - return asBits(lhs) == asBits(rhs); - } - - pub fn eql(lhs: T, rhs: T) bool { - return eq(lhs, rhs); - } - - pub fn neq(lhs: T, rhs: T) bool { - return asBits(lhs) != asBits(rhs); - } - - pub fn hash(this: *const T, hasher: *std.hash.Wyhash) void { - hasher.update(std.mem.asBytes(this)); - } - }; -} diff --git a/src/bits.zig b/src/bits.zig new file mode 100644 index 0000000000..1ac2fdc97d --- /dev/null +++ b/src/bits.zig @@ -0,0 +1,60 @@ +//! Bitfield helper functions. T should be a packed struct of booleans. + +/// If the right side is known at compile time, you should just perform field accesses +/// +/// intersects(T, a, .{ .flag = true }) --> a.flag +/// +pub inline fn intersects(comptime T: type, lhs: T, rhs: T) bool { + return asInt(T, lhs) & asInt(T, rhs) != 0; +} + +pub inline fn @"and"(comptime T: type, lhs: T, rhs: T) T { + return fromInt(T, asInt(T, lhs) & asInt(T, rhs)); +} + +pub inline fn @"or"(comptime T: type, lhs: T, rhs: T) T { + return fromInt(T, asInt(T, lhs) | asInt(T, rhs)); +} + +pub inline fn invert(comptime T: type, value: T) T { + return fromInt(T, ~asInt(T, value)); +} + +/// Prefer a property assignment when possible +/// +/// insert(T, &a, .{ .flag = true }) --> a.flag = true; +/// +pub inline fn insert(comptime T: type, lhs: *T, rhs: T) void { + lhs.* = @"or"(T, lhs.*, rhs); +} + +pub inline fn contains(comptime T: type, lhs: T, rhs: T) bool { + return (asInt(T, lhs) & asInt(T, rhs)) != 0; +} + +pub inline fn maskOut(comptime T: type, lhs: *T, rhs: T) T { + return @"and"(T, lhs, invert(T, rhs)); +} + +pub inline fn remove(comptime T: type, lhs: *T, rhs: T) void { + lhs.* = @"and"(T, lhs.*, invert(T, rhs)); +} + +pub inline fn leadingZeros(comptime T: type, value: T) LeadingZerosInt(T) { + return @clz(asInt(T, value)); +} + +pub fn LeadingZerosInt(comptime T: type) type { + const backing_int = @typeInfo(T).@"struct".backing_integer.?; + return std.math.IntFittingRange(0, @typeInfo(backing_int).int.bits); +} + +pub inline fn fromInt(comptime T: type, bits: @typeInfo(T).@"struct".backing_integer.?) T { + return @bitCast(bits); +} + +pub inline fn asInt(comptime T: type, value: T) @typeInfo(T).@"struct".backing_integer.? { + return @bitCast(value); +} + +const std = @import("std"); diff --git a/src/bun.zig b/src/bun.zig index ab52d48878..7afafa9818 100644 --- a/src/bun.zig +++ b/src/bun.zig @@ -135,7 +135,7 @@ pub const ComptimeStringMapWithKeyType = comptime_string_map.ComptimeStringMapWi pub const glob = @import("./glob.zig"); pub const patch = @import("./patch.zig"); pub const ini = @import("./ini.zig"); -pub const Bitflags = @import("./bitflags.zig").Bitflags; +pub const bits = @import("bits.zig"); pub const css = @import("./css/css_parser.zig"); pub const csrf = @import("./csrf.zig"); pub const validators = @import("./bun.js/node/util/validators.zig"); @@ -3657,7 +3657,9 @@ pub inline fn take(val: anytype) ?@typeInfo(@typeInfo(@TypeOf(val)).pointer.chil /// This function deinitializes the value and sets the optional to null. pub inline fn clear(val: anytype, allocator: std.mem.Allocator) void { if (val.*) |*v| { - v.deinit(allocator); + if (@hasDecl(@TypeOf(v.*), "deinit")) { + v.deinit(allocator); + } val.* = null; } } diff --git a/src/c.zig b/src/c.zig index 2ab4d6674a..1c1c93e0d3 100644 --- a/src/c.zig +++ b/src/c.zig @@ -15,9 +15,9 @@ const Environment = @import("./env.zig"); pub const translated = @import("translated-c-headers"); const PlatformSpecific = switch (Environment.os) { - .mac => @import("./darwin_c.zig"), - .linux => @import("./linux_c.zig"), - .windows => @import("./windows_c.zig"), + .mac => @import("darwin_c.zig"), + .linux => @import("linux_c.zig"), + .windows => @import("windows_c.zig"), else => struct {}, }; pub usingnamespace PlatformSpecific; diff --git a/src/css/build-prefixes.js b/src/css/build-prefixes.js index bd799194c2..91f399e208 100644 --- a/src/css/build-prefixes.js +++ b/src/css/build-prefixes.js @@ -513,20 +513,12 @@ let enumify = f => .replace(/(^|-)([a-z])/g, (_, a, x) => (a === "-" ? "_" + x : x)), ); -let allBrowsers = Object.keys(browsers) - .filter(b => !(b in BROWSER_MAPPING)) - .sort(); -let browsersZig = `pub const Browsers = struct { - ${allBrowsers.join(": ?u32 = null,\n")}: ?u32 = null, - pub usingnamespace BrowsersImpl(@This()); -}`; let field_len = 0; let flagsZig = `pub const Features = packed struct(u32) { ${flags .map((flag, i) => { if (Array.isArray(flag)) { - // return `const ${flag[0]} = ${flag[1].map(f => `Self::${f}.bits()`).join(" | ")};`; - return `pub const ${flag[0]} = Features.fromNames(&.{${flag[1].map(f => `"${f}"`).join(", ")}});`; + return `pub const ${flag[0]}: @This() = .{${flag[1].map(f => `.${f} = true,`).join("")}};`; } else { field_len++; return `${flag}: bool = false,`; @@ -541,14 +533,10 @@ let flagsZig = `pub const Features = packed struct(u32) { return 0; }) .join("\n ")} - - pub usingnamespace css.Bitflags(@This()); - pub usingnamespace FeaturesImpl(@This()); }`; let targets = fs .readFileSync("src/css/targets.zig", "utf8") - .replace(/pub const Browsers = struct \{((?:.|\n)+?)\}/, browsersZig) - .replace(/pub const Features = packed struct\(u32\) \{((?:.|\n)+?)\}/, flagsZig); + .replace(/pub const Features = packed struct\(u32\) \{((?:.|\n)+?)\n\}/, flagsZig); console.log("TARGETS", targets); fs.writeFileSync("src/css/targets.zig", targets); diff --git a/src/css/css_internals.zig b/src/css/css_internals.zig index 97326c2057..e9b69ffdc2 100644 --- a/src/css/css_internals.zig +++ b/src/css/css_internals.zig @@ -169,9 +169,7 @@ fn parserOptionsFromJS(globalThis: *JSC.JSGlobalObject, allocator: Allocator, op const str = bunstr.toUTF8(bun.default_allocator); defer str.deinit(); if (std.mem.eql(u8, str.slice(), "DEEP_SELECTOR_COMBINATOR")) { - opts.flags.insert(bun.css.ParserFlags{ - .deep_selector_combinator = true, - }); + opts.flags.deep_selector_combinator = true; } else { return globalThis.throw("invalid flag: {s}", .{str.slice()}); } diff --git a/src/css/css_parser.zig b/src/css/css_parser.zig index 042d291cd5..78c1387377 100644 --- a/src/css/css_parser.zig +++ b/src/css/css_parser.zig @@ -139,7 +139,6 @@ pub fn OOM(e: anyerror) noreturn { } pub const SmallList = @import("./small_list.zig").SmallList; -pub const Bitflags = bun.Bitflags; pub const todo_stuff = struct { pub const think_mem_mgmt = "TODO: think about memory management"; @@ -173,6 +172,15 @@ pub const VendorPrefix = packed struct(u8) { o: bool = false, __unused: u3 = 0, + pub const empty = VendorPrefix{}; + pub const all = VendorPrefix{ + .none = true, + .moz = true, + .ms = true, + .o = true, + .webkit = true, + }; + pub const NONE = VendorPrefix{ .none = true }; pub const WEBKIT = VendorPrefix{ .webkit = true }; pub const MOZ = VendorPrefix{ .moz = true }; @@ -182,8 +190,6 @@ pub const VendorPrefix = packed struct(u8) { /// Fields listed here so we can iterate them in the order we want pub const FIELDS: []const []const u8 = &.{ "webkit", "moz", "ms", "o", "none" }; - pub usingnamespace Bitflags(@This()); - pub fn toCss(this: *const VendorPrefix, comptime W: type, dest: *Printer(W)) PrintErr!void { return switch (this.asBits()) { VendorPrefix.asBits(.{ .webkit = true }) => dest.writeStr("-webkit-"), @@ -194,6 +200,14 @@ pub const VendorPrefix = packed struct(u8) { }; } + pub inline fn fromName(comptime name: []const u8) VendorPrefix { + comptime { + var vp: VendorPrefix = .{}; + @field(vp, name) = true; + return vp; + } + } + /// Returns VendorPrefix::None if empty. pub inline fn orNone(this: VendorPrefix) VendorPrefix { return this._or(VendorPrefix{ .none = true }); @@ -204,6 +218,22 @@ pub const VendorPrefix = packed struct(u8) { if (this.isEmpty()) return other; return this; } + + pub fn difference(left: @This(), right: @This()) @This() { + return @bitCast(@as(u8, @bitCast(left)) - @as(u8, @bitCast(right))); + } + + pub fn isEmpty(this: VendorPrefix) bool { + return this == VendorPrefix{}; + } + + pub fn bitwiseAnd(a: @This(), b: @This()) @This() { + return bun.bits.@"and"(@This(), a, b); + } + + pub fn asBits(vp: @This()) u8 { + return @bitCast(vp); + } }; pub const SourceLocation = struct { @@ -576,7 +606,7 @@ pub fn DeriveParse(comptime T: type) type { break :counts .{ payload_count, first_payload_index.?, void_count, first_void_index }; }; - return gnerateCode(input, first_payload_index, first_void_index, void_count, payload_count); + return generateCode(input, first_payload_index, first_void_index, void_count, payload_count); } const location = input.currentSourceLocation(); @@ -625,7 +655,7 @@ pub fn DeriveParse(comptime T: type) type { /// and then try to parse the void fields. /// /// This parsing order is a detail copied from LightningCSS. I'm not sure if it is necessary. But it could be. - inline fn gnerateCode( + inline fn generateCode( input: *Parser, comptime first_payload_index: usize, comptime maybe_first_void_index: ?usize, @@ -873,14 +903,6 @@ pub fn DefineEnumProperty(comptime T: type) type { return @intFromEnum(lhs.*) == @intFromEnum(rhs.*); } - pub fn asStr(this: *const T) []const u8 { - const tag = @intFromEnum(this.*); - inline for (fields) |field| { - if (tag == field.value) return field.name; - } - unreachable; - } - pub fn parse(input: *Parser) Result(T) { const location = input.currentSourceLocation(); const ident = switch (input.expectIdent()) { @@ -894,13 +916,10 @@ pub fn DefineEnumProperty(comptime T: type) type { } return .{ .err = location.newUnexpectedTokenError(.{ .ident = ident }) }; - // @panic("TODO renable this"); } - pub fn deinit(_: *T, _: std.mem.Allocator) void {} - pub fn toCss(this: *const T, comptime W: type, dest: *Printer(W)) PrintErr!void { - return dest.writeStr(asStr(this)); + return dest.writeStr(@tagName(this.*)); } pub inline fn deepClone(this: *const T, _: std.mem.Allocator) T { @@ -1151,7 +1170,7 @@ fn parse_until_before( closure: anytype, comptime parse_fn: *const fn (@TypeOf(closure), *Parser) Result(T), ) Result(T) { - const delimiters = parser.stop_before.bitwiseOr(delimiters_); + const delimiters = bun.bits.@"or"(Delimiters, parser.stop_before, delimiters_); const result = result: { var delimited_parser = Parser{ .input = parser.input, @@ -1176,7 +1195,7 @@ fn parse_until_before( // FIXME: have a special-purpose tokenizer method for this that does less work. while (true) { - if (delimiters.contains(Delimiters.fromByte(parser.input.tokenizer.nextByte()))) break; + if (bun.bits.contains(Delimiters, delimiters, Delimiters.fromByte(parser.input.tokenizer.nextByte()))) break; switch (parser.input.tokenizer.next()) { .result => |token| { @@ -1207,8 +1226,9 @@ pub fn parse_until_after( return result; } const next_byte = parser.input.tokenizer.nextByte(); - if (next_byte != null and !parser.stop_before.contains(Delimiters.fromByte(next_byte))) { - bun.debugAssert(delimiters.contains(Delimiters.fromByte(next_byte))); + if (next_byte != null and !bun.bits.contains(Delimiters, parser.stop_before, .fromByte(next_byte))) { + if (bun.Environment.isDebug) bun.debugAssert(bun.bits.contains(Delimiters, delimiters, Delimiters.fromByte(next_byte))); + // We know this byte is ASCII. parser.input.tokenizer.advance(1); if (next_byte == '{') { @@ -2453,7 +2473,7 @@ pub fn NestedRuleParser(comptime T: type) type { .style = css_rules.style.StyleRule(T.CustomAtRuleParser.AtRule){ .selectors = selectors, .declarations = declarations, - .vendor_prefix = VendorPrefix.empty(), + .vendor_prefix = .{}, .rules = rules, .loc = loc, }, @@ -2778,7 +2798,7 @@ pub fn NestedRuleParser(comptime T: type) type { selector.parser.Selector.fromComponent(input.allocator(), .nesting), ), .declarations = declarations, - .vendor_prefix = VendorPrefix.empty(), + .vendor_prefix = .{}, .rules = .{}, .loc = loc, }, @@ -2947,8 +2967,6 @@ pub const CssRef = packed struct(u32) { pub const ID = Tag{ .id = true }; pub const CLASS = Tag{ .class = true }; - pub usingnamespace Bitflags(@This()); - pub fn canBeComposed(this: @This()) bool { return this.class; } @@ -3088,7 +3106,7 @@ pub fn StyleSheet(comptime AtRule: type) type { // @custom-media rules may be defined after they are referenced, but may only be defined at the top level // of a stylesheet. Do a pre-scan here and create a lookup table by name. - var custom_media: ?std.StringArrayHashMapUnmanaged(css_rules.custom_media.CustomMediaRule) = if (this.options.flags.contains(ParserFlags{ .custom_media = true }) and options.targets.shouldCompileSame(.custom_media_queries)) brk: { + var custom_media: ?std.StringArrayHashMapUnmanaged(css_rules.custom_media.CustomMediaRule) = if (this.options.flags.custom_media and options.targets.shouldCompileSame(.custom_media_queries)) brk: { var custom_media = std.StringArrayHashMapUnmanaged(css_rules.custom_media.CustomMediaRule){}; for (this.rules.v.items) |*rule| { @@ -3768,8 +3786,6 @@ pub const ParserFlags = packed struct(u8) { /// Whether to enable the non-standard >>> and /deep/ selector combinators used by Vue and Angular. deep_selector_combinator: bool = false, __unused: u5 = 0, - - pub usingnamespace Bitflags(@This()); }; const ParseUntilErrorBehavior = enum { @@ -3816,7 +3832,7 @@ pub const Parser = struct { bun.assert(this.extra != null); if (comptime bun.Environment.allow_assert) { // tag should only have one bit set, or none - bun.assert(@popCount(tag.asBits()) <= 1); + bun.assert(@popCount(bun.bits.asInt(CssRef.Tag, tag)) <= 1); } const extra = this.extra.?; @@ -3838,7 +3854,7 @@ pub const Parser = struct { const prev_tag = entry.value_ptr.ref.tag; if (!prev_tag.class and tag.class) { entry.value_ptr.loc = loc; - entry.value_ptr.ref.tag = entry.value_ptr.ref.tag.bitwiseOr(tag); + entry.value_ptr.ref.tag = bun.bits.@"or"(CssRef.Tag, entry.value_ptr.ref.tag, tag); } } @@ -4000,7 +4016,7 @@ pub const Parser = struct { /// the internal state of the parser (including position within the input) /// is restored to what it was before the call. /// - /// func needs to be a funtion like this: `fn func(*Parser, ...@TypeOf(args_)) T` + /// func needs to be a function like this: `fn func(*Parser, ...@TypeOf(args_)) T` pub inline fn tryParse(this: *Parser, comptime func: anytype, args_: anytype) bun.meta.ReturnOf(func) { const start = this.state(); const result = result: { @@ -4405,7 +4421,7 @@ pub const Parser = struct { pub fn nextByte(this: *@This()) ?u8 { const byte = this.input.tokenizer.nextByte(); - if (this.stop_before.contains(Delimiters.fromByte(byte))) { + if (bun.bits.contains(Delimiters, this.stop_before, .fromByte(byte))) { return null; } return byte; @@ -4440,7 +4456,7 @@ pub const Parser = struct { } const byte = this.input.tokenizer.nextByte(); - if (this.stop_before.contains(Delimiters.fromByte(byte))) { + if (bun.bits.contains(Delimiters, this.stop_before, .fromByte(byte))) { return .{ .err = this.newError(BasicParseErrorKind.end_of_input) }; } @@ -4505,8 +4521,6 @@ pub const Delimiters = packed struct(u8) { close_parenthesis: bool = false, __unused: u1 = 0, - pub usingnamespace Bitflags(Delimiters); - const NONE: Delimiters = .{}; pub fn getDelimiter(comptime tag: @TypeOf(.enum_literal)) Delimiters { diff --git a/src/css/generics.zig b/src/css/generics.zig index c58a298cd5..25af27e188 100644 --- a/src/css/generics.zig +++ b/src/css/generics.zig @@ -452,8 +452,10 @@ pub inline fn eql(comptime T: type, lhs: *const T, rhs: *const T) bool { CustomIdent, DashedIdent, Ident => bun.strings.eql(lhs.v, rhs.v), []const u8 => bun.strings.eql(lhs.*, rhs.*), bun.logger.Loc => lhs.eql(rhs.*), - // css.VendorPrefix => css.VendorPrefix.eq(lhs.*, rhs.*), - else => T.eql(lhs, rhs), + else => if (@typeInfo(T) == .@"struct" and @typeInfo(T).@"struct".layout == .@"packed") + lhs.* == rhs.* + else + T.eql(lhs, rhs), }; } diff --git a/src/css/media_query.zig b/src/css/media_query.zig index 5e00beada5..37b81621d1 100644 --- a/src/css/media_query.zig +++ b/src/css/media_query.zig @@ -201,12 +201,12 @@ pub const MediaQuery = struct { }; const condition = if (explicit_media_type == null) - switch (MediaCondition.parseWithFlags(input, QueryConditionFlags{ .allow_or = true })) { + switch (MediaCondition.parseWithFlags(input, .{ .allow_or = true })) { .result => |v| v, .err => |e| return .{ .err = e }, } else if (input.tryParse(css.Parser.expectIdentMatching, .{"and"}).isOk()) - switch (MediaCondition.parseWithFlags(input, QueryConditionFlags.empty())) { + switch (MediaCondition.parseWithFlags(input, .{})) { .result => |v| v, .err => |e| return .{ .err = e }, } @@ -274,8 +274,6 @@ pub const QueryConditionFlags = packed struct(u8) { /// Whether to allow style container queries. allow_style: bool = false, __unused: u6 = 0, - - pub usingnamespace css.Bitflags(@This()); }; pub fn toCssWithParensIfNeeded( @@ -488,7 +486,7 @@ pub fn parseQueryCondition( if (bun.strings.eqlCaseInsensitiveASCIIICheckLength(ident, "not")) break :brk .{ true, false }; }, .function => |f| { - if (flags.contains(QueryConditionFlags{ .allow_style = true }) and + if (flags.allow_style and bun.strings.eqlCaseInsensitiveASCIIICheckLength(f, "style")) { break :brk .{ false, true }; @@ -536,7 +534,7 @@ pub fn parseQueryCondition( else return .{ .result = first_condition }; - if (!flags.contains(QueryConditionFlags{ .allow_or = true }) and operator == .@"or") { + if (!flags.allow_or and operator == .@"or") { return .{ .err = location.newUnexpectedTokenError(css.Token{ .ident = "or" }) }; } @@ -587,7 +585,7 @@ pub fn parseParensOrFunction( switch (t.*) { .open_paren => return parseParenBlock(QueryCondition, input, flags), .function => |f| { - if (flags.contains(QueryConditionFlags{ .allow_style = true }) and + if (flags.allow_style and bun.strings.eqlCaseInsensitiveASCIIICheckLength(f, "style")) { return QueryCondition.parseStyleQuery(input); @@ -708,7 +706,7 @@ pub const MediaFeatureId = enum { /// The non-standard -moz-device-pixel-ratio media feature. @"-moz-device-pixel-ratio", - pub usingnamespace css.DeriveValueType(@This(), ValueTypeMap); + pub const valueType = css.DeriveValueType(@This(), ValueTypeMap).valueType; pub const ValueTypeMap = .{ .width = MediaFeatureType.length, diff --git a/src/css/prefixes.zig b/src/css/prefixes.zig index dfb384fe54..a653596f1a 100644 --- a/src/css/prefixes.zig +++ b/src/css/prefixes.zig @@ -196,1956 +196,1956 @@ pub const Feature = enum { .border_radius, .border_top_left_radius, .border_top_right_radius, .border_bottom_right_radius, .border_bottom_left_radius => { if (browsers.android) |version| { if (version <= 131328) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.chrome) |version| { if (version <= 262144) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.firefox) |version| { if (version >= 131072 and version <= 198144) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .moz = true }); + prefixes.moz = true; } } if (browsers.ios_saf) |version| { if (version <= 197120) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 196864 and version <= 262144) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .box_shadow => { if (browsers.android) |version| { if (version >= 131328 and version <= 196608) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.chrome) |version| { if (version >= 262144 and version <= 589824) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.firefox) |version| { if (version >= 197888 and version <= 198144) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .moz = true }); + prefixes.moz = true; } } if (browsers.ios_saf) |version| { if (version >= 197120 and version <= 262656) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 196864 and version <= 327680) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .animation, .animation_name, .animation_duration, .animation_delay, .animation_direction, .animation_fill_mode, .animation_iteration_count, .animation_play_state, .animation_timing_function, .at_keyframes => { if (browsers.android) |version| { if (version >= 131328 and version <= 263171) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.chrome) |version| { if (version >= 262144 and version <= 2752512) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.firefox) |version| { if (version >= 327680 and version <= 983040) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .moz = true }); + prefixes.moz = true; } } if (browsers.ios_saf) |version| { if (version >= 197120 and version <= 524544) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.opera) |version| { if (version == 786432) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .o = true }); + prefixes.o = true; } if (version >= 983040 and version <= 1900544) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 262144 and version <= 524288) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .transition, .transition_property, .transition_duration, .transition_delay, .transition_timing_function => { if (browsers.android) |version| { if (version >= 131328 and version <= 262656) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.chrome) |version| { if (version >= 262144 and version <= 1638400) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.firefox) |version| { if (version >= 262144 and version <= 983040) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .moz = true }); + prefixes.moz = true; } } if (browsers.ios_saf) |version| { if (version >= 197120 and version <= 393216) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.opera) |version| { if (version >= 655360 and version <= 786432) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .o = true }); + prefixes.o = true; } } if (browsers.safari) |version| { if (version >= 196864 and version <= 393216) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .transform, .transform_origin => { if (browsers.android) |version| { if (version >= 131328 and version <= 263171) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.chrome) |version| { if (version >= 262144 and version <= 2293760) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.firefox) |version| { if (version >= 197888 and version <= 983040) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .moz = true }); + prefixes.moz = true; } } if (browsers.ie) |version| { if (version <= 589824) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .ms = true }); + prefixes.ms = true; } } if (browsers.ios_saf) |version| { if (version >= 197120 and version <= 524544) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.opera) |version| { if (version >= 656640 and version <= 786432) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .o = true }); + prefixes.o = true; } if (version >= 983040 and version <= 1441792) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 196864 and version <= 524288) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .perspective, .perspective_origin, .transform_style => { if (browsers.android) |version| { if (version >= 196608 and version <= 263171) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.chrome) |version| { if (version >= 786432 and version <= 2293760) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.firefox) |version| { if (version >= 655360 and version <= 983040) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .moz = true }); + prefixes.moz = true; } } if (browsers.ios_saf) |version| { if (version >= 197120 and version <= 524544) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.opera) |version| { if (version >= 983040 and version <= 1441792) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 262144 and version <= 524288) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .backface_visibility => { if (browsers.android) |version| { if (version >= 196608 and version <= 263171) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.chrome) |version| { if (version >= 786432 and version <= 2293760) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.firefox) |version| { if (version >= 655360 and version <= 983040) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .moz = true }); + prefixes.moz = true; } } if (browsers.ios_saf) |version| { if (version >= 197120 and version <= 983552) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.opera) |version| { if (version >= 983040 and version <= 1441792) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 262144 and version <= 983552) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .linear_gradient, .repeating_linear_gradient, .radial_gradient, .repeating_radial_gradient => { if (browsers.android) |version| { if (version >= 131328 and version <= 262656) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.chrome) |version| { if (version >= 262144 and version <= 1638400) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.firefox) |version| { if (version >= 198144 and version <= 983040) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .moz = true }); + prefixes.moz = true; } } if (browsers.ios_saf) |version| { if (version >= 197120 and version <= 393216) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.opera) |version| { if (version >= 721152 and version <= 786432) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .o = true }); + prefixes.o = true; } } if (browsers.safari) |version| { if (version >= 262144 and version <= 393216) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .box_sizing => { if (browsers.android) |version| { if (version >= 131328 and version <= 196608) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.chrome) |version| { if (version >= 262144 and version <= 589824) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.firefox) |version| { if (version >= 131072 and version <= 1835008) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .moz = true }); + prefixes.moz = true; } } if (browsers.ios_saf) |version| { if (version >= 197120 and version <= 262656) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 196864 and version <= 327680) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .filter => { if (browsers.android) |version| { if (version >= 263168 and version <= 263171) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.chrome) |version| { if (version >= 1179648 and version <= 3407872) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.ios_saf) |version| { if (version >= 393216 and version <= 589824) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.opera) |version| { if (version >= 983040 and version <= 2555904) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 393216 and version <= 589824) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.samsung) |version| { if (version >= 262144 and version <= 393728) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .filter_function => { if (browsers.ios_saf) |version| { if (version >= 589824 and version <= 590592) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version <= 589824) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .backdrop_filter => { if (browsers.edge) |version| { if (version >= 1114112 and version <= 1179648) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.ios_saf) |version| { if (version >= 589824 and version <= 1115648) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 589824 and version <= 1115648) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .element => { if (browsers.firefox) |version| { if (version >= 131072 and version <= 8650752) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .moz = true }); + prefixes.moz = true; } } }, .columns, .column_width, .column_gap, .column_rule, .column_rule_color, .column_rule_width, .column_count, .column_rule_style, .column_span, .column_fill => { if (browsers.android) |version| { if (version >= 131328 and version <= 263171) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.chrome) |version| { if (version >= 262144 and version <= 3211264) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.firefox) |version| { if (version >= 131072 and version <= 3342336) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .moz = true }); + prefixes.moz = true; } } if (browsers.ios_saf) |version| { if (version >= 197120 and version <= 524544) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.opera) |version| { if (version >= 983040 and version <= 2359296) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 196864 and version <= 524288) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.samsung) |version| { if (version <= 262144) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .break_before, .break_after, .break_inside => { if (browsers.android) |version| { if (version >= 131328 and version <= 263171) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.chrome) |version| { if (version >= 262144 and version <= 3211264) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.ios_saf) |version| { if (version >= 197120 and version <= 524544) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.opera) |version| { if (version >= 983040 and version <= 2359296) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 196864 and version <= 524288) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.samsung) |version| { if (version <= 262144) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .user_select => { if (browsers.android) |version| { if (version >= 131328 and version <= 263171) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.chrome) |version| { if (version >= 262144 and version <= 3473408) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.edge) |version| { if (version >= 786432 and version <= 1179648) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .ms = true }); + prefixes.ms = true; } } if (browsers.firefox) |version| { if (version >= 131072 and version <= 4456448) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .moz = true }); + prefixes.moz = true; } } if (browsers.ie) |version| { if (version >= 655360) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .ms = true }); + prefixes.ms = true; } } if (browsers.ios_saf) |version| { if (version >= 197120 and version <= 1179648) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.opera) |version| { if (version >= 983040 and version <= 2621440) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 196864 and version <= 1179648) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.samsung) |version| { if (version >= 262144 and version <= 327680) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .display_flex, .inline_flex, .flex, .flex_grow, .flex_shrink, .flex_basis, .flex_direction, .flex_wrap, .flex_flow, .justify_content, .order, .align_items, .align_self, .align_content => { if (browsers.android) |version| { if (version >= 131328 and version <= 262656) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.chrome) |version| { if (version >= 262144 and version <= 1835008) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.firefox) |version| { if (version >= 131072 and version <= 1376256) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .moz = true }); + prefixes.moz = true; } } if (browsers.ie) |version| { if (version == 655360) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .ms = true }); + prefixes.ms = true; } } if (browsers.ios_saf) |version| { if (version >= 197120 and version <= 524544) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.opera) |version| { if (version >= 983040 and version <= 1048576) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 196864 and version <= 524288) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .calc => { if (browsers.chrome) |version| { if (version >= 1245184 and version <= 1638400) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.firefox) |version| { if (version >= 262144 and version <= 983040) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .moz = true }); + prefixes.moz = true; } } if (browsers.ios_saf) |version| { if (version <= 393216) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version <= 393216) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .background_origin, .background_size => { if (browsers.android) |version| { if (version >= 131328 and version <= 131840) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.firefox) |version| { if (version <= 198144) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .moz = true }); + prefixes.moz = true; } } if (browsers.opera) |version| { if (version <= 655360) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .o = true }); + prefixes.o = true; } } }, .background_clip => { if (browsers.android) |version| { if (version >= 262144 and version <= 263171) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.chrome) |version| { if (version >= 262144 and version <= 7798784) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.edge) |version| { if (version >= 786432 and version <= 917504) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .ms = true }); + prefixes.ms = true; } if (version >= 5177344 and version <= 7798784) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.ios_saf) |version| { if (version >= 393216 and version <= 852992) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.opera) |version| { if (version >= 983040 and version <= 6881280) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 262144 and version <= 852224) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.samsung) |version| { if (version >= 262144 and version <= 1572864) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .font_feature_settings, .font_variant_ligatures, .font_language_override => { if (browsers.android) |version| { if (version >= 263168 and version <= 263171) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.chrome) |version| { if (version >= 1048576 and version <= 3080192) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.firefox) |version| { if (version >= 262144 and version <= 2162688) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .moz = true }); + prefixes.moz = true; } } if (browsers.opera) |version| { if (version >= 983040 and version <= 2228224) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.samsung) |version| { if (version <= 262144) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .font_kerning => { if (browsers.android) |version| { if (version <= 263168) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.chrome) |version| { if (version >= 1900544 and version <= 2097152) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.ios_saf) |version| { if (version >= 524288 and version <= 721664) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.opera) |version| { if (version >= 1048576 and version <= 1245184) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 458752 and version <= 589824) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .border_image => { if (browsers.android) |version| { if (version >= 131328 and version <= 262656) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.chrome) |version| { if (version >= 262144 and version <= 917504) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.firefox) |version| { if (version >= 197888 and version <= 917504) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .moz = true }); + prefixes.moz = true; } } if (browsers.ios_saf) |version| { if (version >= 197120 and version <= 327680) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.opera) |version| { if (version >= 720896 and version <= 786688) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .o = true }); + prefixes.o = true; } } if (browsers.safari) |version| { if (version >= 196864 and version <= 327936) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .pseudo_element_selection => { if (browsers.firefox) |version| { if (version >= 131072 and version <= 3997696) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .moz = true }); + prefixes.moz = true; } } }, .pseudo_element_placeholder => { if (browsers.android) |version| { if (version >= 131328 and version <= 263171) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.chrome) |version| { if (version >= 262144 and version <= 3670016) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.edge) |version| { if (version >= 786432 and version <= 1179648) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .ms = true }); + prefixes.ms = true; } } if (browsers.firefox) |version| { if (version >= 1179648 and version <= 3276800) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .moz = true }); + prefixes.moz = true; } } if (browsers.ie) |version| { if (version >= 655360) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .ms = true }); + prefixes.ms = true; } } if (browsers.ios_saf) |version| { if (version >= 262656 and version <= 655360) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.opera) |version| { if (version >= 983040 and version <= 2818048) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 327680 and version <= 655360) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.samsung) |version| { if (version >= 262144 and version <= 393728) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .pseudo_class_placeholder_shown => { if (browsers.firefox) |version| { if (version >= 262144 and version <= 3276800) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .moz = true }); + prefixes.moz = true; } } if (browsers.ie) |version| { if (version >= 655360) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .ms = true }); + prefixes.ms = true; } } }, .hyphens => { if (browsers.edge) |version| { if (version >= 786432 and version <= 1179648) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .ms = true }); + prefixes.ms = true; } } if (browsers.firefox) |version| { if (version >= 393216 and version <= 2752512) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .moz = true }); + prefixes.moz = true; } } if (browsers.ie) |version| { if (version >= 655360) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .ms = true }); + prefixes.ms = true; } } if (browsers.ios_saf) |version| { if (version >= 262656 and version <= 1050112) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 327936 and version <= 1050112) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .pseudo_class_fullscreen => { if (browsers.chrome) |version| { if (version >= 983040 and version <= 4587520) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.firefox) |version| { if (version >= 655360 and version <= 4128768) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .moz = true }); + prefixes.moz = true; } } if (browsers.ie) |version| { if (version >= 720896) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .ms = true }); + prefixes.ms = true; } } if (browsers.opera) |version| { if (version >= 983040 and version <= 4128768) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 327936 and version <= 1049344) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.samsung) |version| { if (version >= 262144 and version <= 590336) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .pseudo_element_backdrop => { if (browsers.android) |version| { if (version >= 263168 and version <= 263171) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.chrome) |version| { if (version >= 2097152 and version <= 2359296) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.edge) |version| { if (version >= 786432 and version <= 1179648) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .ms = true }); + prefixes.ms = true; } } if (browsers.ie != null) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .ms = true }); + prefixes.ms = true; } if (browsers.opera) |version| { if (version >= 1245184 and version <= 1507328) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .pseudo_element_file_selector_button => { if (browsers.android) |version| { if (version >= 263168 and version <= 263171) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.chrome) |version| { if (version >= 262144 and version <= 5767168) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.edge) |version| { if (version >= 786432 and version <= 1179648) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .ms = true }); + prefixes.ms = true; } if (version >= 5177344 and version <= 5767168) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.ie) |version| { if (version >= 655360) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .ms = true }); + prefixes.ms = true; } } if (browsers.ios_saf) |version| { if (version >= 197120 and version <= 917504) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.opera) |version| { if (version >= 983040 and version <= 4849664) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 196864 and version <= 917504) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.samsung) |version| { if (version >= 262144 and version <= 917504) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .pseudo_class_autofill => { if (browsers.android) |version| { if (version >= 263168 and version <= 263171) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.chrome) |version| { if (version >= 262144 and version <= 7143424) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.edge) |version| { if (version >= 5177344 and version <= 7143424) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.ios_saf) |version| { if (version >= 197120 and version <= 918784) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.opera) |version| { if (version >= 983040 and version <= 6225920) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 196864 and version <= 917760) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.samsung) |version| { if (version >= 262144 and version <= 1310720) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .tab_size => { if (browsers.firefox) |version| { if (version >= 262144 and version <= 5898240) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .moz = true }); + prefixes.moz = true; } } if (browsers.opera) |version| { if (version >= 656896 and version <= 786688) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .o = true }); + prefixes.o = true; } } }, .max_content, .min_content => { if (browsers.android) |version| { if (version >= 263168 and version <= 263171) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.chrome) |version| { if (version >= 1441792 and version <= 2949120) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.firefox) |version| { if (version >= 196608 and version <= 4259840) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .moz = true }); + prefixes.moz = true; } } if (browsers.ios_saf) |version| { if (version >= 458752 and version <= 852992) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.opera) |version| { if (version >= 983040 and version <= 2097152) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 393472 and version <= 655616) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.samsung) |version| { if (version <= 262144) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .fill, .fill_available => { if (browsers.chrome) |version| { if (version >= 1441792 and version <= 8519680) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.android) |version| { if (version >= 263168 and version <= 8323072) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.edge) |version| { if (version >= 5177344 and version <= 8323072) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.firefox) |version| { if (version >= 196608 and version <= 4259840) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .moz = true }); + prefixes.moz = true; } } if (browsers.ios_saf) |version| { if (version >= 458752 and version <= 852992) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.opera) |version| { if (version >= 983040) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 393472 and version <= 655616) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.samsung) |version| { if (version >= 262144 and version <= 1638400) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .fit_content => { if (browsers.android) |version| { if (version >= 263168 and version <= 263171) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.chrome) |version| { if (version >= 1441792 and version <= 2949120) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.firefox) |version| { if (version >= 196608 and version <= 6094848) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .moz = true }); + prefixes.moz = true; } } if (browsers.ios_saf) |version| { if (version >= 458752 and version <= 852992) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.opera) |version| { if (version >= 983040 and version <= 2097152) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 393472 and version <= 655616) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.samsung) |version| { if (version <= 262144) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .stretch => { if (browsers.chrome) |version| { if (version >= 1441792 and version <= 8519680) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.firefox) |version| { if (version >= 196608 and version <= 8650752) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .moz = true }); + prefixes.moz = true; } } if (browsers.android) |version| { if (version >= 263168 and version <= 8323072) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.edge) |version| { if (version >= 5177344 and version <= 8323072) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.ios_saf) |version| { if (version >= 458752 and version <= 1179648) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.opera) |version| { if (version >= 983040) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 458752 and version <= 1179648) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.samsung) |version| { if (version >= 327680 and version <= 1638400) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .zoom_in, .zoom_out => { if (browsers.chrome) |version| { if (version >= 262144 and version <= 2359296) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.firefox) |version| { if (version >= 131072 and version <= 1507328) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .moz = true }); + prefixes.moz = true; } } if (browsers.opera) |version| { if (version >= 983040 and version <= 1507328) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 196864 and version <= 524288) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .grab, .grabbing => { if (browsers.chrome) |version| { if (version >= 262144 and version <= 4390912) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.firefox) |version| { if (version >= 131072 and version <= 1703936) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .moz = true }); + prefixes.moz = true; } } if (browsers.opera) |version| { if (version >= 983040 and version <= 3538944) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 196864 and version <= 655616) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .sticky => { if (browsers.ios_saf) |version| { if (version >= 393216 and version <= 786944) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 393472 and version <= 786688) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .touch_action => { if (browsers.ie) |version| { if (version == 655360) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .ms = true }); + prefixes.ms = true; } } }, .text_decoration_skip, .text_decoration_skip_ink => { if (browsers.ios_saf) |version| { if (version >= 524288 and version <= 1179648) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 459008 and version <= 786432) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .text_decoration => { if (browsers.ios_saf) |version| { if (version >= 524288 and version <= 1179648) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 524288 and version <= 1179648) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .text_decoration_color, .text_decoration_line, .text_decoration_style => { if (browsers.firefox) |version| { if (version >= 393216 and version <= 2293760) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .moz = true }); + prefixes.moz = true; } } if (browsers.ios_saf) |version| { if (version >= 524288 and version <= 786432) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 524288 and version <= 786432) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .text_size_adjust => { if (browsers.firefox) |version| { if (version <= 8323072) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .moz = true }); + prefixes.moz = true; } } if (browsers.edge) |version| { if (version >= 786432 and version <= 1179648) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .ms = true }); + prefixes.ms = true; } } if (browsers.ie) |version| { if (version >= 655360) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .ms = true }); + prefixes.ms = true; } } if (browsers.ios_saf) |version| { if (version >= 327680 and version <= 1179648) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .mask_clip, .mask_composite, .mask_image, .mask_origin, .mask_repeat, .mask_border_repeat, .mask_border_source, .mask, .mask_position, .mask_size, .mask_border, .mask_border_outset, .mask_border_width, .mask_border_slice => { if (browsers.android) |version| { if (version >= 131328 and version <= 263171) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.chrome) |version| { if (version >= 262144 and version <= 7798784) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.edge) |version| { if (version >= 5177344 and version <= 7798784) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.ios_saf) |version| { if (version >= 197120 and version <= 983552) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.opera) |version| { if (version >= 983040 and version <= 6881280) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 262144 and version <= 983552) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.samsung) |version| { if (version >= 262144 and version <= 1572864) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .clip_path => { if (browsers.android) |version| { if (version >= 263168 and version <= 263171) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.chrome) |version| { if (version >= 1572864 and version <= 3538944) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.ios_saf) |version| { if (version >= 458752 and version <= 589824) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.opera) |version| { if (version >= 983040 and version <= 2686976) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 458752 and version <= 589824) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.samsung) |version| { if (version >= 262144 and version <= 327680) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .box_decoration_break => { if (browsers.chrome) |version| { if (version >= 1441792 and version <= 8519680) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.android) |version| { if (version >= 263168 and version <= 8323072) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.edge) |version| { if (version >= 5177344 and version <= 8323072) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.ios_saf) |version| { if (version >= 458752 and version <= 1179648) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.opera) |version| { if (version >= 983040) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 393472 and version <= 1179648) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.samsung) |version| { if (version >= 262144 and version <= 1638400) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .object_fit, .object_position => { if (browsers.opera) |version| { if (version >= 656896 and version <= 786688) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .o = true }); + prefixes.o = true; } } }, .shape_margin, .shape_outside, .shape_image_threshold => { if (browsers.ios_saf) |version| { if (version >= 524288 and version <= 655360) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 459008 and version <= 655360) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .text_overflow => { if (browsers.opera) |version| { if (version >= 589824 and version <= 786432) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .o = true }); + prefixes.o = true; } } }, .at_viewport => { if (browsers.edge) |version| { if (version >= 786432 and version <= 1179648) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .ms = true }); + prefixes.ms = true; } } if (browsers.ie) |version| { if (version >= 655360) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .ms = true }); + prefixes.ms = true; } } if (browsers.opera) |version| { if (version >= 720896 and version <= 786688) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .o = true }); + prefixes.o = true; } } }, .at_resolution => { if (browsers.android) |version| { if (version >= 131840 and version <= 262656) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.chrome) |version| { if (version >= 262144 and version <= 1835008) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.firefox) |version| { if (version >= 197888 and version <= 983040) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .moz = true }); + prefixes.moz = true; } } if (browsers.ios_saf) |version| { if (version >= 262144 and version <= 984576) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.opera) |version| { if (version >= 591104 and version <= 786432) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .o = true }); + prefixes.o = true; } } if (browsers.safari) |version| { if (version >= 262144 and version <= 984576) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .text_align_last => { if (browsers.firefox) |version| { if (version >= 786432 and version <= 3145728) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .moz = true }); + prefixes.moz = true; } } }, .pixelated => { if (browsers.firefox) |version| { if (version >= 198144 and version <= 4194304) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .moz = true }); + prefixes.moz = true; } } if (browsers.ios_saf) |version| { if (version >= 327680 and version <= 393216) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.opera) |version| { if (version >= 722432 and version <= 786688) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .o = true }); + prefixes.o = true; } } if (browsers.safari) |version| { if (version <= 393216) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .image_rendering => { if (browsers.ie) |version| { if (version >= 458752) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .ms = true }); + prefixes.ms = true; } } }, .border_inline_start, .border_inline_end, .margin_inline_start, .margin_inline_end, .padding_inline_start, .padding_inline_end => { if (browsers.android) |version| { if (version >= 131328 and version <= 263171) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.chrome) |version| { if (version >= 262144 and version <= 4456448) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.firefox) |version| { if (version >= 196608 and version <= 2621440) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .moz = true }); + prefixes.moz = true; } } if (browsers.ios_saf) |version| { if (version >= 197120 and version <= 786432) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.opera) |version| { if (version >= 983040 and version <= 3604480) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 196864 and version <= 786432) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.samsung) |version| { if (version >= 262144 and version <= 590336) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .border_block_start, .border_block_end, .margin_block_start, .margin_block_end, .padding_block_start, .padding_block_end => { if (browsers.android) |version| { if (version >= 131328 and version <= 263171) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.chrome) |version| { if (version >= 262144 and version <= 4456448) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.ios_saf) |version| { if (version >= 197120 and version <= 786432) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.opera) |version| { if (version >= 983040 and version <= 3604480) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 196864 and version <= 786432) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.samsung) |version| { if (version >= 262144 and version <= 590336) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .appearance => { if (browsers.android) |version| { if (version >= 131328 and version <= 263171) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.chrome) |version| { if (version >= 262144 and version <= 5439488) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.edge) |version| { if (version >= 786432 and version <= 1179648) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .ms = true }); + prefixes.ms = true; } if (version >= 5177344 and version <= 5439488) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.firefox) |version| { if (version >= 131072 and version <= 5177344) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .moz = true }); + prefixes.moz = true; } } if (browsers.ie != null) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .ms = true }); + prefixes.ms = true; } if (browsers.ios_saf) |version| { if (version >= 197120 and version <= 983552) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.opera) |version| { if (version >= 983040 and version <= 4718592) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 196864 and version <= 983552) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.samsung) |version| { if (version >= 262144 and version <= 851968) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .scroll_snap_type, .scroll_snap_coordinate, .scroll_snap_destination, .scroll_snap_points_x, .scroll_snap_points_y => { if (browsers.edge) |version| { if (version >= 786432 and version <= 1179648) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .ms = true }); + prefixes.ms = true; } } if (browsers.ie) |version| { if (version >= 655360) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .ms = true }); + prefixes.ms = true; } } if (browsers.ios_saf) |version| { if (version >= 589824 and version <= 656128) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 589824 and version <= 655616) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .flow_into, .flow_from, .region_fragment => { if (browsers.chrome) |version| { if (version >= 983040 and version <= 1179648) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.edge) |version| { if (version >= 786432 and version <= 1179648) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .ms = true }); + prefixes.ms = true; } } if (browsers.ie) |version| { if (version >= 655360) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .ms = true }); + prefixes.ms = true; } } if (browsers.ios_saf) |version| { if (version >= 458752 and version <= 720896) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 393472 and version <= 720896) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .image_set => { if (browsers.android) |version| { if (version >= 263168 and version <= 263171) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.chrome) |version| { if (version >= 1376256 and version <= 7340032) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.edge) |version| { if (version >= 5177344 and version <= 7340032) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.ios_saf) |version| { if (version >= 393216 and version <= 590592) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.opera) |version| { if (version >= 983040 and version <= 6422528) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 393216 and version <= 590080) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.samsung) |version| { if (version >= 262144 and version <= 1441792) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .writing_mode => { if (browsers.android) |version| { if (version >= 196608 and version <= 263171) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.chrome) |version| { if (version >= 524288 and version <= 3080192) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.ie) |version| { if (version >= 328960) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .ms = true }); + prefixes.ms = true; } } if (browsers.ios_saf) |version| { if (version >= 327680 and version <= 656128) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.opera) |version| { if (version >= 983040 and version <= 2228224) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 327936 and version <= 655616) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.samsung) |version| { if (version <= 262144) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .cross_fade => { if (browsers.chrome) |version| { if (version >= 1114112 and version <= 8519680) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.android) |version| { if (version >= 263168 and version <= 8323072) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.edge) |version| { if (version >= 5177344 and version <= 8323072) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.ios_saf) |version| { if (version >= 327680 and version <= 590592) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.opera) |version| { if (version >= 983040) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 327936 and version <= 590080) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.samsung) |version| { if (version >= 262144 and version <= 1638400) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .pseudo_class_read_only, .pseudo_class_read_write => { if (browsers.firefox) |version| { if (version >= 196608 and version <= 5046272) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .moz = true }); + prefixes.moz = true; } } }, .text_emphasis, .text_emphasis_position, .text_emphasis_style, .text_emphasis_color => { if (browsers.android) |version| { if (version >= 263168 and version <= 263171) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.chrome) |version| { if (version >= 1638400 and version <= 6422528) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.edge) |version| { if (version >= 5177344 and version <= 6422528) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.opera) |version| { if (version >= 983040 and version <= 5570560) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 393472 and version <= 458752) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.samsung) |version| { if (version >= 262144 and version <= 1114112) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .display_grid, .inline_grid, .grid_template_columns, .grid_template_rows, .grid_row_start, .grid_column_start, .grid_row_end, .grid_column_end, .grid_row, .grid_column, .grid_area, .grid_template, .grid_template_areas, .place_self, .grid_column_align, .grid_row_align => { if (browsers.edge) |version| { if (version >= 786432 and version <= 983040) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .ms = true }); + prefixes.ms = true; } } if (browsers.ie) |version| { if (version >= 655360) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .ms = true }); + prefixes.ms = true; } } }, .text_spacing => { if (browsers.edge) |version| { if (version >= 786432 and version <= 1179648) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .ms = true }); + prefixes.ms = true; } } if (browsers.ie) |version| { if (version >= 524288) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .ms = true }); + prefixes.ms = true; } } }, .pseudo_class_any_link => { if (browsers.android) |version| { if (version >= 263168 and version <= 263171) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.chrome) |version| { if (version >= 983040 and version <= 4194304) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.firefox) |version| { if (version >= 196608 and version <= 3211264) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .moz = true }); + prefixes.moz = true; } } if (browsers.ios_saf) |version| { if (version >= 393216 and version <= 524544) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.opera) |version| { if (version >= 983040 and version <= 3342336) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 393472 and version <= 524288) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.samsung) |version| { if (version >= 327680 and version <= 524800) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .isolate => { if (browsers.chrome) |version| { if (version >= 1048576 and version <= 3080192) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.firefox) |version| { if (version >= 655360 and version <= 3211264) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .moz = true }); + prefixes.moz = true; } } if (browsers.ios_saf) |version| { if (version >= 393216 and version <= 656128) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.opera) |version| { if (version >= 983040 and version <= 2228224) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 393216 and version <= 655616) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .plaintext => { if (browsers.firefox) |version| { if (version >= 655360 and version <= 3211264) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .moz = true }); + prefixes.moz = true; } } if (browsers.ios_saf) |version| { if (version >= 393216 and version <= 656128) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 393216 and version <= 655616) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .isolate_override => { if (browsers.firefox) |version| { if (version >= 1114112 and version <= 3211264) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .moz = true }); + prefixes.moz = true; } } if (browsers.ios_saf) |version| { if (version >= 458752 and version <= 656128) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 458752 and version <= 655616) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .overscroll_behavior => { if (browsers.edge) |version| { if (version >= 786432 and version <= 1114112) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .ms = true }); + prefixes.ms = true; } } if (browsers.ie) |version| { if (version >= 655360) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .ms = true }); + prefixes.ms = true; } } }, .text_orientation => { if (browsers.safari) |version| { if (version >= 655616 and version <= 852224) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .print_color_adjust, .color_adjust => { if (browsers.chrome) |version| { if (version >= 1114112 and version <= 8519680) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.android) |version| { if (version >= 263168 and version <= 8323072) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.edge) |version| { if (version >= 5177344 and version <= 8323072) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.firefox) |version| { if (version >= 3145728 and version <= 6291456) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .moz = true }); + prefixes.moz = true; } } if (browsers.ios_saf) |version| { if (version >= 393216 and version <= 983552) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.opera) |version| { if (version >= 983040) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 393216 and version <= 983552) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.samsung) |version| { if (version >= 262144 and version <= 1638400) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, .any_pseudo => { if (browsers.chrome) |version| { if (version >= 786432 and version <= 5701632) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.edge) |version| { if (version >= 5177344 and version <= 5701632) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.firefox) |version| { if (version >= 262144 and version <= 5111808) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .moz = true }); + prefixes.moz = true; } } if (browsers.opera) |version| { if (version >= 917504 and version <= 4784128) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.safari) |version| { if (version >= 327680 and version <= 851968) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.ios_saf) |version| { if (version >= 327680 and version <= 851968) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.samsung) |version| { if (version >= 65536 and version <= 917504) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } if (browsers.android) |version| { if (version >= 2424832 and version <= 5701632) { - prefixes = prefixes.bitwiseOr(VendorPrefix{ .webkit = true }); + prefixes.webkit = true; } } }, diff --git a/src/css/printer.zig b/src/css/printer.zig index 62ed3766fc..f5d5053bd9 100644 --- a/src/css/printer.zig +++ b/src/css/printer.zig @@ -122,7 +122,7 @@ pub fn Printer(comptime Writer: type) type { col: u32 = 0, minify: bool, targets: Targets, - vendor_prefix: css.VendorPrefix = css.VendorPrefix.empty(), + vendor_prefix: css.VendorPrefix = .{}, in_calc: bool = false, css_module: ?css.CssModule = null, dependencies: ?ArrayList(css.Dependency) = null, diff --git a/src/css/properties/align.zig b/src/css/properties/align.zig index 95ddaa1bc0..f8ce2c51ec 100644 --- a/src/css/properties/align.zig +++ b/src/css/properties/align.zig @@ -57,8 +57,8 @@ pub const AlignContent = union(enum) { } }, - pub usingnamespace css.DeriveParse(@This()); - pub usingnamespace css.DeriveToCss(@This()); + pub const parse = css.DeriveParse(@This()).parse; + pub const toCss = css.DeriveToCss(@This()).toCss; pub fn eql(lhs: *const @This(), rhs: *const @This()) bool { return css.implementEql(@This(), lhs, rhs); @@ -300,8 +300,8 @@ pub const AlignSelf = union(enum) { } }, - pub usingnamespace css.DeriveParse(@This()); - pub usingnamespace css.DeriveToCss(@This()); + pub const parse = css.DeriveParse(@This()).parse; + pub const toCss = css.DeriveToCss(@This()).toCss; pub fn deepClone(this: *const @This(), allocator: std.mem.Allocator) @This() { return css.implementDeepClone(@This(), this, allocator); @@ -494,8 +494,8 @@ pub const AlignItems = union(enum) { } }, - pub usingnamespace css.DeriveParse(@This()); - pub usingnamespace css.DeriveToCss(@This()); + pub const parse = css.DeriveParse(@This()).parse; + pub const toCss = css.DeriveToCss(@This()).toCss; pub fn eql(lhs: *const @This(), rhs: *const @This()) bool { return css.implementEql(@This(), lhs, rhs); @@ -728,8 +728,8 @@ pub const GapValue = union(enum) { /// An explicit length. length_percentage: LengthPercentage, - pub usingnamespace css.DeriveParse(@This()); - pub usingnamespace css.DeriveToCss(@This()); + pub const parse = css.DeriveParse(@This()).parse; + pub const toCss = css.DeriveToCss(@This()).toCss; pub fn eql(lhs: *const @This(), rhs: *const @This()) bool { return css.implementEql(@This(), lhs, rhs); @@ -747,8 +747,6 @@ pub const Gap = struct { /// The column gap. column: GapValue, - pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.gap, PropertyFieldMap); - pub const PropertyFieldMap = .{ .row = "row-gap", .column = "column-gap", @@ -790,8 +788,6 @@ pub const PlaceItems = struct { /// The item justification. justify: JustifyItems, - pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.@"place-items", PropertyFieldMap); - pub const PropertyFieldMap = .{ .@"align" = "align-items", .justify = "justify-items", @@ -862,8 +858,6 @@ pub const PlaceSelf = struct { /// The item justification. justify: JustifySelf, - pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.@"place-self", PropertyFieldMap); - pub const PropertyFieldMap = .{ .@"align" = "align-self", .justify = "justify-self", @@ -946,7 +940,12 @@ pub const SelfPosition = enum { /// Item is aligned to the end of the container, within flexbox layouts. @"flex-end", - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; }; /// A value for the [place-content](https://www.w3.org/TR/css-align-3/#place-content) shorthand property. @@ -956,8 +955,6 @@ pub const PlaceContent = struct { /// The content justification. justify: JustifyContent, - pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.@"place-content", PropertyFieldMap); - pub const PropertyFieldMap = .{ .@"align" = css.PropertyIdTag.@"align-content", .justify = css.PropertyIdTag.@"justify-content", @@ -1036,7 +1033,12 @@ pub const ContentDistribution = enum { /// Items are stretched evenly to fill free space. stretch, - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; }; /// An [``](https://www.w3.org/TR/css-align-3/#typedef-overflow-position) value. @@ -1048,7 +1050,12 @@ pub const OverflowPosition = enum { /// container, the given alignment value is honored. unsafe, - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; }; /// A [``](https://www.w3.org/TR/css-align-3/#typedef-content-position) value. @@ -1064,7 +1071,12 @@ pub const ContentPosition = enum { /// Same as `end` when within a flexbox container. @"flex-end", - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; }; pub const SelfPositionInner = struct { @@ -1280,7 +1292,7 @@ pub const AlignHandler = struct { // If two vendor prefixes for the same property have different // values, we need to flush what we have immediately to preserve order. if (@field(this, prop)) |*v| { - if (!val.eql(&v[0]) and !v[1].contains(vp)) { + if (!val.eql(&v[0]) and !bun.bits.contains(VendorPrefix, v[1], vp)) { this.flush(dest, context); } } @@ -1291,7 +1303,7 @@ pub const AlignHandler = struct { // Otherwise, update the value and add the prefix. if (@field(this, prop)) |*tuple| { tuple.*[0] = css.generic.deepClone(@TypeOf(val.*), val, context.allocator); - tuple.*[1].insert(vp); + bun.bits.insert(VendorPrefix, &tuple.*[1], vp); } else { @field(this, prop) = .{ css.generic.deepClone(@TypeOf(val.*), val, context.allocator), vp }; this.has_any = true; @@ -1303,10 +1315,8 @@ pub const AlignHandler = struct { var prefix = context.targets.prefixes(VendorPrefix.NONE, feature); // Firefox only implemented the 2009 spec prefixed. // Microsoft only implemented the 2012 spec prefixed. - prefix.remove(VendorPrefix{ - .moz = true, - .ms = true, - }); + prefix.moz = false; + prefix.ms = false; return prefix; } @@ -1315,7 +1325,7 @@ pub const AlignHandler = struct { const val = v[0]; var prefix = v[1]; // If we have an unprefixed property, override necessary prefixes. - prefix = if (prefix.contains(VendorPrefix.NONE)) flushPrefixesHelper(this, context, feature) else prefix; + prefix = if (prefix.none) flushPrefixesHelper(this, context, feature) else prefix; dest.append(context.allocator, @unionInit(Property, prop, .{ val, prefix })) catch bun.outOfMemory(); } } @@ -1336,16 +1346,16 @@ pub const AlignHandler = struct { // If we have an unprefixed standard property, generate legacy prefixed versions. prefix = context.targets.prefixes(prefix, feature); - if (prefix.contains(VendorPrefix.NONE)) { + if (prefix.none) { if (comptime prop_2009) |p2009| { // 2009 spec, implemented by webkit and firefox. if (context.targets.browsers) |targets| { - var prefixes_2009 = VendorPrefix.empty(); + var prefixes_2009 = VendorPrefix{}; if (Feature.isFlex2009(targets)) { - prefixes_2009.insert(VendorPrefix.WEBKIT); + prefixes_2009.webkit = true; } - if (prefix.contains(VendorPrefix.MOZ)) { - prefixes_2009.insert(VendorPrefix.MOZ); + if (prefix.moz) { + prefixes_2009.moz = true; } if (!prefixes_2009.isEmpty()) { const s = brk: { @@ -1365,7 +1375,7 @@ pub const AlignHandler = struct { } // 2012 spec, implemented by microsoft. - if (prefix.contains(VendorPrefix.MS)) { + if (prefix.ms) { if (comptime prop_2012) |p2012| { const s = brk: { const T = comptime p2012[0]; @@ -1382,8 +1392,8 @@ pub const AlignHandler = struct { } // Remove Firefox and IE from standard prefixes. - prefix.remove(VendorPrefix.MOZ); - prefix.remove(VendorPrefix.MS); + prefix.moz = false; + prefix.ms = false; } } @@ -1429,10 +1439,10 @@ pub const AlignHandler = struct { const intersection = align_prefix.bitwiseAnd(if (comptime justify_prop != null) __v2.*[1] else align_prefix.*); // Only use shorthand if unprefixed. - if (intersection.contains(VendorPrefix.NONE)) { + if (intersection.none) { // Add prefixed longhands if needed. align_prefix.* = flushPrefixesHelper(this, context, align_prop.feature); - align_prefix.remove(VendorPrefix.NONE); + align_prefix.none = false; if (!align_prefix.isEmpty()) { dest.append( context.allocator, @@ -1444,7 +1454,7 @@ pub const AlignHandler = struct { const justify_actual = &__v2.*[0]; const justify_prefix = &__v2.*[1]; justify_prefix.* = this.flushPrefixesHelper(context, justify_prop.?.feature); - justify_prefix.remove(css.VendorPrefix.NONE); + justify_prefix.none = false; if (!justify_prefix.isEmpty()) { dest.append( diff --git a/src/css/properties/animation.zig b/src/css/properties/animation.zig index c5b23c17da..3d8a5d9ca1 100644 --- a/src/css/properties/animation.zig +++ b/src/css/properties/animation.zig @@ -46,8 +46,6 @@ pub const Animation = struct { /// The animation timeline. timeline: AnimationTimeline, - pub usingnamespace css.DefineListShorthand(@This()); - pub const PropertyFieldMap = .{ .name = css.PropertyIdTag.@"animation-name", .duration = css.PropertyIdTag.@"animation-duration", @@ -288,8 +286,8 @@ pub const AnimationIterationCount = union(enum) { /// The animation will repeat forever. infinite, - pub usingnamespace css.DeriveParse(@This()); - pub usingnamespace css.DeriveToCss(@This()); + pub const parse = css.DeriveParse(@This()).parse; + pub const toCss = css.DeriveToCss(@This()).toCss; pub fn default() AnimationIterationCount { return .{ .number = 1.0 }; @@ -311,7 +309,12 @@ pub const AnimationDirection = enum { /// The animation iterations alternate between forward and reverse, with reverse occurring first. @"alternate-reverse", - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; pub fn default() AnimationDirection { return .normal; @@ -325,7 +328,12 @@ pub const AnimationPlayState = enum { /// The animation is paused. paused, - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; pub fn default() AnimationPlayState { return .running; @@ -343,7 +351,12 @@ pub const AnimationFillMode = enum { /// Both forwards and backwards apply. both, - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; pub fn default() AnimationFillMode { return .none; @@ -359,7 +372,12 @@ pub const AnimationComposition = enum { /// The effect value is accumulated onto the underlying value. accumulate, - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; }; /// A value for the [animation-timeline](https://drafts.csswg.org/css-animations-2/#animation-timeline) property. @@ -375,8 +393,8 @@ pub const AnimationTimeline = union(enum) { /// The view() function. view: ViewTimeline, - pub usingnamespace css.DeriveParse(@This()); - pub usingnamespace css.DeriveToCss(@This()); + pub const parse = css.DeriveParse(@This()).parse; + pub const toCss = css.DeriveToCss(@This()).toCss; pub fn eql(lhs: *const @This(), rhs: *const @This()) bool { return css.implementEql(@This(), lhs, rhs); @@ -412,7 +430,12 @@ pub const Scroller = enum { /// Specifies to use the element's own principal box as the scroll container. self, - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; pub fn default() Scroller { return .nearest; @@ -430,7 +453,12 @@ pub const ScrollAxis = enum { /// Specifies to use the measure of progress along the vertical axis of the scroll container. y, - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; pub fn default() ScrollAxis { return .block; diff --git a/src/css/properties/background.zig b/src/css/properties/background.zig index ded14894f4..4b869b0dc8 100644 --- a/src/css/properties/background.zig +++ b/src/css/properties/background.zig @@ -234,7 +234,11 @@ pub const Background = struct { } pub fn getNecessaryFallbacks(this: *const @This(), targets: css.targets.Targets) css.ColorFallbackKind { - return this.color.getNecessaryFallbacks(targets).bitwiseOr(this.getImage().getNecessaryFallbacks(targets)); + return bun.bits.@"or"( + css.ColorFallbackKind, + this.color.getNecessaryFallbacks(targets), + this.getImage().getNecessaryFallbacks(targets), + ); } pub inline fn deepClone(this: *const @This(), allocator: Allocator) @This() { @@ -327,8 +331,6 @@ pub const BackgroundPosition = struct { /// The y-position. y: VerticalPosition, - pub usingnamespace css.DefineListShorthand(@This()); - const PropertyFieldMap = .{ .x = css.PropertyIdTag.@"background-position-x", .y = css.PropertyIdTag.@"background-position-y", @@ -448,7 +450,12 @@ pub const BackgroundRepeatKeyword = enum { /// The image is placed once and not repeated in this direction. @"no-repeat", - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; }; /// A value for the [background-attachment](https://www.w3.org/TR/css-backgrounds-3/#background-attachment) property. @@ -460,7 +467,12 @@ pub const BackgroundAttachment = enum { /// The background is fixed with regard to the element's contents. local, - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; pub fn default() @This() { return .scroll; @@ -476,7 +488,12 @@ pub const BackgroundOrigin = enum { /// The position is relative to the content box. @"content-box", - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; }; /// A value for the [background-clip](https://drafts.csswg.org/css-backgrounds-4/#background-clip) property. @@ -492,7 +509,12 @@ pub const BackgroundClip = enum { /// The background is clipped to the text content of the element. text, - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; pub fn default() BackgroundClip { return .@"border-box"; @@ -535,8 +557,6 @@ pub const BackgroundProperty = packed struct(u16) { clip: bool = false, __unused: u7 = 0, - pub usingnamespace css.Bitflags(@This()); - pub const @"background-color" = BackgroundProperty{ .color = true }; pub const @"background-image" = BackgroundProperty{ .image = true }; pub const @"background-position-x" = BackgroundProperty{ .@"position-x" = true }; @@ -560,6 +580,10 @@ pub const BackgroundProperty = packed struct(u16) { .clip = true, }; + pub fn isEmpty(this: @This()) bool { + return bun.bits.asInt(@This(), this) == 0; + } + pub fn tryFromPropertyId(property_id: css.PropertyId) ?BackgroundProperty { return switch (property_id) { .@"background-color" => @"background-color", @@ -646,7 +670,7 @@ pub const BackgroundHandler = struct { if (this.clips) |*clips_and_vp| { var clips: *SmallList(BackgroundClip, 1) = &clips_and_vp.*[0]; const vp: *VendorPrefix = &clips_and_vp.*[1]; - if (!vendor_prefix.eql(vp.*) and !val.eql(clips)) { + if (vendor_prefix != vp.* and !val.eql(clips)) { this.flush(allocator, dest, context); clips.deinit(allocator); this.clips = .{ val.deepClone(allocator), vendor_prefix }; @@ -655,7 +679,7 @@ pub const BackgroundHandler = struct { clips.deinit(allocator); clips.* = val.deepClone(allocator); } - vp.insert(vendor_prefix); + bun.bits.insert(VendorPrefix, vp, vendor_prefix); } } else { this.clips = .{ val.deepClone(allocator), vendor_prefix }; @@ -675,10 +699,10 @@ pub const BackgroundHandler = struct { } var clips_vp = VendorPrefix{ .none = true }; if (this.clips) |*clips_and_vp| { - if (!clips_vp.eql(clips_and_vp.*[1]) and !clips_and_vp.*[0].eql(&clips_and_vp[0])) { + if (clips_vp != clips_and_vp.*[1] and !clips_and_vp.*[0].eql(&clips_and_vp[0])) { this.flush(allocator, dest, context); } else { - clips_vp.insert(clips_and_vp.*[1]); + bun.bits.insert(VendorPrefix, &clips_vp, clips_and_vp.*[1]); } } @@ -718,7 +742,7 @@ pub const BackgroundHandler = struct { var unparsed = val.deepClone(allocator); context.addUnparsedFallbacks(&unparsed); if (BackgroundProperty.tryFromPropertyId(val.property_id)) |prop| { - this.flushed_properties.insert(prop); + bun.bits.insert(BackgroundProperty, &this.flushed_properties, prop); } dest.append(allocator, Property{ .unparsed = unparsed }) catch bun.outOfMemory(); @@ -801,7 +825,7 @@ pub const BackgroundHandler = struct { fn push(self: *BackgroundHandler, alloc: Allocator, d: *css.DeclarationList, comptime property_field_name: []const u8, val: anytype) void { d.append(alloc, @unionInit(Property, property_field_name, val)) catch bun.outOfMemory(); const prop = @field(BackgroundProperty, property_field_name); - self.flushed_properties.insert(prop); + bun.bits.insert(BackgroundProperty, &self.flushed_properties, prop); } }.push; @@ -858,7 +882,7 @@ pub const BackgroundHandler = struct { return clip.* == BackgroundClip.text; } }.predicate)) context.targets.prefixes(clips.*[1], .background_clip) else clips.*[1]; - const clip_property = if (!clip_prefixes.eql(css.VendorPrefix{ .none = true })) + const clip_property = if (clip_prefixes != css.VendorPrefix{ .none = true }) css.Property{ .@"background-clip" = .{ clips.*[0].deepClone(allocator), clip_prefixes } } else null; @@ -883,7 +907,7 @@ pub const BackgroundHandler = struct { .size = size, .attachment = attachment, .origin = origin, - .clip = if (clip_prefixes.eql(css.VendorPrefix{ .none = true })) clip else BackgroundClip.default(), + .clip = if (clip_prefixes == css.VendorPrefix{ .none = true }) clip else BackgroundClip.default(), }); } defer { @@ -897,7 +921,7 @@ pub const BackgroundHandler = struct { clips.*[0].clearRetainingCapacity(); } - if (!this.flushed_properties.intersects(BackgroundProperty.background)) { + if (this.flushed_properties.isEmpty()) { for (backgrounds.getFallbacks(allocator, context.targets).slice()) |fallback| { push(this, allocator, dest, "background", fallback); } @@ -907,7 +931,7 @@ pub const BackgroundHandler = struct { if (clip_property) |clip| { dest.append(allocator, clip) catch bun.outOfMemory(); - this.flushed_properties.insert(BackgroundProperty.@"background-clip"); + this.flushed_properties.clip = true; } this.reset(allocator); @@ -915,9 +939,9 @@ pub const BackgroundHandler = struct { } } - if (bun.take(&maybe_color)) |color_| { - var color: CssColor = color_; - if (!this.flushed_properties.contains(BackgroundProperty.@"background-color")) { + if (bun.take(&maybe_color)) |color_const| { + var color: CssColor = color_const; + if (!this.flushed_properties.color) { for (color.getFallbacks(allocator, context.targets).slice()) |fallback| { push(this, allocator, dest, "background-color", fallback); } @@ -927,7 +951,7 @@ pub const BackgroundHandler = struct { if (bun.take(&maybe_images)) |images_| { var images: css.SmallList(Image, 1) = images_; - if (!this.flushed_properties.contains(BackgroundProperty.@"background-image")) { + if (!this.flushed_properties.image) { var fallbacks = images.getFallbacks(allocator, context.targets); for (fallbacks.slice()) |fallback| { push(this, allocator, dest, "background-image", fallback); @@ -982,7 +1006,7 @@ pub const BackgroundHandler = struct { .@"background-clip" = .{ clips.deepClone(allocator), prefixes }, }, ) catch bun.outOfMemory(); - this.flushed_properties.insert(BackgroundProperty.@"background-clip"); + this.flushed_properties.clip = true; } this.reset(allocator); @@ -1024,7 +1048,7 @@ pub const BackgroundHandler = struct { this.decls.clearRetainingCapacity(); this.flush(allocator, dest, context); - this.flushed_properties = BackgroundProperty.empty(); + this.flushed_properties = BackgroundProperty{}; } }; diff --git a/src/css/properties/border.zig b/src/css/properties/border.zig index 30dad0ed6b..1bdf38ed3c 100644 --- a/src/css/properties/border.zig +++ b/src/css/properties/border.zig @@ -194,7 +194,12 @@ pub const LineStyle = enum { /// Two parallel solid lines with some space between them. double, - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; pub fn isCompatible(_: *const @This(), _: bun.css.targets.Browsers) bool { return true; @@ -216,8 +221,8 @@ pub const BorderSideWidth = union(enum) { /// An explicit width. length: Length, - pub usingnamespace css.DeriveParse(@This()); - pub usingnamespace css.DeriveToCss(@This()); + pub const parse = css.DeriveParse(@This()).parse; + pub const toCss = css.DeriveToCss(@This()).toCss; pub fn isCompatible(this: *const @This(), browsers: bun.css.targets.Browsers) bool { return switch (this.*) { @@ -250,9 +255,11 @@ pub const BorderColor = struct { left: CssColor, // TODO: bring this back - // pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.@"border-color"); - pub usingnamespace css.DefineRectShorthand(@This(), CssColor); - pub usingnamespace ImplFallbacks(@This()); + // (old using name space) css.DefineShorthand(@This(), css.PropertyIdTag.@"border-color"); + const css_impl = css.DefineRectShorthand(@This(), CssColor); + pub const toCss = css_impl.toCss; + pub const parse = css_impl.parse; + pub const getFallbacks = ImplFallbacks(@This()).getFallbacks; pub const PropertyFieldMap = .{ .top = css.PropertyIdTag.@"border-top-color", @@ -278,8 +285,10 @@ pub const BorderStyle = struct { left: LineStyle, // TODO: bring this back - // pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.@"border-style"); - pub usingnamespace css.DefineRectShorthand(@This(), LineStyle); + // (old using name space) css.DefineShorthand(@This(), css.PropertyIdTag.@"border-style"); + const css_impl = css.DefineRectShorthand(@This(), LineStyle); + pub const toCss = css_impl.toCss; + pub const parse = css_impl.parse; pub const PropertyFieldMap = .{ .top = css.PropertyIdTag.@"border-top-style", @@ -305,8 +314,10 @@ pub const BorderWidth = struct { left: BorderSideWidth, // TODO: bring this back - // pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.@"border-width"); - pub usingnamespace css.DefineRectShorthand(@This(), BorderSideWidth); + // (old using name space) css.DefineShorthand(@This(), css.PropertyIdTag.@"border-width"); + const css_impl = css.DefineRectShorthand(@This(), BorderSideWidth); + pub const toCss = css_impl.toCss; + pub const parse = css_impl.parse; pub const PropertyFieldMap = .{ .top = css.PropertyIdTag.@"border-top-width", @@ -333,9 +344,11 @@ pub const BorderBlockColor = struct { end: CssColor, // TODO: bring this back - // pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.@"border-block-color"); - pub usingnamespace css.DefineSizeShorthand(@This(), CssColor); - pub usingnamespace ImplFallbacks(@This()); + // (old using name space) css.DefineShorthand(@This(), css.PropertyIdTag.@"border-block-color"); + const css_impl = css.DefineSizeShorthand(@This(), CssColor); + pub const toCss = css_impl.toCss; + pub const parse = css_impl.parse; + pub const getFallbacks = ImplFallbacks(@This()).getFallbacks; pub const PropertyFieldMap = .{ .start = css.PropertyIdTag.@"border-block-start-color", @@ -359,8 +372,10 @@ pub const BorderBlockStyle = struct { end: LineStyle, // TODO: bring this back - // pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.@"border-block-style"); - pub usingnamespace css.DefineSizeShorthand(@This(), LineStyle); + // (old using name space) css.DefineShorthand(@This(), css.PropertyIdTag.@"border-block-style"); + const css_impl = css.DefineSizeShorthand(@This(), LineStyle); + pub const toCss = css_impl.toCss; + pub const parse = css_impl.parse; pub const PropertyFieldMap = .{ .start = css.PropertyIdTag.@"border-block-start-style", @@ -384,8 +399,10 @@ pub const BorderBlockWidth = struct { end: BorderSideWidth, // TODO: bring this back - // pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.@"border-block-width"); - pub usingnamespace css.DefineSizeShorthand(@This(), BorderSideWidth); + // (old using name space) css.DefineShorthand(@This(), css.PropertyIdTag.@"border-block-width"); + const css_impl = css.DefineSizeShorthand(@This(), BorderSideWidth); + pub const toCss = css_impl.toCss; + pub const parse = css_impl.parse; pub const PropertyFieldMap = .{ .start = css.PropertyIdTag.@"border-block-start-width", @@ -410,9 +427,11 @@ pub const BorderInlineColor = struct { end: CssColor, // TODO: bring this back - // pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.@"border-inline-color"); - pub usingnamespace css.DefineSizeShorthand(@This(), CssColor); - pub usingnamespace ImplFallbacks(@This()); + // (old using name space) css.DefineShorthand(@This(), css.PropertyIdTag.@"border-inline-color"); + const css_impl = css.DefineSizeShorthand(@This(), CssColor); + pub const toCss = css_impl.toCss; + pub const parse = css_impl.parse; + pub const getFallbacks = ImplFallbacks(@This()).getFallbacks; pub const PropertyFieldMap = .{ .start = css.PropertyIdTag.@"border-inline-start-color", @@ -436,8 +455,10 @@ pub const BorderInlineStyle = struct { end: LineStyle, // TODO: bring this back - // pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.@"border-inline-style"); - pub usingnamespace css.DefineSizeShorthand(@This(), LineStyle); + // (old using name space) css.DefineShorthand(@This(), css.PropertyIdTag.@"border-inline-style"); + const css_impl = css.DefineSizeShorthand(@This(), LineStyle); + pub const toCss = css_impl.toCss; + pub const parse = css_impl.parse; pub const PropertyFieldMap = .{ .start = css.PropertyIdTag.@"border-inline-start-style", @@ -461,8 +482,10 @@ pub const BorderInlineWidth = struct { end: BorderSideWidth, // TODO: bring this back - // pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.@"border-inline-width"); - pub usingnamespace css.DefineSizeShorthand(@This(), BorderSideWidth); + // (old using name space) css.DefineShorthand(@This(), css.PropertyIdTag.@"border-inline-width"); + const css_impl = css.DefineSizeShorthand(@This(), BorderSideWidth); + pub const toCss = css_impl.toCss; + pub const parse = css_impl.parse; pub const PropertyFieldMap = .{ .start = css.PropertyIdTag.@"border-inline-start-width", @@ -479,35 +502,36 @@ pub const BorderInlineWidth = struct { }; pub fn ImplFallbacks(comptime T: type) type { - const field_names = std.meta.fieldNames(T); return struct { + const fields = std.meta.fields(T); + pub fn getFallbacks(this: *T, allocator: std.mem.Allocator, targets: css.Targets) css.SmallList(T, 2) { const ColorFallbackKind = css.css_values.color.ColorFallbackKind; - var fallbacks = ColorFallbackKind.empty(); - inline for (field_names) |name| { - fallbacks.insert(@field(this, name).getNecessaryFallbacks(targets)); + var fallbacks = ColorFallbackKind{}; + inline for (fields) |field| { + bun.bits.insert(ColorFallbackKind, &fallbacks, @field(this, field.name).getNecessaryFallbacks(targets)); } var res = css.SmallList(T, 2){}; - if (fallbacks.contains(ColorFallbackKind{ .rgb = true })) { + if (fallbacks.rgb) { var out: T = undefined; - inline for (field_names) |name| { - @field(out, name) = @field(this, name).getFallback(allocator, ColorFallbackKind{ .rgb = true }); + inline for (fields) |field| { + @field(out, field.name) = @field(this, field.name).getFallback(allocator, ColorFallbackKind{ .rgb = true }); } res.append(allocator, out); } - if (fallbacks.contains(ColorFallbackKind{ .p3 = true })) { + if (fallbacks.p3) { var out: T = undefined; - inline for (field_names) |name| { - @field(out, name) = @field(this, name).getFallback(allocator, ColorFallbackKind{ .p3 = true }); + inline for (fields) |field| { + @field(out, field.name) = @field(this, field.name).getFallback(allocator, ColorFallbackKind{ .p3 = true }); } res.append(allocator, out); } - if (fallbacks.contains(ColorFallbackKind{ .lab = true })) { - inline for (field_names) |name| { - @field(this, name) = @field(this, name).getFallback(allocator, ColorFallbackKind{ .lab = true }); + if (fallbacks.lab) { + inline for (fields) |field| { + @field(this, field.name) = @field(this, field.name).getFallback(allocator, ColorFallbackKind{ .lab = true }); } } @@ -577,8 +601,6 @@ const BorderProperty = packed struct(u32) { @"inline-end-style": bool = false, __unused: u8 = 0, - pub usingnamespace css.Bitflags(@This()); - const @"border-top-color" = BorderProperty{ .@"top-color" = true }; const @"border-bottom-color" = BorderProperty{ .@"bottom-color" = true }; const @"border-left-color" = BorderProperty{ .@"left-color" = true }; @@ -855,13 +877,13 @@ pub const BorderHandler = struct { } inline fn push(f: *FlushContext, comptime p: []const u8, val: anytype) void { - f.self.flushed_properties.insert(@field(BorderProperty, p)); + bun.bits.insert(BorderProperty, &f.self.flushed_properties, @field(BorderProperty, p)); f.dest.append(f.ctx.allocator, @unionInit(css.Property, p, val.deepClone(f.ctx.allocator))) catch bun.outOfMemory(); } inline fn fallbacks(f: *FlushContext, comptime p: []const u8, _val: anytype) void { var val = _val; - if (!f.self.flushed_properties.contains(@field(BorderProperty, p))) { + if (!bun.bits.contains(BorderProperty, f.self.flushed_properties, @field(BorderProperty, p))) { const fbs = val.getFallbacks(f.ctx.allocator, f.ctx.targets); for (css.generic.slice(@TypeOf(fbs), &fbs)) |fallback| { f.dest.append(f.ctx.allocator, @unionInit(css.Property, p, fallback)) catch bun.outOfMemory(); @@ -1400,7 +1422,7 @@ pub const BorderHandler = struct { if (logical_supported) { var up = unparsed.deepClone(context.allocator); context.addUnparsedFallbacks(&up); - this.flushed_properties.insert(BorderProperty.tryFromPropertyId(up.property_id).?); + bun.bits.insert(BorderProperty, &this.flushed_properties, BorderProperty.tryFromPropertyId(up.property_id).?); dest.append(context.allocator, .{ .unparsed = up }) catch bun.outOfMemory(); return; } @@ -1410,7 +1432,7 @@ pub const BorderHandler = struct { _ = d; // autofix var upppppppppp = up.withPropertyId(c.allocator, @unionInit(css.PropertyId, id, {})); c.addUnparsedFallbacks(&upppppppppp); - self.flushed_properties.insert(@field(BorderProperty, id)); + bun.bits.insert(BorderProperty, &self.flushed_properties, @field(BorderProperty, id)); } }.prop; @@ -1459,7 +1481,7 @@ pub const BorderHandler = struct { else => { var up = unparsed.deepClone(context.allocator); context.addUnparsedFallbacks(&up); - this.flushed_properties.insert(BorderProperty.tryFromPropertyId(up.property_id).?); + bun.bits.insert(BorderProperty, &this.flushed_properties, BorderProperty.tryFromPropertyId(up.property_id).?); dest.append(context.allocator, .{ .unparsed = up }) catch bun.outOfMemory(); }, } diff --git a/src/css/properties/border_image.zig b/src/css/properties/border_image.zig index 8ef7eb0212..e4f3e678e7 100644 --- a/src/css/properties/border_image.zig +++ b/src/css/properties/border_image.zig @@ -40,8 +40,6 @@ pub const BorderImage = struct { /// How the border image is scaled and tiled. repeat: BorderImageRepeat, - pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.@"border-image", PropertyFieldMap); - pub const PropertyFieldMap = .{ .source = css.PropertyIdTag.@"border-image-source", .slice = css.PropertyIdTag.@"border-image-slice", @@ -274,8 +272,8 @@ pub const BorderImageSideWidth = union(enum) { /// The `auto` keyword, representing the natural width of the image slice. auto: void, - pub usingnamespace css.DeriveParse(@This()); - pub usingnamespace css.DeriveToCss(@This()); + pub const parse = css.DeriveParse(@This()).parse; + pub const toCss = css.DeriveToCss(@This()).toCss; pub fn deinit(this: *const BorderImageSideWidth, allocator: std.mem.Allocator) void { switch (this.*) { @@ -329,7 +327,12 @@ pub const BorderImageRepeatKeyword = enum { /// The image is repeated so that it fits, and then spaced apart evenly. space, - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; pub fn isCompatible(this: *const @This(), browsers: css.targets.Browsers) bool { return switch (this.*) { @@ -406,8 +409,6 @@ pub const BorderImageProperty = packed struct(u8) { pub const @"border-image-outset" = BorderImageProperty{ .outset = true }; pub const @"border-image-repeat" = BorderImageProperty{ .repeat = true }; - pub usingnamespace css.Bitflags(@This()); - pub const @"border-image" = BorderImageProperty{ .source = true, .slice = true, @@ -416,6 +417,10 @@ pub const BorderImageProperty = packed struct(u8) { .repeat = true, }; + pub fn isEmpty(this: BorderImageProperty) bool { + return @as(u8, @bitCast(this)) == 0; + } + pub fn tryFromPropertyId(property_id: css.PropertyIdTag) ?BorderImageProperty { inline for (std.meta.fields(BorderImageProperty)) |field| { if (comptime std.mem.eql(u8, field.name, "__unused")) continue; @@ -439,8 +444,8 @@ pub const BorderImageHandler = struct { width: ?Rect(BorderImageSideWidth) = null, outset: ?Rect(LengthOrNumber) = null, repeat: ?BorderImageRepeat = null, - vendor_prefix: css.VendorPrefix = css.VendorPrefix.empty(), - flushed_properties: BorderImageProperty = BorderImageProperty.empty(), + vendor_prefix: css.VendorPrefix = .{}, + flushed_properties: BorderImageProperty = .{}, has_any: bool = false, pub fn handleProperty(this: *@This(), property: *const css.Property, dest: *css.DeclarationList, context: *css.PropertyHandlerContext) bool { @@ -462,7 +467,7 @@ pub const BorderImageHandler = struct { const propertyHelper = struct { inline fn propertyHelper(self: *BorderImageHandler, comptime field: []const u8, comptime T: type, val: *const T, d: *css.DeclarationList, ctx: *css.PropertyHandlerContext) void { - if (!self.vendor_prefix.eql(VendorPrefix{ .none = true })) { + if (self.vendor_prefix != VendorPrefix{ .none = true }) { self.flush(d, ctx); } @@ -495,7 +500,7 @@ pub const BorderImageHandler = struct { this.width = val.width.deepClone(allocator); this.outset = val.outset.deepClone(allocator); this.repeat = val.repeat.deepClone(allocator); - this.vendor_prefix = this.vendor_prefix.bitwiseOr(vp); + this.vendor_prefix = bun.bits.@"or"(VendorPrefix, this.vendor_prefix, vp); this.has_any = true; }, .unparsed => |unparsed| { @@ -510,7 +515,7 @@ pub const BorderImageHandler = struct { unparsed.deepClone(allocator); context.addUnparsedFallbacks(&unparsed_clone); - this.flushed_properties.insert(BorderImageProperty.tryFromPropertyId(unparsed_clone.property_id).?); + bun.bits.insert(BorderImageProperty, &this.flushed_properties, BorderImageProperty.tryFromPropertyId(unparsed_clone.property_id).?); dest.append(allocator, Property{ .unparsed = unparsed_clone }) catch bun.outOfMemory(); } else return false; }, @@ -522,7 +527,7 @@ pub const BorderImageHandler = struct { pub fn finalize(this: *@This(), dest: *css.DeclarationList, context: *css.PropertyHandlerContext) void { this.flush(dest, context); - this.flushed_properties = BorderImageProperty.empty(); + this.flushed_properties = BorderImageProperty{}; } pub fn reset(this: *@This(), allocator: std.mem.Allocator) void { @@ -545,7 +550,7 @@ pub const BorderImageHandler = struct { .@"border-image-width", .@"border-image-outset", .@"border-image-repeat", - => !this.vendor_prefix.eql(VendorPrefix{ .none = true }), + => this.vendor_prefix != VendorPrefix{ .none = true }, .unparsed => |val| isBorderImageProperty(val.property_id), else => false, }; @@ -573,15 +578,15 @@ pub const BorderImageHandler = struct { }; var prefix = this.vendor_prefix; - if (prefix.contains(css.VendorPrefix{ .none = true }) and !border_image.slice.fill) { + if (prefix.none and !border_image.slice.fill) { prefix = context.targets.prefixes(this.vendor_prefix, css.prefixes.Feature.border_image); - if (!this.flushed_properties.intersects(BorderImageProperty.@"border-image")) { + if (this.flushed_properties.isEmpty()) { const fallbacks = border_image.getFallbacks(allocator, context.targets).slice(); for (fallbacks) |fallback| { // Match prefix of fallback. e.g. -webkit-linear-gradient // can only be used in -webkit-border-image, not -moz-border-image. // However, if border-image is unprefixed, gradients can still be. - var p = fallback.source.getVendorPrefix().intersect(prefix); + var p = bun.bits.@"and"(VendorPrefix, fallback.source.getVendorPrefix(), prefix); if (p.isEmpty()) { p = prefix; } @@ -590,47 +595,47 @@ pub const BorderImageHandler = struct { } } - const p = border_image.source.getVendorPrefix().intersect(prefix); + const p = bun.bits.@"and"(css.VendorPrefix, border_image.source.getVendorPrefix(), prefix); if (!p.isEmpty()) { prefix = p; } dest.append(allocator, Property{ .@"border-image" = .{ border_image, prefix } }) catch bun.outOfMemory(); - this.flushed_properties.insert(BorderImageProperty.@"border-image"); + bun.bits.insert(BorderImageProperty, &this.flushed_properties, BorderImageProperty.@"border-image"); } else { if (source) |*mut_source| { - if (!this.flushed_properties.contains(BorderImageProperty.@"border-image-source")) { + if (!bun.bits.contains(BorderImageProperty, this.flushed_properties, BorderImageProperty.@"border-image-source")) { for (mut_source.getFallbacks(allocator, context.targets).slice()) |fallback| { dest.append(allocator, Property{ .@"border-image-source" = fallback }) catch bun.outOfMemory(); } } dest.append(allocator, Property{ .@"border-image-source" = mut_source.* }) catch bun.outOfMemory(); - this.flushed_properties.insert(BorderImageProperty.@"border-image-source"); + bun.bits.insert(BorderImageProperty, &this.flushed_properties, BorderImageProperty.@"border-image-source"); } if (slice) |s| { dest.append(allocator, Property{ .@"border-image-slice" = s }) catch bun.outOfMemory(); - this.flushed_properties.insert(BorderImageProperty.@"border-image-slice"); + bun.bits.insert(BorderImageProperty, &this.flushed_properties, BorderImageProperty.@"border-image-slice"); } if (width) |w| { dest.append(allocator, Property{ .@"border-image-width" = w }) catch bun.outOfMemory(); - this.flushed_properties.insert(BorderImageProperty.@"border-image-width"); + bun.bits.insert(BorderImageProperty, &this.flushed_properties, BorderImageProperty.@"border-image-width"); } if (outset) |o| { dest.append(allocator, Property{ .@"border-image-outset" = o }) catch bun.outOfMemory(); - this.flushed_properties.insert(BorderImageProperty.@"border-image-outset"); + bun.bits.insert(BorderImageProperty, &this.flushed_properties, BorderImageProperty.@"border-image-outset"); } if (repeat) |r| { dest.append(allocator, Property{ .@"border-image-repeat" = r }) catch bun.outOfMemory(); - this.flushed_properties.insert(BorderImageProperty.@"border-image-repeat"); + bun.bits.insert(BorderImageProperty, &this.flushed_properties, BorderImageProperty.@"border-image-repeat"); } } - this.vendor_prefix = VendorPrefix.empty(); + this.vendor_prefix = VendorPrefix{}; } }; diff --git a/src/css/properties/border_radius.zig b/src/css/properties/border_radius.zig index c070482590..c9694f13f8 100644 --- a/src/css/properties/border_radius.zig +++ b/src/css/properties/border_radius.zig @@ -38,7 +38,7 @@ pub const BorderRadius = struct { /// The x and y radius values for the bottom left corner. bottom_left: Size2D(LengthPercentage), - pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.@"border-radius", PropertyFieldMap); + // (old using name space) css.DefineShorthand(@This(), css.PropertyIdTag.@"border-radius", PropertyFieldMap); pub const PropertyFieldMap = .{ .top_left = "border-top-left-radius", @@ -203,10 +203,10 @@ pub const BorderRadiusHandler = struct { }, prefix, } }) catch bun.outOfMemory(); - top_left.?[1].remove(intersection); - top_right.?[1].remove(intersection); - bottom_right.?[1].remove(intersection); - bottom_left.?[1].remove(intersection); + bun.bits.remove(VendorPrefix, &top_left.?[1], intersection); + bun.bits.remove(VendorPrefix, &top_right.?[1], intersection); + bun.bits.remove(VendorPrefix, &bottom_right.?[1], intersection); + bun.bits.remove(VendorPrefix, &bottom_left.?[1], intersection); } } @@ -237,7 +237,7 @@ pub const BorderRadiusHandler = struct { if (logical_supported) { d.append(ctx.allocator, v) catch bun.outOfMemory(); } else { - const prefix = ctx.targets.prefixes(css.VendorPrefix.empty(), css.prefixes.Feature.border_radius); + const prefix = ctx.targets.prefixes(css.VendorPrefix{}, css.prefixes.Feature.border_radius); switch (v) { .@"border-start-start-radius", .@"border-start-end-radius", @@ -267,7 +267,7 @@ pub const BorderRadiusHandler = struct { // If two vendor prefixes for the same property have different // values, we need to flush what we have immediately to preserve order. if (@field(self, prop)) |*existing| { - if (!existing.*[0].eql(val) and !existing.*[1].contains(vp)) { + if (!existing.*[0].eql(val) and !bun.bits.contains(VendorPrefix, existing.*[1], vp)) { self.flush(d, ctx); } } diff --git a/src/css/properties/box_shadow.zig b/src/css/properties/box_shadow.zig index 87febf218a..feeb4fe4f3 100644 --- a/src/css/properties/box_shadow.zig +++ b/src/css/properties/box_shadow.zig @@ -159,7 +159,7 @@ pub const BoxShadowHandler = struct { if (this.box_shadows) |*bxs| { const val: *SmallList(BoxShadow, 1) = &bxs.*[0]; const prefixes: *VendorPrefix = &bxs.*[1]; - if (!val.eql(box_shadows) and !prefixes.contains(prefix)) { + if (!val.eql(box_shadows) and !bun.bits.contains(VendorPrefix, prefixes.*, prefix)) { this.flush(dest, context); this.box_shadows = .{ box_shadows.deepClone(context.allocator), @@ -167,7 +167,7 @@ pub const BoxShadowHandler = struct { }; } else { val.* = box_shadows.deepClone(context.allocator); - prefixes.insert(prefix); + bun.bits.insert(VendorPrefix, prefixes, prefix); } } else { this.box_shadows = .{ @@ -208,12 +208,12 @@ pub const BoxShadowHandler = struct { if (!this.flushed) { const ColorFallbackKind = css.ColorFallbackKind; var prefixes = context.targets.prefixes(prefixes2, Feature.box_shadow); - var fallbacks = ColorFallbackKind.empty(); + var fallbacks = ColorFallbackKind{}; for (box_shadows.slice()) |*shadow| { - fallbacks.insert(shadow.color.getNecessaryFallbacks(context.targets)); + bun.bits.insert(ColorFallbackKind, &fallbacks, shadow.color.getNecessaryFallbacks(context.targets)); } - if (fallbacks.contains(ColorFallbackKind{ .rgb = true })) { + if (fallbacks.rgb) { var rgb = SmallList(BoxShadow, 1).initCapacity(context.allocator, box_shadows.len()); rgb.setLen(box_shadows.len()); for (box_shadows.slice(), rgb.slice_mut()) |*input, *output| { @@ -226,7 +226,7 @@ pub const BoxShadowHandler = struct { } dest.append(context.allocator, .{ .@"box-shadow" = .{ rgb, prefixes } }) catch bun.outOfMemory(); - if (prefixes.contains(VendorPrefix.NONE)) { + if (prefixes.none) { prefixes = VendorPrefix.NONE; } else { // Only output RGB for prefixed property (e.g. -webkit-box-shadow) @@ -234,7 +234,7 @@ pub const BoxShadowHandler = struct { } } - if (fallbacks.contains(ColorFallbackKind.P3)) { + if (fallbacks.p3) { var p3 = SmallList(BoxShadow, 1).initCapacity(context.allocator, box_shadows.len()); p3.setLen(box_shadows.len()); for (box_shadows.slice(), p3.slice_mut()) |*input, *output| { @@ -248,7 +248,7 @@ pub const BoxShadowHandler = struct { dest.append(context.allocator, .{ .@"box-shadow" = .{ p3, VendorPrefix.NONE } }) catch bun.outOfMemory(); } - if (fallbacks.contains(ColorFallbackKind.LAB)) { + if (fallbacks.lab) { var lab = SmallList(BoxShadow, 1).initCapacity(context.allocator, box_shadows.len()); lab.setLen(box_shadows.len()); for (box_shadows.slice(), lab.slice_mut()) |*input, *output| { diff --git a/src/css/properties/custom.zig b/src/css/properties/custom.zig index dea0d4202d..b55ade8a70 100644 --- a/src/css/properties/custom.zig +++ b/src/css/properties/custom.zig @@ -625,17 +625,17 @@ pub const TokenList = struct { // the original declaration. The remaining fallbacks need to be added as @supports rules. var fallbacks = this.getNecessaryFallbacks(targets); const lowest_fallback = fallbacks.lowest(); - fallbacks.remove(lowest_fallback); + bun.bits.remove(ColorFallbackKind, &fallbacks, lowest_fallback); var res = css.SmallList(Fallbacks, 2){}; - if (fallbacks.contains(ColorFallbackKind.P3)) { + if (fallbacks.p3) { res.appendAssumeCapacity(.{ ColorFallbackKind.P3.supportsCondition(), this.getFallback(allocator, ColorFallbackKind.P3), }); } - if (fallbacks.contains(ColorFallbackKind.LAB)) { + if (fallbacks.lab) { res.appendAssumeCapacity(.{ ColorFallbackKind.LAB.supportsCondition(), this.getFallback(allocator, ColorFallbackKind.LAB), @@ -670,23 +670,23 @@ pub const TokenList = struct { } pub fn getNecessaryFallbacks(this: *const TokenList, targets: css.targets.Targets) ColorFallbackKind { - var fallbacks = ColorFallbackKind.empty(); + var fallbacks = ColorFallbackKind{}; for (this.v.items) |*token_or_value| { switch (token_or_value.*) { .color => |*color| { - fallbacks.insert(color.getPossibleFallbacks(targets)); + bun.bits.insert(ColorFallbackKind, &fallbacks, color.getPossibleFallbacks(targets)); }, .function => |*f| { - fallbacks.insert(f.arguments.getNecessaryFallbacks(targets)); + bun.bits.insert(ColorFallbackKind, &fallbacks, f.arguments.getNecessaryFallbacks(targets)); }, .@"var" => |*v| { if (v.fallback) |*fallback| { - fallbacks.insert(fallback.getNecessaryFallbacks(targets)); + bun.bits.insert(ColorFallbackKind, &fallbacks, fallback.getNecessaryFallbacks(targets)); } }, .env => |*v| { if (v.fallback) |*fallback| { - fallbacks.insert(fallback.getNecessaryFallbacks(targets)); + bun.bits.insert(ColorFallbackKind, &fallbacks, fallback.getNecessaryFallbacks(targets)); } }, else => {}, @@ -1265,11 +1265,12 @@ pub const UAEnvironmentVariable = enum { /// The viewport segment right position. @"viewport-segment-right", - pub usingnamespace css.DefineEnumProperty(@This()); - - pub fn eql(lhs: *const @This(), rhs: *const @This()) bool { - return css.implementEql(@This(), lhs, rhs); - } + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; }; /// A custom CSS function. diff --git a/src/css/properties/display.zig b/src/css/properties/display.zig index 07a9f6c339..475d347463 100644 --- a/src/css/properties/display.zig +++ b/src/css/properties/display.zig @@ -34,8 +34,8 @@ pub const Display = union(enum) { /// The inside and outside display values. pair: DisplayPair, - pub usingnamespace css.DeriveParse(@This()); - pub usingnamespace css.DeriveToCss(@This()); + pub const parse = css.DeriveParse(@This()).parse; + pub const toCss = css.DeriveToCss(@This()).toCss; pub fn deepClone(this: *const @This(), allocator: std.mem.Allocator) @This() { return css.implementDeepClone(@This(), this, allocator); @@ -59,7 +59,12 @@ pub const Visibility = enum { /// The element is collapsed. collapse, - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; }; /// A `display` keyword. @@ -81,7 +86,12 @@ pub const DisplayKeyword = enum { @"ruby-base-container", @"ruby-text-container", - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; }; /// A pair of inside and outside display values, as used in the `display` property. @@ -174,7 +184,7 @@ pub const DisplayPair = struct { return dest.writeStr("inline-table"); } else if (this.outside == .@"inline" and this.inside == .flex and !this.is_list_item) { try this.inside.flex.toCss(W, dest); - if (this.inside.flex.eql(css.VendorPrefix{ .ms = true })) { + if (this.inside.flex == css.VendorPrefix{ .ms = true }) { return dest.writeStr("inline-flexbox"); } else { return dest.writeStr("inline-flex"); @@ -224,7 +234,12 @@ pub const DisplayOutside = enum { @"inline", @"run-in", - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; }; /// A [``](https://drafts.csswg.org/css-display-3/#typedef-display-inside) value. @@ -271,7 +286,7 @@ pub const DisplayInside = union(enum) { .table => try dest.writeStr("table"), .flex => |prefix| { try prefix.toCss(W, dest); - if (prefix.eql(css.VendorPrefix{ .ms = true })) { + if (prefix == css.VendorPrefix{ .ms = true }) { try dest.writeStr("flexbox"); } else { try dest.writeStr("flex"); diff --git a/src/css/properties/flex.zig b/src/css/properties/flex.zig index ab50a55821..2937f24bbc 100644 --- a/src/css/properties/flex.zig +++ b/src/css/properties/flex.zig @@ -50,7 +50,12 @@ pub const FlexDirection = enum { /// Flex items are laid out in a column, and reversed. @"column-reverse", - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; pub fn default() FlexDirection { return .row; @@ -76,7 +81,12 @@ pub const FlexWrap = enum { /// The flex items wrap, in reverse. @"wrap-reverse", - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; pub fn default() FlexWrap { return .nowrap; @@ -94,7 +104,7 @@ pub const FlexFlow = struct { /// How the flex items wrap. wrap: FlexWrap, - pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.@"flex-flow", PropertyFieldMap); + // (old using name space) css.DefineShorthand(@This(), css.PropertyIdTag.@"flex-flow", PropertyFieldMap); pub const PropertyFieldMap = .{ .direction = css.PropertyIdTag.@"flex-direction", @@ -170,7 +180,7 @@ pub const Flex = struct { /// The flex basis. basis: LengthPercentageOrAuto, - pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.flex, PropertyFieldMap); + // (old using name space) css.DefineShorthand(@This(), css.PropertyIdTag.flex, PropertyFieldMap); pub const PropertyFieldMap = .{ .grow = css.PropertyIdTag.@"flex-grow", @@ -289,7 +299,12 @@ pub const BoxOrient = enum { /// Items are laid out along the block axis, according to the writing direction. @"block-axis", - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; }; /// A value for the legacy (prefixed) [box-direction](https://www.w3.org/TR/2009/WD-css3-flexbox-20090723/#displayorder) property. @@ -300,7 +315,12 @@ pub const BoxDirection = enum { /// Items flow in the reverse direction. reverse, - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; }; pub const FlexAlign = BoxAlign; @@ -321,7 +341,12 @@ pub const BoxAlign = enum { /// Items are stretched. stretch, - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; pub fn fromStandard(@"align": *const css.css_properties.@"align".AlignItems) ?BoxAlign { return switch (@"align".*) { @@ -351,7 +376,12 @@ pub const BoxPack = enum { /// Items are justified to the start and end. justify, - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; pub fn fromStandard(justify: *const css.css_properties.@"align".JustifyContent) ?BoxPack { return switch (justify.*) { @@ -379,7 +409,12 @@ pub const BoxLines = enum { /// Items may wrap into multiple lines. multiple, - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; pub fn fromStandard(wrap: *const FlexWrap) ?BoxLines { return switch (wrap.*) { @@ -407,7 +442,12 @@ pub const FlexPack = enum { /// Items are distributed evenly, with half size spaces on either end. distribute, - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; pub fn fromStandard(justify: *const css.css_properties.@"align".JustifyContent) ?FlexPack { return switch (justify.*) { @@ -444,7 +484,12 @@ pub const FlexItemAlign = enum { /// The item is stretched. stretch, - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; pub fn fromStandard(justify: *const css.css_properties.@"align".AlignSelf) ?FlexItemAlign { return switch (justify.*) { @@ -479,7 +524,12 @@ pub const FlexLinePack = enum { /// Content is stretched. stretch, - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; pub fn fromStandard(justify: *const css.css_properties.@"align".AlignContent) ?FlexLinePack { return switch (justify.*) { @@ -554,7 +604,7 @@ pub const FlexHandler = struct { // If two vendor prefixes for the same property have different // values, we need to flush what we have immediately to preserve order. if (@field(self, prop)) |*field| { - if (!std.meta.eql(field[0], val.*) and !field[1].contains(vp.*)) { + if (!std.meta.eql(field[0], val.*) and !bun.bits.contains(css.VendorPrefix, field[1], vp.*)) { self.flush(d, ctx); } } @@ -575,7 +625,7 @@ pub const FlexHandler = struct { // Otherwise, update the value and add the prefix if (@field(self, prop)) |*field| { field[0] = css.generic.deepClone(@TypeOf(val.*), val, ctx.allocator); - field[1].insert(vp.*); + bun.bits.insert(css.VendorPrefix, &field[1], vp.*); } else { @field(self, prop) = .{ css.generic.deepClone(@TypeOf(val.*), val, ctx.allocator), @@ -713,12 +763,12 @@ pub const FlexHandler = struct { const dir = val[0]; if (context.targets.browsers) |targets| { const prefixes = context.targets.prefixes(css.VendorPrefix.NONE, css.prefixes.Feature.flex_direction); - var prefixes_2009 = css.VendorPrefix.empty(); + var prefixes_2009 = css.VendorPrefix{}; if (isFlex2009(targets)) { - prefixes_2009.insert(css.VendorPrefix.WEBKIT); + prefixes_2009.webkit = true; } - if (prefixes.contains(css.VendorPrefix.MOZ)) { - prefixes_2009.insert(css.VendorPrefix.MOZ); + if (prefixes.moz) { + prefixes_2009.moz = true; } if (!prefixes_2009.isEmpty()) { const orient, const newdir = dir.to2009(); @@ -738,7 +788,7 @@ pub const FlexHandler = struct { if (!intersection.isEmpty()) { var prefix = context.targets.prefixes(intersection, css.prefixes.Feature.flex_flow); // Firefox only implemented the 2009 spec prefixed. - prefix.remove(css.VendorPrefix.MOZ); + prefix.moz = false; dest.append(context.allocator, Property{ .@"flex-flow" = .{ FlexFlow{ .direction = dir.*, @@ -746,8 +796,8 @@ pub const FlexHandler = struct { }, prefix, } }) catch bun.outOfMemory(); - dir_prefix.remove(intersection); - wrap_prefix.remove(intersection); + bun.bits.remove(css.VendorPrefix, dir_prefix, intersection); + bun.bits.remove(css.VendorPrefix, wrap_prefix, intersection); } } @@ -758,12 +808,12 @@ pub const FlexHandler = struct { if (grow) |val| { const g = val[0]; const prefixes = context.targets.prefixes(css.VendorPrefix.NONE, css.prefixes.Feature.flex_grow); - var prefixes_2009 = css.VendorPrefix.empty(); + var prefixes_2009 = css.VendorPrefix{}; if (isFlex2009(targets)) { - prefixes_2009.insert(css.VendorPrefix.WEBKIT); + prefixes_2009.webkit = true; } - if (prefixes.contains(css.VendorPrefix.MOZ)) { - prefixes_2009.insert(css.VendorPrefix.MOZ); + if (prefixes.moz) { + prefixes_2009.moz = true; } if (!prefixes_2009.isEmpty()) { dest.append(context.allocator, Property{ .@"box-flex" = .{ g, prefixes_2009 } }) catch bun.outOfMemory(); @@ -783,7 +833,7 @@ pub const FlexHandler = struct { if (!intersection.isEmpty()) { var prefix = context.targets.prefixes(intersection, css.prefixes.Feature.flex); // Firefox only implemented the 2009 spec prefixed. - prefix.remove(css.VendorPrefix.MOZ); + prefix.moz = false; dest.append(context.allocator, Property{ .flex = .{ Flex{ .grow = g, @@ -792,9 +842,9 @@ pub const FlexHandler = struct { }, prefix, } }) catch bun.outOfMemory(); - g_prefix.remove(intersection); - s_prefix.remove(intersection); - b_prefix.remove(intersection); + bun.bits.remove(css.VendorPrefix, g_prefix, intersection); + bun.bits.remove(css.VendorPrefix, s_prefix, intersection); + bun.bits.remove(css.VendorPrefix, b_prefix, intersection); } } @@ -821,15 +871,15 @@ pub const FlexHandler = struct { if (!prefix.isEmpty()) { prefix = ctx.targets.prefixes(prefix, @field(css.prefixes.Feature, feature_name)); if (comptime prop_2009) |p2009| { - if (prefix.contains(css.VendorPrefix.NONE)) { + if (prefix.none) { // 2009 spec, implemented by webkit and firefox if (ctx.targets.browsers) |targets| { - var prefixes_2009 = css.VendorPrefix.empty(); + var prefixes_2009 = css.VendorPrefix{}; if (isFlex2009(targets)) { - prefixes_2009.insert(css.VendorPrefix.WEBKIT); + prefixes_2009.webkit = true; } - if (prefix.contains(css.VendorPrefix.MOZ)) { - prefixes_2009.insert(css.VendorPrefix.MOZ); + if (prefix.moz) { + prefixes_2009.moz = true; } if (!prefixes_2009.isEmpty()) { const s = brk: { @@ -850,7 +900,7 @@ pub const FlexHandler = struct { if (comptime prop_2012) |p2012| { var ms = true; - if (prefix.contains(css.VendorPrefix.MS)) { + if (prefix.ms) { dest.append(ctx.allocator, @unionInit(Property, p2012, .{ val, css.VendorPrefix.MS, @@ -859,12 +909,12 @@ pub const FlexHandler = struct { } if (!ms) { - prefix.remove(css.VendorPrefix.MS); + prefix.ms = false; } } // Firefox only implemented the 2009 spec prefixed. - prefix.remove(css.VendorPrefix.MOZ); + prefix.moz = false; dest.append(ctx.allocator, @unionInit(Property, prop, .{ val, prefix, diff --git a/src/css/properties/font.zig b/src/css/properties/font.zig index eea1082c0e..0a85eb265b 100644 --- a/src/css/properties/font.zig +++ b/src/css/properties/font.zig @@ -48,8 +48,8 @@ pub const FontWeight = union(enum) { lighter, // TODO: implement this - pub usingnamespace css.DeriveParse(@This()); - pub usingnamespace css.DeriveToCss(@This()); + pub const parse = css.DeriveParse(@This()).parse; + pub const toCss = css.DeriveToCss(@This()).toCss; pub inline fn default() FontWeight { return .{ .absolute = AbsoluteFontWeight.default() }; @@ -83,7 +83,7 @@ pub const AbsoluteFontWeight = union(enum) { /// Same as `700`. bold, - pub usingnamespace css.DeriveParse(@This()); + pub const parse = css.DeriveParse(@This()).parse; pub fn toCss(this: *const AbsoluteFontWeight, comptime W: type, dest: *css.Printer(W)) css.PrintErr!void { return switch (this.*) { @@ -122,8 +122,8 @@ pub const FontSize = union(enum) { /// A relative font size keyword. relative: RelativeFontSize, - pub usingnamespace css.DeriveParse(@This()); - pub usingnamespace css.DeriveToCss(@This()); + pub const parse = css.DeriveParse(@This()).parse; + pub const toCss = css.DeriveToCss(@This()).toCss; pub fn isCompatible(this: *const FontSize, browsers: bun.css.targets.Browsers) bool { return switch (this.*) { @@ -170,7 +170,12 @@ pub const AbsoluteFontSize = enum { /// "xxx-large" @"xxx-large", - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; pub fn isCompatible(this: *const AbsoluteFontSize, browsers: bun.css.targets.Browsers) bool { return switch (this.*) { @@ -188,7 +193,12 @@ pub const RelativeFontSize = enum { smaller, larger, - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; }; /// A value for the [font-stretch](https://www.w3.org/TR/css-fonts-4/#font-stretch-prop) property. @@ -199,7 +209,7 @@ pub const FontStretch = union(enum) { percentage: Percentage, // TODO: implement this - pub usingnamespace css.DeriveParse(@This()); + pub const parse = css.DeriveParse(@This()).parse; pub fn toCss(this: *const FontStretch, comptime W: type, dest: *css.Printer(W)) css.PrintErr!void { if (dest.minify) { @@ -264,7 +274,12 @@ pub const FontStretchKeyword = enum { /// 200% @"ultra-expanded", - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; pub inline fn default() FontStretchKeyword { return .normal; @@ -433,7 +448,12 @@ pub const GenericFontFamily = enum { revert, @"revert-layer", - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; pub fn isCompatible(this: *const GenericFontFamily, browsers: bun.css.targets.Browsers) bool { return switch (this.*) { @@ -531,7 +551,12 @@ pub const FontVariantCaps = enum { /// Uses titling capitals. @"titling-caps", - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; pub fn default() FontVariantCaps { return .normal; @@ -569,8 +594,8 @@ pub const LineHeight = union(enum) { /// An explicit height. length: LengthPercentage, - pub usingnamespace @call(.auto, css.DeriveParse, .{@This()}); - pub usingnamespace @call(.auto, css.DeriveToCss, .{@This()}); + pub const parse = css.DeriveParse(@This()).parse; + pub const toCss = css.DeriveToCss(@This()).toCss; pub fn isCompatible(this: *const LineHeight, browsers: bun.css.targets.Browsers) bool { return switch (this.*) { @@ -609,7 +634,7 @@ pub const Font = struct { /// How the text should be capitalized. Only CSS 2.1 values are supported. variant_caps: FontVariantCaps, - pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.font, PropertyFieldMap); + // (old using name space) css.DefineShorthand(@This(), css.PropertyIdTag.font, PropertyFieldMap); pub const PropertyFieldMap = .{ .family = css.PropertyIdTag.@"font-family", @@ -776,7 +801,12 @@ pub const VerticalAlignKeyword = enum { /// Align the bottom of the box with the bottom of the parent’s content area. @"text-bottom", - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; }; pub const FontProperty = packed struct(u8) { @@ -789,8 +819,6 @@ pub const FontProperty = packed struct(u8) { @"font-variant-caps": bool = false, __unused: u1 = 0, - pub usingnamespace css.Bitflags(@This()); - const FONT = FontProperty{ .@"font-family" = true, .@"font-size" = true, @@ -865,7 +893,7 @@ pub const FontHandler = struct { .unparsed => |*val| { if (isFontProperty(val.property_id)) { this.flush(dest, context); - this.flushed_properties.insert(FontProperty.tryFromPropertyId(val.property_id).?); + bun.bits.insert(FontProperty, &this.flushed_properties, FontProperty.tryFromPropertyId(val.property_id).?); dest.append(context.allocator, property.*) catch bun.outOfMemory(); } else { return false; @@ -904,20 +932,18 @@ pub const FontHandler = struct { this.flushed_properties = .{}; } - fn flush(this: *FontHandler, decls: *css.DeclarationList, context: *css.PropertyHandlerContext) void { - const push = struct { - fn push(self: *FontHandler, d: *css.DeclarationList, ctx: *css.PropertyHandlerContext, comptime prop: []const u8, val: anytype) void { - d.append(ctx.allocator, @unionInit(css.Property, prop, val)) catch bun.outOfMemory(); - var insertion: FontProperty = .{}; - if (comptime std.mem.eql(u8, prop, "font")) { - insertion = FontProperty.FONT; - } else { - @field(insertion, prop) = true; - } - self.flushed_properties.insert(insertion); - } - }.push; + fn push(self: *FontHandler, d: *css.DeclarationList, ctx: *css.PropertyHandlerContext, comptime prop: []const u8, val: anytype) void { + d.append(ctx.allocator, @unionInit(css.Property, prop, val)) catch bun.outOfMemory(); + var insertion: FontProperty = .{}; + if (comptime std.mem.eql(u8, prop, "font")) { + insertion = FontProperty.FONT; + } else { + @field(insertion, prop) = true; + } + bun.bits.insert(FontProperty, &self.flushed_properties, insertion); + } + fn flush(this: *FontHandler, decls: *css.DeclarationList, context: *css.PropertyHandlerContext) void { if (!this.has_any) { return; } @@ -925,7 +951,7 @@ pub const FontHandler = struct { this.has_any = false; var family: ?bun.BabyList(FontFamily) = bun.take(&this.family); - if (!this.flushed_properties.contains(FontProperty{ .@"font-family" = true })) { + if (!this.flushed_properties.@"font-family") { family = compatibleFontFamily(context.allocator, family, !context.targets.shouldCompileSame(.font_family_system_ui)); } diff --git a/src/css/properties/generate_properties.ts b/src/css/properties/generate_properties.ts index 5b7f831630..404d26b6a4 100644 --- a/src/css/properties/generate_properties.ts +++ b/src/css/properties/generate_properties.ts @@ -111,7 +111,8 @@ function generatePropertyImpl(property_defs: Record): strin const required_functions = ["deepClone", "parse", "toCss", "eql"]; return ` - pub usingnamespace PropertyImpl(); + // Copy manually implemented functions. + pub const toCss = properties_impl.property_mixin.toCss // Sanity check to make sure all types have the following functions: // - deepClone() @@ -120,7 +121,7 @@ function generatePropertyImpl(property_defs: Record): strin // - toCss() // // We do this string concatenation thing so we get all the errors at once, - // instead of relying on Zig semantic analysis which usualy stops at the first error. + // instead of relying on Zig semantic analysis which usually stops at the first error. comptime { const compile_error: []const u8 = compile_error: { var compile_error: []const u8 = ""; @@ -358,7 +359,11 @@ ${Object.entries(property_defs) unparsed, custom: CustomPropertyName, -pub usingnamespace PropertyIdImpl(); + // Copy manually implemented functions. + pub const toCss = properties_impl.property_id_mixin.toCss; + pub const parse = properties_impl.property_id_mixin.toCss; + pub const fromString = properties_impl.property_id_mixin.toCss; + pub const fromStr = fromString; ${generatePropertyIdImpl(property_defs)} };`; @@ -383,7 +388,7 @@ function generatePropertyIdImpl(property_defs: Record): str pub fn prefix(this: *const PropertyId) VendorPrefix { return switch (this.*) { ${generatePropertyIdImplPrefix(property_defs)} - .all, .custom, .unparsed => VendorPrefix.empty(), + .all, .custom, .unparsed => VendorPrefix{}, }; } @@ -475,7 +480,7 @@ function generatePropertyIdImpl(property_defs: Record): str function generatePropertyIdImplPrefix(property_defs: Record): string { return Object.entries(property_defs) .map(([name, meta]) => { - if (meta.valid_prefixes === undefined) return `.${escapeIdent(name)} => VendorPrefix.empty(),`; + if (meta.valid_prefixes === undefined) return `.${escapeIdent(name)} => VendorPrefix{},`; return `.${escapeIdent(name)} => |p| p,`; }) .join("\n"); @@ -1789,9 +1794,7 @@ const Printer = css.Printer; const PrintErr = css.PrintErr; const VendorPrefix = css.VendorPrefix; - -const PropertyImpl = @import("./properties_impl.zig").PropertyImpl; -const PropertyIdImpl = @import("./properties_impl.zig").PropertyIdImpl; +const properties_impl = @import("./properties_impl.zig"); const CSSWideKeyword = css.css_properties.CSSWideKeyword; const UnparsedProperty = css.css_properties.custom.UnparsedProperty; diff --git a/src/css/properties/grid.zig b/src/css/properties/grid.zig index 9e9dcc284c..ee5345b049 100644 --- a/src/css/properties/grid.zig +++ b/src/css/properties/grid.zig @@ -47,8 +47,8 @@ pub const TrackSizing = union(enum) { /// A list of grid tracks. tracklist: TrackList, - pub usingnamespace css.DeriveParse(@This()); - pub usingnamespace css.DeriveToCss(@This()); + pub const parse = css.DeriveParse(@This()).parse; + pub const toCss = css.DeriveToCss(@This()).toCss; }; /// A [``](https://drafts.csswg.org/css-grid-2/#typedef-track-list) value, @@ -449,8 +449,8 @@ pub const RepeatCount = union(enum) { /// The `auto-fit` keyword. @"auto-fit", - pub usingnamespace css.DeriveParse(@This()); - pub usingnamespace css.DeriveToCss(@This()); + pub const parse = css.DeriveParse(@This()).parse; + pub const toCss = css.DeriveToCss(@This()).toCss; pub fn eql(this: *const @This(), other: *const @This()) bool { return css.implementEql(@This(), this, other); diff --git a/src/css/properties/margin_padding.zig b/src/css/properties/margin_padding.zig index 6011032b2f..a8d6473505 100644 --- a/src/css/properties/margin_padding.zig +++ b/src/css/properties/margin_padding.zig @@ -41,8 +41,10 @@ pub const Inset = struct { left: LengthPercentageOrAuto, // TODO: bring this back - // pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.inset); - pub usingnamespace css.DefineRectShorthand(@This(), LengthPercentageOrAuto); + // (old using name space) css.DefineShorthand(@This(), css.PropertyIdTag.inset); + const css_impl = css.DefineRectShorthand(@This(), LengthPercentageOrAuto); + pub const toCss = css_impl.toCss; + pub const parse = css_impl.parse; pub const PropertyFieldMap = .{ .top = css.PropertyIdTag.top, @@ -68,8 +70,10 @@ pub const InsetBlock = struct { block_end: LengthPercentageOrAuto, // TODO: bring this back - // pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.@"inset-block"); - pub usingnamespace css.DefineSizeShorthand(@This(), LengthPercentageOrAuto); + // (old using name space) css.DefineShorthand(@This(), css.PropertyIdTag.@"inset-block"); + const css_impl = css.DefineSizeShorthand(@This(), LengthPercentageOrAuto); + pub const toCss = css_impl.toCss; + pub const parse = css_impl.parse; pub const PropertyFieldMap = .{ .block_start = css.PropertyIdTag.@"inset-block-start", @@ -98,8 +102,10 @@ pub const InsetInline = struct { }; // TODO: bring this back - // pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.@"inset-inline"); - pub usingnamespace css.DefineSizeShorthand(@This(), LengthPercentageOrAuto); + // (old using name space) css.DefineShorthand(@This(), css.PropertyIdTag.@"inset-inline"); + const css_impl = css.DefineSizeShorthand(@This(), LengthPercentageOrAuto); + pub const toCss = css_impl.toCss; + pub const parse = css_impl.parse; pub fn deepClone(this: *const @This(), allocator: std.mem.Allocator) @This() { return css.implementDeepClone(@This(), this, allocator); @@ -118,8 +124,10 @@ pub const MarginBlock = struct { block_end: LengthPercentageOrAuto, // TODO: bring this back - // pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.@"margin-block"); - pub usingnamespace css.DefineSizeShorthand(@This(), LengthPercentageOrAuto); + // (old using name space) css.DefineShorthand(@This(), css.PropertyIdTag.@"margin-block"); + const css_impl = css.DefineSizeShorthand(@This(), LengthPercentageOrAuto); + pub const toCss = css_impl.toCss; + pub const parse = css_impl.parse; pub const PropertyFieldMap = .{ .block_start = css.PropertyIdTag.@"margin-block-start", @@ -143,8 +151,10 @@ pub const MarginInline = struct { inline_end: LengthPercentageOrAuto, // TODO: bring this back - // pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.@"margin-inline"); - pub usingnamespace css.DefineSizeShorthand(@This(), LengthPercentageOrAuto); + // (old using name space) css.DefineShorthand(@This(), css.PropertyIdTag.@"margin-inline"); + const css_impl = css.DefineSizeShorthand(@This(), LengthPercentageOrAuto); + pub const toCss = css_impl.toCss; + pub const parse = css_impl.parse; pub const PropertyFieldMap = .{ .inline_start = css.PropertyIdTag.@"margin-inline-start", @@ -168,8 +178,10 @@ pub const Margin = struct { left: LengthPercentageOrAuto, // TODO: bring this back - // pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.margin); - pub usingnamespace css.DefineRectShorthand(@This(), LengthPercentageOrAuto); + // (old using name space) css.DefineShorthand(@This(), css.PropertyIdTag.margin); + const css_impl = css.DefineRectShorthand(@This(), LengthPercentageOrAuto); + pub const toCss = css_impl.toCss; + pub const parse = css_impl.parse; pub const PropertyFieldMap = .{ .top = css.PropertyIdTag.@"margin-top", @@ -195,8 +207,10 @@ pub const PaddingBlock = struct { block_end: LengthPercentageOrAuto, // TODO: bring this back - // pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.@"padding-block"); - pub usingnamespace css.DefineSizeShorthand(@This(), LengthPercentageOrAuto); + // (old using name space) css.DefineShorthand(@This(), css.PropertyIdTag.@"padding-block"); + const css_impl = css.DefineSizeShorthand(@This(), LengthPercentageOrAuto); + pub const toCss = css_impl.toCss; + pub const parse = css_impl.parse; pub const PropertyFieldMap = .{ .block_start = css.PropertyIdTag.@"padding-block-start", @@ -220,8 +234,10 @@ pub const PaddingInline = struct { inline_end: LengthPercentageOrAuto, // TODO: bring this back - // pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.@"padding-inline"); - pub usingnamespace css.DefineSizeShorthand(@This(), LengthPercentageOrAuto); + // (old using name space) css.DefineShorthand(@This(), css.PropertyIdTag.@"padding-inline"); + const css_impl = css.DefineSizeShorthand(@This(), LengthPercentageOrAuto); + pub const toCss = css_impl.toCss; + pub const parse = css_impl.parse; pub const PropertyFieldMap = .{ .inline_start = css.PropertyIdTag.@"padding-inline-start", @@ -245,8 +261,10 @@ pub const Padding = struct { left: LengthPercentageOrAuto, // TODO: bring this back - // pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.padding); - pub usingnamespace css.DefineRectShorthand(@This(), LengthPercentageOrAuto); + // (old using name space) css.DefineShorthand(@This(), css.PropertyIdTag.padding); + const css_impl = css.DefineRectShorthand(@This(), LengthPercentageOrAuto); + pub const toCss = css_impl.toCss; + pub const parse = css_impl.parse; pub const PropertyFieldMap = .{ .top = css.PropertyIdTag.@"padding-top", @@ -272,8 +290,10 @@ pub const ScrollMarginBlock = struct { block_end: LengthPercentageOrAuto, // TODO: bring this back - // pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.@"scroll-margin-block"); - pub usingnamespace css.DefineSizeShorthand(@This(), LengthPercentageOrAuto); + // (old using name space) css.DefineShorthand(@This(), css.PropertyIdTag.@"scroll-margin-block"); + const css_impl = css.DefineSizeShorthand(@This(), LengthPercentageOrAuto); + pub const toCss = css_impl.toCss; + pub const parse = css_impl.parse; pub const PropertyFieldMap = .{ .block_start = css.PropertyIdTag.@"scroll-margin-block-start", @@ -297,8 +317,10 @@ pub const ScrollMarginInline = struct { inline_end: LengthPercentageOrAuto, // TODO: bring this back - // pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.@"scroll-margin-inline"); - pub usingnamespace css.DefineSizeShorthand(@This(), LengthPercentageOrAuto); + // (old using name space) css.DefineShorthand(@This(), css.PropertyIdTag.@"scroll-margin-inline"); + const css_impl = css.DefineSizeShorthand(@This(), LengthPercentageOrAuto); + pub const toCss = css_impl.toCss; + pub const parse = css_impl.parse; pub const PropertyFieldMap = .{ .inline_start = css.PropertyIdTag.@"scroll-margin-inline-start", @@ -322,8 +344,10 @@ pub const ScrollMargin = struct { left: LengthPercentageOrAuto, // TODO: bring this back - // pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.@"scroll-margin"); - pub usingnamespace css.DefineRectShorthand(@This(), LengthPercentageOrAuto); + // (old using name space) css.DefineShorthand(@This(), css.PropertyIdTag.@"scroll-margin"); + const css_impl = css.DefineRectShorthand(@This(), LengthPercentageOrAuto); + pub const toCss = css_impl.toCss; + pub const parse = css_impl.parse; pub const PropertyFieldMap = .{ .top = css.PropertyIdTag.@"scroll-margin-top", @@ -349,8 +373,10 @@ pub const ScrollPaddingBlock = struct { block_end: LengthPercentageOrAuto, // TODO: bring this back - // pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.@"scroll-padding-block"); - pub usingnamespace css.DefineSizeShorthand(@This(), LengthPercentageOrAuto); + // (old using name space) css.DefineShorthand(@This(), css.PropertyIdTag.@"scroll-padding-block"); + const css_impl = css.DefineSizeShorthand(@This(), LengthPercentageOrAuto); + pub const toCss = css_impl.toCss; + pub const parse = css_impl.parse; pub const PropertyFieldMap = .{ .block_start = css.PropertyIdTag.@"scroll-padding-block-start", @@ -374,8 +400,10 @@ pub const ScrollPaddingInline = struct { inline_end: LengthPercentageOrAuto, // TODO: bring this back - // pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.@"scroll-padding-inline"); - pub usingnamespace css.DefineSizeShorthand(@This(), LengthPercentageOrAuto); + // (old using name space) css.DefineShorthand(@This(), css.PropertyIdTag.@"scroll-padding-inline"); + const css_impl = css.DefineSizeShorthand(@This(), LengthPercentageOrAuto); + pub const toCss = css_impl.toCss; + pub const parse = css_impl.parse; pub const PropertyFieldMap = .{ .inline_start = css.PropertyIdTag.@"scroll-padding-inline-start", @@ -399,8 +427,10 @@ pub const ScrollPadding = struct { left: LengthPercentageOrAuto, // TODO: bring this back - // pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.@"scroll-padding"); - pub usingnamespace css.DefineRectShorthand(@This(), LengthPercentageOrAuto); + // (old using name space) css.DefineShorthand(@This(), css.PropertyIdTag.@"scroll-padding"); + const css_impl = css.DefineRectShorthand(@This(), LengthPercentageOrAuto); + pub const toCss = css_impl.toCss; + pub const parse = css_impl.parse; pub const PropertyFieldMap = .{ .top = css.PropertyIdTag.@"scroll-padding-top", diff --git a/src/css/properties/masking.zig b/src/css/properties/masking.zig index 7022256c81..6e637ffa18 100644 --- a/src/css/properties/masking.zig +++ b/src/css/properties/masking.zig @@ -79,7 +79,12 @@ pub const GeometryBox = enum { /// Uses the nearest SVG viewport as reference box. @"view-box", - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; pub fn intoMaskClip(this: *const @This()) MaskClip { return MaskClip{ .@"geometry-box" = this.* }; @@ -166,7 +171,12 @@ pub const MaskMode = enum { /// If an SVG source is used, the value matches the `mask-type` property. Otherwise, the alpha values are used. @"match-source", - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; pub fn default() MaskMode { return .@"match-source"; @@ -180,8 +190,8 @@ pub const MaskClip = union(enum) { /// The painted content is not clipped. @"no-clip", - pub usingnamespace @call(.auto, css.DeriveParse, .{@This()}); - pub usingnamespace @call(.auto, css.DeriveToCss, .{@This()}); + pub const parse = css.DeriveParse(@This()).parse; + pub const toCss = css.DeriveToCss(@This()).toCss; pub fn eql(lhs: *const @This(), rhs: *const @This()) bool { return css.implementEql(@This(), lhs, rhs); @@ -203,7 +213,12 @@ pub const MaskComposite = enum { /// The non-overlapping regions of source and destination are combined. exclude, - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; pub fn default() MaskComposite { return .add; @@ -217,7 +232,12 @@ pub const MaskType = enum { /// The alpha values of the mask is used. alpha, - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; }; /// A value for the [mask](https://www.w3.org/TR/css-masking-1/#the-mask) shorthand property. @@ -239,8 +259,6 @@ pub const Mask = struct { /// How the mask image is interpreted. mode: MaskMode, - pub usingnamespace css.DefineListShorthand(@This()); - pub const PropertyFieldMap = .{ .image = css.PropertyIdTag.@"mask-image", .position = css.PropertyIdTag.@"mask-position", @@ -404,7 +422,12 @@ pub const MaskBorderMode = enum { /// The alpha values of the mask image is used. alpha, - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; pub fn default() @This() { return .alpha; @@ -427,7 +450,7 @@ pub const MaskBorder = struct { /// How the mask image is interpreted. mode: MaskBorderMode, - pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.@"mask-border", PropertyFieldMap); + // (old using name space) css.DefineShorthand(@This(), css.PropertyIdTag.@"mask-border", PropertyFieldMap); pub const PropertyFieldMap = .{ .source = css.PropertyIdTag.@"mask-border-source", @@ -520,7 +543,12 @@ pub const WebKitMaskComposite = enum { /// Equivalent to `exclude` in the standard `mask-composite` syntax. xor, - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; }; /// A value for the [-webkit-mask-source-type](https://github.com/WebKit/WebKit/blob/6eece09a1c31e47489811edd003d1e36910e9fd3/Source/WebCore/css/CSSProperties.json#L6578-L6587) @@ -539,7 +567,12 @@ pub const WebKitMaskSourceType = enum { /// The alpha values of the mask image is used. alpha, - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; }; pub fn getWebkitMaskProperty(property_id: *const css.PropertyId) ?css.PropertyId { diff --git a/src/css/properties/outline.zig b/src/css/properties/outline.zig index a38119e7bc..c7b3cd2063 100644 --- a/src/css/properties/outline.zig +++ b/src/css/properties/outline.zig @@ -42,8 +42,8 @@ pub const OutlineStyle = union(enum) { /// A value equivalent to the `border-style` property. line_style: LineStyle, - pub usingnamespace css.DeriveParse(@This()); - pub usingnamespace css.DeriveToCss(@This()); + pub const parse = css.DeriveParse(@This()).parse; + pub const toCss = css.DeriveToCss(@This()).toCss; pub fn default() @This() { return .{ .line_style = .none }; diff --git a/src/css/properties/overflow.zig b/src/css/properties/overflow.zig index 43e4fcea6e..9e969cf1bc 100644 --- a/src/css/properties/overflow.zig +++ b/src/css/properties/overflow.zig @@ -82,7 +82,12 @@ pub const OverflowKeyword = enum { /// Overflowing content scrolls if needed. auto, - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; }; /// A value for the [text-overflow](https://www.w3.org/TR/css-overflow-3/#text-overflow) property. @@ -92,5 +97,10 @@ pub const TextOverflow = enum { /// Overflowing text is truncated with an ellipsis. ellipsis, - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; }; diff --git a/src/css/properties/properties.zig b/src/css/properties/properties.zig index e2e68a8852..f7c06a5a7c 100644 --- a/src/css/properties/properties.zig +++ b/src/css/properties/properties.zig @@ -59,7 +59,12 @@ pub const CSSWideKeyword = enum { /// Rolls back the cascade to the value of the previous cascade layer. @"revert-layer", - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; }; // pub fn DefineProperties(comptime properties: anytype) type { @@ -220,7 +225,7 @@ pub const CSSWideKeyword = enum { // const prop = @field(properties, field.name); // const allowed_prefixes = allowed_prefixes: { // var prefixes: css.VendorPrefix = if (@hasField(@TypeOf(prop), "unprefixed") and !prop.unprefixed) -// css.VendorPrefix.empty() +// css.VendorPrefix{} // else // css.VendorPrefix{ .none = true }; diff --git a/src/css/properties/properties_generated.zig b/src/css/properties/properties_generated.zig index 6838b3be51..957a71c5c9 100644 --- a/src/css/properties/properties_generated.zig +++ b/src/css/properties/properties_generated.zig @@ -3,13 +3,13 @@ const bun = @import("bun"); const Allocator = std.mem.Allocator; pub const css = @import("../css_parser.zig"); +const bits = bun.bits; const Printer = css.Printer; const PrintErr = css.PrintErr; const VendorPrefix = css.VendorPrefix; -const PropertyImpl = @import("./properties_impl.zig").PropertyImpl; -const PropertyIdImpl = @import("./properties_impl.zig").PropertyIdImpl; +const properties_impl = @import("./properties_impl.zig"); const CSSWideKeyword = css.css_properties.CSSWideKeyword; const UnparsedProperty = css.css_properties.custom.UnparsedProperty; @@ -508,7 +508,7 @@ pub const Property = union(PropertyIdTag) { unparsed: UnparsedProperty, custom: CustomProperty, - pub usingnamespace PropertyImpl(); + pub const toCss = properties_impl.property_mixin.toCss; // Sanity check to make sure all types have the following functions: // - deepClone() @@ -7116,11 +7116,11 @@ pub const Property = union(PropertyIdTag) { .@"inset-inline" => |*v| return v.longhand(property_id), .inset => |*v| return v.longhand(property_id), .@"border-radius" => |*v| { - if (!v[1].eq(property_id.prefix())) return null; + if (!(v[1] == property_id.prefix())) return null; return v[0].longhand(property_id); }, .@"border-image" => |*v| { - if (!v[1].eq(property_id.prefix())) return null; + if (!(v[1] == property_id.prefix())) return null; return v[0].longhand(property_id); }, .@"border-color" => |*v| return v.longhand(property_id), @@ -7145,11 +7145,11 @@ pub const Property = union(PropertyIdTag) { .@"border-inline-end" => |*v| return v.longhand(property_id), .outline => |*v| return v.longhand(property_id), .@"flex-flow" => |*v| { - if (!v[1].eq(property_id.prefix())) return null; + if (!(v[1] == property_id.prefix())) return null; return v[0].longhand(property_id); }, .flex => |*v| { - if (!v[1].eq(property_id.prefix())) return null; + if (!(v[1] == property_id.prefix())) return null; return v[0].longhand(property_id); }, .@"place-content" => |*v| return v.longhand(property_id), @@ -7170,11 +7170,11 @@ pub const Property = union(PropertyIdTag) { .@"scroll-padding" => |*v| return v.longhand(property_id), .font => |*v| return v.longhand(property_id), .transition => |*v| { - if (!v[1].eq(property_id.prefix())) return null; + if (!(v[1] == property_id.prefix())) return null; return v[0].longhand(property_id); }, .mask => |*v| { - if (!v[1].eq(property_id.prefix())) return null; + if (!(v[1] == property_id.prefix())) return null; return v[0].longhand(property_id); }, .@"mask-border" => |*v| return v.longhand(property_id), @@ -7194,10 +7194,10 @@ pub const Property = union(PropertyIdTag) { .@"background-size" => |*v| css.generic.eql(SmallList(background.BackgroundSize, 1), v, &rhs.@"background-size"), .@"background-repeat" => |*v| css.generic.eql(SmallList(background.BackgroundRepeat, 1), v, &rhs.@"background-repeat"), .@"background-attachment" => |*v| css.generic.eql(SmallList(background.BackgroundAttachment, 1), v, &rhs.@"background-attachment"), - .@"background-clip" => |*v| css.generic.eql(SmallList(background.BackgroundClip, 1), &v[0], &rhs.@"background-clip"[0]) and v[1].eq(rhs.@"background-clip"[1]), + .@"background-clip" => |*v| css.generic.eql(SmallList(background.BackgroundClip, 1), &v[0], &rhs.@"background-clip"[0]) and v[1] == rhs.@"background-clip"[1], .@"background-origin" => |*v| css.generic.eql(SmallList(background.BackgroundOrigin, 1), v, &rhs.@"background-origin"), .background => |*v| css.generic.eql(SmallList(background.Background, 1), v, &rhs.background), - .@"box-shadow" => |*v| css.generic.eql(SmallList(box_shadow.BoxShadow, 1), &v[0], &rhs.@"box-shadow"[0]) and v[1].eq(rhs.@"box-shadow"[1]), + .@"box-shadow" => |*v| css.generic.eql(SmallList(box_shadow.BoxShadow, 1), &v[0], &rhs.@"box-shadow"[0]) and v[1] == rhs.@"box-shadow"[1], .opacity => |*v| css.generic.eql(css.css_values.alpha.AlphaValue, v, &rhs.opacity), .color => |*v| css.generic.eql(CssColor, v, &rhs.color), .display => |*v| css.generic.eql(display.Display, v, &rhs.display), @@ -7214,12 +7214,12 @@ pub const Property = union(PropertyIdTag) { .@"min-inline-size" => |*v| css.generic.eql(size.Size, v, &rhs.@"min-inline-size"), .@"max-block-size" => |*v| css.generic.eql(size.MaxSize, v, &rhs.@"max-block-size"), .@"max-inline-size" => |*v| css.generic.eql(size.MaxSize, v, &rhs.@"max-inline-size"), - .@"box-sizing" => |*v| css.generic.eql(size.BoxSizing, &v[0], &rhs.@"box-sizing"[0]) and v[1].eq(rhs.@"box-sizing"[1]), + .@"box-sizing" => |*v| css.generic.eql(size.BoxSizing, &v[0], &rhs.@"box-sizing"[0]) and v[1] == rhs.@"box-sizing"[1], .@"aspect-ratio" => |*v| css.generic.eql(size.AspectRatio, v, &rhs.@"aspect-ratio"), .overflow => |*v| css.generic.eql(overflow.Overflow, v, &rhs.overflow), .@"overflow-x" => |*v| css.generic.eql(overflow.OverflowKeyword, v, &rhs.@"overflow-x"), .@"overflow-y" => |*v| css.generic.eql(overflow.OverflowKeyword, v, &rhs.@"overflow-y"), - .@"text-overflow" => |*v| css.generic.eql(overflow.TextOverflow, &v[0], &rhs.@"text-overflow"[0]) and v[1].eq(rhs.@"text-overflow"[1]), + .@"text-overflow" => |*v| css.generic.eql(overflow.TextOverflow, &v[0], &rhs.@"text-overflow"[0]) and v[1] == rhs.@"text-overflow"[1], .position => |*v| css.generic.eql(position.Position, v, &rhs.position), .top => |*v| css.generic.eql(LengthPercentageOrAuto, v, &rhs.top), .bottom => |*v| css.generic.eql(LengthPercentageOrAuto, v, &rhs.bottom), @@ -7257,21 +7257,21 @@ pub const Property = union(PropertyIdTag) { .@"border-block-end-width" => |*v| css.generic.eql(BorderSideWidth, v, &rhs.@"border-block-end-width"), .@"border-inline-start-width" => |*v| css.generic.eql(BorderSideWidth, v, &rhs.@"border-inline-start-width"), .@"border-inline-end-width" => |*v| css.generic.eql(BorderSideWidth, v, &rhs.@"border-inline-end-width"), - .@"border-top-left-radius" => |*v| css.generic.eql(Size2D(LengthPercentage), &v[0], &rhs.@"border-top-left-radius"[0]) and v[1].eq(rhs.@"border-top-left-radius"[1]), - .@"border-top-right-radius" => |*v| css.generic.eql(Size2D(LengthPercentage), &v[0], &rhs.@"border-top-right-radius"[0]) and v[1].eq(rhs.@"border-top-right-radius"[1]), - .@"border-bottom-left-radius" => |*v| css.generic.eql(Size2D(LengthPercentage), &v[0], &rhs.@"border-bottom-left-radius"[0]) and v[1].eq(rhs.@"border-bottom-left-radius"[1]), - .@"border-bottom-right-radius" => |*v| css.generic.eql(Size2D(LengthPercentage), &v[0], &rhs.@"border-bottom-right-radius"[0]) and v[1].eq(rhs.@"border-bottom-right-radius"[1]), + .@"border-top-left-radius" => |*v| css.generic.eql(Size2D(LengthPercentage), &v[0], &rhs.@"border-top-left-radius"[0]) and (v[1] == rhs.@"border-top-left-radius"[1]), + .@"border-top-right-radius" => |*v| css.generic.eql(Size2D(LengthPercentage), &v[0], &rhs.@"border-top-right-radius"[0]) and (v[1] == rhs.@"border-top-right-radius"[1]), + .@"border-bottom-left-radius" => |*v| css.generic.eql(Size2D(LengthPercentage), &v[0], &rhs.@"border-bottom-left-radius"[0]) and (v[1] == rhs.@"border-bottom-left-radius"[1]), + .@"border-bottom-right-radius" => |*v| css.generic.eql(Size2D(LengthPercentage), &v[0], &rhs.@"border-bottom-right-radius"[0]) and (v[1] == rhs.@"border-bottom-right-radius"[1]), .@"border-start-start-radius" => |*v| css.generic.eql(Size2D(LengthPercentage), v, &rhs.@"border-start-start-radius"), .@"border-start-end-radius" => |*v| css.generic.eql(Size2D(LengthPercentage), v, &rhs.@"border-start-end-radius"), .@"border-end-start-radius" => |*v| css.generic.eql(Size2D(LengthPercentage), v, &rhs.@"border-end-start-radius"), .@"border-end-end-radius" => |*v| css.generic.eql(Size2D(LengthPercentage), v, &rhs.@"border-end-end-radius"), - .@"border-radius" => |*v| css.generic.eql(BorderRadius, &v[0], &rhs.@"border-radius"[0]) and v[1].eq(rhs.@"border-radius"[1]), + .@"border-radius" => |*v| css.generic.eql(BorderRadius, &v[0], &rhs.@"border-radius"[0]) and (v[1] == rhs.@"border-radius"[1]), .@"border-image-source" => |*v| css.generic.eql(Image, v, &rhs.@"border-image-source"), .@"border-image-outset" => |*v| css.generic.eql(Rect(LengthOrNumber), v, &rhs.@"border-image-outset"), .@"border-image-repeat" => |*v| css.generic.eql(BorderImageRepeat, v, &rhs.@"border-image-repeat"), .@"border-image-width" => |*v| css.generic.eql(Rect(BorderImageSideWidth), v, &rhs.@"border-image-width"), .@"border-image-slice" => |*v| css.generic.eql(BorderImageSlice, v, &rhs.@"border-image-slice"), - .@"border-image" => |*v| css.generic.eql(BorderImage, &v[0], &rhs.@"border-image"[0]) and v[1].eq(rhs.@"border-image"[1]), + .@"border-image" => |*v| css.generic.eql(BorderImage, &v[0], &rhs.@"border-image"[0]) and (v[1] == rhs.@"border-image"[1]), .@"border-color" => |*v| css.generic.eql(BorderColor, v, &rhs.@"border-color"), .@"border-style" => |*v| css.generic.eql(BorderStyle, v, &rhs.@"border-style"), .@"border-width" => |*v| css.generic.eql(BorderWidth, v, &rhs.@"border-width"), @@ -7296,42 +7296,42 @@ pub const Property = union(PropertyIdTag) { .@"outline-color" => |*v| css.generic.eql(CssColor, v, &rhs.@"outline-color"), .@"outline-style" => |*v| css.generic.eql(OutlineStyle, v, &rhs.@"outline-style"), .@"outline-width" => |*v| css.generic.eql(BorderSideWidth, v, &rhs.@"outline-width"), - .@"flex-direction" => |*v| css.generic.eql(FlexDirection, &v[0], &rhs.@"flex-direction"[0]) and v[1].eq(rhs.@"flex-direction"[1]), - .@"flex-wrap" => |*v| css.generic.eql(FlexWrap, &v[0], &rhs.@"flex-wrap"[0]) and v[1].eq(rhs.@"flex-wrap"[1]), - .@"flex-flow" => |*v| css.generic.eql(FlexFlow, &v[0], &rhs.@"flex-flow"[0]) and v[1].eq(rhs.@"flex-flow"[1]), - .@"flex-grow" => |*v| css.generic.eql(CSSNumber, &v[0], &rhs.@"flex-grow"[0]) and v[1].eq(rhs.@"flex-grow"[1]), - .@"flex-shrink" => |*v| css.generic.eql(CSSNumber, &v[0], &rhs.@"flex-shrink"[0]) and v[1].eq(rhs.@"flex-shrink"[1]), - .@"flex-basis" => |*v| css.generic.eql(LengthPercentageOrAuto, &v[0], &rhs.@"flex-basis"[0]) and v[1].eq(rhs.@"flex-basis"[1]), - .flex => |*v| css.generic.eql(Flex, &v[0], &rhs.flex[0]) and v[1].eq(rhs.flex[1]), - .order => |*v| css.generic.eql(CSSInteger, &v[0], &rhs.order[0]) and v[1].eq(rhs.order[1]), - .@"align-content" => |*v| css.generic.eql(AlignContent, &v[0], &rhs.@"align-content"[0]) and v[1].eq(rhs.@"align-content"[1]), - .@"justify-content" => |*v| css.generic.eql(JustifyContent, &v[0], &rhs.@"justify-content"[0]) and v[1].eq(rhs.@"justify-content"[1]), + .@"flex-direction" => |*v| css.generic.eql(FlexDirection, &v[0], &rhs.@"flex-direction"[0]) and (v[1] == rhs.@"flex-direction"[1]), + .@"flex-wrap" => |*v| css.generic.eql(FlexWrap, &v[0], &rhs.@"flex-wrap"[0]) and (v[1] == rhs.@"flex-wrap"[1]), + .@"flex-flow" => |*v| css.generic.eql(FlexFlow, &v[0], &rhs.@"flex-flow"[0]) and (v[1] == rhs.@"flex-flow"[1]), + .@"flex-grow" => |*v| css.generic.eql(CSSNumber, &v[0], &rhs.@"flex-grow"[0]) and (v[1] == rhs.@"flex-grow"[1]), + .@"flex-shrink" => |*v| css.generic.eql(CSSNumber, &v[0], &rhs.@"flex-shrink"[0]) and (v[1] == rhs.@"flex-shrink"[1]), + .@"flex-basis" => |*v| css.generic.eql(LengthPercentageOrAuto, &v[0], &rhs.@"flex-basis"[0]) and (v[1] == rhs.@"flex-basis"[1]), + .flex => |*v| css.generic.eql(Flex, &v[0], &rhs.flex[0]) and (v[1] == rhs.flex[1]), + .order => |*v| css.generic.eql(CSSInteger, &v[0], &rhs.order[0]) and (v[1] == rhs.order[1]), + .@"align-content" => |*v| css.generic.eql(AlignContent, &v[0], &rhs.@"align-content"[0]) and (v[1] == rhs.@"align-content"[1]), + .@"justify-content" => |*v| css.generic.eql(JustifyContent, &v[0], &rhs.@"justify-content"[0]) and (v[1] == rhs.@"justify-content"[1]), .@"place-content" => |*v| css.generic.eql(PlaceContent, v, &rhs.@"place-content"), - .@"align-self" => |*v| css.generic.eql(AlignSelf, &v[0], &rhs.@"align-self"[0]) and v[1].eq(rhs.@"align-self"[1]), + .@"align-self" => |*v| css.generic.eql(AlignSelf, &v[0], &rhs.@"align-self"[0]) and (v[1] == rhs.@"align-self"[1]), .@"justify-self" => |*v| css.generic.eql(JustifySelf, v, &rhs.@"justify-self"), .@"place-self" => |*v| css.generic.eql(PlaceSelf, v, &rhs.@"place-self"), - .@"align-items" => |*v| css.generic.eql(AlignItems, &v[0], &rhs.@"align-items"[0]) and v[1].eq(rhs.@"align-items"[1]), + .@"align-items" => |*v| css.generic.eql(AlignItems, &v[0], &rhs.@"align-items"[0]) and (v[1] == rhs.@"align-items"[1]), .@"justify-items" => |*v| css.generic.eql(JustifyItems, v, &rhs.@"justify-items"), .@"place-items" => |*v| css.generic.eql(PlaceItems, v, &rhs.@"place-items"), .@"row-gap" => |*v| css.generic.eql(GapValue, v, &rhs.@"row-gap"), .@"column-gap" => |*v| css.generic.eql(GapValue, v, &rhs.@"column-gap"), .gap => |*v| css.generic.eql(Gap, v, &rhs.gap), - .@"box-orient" => |*v| css.generic.eql(BoxOrient, &v[0], &rhs.@"box-orient"[0]) and v[1].eq(rhs.@"box-orient"[1]), - .@"box-direction" => |*v| css.generic.eql(BoxDirection, &v[0], &rhs.@"box-direction"[0]) and v[1].eq(rhs.@"box-direction"[1]), - .@"box-ordinal-group" => |*v| css.generic.eql(CSSInteger, &v[0], &rhs.@"box-ordinal-group"[0]) and v[1].eq(rhs.@"box-ordinal-group"[1]), - .@"box-align" => |*v| css.generic.eql(BoxAlign, &v[0], &rhs.@"box-align"[0]) and v[1].eq(rhs.@"box-align"[1]), - .@"box-flex" => |*v| css.generic.eql(CSSNumber, &v[0], &rhs.@"box-flex"[0]) and v[1].eq(rhs.@"box-flex"[1]), - .@"box-flex-group" => |*v| css.generic.eql(CSSInteger, &v[0], &rhs.@"box-flex-group"[0]) and v[1].eq(rhs.@"box-flex-group"[1]), - .@"box-pack" => |*v| css.generic.eql(BoxPack, &v[0], &rhs.@"box-pack"[0]) and v[1].eq(rhs.@"box-pack"[1]), - .@"box-lines" => |*v| css.generic.eql(BoxLines, &v[0], &rhs.@"box-lines"[0]) and v[1].eq(rhs.@"box-lines"[1]), - .@"flex-pack" => |*v| css.generic.eql(FlexPack, &v[0], &rhs.@"flex-pack"[0]) and v[1].eq(rhs.@"flex-pack"[1]), - .@"flex-order" => |*v| css.generic.eql(CSSInteger, &v[0], &rhs.@"flex-order"[0]) and v[1].eq(rhs.@"flex-order"[1]), - .@"flex-align" => |*v| css.generic.eql(BoxAlign, &v[0], &rhs.@"flex-align"[0]) and v[1].eq(rhs.@"flex-align"[1]), - .@"flex-item-align" => |*v| css.generic.eql(FlexItemAlign, &v[0], &rhs.@"flex-item-align"[0]) and v[1].eq(rhs.@"flex-item-align"[1]), - .@"flex-line-pack" => |*v| css.generic.eql(FlexLinePack, &v[0], &rhs.@"flex-line-pack"[0]) and v[1].eq(rhs.@"flex-line-pack"[1]), - .@"flex-positive" => |*v| css.generic.eql(CSSNumber, &v[0], &rhs.@"flex-positive"[0]) and v[1].eq(rhs.@"flex-positive"[1]), - .@"flex-negative" => |*v| css.generic.eql(CSSNumber, &v[0], &rhs.@"flex-negative"[0]) and v[1].eq(rhs.@"flex-negative"[1]), - .@"flex-preferred-size" => |*v| css.generic.eql(LengthPercentageOrAuto, &v[0], &rhs.@"flex-preferred-size"[0]) and v[1].eq(rhs.@"flex-preferred-size"[1]), + .@"box-orient" => |*v| css.generic.eql(BoxOrient, &v[0], &rhs.@"box-orient"[0]) and (v[1] == rhs.@"box-orient"[1]), + .@"box-direction" => |*v| css.generic.eql(BoxDirection, &v[0], &rhs.@"box-direction"[0]) and (v[1] == rhs.@"box-direction"[1]), + .@"box-ordinal-group" => |*v| css.generic.eql(CSSInteger, &v[0], &rhs.@"box-ordinal-group"[0]) and (v[1] == rhs.@"box-ordinal-group"[1]), + .@"box-align" => |*v| css.generic.eql(BoxAlign, &v[0], &rhs.@"box-align"[0]) and (v[1] == rhs.@"box-align"[1]), + .@"box-flex" => |*v| css.generic.eql(CSSNumber, &v[0], &rhs.@"box-flex"[0]) and (v[1] == rhs.@"box-flex"[1]), + .@"box-flex-group" => |*v| css.generic.eql(CSSInteger, &v[0], &rhs.@"box-flex-group"[0]) and (v[1] == rhs.@"box-flex-group"[1]), + .@"box-pack" => |*v| css.generic.eql(BoxPack, &v[0], &rhs.@"box-pack"[0]) and (v[1] == rhs.@"box-pack"[1]), + .@"box-lines" => |*v| css.generic.eql(BoxLines, &v[0], &rhs.@"box-lines"[0]) and (v[1] == rhs.@"box-lines"[1]), + .@"flex-pack" => |*v| css.generic.eql(FlexPack, &v[0], &rhs.@"flex-pack"[0]) and (v[1] == rhs.@"flex-pack"[1]), + .@"flex-order" => |*v| css.generic.eql(CSSInteger, &v[0], &rhs.@"flex-order"[0]) and (v[1] == rhs.@"flex-order"[1]), + .@"flex-align" => |*v| css.generic.eql(BoxAlign, &v[0], &rhs.@"flex-align"[0]) and (v[1] == rhs.@"flex-align"[1]), + .@"flex-item-align" => |*v| css.generic.eql(FlexItemAlign, &v[0], &rhs.@"flex-item-align"[0]) and (v[1] == rhs.@"flex-item-align"[1]), + .@"flex-line-pack" => |*v| css.generic.eql(FlexLinePack, &v[0], &rhs.@"flex-line-pack"[0]) and (v[1] == rhs.@"flex-line-pack"[1]), + .@"flex-positive" => |*v| css.generic.eql(CSSNumber, &v[0], &rhs.@"flex-positive"[0]) and (v[1] == rhs.@"flex-positive"[1]), + .@"flex-negative" => |*v| css.generic.eql(CSSNumber, &v[0], &rhs.@"flex-negative"[0]) and (v[1] == rhs.@"flex-negative"[1]), + .@"flex-preferred-size" => |*v| css.generic.eql(LengthPercentageOrAuto, &v[0], &rhs.@"flex-preferred-size"[0]) and (v[1] == rhs.@"flex-preferred-size"[1]), .@"margin-top" => |*v| css.generic.eql(LengthPercentageOrAuto, v, &rhs.@"margin-top"), .@"margin-bottom" => |*v| css.generic.eql(LengthPercentageOrAuto, v, &rhs.@"margin-bottom"), .@"margin-left" => |*v| css.generic.eql(LengthPercentageOrAuto, v, &rhs.@"margin-left"), @@ -7384,38 +7384,38 @@ pub const Property = union(PropertyIdTag) { .@"font-variant-caps" => |*v| css.generic.eql(FontVariantCaps, v, &rhs.@"font-variant-caps"), .@"line-height" => |*v| css.generic.eql(LineHeight, v, &rhs.@"line-height"), .font => |*v| css.generic.eql(Font, v, &rhs.font), - .@"transition-property" => |*v| css.generic.eql(SmallList(PropertyId, 1), &v[0], &rhs.@"transition-property"[0]) and v[1].eq(rhs.@"transition-property"[1]), - .@"transition-duration" => |*v| css.generic.eql(SmallList(Time, 1), &v[0], &rhs.@"transition-duration"[0]) and v[1].eq(rhs.@"transition-duration"[1]), - .@"transition-delay" => |*v| css.generic.eql(SmallList(Time, 1), &v[0], &rhs.@"transition-delay"[0]) and v[1].eq(rhs.@"transition-delay"[1]), - .@"transition-timing-function" => |*v| css.generic.eql(SmallList(EasingFunction, 1), &v[0], &rhs.@"transition-timing-function"[0]) and v[1].eq(rhs.@"transition-timing-function"[1]), - .transition => |*v| css.generic.eql(SmallList(Transition, 1), &v[0], &rhs.transition[0]) and v[1].eq(rhs.transition[1]), - .transform => |*v| css.generic.eql(TransformList, &v[0], &rhs.transform[0]) and v[1].eq(rhs.transform[1]), - .@"transform-origin" => |*v| css.generic.eql(Position, &v[0], &rhs.@"transform-origin"[0]) and v[1].eq(rhs.@"transform-origin"[1]), - .@"transform-style" => |*v| css.generic.eql(TransformStyle, &v[0], &rhs.@"transform-style"[0]) and v[1].eq(rhs.@"transform-style"[1]), + .@"transition-property" => |*v| css.generic.eql(SmallList(PropertyId, 1), &v[0], &rhs.@"transition-property"[0]) and (v[1] == rhs.@"transition-property"[1]), + .@"transition-duration" => |*v| css.generic.eql(SmallList(Time, 1), &v[0], &rhs.@"transition-duration"[0]) and (v[1] == rhs.@"transition-duration"[1]), + .@"transition-delay" => |*v| css.generic.eql(SmallList(Time, 1), &v[0], &rhs.@"transition-delay"[0]) and (v[1] == rhs.@"transition-delay"[1]), + .@"transition-timing-function" => |*v| css.generic.eql(SmallList(EasingFunction, 1), &v[0], &rhs.@"transition-timing-function"[0]) and (v[1] == rhs.@"transition-timing-function"[1]), + .transition => |*v| css.generic.eql(SmallList(Transition, 1), &v[0], &rhs.transition[0]) and (v[1] == rhs.transition[1]), + .transform => |*v| css.generic.eql(TransformList, &v[0], &rhs.transform[0]) and (v[1] == rhs.transform[1]), + .@"transform-origin" => |*v| css.generic.eql(Position, &v[0], &rhs.@"transform-origin"[0]) and (v[1] == rhs.@"transform-origin"[1]), + .@"transform-style" => |*v| css.generic.eql(TransformStyle, &v[0], &rhs.@"transform-style"[0]) and (v[1] == rhs.@"transform-style"[1]), .@"transform-box" => |*v| css.generic.eql(TransformBox, v, &rhs.@"transform-box"), - .@"backface-visibility" => |*v| css.generic.eql(BackfaceVisibility, &v[0], &rhs.@"backface-visibility"[0]) and v[1].eq(rhs.@"backface-visibility"[1]), - .perspective => |*v| css.generic.eql(Perspective, &v[0], &rhs.perspective[0]) and v[1].eq(rhs.perspective[1]), - .@"perspective-origin" => |*v| css.generic.eql(Position, &v[0], &rhs.@"perspective-origin"[0]) and v[1].eq(rhs.@"perspective-origin"[1]), + .@"backface-visibility" => |*v| css.generic.eql(BackfaceVisibility, &v[0], &rhs.@"backface-visibility"[0]) and (v[1] == rhs.@"backface-visibility"[1]), + .perspective => |*v| css.generic.eql(Perspective, &v[0], &rhs.perspective[0]) and (v[1] == rhs.perspective[1]), + .@"perspective-origin" => |*v| css.generic.eql(Position, &v[0], &rhs.@"perspective-origin"[0]) and (v[1] == rhs.@"perspective-origin"[1]), .translate => |*v| css.generic.eql(Translate, v, &rhs.translate), .rotate => |*v| css.generic.eql(Rotate, v, &rhs.rotate), .scale => |*v| css.generic.eql(Scale, v, &rhs.scale), - .@"text-decoration-color" => |*v| css.generic.eql(CssColor, &v[0], &rhs.@"text-decoration-color"[0]) and v[1].eq(rhs.@"text-decoration-color"[1]), - .@"text-emphasis-color" => |*v| css.generic.eql(CssColor, &v[0], &rhs.@"text-emphasis-color"[0]) and v[1].eq(rhs.@"text-emphasis-color"[1]), + .@"text-decoration-color" => |*v| css.generic.eql(CssColor, &v[0], &rhs.@"text-decoration-color"[0]) and (v[1] == rhs.@"text-decoration-color"[1]), + .@"text-emphasis-color" => |*v| css.generic.eql(CssColor, &v[0], &rhs.@"text-emphasis-color"[0]) and (v[1] == rhs.@"text-emphasis-color"[1]), .@"text-shadow" => |*v| css.generic.eql(SmallList(TextShadow, 1), v, &rhs.@"text-shadow"), .direction => |*v| css.generic.eql(Direction, v, &rhs.direction), .composes => |*v| css.generic.eql(Composes, v, &rhs.composes), - .@"mask-image" => |*v| css.generic.eql(SmallList(Image, 1), &v[0], &rhs.@"mask-image"[0]) and v[1].eq(rhs.@"mask-image"[1]), + .@"mask-image" => |*v| css.generic.eql(SmallList(Image, 1), &v[0], &rhs.@"mask-image"[0]) and (v[1] == rhs.@"mask-image"[1]), .@"mask-mode" => |*v| css.generic.eql(SmallList(MaskMode, 1), v, &rhs.@"mask-mode"), - .@"mask-repeat" => |*v| css.generic.eql(SmallList(BackgroundRepeat, 1), &v[0], &rhs.@"mask-repeat"[0]) and v[1].eq(rhs.@"mask-repeat"[1]), + .@"mask-repeat" => |*v| css.generic.eql(SmallList(BackgroundRepeat, 1), &v[0], &rhs.@"mask-repeat"[0]) and (v[1] == rhs.@"mask-repeat"[1]), .@"mask-position-x" => |*v| css.generic.eql(SmallList(HorizontalPosition, 1), v, &rhs.@"mask-position-x"), .@"mask-position-y" => |*v| css.generic.eql(SmallList(VerticalPosition, 1), v, &rhs.@"mask-position-y"), - .@"mask-position" => |*v| css.generic.eql(SmallList(Position, 1), &v[0], &rhs.@"mask-position"[0]) and v[1].eq(rhs.@"mask-position"[1]), - .@"mask-clip" => |*v| css.generic.eql(SmallList(MaskClip, 1), &v[0], &rhs.@"mask-clip"[0]) and v[1].eq(rhs.@"mask-clip"[1]), - .@"mask-origin" => |*v| css.generic.eql(SmallList(GeometryBox, 1), &v[0], &rhs.@"mask-origin"[0]) and v[1].eq(rhs.@"mask-origin"[1]), - .@"mask-size" => |*v| css.generic.eql(SmallList(BackgroundSize, 1), &v[0], &rhs.@"mask-size"[0]) and v[1].eq(rhs.@"mask-size"[1]), + .@"mask-position" => |*v| css.generic.eql(SmallList(Position, 1), &v[0], &rhs.@"mask-position"[0]) and (v[1] == rhs.@"mask-position"[1]), + .@"mask-clip" => |*v| css.generic.eql(SmallList(MaskClip, 1), &v[0], &rhs.@"mask-clip"[0]) and (v[1] == rhs.@"mask-clip"[1]), + .@"mask-origin" => |*v| css.generic.eql(SmallList(GeometryBox, 1), &v[0], &rhs.@"mask-origin"[0]) and (v[1] == rhs.@"mask-origin"[1]), + .@"mask-size" => |*v| css.generic.eql(SmallList(BackgroundSize, 1), &v[0], &rhs.@"mask-size"[0]) and (v[1] == rhs.@"mask-size"[1]), .@"mask-composite" => |*v| css.generic.eql(SmallList(MaskComposite, 1), v, &rhs.@"mask-composite"), .@"mask-type" => |*v| css.generic.eql(MaskType, v, &rhs.@"mask-type"), - .mask => |*v| css.generic.eql(SmallList(Mask, 1), &v[0], &rhs.mask[0]) and v[1].eq(rhs.mask[1]), + .mask => |*v| css.generic.eql(SmallList(Mask, 1), &v[0], &rhs.mask[0]) and (v[1] == rhs.mask[1]), .@"mask-border-source" => |*v| css.generic.eql(Image, v, &rhs.@"mask-border-source"), .@"mask-border-mode" => |*v| css.generic.eql(MaskBorderMode, v, &rhs.@"mask-border-mode"), .@"mask-border-slice" => |*v| css.generic.eql(BorderImageSlice, v, &rhs.@"mask-border-slice"), @@ -7424,13 +7424,13 @@ pub const Property = union(PropertyIdTag) { .@"mask-border-repeat" => |*v| css.generic.eql(BorderImageRepeat, v, &rhs.@"mask-border-repeat"), .@"mask-border" => |*v| css.generic.eql(MaskBorder, v, &rhs.@"mask-border"), .@"-webkit-mask-composite" => |*v| css.generic.eql(SmallList(WebKitMaskComposite, 1), v, &rhs.@"-webkit-mask-composite"), - .@"mask-source-type" => |*v| css.generic.eql(SmallList(WebKitMaskSourceType, 1), &v[0], &rhs.@"mask-source-type"[0]) and v[1].eq(rhs.@"mask-source-type"[1]), - .@"mask-box-image" => |*v| css.generic.eql(BorderImage, &v[0], &rhs.@"mask-box-image"[0]) and v[1].eq(rhs.@"mask-box-image"[1]), - .@"mask-box-image-source" => |*v| css.generic.eql(Image, &v[0], &rhs.@"mask-box-image-source"[0]) and v[1].eq(rhs.@"mask-box-image-source"[1]), - .@"mask-box-image-slice" => |*v| css.generic.eql(BorderImageSlice, &v[0], &rhs.@"mask-box-image-slice"[0]) and v[1].eq(rhs.@"mask-box-image-slice"[1]), - .@"mask-box-image-width" => |*v| css.generic.eql(Rect(BorderImageSideWidth), &v[0], &rhs.@"mask-box-image-width"[0]) and v[1].eq(rhs.@"mask-box-image-width"[1]), - .@"mask-box-image-outset" => |*v| css.generic.eql(Rect(LengthOrNumber), &v[0], &rhs.@"mask-box-image-outset"[0]) and v[1].eq(rhs.@"mask-box-image-outset"[1]), - .@"mask-box-image-repeat" => |*v| css.generic.eql(BorderImageRepeat, &v[0], &rhs.@"mask-box-image-repeat"[0]) and v[1].eq(rhs.@"mask-box-image-repeat"[1]), + .@"mask-source-type" => |*v| css.generic.eql(SmallList(WebKitMaskSourceType, 1), &v[0], &rhs.@"mask-source-type"[0]) and (v[1] == rhs.@"mask-source-type"[1]), + .@"mask-box-image" => |*v| css.generic.eql(BorderImage, &v[0], &rhs.@"mask-box-image"[0]) and (v[1] == rhs.@"mask-box-image"[1]), + .@"mask-box-image-source" => |*v| css.generic.eql(Image, &v[0], &rhs.@"mask-box-image-source"[0]) and (v[1] == rhs.@"mask-box-image-source"[1]), + .@"mask-box-image-slice" => |*v| css.generic.eql(BorderImageSlice, &v[0], &rhs.@"mask-box-image-slice"[0]) and (v[1] == rhs.@"mask-box-image-slice"[1]), + .@"mask-box-image-width" => |*v| css.generic.eql(Rect(BorderImageSideWidth), &v[0], &rhs.@"mask-box-image-width"[0]) and (v[1] == rhs.@"mask-box-image-width"[1]), + .@"mask-box-image-outset" => |*v| css.generic.eql(Rect(LengthOrNumber), &v[0], &rhs.@"mask-box-image-outset"[0]) and (v[1] == rhs.@"mask-box-image-outset"[1]), + .@"mask-box-image-repeat" => |*v| css.generic.eql(BorderImageRepeat, &v[0], &rhs.@"mask-box-image-repeat"[0]) and (v[1] == rhs.@"mask-box-image-repeat"[1]), .@"color-scheme" => |*v| css.generic.eql(ColorScheme, v, &rhs.@"color-scheme"), .unparsed => |*u| u.eql(&rhs.unparsed), .all => true, @@ -7689,7 +7689,10 @@ pub const PropertyId = union(PropertyIdTag) { unparsed, custom: CustomPropertyName, - pub usingnamespace PropertyIdImpl(); + pub const toCss = properties_impl.property_id_mixin.toCss; + pub const parse = properties_impl.property_id_mixin.parse; + pub const fromString = properties_impl.property_id_mixin.fromString; + pub const fromStr = fromString; /// Returns the property name, without any vendor prefixes. pub inline fn name(this: *const PropertyId) []const u8 { @@ -7700,116 +7703,116 @@ pub const PropertyId = union(PropertyIdTag) { /// Returns the vendor prefix for this property id. pub fn prefix(this: *const PropertyId) VendorPrefix { return switch (this.*) { - .@"background-color" => VendorPrefix.empty(), - .@"background-image" => VendorPrefix.empty(), - .@"background-position-x" => VendorPrefix.empty(), - .@"background-position-y" => VendorPrefix.empty(), - .@"background-position" => VendorPrefix.empty(), - .@"background-size" => VendorPrefix.empty(), - .@"background-repeat" => VendorPrefix.empty(), - .@"background-attachment" => VendorPrefix.empty(), + .@"background-color" => .empty, + .@"background-image" => .empty, + .@"background-position-x" => .empty, + .@"background-position-y" => .empty, + .@"background-position" => .empty, + .@"background-size" => .empty, + .@"background-repeat" => .empty, + .@"background-attachment" => .empty, .@"background-clip" => |p| p, - .@"background-origin" => VendorPrefix.empty(), - .background => VendorPrefix.empty(), + .@"background-origin" => .empty, + .background => .empty, .@"box-shadow" => |p| p, - .opacity => VendorPrefix.empty(), - .color => VendorPrefix.empty(), - .display => VendorPrefix.empty(), - .visibility => VendorPrefix.empty(), - .width => VendorPrefix.empty(), - .height => VendorPrefix.empty(), - .@"min-width" => VendorPrefix.empty(), - .@"min-height" => VendorPrefix.empty(), - .@"max-width" => VendorPrefix.empty(), - .@"max-height" => VendorPrefix.empty(), - .@"block-size" => VendorPrefix.empty(), - .@"inline-size" => VendorPrefix.empty(), - .@"min-block-size" => VendorPrefix.empty(), - .@"min-inline-size" => VendorPrefix.empty(), - .@"max-block-size" => VendorPrefix.empty(), - .@"max-inline-size" => VendorPrefix.empty(), + .opacity => .empty, + .color => .empty, + .display => .empty, + .visibility => .empty, + .width => .empty, + .height => .empty, + .@"min-width" => .empty, + .@"min-height" => .empty, + .@"max-width" => .empty, + .@"max-height" => .empty, + .@"block-size" => .empty, + .@"inline-size" => .empty, + .@"min-block-size" => .empty, + .@"min-inline-size" => .empty, + .@"max-block-size" => .empty, + .@"max-inline-size" => .empty, .@"box-sizing" => |p| p, - .@"aspect-ratio" => VendorPrefix.empty(), - .overflow => VendorPrefix.empty(), - .@"overflow-x" => VendorPrefix.empty(), - .@"overflow-y" => VendorPrefix.empty(), + .@"aspect-ratio" => .empty, + .overflow => .empty, + .@"overflow-x" => .empty, + .@"overflow-y" => .empty, .@"text-overflow" => |p| p, - .position => VendorPrefix.empty(), - .top => VendorPrefix.empty(), - .bottom => VendorPrefix.empty(), - .left => VendorPrefix.empty(), - .right => VendorPrefix.empty(), - .@"inset-block-start" => VendorPrefix.empty(), - .@"inset-block-end" => VendorPrefix.empty(), - .@"inset-inline-start" => VendorPrefix.empty(), - .@"inset-inline-end" => VendorPrefix.empty(), - .@"inset-block" => VendorPrefix.empty(), - .@"inset-inline" => VendorPrefix.empty(), - .inset => VendorPrefix.empty(), - .@"border-spacing" => VendorPrefix.empty(), - .@"border-top-color" => VendorPrefix.empty(), - .@"border-bottom-color" => VendorPrefix.empty(), - .@"border-left-color" => VendorPrefix.empty(), - .@"border-right-color" => VendorPrefix.empty(), - .@"border-block-start-color" => VendorPrefix.empty(), - .@"border-block-end-color" => VendorPrefix.empty(), - .@"border-inline-start-color" => VendorPrefix.empty(), - .@"border-inline-end-color" => VendorPrefix.empty(), - .@"border-top-style" => VendorPrefix.empty(), - .@"border-bottom-style" => VendorPrefix.empty(), - .@"border-left-style" => VendorPrefix.empty(), - .@"border-right-style" => VendorPrefix.empty(), - .@"border-block-start-style" => VendorPrefix.empty(), - .@"border-block-end-style" => VendorPrefix.empty(), - .@"border-inline-start-style" => VendorPrefix.empty(), - .@"border-inline-end-style" => VendorPrefix.empty(), - .@"border-top-width" => VendorPrefix.empty(), - .@"border-bottom-width" => VendorPrefix.empty(), - .@"border-left-width" => VendorPrefix.empty(), - .@"border-right-width" => VendorPrefix.empty(), - .@"border-block-start-width" => VendorPrefix.empty(), - .@"border-block-end-width" => VendorPrefix.empty(), - .@"border-inline-start-width" => VendorPrefix.empty(), - .@"border-inline-end-width" => VendorPrefix.empty(), + .position => .empty, + .top => .empty, + .bottom => .empty, + .left => .empty, + .right => .empty, + .@"inset-block-start" => .empty, + .@"inset-block-end" => .empty, + .@"inset-inline-start" => .empty, + .@"inset-inline-end" => .empty, + .@"inset-block" => .empty, + .@"inset-inline" => .empty, + .inset => .empty, + .@"border-spacing" => .empty, + .@"border-top-color" => .empty, + .@"border-bottom-color" => .empty, + .@"border-left-color" => .empty, + .@"border-right-color" => .empty, + .@"border-block-start-color" => .empty, + .@"border-block-end-color" => .empty, + .@"border-inline-start-color" => .empty, + .@"border-inline-end-color" => .empty, + .@"border-top-style" => .empty, + .@"border-bottom-style" => .empty, + .@"border-left-style" => .empty, + .@"border-right-style" => .empty, + .@"border-block-start-style" => .empty, + .@"border-block-end-style" => .empty, + .@"border-inline-start-style" => .empty, + .@"border-inline-end-style" => .empty, + .@"border-top-width" => .empty, + .@"border-bottom-width" => .empty, + .@"border-left-width" => .empty, + .@"border-right-width" => .empty, + .@"border-block-start-width" => .empty, + .@"border-block-end-width" => .empty, + .@"border-inline-start-width" => .empty, + .@"border-inline-end-width" => .empty, .@"border-top-left-radius" => |p| p, .@"border-top-right-radius" => |p| p, .@"border-bottom-left-radius" => |p| p, .@"border-bottom-right-radius" => |p| p, - .@"border-start-start-radius" => VendorPrefix.empty(), - .@"border-start-end-radius" => VendorPrefix.empty(), - .@"border-end-start-radius" => VendorPrefix.empty(), - .@"border-end-end-radius" => VendorPrefix.empty(), + .@"border-start-start-radius" => .empty, + .@"border-start-end-radius" => .empty, + .@"border-end-start-radius" => .empty, + .@"border-end-end-radius" => .empty, .@"border-radius" => |p| p, - .@"border-image-source" => VendorPrefix.empty(), - .@"border-image-outset" => VendorPrefix.empty(), - .@"border-image-repeat" => VendorPrefix.empty(), - .@"border-image-width" => VendorPrefix.empty(), - .@"border-image-slice" => VendorPrefix.empty(), + .@"border-image-source" => .empty, + .@"border-image-outset" => .empty, + .@"border-image-repeat" => .empty, + .@"border-image-width" => .empty, + .@"border-image-slice" => .empty, .@"border-image" => |p| p, - .@"border-color" => VendorPrefix.empty(), - .@"border-style" => VendorPrefix.empty(), - .@"border-width" => VendorPrefix.empty(), - .@"border-block-color" => VendorPrefix.empty(), - .@"border-block-style" => VendorPrefix.empty(), - .@"border-block-width" => VendorPrefix.empty(), - .@"border-inline-color" => VendorPrefix.empty(), - .@"border-inline-style" => VendorPrefix.empty(), - .@"border-inline-width" => VendorPrefix.empty(), - .border => VendorPrefix.empty(), - .@"border-top" => VendorPrefix.empty(), - .@"border-bottom" => VendorPrefix.empty(), - .@"border-left" => VendorPrefix.empty(), - .@"border-right" => VendorPrefix.empty(), - .@"border-block" => VendorPrefix.empty(), - .@"border-block-start" => VendorPrefix.empty(), - .@"border-block-end" => VendorPrefix.empty(), - .@"border-inline" => VendorPrefix.empty(), - .@"border-inline-start" => VendorPrefix.empty(), - .@"border-inline-end" => VendorPrefix.empty(), - .outline => VendorPrefix.empty(), - .@"outline-color" => VendorPrefix.empty(), - .@"outline-style" => VendorPrefix.empty(), - .@"outline-width" => VendorPrefix.empty(), + .@"border-color" => .empty, + .@"border-style" => .empty, + .@"border-width" => .empty, + .@"border-block-color" => .empty, + .@"border-block-style" => .empty, + .@"border-block-width" => .empty, + .@"border-inline-color" => .empty, + .@"border-inline-style" => .empty, + .@"border-inline-width" => .empty, + .border => .empty, + .@"border-top" => .empty, + .@"border-bottom" => .empty, + .@"border-left" => .empty, + .@"border-right" => .empty, + .@"border-block" => .empty, + .@"border-block-start" => .empty, + .@"border-block-end" => .empty, + .@"border-inline" => .empty, + .@"border-inline-start" => .empty, + .@"border-inline-end" => .empty, + .outline => .empty, + .@"outline-color" => .empty, + .@"outline-style" => .empty, + .@"outline-width" => .empty, .@"flex-direction" => |p| p, .@"flex-wrap" => |p| p, .@"flex-flow" => |p| p, @@ -7820,16 +7823,16 @@ pub const PropertyId = union(PropertyIdTag) { .order => |p| p, .@"align-content" => |p| p, .@"justify-content" => |p| p, - .@"place-content" => VendorPrefix.empty(), + .@"place-content" => .empty, .@"align-self" => |p| p, - .@"justify-self" => VendorPrefix.empty(), - .@"place-self" => VendorPrefix.empty(), + .@"justify-self" => .empty, + .@"place-self" => .empty, .@"align-items" => |p| p, - .@"justify-items" => VendorPrefix.empty(), - .@"place-items" => VendorPrefix.empty(), - .@"row-gap" => VendorPrefix.empty(), - .@"column-gap" => VendorPrefix.empty(), - .gap => VendorPrefix.empty(), + .@"justify-items" => .empty, + .@"place-items" => .empty, + .@"row-gap" => .empty, + .@"column-gap" => .empty, + .gap => .empty, .@"box-orient" => |p| p, .@"box-direction" => |p| p, .@"box-ordinal-group" => |p| p, @@ -7846,58 +7849,58 @@ pub const PropertyId = union(PropertyIdTag) { .@"flex-positive" => |p| p, .@"flex-negative" => |p| p, .@"flex-preferred-size" => |p| p, - .@"margin-top" => VendorPrefix.empty(), - .@"margin-bottom" => VendorPrefix.empty(), - .@"margin-left" => VendorPrefix.empty(), - .@"margin-right" => VendorPrefix.empty(), - .@"margin-block-start" => VendorPrefix.empty(), - .@"margin-block-end" => VendorPrefix.empty(), - .@"margin-inline-start" => VendorPrefix.empty(), - .@"margin-inline-end" => VendorPrefix.empty(), - .@"margin-block" => VendorPrefix.empty(), - .@"margin-inline" => VendorPrefix.empty(), - .margin => VendorPrefix.empty(), - .@"padding-top" => VendorPrefix.empty(), - .@"padding-bottom" => VendorPrefix.empty(), - .@"padding-left" => VendorPrefix.empty(), - .@"padding-right" => VendorPrefix.empty(), - .@"padding-block-start" => VendorPrefix.empty(), - .@"padding-block-end" => VendorPrefix.empty(), - .@"padding-inline-start" => VendorPrefix.empty(), - .@"padding-inline-end" => VendorPrefix.empty(), - .@"padding-block" => VendorPrefix.empty(), - .@"padding-inline" => VendorPrefix.empty(), - .padding => VendorPrefix.empty(), - .@"scroll-margin-top" => VendorPrefix.empty(), - .@"scroll-margin-bottom" => VendorPrefix.empty(), - .@"scroll-margin-left" => VendorPrefix.empty(), - .@"scroll-margin-right" => VendorPrefix.empty(), - .@"scroll-margin-block-start" => VendorPrefix.empty(), - .@"scroll-margin-block-end" => VendorPrefix.empty(), - .@"scroll-margin-inline-start" => VendorPrefix.empty(), - .@"scroll-margin-inline-end" => VendorPrefix.empty(), - .@"scroll-margin-block" => VendorPrefix.empty(), - .@"scroll-margin-inline" => VendorPrefix.empty(), - .@"scroll-margin" => VendorPrefix.empty(), - .@"scroll-padding-top" => VendorPrefix.empty(), - .@"scroll-padding-bottom" => VendorPrefix.empty(), - .@"scroll-padding-left" => VendorPrefix.empty(), - .@"scroll-padding-right" => VendorPrefix.empty(), - .@"scroll-padding-block-start" => VendorPrefix.empty(), - .@"scroll-padding-block-end" => VendorPrefix.empty(), - .@"scroll-padding-inline-start" => VendorPrefix.empty(), - .@"scroll-padding-inline-end" => VendorPrefix.empty(), - .@"scroll-padding-block" => VendorPrefix.empty(), - .@"scroll-padding-inline" => VendorPrefix.empty(), - .@"scroll-padding" => VendorPrefix.empty(), - .@"font-weight" => VendorPrefix.empty(), - .@"font-size" => VendorPrefix.empty(), - .@"font-stretch" => VendorPrefix.empty(), - .@"font-family" => VendorPrefix.empty(), - .@"font-style" => VendorPrefix.empty(), - .@"font-variant-caps" => VendorPrefix.empty(), - .@"line-height" => VendorPrefix.empty(), - .font => VendorPrefix.empty(), + .@"margin-top" => .empty, + .@"margin-bottom" => .empty, + .@"margin-left" => .empty, + .@"margin-right" => .empty, + .@"margin-block-start" => .empty, + .@"margin-block-end" => .empty, + .@"margin-inline-start" => .empty, + .@"margin-inline-end" => .empty, + .@"margin-block" => .empty, + .@"margin-inline" => .empty, + .margin => .empty, + .@"padding-top" => .empty, + .@"padding-bottom" => .empty, + .@"padding-left" => .empty, + .@"padding-right" => .empty, + .@"padding-block-start" => .empty, + .@"padding-block-end" => .empty, + .@"padding-inline-start" => .empty, + .@"padding-inline-end" => .empty, + .@"padding-block" => .empty, + .@"padding-inline" => .empty, + .padding => .empty, + .@"scroll-margin-top" => .empty, + .@"scroll-margin-bottom" => .empty, + .@"scroll-margin-left" => .empty, + .@"scroll-margin-right" => .empty, + .@"scroll-margin-block-start" => .empty, + .@"scroll-margin-block-end" => .empty, + .@"scroll-margin-inline-start" => .empty, + .@"scroll-margin-inline-end" => .empty, + .@"scroll-margin-block" => .empty, + .@"scroll-margin-inline" => .empty, + .@"scroll-margin" => .empty, + .@"scroll-padding-top" => .empty, + .@"scroll-padding-bottom" => .empty, + .@"scroll-padding-left" => .empty, + .@"scroll-padding-right" => .empty, + .@"scroll-padding-block-start" => .empty, + .@"scroll-padding-block-end" => .empty, + .@"scroll-padding-inline-start" => .empty, + .@"scroll-padding-inline-end" => .empty, + .@"scroll-padding-block" => .empty, + .@"scroll-padding-inline" => .empty, + .@"scroll-padding" => .empty, + .@"font-weight" => .empty, + .@"font-size" => .empty, + .@"font-stretch" => .empty, + .@"font-family" => .empty, + .@"font-style" => .empty, + .@"font-variant-caps" => .empty, + .@"line-height" => .empty, + .font => .empty, .@"transition-property" => |p| p, .@"transition-duration" => |p| p, .@"transition-delay" => |p| p, @@ -7906,38 +7909,38 @@ pub const PropertyId = union(PropertyIdTag) { .transform => |p| p, .@"transform-origin" => |p| p, .@"transform-style" => |p| p, - .@"transform-box" => VendorPrefix.empty(), + .@"transform-box" => .empty, .@"backface-visibility" => |p| p, .perspective => |p| p, .@"perspective-origin" => |p| p, - .translate => VendorPrefix.empty(), - .rotate => VendorPrefix.empty(), - .scale => VendorPrefix.empty(), + .translate => .empty, + .rotate => .empty, + .scale => .empty, .@"text-decoration-color" => |p| p, .@"text-emphasis-color" => |p| p, - .@"text-shadow" => VendorPrefix.empty(), - .direction => VendorPrefix.empty(), - .composes => VendorPrefix.empty(), + .@"text-shadow" => .empty, + .direction => .empty, + .composes => .empty, .@"mask-image" => |p| p, - .@"mask-mode" => VendorPrefix.empty(), + .@"mask-mode" => .empty, .@"mask-repeat" => |p| p, - .@"mask-position-x" => VendorPrefix.empty(), - .@"mask-position-y" => VendorPrefix.empty(), + .@"mask-position-x" => .empty, + .@"mask-position-y" => .empty, .@"mask-position" => |p| p, .@"mask-clip" => |p| p, .@"mask-origin" => |p| p, .@"mask-size" => |p| p, - .@"mask-composite" => VendorPrefix.empty(), - .@"mask-type" => VendorPrefix.empty(), + .@"mask-composite" => .empty, + .@"mask-type" => .empty, .mask => |p| p, - .@"mask-border-source" => VendorPrefix.empty(), - .@"mask-border-mode" => VendorPrefix.empty(), - .@"mask-border-slice" => VendorPrefix.empty(), - .@"mask-border-width" => VendorPrefix.empty(), - .@"mask-border-outset" => VendorPrefix.empty(), - .@"mask-border-repeat" => VendorPrefix.empty(), - .@"mask-border" => VendorPrefix.empty(), - .@"-webkit-mask-composite" => VendorPrefix.empty(), + .@"mask-border-source" => .empty, + .@"mask-border-mode" => .empty, + .@"mask-border-slice" => .empty, + .@"mask-border-width" => .empty, + .@"mask-border-outset" => .empty, + .@"mask-border-repeat" => .empty, + .@"mask-border" => .empty, + .@"-webkit-mask-composite" => .empty, .@"mask-source-type" => |p| p, .@"mask-box-image" => |p| p, .@"mask-box-image-source" => |p| p, @@ -7945,8 +7948,8 @@ pub const PropertyId = union(PropertyIdTag) { .@"mask-box-image-width" => |p| p, .@"mask-box-image-outset" => |p| p, .@"mask-box-image-repeat" => |p| p, - .@"color-scheme" => VendorPrefix.empty(), - .all, .custom, .unparsed => VendorPrefix.empty(), + .@"color-scheme" => .empty, + .all, .custom, .unparsed => .empty, }; } @@ -7957,987 +7960,987 @@ pub const PropertyId = union(PropertyIdTag) { switch (prop) { .@"background-color" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"background-color"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"background-color"; }, .@"background-image" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"background-image"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"background-image"; }, .@"background-position-x" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"background-position-x"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"background-position-x"; }, .@"background-position-y" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"background-position-y"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"background-position-y"; }, .@"background-position" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"background-position"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"background-position"; }, .@"background-size" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"background-size"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"background-size"; }, .@"background-repeat" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"background-repeat"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"background-repeat"; }, .@"background-attachment" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"background-attachment"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"background-attachment"; }, .@"background-clip" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true, .moz = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"background-clip" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"background-clip" = pre }; }, .@"background-origin" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"background-origin"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"background-origin"; }, .background => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .background; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .background; }, .@"box-shadow" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true, .moz = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"box-shadow" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"box-shadow" = pre }; }, .opacity => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .opacity; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .opacity; }, .color => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .color; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .color; }, .display => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .display; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .display; }, .visibility => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .visibility; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .visibility; }, .width => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .width; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .width; }, .height => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .height; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .height; }, .@"min-width" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"min-width"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"min-width"; }, .@"min-height" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"min-height"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"min-height"; }, .@"max-width" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"max-width"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"max-width"; }, .@"max-height" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"max-height"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"max-height"; }, .@"block-size" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"block-size"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"block-size"; }, .@"inline-size" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"inline-size"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"inline-size"; }, .@"min-block-size" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"min-block-size"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"min-block-size"; }, .@"min-inline-size" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"min-inline-size"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"min-inline-size"; }, .@"max-block-size" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"max-block-size"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"max-block-size"; }, .@"max-inline-size" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"max-inline-size"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"max-inline-size"; }, .@"box-sizing" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true, .moz = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"box-sizing" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"box-sizing" = pre }; }, .@"aspect-ratio" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"aspect-ratio"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"aspect-ratio"; }, .overflow => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .overflow; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .overflow; }, .@"overflow-x" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"overflow-x"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"overflow-x"; }, .@"overflow-y" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"overflow-y"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"overflow-y"; }, .@"text-overflow" => { const allowed_prefixes = VendorPrefix{ .none = true, .o = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"text-overflow" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"text-overflow" = pre }; }, .position => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .position; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .position; }, .top => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .top; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .top; }, .bottom => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .bottom; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .bottom; }, .left => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .left; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .left; }, .right => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .right; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .right; }, .@"inset-block-start" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"inset-block-start"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"inset-block-start"; }, .@"inset-block-end" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"inset-block-end"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"inset-block-end"; }, .@"inset-inline-start" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"inset-inline-start"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"inset-inline-start"; }, .@"inset-inline-end" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"inset-inline-end"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"inset-inline-end"; }, .@"inset-block" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"inset-block"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"inset-block"; }, .@"inset-inline" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"inset-inline"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"inset-inline"; }, .inset => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .inset; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .inset; }, .@"border-spacing" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-spacing"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-spacing"; }, .@"border-top-color" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-top-color"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-top-color"; }, .@"border-bottom-color" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-bottom-color"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-bottom-color"; }, .@"border-left-color" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-left-color"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-left-color"; }, .@"border-right-color" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-right-color"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-right-color"; }, .@"border-block-start-color" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-block-start-color"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-block-start-color"; }, .@"border-block-end-color" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-block-end-color"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-block-end-color"; }, .@"border-inline-start-color" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-inline-start-color"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-inline-start-color"; }, .@"border-inline-end-color" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-inline-end-color"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-inline-end-color"; }, .@"border-top-style" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-top-style"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-top-style"; }, .@"border-bottom-style" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-bottom-style"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-bottom-style"; }, .@"border-left-style" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-left-style"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-left-style"; }, .@"border-right-style" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-right-style"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-right-style"; }, .@"border-block-start-style" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-block-start-style"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-block-start-style"; }, .@"border-block-end-style" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-block-end-style"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-block-end-style"; }, .@"border-inline-start-style" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-inline-start-style"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-inline-start-style"; }, .@"border-inline-end-style" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-inline-end-style"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-inline-end-style"; }, .@"border-top-width" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-top-width"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-top-width"; }, .@"border-bottom-width" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-bottom-width"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-bottom-width"; }, .@"border-left-width" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-left-width"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-left-width"; }, .@"border-right-width" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-right-width"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-right-width"; }, .@"border-block-start-width" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-block-start-width"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-block-start-width"; }, .@"border-block-end-width" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-block-end-width"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-block-end-width"; }, .@"border-inline-start-width" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-inline-start-width"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-inline-start-width"; }, .@"border-inline-end-width" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-inline-end-width"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-inline-end-width"; }, .@"border-top-left-radius" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true, .moz = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"border-top-left-radius" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"border-top-left-radius" = pre }; }, .@"border-top-right-radius" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true, .moz = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"border-top-right-radius" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"border-top-right-radius" = pre }; }, .@"border-bottom-left-radius" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true, .moz = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"border-bottom-left-radius" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"border-bottom-left-radius" = pre }; }, .@"border-bottom-right-radius" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true, .moz = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"border-bottom-right-radius" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"border-bottom-right-radius" = pre }; }, .@"border-start-start-radius" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-start-start-radius"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-start-start-radius"; }, .@"border-start-end-radius" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-start-end-radius"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-start-end-radius"; }, .@"border-end-start-radius" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-end-start-radius"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-end-start-radius"; }, .@"border-end-end-radius" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-end-end-radius"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-end-end-radius"; }, .@"border-radius" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true, .moz = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"border-radius" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"border-radius" = pre }; }, .@"border-image-source" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-image-source"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-image-source"; }, .@"border-image-outset" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-image-outset"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-image-outset"; }, .@"border-image-repeat" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-image-repeat"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-image-repeat"; }, .@"border-image-width" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-image-width"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-image-width"; }, .@"border-image-slice" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-image-slice"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-image-slice"; }, .@"border-image" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true, .moz = true, .o = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"border-image" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"border-image" = pre }; }, .@"border-color" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-color"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-color"; }, .@"border-style" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-style"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-style"; }, .@"border-width" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-width"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-width"; }, .@"border-block-color" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-block-color"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-block-color"; }, .@"border-block-style" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-block-style"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-block-style"; }, .@"border-block-width" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-block-width"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-block-width"; }, .@"border-inline-color" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-inline-color"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-inline-color"; }, .@"border-inline-style" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-inline-style"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-inline-style"; }, .@"border-inline-width" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-inline-width"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-inline-width"; }, .border => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .border; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .border; }, .@"border-top" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-top"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-top"; }, .@"border-bottom" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-bottom"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-bottom"; }, .@"border-left" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-left"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-left"; }, .@"border-right" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-right"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-right"; }, .@"border-block" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-block"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-block"; }, .@"border-block-start" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-block-start"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-block-start"; }, .@"border-block-end" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-block-end"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-block-end"; }, .@"border-inline" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-inline"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-inline"; }, .@"border-inline-start" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-inline-start"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-inline-start"; }, .@"border-inline-end" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"border-inline-end"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"border-inline-end"; }, .outline => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .outline; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .outline; }, .@"outline-color" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"outline-color"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"outline-color"; }, .@"outline-style" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"outline-style"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"outline-style"; }, .@"outline-width" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"outline-width"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"outline-width"; }, .@"flex-direction" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true, .ms = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"flex-direction" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"flex-direction" = pre }; }, .@"flex-wrap" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true, .ms = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"flex-wrap" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"flex-wrap" = pre }; }, .@"flex-flow" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true, .ms = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"flex-flow" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"flex-flow" = pre }; }, .@"flex-grow" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"flex-grow" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"flex-grow" = pre }; }, .@"flex-shrink" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"flex-shrink" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"flex-shrink" = pre }; }, .@"flex-basis" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"flex-basis" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"flex-basis" = pre }; }, .flex => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true, .ms = true }; - if (allowed_prefixes.contains(pre)) return .{ .flex = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .flex = pre }; }, .order => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true }; - if (allowed_prefixes.contains(pre)) return .{ .order = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .order = pre }; }, .@"align-content" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"align-content" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"align-content" = pre }; }, .@"justify-content" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"justify-content" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"justify-content" = pre }; }, .@"place-content" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"place-content"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"place-content"; }, .@"align-self" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"align-self" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"align-self" = pre }; }, .@"justify-self" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"justify-self"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"justify-self"; }, .@"place-self" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"place-self"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"place-self"; }, .@"align-items" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"align-items" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"align-items" = pre }; }, .@"justify-items" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"justify-items"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"justify-items"; }, .@"place-items" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"place-items"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"place-items"; }, .@"row-gap" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"row-gap"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"row-gap"; }, .@"column-gap" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"column-gap"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"column-gap"; }, .gap => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .gap; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .gap; }, .@"box-orient" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true, .moz = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"box-orient" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"box-orient" = pre }; }, .@"box-direction" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true, .moz = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"box-direction" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"box-direction" = pre }; }, .@"box-ordinal-group" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true, .moz = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"box-ordinal-group" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"box-ordinal-group" = pre }; }, .@"box-align" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true, .moz = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"box-align" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"box-align" = pre }; }, .@"box-flex" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true, .moz = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"box-flex" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"box-flex" = pre }; }, .@"box-flex-group" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"box-flex-group" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"box-flex-group" = pre }; }, .@"box-pack" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true, .moz = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"box-pack" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"box-pack" = pre }; }, .@"box-lines" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true, .moz = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"box-lines" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"box-lines" = pre }; }, .@"flex-pack" => { const allowed_prefixes = VendorPrefix{ .none = true, .ms = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"flex-pack" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"flex-pack" = pre }; }, .@"flex-order" => { const allowed_prefixes = VendorPrefix{ .none = true, .ms = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"flex-order" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"flex-order" = pre }; }, .@"flex-align" => { const allowed_prefixes = VendorPrefix{ .none = true, .ms = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"flex-align" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"flex-align" = pre }; }, .@"flex-item-align" => { const allowed_prefixes = VendorPrefix{ .none = true, .ms = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"flex-item-align" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"flex-item-align" = pre }; }, .@"flex-line-pack" => { const allowed_prefixes = VendorPrefix{ .none = true, .ms = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"flex-line-pack" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"flex-line-pack" = pre }; }, .@"flex-positive" => { const allowed_prefixes = VendorPrefix{ .none = true, .ms = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"flex-positive" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"flex-positive" = pre }; }, .@"flex-negative" => { const allowed_prefixes = VendorPrefix{ .none = true, .ms = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"flex-negative" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"flex-negative" = pre }; }, .@"flex-preferred-size" => { const allowed_prefixes = VendorPrefix{ .none = true, .ms = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"flex-preferred-size" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"flex-preferred-size" = pre }; }, .@"margin-top" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"margin-top"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"margin-top"; }, .@"margin-bottom" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"margin-bottom"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"margin-bottom"; }, .@"margin-left" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"margin-left"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"margin-left"; }, .@"margin-right" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"margin-right"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"margin-right"; }, .@"margin-block-start" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"margin-block-start"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"margin-block-start"; }, .@"margin-block-end" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"margin-block-end"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"margin-block-end"; }, .@"margin-inline-start" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"margin-inline-start"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"margin-inline-start"; }, .@"margin-inline-end" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"margin-inline-end"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"margin-inline-end"; }, .@"margin-block" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"margin-block"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"margin-block"; }, .@"margin-inline" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"margin-inline"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"margin-inline"; }, .margin => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .margin; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .margin; }, .@"padding-top" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"padding-top"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"padding-top"; }, .@"padding-bottom" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"padding-bottom"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"padding-bottom"; }, .@"padding-left" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"padding-left"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"padding-left"; }, .@"padding-right" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"padding-right"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"padding-right"; }, .@"padding-block-start" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"padding-block-start"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"padding-block-start"; }, .@"padding-block-end" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"padding-block-end"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"padding-block-end"; }, .@"padding-inline-start" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"padding-inline-start"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"padding-inline-start"; }, .@"padding-inline-end" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"padding-inline-end"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"padding-inline-end"; }, .@"padding-block" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"padding-block"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"padding-block"; }, .@"padding-inline" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"padding-inline"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"padding-inline"; }, .padding => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .padding; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .padding; }, .@"scroll-margin-top" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"scroll-margin-top"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"scroll-margin-top"; }, .@"scroll-margin-bottom" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"scroll-margin-bottom"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"scroll-margin-bottom"; }, .@"scroll-margin-left" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"scroll-margin-left"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"scroll-margin-left"; }, .@"scroll-margin-right" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"scroll-margin-right"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"scroll-margin-right"; }, .@"scroll-margin-block-start" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"scroll-margin-block-start"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"scroll-margin-block-start"; }, .@"scroll-margin-block-end" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"scroll-margin-block-end"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"scroll-margin-block-end"; }, .@"scroll-margin-inline-start" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"scroll-margin-inline-start"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"scroll-margin-inline-start"; }, .@"scroll-margin-inline-end" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"scroll-margin-inline-end"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"scroll-margin-inline-end"; }, .@"scroll-margin-block" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"scroll-margin-block"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"scroll-margin-block"; }, .@"scroll-margin-inline" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"scroll-margin-inline"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"scroll-margin-inline"; }, .@"scroll-margin" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"scroll-margin"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"scroll-margin"; }, .@"scroll-padding-top" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"scroll-padding-top"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"scroll-padding-top"; }, .@"scroll-padding-bottom" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"scroll-padding-bottom"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"scroll-padding-bottom"; }, .@"scroll-padding-left" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"scroll-padding-left"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"scroll-padding-left"; }, .@"scroll-padding-right" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"scroll-padding-right"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"scroll-padding-right"; }, .@"scroll-padding-block-start" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"scroll-padding-block-start"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"scroll-padding-block-start"; }, .@"scroll-padding-block-end" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"scroll-padding-block-end"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"scroll-padding-block-end"; }, .@"scroll-padding-inline-start" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"scroll-padding-inline-start"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"scroll-padding-inline-start"; }, .@"scroll-padding-inline-end" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"scroll-padding-inline-end"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"scroll-padding-inline-end"; }, .@"scroll-padding-block" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"scroll-padding-block"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"scroll-padding-block"; }, .@"scroll-padding-inline" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"scroll-padding-inline"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"scroll-padding-inline"; }, .@"scroll-padding" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"scroll-padding"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"scroll-padding"; }, .@"font-weight" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"font-weight"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"font-weight"; }, .@"font-size" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"font-size"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"font-size"; }, .@"font-stretch" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"font-stretch"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"font-stretch"; }, .@"font-family" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"font-family"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"font-family"; }, .@"font-style" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"font-style"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"font-style"; }, .@"font-variant-caps" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"font-variant-caps"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"font-variant-caps"; }, .@"line-height" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"line-height"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"line-height"; }, .font => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .font; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .font; }, .@"transition-property" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true, .moz = true, .ms = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"transition-property" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"transition-property" = pre }; }, .@"transition-duration" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true, .moz = true, .ms = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"transition-duration" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"transition-duration" = pre }; }, .@"transition-delay" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true, .moz = true, .ms = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"transition-delay" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"transition-delay" = pre }; }, .@"transition-timing-function" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true, .moz = true, .ms = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"transition-timing-function" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"transition-timing-function" = pre }; }, .transition => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true, .moz = true, .ms = true }; - if (allowed_prefixes.contains(pre)) return .{ .transition = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .transition = pre }; }, .transform => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true, .moz = true, .ms = true, .o = true }; - if (allowed_prefixes.contains(pre)) return .{ .transform = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .transform = pre }; }, .@"transform-origin" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true, .moz = true, .ms = true, .o = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"transform-origin" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"transform-origin" = pre }; }, .@"transform-style" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true, .moz = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"transform-style" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"transform-style" = pre }; }, .@"transform-box" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"transform-box"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"transform-box"; }, .@"backface-visibility" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true, .moz = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"backface-visibility" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"backface-visibility" = pre }; }, .perspective => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true, .moz = true }; - if (allowed_prefixes.contains(pre)) return .{ .perspective = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .perspective = pre }; }, .@"perspective-origin" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true, .moz = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"perspective-origin" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"perspective-origin" = pre }; }, .translate => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .translate; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .translate; }, .rotate => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .rotate; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .rotate; }, .scale => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .scale; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .scale; }, .@"text-decoration-color" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true, .moz = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"text-decoration-color" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"text-decoration-color" = pre }; }, .@"text-emphasis-color" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"text-emphasis-color" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"text-emphasis-color" = pre }; }, .@"text-shadow" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"text-shadow"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"text-shadow"; }, .direction => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .direction; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .direction; }, .composes => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .composes; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .composes; }, .@"mask-image" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"mask-image" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"mask-image" = pre }; }, .@"mask-mode" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"mask-mode"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"mask-mode"; }, .@"mask-repeat" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"mask-repeat" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"mask-repeat" = pre }; }, .@"mask-position-x" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"mask-position-x"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"mask-position-x"; }, .@"mask-position-y" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"mask-position-y"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"mask-position-y"; }, .@"mask-position" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"mask-position" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"mask-position" = pre }; }, .@"mask-clip" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"mask-clip" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"mask-clip" = pre }; }, .@"mask-origin" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"mask-origin" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"mask-origin" = pre }; }, .@"mask-size" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"mask-size" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"mask-size" = pre }; }, .@"mask-composite" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"mask-composite"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"mask-composite"; }, .@"mask-type" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"mask-type"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"mask-type"; }, .mask => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true }; - if (allowed_prefixes.contains(pre)) return .{ .mask = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .mask = pre }; }, .@"mask-border-source" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"mask-border-source"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"mask-border-source"; }, .@"mask-border-mode" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"mask-border-mode"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"mask-border-mode"; }, .@"mask-border-slice" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"mask-border-slice"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"mask-border-slice"; }, .@"mask-border-width" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"mask-border-width"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"mask-border-width"; }, .@"mask-border-outset" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"mask-border-outset"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"mask-border-outset"; }, .@"mask-border-repeat" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"mask-border-repeat"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"mask-border-repeat"; }, .@"mask-border" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"mask-border"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"mask-border"; }, .@"-webkit-mask-composite" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"-webkit-mask-composite"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"-webkit-mask-composite"; }, .@"mask-source-type" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"mask-source-type" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"mask-source-type" = pre }; }, .@"mask-box-image" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"mask-box-image" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"mask-box-image" = pre }; }, .@"mask-box-image-source" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"mask-box-image-source" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"mask-box-image-source" = pre }; }, .@"mask-box-image-slice" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"mask-box-image-slice" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"mask-box-image-slice" = pre }; }, .@"mask-box-image-width" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"mask-box-image-width" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"mask-box-image-width" = pre }; }, .@"mask-box-image-outset" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"mask-box-image-outset" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"mask-box-image-outset" = pre }; }, .@"mask-box-image-repeat" => { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true }; - if (allowed_prefixes.contains(pre)) return .{ .@"mask-box-image-repeat" = pre }; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .{ .@"mask-box-image-repeat" = pre }; }, .@"color-scheme" => { const allowed_prefixes = VendorPrefix{ .none = true }; - if (allowed_prefixes.contains(pre)) return .@"color-scheme"; + if (bits.contains(VendorPrefix, allowed_prefixes, pre)) return .@"color-scheme"; }, } } @@ -9199,383 +9202,13 @@ pub const PropertyId = union(PropertyIdTag) { pub fn addPrefix(this: *PropertyId, pre: VendorPrefix) void { return switch (this.*) { - .@"background-color" => {}, - .@"background-image" => {}, - .@"background-position-x" => {}, - .@"background-position-y" => {}, - .@"background-position" => {}, - .@"background-size" => {}, - .@"background-repeat" => {}, - .@"background-attachment" => {}, - .@"background-clip" => |*p| { - p.insert(pre); + inline else => |*p| { + switch (@TypeOf(p)) { + *void, *CustomPropertyName => {}, + *VendorPrefix => bits.insert(VendorPrefix, p, pre), + else => |T| @compileError("unexpected " ++ @typeName(T)), + } }, - .@"background-origin" => {}, - .background => {}, - .@"box-shadow" => |*p| { - p.insert(pre); - }, - .opacity => {}, - .color => {}, - .display => {}, - .visibility => {}, - .width => {}, - .height => {}, - .@"min-width" => {}, - .@"min-height" => {}, - .@"max-width" => {}, - .@"max-height" => {}, - .@"block-size" => {}, - .@"inline-size" => {}, - .@"min-block-size" => {}, - .@"min-inline-size" => {}, - .@"max-block-size" => {}, - .@"max-inline-size" => {}, - .@"box-sizing" => |*p| { - p.insert(pre); - }, - .@"aspect-ratio" => {}, - .overflow => {}, - .@"overflow-x" => {}, - .@"overflow-y" => {}, - .@"text-overflow" => |*p| { - p.insert(pre); - }, - .position => {}, - .top => {}, - .bottom => {}, - .left => {}, - .right => {}, - .@"inset-block-start" => {}, - .@"inset-block-end" => {}, - .@"inset-inline-start" => {}, - .@"inset-inline-end" => {}, - .@"inset-block" => {}, - .@"inset-inline" => {}, - .inset => {}, - .@"border-spacing" => {}, - .@"border-top-color" => {}, - .@"border-bottom-color" => {}, - .@"border-left-color" => {}, - .@"border-right-color" => {}, - .@"border-block-start-color" => {}, - .@"border-block-end-color" => {}, - .@"border-inline-start-color" => {}, - .@"border-inline-end-color" => {}, - .@"border-top-style" => {}, - .@"border-bottom-style" => {}, - .@"border-left-style" => {}, - .@"border-right-style" => {}, - .@"border-block-start-style" => {}, - .@"border-block-end-style" => {}, - .@"border-inline-start-style" => {}, - .@"border-inline-end-style" => {}, - .@"border-top-width" => {}, - .@"border-bottom-width" => {}, - .@"border-left-width" => {}, - .@"border-right-width" => {}, - .@"border-block-start-width" => {}, - .@"border-block-end-width" => {}, - .@"border-inline-start-width" => {}, - .@"border-inline-end-width" => {}, - .@"border-top-left-radius" => |*p| { - p.insert(pre); - }, - .@"border-top-right-radius" => |*p| { - p.insert(pre); - }, - .@"border-bottom-left-radius" => |*p| { - p.insert(pre); - }, - .@"border-bottom-right-radius" => |*p| { - p.insert(pre); - }, - .@"border-start-start-radius" => {}, - .@"border-start-end-radius" => {}, - .@"border-end-start-radius" => {}, - .@"border-end-end-radius" => {}, - .@"border-radius" => |*p| { - p.insert(pre); - }, - .@"border-image-source" => {}, - .@"border-image-outset" => {}, - .@"border-image-repeat" => {}, - .@"border-image-width" => {}, - .@"border-image-slice" => {}, - .@"border-image" => |*p| { - p.insert(pre); - }, - .@"border-color" => {}, - .@"border-style" => {}, - .@"border-width" => {}, - .@"border-block-color" => {}, - .@"border-block-style" => {}, - .@"border-block-width" => {}, - .@"border-inline-color" => {}, - .@"border-inline-style" => {}, - .@"border-inline-width" => {}, - .border => {}, - .@"border-top" => {}, - .@"border-bottom" => {}, - .@"border-left" => {}, - .@"border-right" => {}, - .@"border-block" => {}, - .@"border-block-start" => {}, - .@"border-block-end" => {}, - .@"border-inline" => {}, - .@"border-inline-start" => {}, - .@"border-inline-end" => {}, - .outline => {}, - .@"outline-color" => {}, - .@"outline-style" => {}, - .@"outline-width" => {}, - .@"flex-direction" => |*p| { - p.insert(pre); - }, - .@"flex-wrap" => |*p| { - p.insert(pre); - }, - .@"flex-flow" => |*p| { - p.insert(pre); - }, - .@"flex-grow" => |*p| { - p.insert(pre); - }, - .@"flex-shrink" => |*p| { - p.insert(pre); - }, - .@"flex-basis" => |*p| { - p.insert(pre); - }, - .flex => |*p| { - p.insert(pre); - }, - .order => |*p| { - p.insert(pre); - }, - .@"align-content" => |*p| { - p.insert(pre); - }, - .@"justify-content" => |*p| { - p.insert(pre); - }, - .@"place-content" => {}, - .@"align-self" => |*p| { - p.insert(pre); - }, - .@"justify-self" => {}, - .@"place-self" => {}, - .@"align-items" => |*p| { - p.insert(pre); - }, - .@"justify-items" => {}, - .@"place-items" => {}, - .@"row-gap" => {}, - .@"column-gap" => {}, - .gap => {}, - .@"box-orient" => |*p| { - p.insert(pre); - }, - .@"box-direction" => |*p| { - p.insert(pre); - }, - .@"box-ordinal-group" => |*p| { - p.insert(pre); - }, - .@"box-align" => |*p| { - p.insert(pre); - }, - .@"box-flex" => |*p| { - p.insert(pre); - }, - .@"box-flex-group" => |*p| { - p.insert(pre); - }, - .@"box-pack" => |*p| { - p.insert(pre); - }, - .@"box-lines" => |*p| { - p.insert(pre); - }, - .@"flex-pack" => |*p| { - p.insert(pre); - }, - .@"flex-order" => |*p| { - p.insert(pre); - }, - .@"flex-align" => |*p| { - p.insert(pre); - }, - .@"flex-item-align" => |*p| { - p.insert(pre); - }, - .@"flex-line-pack" => |*p| { - p.insert(pre); - }, - .@"flex-positive" => |*p| { - p.insert(pre); - }, - .@"flex-negative" => |*p| { - p.insert(pre); - }, - .@"flex-preferred-size" => |*p| { - p.insert(pre); - }, - .@"margin-top" => {}, - .@"margin-bottom" => {}, - .@"margin-left" => {}, - .@"margin-right" => {}, - .@"margin-block-start" => {}, - .@"margin-block-end" => {}, - .@"margin-inline-start" => {}, - .@"margin-inline-end" => {}, - .@"margin-block" => {}, - .@"margin-inline" => {}, - .margin => {}, - .@"padding-top" => {}, - .@"padding-bottom" => {}, - .@"padding-left" => {}, - .@"padding-right" => {}, - .@"padding-block-start" => {}, - .@"padding-block-end" => {}, - .@"padding-inline-start" => {}, - .@"padding-inline-end" => {}, - .@"padding-block" => {}, - .@"padding-inline" => {}, - .padding => {}, - .@"scroll-margin-top" => {}, - .@"scroll-margin-bottom" => {}, - .@"scroll-margin-left" => {}, - .@"scroll-margin-right" => {}, - .@"scroll-margin-block-start" => {}, - .@"scroll-margin-block-end" => {}, - .@"scroll-margin-inline-start" => {}, - .@"scroll-margin-inline-end" => {}, - .@"scroll-margin-block" => {}, - .@"scroll-margin-inline" => {}, - .@"scroll-margin" => {}, - .@"scroll-padding-top" => {}, - .@"scroll-padding-bottom" => {}, - .@"scroll-padding-left" => {}, - .@"scroll-padding-right" => {}, - .@"scroll-padding-block-start" => {}, - .@"scroll-padding-block-end" => {}, - .@"scroll-padding-inline-start" => {}, - .@"scroll-padding-inline-end" => {}, - .@"scroll-padding-block" => {}, - .@"scroll-padding-inline" => {}, - .@"scroll-padding" => {}, - .@"font-weight" => {}, - .@"font-size" => {}, - .@"font-stretch" => {}, - .@"font-family" => {}, - .@"font-style" => {}, - .@"font-variant-caps" => {}, - .@"line-height" => {}, - .font => {}, - .@"transition-property" => |*p| { - p.insert(pre); - }, - .@"transition-duration" => |*p| { - p.insert(pre); - }, - .@"transition-delay" => |*p| { - p.insert(pre); - }, - .@"transition-timing-function" => |*p| { - p.insert(pre); - }, - .transition => |*p| { - p.insert(pre); - }, - .transform => |*p| { - p.insert(pre); - }, - .@"transform-origin" => |*p| { - p.insert(pre); - }, - .@"transform-style" => |*p| { - p.insert(pre); - }, - .@"transform-box" => {}, - .@"backface-visibility" => |*p| { - p.insert(pre); - }, - .perspective => |*p| { - p.insert(pre); - }, - .@"perspective-origin" => |*p| { - p.insert(pre); - }, - .translate => {}, - .rotate => {}, - .scale => {}, - .@"text-decoration-color" => |*p| { - p.insert(pre); - }, - .@"text-emphasis-color" => |*p| { - p.insert(pre); - }, - .@"text-shadow" => {}, - .direction => {}, - .composes => {}, - .@"mask-image" => |*p| { - p.insert(pre); - }, - .@"mask-mode" => {}, - .@"mask-repeat" => |*p| { - p.insert(pre); - }, - .@"mask-position-x" => {}, - .@"mask-position-y" => {}, - .@"mask-position" => |*p| { - p.insert(pre); - }, - .@"mask-clip" => |*p| { - p.insert(pre); - }, - .@"mask-origin" => |*p| { - p.insert(pre); - }, - .@"mask-size" => |*p| { - p.insert(pre); - }, - .@"mask-composite" => {}, - .@"mask-type" => {}, - .mask => |*p| { - p.insert(pre); - }, - .@"mask-border-source" => {}, - .@"mask-border-mode" => {}, - .@"mask-border-slice" => {}, - .@"mask-border-width" => {}, - .@"mask-border-outset" => {}, - .@"mask-border-repeat" => {}, - .@"mask-border" => {}, - .@"-webkit-mask-composite" => {}, - .@"mask-source-type" => |*p| { - p.insert(pre); - }, - .@"mask-box-image" => |*p| { - p.insert(pre); - }, - .@"mask-box-image-source" => |*p| { - p.insert(pre); - }, - .@"mask-box-image-slice" => |*p| { - p.insert(pre); - }, - .@"mask-box-image-width" => |*p| { - p.insert(pre); - }, - .@"mask-box-image-outset" => |*p| { - p.insert(pre); - }, - .@"mask-box-image-repeat" => |*p| { - p.insert(pre); - }, - .@"color-scheme" => {}, - else => {}, }; } @@ -9588,7 +9221,7 @@ pub const PropertyId = union(PropertyIdTag) { inline for (bun.meta.EnumFields(PropertyId), std.meta.fields(PropertyId)) |enum_field, union_field| { if (enum_field.value == @intFromEnum(lhs.*)) { if (comptime union_field.type == css.VendorPrefix) { - return @field(lhs, union_field.name).eql(@field(rhs, union_field.name)); + return @field(lhs, union_field.name) == @field(rhs, union_field.name); } else { return true; } diff --git a/src/css/properties/properties_impl.zig b/src/css/properties/properties_impl.zig index 24413ad276..4f420f16a1 100644 --- a/src/css/properties/properties_impl.zig +++ b/src/css/properties/properties_impl.zig @@ -14,107 +14,99 @@ const Error = css.Error; const PropertyId = css.PropertyId; const Property = css.Property; -pub fn PropertyIdImpl() type { - return struct { - pub fn toCss(this: *const PropertyId, comptime W: type, dest: *Printer(W)) PrintErr!void { - var first = true; - const name = this.name(); - const prefix_value = this.prefix().orNone(); +pub const property_id_mixin = struct { + pub fn toCss(this: *const PropertyId, comptime W: type, dest: *Printer(W)) PrintErr!void { + var first = true; + const name = this.name(); + const prefix_value = this.prefix().orNone(); - inline for (VendorPrefix.FIELDS) |field| { - if (@field(prefix_value, field)) { - var prefix: VendorPrefix = .{}; - @field(prefix, field) = true; + inline for (VendorPrefix.FIELDS) |field| { + if (@field(prefix_value, field)) { + var prefix: VendorPrefix = .{}; + @field(prefix, field) = true; - if (first) { - first = false; - } else { - try dest.delim(',', false); - } - try prefix.toCss(W, dest); - try dest.writeStr(name); + if (first) { + first = false; + } else { + try dest.delim(',', false); } + try prefix.toCss(W, dest); + try dest.writeStr(name); } } + } - pub fn parse(input: *css.Parser) css.Result(PropertyId) { - const name = switch (input.expectIdent()) { - .result => |v| v, - .err => |e| return .{ .err = e }, - }; - return .{ .result = fromString(name) }; + pub fn parse(input: *css.Parser) css.Result(PropertyId) { + const name = switch (input.expectIdent()) { + .result => |v| v, + .err => |e| return .{ .err = e }, + }; + return .{ .result = fromString(name) }; + } + + pub fn fromString(name_: []const u8) PropertyId { + const name_ref = name_; + var prefix: VendorPrefix = undefined; + var trimmed_name: []const u8 = undefined; + + // TODO: todo_stuff.match_ignore_ascii_case + if (bun.strings.startsWithCaseInsensitiveAscii(name_ref, "-webkit-")) { + prefix = VendorPrefix{ .webkit = true }; + trimmed_name = name_ref[8..]; + } else if (bun.strings.startsWithCaseInsensitiveAscii(name_ref, "-moz-")) { + prefix = VendorPrefix{ .moz = true }; + trimmed_name = name_ref[5..]; + } else if (bun.strings.startsWithCaseInsensitiveAscii(name_ref, "-o-")) { + prefix = VendorPrefix{ .o = true }; + trimmed_name = name_ref[3..]; + } else if (bun.strings.startsWithCaseInsensitiveAscii(name_ref, "-ms-")) { + prefix = VendorPrefix{ .ms = true }; + trimmed_name = name_ref[4..]; + } else { + prefix = VendorPrefix{ .none = true }; + trimmed_name = name_ref; } - pub fn fromStr(name: []const u8) PropertyId { - return fromString(name); - } + return PropertyId.fromNameAndPrefix(trimmed_name, prefix) orelse .{ .custom = CustomPropertyName.fromStr(name_) }; + } +}; - pub fn fromString(name_: []const u8) PropertyId { - const name_ref = name_; - var prefix: VendorPrefix = undefined; - var trimmed_name: []const u8 = undefined; - - // TODO: todo_stuff.match_ignore_ascii_case - if (bun.strings.startsWithCaseInsensitiveAscii(name_ref, "-webkit-")) { - prefix = VendorPrefix{ .webkit = true }; - trimmed_name = name_ref[8..]; - } else if (bun.strings.startsWithCaseInsensitiveAscii(name_ref, "-moz-")) { - prefix = VendorPrefix{ .moz = true }; - trimmed_name = name_ref[5..]; - } else if (bun.strings.startsWithCaseInsensitiveAscii(name_ref, "-o-")) { - prefix = VendorPrefix{ .o = true }; - trimmed_name = name_ref[3..]; - } else if (bun.strings.startsWithCaseInsensitiveAscii(name_ref, "-ms-")) { - prefix = VendorPrefix{ .ms = true }; - trimmed_name = name_ref[4..]; - } else { - prefix = VendorPrefix{ .none = true }; - trimmed_name = name_ref; +pub const property_mixin = struct { + /// Serializes the CSS property, with an optional `!important` flag. + pub fn toCss(this: *const Property, comptime W: type, dest: *Printer(W), important: bool) PrintErr!void { + if (this.* == .custom) { + try this.custom.name.toCss(W, dest); + try dest.delim(':', false); + try this.valueToCss(W, dest); + if (important) { + try dest.whitespace(); + try dest.writeStr("!important"); } - - return PropertyId.fromNameAndPrefix(trimmed_name, prefix) orelse .{ .custom = CustomPropertyName.fromStr(name_) }; + return; } - }; -} + const name, const prefix = this.__toCssHelper(); + var first = true; -pub fn PropertyImpl() type { - return struct { - /// Serializes the CSS property, with an optional `!important` flag. - pub fn toCss(this: *const Property, comptime W: type, dest: *Printer(W), important: bool) PrintErr!void { - if (this.* == .custom) { - try this.custom.name.toCss(W, dest); + inline for (VendorPrefix.FIELDS) |field| { + if (@field(prefix, field)) { + var p: VendorPrefix = .{}; + @field(p, field) = true; + + if (first) { + first = false; + } else { + try dest.writeChar(';'); + try dest.newline(); + } + try p.toCss(W, dest); + try dest.writeStr(name); try dest.delim(':', false); try this.valueToCss(W, dest); if (important) { try dest.whitespace(); try dest.writeStr("!important"); } - return; - } - const name, const prefix = this.__toCssHelper(); - var first = true; - - inline for (VendorPrefix.FIELDS) |field| { - if (@field(prefix, field)) { - var p: VendorPrefix = .{}; - @field(p, field) = true; - - if (first) { - first = false; - } else { - try dest.writeChar(';'); - try dest.newline(); - } - try p.toCss(W, dest); - try dest.writeStr(name); - try dest.delim(':', false); - try this.valueToCss(W, dest); - if (important) { - try dest.whitespace(); - try dest.writeStr("!important"); - } - } } } - }; -} + } +}; diff --git a/src/css/properties/size.zig b/src/css/properties/size.zig index 855dbc4805..74974a3e87 100644 --- a/src/css/properties/size.zig +++ b/src/css/properties/size.zig @@ -44,7 +44,12 @@ pub const BoxSizing = enum { @"content-box", /// Include the padding and border (but not the margin) in the width and height. @"border-box", - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; }; pub const Size = union(enum) { @@ -141,11 +146,11 @@ pub const Size = union(enum) { try dest.writeStr("fit-content"); }, .stretch => |vp| { - if (vp.eql(css.VendorPrefix{ .none = true })) { + if (vp == css.VendorPrefix{ .none = true }) { try dest.writeStr("stretch"); - } else if (vp.eql(css.VendorPrefix{ .webkit = true })) { + } else if (vp == css.VendorPrefix{ .webkit = true }) { try dest.writeStr("-webkit-fill-available"); - } else if (vp.eql(css.VendorPrefix{ .moz = true })) { + } else if (vp == css.VendorPrefix{ .moz = true }) { try dest.writeStr("-moz-available"); } else { bun.unreachablePanic("Unexpected vendor prefixes", .{}); @@ -301,11 +306,11 @@ pub const MaxSize = union(enum) { try dest.writeStr("fit-content"); }, .stretch => |vp| { - if (css.VendorPrefix.eql(vp, css.VendorPrefix{ .none = true })) { + if (vp == css.VendorPrefix{ .none = true }) { try dest.writeStr("stretch"); - } else if (css.VendorPrefix.eql(vp, css.VendorPrefix{ .webkit = true })) { + } else if (vp == css.VendorPrefix{ .webkit = true }) { try dest.writeStr("-webkit-fill-available"); - } else if (css.VendorPrefix.eql(vp, css.VendorPrefix{ .moz = true })) { + } else if (vp == css.VendorPrefix{ .moz = true }) { try dest.writeStr("-moz-available"); } else { bun.unreachablePanic("Unexpected vendor prefixes", .{}); @@ -418,8 +423,6 @@ pub const SizeProperty = packed struct(u16) { @"max-inline-size": bool = false, __unused: u4 = 0, - pub usingnamespace css.Bitflags(@This()); - pub fn tryFromPropertyIdTag(property_id: PropertyIdTag) ?SizeProperty { inline for (std.meta.fields(@This())) |field| { if (comptime std.mem.eql(u8, field.name, "__unused")) continue; @@ -471,7 +474,7 @@ pub const SizeHandler = struct { .unparsed => |*unparsed| { switch (unparsed.property_id) { .width, .height, .@"min-width", .@"max-width", .@"min-height", .@"max-height" => { - this.flushed_properties.insert(SizeProperty.tryFromPropertyIdTag(@as(PropertyIdTag, unparsed.property_id)).?); + bun.bits.insert(SizeProperty, &this.flushed_properties, SizeProperty.tryFromPropertyIdTag(@as(PropertyIdTag, unparsed.property_id)).?); dest.append(context.allocator, property.deepClone(context.allocator)) catch unreachable; }, .@"block-size" => this.logicalUnparsedHelper(property, unparsed, .height, logical_supported, dest, context), @@ -491,7 +494,7 @@ pub const SizeHandler = struct { inline fn logicalUnparsedHelper(this: *@This(), property: *const Property, unparsed: *const UnparsedProperty, comptime physical: PropertyIdTag, logical_supported: bool, dest: *css.DeclarationList, context: *css.PropertyHandlerContext) void { if (logical_supported) { - this.flushed_properties.insert(SizeProperty.tryFromPropertyIdTag(@as(PropertyIdTag, unparsed.property_id)).?); + bun.bits.insert(SizeProperty, &this.flushed_properties, SizeProperty.tryFromPropertyIdTag(@as(PropertyIdTag, unparsed.property_id)).?); dest.append(context.allocator, property.deepClone(context.allocator)) catch bun.outOfMemory(); } else { dest.append(context.allocator, Property{ @@ -500,7 +503,7 @@ pub const SizeHandler = struct { @unionInit(PropertyId, @tagName(physical), {}), ), }) catch bun.outOfMemory(); - this.flushed_properties.insert(SizeProperty.fromName(@tagName(physical))); + @field(this.flushed_properties, @tagName(physical)) = true; } } @@ -548,7 +551,7 @@ pub const SizeHandler = struct { pub fn finalize(this: *@This(), dest: *css.DeclarationList, context: *css.PropertyHandlerContext) void { this.flush(dest, context); - this.flushed_properties = SizeProperty.empty(); + this.flushed_properties = SizeProperty{}; } inline fn flushPrefixHelper( @@ -559,7 +562,7 @@ pub const SizeHandler = struct { dest: *css.DeclarationList, context: *css.PropertyHandlerContext, ) void { - if (!this.flushed_properties.contains(comptime SizeProperty.fromName(@tagName(property)))) { + if (!@field(this.flushed_properties, @tagName(property))) { const prefixes = context.targets.prefixes(css.VendorPrefix{ .none = true }, feature).difference(css.VendorPrefix{ .none = true }); inline for (css.VendorPrefix.FIELDS) |field| { if (@field(prefixes, field)) { @@ -588,22 +591,22 @@ pub const SizeHandler = struct { ) void { if (bun.take(&@field(this, field))) |val| { switch (val) { - .stretch => |vp| if (vp.eql(css.VendorPrefix{ .none = true })) { + .stretch => |vp| if (vp == css.VendorPrefix{ .none = true }) { this.flushPrefixHelper(property, SizeType, .stretch, dest, context); }, - .min_content => |vp| if (vp.eql(css.VendorPrefix{ .none = true })) { + .min_content => |vp| if (vp == css.VendorPrefix{ .none = true }) { this.flushPrefixHelper(property, SizeType, .min_content, dest, context); }, - .max_content => |vp| if (vp.eql(css.VendorPrefix{ .none = true })) { + .max_content => |vp| if (vp == css.VendorPrefix{ .none = true }) { this.flushPrefixHelper(property, SizeType, .max_content, dest, context); }, - .fit_content => |vp| if (vp.eql(css.VendorPrefix{ .none = true })) { + .fit_content => |vp| if (vp == css.VendorPrefix{ .none = true }) { this.flushPrefixHelper(property, SizeType, .fit_content, dest, context); }, else => {}, } dest.append(context.allocator, @unionInit(Property, @tagName(property), val.deepClone(context.allocator))) catch bun.outOfMemory(); - this.flushed_properties.insert(comptime SizeProperty.fromName(@tagName(property))); + @field(this.flushed_properties, @tagName(property)) = true; } } diff --git a/src/css/properties/text.zig b/src/css/properties/text.zig index 0fa64d1854..d572f299fc 100644 --- a/src/css/properties/text.zig +++ b/src/css/properties/text.zig @@ -279,7 +279,12 @@ pub const Direction = enum { /// This value sets inline base direction (bidi directionality) to line-right-to-line-left. rtl, - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; }; /// A value for the [unicode-bidi](https://drafts.csswg.org/css-writing-modes-3/#unicode-bidi) property. diff --git a/src/css/properties/transform.zig b/src/css/properties/transform.zig index f3e1504b48..e9410aef22 100644 --- a/src/css/properties/transform.zig +++ b/src/css/properties/transform.zig @@ -864,7 +864,12 @@ pub fn Matrix3d(comptime T: type) type { pub const TransformStyle = enum { flat, @"preserve-3d", - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; }; /// A value for the [transform-box](https://drafts.csswg.org/css-transforms-1/#transform-box) property. @@ -880,7 +885,12 @@ pub const TransformBox = enum { /// Uses the nearest SVG viewport as reference box. @"view-box", - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; }; /// A value for the [backface-visibility](https://drafts.csswg.org/css-transforms-2/#backface-visibility-property) property. @@ -888,7 +898,12 @@ pub const BackfaceVisibility = enum { visible, hidden, - pub usingnamespace css.DefineEnumProperty(@This()); + const css_impl = css.DefineEnumProperty(@This()); + pub const eql = css_impl.eql; + pub const hash = css_impl.hash; + pub const parse = css_impl.parse; + pub const toCss = css_impl.toCss; + pub const deepClone = css_impl.deepClone; }; /// A value for the perspective property. @@ -898,8 +913,8 @@ pub const Perspective = union(enum) { /// Distance to the center of projection. length: Length, - pub usingnamespace css.DeriveParse(@This()); - pub usingnamespace css.DeriveToCss(@This()); + pub const parse = css.DeriveParse(@This()).parse; + pub const toCss = css.DeriveToCss(@This()).toCss; pub fn eql(this: *const @This(), other: *const @This()) bool { return css.implementEql(@This(), this, other); @@ -1230,14 +1245,14 @@ pub const TransformHandler = struct { // If two vendor prefixes for the same property have different // values, we need to flush what we have immediately to preserve order. if (this.transform) |current| { - if (!current[0].eql(&transform_val) and !current[1].contains(vp)) { + if (!current[0].eql(&transform_val) and !bun.bits.contains(css.VendorPrefix, current[1], vp)) { this.flush(allocator, dest, context); } } // Otherwise, update the value and add the prefix. if (this.transform) |*transform| { - transform.* = .{ transform_val.deepClone(allocator), transform.*[1].bitwiseOr(vp) }; + transform.* = .{ transform_val.deepClone(allocator), bun.bits.@"or"(css.VendorPrefix, transform.*[1], vp) }; } else { this.transform = .{ transform_val.deepClone(allocator), vp }; this.has_any = true; diff --git a/src/css/properties/transition.zig b/src/css/properties/transition.zig index 6241e7e704..d8a68ca122 100644 --- a/src/css/properties/transition.zig +++ b/src/css/properties/transition.zig @@ -52,9 +52,6 @@ pub const Transition = struct { /// The easing function for the transition. timing_function: EasingFunction, - pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.transition, PropertyFieldMap); - pub usingnamespace css.DefineListShorthand(@This()); - pub const PropertyFieldMap = .{ .property = css.PropertyIdTag.@"transition-property", .duration = css.PropertyIdTag.@"transition-duration", @@ -211,7 +208,7 @@ pub const TransitionHandler = struct { const v = &p.*[0]; const prefixes = &p.*[1]; v.* = val.deepClone(context.allocator); - prefixes.insert(vp); + bun.bits.insert(VendorPrefix, prefixes, vp); prefixes.* = context.targets.prefixes(prefixes.*, feature); } else { const prefixes = context.targets.prefixes(vp, feature); @@ -227,7 +224,7 @@ pub const TransitionHandler = struct { if (@field(this, prop)) |*p| { const v = &p.*[0]; const prefixes = &p.*[1]; - if (!val.eql(v) and !prefixes.contains(vp)) { + if (!val.eql(v) and !bun.bits.contains(VendorPrefix, prefixes.*, vp)) { this.flush(dest, context); } } @@ -279,10 +276,10 @@ pub const TransitionHandler = struct { ) catch bun.outOfMemory(); } - property_prefixes.remove(intersection); - duration_prefixes.remove(intersection); - delay_prefixes.remove(intersection); - timing_prefixes.remove(intersection); + bun.bits.remove(VendorPrefix, property_prefixes, intersection); + bun.bits.remove(VendorPrefix, duration_prefixes, intersection); + bun.bits.remove(VendorPrefix, timing_prefixes, intersection); + bun.bits.remove(VendorPrefix, delay_prefixes, intersection); } } @@ -435,7 +432,7 @@ fn expandProperties(properties: *css.SmallList(PropertyId, 1), context: *css.Pro // Expand mask properties, which use different vendor-prefixed names. if (css.css_properties.masking.getWebkitMaskProperty(properties.at(i))) |property_id| { - if (context.targets.prefixes(VendorPrefix.NONE, Feature.mask_border).contains(VendorPrefix.WEBKIT)) { + if (context.targets.prefixes(VendorPrefix.NONE, Feature.mask_border).webkit) { properties.insert(context.allocator, i, property_id); i += 1; } @@ -445,7 +442,7 @@ fn expandProperties(properties: *css.SmallList(PropertyId, 1), context: *css.Pro rtl_props.mut(i).setPrefixesForTargets(context.targets); if (css.css_properties.masking.getWebkitMaskProperty(rtl_props.at(i))) |property_id| { - if (context.targets.prefixes(VendorPrefix.NONE, Feature.mask_border).contains(VendorPrefix.WEBKIT)) { + if (context.targets.prefixes(VendorPrefix.NONE, Feature.mask_border).webkit) { rtl_props.insert(context.allocator, i, property_id); i += 1; } diff --git a/src/css/properties/ui.zig b/src/css/properties/ui.zig index 225f0fb6f8..47c03afdf8 100644 --- a/src/css/properties/ui.zig +++ b/src/css/properties/ui.zig @@ -43,12 +43,14 @@ pub const ColorScheme = packed struct(u8) { only: bool = false, __unused: u5 = 0, - pub usingnamespace css.Bitflags(@This()); + pub fn eql(a: ColorScheme, b: ColorScheme) bool { + return a == b; + } const Map = bun.ComptimeEnumMap(enum { normal, only, light, dark }); pub fn parse(input: *css.Parser) css.Result(ColorScheme) { - var res = ColorScheme.empty(); + var res = ColorScheme{}; const ident = switch (input.expectIdent()) { .result => |ident| ident, .err => |e| return .{ .err = e }, @@ -56,9 +58,9 @@ pub const ColorScheme = packed struct(u8) { if (Map.get(ident)) |value| switch (value) { .normal => return .{ .result = res }, - .only => res.insert(ColorScheme{ .only = true }), - .light => res.insert(ColorScheme{ .light = true }), - .dark => res.insert(ColorScheme{ .dark = true }), + .only => res.only = true, + .light => res.light = true, + .dark => res.dark = true, }; while (input.tryParse(css.Parser.expectIdent, .{}).asValue()) |i| { @@ -66,14 +68,14 @@ pub const ColorScheme = packed struct(u8) { .normal => return .{ .err = input.newCustomError(css.ParserError.invalid_value) }, .only => { // Only must be at the start or the end, not in the middle - if (res.contains(ColorScheme{ .only = true })) { + if (res.only) { return .{ .err = input.newCustomError(css.ParserError.invalid_value) }; } - res.insert(ColorScheme{ .only = true }); + res.only = true; return .{ .result = res }; }, - .light => res.insert(ColorScheme{ .light = true }), - .dark => res.insert(ColorScheme{ .dark = true }), + .light => res.light = true, + .dark => res.dark = true, }; } @@ -81,22 +83,22 @@ pub const ColorScheme = packed struct(u8) { } pub fn toCss(this: *const ColorScheme, comptime W: type, dest: *Printer(W)) css.PrintErr!void { - if (this.isEmpty()) { + if (this.* == ColorScheme{}) { return dest.writeStr("normal"); } - if (this.contains(ColorScheme{ .light = true })) { + if (this.light) { try dest.writeStr("light"); - if (this.contains(ColorScheme{ .dark = true })) { + if (this.dark) { try dest.writeChar(' '); } } - if (this.contains(ColorScheme{ .dark = true })) { + if (this.dark) { try dest.writeStr("dark"); } - if (this.contains(ColorScheme{ .only = true })) { + if (this.only) { try dest.writeStr(" only"); } } @@ -177,7 +179,7 @@ pub const ColorSchemeHandler = struct { .@"color-scheme" => |*color_scheme_| { const color_scheme: *const ColorScheme = color_scheme_; if (!context.targets.isCompatible(css.compat.Feature.light_dark)) { - if (color_scheme.contains(ColorScheme{ .light = true })) { + if (color_scheme.light) { dest.append( context.allocator, defineVar(context.allocator, "--buncss-light", .{ .ident = "initial" }), @@ -187,7 +189,7 @@ pub const ColorSchemeHandler = struct { defineVar(context.allocator, "--buncss-dark", .{ .whitespace = " " }), ) catch bun.outOfMemory(); - if (color_scheme.contains(ColorScheme{ .dark = true })) { + if (color_scheme.dark) { context.addDarkRule( context.allocator, defineVar(context.allocator, "--buncss-light", .{ .whitespace = " " }), @@ -197,7 +199,7 @@ pub const ColorSchemeHandler = struct { defineVar(context.allocator, "--buncss-dark", .{ .ident = "initial" }), ); } - } else if (color_scheme.contains(ColorScheme{ .dark = true })) { + } else if (color_scheme.dark) { dest.append(context.allocator, defineVar(context.allocator, "--buncss-light", .{ .whitespace = " " })) catch bun.outOfMemory(); dest.append(context.allocator, defineVar(context.allocator, "--buncss-dark", .{ .ident = "initial" })) catch bun.outOfMemory(); } diff --git a/src/css/rules/container.zig b/src/css/rules/container.zig index 889f6cb030..53f8a801fc 100644 --- a/src/css/rules/container.zig +++ b/src/css/rules/container.zig @@ -62,7 +62,7 @@ pub const ContainerSizeFeatureId = enum { /// The [orientation](https://w3c.github.io/csswg-drafts/css-contain-3/#orientation) size container feature. orientation, - pub usingnamespace css.DeriveValueType(@This(), ValueTypeMap); + pub const valueType = css.DeriveValueType(@This(), ValueTypeMap).valueType; pub const ValueTypeMap = .{ .width = css.MediaFeatureType.length, @@ -334,7 +334,7 @@ pub fn ContainerRule(comptime R: type) type { // Don't downlevel range syntax in container queries. const exclude = dest.targets.exclude; - dest.targets.exclude.insert(css.targets.Features.media_queries); + bun.bits.insert(css.targets.Features, &dest.targets.exclude, .media_queries); try this.condition.toCss(W, dest); dest.targets.exclude = exclude; diff --git a/src/css/rules/keyframes.zig b/src/css/rules/keyframes.zig index 37ae756e5d..b93ae93522 100644 --- a/src/css/rules/keyframes.zig +++ b/src/css/rules/keyframes.zig @@ -181,7 +181,7 @@ pub const KeyframeSelector = union(enum) { to, // TODO: implement this - pub usingnamespace css.DeriveParse(@This()); + pub const parse = css.DeriveParse(@This()).parse; // pub fn parse(input: *css.Parser) Result(KeyframeSelector) { // _ = input; // autofix @@ -263,12 +263,8 @@ pub const KeyframesRule = struct { var first_rule = true; - const PREFIXES = .{ "webkit", "moz", "ms", "o", "none" }; - - inline for (PREFIXES) |prefix_name| { - const prefix = css.VendorPrefix.fromName(prefix_name); - - if (this.vendor_prefix.contains(prefix)) { + inline for (.{ "webkit", "moz", "ms", "o", "none" }) |prefix_name| { + if (@field(this.vendor_prefix, prefix_name)) { if (first_rule) { first_rule = false; } else { @@ -279,7 +275,7 @@ pub const KeyframesRule = struct { } try dest.writeChar('@'); - try prefix.toCss(W, dest); + try css.VendorPrefix.fromName(prefix_name).toCss(W, dest); try dest.writeStr("keyframes "); try this.name.toCss(W, dest); try dest.whitespace(); diff --git a/src/css/rules/rules.zig b/src/css/rules/rules.zig index 5d98fb5bc4..f174b7967a 100644 --- a/src/css/rules/rules.zig +++ b/src/css/rules/rules.zig @@ -651,10 +651,10 @@ fn mergeStyleRules( { // If the new rule is unprefixed, replace the prefixes of the last rule. // Otherwise, add the new prefix. - if (sty.vendor_prefix.contains(css.VendorPrefix{ .none = true }) and context.targets.shouldCompileSelectors()) { + if (sty.vendor_prefix.none and context.targets.shouldCompileSelectors()) { last_style_rule.vendor_prefix = sty.vendor_prefix; } else { - last_style_rule.vendor_prefix.insert(sty.vendor_prefix); + bun.bits.insert(css.VendorPrefix, &last_style_rule.vendor_prefix, sty.vendor_prefix); } return true; } @@ -666,10 +666,10 @@ fn mergeStyleRules( sty.selectors.v.slice(), ); sty.selectors.v.clearRetainingCapacity(); - if (sty.vendor_prefix.contains(css.VendorPrefix{ .none = true }) and context.targets.shouldCompileSelectors()) { + if (sty.vendor_prefix.none and context.targets.shouldCompileSelectors()) { last_style_rule.vendor_prefix = sty.vendor_prefix; } else { - last_style_rule.vendor_prefix.insert(sty.vendor_prefix); + bun.bits.insert(css.VendorPrefix, &last_style_rule.vendor_prefix, sty.vendor_prefix); } return true; } diff --git a/src/css/rules/style.zig b/src/css/rules/style.zig index 855098d70f..13cb4a3fec 100644 --- a/src/css/rules/style.zig +++ b/src/css/rules/style.zig @@ -58,7 +58,7 @@ pub fn StyleRule(comptime R: type) type { pub fn updatePrefix(this: *This, context: *css.MinifyContext) void { this.vendor_prefix = css.selector.getPrefix(&this.selectors); - if (this.vendor_prefix.contains(css.VendorPrefix{ .none = true }) and + if (this.vendor_prefix.none and context.targets.shouldCompileSelectors()) { this.vendor_prefix = css.selector.downlevelSelectors(context.allocator, this.selectors.v.slice_mut(), context.targets.*); @@ -91,7 +91,7 @@ pub fn StyleRule(comptime R: type) type { } } - dest.vendor_prefix = css.VendorPrefix.empty(); + dest.vendor_prefix = .{}; } } diff --git a/src/css/rules/supports.zig b/src/css/rules/supports.zig index bcdc7ac8de..81d2fdde0f 100644 --- a/src/css/rules/supports.zig +++ b/src/css/rules/supports.zig @@ -343,7 +343,7 @@ pub const SupportsCondition = union(enum) { try dest.writeChar('('); const prefix: css.VendorPrefix = property_id.prefix().orNone(); - if (!prefix.eq(css.VendorPrefix{ .none = true })) { + if (prefix != css.VendorPrefix{ .none = true }) { try dest.writeChar('('); } @@ -365,7 +365,7 @@ pub const SupportsCondition = union(enum) { } } - if (!prefix.eq(css.VendorPrefix{ .none = true })) { + if (prefix != css.VendorPrefix{ .none = true }) { try dest.writeChar(')'); } try dest.writeChar(')'); diff --git a/src/css/selectors/builder.zig b/src/css/selectors/builder.zig index 50e0112a01..cd6db25722 100644 --- a/src/css/selectors/builder.zig +++ b/src/css/selectors/builder.zig @@ -39,8 +39,8 @@ const parser = css.selector.parser; const ValidSelectorImpl = parser.ValidSelectorImpl; const GenericComponent = parser.GenericComponent; const Combinator = parser.Combinator; -const SpecifityAndFlags = parser.SpecifityAndFlags; -const compute_specifity = parser.compute_specifity; +const SpecificityAndFlags = parser.SpecificityAndFlags; +const compute_specificity = parser.compute_specificity; const SelectorFlags = parser.SelectorFlags; /// Top-level SelectorBuilder struct. This should be stack-allocated by the @@ -77,7 +77,7 @@ pub fn SelectorBuilder(comptime Impl: type) type { const This = @This(); const BuildResult = struct { - specifity_and_flags: SpecifityAndFlags, + specificity_and_flags: SpecificityAndFlags, components: ArrayList(GenericComponent(Impl)), }; @@ -125,24 +125,18 @@ pub fn SelectorBuilder(comptime Impl: type) type { parsed_slotted: bool, parsed_part: bool, ) BuildResult { - const specifity = compute_specifity(Impl, this.simple_selectors.slice()); - var flags = SelectorFlags.empty(); - // PERF: is it faster to do these ORs all at once - if (parsed_pseudo) { - flags.has_pseudo = true; - } - if (parsed_slotted) { - flags.has_slotted = true; - } - if (parsed_part) { - flags.has_part = true; - } + const specificity = compute_specificity(Impl, this.simple_selectors.slice()); + const flags: SelectorFlags = .{ + .has_pseudo = parsed_pseudo, + .has_slotted = parsed_slotted, + .has_part = parsed_part, + }; // `buildWithSpecificityAndFlags()` will defer this.deinit(); - return this.buildWithSpecificityAndFlags(SpecifityAndFlags{ .specificity = specifity, .flags = flags }); + return this.buildWithSpecificityAndFlags(SpecificityAndFlags{ .specificity = specificity, .flags = flags }); } - /// Builds a selector with the given specifity and flags. + /// Builds a selector with the given specificity and flags. /// /// PERF: /// Recall that this code is ported from servo, which optimizes for matching speed, so @@ -153,7 +147,7 @@ pub fn SelectorBuilder(comptime Impl: type) type { /// order requires additional allocations, and undoing the reversal when serializing the /// selector. So we could just change this code to store the components in the same order /// as the source. - pub fn buildWithSpecificityAndFlags(this: *This, spec: SpecifityAndFlags) BuildResult { + pub fn buildWithSpecificityAndFlags(this: *This, spec: SpecificityAndFlags) BuildResult { const T = GenericComponent(Impl); const rest: []const T, const current: []const T = splitFromEnd(T, this.simple_selectors.slice(), this.current_len); const combinators = this.combinators.slice(); @@ -201,7 +195,7 @@ pub fn SelectorBuilder(comptime Impl: type) type { } } - return .{ .specifity_and_flags = spec, .components = components }; + return .{ .specificity_and_flags = spec, .components = components }; } pub fn splitFromEnd(comptime T: type, s: []const T, at: usize) struct { []const T, []const T } { diff --git a/src/css/selectors/parser.zig b/src/css/selectors/parser.zig index 47bded67d5..50a997b192 100644 --- a/src/css/selectors/parser.zig +++ b/src/css/selectors/parser.zig @@ -218,81 +218,81 @@ pub const attrs = struct { }; }; -pub const Specifity = struct { +pub const Specificity = struct { id_selectors: u32 = 0, class_like_selectors: u32 = 0, element_selectors: u32 = 0, const MAX_10BIT: u32 = (1 << 10) - 1; - pub fn toU32(this: Specifity) u32 { + pub fn toU32(this: Specificity) u32 { return @as(u32, @as(u32, @min(this.id_selectors, MAX_10BIT)) << @as(u32, 20)) | @as(u32, @as(u32, @min(this.class_like_selectors, MAX_10BIT)) << @as(u32, 10)) | @min(this.element_selectors, MAX_10BIT); } - pub fn fromU32(value: u32) Specifity { + pub fn fromU32(value: u32) Specificity { bun.assert(value <= MAX_10BIT << 20 | MAX_10BIT << 10 | MAX_10BIT); - return Specifity{ + return Specificity{ .id_selectors = value >> 20, .class_like_selectors = (value >> 10) & MAX_10BIT, .element_selectors = value & MAX_10BIT, }; } - pub fn add(lhs: *Specifity, rhs: Specifity) void { + pub fn add(lhs: *Specificity, rhs: Specificity) void { lhs.id_selectors += rhs.id_selectors; lhs.element_selectors += rhs.element_selectors; lhs.class_like_selectors += rhs.class_like_selectors; } }; -pub fn compute_specifity(comptime Impl: type, iter: []const GenericComponent(Impl)) u32 { - const spec = compute_complex_selector_specifity(Impl, iter); +pub fn compute_specificity(comptime Impl: type, iter: []const GenericComponent(Impl)) u32 { + const spec = compute_complex_selector_specificity(Impl, iter); return spec.toU32(); } -fn compute_complex_selector_specifity(comptime Impl: type, iter: []const GenericComponent(Impl)) Specifity { - var specifity: Specifity = .{}; +fn compute_complex_selector_specificity(comptime Impl: type, iter: []const GenericComponent(Impl)) Specificity { + var specificity: Specificity = .{}; for (iter) |*simple_selector| { - compute_simple_selector_specifity(Impl, simple_selector, &specifity); + compute_simple_selector_specificity(Impl, simple_selector, &specificity); } - return specifity; + return specificity; } -fn compute_simple_selector_specifity( +fn compute_simple_selector_specificity( comptime Impl: type, simple_selector: *const GenericComponent(Impl), - specifity: *Specifity, + specificity: *Specificity, ) void { switch (simple_selector.*) { .combinator => { bun.unreachablePanic("Found combinator in simple selectors vector?", .{}); }, .part, .pseudo_element, .local_name => { - specifity.element_selectors += 1; + specificity.element_selectors += 1; }, .slotted => |selector| { - specifity.element_selectors += 1; + specificity.element_selectors += 1; // Note that due to the way ::slotted works we only compete with // other ::slotted rules, so the above rule doesn't really // matter, but we do it still for consistency with other // pseudo-elements. // // See: https://github.com/w3c/csswg-drafts/issues/1915 - specifity.add(Specifity.fromU32(selector.specifity())); + specificity.add(Specificity.fromU32(selector.specificity())); }, .host => |maybe_selector| { - specifity.class_like_selectors += 1; + specificity.class_like_selectors += 1; if (maybe_selector) |*selector| { // See: https://github.com/w3c/csswg-drafts/issues/1915 - specifity.add(Specifity.fromU32(selector.specifity())); + specificity.add(Specificity.fromU32(selector.specificity())); } }, .id => { - specifity.id_selectors += 1; + specificity.id_selectors += 1; }, .class, .attribute_in_no_namespace, @@ -304,7 +304,7 @@ fn compute_simple_selector_specifity( .nth, .non_ts_pseudo_class, => { - specifity.class_like_selectors += 1; + specificity.class_like_selectors += 1; }, .nth_of => |nth_of_data| { // https://drafts.csswg.org/selectors/#specificity-rules: @@ -313,12 +313,12 @@ fn compute_simple_selector_specifity( // like the :nth-child() pseudo-class, combines the // specificity of a regular pseudo-class with that of its // selector argument S. - specifity.class_like_selectors += 1; + specificity.class_like_selectors += 1; var max: u32 = 0; for (nth_of_data.selectors) |*selector| { - max = @max(selector.specifity(), max); + max = @max(selector.specificity(), max); } - specifity.add(Specifity.fromU32(max)); + specificity.add(Specificity.fromU32(max)); }, .negation, .is, .any => { // https://drafts.csswg.org/selectors/#specificity-rules: @@ -334,9 +334,9 @@ fn compute_simple_selector_specifity( }; var max: u32 = 0; for (list) |*selector| { - max = @max(selector.specifity(), max); + max = @max(selector.specificity(), max); } - specifity.add(Specifity.fromU32(max)); + specificity.add(Specificity.fromU32(max)); }, .where, .has, @@ -346,7 +346,7 @@ fn compute_simple_selector_specifity( .default_namespace, .namespace, => { - // Does not affect specifity + // Does not affect specificity }, .nesting => { // TODO @@ -395,7 +395,7 @@ fn parse_selector( return .{ .err = input.newCustomError(kind.intoDefaultParserError()) }; } - if (state.intersects(SelectorParsingState.AFTER_PSEUDO)) { + if (state.afterAnyPseudo()) { const source_location = input.currentSourceLocation(); if (input.next().asValue()) |next| { return .{ .err = source_location.newCustomError(SelectorParseErrorKind.intoDefaultParserError(.{ .unexpected_selector_after_pseudo_element = next.* })) }; @@ -478,7 +478,7 @@ fn parse_selector( builder.pushCombinator(combinator); } - if (!state.contains(SelectorParsingState{ .after_nesting = true })) { + if (!state.after_nesting) { switch (nesting_requirement) { .implicit => { builder.addNestingPrefix(); @@ -490,15 +490,12 @@ fn parse_selector( } } - const has_pseudo_element = state.intersects(SelectorParsingState{ - .after_pseudo_element = true, - .after_unknown_pseudo_element = true, - }); - const slotted = state.intersects(SelectorParsingState{ .after_slotted = true }); - const part = state.intersects(SelectorParsingState{ .after_part = true }); + const has_pseudo_element = state.after_pseudo_element or state.after_unknown_pseudo_element; + const slotted = state.after_slotted; + const part = state.after_part; const result = builder.build(has_pseudo_element, slotted, part); return .{ .result = Selector{ - .specifity_and_flags = result.specifity_and_flags, + .specificity_and_flags = result.specificity_and_flags, .components = result.components, } }; } @@ -520,7 +517,7 @@ fn parse_compound_selector( var empty: bool = true; if (parser.isNestingAllowed() and if (input.tryParse(css.Parser.expectDelim, .{'&'}).isOk()) true else false) { - state.insert(SelectorParsingState{ .after_nesting = true }); + state.after_nesting = true; builder.pushSimpleSelector(.nesting); empty = false; } @@ -570,7 +567,7 @@ fn parse_compound_selector( // // (Similar quotes for :where() / :not()) // - const ignore_default_ns = state.intersects(SelectorParsingState{ .skip_default_namespace = true }) or + const ignore_default_ns = state.skip_default_namespace or (result == .simple_selector and result.simple_selector == .host); if (!ignore_default_ns) { builder.pushSimpleSelector(.{ .default_namespace = url }); @@ -586,33 +583,33 @@ fn parse_compound_selector( }, .part_pseudo => { const selector = result.part_pseudo; - state.insert(SelectorParsingState{ .after_part = true }); + state.after_part = true; builder.pushCombinator(.part); builder.pushSimpleSelector(.{ .part = selector }); }, .slotted_pseudo => |selector| { - state.insert(.{ .after_slotted = true }); + state.after_slotted = true; builder.pushCombinator(.slot_assignment); builder.pushSimpleSelector(.{ .slotted = selector }); }, .pseudo_element => |p| { if (!p.isUnknown()) { - state.insert(SelectorParsingState{ .after_pseudo_element = true }); + state.after_pseudo_element = true; builder.pushCombinator(.pseudo_element); } else { - state.insert(.{ .after_unknown_pseudo_element = true }); + state.after_unknown_pseudo_element = true; } if (!p.acceptsStatePseudoClasses()) { - state.insert(.{ .after_non_stateful_pseudo_element = true }); + state.after_non_stateful_pseudo_element = true; } if (p.isWebkitScrollbar()) { - state.insert(.{ .after_webkit_scrollbar = true }); + state.after_webkit_scrollbar = true; } if (p.isViewTransition()) { - state.insert(.{ .after_view_transition = true }); + state.after_view_transition = true; } builder.pushSimpleSelector(.{ .pseudo_element = p }); @@ -947,7 +944,7 @@ pub const PseudoClass = union(enum) { pub fn getPrefix(this: *const PseudoClass) css.VendorPrefix { return switch (this.*) { inline .fullscreen, .any_link, .read_only, .read_write, .placeholder_shown, .autofill => |p| p, - else => css.VendorPrefix.empty(), + else => css.VendorPrefix{}, }; } @@ -960,7 +957,7 @@ pub const PseudoClass = union(enum) { .read_write => |*p| .{ p, F.pseudo_class_read_write }, .placeholder_shown => |*p| .{ p, F.pseudo_class_placeholder_shown }, .autofill => |*p| .{ p, F.pseudo_class_autofill }, - else => return css.VendorPrefix.empty(), + else => return css.VendorPrefix{}, }; p.* = targets.prefixes(p.*, feature); return p.*; @@ -1322,7 +1319,7 @@ pub const SelectorParser = struct { } pub fn deepCombinatorEnabled(this: *SelectorParser) bool { - return this.options.flags.contains(css.ParserFlags{ .deep_selector_combinator = true }); + return this.options.flags.deep_selector_combinator; } pub fn defaultNamespace(this: *SelectorParser) ?impl.Selectors.SelectorImpl.NamespaceUrl { @@ -1432,9 +1429,9 @@ pub fn GenericSelectorList(comptime Impl: type) type { if (this.v.len() == 0) return true; if (this.v.len() == 1) return true; - const value = this.v.at(0).specifity(); + const value = this.v.at(0).specificity(); for (this.v.slice()[1..]) |*sel| { - if (sel.specifity() != value) return false; + if (sel.specificity() != value) return false; } return true; } @@ -1459,7 +1456,7 @@ pub fn GenericSelectorList(comptime Impl: type) type { error_recovery: ParseErrorRecovery, nesting_requirement: NestingRequirement, ) Result(This) { - var state = SelectorParsingState.empty(); + var state = SelectorParsingState{}; return parseWithState(parser, input, &state, error_recovery, nesting_requirement); } @@ -1469,7 +1466,7 @@ pub fn GenericSelectorList(comptime Impl: type) type { error_recovery: ParseErrorRecovery, nesting_requirement: NestingRequirement, ) Result(This) { - var state = SelectorParsingState.empty(); + var state = SelectorParsingState{}; return parseRelativeWithState(parser, input, &state, error_recovery, nesting_requirement); } @@ -1631,7 +1628,7 @@ pub fn GenericSelector(comptime Impl: type) type { ValidSelectorImpl(Impl); return struct { - specifity_and_flags: SpecifityAndFlags, + specificity_and_flags: SpecificityAndFlags, components: ArrayList(GenericComponent(Impl)), const This = @This(); @@ -1665,7 +1662,7 @@ pub fn GenericSelector(comptime Impl: type) type { /// Parse a selector, without any pseudo-element. pub fn parse(parser: *SelectorParser, input: *css.Parser) Result(This) { - var state = SelectorParsingState.empty(); + var state = SelectorParsingState{}; return parse_selector(Impl, parser, input, &state, .none); } @@ -1704,7 +1701,7 @@ pub fn GenericSelector(comptime Impl: type) type { } pub fn hasPseudoElement(this: *const This) bool { - return this.specifity_and_flags.hasPseudoElement(); + return this.specificity_and_flags.hasPseudoElement(); } /// Returns count of simple selectors and combinators in the Selector. @@ -1721,13 +1718,13 @@ pub fn GenericSelector(comptime Impl: type) type { } const result = builder.build(false, false, false); return This{ - .specifity_and_flags = result.specifity_and_flags, + .specificity_and_flags = result.specificity_and_flags, .components = result.components, }; } - pub fn specifity(this: *const This) u32 { - return this.specifity_and_flags.specificity; + pub fn specificity(this: *const This) u32 { + return this.specificity_and_flags.specificity; } pub fn parseWithOptions(input: *css.Parser, options: *const css.ParserOptions) Result(This) { @@ -2123,55 +2120,52 @@ pub const SelectorParsingState = packed struct(u16) { __unused: u5 = 0, /// Whether we are after any of the pseudo-like things. - pub const AFTER_PSEUDO = SelectorParsingState{ .after_part = true, .after_slotted = true, .after_pseudo_element = true }; - - pub usingnamespace css.Bitflags(@This()); + pub fn afterAnyPseudo(state: SelectorParsingState) bool { + return state.after_part or state.after_slotted or state.after_pseudo_element; + } pub fn allowsPseudos(this: SelectorParsingState) bool { - return !this.intersects(SelectorParsingState{ - .after_pseudo_element = true, - .disallow_pseudos = true, - }); + return !this.after_pseudo_element and !this.disallow_pseudos; } pub fn allowsPart(this: SelectorParsingState) bool { - return !this.intersects(SelectorParsingState.AFTER_PSEUDO.bitwiseOr(SelectorParsingState{ .disallow_pseudos = true })); + return !this.disallow_pseudos and !this.afterAnyPseudo(); } pub fn allowsSlotted(this: SelectorParsingState) bool { - return !this.intersects(SelectorParsingState.AFTER_PSEUDO.bitwiseOr(.{ .disallow_pseudos = true })); + return this.allowsPart(); } pub fn allowsTreeStructuralPseudoClasses(this: SelectorParsingState) bool { - return !this.intersects(SelectorParsingState.AFTER_PSEUDO); + return !this.afterAnyPseudo(); } pub fn allowsNonFunctionalPseudoClasses(this: SelectorParsingState) bool { - return !this.intersects(SelectorParsingState{ .after_slotted = true, .after_non_stateful_pseudo_element = true }); + return !this.after_slotted and !this.after_non_stateful_pseudo_element; } pub fn allowsCombinators(this: SelectorParsingState) bool { - return !this.intersects(SelectorParsingState{ .disallow_combinators = true }); + return !this.disallow_combinators; } pub fn allowsCustomFunctionalPseudoClasses(this: SelectorParsingState) bool { - return !this.intersects(SelectorParsingState.AFTER_PSEUDO); + return !this.afterAnyPseudo(); } }; -pub const SpecifityAndFlags = struct { +pub const SpecificityAndFlags = struct { /// There are two free bits here, since we use ten bits for each specificity /// kind (id, class, element). specificity: u32, /// There's padding after this field due to the size of the flags. flags: SelectorFlags, - pub fn eql(this: *const SpecifityAndFlags, other: *const SpecifityAndFlags) bool { + pub fn eql(this: *const SpecificityAndFlags, other: *const SpecificityAndFlags) bool { return css.implementEql(@This(), this, other); } - pub fn hasPseudoElement(this: *const SpecifityAndFlags) bool { - return this.flags.intersects(SelectorFlags{ .has_pseudo = true }); + pub fn hasPseudoElement(this: *const SpecificityAndFlags) bool { + return this.flags.has_pseudo; } pub fn hash(this: *const @This(), hasher: *std.hash.Wyhash) void { @@ -2188,8 +2182,6 @@ pub const SelectorFlags = packed struct(u8) { has_slotted: bool = false, has_part: bool = false, __unused: u5 = 0, - - pub usingnamespace css.Bitflags(@This()); }; /// How to treat invalid selectors in a selector list. @@ -2465,7 +2457,7 @@ pub const PseudoElement = union(enum) { .placeholder => |*p| .{ p, F.pseudo_element_placeholder }, .backdrop => |*p| .{ p, F.pseudo_element_backdrop }, .file_selector_button => |*p| .{ p, F.pseudo_element_file_selector_button }, - else => return css.VendorPrefix.empty(), + else => return css.VendorPrefix{}, }; p.* = targets.prefixes(p.*, feature); @@ -2476,7 +2468,7 @@ pub const PseudoElement = union(enum) { pub fn getPrefix(this: *const PseudoElement) css.VendorPrefix { return switch (this.*) { .selection, .placeholder, .backdrop, .file_selector_button => |p| p, - else => css.VendorPrefix.empty(), + else => css.VendorPrefix{}, }; } @@ -2585,7 +2577,7 @@ pub fn parse_type_selector( const namespace: QNamePrefix(Impl) = result.some[0]; const local_name: ?[]const u8 = result.some[1]; - if (state.intersects(SelectorParsingState.AFTER_PSEUDO)) { + if (state.afterAnyPseudo()) { return .{ .err = input.newCustomError(SelectorParseErrorKind.intoDefaultParserError(.invalid_state)) }; } @@ -2678,7 +2670,7 @@ pub fn parse_one_simple_selector( switch (token) { .idhash => |id| { - if (state.intersects(SelectorParsingState.AFTER_PSEUDO)) { + if (state.afterAnyPseudo()) { return .{ .err = token_location.newCustomError(SelectorParseErrorKind.intoDefaultParserError(.{ .unexpected_selector_after_pseudo_element = .{ .idhash = id } })) }; } const component: GenericComponent(Impl) = .{ .id = parser.newLocalIdentifier(input, .ID, id, token_loc) }; @@ -2687,7 +2679,7 @@ pub fn parse_one_simple_selector( } }; }, .open_square => { - if (state.intersects(SelectorParsingState.AFTER_PSEUDO)) { + if (state.afterAnyPseudo()) { return .{ .err = token_location.newCustomError(SelectorParseErrorKind.intoDefaultParserError(.{ .unexpected_selector_after_pseudo_element = .open_square })) }; } const Closure = struct { @@ -2823,7 +2815,7 @@ pub fn parse_one_simple_selector( }; }; - if (state.intersects(.{ .after_slotted = true }) and pseudo_element.validAfterSlotted()) { + if (state.after_slotted and pseudo_element.validAfterSlotted()) { return .{ .result = .{ .pseudo_element = pseudo_element } }; } @@ -2858,7 +2850,7 @@ pub fn parse_one_simple_selector( .delim => |d| { switch (d) { '.' => { - if (state.intersects(SelectorParsingState.AFTER_PSEUDO)) { + if (state.afterAnyPseudo()) { return .{ .err = token_location.newCustomError(SelectorParseErrorKind.intoDefaultParserError(.{ .unexpected_selector_after_pseudo_element = .{ .delim = '.' } })) }; } const location = input.currentSourceLocation(); @@ -2876,7 +2868,7 @@ pub fn parse_one_simple_selector( }, '&' => { if (parser.isNestingAllowed()) { - state.insert(SelectorParsingState{ .after_nesting = true }); + state.after_nesting = true; return .{ .result = S{ .simple_selector = .nesting, } }; @@ -3181,7 +3173,7 @@ pub fn parse_simple_pseudo_class( // The view-transition pseudo elements accept the :only-child pseudo class. // https://w3c.github.io/csswg-drafts/css-view-transitions-1/#pseudo-root - if (state.intersects(SelectorParsingState{ .after_view_transition = true })) { + if (state.after_view_transition) { if (bun.strings.eqlCaseInsensitiveASCIIICheckLength(name, "only-child")) { return .{ .result = .{ .nth = NthSelectorData.only(false) } }; } @@ -3191,11 +3183,11 @@ pub fn parse_simple_pseudo_class( .err => |e| return .{ .err = e }, .result => |v| v, }; - if (state.intersects(SelectorParsingState{ .after_webkit_scrollbar = true })) { + if (state.after_webkit_scrollbar) { if (!pseudo_class.isValidAfterWebkitScrollbar()) { return .{ .err = location.newCustomError(SelectorParseErrorKind.intoDefaultParserError(.invalid_pseudo_class_after_webkit_scrollbar)) }; } - } else if (state.intersects(SelectorParsingState{ .after_pseudo_element = true })) { + } else if (state.after_pseudo_element) { if (!pseudo_class.isUserActionState()) { return .{ .err = location.newCustomError(SelectorParseErrorKind.intoDefaultParserError(.invalid_pseudo_class_after_pseudo_element)) }; } diff --git a/src/css/selectors/selector.zig b/src/css/selectors/selector.zig index f4d139925e..a04b616131 100644 --- a/src/css/selectors/selector.zig +++ b/src/css/selectors/selector.zig @@ -3,6 +3,7 @@ const Allocator = std.mem.Allocator; const bun = @import("bun"); const logger = bun.logger; const Log = logger.Log; +const bits = bun.bits; pub const css = @import("../css_parser.zig"); const CSSString = css.CSSString; @@ -102,10 +103,10 @@ pub fn isEquivalent(selectors: []const Selector, other: []const Selector) bool { /// Downlevels the given selectors to be compatible with the given browser targets. /// Returns the necessary vendor prefixes. pub fn downlevelSelectors(allocator: Allocator, selectors: []Selector, targets: css.targets.Targets) css.VendorPrefix { - var necessary_prefixes = css.VendorPrefix.empty(); + var necessary_prefixes = css.VendorPrefix{}; for (selectors) |*selector| { for (selector.components.items) |*component| { - necessary_prefixes.insert(downlevelComponent(allocator, component, targets)); + bun.bits.insert(css.VendorPrefix, &necessary_prefixes, downlevelComponent(allocator, component, targets)); } } return necessary_prefixes; @@ -120,7 +121,7 @@ pub fn downlevelComponent(allocator: Allocator, component: *Component, targets: component.* = downlevelDir(allocator, d.direction, targets); return downlevelComponent(allocator, component, targets); } - return css.VendorPrefix.empty(); + return css.VendorPrefix{}; }, .lang => |l| { // :lang() with multiple languages is not supported everywhere. @@ -129,7 +130,7 @@ pub fn downlevelComponent(allocator: Allocator, component: *Component, targets: component.* = .{ .is = langListToSelectors(allocator, l.languages.items) }; return downlevelComponent(allocator, component, targets); } - return css.VendorPrefix.empty(); + return css.VendorPrefix{}; }, else => pc.getNecessaryPrefixes(targets), }; @@ -147,9 +148,9 @@ pub fn downlevelComponent(allocator: Allocator, component: *Component, targets: } break :brk true; }) { - necessary_prefixes.insert(targets.prefixes(css.VendorPrefix{ .none = true }, .any_pseudo)); + bun.bits.insert(css.VendorPrefix, &necessary_prefixes, targets.prefixes(css.VendorPrefix{ .none = true }, .any_pseudo)); } else { - necessary_prefixes.insert(css.VendorPrefix{ .none = true }); + necessary_prefixes.none = true; } return necessary_prefixes; @@ -173,9 +174,9 @@ pub fn downlevelComponent(allocator: Allocator, component: *Component, targets: component.* = .{ .negation = list.items }; if (targets.shouldCompileSame(.is_selector)) { - necessary_prefixes.insert(targets.prefixes(css.VendorPrefix{ .none = true }, .any_pseudo)); + bun.bits.insert(css.VendorPrefix, &necessary_prefixes, targets.prefixes(css.VendorPrefix{ .none = true }, .any_pseudo)); } else { - necessary_prefixes.insert(css.VendorPrefix{ .none = true }); + bun.bits.insert(css.VendorPrefix, &necessary_prefixes, css.VendorPrefix{ .none = true }); } } @@ -183,7 +184,7 @@ pub fn downlevelComponent(allocator: Allocator, component: *Component, targets: }, .where, .has => |s| downlevelSelectors(allocator, s, targets), .any => |*a| downlevelSelectors(allocator, a.selectors, targets), - else => css.VendorPrefix.empty(), + else => css.VendorPrefix{}, }; } @@ -238,7 +239,7 @@ fn langListToSelectors(allocator: Allocator, langs: []const []const u8) []Select /// Returns the vendor prefix (if any) used in the given selector list. /// If multiple vendor prefixes are seen, this is invalid, and an empty result is returned. pub fn getPrefix(selectors: *const SelectorList) css.VendorPrefix { - var prefix = css.VendorPrefix.empty(); + var prefix = css.VendorPrefix{}; for (selectors.v.slice()) |*selector| { for (selector.components.items) |*component_| { const component: *const Component = component_; @@ -255,16 +256,17 @@ pub fn getPrefix(selectors: *const SelectorList) css.VendorPrefix { .negation => css.VendorPrefix{ .none = true }, .any => |*any| any.vendor_prefix, .pseudo_element => |*pe| pe.getPrefix(), - else => css.VendorPrefix.empty(), + else => css.VendorPrefix{}, }; if (!p.isEmpty()) { // Allow none to be mixed with a prefix. - const prefix_without_none = prefix.maskOut(css.VendorPrefix{ .none = true }); - if (prefix_without_none.isEmpty() or prefix_without_none.eql(p)) { - prefix.insert(p); + var prefix_without_none = prefix; + prefix_without_none.none = false; + if (prefix_without_none.isEmpty() or prefix_without_none == p) { + bun.bits.insert(css.VendorPrefix, &prefix, p); } else { - return css.VendorPrefix.empty(); + return css.VendorPrefix{}; } } } @@ -351,12 +353,12 @@ pub fn isCompatible(selectors: []const parser.Selector, targets: css.targets.Tar .checked, .disabled, .enabled, .target => break :brk F.selectors3, .any_link => |prefix| { - if (prefix.eql(css.VendorPrefix{ .none = true })) break :brk F.any_link; + if (prefix == css.VendorPrefix{ .none = true }) break :brk F.any_link; }, .indeterminate => break :brk F.indeterminate_pseudo, .fullscreen => |prefix| { - if (prefix.eql(css.VendorPrefix{ .none = true })) break :brk F.fullscreen; + if (prefix == css.VendorPrefix{ .none = true }) break :brk F.fullscreen; }, .focus_visible => break :brk F.focus_visible, @@ -365,18 +367,18 @@ pub fn isCompatible(selectors: []const parser.Selector, targets: css.targets.Tar .dir => break :brk F.dir_selector, .optional => break :brk F.optional_pseudo, .placeholder_shown => |prefix| { - if (prefix.eql(css.VendorPrefix{ .none = true })) break :brk F.placeholder_shown; + if (prefix == css.VendorPrefix{ .none = true }) break :brk F.placeholder_shown; }, inline .read_only, .read_write => |prefix| { - if (prefix.eql(css.VendorPrefix{ .none = true })) break :brk F.read_only_write; + if (prefix == css.VendorPrefix{ .none = true }) break :brk F.read_only_write; }, .valid, .invalid, .required => break :brk F.form_validation, .in_range, .out_of_range => break :brk F.in_out_of_range, .autofill => |prefix| { - if (prefix.eql(css.VendorPrefix{ .none = true })) break :brk F.autofill; + if (prefix == css.VendorPrefix{ .none = true }) break :brk F.autofill; }, // Experimental, no browser support. @@ -411,14 +413,14 @@ pub fn isCompatible(selectors: []const parser.Selector, targets: css.targets.Tar .first_line => break :brk F.first_line, .first_letter => break :brk F.first_letter, .selection => |prefix| { - if (prefix.eql(css.VendorPrefix{ .none = true })) break :brk F.selection; + if (prefix == css.VendorPrefix{ .none = true }) break :brk F.selection; }, .placeholder => |prefix| { - if (prefix.eql(css.VendorPrefix{ .none = true })) break :brk F.placeholder; + if (prefix == css.VendorPrefix{ .none = true }) break :brk F.placeholder; }, .marker => break :brk F.marker_pseudo, .backdrop => |prefix| { - if (prefix.eql(css.VendorPrefix{ .none = true })) break :brk F.dialog; + if (prefix == css.VendorPrefix{ .none = true }) break :brk F.dialog; }, .cue => break :brk F.cue, .cue_function => break :brk F.cue_function, @@ -577,7 +579,7 @@ pub const serialize = struct { // which is a universal selector, append the result of // serializing the universal selector to s. // - // Check if `!compound.empty()` first--this can happen if we have + // Check if `!compound{}` first--this can happen if we have // something like `... > ::before`, because we store `>` and `::` // both as combinators internally. // @@ -747,7 +749,7 @@ pub const serialize = struct { } const vp = dest.vendor_prefix; - if (vp.intersects(css.VendorPrefix{ .webkit = true, .moz = true })) { + if (vp.webkit or vp.moz) { try dest.writeChar(':'); try vp.toCss(W, dest); try dest.writeStr("any("); @@ -760,7 +762,7 @@ pub const serialize = struct { }, .any => |v| { const vp = dest.vendor_prefix._or(v.vendor_prefix); - if (vp.intersects(css.VendorPrefix{ .webkit = true, .moz = true })) { + if (vp.webkit or vp.moz) { try dest.writeChar(':'); try vp.toCss(W, dest); try dest.writeStr("any("); @@ -885,7 +887,7 @@ pub const serialize = struct { try d.writeChar(':'); // If the printer has a vendor prefix override, use that. const vp = if (!d.vendor_prefix.isEmpty()) - d.vendor_prefix.bitwiseOr(prefix).orNone() + bun.bits.@"or"(css.VendorPrefix, d.vendor_prefix, prefix).orNone() else prefix; @@ -942,7 +944,7 @@ pub const serialize = struct { .fullscreen => |prefix| { try dest.writeChar(':'); const vp = if (!dest.vendor_prefix.isEmpty()) - dest.vendor_prefix.bitwiseAnd(prefix).orNone() + bits.@"and"(css.VendorPrefix, dest.vendor_prefix, prefix).orNone() else prefix; try vp.toCss(W, dest); @@ -1048,7 +1050,10 @@ pub const serialize = struct { pub fn writePrefix(d: *Printer(W), prefix: css.VendorPrefix) PrintErr!css.VendorPrefix { try d.writeStr("::"); // If the printer has a vendor prefix override, use that. - const vp = if (!d.vendor_prefix.isEmpty()) d.vendor_prefix.bitwiseAnd(prefix).orNone() else prefix; + const vp = if (!d.vendor_prefix.isEmpty()) + bits.@"and"(css.VendorPrefix, d.vendor_prefix, prefix).orNone() + else + prefix; try vp.toCss(W, d); debug("VENDOR PREFIX {d} OVERRIDE {d}", .{ vp.asBits(), d.vendor_prefix.asBits() }); return vp; @@ -1246,7 +1251,7 @@ pub const tocss_servo = struct { // which is a universal selector, append the result of // serializing the universal selector to s. // - // Check if `!compound.empty()` first--this can happen if we have + // Check if `!compound{}` first--this can happen if we have // something like `... > ::before`, because we store `>` and `::` // both as combinators internally. // diff --git a/src/css/small_list.zig b/src/css/small_list.zig index 33dba26e84..a2925ea166 100644 --- a/src/css/small_list.zig +++ b/src/css/small_list.zig @@ -213,16 +213,16 @@ pub fn SmallList(comptime T: type, comptime N: comptime_int) type { if (@hasDecl(T, "getImage") and N == 1) { const ColorFallbackKind = css.css_values.color.ColorFallbackKind; // Determine what vendor prefixes and color fallbacks are needed. - var prefixes = css.VendorPrefix.empty(); - var fallbacks = ColorFallbackKind.empty(); + var prefixes = css.VendorPrefix{}; + var fallbacks = ColorFallbackKind{}; var res: bun.BabyList(@This()) = .{}; for (this.slice()) |*item| { - prefixes.insert(item.getImage().getNecessaryPrefixes(targets)); - fallbacks.insert(item.getNecessaryFallbacks(targets)); + bun.bits.insert(css.VendorPrefix, &prefixes, item.getImage().getNecessaryPrefixes(targets)); + bun.bits.insert(css.ColorFallbackKind, &fallbacks, item.getNecessaryFallbacks(targets)); } // Get RGB fallbacks if needed. - const rgb: ?SmallList(T, 1) = if (fallbacks.contains(ColorFallbackKind{ .rgb = true })) brk: { + const rgb: ?SmallList(T, 1) = if (fallbacks.rgb) brk: { var shallow_clone = this.shallowClone(allocator); for (shallow_clone.slice_mut(), this.slice_mut()) |*out, *in| { out.* = in.getFallback(allocator, ColorFallbackKind{ .rgb = true }); @@ -234,7 +234,7 @@ pub fn SmallList(comptime T: type, comptime N: comptime_int) type { const prefix_images: *const SmallList(T, 1) = if (rgb) |*r| r else this; // Legacy -webkit-gradient() - if (prefixes.contains(css.VendorPrefix{ .webkit = true }) and targets.browsers != null and css.prefixes.Feature.isWebkitGradient(targets.browsers.?)) { + if (prefixes.webkit and targets.browsers != null and css.prefixes.Feature.isWebkitGradient(targets.browsers.?)) { const images = images: { var images = SmallList(T, 1){}; for (prefix_images.slice()) |*item| { @@ -251,7 +251,7 @@ pub fn SmallList(comptime T: type, comptime N: comptime_int) type { const prefix = struct { pub inline fn helper(comptime prefix: []const u8, pfs: *css.VendorPrefix, pfi: *const SmallList(T, 1), r: *bun.BabyList(This), alloc: Allocator) void { - if (pfs.contains(css.VendorPrefix.fromName(prefix))) { + if (bun.bits.contains(css.VendorPrefix, pfs.*, .fromName(prefix))) { var images = SmallList(T, 1).initCapacity(alloc, pfi.len()); images.setLen(pfi.len()); for (images.slice_mut(), pfi.slice()) |*out, *in| { @@ -267,12 +267,12 @@ pub fn SmallList(comptime T: type, comptime N: comptime_int) type { prefix("moz", &prefixes, prefix_images, &res, allocator); prefix("o", &prefixes, prefix_images, &res, allocator); - if (prefixes.contains(css.VendorPrefix{ .none = true })) { + if (prefixes.none) { if (rgb) |r| { res.push(allocator, r) catch bun.outOfMemory(); } - if (fallbacks.contains(ColorFallbackKind{ .p3 = true })) { + if (fallbacks.p3) { var p3_images = this.shallowClone(allocator); for (p3_images.slice_mut(), this.slice_mut()) |*out, *in| { out.* = in.getFallback(allocator, ColorFallbackKind{ .p3 = true }); @@ -280,7 +280,7 @@ pub fn SmallList(comptime T: type, comptime N: comptime_int) type { } // Convert to lab if needed (e.g. if oklab is not supported but lab is). - if (fallbacks.contains(ColorFallbackKind{ .lab = true })) { + if (fallbacks.lab) { for (this.slice_mut()) |*item| { var old = item.*; item.* = item.getFallback(allocator, ColorFallbackKind{ .lab = true }); @@ -298,13 +298,13 @@ pub fn SmallList(comptime T: type, comptime N: comptime_int) type { return res; } if (T == TextShadow and N == 1) { - var fallbacks = css.ColorFallbackKind.empty(); + var fallbacks = css.ColorFallbackKind{}; for (this.slice()) |*shadow| { - fallbacks.insert(shadow.color.getNecessaryFallbacks(targets)); + bun.bits.insert(css.ColorFallbackKind, &fallbacks, shadow.color.getNecessaryFallbacks(targets)); } var res = SmallList(SmallList(TextShadow, 1), 2){}; - if (fallbacks.contains(css.ColorFallbackKind{ .rgb = true })) { + if (fallbacks.rgb) { var rgb = SmallList(TextShadow, 1).initCapacity(allocator, this.len()); for (this.slice()) |*shadow| { var new_shadow = shadow.*; @@ -317,7 +317,7 @@ pub fn SmallList(comptime T: type, comptime N: comptime_int) type { res.append(allocator, rgb); } - if (fallbacks.contains(css.ColorFallbackKind{ .p3 = true })) { + if (fallbacks.p3) { var p3 = SmallList(TextShadow, 1).initCapacity(allocator, this.len()); for (this.slice()) |*shadow| { var new_shadow = shadow.*; @@ -330,7 +330,7 @@ pub fn SmallList(comptime T: type, comptime N: comptime_int) type { res.append(allocator, p3); } - if (fallbacks.contains(css.ColorFallbackKind{ .lab = true })) { + if (fallbacks.lab) { for (this.slice_mut()) |*shadow| { const out = shadow.color.toLAB(allocator).?; shadow.color.deinit(allocator); diff --git a/src/css/targets.zig b/src/css/targets.zig index d50825b523..9e168f2486 100644 --- a/src/css/targets.zig +++ b/src/css/targets.zig @@ -3,6 +3,7 @@ const bun = @import("bun"); const Allocator = std.mem.Allocator; pub const css = @import("./css_parser.zig"); +const bits = bun.bits; const Printer = css.Printer; const PrintErr = css.PrintErr; @@ -90,9 +91,9 @@ pub const Targets = struct { } pub fn prefixes(this: *const Targets, prefix: css.VendorPrefix, feature: css.prefixes.Feature) css.VendorPrefix { - if (prefix.contains(css.VendorPrefix{ .none = true }) and !this.exclude.contains(css.targets.Features{ .vendor_prefixes = true })) { - if (this.include.contains(css.targets.Features{ .vendor_prefixes = true })) { - return css.VendorPrefix.all(); + if (prefix.none and !this.exclude.vendor_prefixes) { + if (this.include.vendor_prefixes) { + return .all; } else { return if (this.browsers) |b| feature.prefixesFor(b) else prefix; } @@ -106,7 +107,8 @@ pub const Targets = struct { } pub fn shouldCompile(this: *const Targets, feature: css.compat.Feature, flag: Features) bool { - return this.include.contains(flag) or (!this.exclude.contains(flag) and !this.isCompatible(feature)); + return bits.contains(Features, this.include, flag) or + (!bits.contains(Features, this.exclude, flag) and !this.isCompatible(feature)); } pub fn shouldCompileSame(this: *const Targets, comptime compat_feature: css.compat.Feature) bool { @@ -120,8 +122,8 @@ pub const Targets = struct { } pub fn shouldCompileSelectors(this: *const Targets) bool { - return this.include.intersects(Features.selectors) or - (!this.exclude.intersects(Features.selectors) and this.browsers != null); + return bun.bits.intersects(Features, this.include, Features.selectors) or + (!bun.bits.intersects(Features, this.exclude, Features.selectors) and this.browsers != null); } pub fn isCompatible(this: *const Targets, feature: css.compat.Feature) bool { @@ -132,8 +134,6 @@ pub const Targets = struct { } }; -/// Autogenerated by build-prefixes.js -/// /// Browser versions to compile CSS for. /// /// Versions are represented as a single 24-bit integer, with one byte @@ -159,7 +159,148 @@ pub const Browsers = struct { opera: ?u32 = null, safari: ?u32 = null, samsung: ?u32 = null, - pub usingnamespace BrowsersImpl(@This()); + + pub const browserDefault = convertFromString(&.{ + "es2020", // support import.meta.url + "edge88", + "firefox78", + "chrome87", + "safari14", + }) catch unreachable; + + /// Ported from here: + /// https://github.com/vitejs/vite/blob/ac329685bba229e1ff43e3d96324f817d48abe48/packages/vite/src/node/plugins/css.ts#L3335 + pub fn convertFromString(esbuild_target: []const []const u8) anyerror!Browsers { + var browsers: Browsers = .{}; + + for (esbuild_target) |str| { + var entries_buf: [5][]const u8 = undefined; + const entries_without_es: [][]const u8 = entries_without_es: { + if (str.len <= 2 or !(str[0] == 'e' and str[1] == 's')) { + entries_buf[0] = str; + break :entries_without_es entries_buf[0..1]; + } + + const number_part = str[2..]; + const year = try std.fmt.parseInt(u16, number_part, 10); + switch (year) { + // https://caniuse.com/?search=es2015 + 2015 => { + entries_buf[0..5].* = .{ "chrome49", "edge13", "safari10", "firefox44", "opera36" }; + break :entries_without_es entries_buf[0..5]; + }, + // https://caniuse.com/?search=es2016 + 2016 => { + entries_buf[0..5].* = .{ "chrome50", "edge13", "safari10", "firefox43", "opera37" }; + break :entries_without_es entries_buf[0..5]; + }, + // https://caniuse.com/?search=es2017 + 2017 => { + entries_buf[0..5].* = .{ "chrome58", "edge15", "safari11", "firefox52", "opera45" }; + break :entries_without_es entries_buf[0..5]; + }, + // https://caniuse.com/?search=es2018 + 2018 => { + entries_buf[0..5].* = .{ "chrome63", "edge79", "safari12", "firefox58", "opera50" }; + break :entries_without_es entries_buf[0..5]; + }, + // https://caniuse.com/?search=es2019 + 2019 => { + entries_buf[0..5].* = .{ "chrome73", "edge79", "safari12.1", "firefox64", "opera60" }; + break :entries_without_es entries_buf[0..5]; + }, + // https://caniuse.com/?search=es2020 + 2020 => { + entries_buf[0..5].* = .{ "chrome80", "edge80", "safari14.1", "firefox80", "opera67" }; + break :entries_without_es entries_buf[0..5]; + }, + // https://caniuse.com/?search=es2021 + 2021 => { + entries_buf[0..5].* = .{ "chrome85", "edge85", "safari14.1", "firefox80", "opera71" }; + break :entries_without_es entries_buf[0..5]; + }, + // https://caniuse.com/?search=es2022 + 2022 => { + entries_buf[0..5].* = .{ "chrome94", "edge94", "safari16.4", "firefox93", "opera80" }; + break :entries_without_es entries_buf[0..5]; + }, + // https://caniuse.com/?search=es2023 + 2023 => { + entries_buf[0..4].* = .{ "chrome110", "edge110", "safari16.4", "opera96" }; + break :entries_without_es entries_buf[0..4]; + }, + else => { + if (@inComptime()) { + @compileLog("Invalid target: " ++ str); + } + return error.UnsupportedCSSTarget; + }, + } + }; + + for_loop: for (entries_without_es) |entry| { + if (bun.strings.eql(entry, "esnext")) continue; + const maybe_idx: ?usize = maybe_idx: { + for (entry, 0..) |c, i| { + if (std.ascii.isDigit(c)) break :maybe_idx i; + } + break :maybe_idx null; + }; + + if (maybe_idx) |idx| { + const Browser = enum { + chrome, + edge, + firefox, + ie, + ios_saf, + opera, + safari, + no_mapping, + }; + const Map = bun.ComptimeStringMap(Browser, .{ + .{ "chrome", Browser.chrome }, + .{ "edge", Browser.edge }, + .{ "firefox", Browser.firefox }, + .{ "hermes", Browser.no_mapping }, + .{ "ie", Browser.ie }, + .{ "ios", Browser.ios_saf }, + .{ "node", Browser.no_mapping }, + .{ "opera", Browser.opera }, + .{ "rhino", Browser.no_mapping }, + .{ "safari", Browser.safari }, + }); + const browser = Map.get(entry[0..idx]); + if (browser == null or browser.? == .no_mapping) continue; // No mapping available + + const major, const minor = major_minor: { + const version_str = entry[idx..]; + const dot_index = std.mem.indexOfScalar(u8, version_str, '.') orelse version_str.len; + const major = std.fmt.parseInt(u16, version_str[0..dot_index], 10) catch continue; + const minor = if (dot_index < version_str.len) + std.fmt.parseInt(u16, version_str[dot_index + 1 ..], 10) catch 0 + else + 0; + break :major_minor .{ major, minor }; + }; + + const version: u32 = (@as(u32, major) << 16) | @as(u32, minor << 8); + switch (browser.?) { + inline else => |browser_name| { + if (@field(browsers, @tagName(browser_name)) == null or + version < @field(browsers, @tagName(browser_name)).?) + { + @field(browsers, @tagName(browser_name)) = version; + } + continue :for_loop; + }, + } + } + } + } + + return browsers; + } }; /// Autogenerated by build-prefixes.js @@ -186,169 +327,25 @@ pub const Features = packed struct(u32) { vendor_prefixes: bool = false, logical_properties: bool = false, __unused: u12 = 0, - pub const selectors = Features.fromNames(&.{ "nesting", "not_selector_list", "dir_selector", "lang_selector_list", "is_selector" }); - pub const media_queries = Features.fromNames(&.{ "media_interval_syntax", "media_range_syntax", "custom_media_queries" }); - pub const colors = Features.fromNames(&.{ "color_function", "oklab_colors", "lab_colors", "p3_colors", "hex_alpha_colors", "space_separated_color_notation" }); - pub usingnamespace css.Bitflags(@This()); - pub usingnamespace FeaturesImpl(@This()); -}; - -pub fn BrowsersImpl(comptime T: type) type { - return struct { - pub const browserDefault = convertFromString(&.{ - "es2020", // support import.meta.url - "edge88", - "firefox78", - "chrome87", - "safari14", - }) catch |e| std.debug.panic("WOOPSIE: {s}\n", .{@errorName(e)}); - - // pub const bundlerDefault = T{ - // .chrome = 80 << 16, - // .edge = 80 << 16, - // .firefox = 78 << 16, - // .safari = 14 << 16, - // .opera = 67 << 16, - // }; - - /// Ported from here: - /// https://github.com/vitejs/vite/blob/ac329685bba229e1ff43e3d96324f817d48abe48/packages/vite/src/node/plugins/css.ts#L3335 - pub fn convertFromString(esbuild_target: []const []const u8) anyerror!T { - var browsers: T = .{}; - - for (esbuild_target) |str| { - var entries_buf: [5][]const u8 = undefined; - const entries_without_es: [][]const u8 = entries_without_es: { - if (str.len <= 2 or !(str[0] == 'e' and str[1] == 's')) { - entries_buf[0] = str; - break :entries_without_es entries_buf[0..1]; - } - - const number_part = str[2..]; - const year = try std.fmt.parseInt(u16, number_part, 10); - switch (year) { - // https://caniuse.com/?search=es2015 - 2015 => { - entries_buf[0..5].* = .{ "chrome49", "edge13", "safari10", "firefox44", "opera36" }; - break :entries_without_es entries_buf[0..5]; - }, - // https://caniuse.com/?search=es2016 - 2016 => { - entries_buf[0..5].* = .{ "chrome50", "edge13", "safari10", "firefox43", "opera37" }; - break :entries_without_es entries_buf[0..5]; - }, - // https://caniuse.com/?search=es2017 - 2017 => { - entries_buf[0..5].* = .{ "chrome58", "edge15", "safari11", "firefox52", "opera45" }; - break :entries_without_es entries_buf[0..5]; - }, - // https://caniuse.com/?search=es2018 - 2018 => { - entries_buf[0..5].* = .{ "chrome63", "edge79", "safari12", "firefox58", "opera50" }; - break :entries_without_es entries_buf[0..5]; - }, - // https://caniuse.com/?search=es2019 - 2019 => { - entries_buf[0..5].* = .{ "chrome73", "edge79", "safari12.1", "firefox64", "opera60" }; - break :entries_without_es entries_buf[0..5]; - }, - // https://caniuse.com/?search=es2020 - 2020 => { - entries_buf[0..5].* = .{ "chrome80", "edge80", "safari14.1", "firefox80", "opera67" }; - break :entries_without_es entries_buf[0..5]; - }, - // https://caniuse.com/?search=es2021 - 2021 => { - entries_buf[0..5].* = .{ "chrome85", "edge85", "safari14.1", "firefox80", "opera71" }; - break :entries_without_es entries_buf[0..5]; - }, - // https://caniuse.com/?search=es2022 - 2022 => { - entries_buf[0..5].* = .{ "chrome94", "edge94", "safari16.4", "firefox93", "opera80" }; - break :entries_without_es entries_buf[0..5]; - }, - // https://caniuse.com/?search=es2023 - 2023 => { - entries_buf[0..4].* = .{ "chrome110", "edge110", "safari16.4", "opera96" }; - break :entries_without_es entries_buf[0..4]; - }, - else => { - if (@inComptime()) { - @compileLog("Invalid target: " ++ str); - } - return error.UnsupportedCSSTarget; - }, - } - }; - - for_loop: for (entries_without_es) |entry| { - if (bun.strings.eql(entry, "esnext")) continue; - const maybe_idx: ?usize = maybe_idx: { - for (entry, 0..) |c, i| { - if (std.ascii.isDigit(c)) break :maybe_idx i; - } - break :maybe_idx null; - }; - - if (maybe_idx) |idx| { - const Browser = enum { - chrome, - edge, - firefox, - ie, - ios_saf, - opera, - safari, - no_mapping, - }; - const Map = bun.ComptimeStringMap(Browser, .{ - .{ "chrome", Browser.chrome }, - .{ "edge", Browser.edge }, - .{ "firefox", Browser.firefox }, - .{ "hermes", Browser.no_mapping }, - .{ "ie", Browser.ie }, - .{ "ios", Browser.ios_saf }, - .{ "node", Browser.no_mapping }, - .{ "opera", Browser.opera }, - .{ "rhino", Browser.no_mapping }, - .{ "safari", Browser.safari }, - }); - const browser = Map.get(entry[0..idx]); - if (browser == null or browser.? == .no_mapping) continue; // No mapping available - - const major, const minor = major_minor: { - const version_str = entry[idx..]; - const dot_index = std.mem.indexOfScalar(u8, version_str, '.') orelse version_str.len; - const major = std.fmt.parseInt(u16, version_str[0..dot_index], 10) catch continue; - const minor = if (dot_index < version_str.len) - std.fmt.parseInt(u16, version_str[dot_index + 1 ..], 10) catch 0 - else - 0; - break :major_minor .{ major, minor }; - }; - - const version: u32 = (@as(u32, major) << 16) | @as(u32, minor << 8); - switch (browser.?) { - inline else => |browser_name| { - if (@field(browsers, @tagName(browser_name)) == null or - version < @field(browsers, @tagName(browser_name)).?) - { - @field(browsers, @tagName(browser_name)) = version; - } - continue :for_loop; - }, - } - } - } - } - - return browsers; - } + pub const selectors: @This() = .{ + .nesting = true, + .not_selector_list = true, + .dir_selector = true, + .lang_selector_list = true, + .is_selector = true, }; -} - -pub fn FeaturesImpl(comptime T: type) type { - _ = T; // autofix - return struct {}; -} + pub const media_queries: @This() = .{ + .media_interval_syntax = true, + .media_range_syntax = true, + .custom_media_queries = true, + }; + pub const colors: @This() = .{ + .color_function = true, + .oklab_colors = true, + .lab_colors = true, + .p3_colors = true, + .hex_alpha_colors = true, + .space_separated_color_notation = true, + }; +}; diff --git a/src/css/values/color.zig b/src/css/values/color.zig index 0dadedd867..6936e02c42 100644 --- a/src/css/values/color.zig +++ b/src/css/values/color.zig @@ -3,6 +3,7 @@ const Allocator = std.mem.Allocator; const bun = @import("bun"); const logger = bun.logger; const Log = logger.Log; +const bits = bun.bits; pub const css = @import("../css_parser.zig"); pub const Result = css.Result; @@ -497,15 +498,15 @@ pub const CssColor = union(enum) { var res = css.SmallList(CssColor, 2){}; - if (fallbacks.contains(ColorFallbackKind{ .rgb = true })) { + if (fallbacks.rgb) { res.appendAssumeCapacity(this.toRGB(allocator).?); } - if (fallbacks.contains(ColorFallbackKind{ .p3 = true })) { + if (fallbacks.p3) { res.appendAssumeCapacity(this.toP3(allocator).?); } - if (fallbacks.contains(ColorFallbackKind{ .lab = true })) { + if (fallbacks.lab) { const foo = this.toLAB(allocator).?; this.* = foo; } @@ -526,49 +527,49 @@ pub const CssColor = union(enum) { // below and including the authored color space, and remove the ones that aren't // compatible with our browser targets. var fallbacks = switch (this.*) { - .current_color, .rgba, .float, .system => return ColorFallbackKind.empty(), + .current_color, .rgba, .float, .system => return ColorFallbackKind{}, .lab => |lab| brk: { if (lab.* == .lab or lab.* == .lch and targets.shouldCompileSame(.lab_colors)) break :brk ColorFallbackKind.andBelow(.{ .lab = true }); if (lab.* == .oklab or lab.* == .oklch and targets.shouldCompileSame(.oklab_colors)) break :brk ColorFallbackKind.andBelow(.{ .oklab = true }); - return ColorFallbackKind.empty(); + return ColorFallbackKind{}; }, .predefined => |predefined| brk: { if (predefined.* == .display_p3 and targets.shouldCompileSame(.p3_colors)) break :brk ColorFallbackKind.andBelow(.{ .p3 = true }); if (targets.shouldCompileSame(.color_function)) break :brk ColorFallbackKind.andBelow(.{ .lab = true }); - return ColorFallbackKind.empty(); + return ColorFallbackKind{}; }, .light_dark => |*ld| { - return ld.light.getPossibleFallbacks(targets).bitwiseOr(ld.dark.getPossibleFallbacks(targets)); + return bun.bits.@"or"(ColorFallbackKind, ld.light.getPossibleFallbacks(targets), ld.dark.getPossibleFallbacks(targets)); }, }; - if (fallbacks.contains(.{ .oklab = true })) { + if (fallbacks.oklab) { if (!targets.shouldCompileSame(.oklab_colors)) { - fallbacks.remove(ColorFallbackKind.andBelow(.{ .lab = true })); + fallbacks = fallbacks.difference(ColorFallbackKind.andBelow(.{ .lab = true })); } } - if (fallbacks.contains(.{ .lab = true })) { + if (fallbacks.lab) { if (!targets.shouldCompileSame(.lab_colors)) { fallbacks = fallbacks.difference(ColorFallbackKind.andBelow(.{ .p3 = true })); } else if (targets.browsers != null and css.compat.Feature.isPartiallyCompatible(&css.compat.Feature.lab_colors, targets.browsers.?)) { // We don't need P3 if Lab is supported by some of our targets. // No browser implements Lab but not P3. - fallbacks.remove(.{ .p3 = true }); + fallbacks.p3 = false; } } - if (fallbacks.contains(.{ .p3 = true })) { + if (fallbacks.p3) { if (!targets.shouldCompileSame(.p3_colors)) { - fallbacks.remove(.{ .rgb = true }); - } else if (fallbacks.highest().asBits() != ColorFallbackKind.asBits(.{ .p3 = true }) and + fallbacks.rgb = false; + } else if (fallbacks.highest() != ColorFallbackKind.P3 and (targets.browsers == null or !css.compat.Feature.isPartiallyCompatible(&css.compat.Feature.p3_colors, targets.browsers.?))) { // Remove P3 if it isn't supported by any targets, and wasn't the // original authored color. - fallbacks.remove(.{ .p3 = true }); + fallbacks.p3 = false; } } @@ -673,7 +674,7 @@ pub fn parseColorFunction(location: css.SourceLocation, function: []const u8, in fn callback(allocator: Allocator, h: f32, s: f32, l: f32, a: f32) CssColor { const hsl = HSL{ .h = h, .s = s, .l = l, .alpha = a }; if (!std.math.isNan(h) and !std.math.isNan(s) and !std.math.isNan(l) and !std.math.isNan(a)) { - return CssColor{ .rgba = hsl.intoRGBA() }; + return CssColor{ .rgba = hsl.into(.RGBA) }; } else { return CssColor{ .float = bun.create(allocator, FloatColor, .{ .hsl = hsl }) }; } @@ -683,7 +684,7 @@ pub fn parseColorFunction(location: css.SourceLocation, function: []const u8, in fn callback(allocator: Allocator, h: f32, w: f32, b: f32, a: f32) CssColor { const hwb = HWB{ .h = h, .w = w, .b = b, .alpha = a }; if (!std.math.isNan(h) and !std.math.isNan(w) and !std.math.isNan(b) and !std.math.isNan(a)) { - return CssColor{ .rgba = hwb.intoRGBA() }; + return CssColor{ .rgba = hwb.into(.RGBA) }; } else { return CssColor{ .float = bun.create(allocator, FloatColor, .{ .hwb = hwb }) }; } @@ -818,12 +819,12 @@ pub fn parseHSLHWBComponents(comptime T: type, input: *css.Parser, parser: *Comp } pub fn mapGamut(comptime T: type, color: T) T { - const conversion_function_name = "into" ++ comptime bun.meta.typeName(T); + const conversion_target = comptime ConvertTo.fromType(T); const JND: f32 = 0.02; const EPSILON: f32 = 0.00001; // https://www.w3.org/TR/css-color-4/#binsearch - var current: OKLCH = color.intoOKLCH(); + var current: OKLCH = color.into(.OKLCH); // If lightness is >= 100%, return pure white. if (@abs(current.l - 1.0) < EPSILON or current.l > 1.0) { @@ -833,7 +834,7 @@ pub fn mapGamut(comptime T: type, color: T) T { .h = 0.0, .alpha = current.alpha, }; - return @call(.auto, @field(OKLCH, conversion_function_name), .{&oklch}); + return oklch.into(conversion_target); } // If lightness <= 0%, return pure black. @@ -844,7 +845,7 @@ pub fn mapGamut(comptime T: type, color: T) T { .h = 0.0, .alpha = current.alpha, }; - return @call(.auto, @field(OKLCH, conversion_function_name), .{&oklch}); + return oklch.into(conversion_target); } var min: f32 = 0.0; @@ -854,7 +855,7 @@ pub fn mapGamut(comptime T: type, color: T) T { const chroma = (min + max) / 2.0; current.c = chroma; - const converted = @call(.auto, @field(OKLCH, conversion_function_name), .{¤t}); + const converted = current.into(conversion_target); if (converted.inGamut()) { min = chroma; continue; @@ -869,13 +870,13 @@ pub fn mapGamut(comptime T: type, color: T) T { max = chroma; } - return @call(.auto, @field(OKLCH, conversion_function_name), .{¤t}); + return current.into(conversion_target); } pub fn deltaEok(comptime T: type, _a: T, _b: OKLCH) f32 { // https://www.w3.org/TR/css-color-4/#color-difference-OK - const a = T.intoOKLAB(&_a); - const b: OKLAB = _b.intoOKLAB(); + const a: OKLAB = _a.into(.OKLAB); + const b: OKLAB = _b.into(.OKLAB); const delta_l = a.l - b.l; const delta_a = a.a - b.a; @@ -1337,8 +1338,15 @@ pub const RGBA = struct { /// The alpha component. alpha: u8, - pub usingnamespace ColorspaceConversions(@This()); - pub usingnamespace color_conversions.convert_RGBA; + /// Convert the color into another color format. + pub const into = ColorIntoMixin(@This(), .RGBA).into; + + const conversions_impl = ColorspaceConversions(@This()); + pub const fromLABColor = conversions_impl.fromLABColor; + pub const fromPredefinedColor = conversions_impl.fromPredefinedColor; + pub const fromFloatColor = conversions_impl.fromFloatColor; + pub const tryFromCssColor = conversions_impl.tryFromCssColor; + pub const hash = conversions_impl.hash; pub fn new(red: u8, green: u8, blue: u8, alpha: f32) RGBA { return RGBA{ @@ -1620,15 +1628,33 @@ pub const LAB = struct { /// The alpha component. alpha: f32, - pub usingnamespace DefineColorspace(@This(), ChannelTypeMap); - pub usingnamespace ColorspaceConversions(@This()); - pub usingnamespace UnboundedColorGamut(@This()); + const colorspace_impl = DefineColorspace(@This(), ChannelTypeMap); + pub const components = colorspace_impl.components; + pub const types = colorspace_impl.types; + pub const channels = colorspace_impl.channels; + pub const resolveMissing = colorspace_impl.resolveMissing; + pub const resolve = colorspace_impl.resolve; + const conversions_impl = ColorspaceConversions(@This()); + pub const fromLABColor = conversions_impl.fromLABColor; + pub const fromPredefinedColor = conversions_impl.fromPredefinedColor; + pub const fromFloatColor = conversions_impl.fromFloatColor; + pub const tryFromCssColor = conversions_impl.tryFromCssColor; + pub const hash = conversions_impl.hash; + const gamut_impl = UnboundedColorGamut(@This()); + pub const clip = gamut_impl.clip; + pub const inGamut = gamut_impl.inGamut; - pub usingnamespace AdjustPowerlessLAB(@This()); - pub usingnamespace DeriveInterpolate(@This(), "l", "a", "b"); - pub usingnamespace RecangularPremultiply(@This(), "l", "a", "b"); + pub const adjustPowerlessComponents = AdjustPowerlessLAB(@This()).adjustPowerlessComponents; + const interpolate_impl = DeriveInterpolate(@This(), "l", "a", "b"); + pub const fillMissingComponents = interpolate_impl.fillMissingComponents; + pub const interpolate = interpolate_impl.interpolate; + const recangular_impl = RecangularPremultiply(@This(), "l", "a", "b"); + pub const premultiply = recangular_impl.premultiply; + pub const unpremultiply = recangular_impl.unpremultiply; - pub usingnamespace color_conversions.convert_LAB; + /// Convert this color into another color format. + pub const into = ColorIntoMixin(@This(), .LAB).into; + pub const intoCssColor = ImplementIntoCssColor(@This(), .LAB); pub const ChannelTypeMap = .{ .l = ChannelType{ .percentage = true }, @@ -1650,14 +1676,32 @@ pub const SRGB = struct { /// The alpha component. alpha: f32, - pub usingnamespace DefineColorspace(@This(), ChannelTypeMap); - pub usingnamespace ColorspaceConversions(@This()); - pub usingnamespace BoundedColorGamut(@This()); + const colorspace_impl = DefineColorspace(@This(), ChannelTypeMap); + pub const components = colorspace_impl.components; + pub const channels = colorspace_impl.channels; + pub const types = colorspace_impl.types; + pub const resolveMissing = colorspace_impl.resolveMissing; + pub const resolve = colorspace_impl.resolve; + const conversions_impl = ColorspaceConversions(@This()); + pub const fromLABColor = conversions_impl.fromLABColor; + pub const fromPredefinedColor = conversions_impl.fromPredefinedColor; + pub const fromFloatColor = conversions_impl.fromFloatColor; + pub const tryFromCssColor = conversions_impl.tryFromCssColor; + pub const hash = conversions_impl.hash; + const gamut_impl = BoundedColorGamut(@This()); + pub const clip = gamut_impl.clip; + pub const inGamut = gamut_impl.inGamut; - pub usingnamespace DeriveInterpolate(@This(), "r", "g", "b"); - pub usingnamespace RecangularPremultiply(@This(), "r", "g", "b"); + const interpolate_impl = DeriveInterpolate(@This(), "r", "g", "b"); + pub const fillMissingComponents = interpolate_impl.fillMissingComponents; + pub const interpolate = interpolate_impl.interpolate; + const recangular_impl = RecangularPremultiply(@This(), "r", "g", "b"); + pub const premultiply = recangular_impl.premultiply; + pub const unpremultiply = recangular_impl.unpremultiply; - pub usingnamespace color_conversions.convert_SRGB; + /// Convert this color into another color format. + pub const into = ColorIntoMixin(@This(), .SRGB).into; + pub const intoCssColor = ImplementIntoCssColor(@This(), .SRGB); pub const ChannelTypeMap = .{ .r = ChannelType{ .percentage = true }, @@ -1690,14 +1734,32 @@ pub const HSL = struct { /// The alpha component. alpha: f32, - pub usingnamespace DefineColorspace(@This(), ChannelTypeMap); - pub usingnamespace ColorspaceConversions(@This()); - pub usingnamespace HslHwbColorGamut(@This(), "s", "l"); + const colorspace_impl = DefineColorspace(@This(), ChannelTypeMap); + pub const components = colorspace_impl.components; + pub const channels = colorspace_impl.channels; + pub const types = colorspace_impl.types; + pub const resolveMissing = colorspace_impl.resolveMissing; + pub const resolve = colorspace_impl.resolve; + const conversions_impl = ColorspaceConversions(@This()); + pub const fromLABColor = conversions_impl.fromLABColor; + pub const fromPredefinedColor = conversions_impl.fromPredefinedColor; + pub const fromFloatColor = conversions_impl.fromFloatColor; + pub const tryFromCssColor = conversions_impl.tryFromCssColor; + pub const hash = conversions_impl.hash; + const gamut_impl = HslHwbColorGamut(@This(), "s", "l"); + pub const clip = gamut_impl.clip; + pub const inGamut = gamut_impl.inGamut; - pub usingnamespace PolarPremultiply(@This(), "s", "l"); - pub usingnamespace DeriveInterpolate(@This(), "h", "s", "l"); + const polar_impl = PolarPremultiply(@This(), "s", "l"); + pub const premultiply = polar_impl.premultiply; + pub const unpremultiply = polar_impl.unpremultiply; + const interpolate_impl = DeriveInterpolate(@This(), "h", "s", "l"); + pub const fillMissingComponents = interpolate_impl.fillMissingComponents; + pub const interpolate = interpolate_impl.interpolate; - pub usingnamespace color_conversions.convert_HSL; + /// Convert this color into another color format. + pub const into = ColorIntoMixin(@This(), .HSL).into; + pub const intoCssColor = ImplementIntoCssColor(@This(), .HSL); pub const ChannelTypeMap = .{ .h = ChannelType{ .angle = true }, @@ -1734,14 +1796,32 @@ pub const HWB = struct { /// The alpha component. alpha: f32, - pub usingnamespace DefineColorspace(@This(), ChannelTypeMap); - pub usingnamespace ColorspaceConversions(@This()); - pub usingnamespace HslHwbColorGamut(@This(), "w", "b"); + const colorspace_impl = DefineColorspace(@This(), ChannelTypeMap); + pub const components = colorspace_impl.components; + pub const channels = colorspace_impl.channels; + pub const types = colorspace_impl.types; + pub const resolveMissing = colorspace_impl.resolveMissing; + pub const resolve = colorspace_impl.resolve; + const conversions_impl = ColorspaceConversions(@This()); + pub const fromLABColor = conversions_impl.fromLABColor; + pub const fromPredefinedColor = conversions_impl.fromPredefinedColor; + pub const fromFloatColor = conversions_impl.fromFloatColor; + pub const tryFromCssColor = conversions_impl.tryFromCssColor; + pub const hash = conversions_impl.hash; + const gamut_impl = HslHwbColorGamut(@This(), "w", "b"); + pub const inGamut = gamut_impl.inGamut; + pub const clip = gamut_impl.clip; - pub usingnamespace PolarPremultiply(@This(), "w", "b"); - pub usingnamespace DeriveInterpolate(@This(), "h", "w", "b"); + const polar_impl = PolarPremultiply(@This(), "w", "b"); + pub const premultiply = polar_impl.premultiply; + pub const unpremultiply = polar_impl.unpremultiply; + const interpolate_impl = DeriveInterpolate(@This(), "h", "w", "b"); + pub const fillMissingComponents = interpolate_impl.fillMissingComponents; + pub const interpolate = interpolate_impl.interpolate; - pub usingnamespace color_conversions.convert_HWB; + /// Convert this color into another color format. + pub const into = ColorIntoMixin(@This(), .HWB).into; + pub const intoCssColor = ImplementIntoCssColor(@This(), .HWB); pub const ChannelTypeMap = .{ .h = ChannelType{ .angle = true }, @@ -1773,14 +1853,32 @@ pub const SRGBLinear = struct { /// The alpha component. alpha: f32, - pub usingnamespace DefineColorspace(@This(), ChannelTypeMap); - pub usingnamespace ColorspaceConversions(@This()); - pub usingnamespace BoundedColorGamut(@This()); + const colorspace_impl = DefineColorspace(@This(), ChannelTypeMap); + pub const components = colorspace_impl.components; + pub const channels = colorspace_impl.channels; + pub const types = colorspace_impl.types; + pub const resolveMissing = colorspace_impl.resolveMissing; + pub const resolve = colorspace_impl.resolve; + const conversions_impl = ColorspaceConversions(@This()); + pub const fromLABColor = conversions_impl.fromLABColor; + pub const fromPredefinedColor = conversions_impl.fromPredefinedColor; + pub const fromFloatColor = conversions_impl.fromFloatColor; + pub const tryFromCssColor = conversions_impl.tryFromCssColor; + pub const hash = conversions_impl.hash; + const gamut_impl = BoundedColorGamut(@This()); + pub const clip = gamut_impl.clip; + pub const inGamut = gamut_impl.inGamut; - pub usingnamespace DeriveInterpolate(@This(), "r", "g", "b"); - pub usingnamespace RecangularPremultiply(@This(), "r", "g", "b"); + const interpolate_impl = DeriveInterpolate(@This(), "r", "g", "b"); + pub const fillMissingComponents = interpolate_impl.fillMissingComponents; + pub const interpolate = interpolate_impl.interpolate; + const recangular_impl = RecangularPremultiply(@This(), "r", "g", "b"); + pub const premultiply = recangular_impl.premultiply; + pub const unpremultiply = recangular_impl.unpremultiply; - pub usingnamespace color_conversions.convert_SRGBLinear; + /// Convert this color into another color format. + pub const into = ColorIntoMixin(@This(), .SRGBLinear).into; + pub const intoCssColor = ImplementIntoCssColor(@This(), .SRGBLinear); pub const ChannelTypeMap = .{ .r = ChannelType{ .angle = true }, @@ -1803,11 +1901,25 @@ pub const P3 = struct { /// The alpha component. alpha: f32, - pub usingnamespace DefineColorspace(@This(), ChannelTypeMap); - pub usingnamespace ColorspaceConversions(@This()); - pub usingnamespace BoundedColorGamut(@This()); + const colorspace_impl = DefineColorspace(@This(), ChannelTypeMap); + pub const components = colorspace_impl.components; + pub const channels = colorspace_impl.channels; + pub const types = colorspace_impl.types; + pub const resolveMissing = colorspace_impl.resolveMissing; + pub const resolve = colorspace_impl.resolve; + const conversions_impl = ColorspaceConversions(@This()); + pub const fromLABColor = conversions_impl.fromLABColor; + pub const fromPredefinedColor = conversions_impl.fromPredefinedColor; + pub const fromFloatColor = conversions_impl.fromFloatColor; + pub const tryFromCssColor = conversions_impl.tryFromCssColor; + pub const hash = conversions_impl.hash; + const gamut_impl = BoundedColorGamut(@This()); + pub const clip = gamut_impl.clip; + pub const inGamut = gamut_impl.inGamut; - pub usingnamespace color_conversions.convert_P3; + /// Convert this color into another color format. + pub const into = ColorIntoMixin(@This(), .P3).into; + pub const intoCssColor = ImplementIntoCssColor(@This(), .P3); pub const ChannelTypeMap = .{ .r = ChannelType{ .percentage = true }, @@ -1827,11 +1939,25 @@ pub const A98 = struct { /// The alpha component. alpha: f32, - pub usingnamespace DefineColorspace(@This(), ChannelTypeMap); - pub usingnamespace ColorspaceConversions(@This()); - pub usingnamespace BoundedColorGamut(@This()); + const colorspace_impl = DefineColorspace(@This(), ChannelTypeMap); + pub const components = colorspace_impl.components; + pub const channels = colorspace_impl.channels; + pub const types = colorspace_impl.types; + pub const resolveMissing = colorspace_impl.resolveMissing; + pub const resolve = colorspace_impl.resolve; + const conversions_impl = ColorspaceConversions(@This()); + pub const fromLABColor = conversions_impl.fromLABColor; + pub const fromPredefinedColor = conversions_impl.fromPredefinedColor; + pub const fromFloatColor = conversions_impl.fromFloatColor; + pub const tryFromCssColor = conversions_impl.tryFromCssColor; + pub const hash = conversions_impl.hash; + const gamut_impl = BoundedColorGamut(@This()); + pub const clip = gamut_impl.clip; + pub const inGamut = gamut_impl.inGamut; - pub usingnamespace color_conversions.convert_A98; + /// Convert this color into another color format. + pub const into = ColorIntoMixin(@This(), .A98).into; + pub const intoCssColor = ImplementIntoCssColor(@This(), .A98); pub const ChannelTypeMap = .{ .r = ChannelType{ .percentage = true }, @@ -1851,11 +1977,25 @@ pub const ProPhoto = struct { /// The alpha component. alpha: f32, - pub usingnamespace DefineColorspace(@This(), ChannelTypeMap); - pub usingnamespace ColorspaceConversions(@This()); - pub usingnamespace BoundedColorGamut(@This()); + const colorspace_impl = DefineColorspace(@This(), ChannelTypeMap); + pub const components = colorspace_impl.components; + pub const channels = colorspace_impl.channels; + pub const types = colorspace_impl.types; + pub const resolveMissing = colorspace_impl.resolveMissing; + pub const resolve = colorspace_impl.resolve; + const conversions_impl = ColorspaceConversions(@This()); + pub const fromLABColor = conversions_impl.fromLABColor; + pub const fromPredefinedColor = conversions_impl.fromPredefinedColor; + pub const fromFloatColor = conversions_impl.fromFloatColor; + pub const tryFromCssColor = conversions_impl.tryFromCssColor; + pub const hash = conversions_impl.hash; + const gamut_impl = BoundedColorGamut(@This()); + pub const clip = gamut_impl.clip; + pub const inGamut = gamut_impl.inGamut; - pub usingnamespace color_conversions.convert_ProPhoto; + /// Convert this color into another color format. + pub const into = ColorIntoMixin(@This(), .ProPhoto).into; + pub const intoCssColor = ImplementIntoCssColor(@This(), .ProPhoto); pub const ChannelTypeMap = .{ .r = ChannelType{ .percentage = true }, @@ -1875,11 +2015,25 @@ pub const Rec2020 = struct { /// The alpha component. alpha: f32, - pub usingnamespace DefineColorspace(@This(), ChannelTypeMap); - pub usingnamespace ColorspaceConversions(@This()); - pub usingnamespace BoundedColorGamut(@This()); + const colorspace_impl = DefineColorspace(@This(), ChannelTypeMap); + pub const components = colorspace_impl.components; + pub const channels = colorspace_impl.channels; + pub const types = colorspace_impl.types; + pub const resolveMissing = colorspace_impl.resolveMissing; + pub const resolve = colorspace_impl.resolve; + const conversions_impl = ColorspaceConversions(@This()); + pub const fromLABColor = conversions_impl.fromLABColor; + pub const fromPredefinedColor = conversions_impl.fromPredefinedColor; + pub const fromFloatColor = conversions_impl.fromFloatColor; + pub const tryFromCssColor = conversions_impl.tryFromCssColor; + pub const hash = conversions_impl.hash; + const gamut_impl = BoundedColorGamut(@This()); + pub const clip = gamut_impl.clip; + pub const inGamut = gamut_impl.inGamut; - pub usingnamespace color_conversions.convert_Rec2020; + /// Convert this color into another color format. + pub const into = ColorIntoMixin(@This(), .Rec2020).into; + pub const intoCssColor = ImplementIntoCssColor(@This(), .Rec2020); pub const ChannelTypeMap = .{ .r = ChannelType{ .percentage = true }, @@ -1899,14 +2053,32 @@ pub const XYZd50 = struct { /// The alpha component. alpha: f32, - pub usingnamespace DefineColorspace(@This(), ChannelTypeMap); - pub usingnamespace ColorspaceConversions(@This()); - pub usingnamespace UnboundedColorGamut(@This()); + const colorspace_impl = DefineColorspace(@This(), ChannelTypeMap); + pub const components = colorspace_impl.components; + pub const channels = colorspace_impl.channels; + pub const types = colorspace_impl.types; + pub const resolveMissing = colorspace_impl.resolveMissing; + pub const resolve = colorspace_impl.resolve; + const conversions_impl = ColorspaceConversions(@This()); + pub const fromLABColor = conversions_impl.fromLABColor; + pub const fromPredefinedColor = conversions_impl.fromPredefinedColor; + pub const fromFloatColor = conversions_impl.fromFloatColor; + pub const tryFromCssColor = conversions_impl.tryFromCssColor; + pub const hash = conversions_impl.hash; + const gamut_impl = UnboundedColorGamut(@This()); + pub const clip = gamut_impl.clip; + pub const inGamut = gamut_impl.inGamut; - pub usingnamespace DeriveInterpolate(@This(), "x", "y", "z"); - pub usingnamespace RecangularPremultiply(@This(), "x", "y", "z"); + const interpolate_impl = DeriveInterpolate(@This(), "x", "y", "z"); + pub const fillMissingComponents = interpolate_impl.fillMissingComponents; + pub const interpolate = interpolate_impl.interpolate; + const recangular_impl = RecangularPremultiply(@This(), "x", "y", "z"); + pub const premultiply = recangular_impl.premultiply; + pub const unpremultiply = recangular_impl.unpremultiply; - pub usingnamespace color_conversions.convert_XYZd50; + /// Convert this color into another color format. + pub const into = ColorIntoMixin(@This(), .XYZd50).into; + pub const intoCssColor = ImplementIntoCssColor(@This(), .XYZd50); pub const ChannelTypeMap = .{ .x = ChannelType{ .percentage = true }, @@ -1926,14 +2098,32 @@ pub const XYZd65 = struct { /// The alpha component. alpha: f32, - pub usingnamespace DefineColorspace(@This(), ChannelTypeMap); - pub usingnamespace ColorspaceConversions(@This()); - pub usingnamespace UnboundedColorGamut(@This()); + const colorspace_impl = DefineColorspace(@This(), ChannelTypeMap); + pub const components = colorspace_impl.components; + pub const channels = colorspace_impl.channels; + pub const types = colorspace_impl.types; + pub const resolveMissing = colorspace_impl.resolveMissing; + pub const resolve = colorspace_impl.resolve; + const conversions_impl = ColorspaceConversions(@This()); + pub const fromLABColor = conversions_impl.fromLABColor; + pub const fromPredefinedColor = conversions_impl.fromPredefinedColor; + pub const fromFloatColor = conversions_impl.fromFloatColor; + pub const tryFromCssColor = conversions_impl.tryFromCssColor; + pub const hash = conversions_impl.hash; + const gamut_impl = UnboundedColorGamut(@This()); + pub const clip = gamut_impl.clip; + pub const inGamut = gamut_impl.inGamut; - pub usingnamespace DeriveInterpolate(@This(), "x", "y", "z"); - pub usingnamespace RecangularPremultiply(@This(), "x", "y", "z"); + const interpolate_impl = DeriveInterpolate(@This(), "x", "y", "z"); + pub const fillMissingComponents = interpolate_impl.fillMissingComponents; + pub const interpolate = interpolate_impl.interpolate; + const recangular_impl = RecangularPremultiply(@This(), "x", "y", "z"); + pub const premultiply = recangular_impl.premultiply; + pub const unpremultiply = recangular_impl.unpremultiply; - pub usingnamespace color_conversions.convert_XYZd65; + /// Convert this color into another color format. + pub const into = ColorIntoMixin(@This(), .XYZd65).into; + pub const intoCssColor = ImplementIntoCssColor(@This(), .XYZd65); pub const ChannelTypeMap = .{ .x = ChannelType{ .percentage = true }, @@ -1956,15 +2146,35 @@ pub const LCH = struct { /// The alpha component. alpha: f32, - pub usingnamespace DefineColorspace(@This(), ChannelTypeMap); - pub usingnamespace ColorspaceConversions(@This()); - pub usingnamespace UnboundedColorGamut(@This()); + const colorspace_impl = DefineColorspace(@This(), ChannelTypeMap); + pub const components = colorspace_impl.components; + pub const channels = colorspace_impl.channels; + pub const types = colorspace_impl.types; + pub const resolveMissing = colorspace_impl.resolveMissing; + pub const resolve = colorspace_impl.resolve; + const conversions_impl = ColorspaceConversions(@This()); + pub const fromLABColor = conversions_impl.fromLABColor; + pub const fromPredefinedColor = conversions_impl.fromPredefinedColor; + pub const fromFloatColor = conversions_impl.fromFloatColor; + pub const tryFromCssColor = conversions_impl.tryFromCssColor; + pub const hash = conversions_impl.hash; + const gamut_impl = UnboundedColorGamut(@This()); + pub const clip = gamut_impl.clip; + pub const inGamut = gamut_impl.inGamut; - pub usingnamespace AdjustPowerlessLCH(@This()); - pub usingnamespace DeriveInterpolate(@This(), "l", "c", "h"); - pub usingnamespace RecangularPremultiply(@This(), "l", "c", "h"); + const powerless_lch_impl = AdjustPowerlessLCH(@This()); + pub const adjustPowerlessComponents = powerless_lch_impl.adjustPowerlessComponents; + pub const adjustHue = powerless_lch_impl.adjustHue; + const interpolate_impl = DeriveInterpolate(@This(), "l", "c", "h"); + pub const fillMissingComponents = interpolate_impl.fillMissingComponents; + pub const interpolate = interpolate_impl.interpolate; + const recangular_impl = RecangularPremultiply(@This(), "l", "c", "h"); + pub const premultiply = recangular_impl.premultiply; + pub const unpremultiply = recangular_impl.unpremultiply; - pub usingnamespace color_conversions.convert_LCH; + /// Convert this color into another color format. + pub const into = ColorIntoMixin(@This(), .LCH).into; + pub const intoCssColor = ImplementIntoCssColor(@This(), .LCH); pub const ChannelTypeMap = .{ .l = ChannelType{ .percentage = true }, @@ -1984,15 +2194,33 @@ pub const OKLAB = struct { /// The alpha component. alpha: f32, - pub usingnamespace DefineColorspace(@This(), ChannelTypeMap); - pub usingnamespace ColorspaceConversions(@This()); - pub usingnamespace UnboundedColorGamut(@This()); + const colorspace_impl = DefineColorspace(@This(), ChannelTypeMap); + pub const components = colorspace_impl.components; + pub const channels = colorspace_impl.channels; + pub const types = colorspace_impl.types; + pub const resolveMissing = colorspace_impl.resolveMissing; + pub const resolve = colorspace_impl.resolve; + const conversions_impl = ColorspaceConversions(@This()); + pub const fromLABColor = conversions_impl.fromLABColor; + pub const fromPredefinedColor = conversions_impl.fromPredefinedColor; + pub const fromFloatColor = conversions_impl.fromFloatColor; + pub const tryFromCssColor = conversions_impl.tryFromCssColor; + pub const hash = conversions_impl.hash; + const gamut_impl = UnboundedColorGamut(@This()); + pub const clip = gamut_impl.clip; + pub const inGamut = gamut_impl.inGamut; - pub usingnamespace AdjustPowerlessLAB(@This()); - pub usingnamespace DeriveInterpolate(@This(), "l", "a", "b"); - pub usingnamespace RecangularPremultiply(@This(), "l", "a", "b"); + pub const adjustPowerlessComponents = AdjustPowerlessLAB(@This()).adjustPowerlessComponents; + const interpolate_impl = DeriveInterpolate(@This(), "l", "a", "b"); + pub const fillMissingComponents = interpolate_impl.fillMissingComponents; + pub const interpolate = interpolate_impl.interpolate; + const recangular_impl = RecangularPremultiply(@This(), "l", "a", "b"); + pub const premultiply = recangular_impl.premultiply; + pub const unpremultiply = recangular_impl.unpremultiply; - pub usingnamespace color_conversions.convert_OKLAB; + /// Convert this color into another color format. + pub const into = ColorIntoMixin(@This(), .OKLAB).into; + pub const intoCssColor = ImplementIntoCssColor(@This(), .OKLAB); pub const ChannelTypeMap = .{ .l = ChannelType{ .percentage = true }, @@ -2014,15 +2242,36 @@ pub const OKLCH = struct { /// The alpha component. alpha: f32, - pub usingnamespace DefineColorspace(@This(), ChannelTypeMap); - pub usingnamespace ColorspaceConversions(@This()); - pub usingnamespace UnboundedColorGamut(@This()); + const colorspace_impl = DefineColorspace(@This(), ChannelTypeMap); + pub const components = colorspace_impl.components; + pub const channels = colorspace_impl.channels; + pub const types = colorspace_impl.types; + pub const resolveMissing = colorspace_impl.resolveMissing; + pub const resolve = colorspace_impl.resolve; + const conversions_impl = ColorspaceConversions(@This()); + pub const fromLABColor = conversions_impl.fromLABColor; + pub const fromPredefinedColor = conversions_impl.fromPredefinedColor; + pub const fromFloatColor = conversions_impl.fromFloatColor; + pub const tryFromCssColor = conversions_impl.tryFromCssColor; + pub const hash = conversions_impl.hash; + const gamut_impl = UnboundedColorGamut(@This()); + pub const clip = gamut_impl.clip; + pub const inGamut = gamut_impl.inGamut; - pub usingnamespace AdjustPowerlessLCH(@This()); - pub usingnamespace DeriveInterpolate(@This(), "l", "c", "h"); - pub usingnamespace RecangularPremultiply(@This(), "l", "c", "h"); + const powerless_lch_impl = AdjustPowerlessLCH(@This()); + pub const adjustPowerlessComponents = powerless_lch_impl.adjustPowerlessComponents; + pub const adjustHue = powerless_lch_impl.adjustHue; + const interpolate_impl = DeriveInterpolate(@This(), "l", "c", "h"); + pub const fillMissingComponents = interpolate_impl.fillMissingComponents; + pub const interpolate = interpolate_impl.interpolate; - pub usingnamespace color_conversions.convert_OKLCH; + const recangular_impl = RecangularPremultiply(@This(), "l", "c", "h"); + pub const premultiply = recangular_impl.premultiply; + pub const unpremultiply = recangular_impl.unpremultiply; + + /// Convert this color into another color format. + pub const into = ColorIntoMixin(@This(), .OKLCH).into; + pub const intoCssColor = ImplementIntoCssColor(@This(), .OKLCH); pub const ChannelTypeMap = .{ .l = ChannelType{ .percentage = true }, @@ -2455,19 +2704,25 @@ const RelativeComponentParser = struct { ident: []const u8, allowed_types: ChannelType, ) ?f32 { - if (bun.strings.eqlCaseInsensitiveASCIIICheckLength(ident, this.names[0]) and allowed_types.intersects(this.types[0])) { + if (bun.strings.eqlCaseInsensitiveASCIIICheckLength(ident, this.names[0]) and + bits.intersects(ChannelType, allowed_types, this.types[0])) + { return this.components[0]; } - if (bun.strings.eqlCaseInsensitiveASCIIICheckLength(ident, this.names[1]) and allowed_types.intersects(this.types[1])) { + if (bun.strings.eqlCaseInsensitiveASCIIICheckLength(ident, this.names[1]) and + bits.intersects(ChannelType, allowed_types, this.types[1])) + { return this.components[1]; } - if (bun.strings.eqlCaseInsensitiveASCIIICheckLength(ident, this.names[2]) and allowed_types.intersects(this.types[2])) { + if (bun.strings.eqlCaseInsensitiveASCIIICheckLength(ident, this.names[2]) and + bits.intersects(ChannelType, allowed_types, this.types[2])) + { return this.components[2]; } - if (bun.strings.eqlCaseInsensitiveASCIIICheckLength(ident, "alpha") and allowed_types.intersects(ChannelType{ .percentage = true })) { + if (bun.strings.eqlCaseInsensitiveASCIIICheckLength(ident, "alpha") and allowed_types.percentage) { return this.components[3]; } @@ -2485,8 +2740,6 @@ pub const ChannelType = packed struct(u8) { /// Channel represents a number. number: bool = false, __unused: u5 = 0, - - pub usingnamespace css.Bitflags(@This()); }; pub fn parsePredefined(input: *css.Parser, parser: *ComponentParser) Result(CssColor) { @@ -2707,24 +2960,30 @@ pub const ColorFallbackKind = packed struct(u8) { pub const LAB = ColorFallbackKind{ .lab = true }; pub const OKLAB = ColorFallbackKind{ .oklab = true }; - pub usingnamespace css.Bitflags(@This()); - pub fn lowest(this: @This()) ColorFallbackKind { - return this.bitwiseAnd(ColorFallbackKind.fromBitsTruncate(bun.wrappingNegation(this.asBits()))); + return bun.bits.@"and"( + ColorFallbackKind, + this, + fromBitsTruncate(bun.wrappingNegation(@as(u8, @bitCast(this)))), + ); } pub fn highest(this: @This()) ColorFallbackKind { // This finds the highest set bit. - if (this.isEmpty()) return ColorFallbackKind.empty(); + if (this.isEmpty()) return ColorFallbackKind{}; - const zeroes: u3 = @intCast(@as(u4, 7) - this.leadingZeroes()); - return ColorFallbackKind.fromBitsTruncate(@as(u8, 1) << zeroes); + const zeroes: u3 = @intCast(@as(u4, 7) - bun.bits.leadingZeros(ColorFallbackKind, this)); + return fromBitsTruncate(@as(u8, 1) << zeroes); + } + + pub fn difference(left: @This(), right: @This()) ColorFallbackKind { + return @bitCast(@as(u8, @bitCast(left)) - @as(u8, @bitCast(right))); } pub fn andBelow(this: @This()) ColorFallbackKind { - if (this.isEmpty()) return ColorFallbackKind.empty(); + if (this.isEmpty()) return .{}; - return this.bitwiseOr(ColorFallbackKind.fromBitsTruncate(this.asBits() - 1)); + return bun.bits.@"or"(ColorFallbackKind, this, fromBitsTruncate(@as(u8, @bitCast(this)) - 1)); } pub fn supportsCondition(this: @This()) css.SupportsCondition { @@ -2741,6 +3000,20 @@ pub const ColorFallbackKind = packed struct(u8) { }, }; } + + pub fn isEmpty(cfk: ColorFallbackKind) bool { + return @as(u8, @bitCast(cfk)) == 0; + } + + pub inline fn fromBitsTruncate(b: u8) ColorFallbackKind { + var cfk: ColorFallbackKind = @bitCast(b); + cfk.__unused = 0; + return cfk; + } + + pub fn asBits(this: @This()) u8 { + return @bitCast(this); + } }; /// A [color space](https://www.w3.org/TR/css-color-4/#interpolation-space) keyword @@ -2937,91 +3210,30 @@ fn rectangularToPolar(l: f32, a: f32, b: f32) struct { f32, f32, f32 } { } pub fn ColorspaceConversions(comptime T: type) type { - // e.g. T = LAB, so then: into_this_function_name = "intoLAB" - const into_this_function_name = "into" ++ comptime bun.meta.typeName(T); - return struct { + const convert_type: ConvertTo = .fromType(T); + pub fn fromLABColor(color: *const LABColor) T { return switch (color.*) { - .lab => |*v| { - if (comptime @TypeOf(v.*) == T) return v.*; - return @call(.auto, @field(@TypeOf(v.*), into_this_function_name), .{v}); - }, - .lch => |*v| { - if (comptime @TypeOf(v.*) == T) return v.*; - return @call(.auto, @field(@TypeOf(v.*), into_this_function_name), .{v}); - }, - .oklab => |*v| { - if (comptime @TypeOf(v.*) == T) return v.*; - return @call(.auto, @field(@TypeOf(v.*), into_this_function_name), .{v}); - }, - .oklch => |*v| { - if (comptime @TypeOf(v.*) == T) return v.*; - return @call(.auto, @field(@TypeOf(v.*), into_this_function_name), .{v}); - }, + inline else => |*v| v.into(convert_type), }; } pub fn fromPredefinedColor(color: *const PredefinedColor) T { return switch (color.*) { - .srgb => |*v| { - if (comptime @TypeOf(v.*) == T) return v.*; - return @call(.auto, @field(@TypeOf(v.*), into_this_function_name), .{v}); - }, - .srgb_linear => |*v| { - if (comptime @TypeOf(v.*) == T) return v.*; - return @call(.auto, @field(@TypeOf(v.*), into_this_function_name), .{v}); - }, - .display_p3 => |*v| { - if (comptime @TypeOf(v.*) == T) return v.*; - return @call(.auto, @field(@TypeOf(v.*), into_this_function_name), .{v}); - }, - .a98 => |*v| { - if (comptime @TypeOf(v.*) == T) return v.*; - return @call(.auto, @field(@TypeOf(v.*), into_this_function_name), .{v}); - }, - .prophoto => |*v| { - if (comptime @TypeOf(v.*) == T) return v.*; - return @call(.auto, @field(@TypeOf(v.*), into_this_function_name), .{v}); - }, - .rec2020 => |*v| { - if (comptime @TypeOf(v.*) == T) return v.*; - return @call(.auto, @field(@TypeOf(v.*), into_this_function_name), .{v}); - }, - .xyz_d50 => |*v| { - if (comptime @TypeOf(v.*) == T) return v.*; - return @call(.auto, @field(@TypeOf(v.*), into_this_function_name), .{v}); - }, - .xyz_d65 => |*v| { - if (comptime @TypeOf(v.*) == T) return v.*; - return @call(.auto, @field(@TypeOf(v.*), into_this_function_name), .{v}); - }, + inline else => |*v| v.into(convert_type), }; } pub fn fromFloatColor(color: *const FloatColor) T { return switch (color.*) { - .rgb => |*v| { - if (comptime T == SRGB) return v.*; - return @call(.auto, @field(@TypeOf(v.*), into_this_function_name), .{v}); - }, - .hsl => |*v| { - if (comptime T == HSL) return v.*; - return @call(.auto, @field(@TypeOf(v.*), into_this_function_name), .{v}); - }, - .hwb => |*v| { - if (comptime T == HWB) return v.*; - return @call(.auto, @field(@TypeOf(v.*), into_this_function_name), .{v}); - }, + inline else => |*v| v.into(convert_type), }; } pub fn tryFromCssColor(color: *const CssColor) ?T { return switch (color.*) { - .rgba => |*rgba| { - if (comptime T == RGBA) return rgba.*; - return @call(.auto, @field(@TypeOf(rgba.*), into_this_function_name), .{rgba}); - }, + .rgba => |*rgba| rgba.into(convert_type), .lab => |lab| fromLABColor(lab), .predefined => |predefined| fromPredefinedColor(predefined), .float => |float| fromFloatColor(float), @@ -3038,7 +3250,7 @@ pub fn ColorspaceConversions(comptime T: type) type { } pub fn DefineColorspace(comptime T: type, comptime ChannelTypeMap: anytype) type { - const fields: []const std.builtin.Type.StructField = std.meta.fields(T); + const fields: []const std.builtin.Type.StructField = @typeInfo(T).@"struct".fields; const a = fields[0].name; const b = fields[1].name; const c = fields[2].name; @@ -3471,16 +3683,11 @@ pub fn polarToRectangular(l: f32, c: f32, h: f32) struct { f32, f32, f32 } { const D50: []const f32 = &.{ @floatCast(@as(f64, 0.3457) / @as(f64, 0.3585)), 1.00000, @floatCast((@as(f64, 1.0) - @as(f64, 0.3457) - @as(f64, 0.3585)) / @as(f64, 0.3585)) }; // const D50: []const f32 = &.{ 0.9642956, 1.0, 0.82510453 }; +const generated_color_conversions = @import("./color_generated.zig").generated_color_conversions; const color_conversions = struct { - const generated = @import("./color_generated.zig").generated_color_conversions; - - pub const convert_RGBA = struct { - pub usingnamespace generated.convert_RGBA; - }; + pub const convert_RGBA = struct {}; pub const convert_LAB = struct { - pub usingnamespace generated.convert_LAB; - pub fn intoCssColor(c: *const LAB, allocator: Allocator) CssColor { return CssColor{ .lab = bun.create( allocator, @@ -3543,12 +3750,10 @@ const color_conversions = struct { }; pub const convert_SRGB = struct { - pub usingnamespace generated.convert_SRGB; - pub fn intoCssColor(srgb: *const SRGB, _: Allocator) CssColor { // TODO: should we serialize as color(srgb, ...)? // would be more precise than 8-bit color. - return CssColor{ .rgba = srgb.intoRGBA() }; + return CssColor{ .rgba = srgb.into(.RGBA) }; } pub fn intoSRGBLinear(rgb: *const SRGB) SRGBLinear { @@ -3605,7 +3810,7 @@ const color_conversions = struct { pub fn intoHWB(_rgb: *const SRGB) HWB { const rgb = _rgb.resolve(); - const hsl = rgb.intoHSL(); + const hsl = rgb.into(.HSL); const r = rgb.r; const g = rgb.g; const _b = rgb.b; @@ -3621,12 +3826,10 @@ const color_conversions = struct { }; pub const convert_HSL = struct { - pub usingnamespace generated.convert_HSL; - pub fn intoCssColor(c: *const HSL, _: Allocator) CssColor { // TODO: should we serialize as color(srgb, ...)? // would be more precise than 8-bit color. - return CssColor{ .rgba = c.intoRGBA() }; + return CssColor{ .rgba = c.into(.RGBA) }; } pub fn intoSRGB(hsl_: *const HSL) SRGB { @@ -3644,12 +3847,10 @@ const color_conversions = struct { }; pub const convert_HWB = struct { - pub usingnamespace generated.convert_HWB; - pub fn intoCssColor(c: *const HWB, _: Allocator) CssColor { // TODO: should we serialize as color(srgb, ...)? // would be more precise than 8-bit color. - return CssColor{ .rgba = c.intoRGBA() }; + return CssColor{ .rgba = c.into(.RGBA) }; } pub fn intoSRGB(_hwb: *const HWB) SRGB { @@ -3669,7 +3870,7 @@ const color_conversions = struct { }; } - var rgba = (HSL{ .h = h, .s = 1.0, .l = 0.5, .alpha = hwb.alpha }).intoSRGB(); + var rgba = (HSL{ .h = h, .s = 1.0, .l = 0.5, .alpha = hwb.alpha }).into(.SRGB); const x = 1.0 - w - b; rgba.r = rgba.r * x + w; rgba.g = rgba.g * x + w; @@ -3679,8 +3880,6 @@ const color_conversions = struct { }; pub const convert_SRGBLinear = struct { - pub usingnamespace generated.convert_SRGBLinear; - pub fn intoPredefinedColor(rgb: *const SRGBLinear) PredefinedColor { return PredefinedColor{ .srgb_linear = rgb.* }; } @@ -3690,7 +3889,7 @@ const color_conversions = struct { .predefined = bun.create( allocator, PredefinedColor, - rgb.intoPredefinedColor(), + rgb.into(.PredefinedColor), ), }; } @@ -3734,8 +3933,6 @@ const color_conversions = struct { }; pub const convert_P3 = struct { - pub usingnamespace generated.convert_P3; - pub fn intoPredefinedColor(rgb: *const P3) PredefinedColor { return PredefinedColor{ .display_p3 = rgb.* }; } @@ -3745,7 +3942,7 @@ const color_conversions = struct { .predefined = bun.create( allocator, PredefinedColor, - rgb.intoPredefinedColor(), + rgb.into(.PredefinedColor), ), }; } @@ -3780,8 +3977,6 @@ const color_conversions = struct { }; pub const convert_A98 = struct { - pub usingnamespace generated.convert_A98; - pub fn intoPredefinedColor(rgb: *const A98) PredefinedColor { return PredefinedColor{ .a98 = rgb.* }; } @@ -3791,7 +3986,7 @@ const color_conversions = struct { .predefined = bun.create( allocator, PredefinedColor, - rgb.intoPredefinedColor(), + rgb.into(.PredefinedColor), ), }; } @@ -3843,8 +4038,6 @@ const color_conversions = struct { }; pub const convert_ProPhoto = struct { - pub usingnamespace generated.convert_ProPhoto; - pub fn intoPredefinedColor(rgb: *const ProPhoto) PredefinedColor { return PredefinedColor{ .prophoto = rgb.* }; } @@ -3854,7 +4047,7 @@ const color_conversions = struct { .predefined = bun.create( allocator, PredefinedColor, - rgb.intoPredefinedColor(), + rgb.into(.PredefinedColor), ), }; } @@ -3911,8 +4104,6 @@ const color_conversions = struct { }; pub const convert_Rec2020 = struct { - pub usingnamespace generated.convert_Rec2020; - pub fn intoPredefinedColor(rgb: *const Rec2020) PredefinedColor { return PredefinedColor{ .rec2020 = rgb.* }; } @@ -3922,7 +4113,7 @@ const color_conversions = struct { .predefined = bun.create( allocator, PredefinedColor, - rgb.intoPredefinedColor(), + rgb.into(.PredefinedColor), ), }; } @@ -3984,8 +4175,6 @@ const color_conversions = struct { }; pub const convert_XYZd50 = struct { - pub usingnamespace generated.convert_XYZd50; - pub fn intoPredefinedColor(rgb: *const XYZd50) PredefinedColor { return PredefinedColor{ .xyz_d50 = rgb.* }; } @@ -3995,7 +4184,7 @@ const color_conversions = struct { .predefined = bun.create( allocator, PredefinedColor, - rgb.intoPredefinedColor(), + rgb.into(.PredefinedColor), ), }; } @@ -4101,8 +4290,6 @@ const color_conversions = struct { }; pub const convert_XYZd65 = struct { - pub usingnamespace generated.convert_XYZd65; - pub fn intoPredefinedColor(rgb: *const XYZd65) PredefinedColor { return PredefinedColor{ .xyz_d65 = rgb.* }; } @@ -4112,7 +4299,7 @@ const color_conversions = struct { .predefined = bun.create( allocator, PredefinedColor, - rgb.intoPredefinedColor(), + rgb.into(.PredefinedColor), ), }; } @@ -4319,8 +4506,6 @@ const color_conversions = struct { }; pub const convert_LCH = struct { - pub usingnamespace generated.convert_LCH; - pub fn intoCssColor(c: *const LCH, allocator: Allocator) CssColor { return CssColor{ .lab = bun.create( allocator, @@ -4342,8 +4527,6 @@ const color_conversions = struct { }; pub const convert_OKLAB = struct { - pub usingnamespace generated.convert_OKLAB; - pub fn intoCssColor(c: *const OKLAB, allocator: Allocator) CssColor { return CssColor{ .lab = bun.create( allocator, @@ -4412,8 +4595,6 @@ const color_conversions = struct { }; pub const convert_OKLCH = struct { - pub usingnamespace generated.convert_OKLCH; - pub fn intoCssColor(c: *const OKLCH, allocator: Allocator) CssColor { return CssColor{ .lab = bun.create( allocator, @@ -4438,3 +4619,93 @@ const color_conversions = struct { } }; }; + +pub const ConvertTo = enum { + RGBA, + LAB, + SRGB, + HSL, + HWB, + SRGBLinear, + P3, + A98, + ProPhoto, + Rec2020, + XYZd50, + XYZd65, + LCH, + OKLAB, + OKLCH, + PredefinedColor, + pub fn fromType(comptime T: type) ConvertTo { + return @field(ConvertTo, bun.meta.typeName(T)); + } + pub fn Type(comptime space: ConvertTo) type { + return switch (space) { + .RGBA => RGBA, + .LAB => LAB, + .SRGB => SRGB, + .HSL => HSL, + .HWB => HWB, + .SRGBLinear => SRGBLinear, + .P3 => P3, + .A98 => A98, + .ProPhoto => ProPhoto, + .Rec2020 => Rec2020, + .XYZd50 => XYZd50, + .XYZd65 => XYZd65, + .LCH => LCH, + .OKLAB => OKLAB, + .OKLCH => OKLCH, + .PredefinedColor => PredefinedColor, + }; + } +}; +pub fn ColorIntoMixin(T: type, space: ConvertTo) type { + return struct { + pub const into_names = struct { + const RGBA = "intoRGBA"; + const LAB = "intoLAB"; + const SRGB = "intoSRGB"; + const HSL = "intoHSL"; + const HWB = "intoHWB"; + const SRGBLinear = "intoSRGBLinear"; + const P3 = "intoP3"; + const A98 = "intoA98"; + const ProPhoto = "intoProPhoto"; + const Rec2020 = "intoRec2020"; + const XYZd50 = "intoXYZd50"; + const XYZd65 = "intoXYZd65"; + const LCH = "intoLCH"; + const OKLAB = "intoOKLAB"; + const OKLCH = "intoOKLCH"; + const PredefinedColor = "intoPredefinedColor"; + }; + const ns = "convert_" ++ @tagName(space); + + const handwritten_conversions = @field(color_conversions, ns); + const generated_conversions = @field(generated_color_conversions, ns); + + pub fn into(color: *const T, comptime target_space: ConvertTo) target_space.Type() { + if (target_space == space) return color.*; + + const name = @field(into_names, @tagName(target_space)); + + const function = if (@hasDecl(handwritten_conversions, name)) + @field(handwritten_conversions, name) + else if (@hasDecl(generated_conversions, name)) + @field(generated_conversions, name) + else if (@hasDecl(T, name)) + @field(T, name) + else + @compileError("No conversion from " ++ @tagName(space) ++ " to " ++ @tagName(target_space)); + + return function(color); + } + }; +} + +pub fn ImplementIntoCssColor(comptime T: type, space: ConvertTo) fn (*const T, Allocator) CssColor { + const ns = "convert_" ++ @tagName(space); + return @field(color_conversions, ns).intoCssColor; +} diff --git a/src/css/values/color_generated.zig b/src/css/values/color_generated.zig index a767990f1f..596d0fb586 100644 --- a/src/css/values/color_generated.zig +++ b/src/css/values/color_generated.zig @@ -19,927 +19,927 @@ const Rec2020 = color.Rec2020; pub const generated_color_conversions = struct { pub const convert_RGBA = struct { pub fn intoLAB(this: *const RGBA) LAB { - const xyz: SRGB = this.intoSRGB(); - return xyz.intoLAB(); + const xyz: SRGB = this.into(.SRGB); + return xyz.into(.LAB); } pub fn intoLCH(this: *const RGBA) LCH { - const xyz: SRGB = this.intoSRGB(); - return xyz.intoLCH(); + const xyz: SRGB = this.into(.SRGB); + return xyz.into(.LCH); } pub fn intoOKLAB(this: *const RGBA) OKLAB { - const xyz: SRGB = this.intoSRGB(); - return xyz.intoOKLAB(); + const xyz: SRGB = this.into(.SRGB); + return xyz.into(.OKLAB); } pub fn intoOKLCH(this: *const RGBA) OKLCH { - const xyz: SRGB = this.intoSRGB(); - return xyz.intoOKLCH(); + const xyz: SRGB = this.into(.SRGB); + return xyz.into(.OKLCH); } pub fn intoP3(this: *const RGBA) P3 { - const xyz: SRGB = this.intoSRGB(); - return xyz.intoP3(); + const xyz: SRGB = this.into(.SRGB); + return xyz.into(.P3); } pub fn intoSRGBLinear(this: *const RGBA) SRGBLinear { - const xyz: SRGB = this.intoSRGB(); - return xyz.intoSRGBLinear(); + const xyz: SRGB = this.into(.SRGB); + return xyz.into(.SRGBLinear); } pub fn intoA98(this: *const RGBA) A98 { - const xyz: SRGB = this.intoSRGB(); - return xyz.intoA98(); + const xyz: SRGB = this.into(.SRGB); + return xyz.into(.A98); } pub fn intoProPhoto(this: *const RGBA) ProPhoto { - const xyz: SRGB = this.intoSRGB(); - return xyz.intoProPhoto(); + const xyz: SRGB = this.into(.SRGB); + return xyz.into(.ProPhoto); } pub fn intoXYZd50(this: *const RGBA) XYZd50 { - const xyz: SRGB = this.intoSRGB(); - return xyz.intoXYZd50(); + const xyz: SRGB = this.into(.SRGB); + return xyz.into(.XYZd50); } pub fn intoXYZd65(this: *const RGBA) XYZd65 { - const xyz: SRGB = this.intoSRGB(); - return xyz.intoXYZd65(); + const xyz: SRGB = this.into(.SRGB); + return xyz.into(.XYZd65); } pub fn intoRec2020(this: *const RGBA) Rec2020 { - const xyz: SRGB = this.intoSRGB(); - return xyz.intoRec2020(); + const xyz: SRGB = this.into(.SRGB); + return xyz.into(.Rec2020); } pub fn intoHSL(this: *const RGBA) HSL { - const xyz: SRGB = this.intoSRGB(); - return xyz.intoHSL(); + const xyz: SRGB = this.into(.SRGB); + return xyz.into(.HSL); } pub fn intoHWB(this: *const RGBA) HWB { - const xyz: SRGB = this.intoSRGB(); - return xyz.intoHWB(); + const xyz: SRGB = this.into(.SRGB); + return xyz.into(.HWB); } }; pub const convert_LAB = struct { pub fn intoXYZd65(this: *const LAB) XYZd65 { - const xyz: XYZd50 = this.intoXYZd50(); - return xyz.intoXYZd65(); + const xyz: XYZd50 = this.into(.XYZd50); + return xyz.into(.XYZd65); } pub fn intoOKLAB(this: *const LAB) OKLAB { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoOKLAB(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.OKLAB); } pub fn intoOKLCH(this: *const LAB) OKLCH { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoOKLCH(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.OKLCH); } pub fn intoSRGB(this: *const LAB) SRGB { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoSRGB(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.SRGB); } pub fn intoSRGBLinear(this: *const LAB) SRGBLinear { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoSRGBLinear(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.SRGBLinear); } pub fn intoP3(this: *const LAB) P3 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoP3(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.P3); } pub fn intoA98(this: *const LAB) A98 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoA98(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.A98); } pub fn intoProPhoto(this: *const LAB) ProPhoto { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoProPhoto(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.ProPhoto); } pub fn intoRec2020(this: *const LAB) Rec2020 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoRec2020(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.Rec2020); } pub fn intoHSL(this: *const LAB) HSL { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoHSL(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.HSL); } pub fn intoHWB(this: *const LAB) HWB { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoHWB(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.HWB); } pub fn intoRGBA(this: *const LAB) RGBA { - const xyz: SRGB = this.intoSRGB(); - return xyz.intoRGBA(); + const xyz: SRGB = this.into(.SRGB); + return xyz.into(.RGBA); } }; pub const convert_SRGB = struct { pub fn intoLAB(this: *const SRGB) LAB { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoLAB(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.LAB); } pub fn intoLCH(this: *const SRGB) LCH { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoLCH(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.LCH); } pub fn intoXYZd65(this: *const SRGB) XYZd65 { - const xyz: SRGBLinear = this.intoSRGBLinear(); - return xyz.intoXYZd65(); + const xyz: SRGBLinear = this.into(.SRGBLinear); + return xyz.into(.XYZd65); } pub fn intoOKLAB(this: *const SRGB) OKLAB { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoOKLAB(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.OKLAB); } pub fn intoOKLCH(this: *const SRGB) OKLCH { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoOKLCH(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.OKLCH); } pub fn intoP3(this: *const SRGB) P3 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoP3(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.P3); } pub fn intoA98(this: *const SRGB) A98 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoA98(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.A98); } pub fn intoProPhoto(this: *const SRGB) ProPhoto { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoProPhoto(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.ProPhoto); } pub fn intoRec2020(this: *const SRGB) Rec2020 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoRec2020(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.Rec2020); } pub fn intoXYZd50(this: *const SRGB) XYZd50 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoXYZd50(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.XYZd50); } }; pub const convert_HSL = struct { pub fn intoLAB(this: *const HSL) LAB { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoLAB(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.LAB); } pub fn intoLCH(this: *const HSL) LCH { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoLCH(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.LCH); } pub fn intoP3(this: *const HSL) P3 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoP3(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.P3); } pub fn intoSRGBLinear(this: *const HSL) SRGBLinear { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoSRGBLinear(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.SRGBLinear); } pub fn intoA98(this: *const HSL) A98 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoA98(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.A98); } pub fn intoProPhoto(this: *const HSL) ProPhoto { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoProPhoto(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.ProPhoto); } pub fn intoXYZd50(this: *const HSL) XYZd50 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoXYZd50(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.XYZd50); } pub fn intoRec2020(this: *const HSL) Rec2020 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoRec2020(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.Rec2020); } pub fn intoOKLAB(this: *const HSL) OKLAB { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoOKLAB(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.OKLAB); } pub fn intoOKLCH(this: *const HSL) OKLCH { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoOKLCH(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.OKLCH); } pub fn intoXYZd65(this: *const HSL) XYZd65 { - const xyz: SRGB = this.intoSRGB(); - return xyz.intoXYZd65(); + const xyz: SRGB = this.into(.SRGB); + return xyz.into(.XYZd65); } pub fn intoHWB(this: *const HSL) HWB { - const xyz: SRGB = this.intoSRGB(); - return xyz.intoHWB(); + const xyz: SRGB = this.into(.SRGB); + return xyz.into(.HWB); } pub fn intoRGBA(this: *const HSL) RGBA { - const xyz: SRGB = this.intoSRGB(); - return xyz.intoRGBA(); + const xyz: SRGB = this.into(.SRGB); + return xyz.into(.RGBA); } }; pub const convert_HWB = struct { pub fn intoLAB(this: *const HWB) LAB { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoLAB(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.LAB); } pub fn intoLCH(this: *const HWB) LCH { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoLCH(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.LCH); } pub fn intoP3(this: *const HWB) P3 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoP3(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.P3); } pub fn intoSRGBLinear(this: *const HWB) SRGBLinear { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoSRGBLinear(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.SRGBLinear); } pub fn intoA98(this: *const HWB) A98 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoA98(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.A98); } pub fn intoProPhoto(this: *const HWB) ProPhoto { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoProPhoto(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.ProPhoto); } pub fn intoXYZd50(this: *const HWB) XYZd50 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoXYZd50(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.XYZd50); } pub fn intoRec2020(this: *const HWB) Rec2020 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoRec2020(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.Rec2020); } pub fn intoHSL(this: *const HWB) HSL { - const xyz: SRGB = this.intoSRGB(); - return xyz.intoHSL(); + const xyz: SRGB = this.into(.SRGB); + return xyz.into(.HSL); } pub fn intoXYZd65(this: *const HWB) XYZd65 { - const xyz: SRGB = this.intoSRGB(); - return xyz.intoXYZd65(); + const xyz: SRGB = this.into(.SRGB); + return xyz.into(.XYZd65); } pub fn intoOKLAB(this: *const HWB) OKLAB { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoOKLAB(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.OKLAB); } pub fn intoOKLCH(this: *const HWB) OKLCH { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoOKLCH(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.OKLCH); } pub fn intoRGBA(this: *const HWB) RGBA { - const xyz: SRGB = this.intoSRGB(); - return xyz.intoRGBA(); + const xyz: SRGB = this.into(.SRGB); + return xyz.into(.RGBA); } }; pub const convert_SRGBLinear = struct { pub fn intoLAB(this: *const SRGBLinear) LAB { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoLAB(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.LAB); } pub fn intoLCH(this: *const SRGBLinear) LCH { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoLCH(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.LCH); } pub fn intoP3(this: *const SRGBLinear) P3 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoP3(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.P3); } pub fn intoOKLAB(this: *const SRGBLinear) OKLAB { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoOKLAB(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.OKLAB); } pub fn intoOKLCH(this: *const SRGBLinear) OKLCH { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoOKLCH(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.OKLCH); } pub fn intoA98(this: *const SRGBLinear) A98 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoA98(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.A98); } pub fn intoProPhoto(this: *const SRGBLinear) ProPhoto { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoProPhoto(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.ProPhoto); } pub fn intoRec2020(this: *const SRGBLinear) Rec2020 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoRec2020(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.Rec2020); } pub fn intoXYZd50(this: *const SRGBLinear) XYZd50 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoXYZd50(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.XYZd50); } pub fn intoHSL(this: *const SRGBLinear) HSL { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoHSL(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.HSL); } pub fn intoHWB(this: *const SRGBLinear) HWB { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoHWB(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.HWB); } pub fn intoRGBA(this: *const SRGBLinear) RGBA { - const xyz: SRGB = this.intoSRGB(); - return xyz.intoRGBA(); + const xyz: SRGB = this.into(.SRGB); + return xyz.into(.RGBA); } }; pub const convert_P3 = struct { pub fn intoLAB(this: *const P3) LAB { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoLAB(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.LAB); } pub fn intoLCH(this: *const P3) LCH { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoLCH(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.LCH); } pub fn intoSRGB(this: *const P3) SRGB { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoSRGB(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.SRGB); } pub fn intoSRGBLinear(this: *const P3) SRGBLinear { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoSRGBLinear(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.SRGBLinear); } pub fn intoOKLAB(this: *const P3) OKLAB { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoOKLAB(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.OKLAB); } pub fn intoOKLCH(this: *const P3) OKLCH { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoOKLCH(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.OKLCH); } pub fn intoA98(this: *const P3) A98 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoA98(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.A98); } pub fn intoProPhoto(this: *const P3) ProPhoto { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoProPhoto(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.ProPhoto); } pub fn intoRec2020(this: *const P3) Rec2020 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoRec2020(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.Rec2020); } pub fn intoXYZd50(this: *const P3) XYZd50 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoXYZd50(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.XYZd50); } pub fn intoHSL(this: *const P3) HSL { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoHSL(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.HSL); } pub fn intoHWB(this: *const P3) HWB { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoHWB(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.HWB); } pub fn intoRGBA(this: *const P3) RGBA { - const xyz: SRGB = this.intoSRGB(); - return xyz.intoRGBA(); + const xyz: SRGB = this.into(.SRGB); + return xyz.into(.RGBA); } }; pub const convert_A98 = struct { pub fn intoLAB(this: *const A98) LAB { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoLAB(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.LAB); } pub fn intoLCH(this: *const A98) LCH { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoLCH(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.LCH); } pub fn intoSRGB(this: *const A98) SRGB { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoSRGB(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.SRGB); } pub fn intoP3(this: *const A98) P3 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoP3(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.P3); } pub fn intoSRGBLinear(this: *const A98) SRGBLinear { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoSRGBLinear(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.SRGBLinear); } pub fn intoOKLAB(this: *const A98) OKLAB { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoOKLAB(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.OKLAB); } pub fn intoOKLCH(this: *const A98) OKLCH { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoOKLCH(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.OKLCH); } pub fn intoProPhoto(this: *const A98) ProPhoto { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoProPhoto(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.ProPhoto); } pub fn intoRec2020(this: *const A98) Rec2020 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoRec2020(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.Rec2020); } pub fn intoXYZd50(this: *const A98) XYZd50 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoXYZd50(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.XYZd50); } pub fn intoHSL(this: *const A98) HSL { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoHSL(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.HSL); } pub fn intoHWB(this: *const A98) HWB { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoHWB(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.HWB); } pub fn intoRGBA(this: *const A98) RGBA { - const xyz: SRGB = this.intoSRGB(); - return xyz.intoRGBA(); + const xyz: SRGB = this.into(.SRGB); + return xyz.into(.RGBA); } }; pub const convert_ProPhoto = struct { pub fn intoXYZd65(this: *const ProPhoto) XYZd65 { - const xyz: XYZd50 = this.intoXYZd50(); - return xyz.intoXYZd65(); + const xyz: XYZd50 = this.into(.XYZd50); + return xyz.into(.XYZd65); } pub fn intoLAB(this: *const ProPhoto) LAB { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoLAB(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.LAB); } pub fn intoLCH(this: *const ProPhoto) LCH { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoLCH(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.LCH); } pub fn intoSRGB(this: *const ProPhoto) SRGB { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoSRGB(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.SRGB); } pub fn intoP3(this: *const ProPhoto) P3 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoP3(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.P3); } pub fn intoSRGBLinear(this: *const ProPhoto) SRGBLinear { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoSRGBLinear(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.SRGBLinear); } pub fn intoA98(this: *const ProPhoto) A98 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoA98(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.A98); } pub fn intoOKLAB(this: *const ProPhoto) OKLAB { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoOKLAB(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.OKLAB); } pub fn intoOKLCH(this: *const ProPhoto) OKLCH { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoOKLCH(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.OKLCH); } pub fn intoRec2020(this: *const ProPhoto) Rec2020 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoRec2020(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.Rec2020); } pub fn intoHSL(this: *const ProPhoto) HSL { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoHSL(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.HSL); } pub fn intoHWB(this: *const ProPhoto) HWB { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoHWB(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.HWB); } pub fn intoRGBA(this: *const ProPhoto) RGBA { - const xyz: SRGB = this.intoSRGB(); - return xyz.intoRGBA(); + const xyz: SRGB = this.into(.SRGB); + return xyz.into(.RGBA); } }; pub const convert_Rec2020 = struct { pub fn intoLAB(this: *const Rec2020) LAB { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoLAB(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.LAB); } pub fn intoLCH(this: *const Rec2020) LCH { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoLCH(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.LCH); } pub fn intoSRGB(this: *const Rec2020) SRGB { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoSRGB(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.SRGB); } pub fn intoP3(this: *const Rec2020) P3 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoP3(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.P3); } pub fn intoSRGBLinear(this: *const Rec2020) SRGBLinear { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoSRGBLinear(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.SRGBLinear); } pub fn intoA98(this: *const Rec2020) A98 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoA98(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.A98); } pub fn intoProPhoto(this: *const Rec2020) ProPhoto { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoProPhoto(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.ProPhoto); } pub fn intoXYZd50(this: *const Rec2020) XYZd50 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoXYZd50(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.XYZd50); } pub fn intoOKLAB(this: *const Rec2020) OKLAB { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoOKLAB(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.OKLAB); } pub fn intoOKLCH(this: *const Rec2020) OKLCH { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoOKLCH(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.OKLCH); } pub fn intoHSL(this: *const Rec2020) HSL { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoHSL(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.HSL); } pub fn intoHWB(this: *const Rec2020) HWB { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoHWB(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.HWB); } pub fn intoRGBA(this: *const Rec2020) RGBA { - const xyz: SRGB = this.intoSRGB(); - return xyz.intoRGBA(); + const xyz: SRGB = this.into(.SRGB); + return xyz.into(.RGBA); } }; pub const convert_XYZd50 = struct { pub fn intoLCH(this: *const XYZd50) LCH { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoLCH(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.LCH); } pub fn intoSRGB(this: *const XYZd50) SRGB { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoSRGB(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.SRGB); } pub fn intoP3(this: *const XYZd50) P3 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoP3(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.P3); } pub fn intoSRGBLinear(this: *const XYZd50) SRGBLinear { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoSRGBLinear(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.SRGBLinear); } pub fn intoA98(this: *const XYZd50) A98 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoA98(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.A98); } pub fn intoOKLAB(this: *const XYZd50) OKLAB { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoOKLAB(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.OKLAB); } pub fn intoOKLCH(this: *const XYZd50) OKLCH { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoOKLCH(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.OKLCH); } pub fn intoRec2020(this: *const XYZd50) Rec2020 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoRec2020(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.Rec2020); } pub fn intoHSL(this: *const XYZd50) HSL { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoHSL(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.HSL); } pub fn intoHWB(this: *const XYZd50) HWB { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoHWB(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.HWB); } pub fn intoRGBA(this: *const XYZd50) RGBA { - const xyz: SRGB = this.intoSRGB(); - return xyz.intoRGBA(); + const xyz: SRGB = this.into(.SRGB); + return xyz.into(.RGBA); } }; pub const convert_XYZd65 = struct { pub fn intoLAB(this: *const XYZd65) LAB { - const xyz: XYZd50 = this.intoXYZd50(); - return xyz.intoLAB(); + const xyz: XYZd50 = this.into(.XYZd50); + return xyz.into(.LAB); } pub fn intoProPhoto(this: *const XYZd65) ProPhoto { - const xyz: XYZd50 = this.intoXYZd50(); - return xyz.intoProPhoto(); + const xyz: XYZd50 = this.into(.XYZd50); + return xyz.into(.ProPhoto); } pub fn intoOKLCH(this: *const XYZd65) OKLCH { - const xyz: OKLAB = this.intoOKLAB(); - return xyz.intoOKLCH(); + const xyz: OKLAB = this.into(.OKLAB); + return xyz.into(.OKLCH); } pub fn intoLCH(this: *const XYZd65) LCH { - const xyz: LAB = this.intoLAB(); - return xyz.intoLCH(); + const xyz: LAB = this.into(.LAB); + return xyz.into(.LCH); } pub fn intoSRGB(this: *const XYZd65) SRGB { - const xyz: SRGBLinear = this.intoSRGBLinear(); - return xyz.intoSRGB(); + const xyz: SRGBLinear = this.into(.SRGBLinear); + return xyz.into(.SRGB); } pub fn intoHSL(this: *const XYZd65) HSL { - const xyz: SRGB = this.intoSRGB(); - return xyz.intoHSL(); + const xyz: SRGB = this.into(.SRGB); + return xyz.into(.HSL); } pub fn intoHWB(this: *const XYZd65) HWB { - const xyz: SRGB = this.intoSRGB(); - return xyz.intoHWB(); + const xyz: SRGB = this.into(.SRGB); + return xyz.into(.HWB); } pub fn intoRGBA(this: *const XYZd65) RGBA { - const xyz: SRGB = this.intoSRGB(); - return xyz.intoRGBA(); + const xyz: SRGB = this.into(.SRGB); + return xyz.into(.RGBA); } }; pub const convert_LCH = struct { pub fn intoXYZd65(this: *const LCH) XYZd65 { - const xyz: LAB = this.intoLAB(); - return xyz.intoXYZd65(); + const xyz: LAB = this.into(.LAB); + return xyz.into(.XYZd65); } pub fn intoOKLAB(this: *const LCH) OKLAB { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoOKLAB(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.OKLAB); } pub fn intoOKLCH(this: *const LCH) OKLCH { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoOKLCH(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.OKLCH); } pub fn intoSRGB(this: *const LCH) SRGB { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoSRGB(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.SRGB); } pub fn intoSRGBLinear(this: *const LCH) SRGBLinear { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoSRGBLinear(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.SRGBLinear); } pub fn intoP3(this: *const LCH) P3 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoP3(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.P3); } pub fn intoA98(this: *const LCH) A98 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoA98(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.A98); } pub fn intoProPhoto(this: *const LCH) ProPhoto { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoProPhoto(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.ProPhoto); } pub fn intoRec2020(this: *const LCH) Rec2020 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoRec2020(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.Rec2020); } pub fn intoXYZd50(this: *const LCH) XYZd50 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoXYZd50(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.XYZd50); } pub fn intoHSL(this: *const LCH) HSL { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoHSL(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.HSL); } pub fn intoHWB(this: *const LCH) HWB { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoHWB(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.HWB); } pub fn intoRGBA(this: *const LCH) RGBA { - const xyz: SRGB = this.intoSRGB(); - return xyz.intoRGBA(); + const xyz: SRGB = this.into(.SRGB); + return xyz.into(.RGBA); } }; pub const convert_OKLAB = struct { pub fn intoLAB(this: *const OKLAB) LAB { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoLAB(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.LAB); } pub fn intoLCH(this: *const OKLAB) LCH { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoLCH(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.LCH); } pub fn intoSRGB(this: *const OKLAB) SRGB { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoSRGB(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.SRGB); } pub fn intoP3(this: *const OKLAB) P3 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoP3(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.P3); } pub fn intoSRGBLinear(this: *const OKLAB) SRGBLinear { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoSRGBLinear(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.SRGBLinear); } pub fn intoA98(this: *const OKLAB) A98 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoA98(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.A98); } pub fn intoProPhoto(this: *const OKLAB) ProPhoto { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoProPhoto(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.ProPhoto); } pub fn intoXYZd50(this: *const OKLAB) XYZd50 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoXYZd50(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.XYZd50); } pub fn intoRec2020(this: *const OKLAB) Rec2020 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoRec2020(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.Rec2020); } pub fn intoHSL(this: *const OKLAB) HSL { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoHSL(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.HSL); } pub fn intoHWB(this: *const OKLAB) HWB { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoHWB(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.HWB); } pub fn intoRGBA(this: *const OKLAB) RGBA { - const xyz: SRGB = this.intoSRGB(); - return xyz.intoRGBA(); + const xyz: SRGB = this.into(.SRGB); + return xyz.into(.RGBA); } }; pub const convert_OKLCH = struct { pub fn intoXYZd65(this: *const OKLCH) XYZd65 { - const xyz: OKLAB = this.intoOKLAB(); - return xyz.intoXYZd65(); + const xyz: OKLAB = this.into(.OKLAB); + return xyz.into(.XYZd65); } pub fn intoLAB(this: *const OKLCH) LAB { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoLAB(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.LAB); } pub fn intoLCH(this: *const OKLCH) LCH { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoLCH(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.LCH); } pub fn intoSRGB(this: *const OKLCH) SRGB { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoSRGB(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.SRGB); } pub fn intoP3(this: *const OKLCH) P3 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoP3(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.P3); } pub fn intoSRGBLinear(this: *const OKLCH) SRGBLinear { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoSRGBLinear(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.SRGBLinear); } pub fn intoA98(this: *const OKLCH) A98 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoA98(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.A98); } pub fn intoProPhoto(this: *const OKLCH) ProPhoto { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoProPhoto(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.ProPhoto); } pub fn intoXYZd50(this: *const OKLCH) XYZd50 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoXYZd50(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.XYZd50); } pub fn intoRec2020(this: *const OKLCH) Rec2020 { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoRec2020(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.Rec2020); } pub fn intoHSL(this: *const OKLCH) HSL { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoHSL(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.HSL); } pub fn intoHWB(this: *const OKLCH) HWB { - const xyz: XYZd65 = this.intoXYZd65(); - return xyz.intoHWB(); + const xyz: XYZd65 = this.into(.XYZd65); + return xyz.into(.HWB); } pub fn intoRGBA(this: *const OKLCH) RGBA { - const xyz: SRGB = this.intoSRGB(); - return xyz.intoRGBA(); + const xyz: SRGB = this.into(.SRGB); + return xyz.into(.RGBA); } }; }; diff --git a/src/css/values/color_js.zig b/src/css/values/color_js.zig index 0ae65a1c6c..0438bcc4b0 100644 --- a/src/css/values/color_js.zig +++ b/src/css/values/color_js.zig @@ -281,15 +281,15 @@ pub fn jsFunctionColor(globalThis: *JSC.JSGlobalObject, callFrame: *JSC.CallFram const srgba = switch (result.*) { .float => |float| switch (float.*) { .rgb => |rgb| rgb, - inline else => |*val| val.intoSRGB(), + inline else => |*val| val.into(.SRGB), }, - .rgba => |*rgba| rgba.intoSRGB(), + .rgba => |*rgba| rgba.into(.SRGB), .lab => |lab| switch (lab.*) { - inline else => |entry| entry.intoSRGB(), + inline else => |entry| entry.into(.SRGB), }, else => break :formatted, }; - const rgba = srgba.intoRGBA(); + const rgba = srgba.into(.RGBA); switch (tag) { .@"{rgba}" => { const object = JSC.JSValue.createEmptyObject(globalThis, 4); @@ -385,12 +385,12 @@ pub fn jsFunctionColor(globalThis: *JSC.JSGlobalObject, callFrame: *JSC.CallFram .float => |float| brk: { switch (float.*) { .hsl => |hsl| break :brk hsl, - inline else => |*val| break :brk val.intoHSL(), + inline else => |*val| break :brk val.into(.HSL), } }, - .rgba => |*rgba| rgba.intoHSL(), + .rgba => |*rgba| rgba.into(.HSL), .lab => |lab| switch (lab.*) { - inline else => |entry| entry.intoHSL(), + inline else => |entry| entry.into(.HSL), }, else => break :formatted, }; @@ -400,13 +400,13 @@ pub fn jsFunctionColor(globalThis: *JSC.JSGlobalObject, callFrame: *JSC.CallFram .lab => { const lab = switch (result.*) { .float => |float| switch (float.*) { - inline else => |*val| val.intoLAB(), + inline else => |*val| val.into(.LAB), }, .lab => |lab| switch (lab.*) { .lab => |lab_| lab_, - inline else => |entry| entry.intoLAB(), + inline else => |entry| entry.into(.LAB), }, - .rgba => |*rgba| rgba.intoLAB(), + .rgba => |*rgba| rgba.into(.LAB), else => break :formatted, }; diff --git a/src/css/values/easing.zig b/src/css/values/easing.zig index 263d45bf02..8fcb6807db 100644 --- a/src/css/values/easing.zig +++ b/src/css/values/easing.zig @@ -250,7 +250,7 @@ pub const StepPosition = enum { /// The first rise occurs at input progress value of 0 and the last rise occurs at input progress value of 1. @"jump-both", - pub usingnamespace css.DeriveToCss(@This()); + pub const toCss = css.DeriveToCss(@This()).toCss; const Map = bun.ComptimeEnumMap(enum { start, diff --git a/src/css/values/gradient.zig b/src/css/values/gradient.zig index e8e3b34858..2a49f088cb 100644 --- a/src/css/values/gradient.zig +++ b/src/css/values/gradient.zig @@ -212,7 +212,7 @@ pub const Gradient = union(enum) { switch (this.*) { .linear, .repeating_linear => |*linear| { - try linear.toCss(W, dest, linear.vendor_prefix.neq(css.VendorPrefix{ .none = true })); + try linear.toCss(W, dest, linear.vendor_prefix != css.VendorPrefix{ .none = true }); }, .radial, .repeating_radial => |*radial| { try radial.toCss(W, dest); @@ -330,21 +330,21 @@ pub const Gradient = union(enum) { /// Returns the color fallback types needed for the given browser targets. pub fn getNecessaryFallbacks(this: *const @This(), targets: css.targets.Targets) css.ColorFallbackKind { - var fallbacks = css.ColorFallbackKind.empty(); + var fallbacks = css.ColorFallbackKind{}; switch (this.*) { .linear, .repeating_linear => |*linear| { for (linear.items.items) |*item| { - fallbacks = fallbacks.bitwiseOr(item.getNecessaryFallbacks(targets)); + bun.bits.insert(css.ColorFallbackKind, &fallbacks, item.getNecessaryFallbacks(targets)); } }, .radial, .repeating_radial => |*radial| { for (radial.items.items) |*item| { - fallbacks = fallbacks.bitwiseOr(item.getNecessaryFallbacks(targets)); + bun.bits.insert(css.ColorFallbackKind, &fallbacks, item.getNecessaryFallbacks(targets)); } }, .conic, .repeating_conic => |*conic| { for (conic.items.items) |*item| { - fallbacks = fallbacks.bitwiseOr(item.getNecessaryFallbacks(targets)); + bun.bits.insert(css.ColorFallbackKind, &fallbacks, item.getNecessaryFallbacks(targets)); } }, .@"webkit-gradient" => {}, @@ -363,7 +363,7 @@ pub const LinearGradient = struct { items: ArrayList(GradientItem(LengthPercentage)), pub fn parse(input: *css.Parser, vendor_prefix: VendorPrefix) Result(LinearGradient) { - const direction: LineDirection = if (input.tryParse(LineDirection.parse, .{vendor_prefix.neq(VendorPrefix{ .none = true })}).asValue()) |dir| direction: { + const direction: LineDirection = if (input.tryParse(LineDirection.parse, .{vendor_prefix != VendorPrefix{ .none = true }}).asValue()) |dir| direction: { if (input.expectComma().asErr()) |e| return .{ .err = e }; break :direction dir; } else LineDirection{ .vertical = .bottom }; @@ -1083,7 +1083,7 @@ pub fn GradientItem(comptime D: type) type { pub fn getNecessaryFallbacks(this: *const @This(), targets: css.targets.Targets) css.ColorFallbackKind { return switch (this.*) { .color_stop => |*stop| stop.color.getNecessaryFallbacks(targets), - .hint => css.ColorFallbackKind.empty(), + .hint => css.ColorFallbackKind{}, }; } }; @@ -1098,8 +1098,8 @@ pub const EndingShape = union(enum) { /// A circle. circle: Circle, - pub usingnamespace css.DeriveParse(@This()); - pub usingnamespace css.DeriveToCss(@This()); + pub const parse = css.DeriveParse(@This()).parse; + pub const toCss = css.DeriveToCss(@This()).toCss; pub fn default() EndingShape { return .{ .ellipse = .{ .extent = .@"farthest-corner" } }; diff --git a/src/css/values/image.zig b/src/css/values/image.zig index a0601ce9c6..d0c2d914e1 100644 --- a/src/css/values/image.zig +++ b/src/css/values/image.zig @@ -25,8 +25,8 @@ pub const Image = union(enum) { /// An `image-set()`. image_set: ImageSet, - pub usingnamespace css.DeriveParse(@This()); - pub usingnamespace css.DeriveToCss(@This()); + pub const parse = css.DeriveParse(@This()).parse; + pub const toCss = css.DeriveToCss(@This()).toCss; pub fn deinit(_: *@This(), _: std.mem.Allocator) void { // TODO: implement this @@ -68,7 +68,7 @@ pub const Image = union(enum) { pub fn hasVendorPrefix(this: *const @This()) bool { const prefix = this.getVendorPrefix(); - return !prefix.isEmpty() and !prefix.eq(VendorPrefix{ .none = true }); + return !prefix.isEmpty() and prefix != VendorPrefix{ .none = true }; } /// Returns the vendor prefix used in the image value. @@ -76,7 +76,7 @@ pub const Image = union(enum) { return switch (this.*) { .gradient => |a| a.getVendorPrefix(), .image_set => |a| a.getVendorPrefix(), - else => VendorPrefix.empty(), + else => .{}, }; } @@ -120,7 +120,7 @@ pub const Image = union(enum) { var res = css.SmallList(Image, 6){}; // Get RGB fallbacks if needed. - const rgb = if (fallbacks.contains(ColorFallbackKind.RGB)) + const rgb = if (fallbacks.rgb) this.getFallback(allocator, ColorFallbackKind.RGB) else null; @@ -129,7 +129,7 @@ pub const Image = union(enum) { const prefix_image = if (rgb) |r| &r else this; // Legacy -webkit-gradient() - if (prefixes.contains(VendorPrefix.WEBKIT) and + if (prefixes.webkit and if (targets.browsers) |browsers| css.prefixes.Feature.isWebkitGradient(browsers) else false and prefix_image.* == .gradient) { @@ -139,31 +139,31 @@ pub const Image = union(enum) { } // Standard syntax, with prefixes. - if (prefixes.contains(VendorPrefix.WEBKIT)) { + if (prefixes.webkit) { res.append(allocator, prefix_image.getPrefixed(allocator, css.VendorPrefix.WEBKIT)); } - if (prefixes.contains(VendorPrefix.MOZ)) { + if (prefixes.moz) { res.append(allocator, prefix_image.getPrefixed(allocator, css.VendorPrefix.MOZ)); } - if (prefixes.contains(VendorPrefix.O)) { + if (prefixes.o) { res.append(allocator, prefix_image.getPrefixed(allocator, css.VendorPrefix.O)); } - if (prefixes.contains(VendorPrefix.NONE)) { + if (prefixes.none) { // Unprefixed, rgb fallback. if (rgb) |r| { res.append(allocator, r); } // P3 fallback. - if (fallbacks.contains(ColorFallbackKind.P3)) { + if (fallbacks.p3) { res.append(allocator, this.getFallback(allocator, ColorFallbackKind.P3)); } // Convert original to lab if needed (e.g. if oklab is not supported but lab is). - if (fallbacks.contains(ColorFallbackKind.LAB)) { + if (fallbacks.lab) { this.* = this.getFallback(allocator, ColorFallbackKind.LAB); } } else if (res.pop()) |last| { @@ -186,7 +186,7 @@ pub const Image = union(enum) { pub fn getNecessaryFallbacks(this: *const @This(), targets: css.targets.Targets) css.ColorFallbackKind { return switch (this.*) { .gradient => |grad| grad.getNecessaryFallbacks(targets), - else => css.ColorFallbackKind.empty(), + else => css.ColorFallbackKind{}, }; } @@ -255,7 +255,7 @@ pub const ImageSet = struct { } else { try dest.delim(',', false); } - try option.toCss(W, dest, this.vendor_prefix.neq(VendorPrefix{ .none = true })); + try option.toCss(W, dest, this.vendor_prefix != VendorPrefix{ .none = true }); } return dest.writeChar(')'); } diff --git a/src/css/values/length.zig b/src/css/values/length.zig index ed58df5e58..b3a4df8dae 100644 --- a/src/css/values/length.zig +++ b/src/css/values/length.zig @@ -19,8 +19,8 @@ pub const LengthOrNumber = union(enum) { /// A length. length: Length, - pub usingnamespace css.DeriveParse(@This()); - pub usingnamespace css.DeriveToCss(@This()); + pub const parse = css.DeriveParse(@This()).parse; + pub const toCss = css.DeriveToCss(@This()).toCss; pub fn deinit(this: *const LengthOrNumber, allocator: std.mem.Allocator) void { switch (this.*) { @@ -57,8 +57,8 @@ pub const LengthPercentageOrAuto = union(enum) { /// A [``](https://www.w3.org/TR/css-values-4/#typedef-length-percentage). length: LengthPercentage, - pub usingnamespace css.DeriveParse(@This()); - pub usingnamespace css.DeriveToCss(@This()); + pub const parse = css.DeriveParse(@This()).parse; + pub const toCss = css.DeriveToCss(@This()).toCss; pub fn isCompatible(this: *const @This(), browsers: css.targets.Browsers) bool { return switch (this.*) { diff --git a/src/css/values/percentage.zig b/src/css/values/percentage.zig index ed558d854b..b5308c3671 100644 --- a/src/css/values/percentage.zig +++ b/src/css/values/percentage.zig @@ -471,8 +471,8 @@ pub const NumberOrPercentage = union(enum) { percentage: Percentage, // TODO: implement this - pub usingnamespace css.DeriveParse(@This()); - pub usingnamespace css.DeriveToCss(@This()); + pub const parse = css.DeriveParse(@This()).parse; + pub const toCss = css.DeriveToCss(@This()).toCss; // pub fn parse(input: *css.Parser) Result(NumberOrPercentage) { // _ = input; // autofix diff --git a/src/meta.zig b/src/meta.zig index c8db1d72ee..49d5b794dc 100644 --- a/src/meta.zig +++ b/src/meta.zig @@ -284,6 +284,7 @@ pub fn isSimpleEqlType(comptime T: type) bool { .int => true, .float => true, .@"enum" => true, + .@"struct" => |struct_info| struct_info.layout == .@"packed", else => false, }; } diff --git a/test/internal/ban-words.test.ts b/test/internal/ban-words.test.ts index 4619112164..54a547843a 100644 --- a/test/internal/ban-words.test.ts +++ b/test/internal/ban-words.test.ts @@ -30,7 +30,7 @@ const words: Record "!= alloc.ptr": { reason: "The std.mem.Allocator context pointer can be undefined, which makes this comparison undefined behavior" }, [String.raw`: [a-zA-Z0-9_\.\*\?\[\]\(\)]+ = undefined,`]: { reason: "Do not default a struct field to undefined", limit: 242, regex: true }, - "usingnamespace": { reason: "Zig deprecates this, and will not support it in incremental compilation.", limit: 310 }, + "usingnamespace": { reason: "Zig deprecates this, and will not support it in incremental compilation.", limit: 50 }, "std.fs.Dir": { reason: "Prefer bun.sys + bun.FD instead of std.fs", limit: 180 }, "std.fs.cwd": { reason: "Prefer bun.FD.cwd()", limit: 103 },