mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 23:23:28 +00:00
Iterfaces generation refacto
Signed-off-by: Francis Bouvier <francis.bouvier@gmail.com>
This commit is contained in:
36
src/dom.zig
36
src/dom.zig
@@ -2,38 +2,14 @@ const generate = @import("generate.zig");
|
|||||||
|
|
||||||
const Console = @import("jsruntime").Console;
|
const Console = @import("jsruntime").Console;
|
||||||
|
|
||||||
// DOM
|
const DOM = @import("dom/dom.zig");
|
||||||
const EventTarget = @import("dom/event_target.zig").EventTarget;
|
const HTML = @import("html/html.zig");
|
||||||
const N = @import("dom/node.zig");
|
|
||||||
const CharacterData = @import("dom/character_data.zig").CharacterData;
|
|
||||||
const Comment = @import("dom/comment.zig").Comment;
|
|
||||||
const Text = @import("dom/text.zig").Text;
|
|
||||||
const Element = @import("dom/element.zig").Element;
|
|
||||||
const Document = @import("dom/document.zig").Document;
|
|
||||||
|
|
||||||
// HTML
|
|
||||||
pub const HTMLDocument = @import("html/document.zig").HTMLDocument;
|
pub const HTMLDocument = @import("html/document.zig").HTMLDocument;
|
||||||
const HTMLElem = @import("html/elements.zig");
|
|
||||||
|
|
||||||
const E = @import("html/elements.zig");
|
|
||||||
|
|
||||||
// Interfaces
|
// Interfaces
|
||||||
const interfaces = .{
|
pub const Interfaces = generate.Tuple(.{
|
||||||
Console,
|
Console,
|
||||||
|
DOM.Interfaces,
|
||||||
// DOM
|
HTML.Interfaces,
|
||||||
EventTarget,
|
});
|
||||||
N.Node,
|
|
||||||
N.Types,
|
|
||||||
CharacterData,
|
|
||||||
Comment,
|
|
||||||
Element,
|
|
||||||
Document,
|
|
||||||
|
|
||||||
// HTML
|
|
||||||
HTMLDocument,
|
|
||||||
HTMLElem.HTMLElement,
|
|
||||||
HTMLElem.HTMLMediaElement,
|
|
||||||
HTMLElem.Types,
|
|
||||||
};
|
|
||||||
pub const Interfaces = generate.Tuple(interfaces);
|
|
||||||
|
|||||||
@@ -12,6 +12,13 @@ const Comment = @import("comment.zig").Comment;
|
|||||||
const Text = @import("text.zig").Text;
|
const Text = @import("text.zig").Text;
|
||||||
const HTMLElem = @import("../html/elements.zig");
|
const HTMLElem = @import("../html/elements.zig");
|
||||||
|
|
||||||
|
// CharacterData interfaces
|
||||||
|
pub const Interfaces = generate.Tuple(.{
|
||||||
|
Comment,
|
||||||
|
Text,
|
||||||
|
});
|
||||||
|
|
||||||
|
// CharacterData implementation
|
||||||
pub const CharacterData = struct {
|
pub const CharacterData = struct {
|
||||||
pub const Self = parser.CharacterData;
|
pub const Self = parser.CharacterData;
|
||||||
pub const prototype = *Node;
|
pub const prototype = *Node;
|
||||||
@@ -76,14 +83,6 @@ pub const CharacterData = struct {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Types = generate.Tuple(.{
|
|
||||||
Comment,
|
|
||||||
Text,
|
|
||||||
});
|
|
||||||
const Generated = generate.Union.compile(Types);
|
|
||||||
pub const Union = Generated._union;
|
|
||||||
pub const Tags = Generated._enum;
|
|
||||||
|
|
||||||
// Tests
|
// Tests
|
||||||
// -----
|
// -----
|
||||||
|
|
||||||
|
|||||||
@@ -8,10 +8,30 @@ const generate = @import("../generate.zig");
|
|||||||
const parser = @import("../netsurf.zig");
|
const parser = @import("../netsurf.zig");
|
||||||
|
|
||||||
const EventTarget = @import("event_target.zig").EventTarget;
|
const EventTarget = @import("event_target.zig").EventTarget;
|
||||||
|
|
||||||
|
// DOM
|
||||||
const CData = @import("character_data.zig");
|
const CData = @import("character_data.zig");
|
||||||
const HTMLDocument = @import("../html/document.zig").HTMLDocument;
|
const Element = @import("element.zig").Element;
|
||||||
|
const Document = @import("document.zig").Document;
|
||||||
|
|
||||||
|
// HTML
|
||||||
|
const HTML = @import("../html/html.zig");
|
||||||
const HTMLElem = @import("../html/elements.zig");
|
const HTMLElem = @import("../html/elements.zig");
|
||||||
|
|
||||||
|
// Node interfaces
|
||||||
|
pub const Interfaces = generate.Tuple(.{
|
||||||
|
CData.CharacterData,
|
||||||
|
CData.Interfaces,
|
||||||
|
Element,
|
||||||
|
Document,
|
||||||
|
|
||||||
|
HTML.Interfaces,
|
||||||
|
});
|
||||||
|
const Generated = generate.Union.compile(Interfaces);
|
||||||
|
pub const Union = Generated._union;
|
||||||
|
pub const Tags = Generated._enum;
|
||||||
|
|
||||||
|
// Node implementation
|
||||||
pub const Node = struct {
|
pub const Node = struct {
|
||||||
pub const Self = parser.Node;
|
pub const Self = parser.Node;
|
||||||
pub const prototype = *EventTarget;
|
pub const prototype = *EventTarget;
|
||||||
@@ -207,15 +227,6 @@ pub const Node = struct {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Types = generate.Tuple(.{
|
|
||||||
CData.Types,
|
|
||||||
HTMLElem.Types,
|
|
||||||
HTMLDocument,
|
|
||||||
});
|
|
||||||
const Generated = generate.Union.compile(Types);
|
|
||||||
pub const Union = Generated._union;
|
|
||||||
pub const Tags = Generated._enum;
|
|
||||||
|
|
||||||
// Tests
|
// Tests
|
||||||
// -----
|
// -----
|
||||||
|
|
||||||
|
|||||||
@@ -3,16 +3,8 @@ const generate = @import("../generate.zig");
|
|||||||
|
|
||||||
const Element = @import("../dom/element.zig").Element;
|
const Element = @import("../dom/element.zig").Element;
|
||||||
|
|
||||||
// Abstract class
|
// HTMLElement interfaces
|
||||||
// --------------
|
pub const Interfaces = .{
|
||||||
|
|
||||||
pub const HTMLElement = struct {
|
|
||||||
pub const Self = parser.ElementHTML;
|
|
||||||
pub const prototype = *Element;
|
|
||||||
pub const mem_guarantied = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
pub const Types = .{
|
|
||||||
HTMLUnknownElement,
|
HTMLUnknownElement,
|
||||||
HTMLAnchorElement,
|
HTMLAnchorElement,
|
||||||
HTMLAreaElement,
|
HTMLAreaElement,
|
||||||
@@ -74,10 +66,19 @@ pub const Types = .{
|
|||||||
HTMLUListElement,
|
HTMLUListElement,
|
||||||
HTMLVideoElement,
|
HTMLVideoElement,
|
||||||
};
|
};
|
||||||
const Generated = generate.Union.compile(Types);
|
const Generated = generate.Union.compile(Interfaces);
|
||||||
pub const Union = Generated._union;
|
pub const Union = Generated._union;
|
||||||
pub const Tags = Generated._enum;
|
pub const Tags = Generated._enum;
|
||||||
|
|
||||||
|
// Abstract class
|
||||||
|
// --------------
|
||||||
|
|
||||||
|
pub const HTMLElement = struct {
|
||||||
|
pub const Self = parser.ElementHTML;
|
||||||
|
pub const prototype = *Element;
|
||||||
|
pub const mem_guarantied = true;
|
||||||
|
};
|
||||||
|
|
||||||
// Deprecated HTMLElements in Chrome (2023/03/15)
|
// Deprecated HTMLElements in Chrome (2023/03/15)
|
||||||
// HTMLContentelement
|
// HTMLContentelement
|
||||||
// HTMLShadowElement
|
// HTMLShadowElement
|
||||||
|
|||||||
Reference in New Issue
Block a user