add some skeleton implementations for various CSS WebAPIs

This commit is contained in:
Karl Seguin
2025-11-25 13:00:32 +08:00
parent e336c67857
commit 218d08b1f6
16 changed files with 547 additions and 29 deletions

View File

@@ -29,28 +29,6 @@ const CSSStyleDeclaration = @This();
_element: ?*Element = null,
_properties: std.DoublyLinkedList = .{},
pub const Property = struct {
_name: String,
_value: String,
_important: bool = false,
_node: std.DoublyLinkedList.Node,
fn fromNodeLink(n: *std.DoublyLinkedList.Node) *Property {
return @alignCast(@fieldParentPtr("_node", n));
}
pub fn format(self: *const Property, writer: *std.Io.Writer) !void {
try self._name.format(writer);
try writer.writeAll(": ");
try self._value.format(writer);
if (self._important) {
try writer.writeAll(" !important");
}
try writer.writeByte(';');
}
};
pub fn init(element: ?*Element, page: *Page) !*CSSStyleDeclaration {
return page._factory.create(CSSStyleDeclaration{
._element = element,
@@ -214,6 +192,28 @@ fn normalizePropertyName(name: []const u8, buf: []u8) []const u8 {
return std.ascii.lowerString(buf, name);
}
pub const Property = struct {
_name: String,
_value: String,
_important: bool = false,
_node: std.DoublyLinkedList.Node,
fn fromNodeLink(n: *std.DoublyLinkedList.Node) *Property {
return @alignCast(@fieldParentPtr("_node", n));
}
pub fn format(self: *const Property, writer: *std.Io.Writer) !void {
try self._name.format(writer);
try writer.writeAll(": ");
try self._value.format(writer);
if (self._important) {
try writer.writeAll(" !important");
}
try writer.writeByte(';');
}
};
pub const JsApi = struct {
pub const bridge = js.Bridge(CSSStyleDeclaration);