File tree Expand file tree Collapse file tree 3 files changed +30
-0
lines changed Expand file tree Collapse file tree 3 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,18 @@ const std = @import("std");
2323const Selector = @import ("selector.zig" ).Selector ;
2424const parser = @import ("parser.zig" );
2525
26+ pub const Interfaces = .{
27+ Css ,
28+ };
29+
30+ // https://developer.mozilla.org/en-US/docs/Web/API/CSS
31+ pub const Css = struct {
32+ pub fn _supports (_ : * Css , _ : []const u8 , _ : ? []const u8 ) bool {
33+ // TODO: Actually respond with which CSS features we support.
34+ return true ;
35+ }
36+ };
37+
2638// parse parse a selector string and returns the parsed result or an error.
2739pub fn parse (alloc : std.mem.Allocator , s : []const u8 , opts : parser.ParseOptions ) parser.ParseError ! Selector {
2840 var p = parser.Parser { .s = s , .i = 0 , .opts = opts };
@@ -174,3 +186,14 @@ test "parse" {
174186 defer s .deinit (alloc );
175187 }
176188}
189+
190+ const testing = @import ("../../testing.zig" );
191+ test "Browser.HTML.CSS" {
192+ var runner = try testing .jsRunner (testing .tracking_allocator , .{});
193+ defer runner .deinit ();
194+
195+ try runner .testCases (&.{
196+ .{ "CSS.supports('display: flex')" , "true" },
197+ .{ "CSS.supports('text-decoration-style', 'blink')" , "true" },
198+ }, .{});
199+ }
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ const WebApis = struct {
2222 pub const Interfaces = generate .Tuple (.{
2323 @import ("crypto/crypto.zig" ).Crypto ,
2424 @import ("console/console.zig" ).Console ,
25+ @import ("css/css.zig" ).Interfaces ,
2526 @import ("cssom/cssom.zig" ).Interfaces ,
2627 @import ("dom/dom.zig" ).Interfaces ,
2728 @import ("encoding/text_encoder.zig" ).Interfaces ,
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ const Performance = @import("../dom/performance.zig").Performance;
3535const CSSStyleDeclaration = @import ("../cssom/css_style_declaration.zig" ).CSSStyleDeclaration ;
3636const CustomElementRegistry = @import ("../webcomponents/custom_element_registry.zig" ).CustomElementRegistry ;
3737const Screen = @import ("screen.zig" ).Screen ;
38+ const Css = @import ("../css/css.zig" ).Css ;
3839
3940const storage = @import ("../storage/storage.zig" );
4041
@@ -62,6 +63,7 @@ pub const Window = struct {
6263 performance : Performance ,
6364 custom_elements : CustomElementRegistry = .{},
6465 screen : Screen = .{},
66+ css : Css = .{},
6567
6668 pub fn create (target : ? []const u8 , navigator : ? Navigator ) ! Window {
6769 var fbs = std .io .fixedBufferStream ("" );
@@ -175,6 +177,10 @@ pub const Window = struct {
175177 return & self .screen ;
176178 }
177179
180+ pub fn get_CSS (self : * Window ) * Css {
181+ return & self .css ;
182+ }
183+
178184 pub fn _requestAnimationFrame (self : * Window , cbk : Function , page : * Page ) ! u32 {
179185 return self .createTimeout (cbk , 5 , page , .{ .animation_frame = true });
180186 }
You can’t perform that action at this time.
0 commit comments