Skip to content

Commit 97bc19e

Browse files
committed
clean up various imports in CSSOM
1 parent 2656cc7 commit 97bc19e

File tree

4 files changed

+22
-30
lines changed

4 files changed

+22
-30
lines changed

src/browser/cssom/css_rule.zig

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818

1919
const std = @import("std");
2020

21-
const Page = @import("../page.zig").Page;
22-
23-
const CSSStyleDeclaration = @import("css_style_declaration.zig").CSSStyleDeclaration;
2421
const CSSStyleSheet = @import("css_stylesheet.zig").CSSStyleSheet;
2522

2623
pub const Interfaces = .{

src/browser/cssom/css_rule_list.zig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818

1919
const std = @import("std");
2020

21-
const Page = @import("../page.zig").Page;
2221
const StyleSheet = @import("stylesheet.zig").StyleSheet;
23-
2422
const CSSRule = @import("css_rule.zig").CSSRule;
2523
const CSSImportRule = @import("css_rule.zig").CSSImportRule;
2624

src/browser/cssom/css_stylesheet.zig

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ const CSSRuleList = @import("css_rule_list.zig").CSSRuleList;
2525
const CSSImportRule = @import("css_rule.zig").CSSImportRule;
2626

2727
pub const CSSStyleSheet = struct {
28-
pub const prototype = *StyleSheet;
29-
30-
css_rules: *CSSRuleList,
28+
proto: StyleSheet,
29+
css_rules: CSSRuleList,
3130
owner_rule: ?*CSSImportRule,
3231

3332
const CSSStyleSheetOpts = struct {
@@ -36,23 +35,21 @@ pub const CSSStyleSheet = struct {
3635
disabled: bool = false,
3736
};
3837

39-
pub fn constructor(_opts: ?CSSStyleSheetOpts, page: *Page) !CSSStyleSheet {
38+
pub fn constructor(_opts: ?CSSStyleSheetOpts) !CSSStyleSheet {
4039
const opts = _opts orelse CSSStyleSheetOpts{};
41-
_ = opts;
42-
43-
const arena = page.arena;
44-
const rules = try arena.create(CSSRuleList);
45-
rules.* = .constructor();
46-
47-
return .{ .css_rules = rules, .owner_rule = null };
40+
return .{
41+
.proto = StyleSheet{ .disabled = opts.disabled },
42+
.css_rules = .constructor(),
43+
.owner_rule = null,
44+
};
4845
}
4946

5047
pub fn get_ownerRule(_: *CSSStyleSheet) ?*CSSImportRule {
5148
return null;
5249
}
5350

5451
pub fn get_cssRules(self: *CSSStyleSheet) *CSSRuleList {
55-
return self.css_rules;
52+
return &self.css_rules;
5653
}
5754

5855
pub fn _insertRule(self: *CSSStyleSheet, rule: []const u8, _index: ?usize, page: *Page) !usize {

src/browser/cssom/stylesheet.zig

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,36 +20,36 @@ const parser = @import("../netsurf.zig");
2020

2121
// https://developer.mozilla.org/en-US/docs/Web/API/StyleSheet#specifications
2222
pub const StyleSheet = struct {
23-
disabled: bool,
24-
href: []const u8,
25-
owner_node: *parser.Node,
26-
parent_stylesheet: ?*StyleSheet,
27-
title: []const u8,
28-
type: []const u8,
29-
30-
pub fn get_disabled(self: *StyleSheet) bool {
23+
disabled: bool = false,
24+
href: []const u8 = "",
25+
owner_node: ?*parser.Node = null,
26+
parent_stylesheet: ?*StyleSheet = null,
27+
title: []const u8 = "",
28+
type: []const u8 = "text/css",
29+
30+
pub fn get_disabled(self: *const StyleSheet) bool {
3131
return self.disabled;
3232
}
3333

34-
pub fn get_href(self: *StyleSheet) []const u8 {
34+
pub fn get_href(self: *const StyleSheet) []const u8 {
3535
return self.href;
3636
}
3737

3838
// TODO: media
3939

40-
pub fn get_ownerNode(self: *StyleSheet) *parser.Node {
40+
pub fn get_ownerNode(self: *const StyleSheet) ?*parser.Node {
4141
return self.owner_node;
4242
}
4343

44-
pub fn get_parentStyleSheet(self: *StyleSheet) ?*StyleSheet {
44+
pub fn get_parentStyleSheet(self: *const StyleSheet) ?*StyleSheet {
4545
return self.parent_stylesheet;
4646
}
4747

48-
pub fn get_title(self: *StyleSheet) []const u8 {
48+
pub fn get_title(self: *const StyleSheet) []const u8 {
4949
return self.title;
5050
}
5151

52-
pub fn get_type(self: *StyleSheet) []const u8 {
52+
pub fn get_type(self: *const StyleSheet) []const u8 {
5353
return self.type;
5454
}
5555
};

0 commit comments

Comments
 (0)