Skip to content

Commit

Permalink
CSS fix bug with merging style rules, fix unnecessary backslash, more…
Browse files Browse the repository at this point in the history
… tests (#16628)
  • Loading branch information
zackradisic authored Jan 23, 2025
1 parent ba2bd5c commit 70ed282
Show file tree
Hide file tree
Showing 7 changed files with 1,721 additions and 446 deletions.
5 changes: 4 additions & 1 deletion src/css/css_parser.zig
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ pub const VendorPrefix = packed struct(u8) {
pub const NONE = VendorPrefix{ .none = true };
pub const WEBKIT = VendorPrefix{ .webkit = true };
pub const MOZ = VendorPrefix{ .moz = true };
pub const MS = VendorPrefix{ .ms = true };
pub const O = VendorPrefix{ .o = true };

/// Fields listed here so we can iterate them in the order we want
Expand Down Expand Up @@ -881,6 +882,8 @@ pub fn DefineEnumProperty(comptime T: type) type {
// @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));
}
Expand Down Expand Up @@ -4901,7 +4904,7 @@ const Tokenizer = struct {
}
}
// else: escaped EOF, do nothing.
// continue;
continue;
},
0 => {
this.advance(1);
Expand Down
4 changes: 4 additions & 0 deletions src/css/declaration.zig
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const ScrollMarginHandler = css.css_properties.margin_padding.ScrollMarginHandle
const FontHandler = css.css_properties.font.FontHandler;
const InsetHandler = css.css_properties.margin_padding.InsetHandler;
const SizeHandler = css.css_properties.size.SizeHandler;
const FlexHandler = css.css_properties.flex.FlexHandler;

/// A CSS declaration block.
///
Expand Down Expand Up @@ -332,6 +333,7 @@ pub fn parse_declaration(
pub const DeclarationHandler = struct {
background: BackgroundHandler = .{},
border: BorderHandler = .{},
flex: FlexHandler = .{},
size: SizeHandler = .{},
margin: MarginHandler = .{},
padding: PaddingHandler = .{},
Expand All @@ -356,6 +358,7 @@ pub const DeclarationHandler = struct {

this.background.finalize(&this.decls, context);
this.border.finalize(&this.decls, context);
this.flex.finalize(&this.decls, context);
this.size.finalize(&this.decls, context);
this.margin.finalize(&this.decls, context);
this.padding.finalize(&this.decls, context);
Expand All @@ -369,6 +372,7 @@ pub const DeclarationHandler = struct {
// return this.background.handleProperty(property, &this.decls, context);
return this.background.handleProperty(property, &this.decls, context) or
this.border.handleProperty(property, &this.decls, context) or
this.flex.handleProperty(property, &this.decls, context) or
this.size.handleProperty(property, &this.decls, context) or
this.margin.handleProperty(property, &this.decls, context) or
this.padding.handleProperty(property, &this.decls, context) or
Expand Down
2 changes: 0 additions & 2 deletions src/css/properties/border.zig
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,6 @@ pub const LineStyle = enum {
return true;
}

pub fn deinit(_: *const @This(), _: std.mem.Allocator) void {}

pub fn default() LineStyle {
return .none;
}
Expand Down
Loading

0 comments on commit 70ed282

Please sign in to comment.