mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 23:23:28 +00:00
61 lines
1.9 KiB
Zig
61 lines
1.9 KiB
Zig
// Copyright (C) 2023-2024 Lightpanda (Selecy SAS)
|
|
//
|
|
// Francis Bouvier <francis@lightpanda.io>
|
|
// Pierre Tachoire <pierre@lightpanda.io>
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU Affero General Public License as
|
|
// published by the Free Software Foundation, either version 3 of the
|
|
// License, or (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU Affero General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
const std = @import("std");
|
|
|
|
const StyleSheet = @import("stylesheet.zig").StyleSheet;
|
|
const CSSRule = @import("css_rule.zig").CSSRule;
|
|
const CSSImportRule = @import("css_rule.zig").CSSImportRule;
|
|
|
|
pub const CSSRuleList = struct {
|
|
list: std.ArrayListUnmanaged([]const u8),
|
|
|
|
pub fn constructor() CSSRuleList {
|
|
return .{ .list = .empty };
|
|
}
|
|
|
|
pub fn _item(self: *CSSRuleList, _index: u32) ?CSSRule {
|
|
const index: usize = @intCast(_index);
|
|
|
|
if (index > self.list.items.len) {
|
|
return null;
|
|
}
|
|
|
|
// todo: for now, just return null.
|
|
// this depends on properly parsing CSSRule
|
|
return null;
|
|
}
|
|
|
|
pub fn get_length(self: *CSSRuleList) u32 {
|
|
return @intCast(self.list.items.len);
|
|
}
|
|
};
|
|
|
|
const testing = @import("../../testing.zig");
|
|
test "Browser.CSS.CSSRuleList" {
|
|
var runner = try testing.jsRunner(testing.tracking_allocator, .{});
|
|
defer runner.deinit();
|
|
|
|
try runner.testCases(&.{
|
|
.{ "let list = new CSSRuleList()", "undefined" },
|
|
.{ "list instanceof CSSRuleList", "true" },
|
|
.{ "list.length", "0" },
|
|
.{ "list.item(0)", "null" },
|
|
}, .{});
|
|
}
|