|
| 1 | +// Copyright (C) 2023-2024 Lightpanda (Selecy SAS) |
| 2 | +// |
| 3 | +// Francis Bouvier <francis@lightpanda.io> |
| 4 | +// Pierre Tachoire <pierre@lightpanda.io> |
| 5 | +// |
| 6 | +// This program is free software: you can redistribute it and/or modify |
| 7 | +// it under the terms of the GNU Affero General Public License as |
| 8 | +// published by the Free Software Foundation, either version 3 of the |
| 9 | +// License, or (at your option) any later version. |
| 10 | +// |
| 11 | +// This program is distributed in the hope that it will be useful, |
| 12 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | +// GNU Affero General Public License for more details. |
| 15 | +// |
| 16 | +// You should have received a copy of the GNU Affero General Public License |
| 17 | +// along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 18 | + |
| 19 | +const std = @import("std"); |
| 20 | + |
| 21 | +const Page = @import("../page.zig").Page; |
| 22 | + |
| 23 | +const CSSStyleDeclaration = @import("css_style_declaration.zig").CSSStyleDeclaration; |
| 24 | +const CSSStyleSheet = @import("css_stylesheet.zig").CSSStyleSheet; |
| 25 | + |
| 26 | +pub const Interfaces = .{ |
| 27 | + CSSRule, |
| 28 | + CSSImportRule, |
| 29 | +}; |
| 30 | + |
| 31 | +// https://developer.mozilla.org/en-US/docs/Web/API/CSSRule |
| 32 | +pub const CSSRule = struct { |
| 33 | + css_text: []const u8, |
| 34 | + parent_rule: ?*CSSRule = null, |
| 35 | + parent_stylesheet: ?*CSSStyleSheet = null, |
| 36 | +}; |
| 37 | + |
| 38 | +pub const CSSImportRule = struct { |
| 39 | + pub const prototype = *CSSRule; |
| 40 | + href: []const u8, |
| 41 | + layer_name: ?[]const u8, |
| 42 | + media: void, |
| 43 | + style_sheet: CSSStyleSheet, |
| 44 | + supports_text: ?[]const u8, |
| 45 | +}; |
| 46 | + |
| 47 | +// pub const CSSGroupingRule = struct { |
| 48 | +// pub const prototype = *CSSRule; |
| 49 | +// list: std.ArrayListUnmanaged(CSSRule), |
| 50 | + |
| 51 | +// pub fn _insertRule(self: *CSSGroupingRule, rule: []const u8, _index: ?usize, page: *Page) !usize { |
| 52 | +// const index = _index orelse 0; |
| 53 | +// if (index > self.list.items.len) return error.IndexSizeError; |
| 54 | + |
| 55 | +// const css_rule: CSSRule = .{ .css_text = rule, .parent_rule = null, .parent_stylesheet = null }; |
| 56 | +// try self.list.insert(page.arena, index, css_rule); |
| 57 | +// return self.list.items.len; |
| 58 | +// } |
| 59 | + |
| 60 | +// pub fn _deleteRule(self: *CSSGroupingRule, index: usize) !void { |
| 61 | +// if (index > self.list.items.len) return error.IndexSizeError; |
| 62 | +// _ = self.list.orderedRemove(index); |
| 63 | +// } |
| 64 | +// }; |
| 65 | + |
| 66 | +// pub const CSSStyleRule = struct { |
| 67 | +// pub const prototype = *CSSGroupingRule; |
| 68 | +// selector_text: []const u8, |
| 69 | +// style: CSSStyleDeclaration, |
| 70 | +// }; |
| 71 | + |
| 72 | +// pub const CSSFontFaceRule = struct { |
| 73 | +// pub const prototype = *CSSRule; |
| 74 | +// }; |
| 75 | + |
| 76 | +// pub const CSSPageRule = struct { |
| 77 | +// pub const prototype = *CSSGroupingRule; |
| 78 | +// selector_text: []const u8, |
| 79 | +// style: CSSStyleDeclaration, |
| 80 | +// }; |
0 commit comments