Skip to content

Lightpanda: the headless browser designed for AI and automation

mem: remove _proto field from leaf nodes

Karl Seguin655d806fa5e0
diff --git a/src/browser/Factory.zig b/src/browser/Factory.zig
index 109a03fc4..f156055b3 100644
--- a/src/browser/Factory.zig
+++ b/src/browser/Factory.zig
@@ -323,7 +323,9 @@ pub fn cdataNode(self: *Factory, cd: Node.CData, leaf: anytype) !*Node.CData {
// only the CDATASection chain has a middle here (its Text)
inline for (3..types.len - 1) |i| {
- chain.set(i, .{ ._proto = chain.get(i - 1) });
+ const ptr = chain.get(i);
+ ptr.* = .{};
+ setProto(ptr, chain.get(i - 1));
}
chain.setLeaf(types.len - 1, leaf);
return cd_ptr;
diff --git a/src/browser/Frame.zig b/src/browser/Frame.zig
index 07233e382..c046fc98b 100644
--- a/src/browser/Frame.zig
+++ b/src/browser/Frame.zig
@@ -1111,7 +1111,7 @@ pub fn iframeCompletedLoading(self: *Frame, iframe: *IFrame, delays_load: bool)
else => false,
};
if (parsing_html and iframe._src.len > 0) {
- self.queueElementEvent(iframe._proto, .load) catch |err| {
+ self.queueElementEvent(Factory.protoOf(iframe), .load) catch |err| {
log.err(.frame, "iframe queue load", .{ .err = err, .url = iframe._src });
};
if (delays_load) {
@@ -2168,7 +2168,7 @@ pub fn loadExternalStylesheet(self: *Frame, link: *Element.Html.Link, href: []co
// this feature is disabled by default, and can be turned on via a command
// line flag or via an CDP command
if (session.load_external_stylesheets == false) {
- return self.queueLoad(link._proto);
+ return self.queueLoad(Factory.protoOf(link));
}
// Fragment-parsed links (innerHTML, DOMParser, ...) may not be attached.
diff --git a/src/browser/frame/node_factory.zig b/src/browser/frame/node_factory.zig
index eba49eb94..f4ee58df2 100644
--- a/src/browser/frame/node_factory.zig
+++ b/src/browser/frame/node_factory.zig
@@ -50,42 +50,42 @@ pub fn createElementNS(frame: *Frame, namespace: Element.Namespace, name: []cons
Element.Html.Paragraph,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
'a' => return createHtmlElementT(
frame,
Element.Html.Anchor,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
'b' => return createHtmlElementT(
frame,
Element.Html.Generic,
namespace,
attribute_iterator,
- .{ ._proto = undefined, ._tag_name = comptime .wrap("b"), ._tag = .b },
+ .{ ._tag_name = comptime .wrap("b"), ._tag = .b },
),
'i' => return createHtmlElementT(
frame,
Element.Html.Generic,
namespace,
attribute_iterator,
- .{ ._proto = undefined, ._tag_name = comptime .wrap("i"), ._tag = .i },
+ .{ ._tag_name = comptime .wrap("i"), ._tag = .i },
),
'q' => return createHtmlElementT(
frame,
Element.Html.Quote,
namespace,
attribute_iterator,
- .{ ._proto = undefined, ._tag_name = comptime .wrap("q"), ._tag = .quote },
+ .{ ._tag_name = comptime .wrap("q"), ._tag = .quote },
),
's' => return createHtmlElementT(
frame,
Element.Html.Generic,
namespace,
attribute_iterator,
- .{ ._proto = undefined, ._tag_name = comptime .wrap("s"), ._tag = .s },
+ .{ ._tag_name = comptime .wrap("s"), ._tag = .s },
),
else => {},
},
@@ -95,126 +95,126 @@ pub fn createElementNS(frame: *Frame, namespace: Element.Namespace, name: []cons
Element.Html.BR,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("ol") => return createHtmlElementT(
frame,
Element.Html.OL,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("ul") => return createHtmlElementT(
frame,
Element.Html.UL,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("li") => return createHtmlElementT(
frame,
Element.Html.LI,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("h1") => return createHtmlElementT(
frame,
Element.Html.Heading,
namespace,
attribute_iterator,
- .{ ._proto = undefined, ._tag_name = comptime .wrap("h1"), ._tag = .h1 },
+ .{ ._tag_name = comptime .wrap("h1"), ._tag = .h1 },
),
asUint("h2") => return createHtmlElementT(
frame,
Element.Html.Heading,
namespace,
attribute_iterator,
- .{ ._proto = undefined, ._tag_name = comptime .wrap("h2"), ._tag = .h2 },
+ .{ ._tag_name = comptime .wrap("h2"), ._tag = .h2 },
),
asUint("h3") => return createHtmlElementT(
frame,
Element.Html.Heading,
namespace,
attribute_iterator,
- .{ ._proto = undefined, ._tag_name = comptime .wrap("h3"), ._tag = .h3 },
+ .{ ._tag_name = comptime .wrap("h3"), ._tag = .h3 },
),
asUint("h4") => return createHtmlElementT(
frame,
Element.Html.Heading,
namespace,
attribute_iterator,
- .{ ._proto = undefined, ._tag_name = comptime .wrap("h4"), ._tag = .h4 },
+ .{ ._tag_name = comptime .wrap("h4"), ._tag = .h4 },
),
asUint("h5") => return createHtmlElementT(
frame,
Element.Html.Heading,
namespace,
attribute_iterator,
- .{ ._proto = undefined, ._tag_name = comptime .wrap("h5"), ._tag = .h5 },
+ .{ ._tag_name = comptime .wrap("h5"), ._tag = .h5 },
),
asUint("h6") => return createHtmlElementT(
frame,
Element.Html.Heading,
namespace,
attribute_iterator,
- .{ ._proto = undefined, ._tag_name = comptime .wrap("h6"), ._tag = .h6 },
+ .{ ._tag_name = comptime .wrap("h6"), ._tag = .h6 },
),
asUint("hr") => return createHtmlElementT(
frame,
Element.Html.HR,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("em") => return createHtmlElementT(
frame,
Element.Html.Generic,
namespace,
attribute_iterator,
- .{ ._proto = undefined, ._tag_name = comptime .wrap("em"), ._tag = .em },
+ .{ ._tag_name = comptime .wrap("em"), ._tag = .em },
),
asUint("dd") => return createHtmlElementT(
frame,
Element.Html.Generic,
namespace,
attribute_iterator,
- .{ ._proto = undefined, ._tag_name = comptime .wrap("dd"), ._tag = .dd },
+ .{ ._tag_name = comptime .wrap("dd"), ._tag = .dd },
),
asUint("dl") => return createHtmlElementT(
frame,
Element.Html.DList,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("dt") => return createHtmlElementT(
frame,
Element.Html.Generic,
namespace,
attribute_iterator,
- .{ ._proto = undefined, ._tag_name = comptime .wrap("dt"), ._tag = .dt },
+ .{ ._tag_name = comptime .wrap("dt"), ._tag = .dt },
),
asUint("td") => return createHtmlElementT(
frame,
Element.Html.TableCell,
namespace,
attribute_iterator,
- .{ ._proto = undefined, ._tag_name = comptime .wrap("td"), ._tag = .td },
+ .{ ._tag_name = comptime .wrap("td"), ._tag = .td },
),
asUint("th") => return createHtmlElementT(
frame,
Element.Html.TableCell,
namespace,
attribute_iterator,
- .{ ._proto = undefined, ._tag_name = comptime .wrap("th"), ._tag = .th },
+ .{ ._tag_name = comptime .wrap("th"), ._tag = .th },
),
asUint("tr") => return createHtmlElementT(
frame,
Element.Html.TableRow,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
else => {},
},
@@ -224,84 +224,84 @@ pub fn createElementNS(frame: *Frame, namespace: Element.Namespace, name: []cons
Element.Html.Div,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("img") => return createHtmlElementT(
frame,
Element.Html.Image,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("nav") => return createHtmlElementT(
frame,
Element.Html.Generic,
namespace,
attribute_iterator,
- .{ ._proto = undefined, ._tag_name = comptime .wrap("nav"), ._tag = .nav },
+ .{ ._tag_name = comptime .wrap("nav"), ._tag = .nav },
),
asUint("del") => return createHtmlElementT(
frame,
Element.Html.Mod,
namespace,
attribute_iterator,
- .{ ._proto = undefined, ._tag_name = comptime .wrap("del"), ._tag = .del },
+ .{ ._tag_name = comptime .wrap("del"), ._tag = .del },
),
asUint("ins") => return createHtmlElementT(
frame,
Element.Html.Mod,
namespace,
attribute_iterator,
- .{ ._proto = undefined, ._tag_name = comptime .wrap("ins"), ._tag = .ins },
+ .{ ._tag_name = comptime .wrap("ins"), ._tag = .ins },
),
asUint("col") => return createHtmlElementT(
frame,
Element.Html.TableCol,
namespace,
attribute_iterator,
- .{ ._proto = undefined, ._tag_name = comptime .wrap("col"), ._tag = .col },
+ .{ ._tag_name = comptime .wrap("col"), ._tag = .col },
),
asUint("dir") => return createHtmlElementT(
frame,
Element.Html.Directory,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("map") => return createHtmlElementT(
frame,
Element.Html.Map,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("pre") => return createHtmlElementT(
frame,
Element.Html.Pre,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("sub") => return createHtmlElementT(
frame,
Element.Html.Generic,
namespace,
attribute_iterator,
- .{ ._proto = undefined, ._tag_name = comptime .wrap("sub"), ._tag = .sub },
+ .{ ._tag_name = comptime .wrap("sub"), ._tag = .sub },
),
asUint("sup") => return createHtmlElementT(
frame,
Element.Html.Generic,
namespace,
attribute_iterator,
- .{ ._proto = undefined, ._tag_name = comptime .wrap("sup"), ._tag = .sup },
+ .{ ._tag_name = comptime .wrap("sup"), ._tag = .sup },
),
asUint("dfn") => return createHtmlElementT(
frame,
Element.Html.Generic,
namespace,
attribute_iterator,
- .{ ._proto = undefined, ._tag_name = comptime .wrap("dfn"), ._tag = .dfn },
+ .{ ._tag_name = comptime .wrap("dfn"), ._tag = .dfn },
),
else => {},
},
@@ -311,35 +311,35 @@ pub fn createElementNS(frame: *Frame, namespace: Element.Namespace, name: []cons
Element.Html.Span,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("meta") => return createHtmlElementT(
frame,
Element.Html.Meta,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("link") => return createHtmlElementT(
frame,
Element.Html.Link,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("slot") => return createHtmlElementT(
frame,
Element.Html.Slot,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("html") => return createHtmlElementT(
frame,
Element.Html.Html,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("head") => {
// Inject user-provided scripts.
@@ -368,7 +368,7 @@ pub fn createElementNS(frame: *Frame, namespace: Element.Namespace, name: []cons
Element.Html.Head,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
);
},
asUint("body") => return createHtmlElementT(
@@ -376,28 +376,28 @@ pub fn createElementNS(frame: *Frame, namespace: Element.Namespace, name: []cons
Element.Html.Body,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("form") => return createHtmlElementT(
frame,
Element.Html.Form,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("main") => return createHtmlElementT(
frame,
Element.Html.Generic,
namespace,
attribute_iterator,
- .{ ._proto = undefined, ._tag_name = comptime .wrap("main"), ._tag = .main },
+ .{ ._tag_name = comptime .wrap("main"), ._tag = .main },
),
asUint("data") => return createHtmlElementT(
frame,
Element.Html.Data,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("base") => {
const n = try createHtmlElementT(
@@ -405,7 +405,7 @@ pub fn createElementNS(frame: *Frame, namespace: Element.Namespace, name: []cons
Element.Html.Base,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
);
// If frames's base url is not already set, fill it with
@@ -423,35 +423,35 @@ pub fn createElementNS(frame: *Frame, namespace: Element.Namespace, name: []cons
Element.Html.Generic,
namespace,
attribute_iterator,
- .{ ._proto = undefined, ._tag_name = comptime .wrap("menu"), ._tag = .menu },
+ .{ ._tag_name = comptime .wrap("menu"), ._tag = .menu },
),
asUint("area") => return createHtmlElementT(
frame,
Element.Html.Area,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("font") => return createHtmlElementT(
frame,
Element.Html.Font,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("code") => return createHtmlElementT(
frame,
Element.Html.Generic,
namespace,
attribute_iterator,
- .{ ._proto = undefined, ._tag_name = comptime .wrap("code"), ._tag = .code },
+ .{ ._tag_name = comptime .wrap("code"), ._tag = .code },
),
asUint("time") => return createHtmlElementT(
frame,
Element.Html.Time,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
else => {},
},
@@ -461,28 +461,28 @@ pub fn createElementNS(frame: *Frame, namespace: Element.Namespace, name: []cons
Element.Html.Input,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("style") => return createHtmlElementT(
frame,
Element.Html.Style,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("title") => return createHtmlElementT(
frame,
Element.Html.Title,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("embed") => return createHtmlElementT(
frame,
Element.Html.Embed,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("audio") => return createHtmlMediaElementT(
frame,
@@ -501,63 +501,63 @@ pub fn createElementNS(frame: *Frame, namespace: Element.Namespace, name: []cons
Element.Html.Generic,
namespace,
attribute_iterator,
- .{ ._proto = undefined, ._tag_name = comptime .wrap("aside"), ._tag = .aside },
+ .{ ._tag_name = comptime .wrap("aside"), ._tag = .aside },
),
asUint("label") => return createHtmlElementT(
frame,
Element.Html.Label,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("meter") => return createHtmlElementT(
frame,
Element.Html.Meter,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("param") => return createHtmlElementT(
frame,
Element.Html.Param,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("table") => return createHtmlElementT(
frame,
Element.Html.Table,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("thead") => return createHtmlElementT(
frame,
Element.Html.TableSection,
namespace,
attribute_iterator,
- .{ ._proto = undefined, ._tag_name = comptime .wrap("thead"), ._tag = .thead },
+ .{ ._tag_name = comptime .wrap("thead"), ._tag = .thead },
),
asUint("tbody") => return createHtmlElementT(
frame,
Element.Html.TableSection,
namespace,
attribute_iterator,
- .{ ._proto = undefined, ._tag_name = comptime .wrap("tbody"), ._tag = .tbody },
+ .{ ._tag_name = comptime .wrap("tbody"), ._tag = .tbody },
),
asUint("tfoot") => return createHtmlElementT(
frame,
Element.Html.TableSection,
namespace,
attribute_iterator,
- .{ ._proto = undefined, ._tag_name = comptime .wrap("tfoot"), ._tag = .tfoot },
+ .{ ._tag_name = comptime .wrap("tfoot"), ._tag = .tfoot },
),
asUint("track") => return createHtmlElementT(
frame,
Element.Html.Track,
namespace,
attribute_iterator,
- .{ ._proto = undefined, ._kind = comptime .wrap("subtitles"), ._ready_state = .none },
+ .{ ._kind = comptime .wrap("subtitles"), ._ready_state = .none },
),
else => {},
},
@@ -567,112 +567,112 @@ pub fn createElementNS(frame: *Frame, namespace: Element.Namespace, name: []cons
Element.Html.Script,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("button") => return createHtmlElementT(
frame,
Element.Html.Button,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("canvas") => return createHtmlElementT(
frame,
Element.Html.Canvas,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("dialog") => return createHtmlElementT(
frame,
Element.Html.Dialog,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("legend") => return createHtmlElementT(
frame,
Element.Html.Legend,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("object") => return createHtmlElementT(
frame,
Element.Html.Object,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("output") => return createHtmlElementT(
frame,
Element.Html.Output,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("source") => return createHtmlElementT(
frame,
Element.Html.Source,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("strong") => return createHtmlElementT(
frame,
Element.Html.Generic,
namespace,
attribute_iterator,
- .{ ._proto = undefined, ._tag_name = comptime .wrap("strong"), ._tag = .strong },
+ .{ ._tag_name = comptime .wrap("strong"), ._tag = .strong },
),
asUint("header") => return createHtmlElementT(
frame,
Element.Html.Generic,
namespace,
attribute_iterator,
- .{ ._proto = undefined, ._tag_name = comptime .wrap("header"), ._tag = .header },
+ .{ ._tag_name = comptime .wrap("header"), ._tag = .header },
),
asUint("footer") => return createHtmlElementT(
frame,
Element.Html.Generic,
namespace,
attribute_iterator,
- .{ ._proto = undefined, ._tag_name = comptime .wrap("footer"), ._tag = .footer },
+ .{ ._tag_name = comptime .wrap("footer"), ._tag = .footer },
),
asUint("select") => return createHtmlElementT(
frame,
Element.Html.Select,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("option") => return createHtmlElementT(
frame,
Element.Html.Option,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("iframe") => return createHtmlElementT(
frame,
IFrame,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("figure") => return createHtmlElementT(
frame,
Element.Html.Generic,
namespace,
attribute_iterator,
- .{ ._proto = undefined, ._tag_name = comptime .wrap("figure"), ._tag = .figure },
+ .{ ._tag_name = comptime .wrap("figure"), ._tag = .figure },
),
asUint("hgroup") => return createHtmlElementT(
frame,
Element.Html.Generic,
namespace,
attribute_iterator,
- .{ ._proto = undefined, ._tag_name = comptime .wrap("hgroup"), ._tag = .hgroup },
+ .{ ._tag_name = comptime .wrap("hgroup"), ._tag = .hgroup },
),
else => {},
},
@@ -682,56 +682,56 @@ pub fn createElementNS(frame: *Frame, namespace: Element.Namespace, name: []cons
Element.Html.Generic,
namespace,
attribute_iterator,
- .{ ._proto = undefined, ._tag_name = comptime .wrap("section"), ._tag = .section },
+ .{ ._tag_name = comptime .wrap("section"), ._tag = .section },
),
asUint("article") => return createHtmlElementT(
frame,
Element.Html.Generic,
namespace,
attribute_iterator,
- .{ ._proto = undefined, ._tag_name = comptime .wrap("article"), ._tag = .article },
+ .{ ._tag_name = comptime .wrap("article"), ._tag = .article },
),
asUint("details") => return createHtmlElementT(
frame,
Element.Html.Details,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("summary") => return createHtmlElementT(
frame,
Element.Html.Generic,
namespace,
attribute_iterator,
- .{ ._proto = undefined, ._tag_name = comptime .wrap("summary"), ._tag = .summary },
+ .{ ._tag_name = comptime .wrap("summary"), ._tag = .summary },
),
asUint("caption") => return createHtmlElementT(
frame,
Element.Html.TableCaption,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("marquee") => return createHtmlElementT(
frame,
Element.Html.Marquee,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("address") => return createHtmlElementT(
frame,
Element.Html.Generic,
namespace,
attribute_iterator,
- .{ ._proto = undefined, ._tag_name = comptime .wrap("address"), ._tag = .address },
+ .{ ._tag_name = comptime .wrap("address"), ._tag = .address },
),
asUint("picture") => return createHtmlElementT(
frame,
Element.Html.Picture,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
else => {},
},
@@ -741,28 +741,28 @@ pub fn createElementNS(frame: *Frame, namespace: Element.Namespace, name: []cons
Element.Html.TextArea,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("template") => return createHtmlElementT(
frame,
Element.Html.Template,
namespace,
attribute_iterator,
- .{ ._proto = undefined, ._content = undefined },
+ .{ ._content = undefined },
),
asUint("colgroup") => return createHtmlElementT(
frame,
Element.Html.TableCol,
namespace,
attribute_iterator,
- .{ ._proto = undefined, ._tag_name = comptime .wrap("colgroup"), ._tag = .colgroup },
+ .{ ._tag_name = comptime .wrap("colgroup"), ._tag = .colgroup },
),
asUint("fieldset") => return createHtmlElementT(
frame,
Element.Html.FieldSet,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("frameset") => {
if (comptime from_parser) {
@@ -773,7 +773,7 @@ pub fn createElementNS(frame: *Frame, namespace: Element.Namespace, name: []cons
Element.Html.FrameSet,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
);
},
asUint("optgroup") => return createHtmlElementT(
@@ -781,28 +781,28 @@ pub fn createElementNS(frame: *Frame, namespace: Element.Namespace, name: []cons
Element.Html.OptGroup,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("progress") => return createHtmlElementT(
frame,
Element.Html.Progress,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("datalist") => return createHtmlElementT(
frame,
Element.Html.DataList,
namespace,
attribute_iterator,
- .{ ._proto = undefined },
+ .{},
),
asUint("noscript") => return createHtmlElementT(
frame,
Element.Html.Generic,
namespace,
attribute_iterator,
- .{ ._proto = undefined, ._tag_name = comptime .wrap("noscript"), ._tag = .noscript },
+ .{ ._tag_name = comptime .wrap("noscript"), ._tag = .noscript },
),
else => {},
},
@@ -812,7 +812,7 @@ pub fn createElementNS(frame: *Frame, namespace: Element.Namespace, name: []cons
Element.Html.Quote,
namespace,
attribute_iterator,
- .{ ._proto = undefined, ._tag_name = comptime .wrap("blockquote"), ._tag = .blockquote },
+ .{ ._tag_name = comptime .wrap("blockquote"), ._tag = .blockquote },
),
else => {},
},
@@ -832,7 +832,6 @@ pub fn createElementNS(frame: *Frame, namespace: Element.Namespace, name: []cons
// upgraded later, when a matching definition is registered.
if (frame._skip_custom_element_upgrade or definition == null) {
const node = try createHtmlElementT(frame, Element.Html.Custom, namespace, attribute_iterator, .{
- ._proto = undefined,
._tag_name = tag_name,
._definition = definition,
});
@@ -847,7 +846,6 @@ pub fn createElementNS(frame: *Frame, namespace: Element.Namespace, name: []cons
const constructed = constructForToken(frame, definition.?, tag_name, from_parser) catch {
// Construction failed, we fallback to HTMLUnknownElement
return createHtmlElementT(frame, Element.Html.Unknown, namespace, attribute_iterator, .{
- ._proto = undefined,
._tag_name = tag_name,
});
};
@@ -869,7 +867,7 @@ pub fn createElementNS(frame: *Frame, namespace: Element.Namespace, name: []cons
return constructed.asNode();
}
- return createHtmlElementT(frame, Element.Html.Unknown, namespace, attribute_iterator, .{ ._proto = undefined, ._tag_name = tag_name });
+ return createHtmlElementT(frame, Element.Html.Unknown, namespace, attribute_iterator, .{ ._tag_name = tag_name });
},
.svg => {
const Graphics = Element.Svg.Graphics;
@@ -877,60 +875,60 @@ pub fn createElementNS(frame: *Frame, namespace: Element.Namespace, name: []cons
// SVG tag names are case-sensitive; no lowering before matching.
switch (name.len) {
1 => switch (name[0]) {
- 'g' => return createSvgElementT(frame, Graphics.G, name, attribute_iterator, .{ ._proto = undefined }),
- 'a' => return createSvgElementT(frame, Graphics.A, name, attribute_iterator, .{ ._proto = undefined }),
+ 'g' => return createSvgElementT(frame, Graphics.G, name, attribute_iterator, .{}),
+ 'a' => return createSvgElementT(frame, Graphics.A, name, attribute_iterator, .{}),
else => {},
},
3 => switch (@as(u24, @bitCast(name[0..3].*))) {
- asUint("svg") => return createSvgElementT(frame, Graphics.Svg, name, attribute_iterator, .{ ._proto = undefined }),
- asUint("use") => return createSvgElementT(frame, Graphics.Use, name, attribute_iterator, .{ ._proto = undefined }),
+ asUint("svg") => return createSvgElementT(frame, Graphics.Svg, name, attribute_iterator, .{}),
+ asUint("use") => return createSvgElementT(frame, Graphics.Use, name, attribute_iterator, .{}),
else => {},
},
4 => switch (@as(u32, @bitCast(name[0..4].*))) {
- asUint("defs") => return createSvgElementT(frame, Graphics.Defs, name, attribute_iterator, .{ ._proto = undefined }),
- asUint("desc") => return createSvgElementT(frame, Element.Svg.Desc, name, attribute_iterator, .{ ._proto = undefined }),
- asUint("mask") => return createSvgElementT(frame, Element.Svg.Mask, name, attribute_iterator, .{ ._proto = undefined }),
- asUint("rect") => return createSvgElementT(frame, Geometry.Rect, name, attribute_iterator, .{ ._proto = undefined }),
- asUint("stop") => return createSvgElementT(frame, Element.Svg.Stop, name, attribute_iterator, .{ ._proto = undefined }),
- asUint("text") => return createSvgElementT(frame, Graphics.TextContent.TextPositioning.Text, name, attribute_iterator, .{ ._proto = undefined }),
- asUint("line") => return createSvgElementT(frame, Geometry.Line, name, attribute_iterator, .{ ._proto = undefined }),
- asUint("path") => return createSvgElementT(frame, Geometry.Path, name, attribute_iterator, .{ ._proto = undefined }),
- asUint("view") => return createSvgElementT(frame, Element.Svg.View, name, attribute_iterator, .{ ._proto = undefined }),
+ asUint("defs") => return createSvgElementT(frame, Graphics.Defs, name, attribute_iterator, .{}),
+ asUint("desc") => return createSvgElementT(frame, Element.Svg.Desc, name, attribute_iterator, .{}),
+ asUint("mask") => return createSvgElementT(frame, Element.Svg.Mask, name, attribute_iterator, .{}),
+ asUint("rect") => return createSvgElementT(frame, Geometry.Rect, name, attribute_iterator, .{}),
+ asUint("stop") => return createSvgElementT(frame, Element.Svg.Stop, name, attribute_iterator, .{}),
+ asUint("text") => return createSvgElementT(frame, Graphics.TextContent.TextPositioning.Text, name, attribute_iterator, .{}),
+ asUint("line") => return createSvgElementT(frame, Geometry.Line, name, attribute_iterator, .{}),
+ asUint("path") => return createSvgElementT(frame, Geometry.Path, name, attribute_iterator, .{}),
+ asUint("view") => return createSvgElementT(frame, Element.Svg.View, name, attribute_iterator, .{}),
else => {},
},
5 => switch (@as(u40, @bitCast(name[0..5].*))) {
- asUint("image") => return createSvgElementT(frame, Graphics.Image, name, attribute_iterator, .{ ._proto = undefined }),
- asUint("title") => return createSvgElementT(frame, Element.Svg.Title, name, attribute_iterator, .{ ._proto = undefined }),
- asUint("tspan") => return createSvgElementT(frame, Graphics.TextContent.TextPositioning.TSpan, name, attribute_iterator, .{ ._proto = undefined }),
+ asUint("image") => return createSvgElementT(frame, Graphics.Image, name, attribute_iterator, .{}),
+ asUint("title") => return createSvgElementT(frame, Element.Svg.Title, name, attribute_iterator, .{}),
+ asUint("tspan") => return createSvgElementT(frame, Graphics.TextContent.TextPositioning.TSpan, name, attribute_iterator, .{}),
else => {},
},
6 => switch (@as(u48, @bitCast(name[0..6].*))) {
- asUint("circle") => return createSvgElementT(frame, Geometry.Circle, name, attribute_iterator, .{ ._proto = undefined }),
- asUint("marker") => return createSvgElementT(frame, Element.Svg.Marker, name, attribute_iterator, .{ ._proto = undefined }),
- asUint("switch") => return createSvgElementT(frame, Graphics.Switch, name, attribute_iterator, .{ ._proto = undefined }),
- asUint("symbol") => return createSvgElementT(frame, Graphics.Symbol, name, attribute_iterator, .{ ._proto = undefined }),
+ asUint("circle") => return createSvgElementT(frame, Geometry.Circle, name, attribute_iterator, .{}),
+ asUint("marker") => return createSvgElementT(frame, Element.Svg.Marker, name, attribute_iterator, .{}),
+ asUint("switch") => return createSvgElementT(frame, Graphics.Switch, name, attribute_iterator, .{}),
+ asUint("symbol") => return createSvgElementT(frame, Graphics.Symbol, name, attribute_iterator, .{}),
else => {},
},
7 => switch (@as(u56, @bitCast(name[0..7].*))) {
- asUint("ellipse") => return createSvgElementT(frame, Geometry.Ellipse, name, attribute_iterator, .{ ._proto = undefined }),
- asUint("pattern") => return createSvgElementT(frame, Element.Svg.Pattern, name, attribute_iterator, .{ ._proto = undefined }),
- asUint("polygon") => return createSvgElementT(frame, Geometry.Polygon, name, attribute_iterator, .{ ._proto = undefined }),
+ asUint("ellipse") => return createSvgElementT(frame, Geometry.Ellipse, name, attribute_iterator, .{}),
+ asUint("pattern") => return createSvgElementT(frame, Element.Svg.Pattern, name, attribute_iterator, .{}),
+ asUint("polygon") => return createSvgElementT(frame, Geometry.Polygon, name, attribute_iterator, .{}),
else => {},
},
8 => switch (@as(u64, @bitCast(name[0..8].*))) {
- asUint("clipPath") => return createSvgElementT(frame, Element.Svg.ClipPath, name, attribute_iterator, .{ ._proto = undefined }),
- asUint("metadata") => return createSvgElementT(frame, Element.Svg.Metadata, name, attribute_iterator, .{ ._proto = undefined }),
- asUint("polyline") => return createSvgElementT(frame, Geometry.Polyline, name, attribute_iterator, .{ ._proto = undefined }),
- asUint("textPath") => return createSvgElementT(frame, Graphics.TextContent.TextPath, name, attribute_iterator, .{ ._proto = undefined }),
+ asUint("clipPath") => return createSvgElementT(frame, Element.Svg.ClipPath, name, attribute_iterator, .{}),
+ asUint("metadata") => return createSvgElementT(frame, Element.Svg.Metadata, name, attribute_iterator, .{}),
+ asUint("polyline") => return createSvgElementT(frame, Geometry.Polyline, name, attribute_iterator, .{}),
+ asUint("textPath") => return createSvgElementT(frame, Graphics.TextContent.TextPath, name, attribute_iterator, .{}),
else => {},
},
13 => switch (@as(u104, @bitCast(name[0..13].*))) {
- asUint("foreignObject") => return createSvgElementT(frame, Graphics.ForeignObject, name, attribute_iterator, .{ ._proto = undefined }),
+ asUint("foreignObject") => return createSvgElementT(frame, Graphics.ForeignObject, name, attribute_iterator, .{}),
else => {},
},
14 => switch (@as(u112, @bitCast(name[0..14].*))) {
- asUint("linearGradient") => return createSvgElementT(frame, Element.Svg.GradientElement.LinearGradient, name, attribute_iterator, .{ ._proto = undefined }),
- asUint("radialGradient") => return createSvgElementT(frame, Element.Svg.GradientElement.RadialGradient, name, attribute_iterator, .{ ._proto = undefined }),
+ asUint("linearGradient") => return createSvgElementT(frame, Element.Svg.GradientElement.LinearGradient, name, attribute_iterator, .{}),
+ asUint("radialGradient") => return createSvgElementT(frame, Element.Svg.GradientElement.RadialGradient, name, attribute_iterator, .{}),
else => {},
},
else => {},
@@ -938,11 +936,11 @@ pub fn createElementNS(frame: *Frame, namespace: Element.Namespace, name: []cons
const lower = std.ascii.lowerString(&frame.buf, name);
const tag = std.meta.stringToEnum(Element.Tag, lower) orelse .unknown;
- return createSvgElementT(frame, Element.Svg.Generic, name, attribute_iterator, .{ ._proto = undefined, ._tag = tag });
+ return createSvgElementT(frame, Element.Svg.Generic, name, attribute_iterator, .{ ._tag = tag });
},
else => {
const tag_name = try String.init(frame.arena, name, .{});
- return createHtmlElementT(frame, Element.Html.Unknown, namespace, attribute_iterator, .{ ._proto = undefined, ._tag_name = tag_name });
+ return createHtmlElementT(frame, Element.Html.Unknown, namespace, attribute_iterator, .{ ._tag_name = tag_name });
},
}
}
@@ -1023,7 +1021,7 @@ fn createHtmlElementT(frame: *Frame, comptime E: type, namespace: Element.Namesp
}
fn createHtmlMediaElementT(frame: *Frame, comptime E: type, namespace: Element.Namespace, attribute_iterator: anytype) !*Node {
- const media_element = try frame._factory.htmlMediaElement(E{ ._proto = undefined });
+ const media_element = try frame._factory.htmlMediaElement(E{});
const element = media_element.asElement();
element._namespace = namespace;
try populateElementAttributes(frame, element, attribute_iterator);
@@ -1085,7 +1083,6 @@ pub fn constructCustomElement(frame: *Frame, new_target: JS.Function) !*Element
const tag_name = try String.init(frame.arena, definition.name, .{});
const node = try createHtmlElementT(frame, Element.Html.Custom, .html, null, .{
- ._proto = undefined,
._tag_name = tag_name,
._definition = definition,
});
@@ -1096,7 +1093,7 @@ pub fn createTextNode(frame: *Frame, text: []const u8) !*Node {
const cd = try frame._factory.cdataNode(.{
._type = .text,
._data = try frame.dupeSSO(text),
- }, CData.Text{ ._proto = undefined });
+ }, CData.Text{});
return cd.asNode();
}
@@ -1104,7 +1101,7 @@ pub fn createComment(frame: *Frame, text: []const u8) !*Node {
const cd = try frame._factory.cdataNode(.{
._type = .comment,
._data = try frame.dupeSSO(text),
- }, CData.Comment{ ._proto = undefined });
+ }, CData.Comment{});
return cd.asNode();
}
@@ -1117,7 +1114,7 @@ pub fn createCDATASection(frame: *Frame, data: []const u8) !*Node {
const cd = try frame._factory.cdataNode(.{
._type = .cdata_section,
._data = try frame.dupeSSO(data),
- }, CData.CDATASection{ ._proto = undefined });
+ }, CData.CDATASection{});
return cd.asNode();
}
@@ -1139,7 +1136,6 @@ pub fn createProcessingInstruction(frame: *Frame, target: []const u8, data: []co
._type = .processing_instruction,
._data = try frame.dupeSSO(data),
}, CData.ProcessingInstruction{
- ._proto = undefined,
._target = owned_target,
});
return cd.asNode();
diff --git a/src/browser/parser/Parser.zig b/src/browser/parser/Parser.zig
index c8d9ac364..370f65a5f 100644
--- a/src/browser/parser/Parser.zig
+++ b/src/browser/parser/Parser.zig
@@ -133,7 +133,7 @@ fn appendTextChunk(self: *Parser, parent: *Node, txt: []const u8) !void {
// Existing text sibling without a matching pending_text. Seed the
// buf from its _data and register pending so subsequent chunks
// accumulate cheaply.
- const cdata = tn._proto;
+ const cdata = tn.asCData();
const existing = cdata.getData().str();
try self.buf.ensureTotalCapacity(self.arena, existing.len + txt.len);
self.buf.appendSliceAssumeCapacity(existing);
@@ -149,7 +149,7 @@ fn appendTextChunk(self: *Parser, parent: *Node, txt: []const u8) !void {
try self.frame.appendNew(parent, new_text);
self.pending_text = .{
.parent = parent,
- .text_node = new_text.is(CData.Text).?._proto,
+ .text_node = new_text.is(CData.Text).?.asCData(),
};
}
diff --git a/src/browser/webapi/CData.zig b/src/browser/webapi/CData.zig
index 674472142..4eeab1337 100644
--- a/src/browser/webapi/CData.zig
+++ b/src/browser/webapi/CData.zig
@@ -77,9 +77,9 @@ pub fn subtype(self: *const CData, comptime T: type) *T {
// the arithmetic rides on factory-chain contiguity; the stored
// back-pointer doubles as its canary
if (comptime T == CDATASection) {
- std.debug.assert(sub._proto._proto == self);
+ std.debug.assert(sub._proto_canary._proto_canary == self);
} else {
- std.debug.assert(sub._proto == self);
+ std.debug.assert(sub._proto_canary == self);
}
}
return sub;
diff --git a/src/browser/webapi/Node.zig b/src/browser/webapi/Node.zig
index cb6f038d7..f2604ab02 100644
--- a/src/browser/webapi/Node.zig
+++ b/src/browser/webapi/Node.zig
@@ -464,7 +464,7 @@ pub fn getChildTextContent(self: *Node, writer: *std.Io.Writer) error{WriteFaile
var it = self.childrenIterator();
while (it.next()) |child| {
if (child.is(CData.Text)) |text| {
- try writer.writeAll(text._proto._data.str());
+ try writer.writeAll(text.asCData()._data.str());
}
}
}
@@ -476,7 +476,7 @@ pub fn childTextContentLen(self: *Node) usize {
var it = self.childrenIterator();
while (it.next()) |child| {
if (child.is(CData.Text)) |text| {
- len += text._proto._data.str().len;
+ len += text.asCData()._data.str().len;
}
}
return len;
@@ -1389,7 +1389,7 @@ fn _normalize(self: *Node, allocator: Allocator, buffer: *std.ArrayList(u8), fra
continue;
};
- if (text_node._proto.getData().len == 0) {
+ if (text_node.asCData().getData().len == 0) {
frame.removeNode(self, current_node, .{ .will_be_reconnected = false });
child = next_node;
continue;
@@ -1407,7 +1407,7 @@ fn _normalize(self: *Node, allocator: Allocator, buffer: *std.ArrayList(u8), fra
next_node = node_to_merge.nextSibling();
frame.removeNode(self, to_remove, .{ .will_be_reconnected = false });
}
- text_node._proto._data = try frame.dupeSSO(buffer.items);
+ text_node.asCData()._data = try frame.dupeSSO(buffer.items);
buffer.clearRetainingCapacity();
}
}
diff --git a/src/browser/webapi/Range.zig b/src/browser/webapi/Range.zig
index 30da788d6..6b6978ded 100644
--- a/src/browser/webapi/Range.zig
+++ b/src/browser/webapi/Range.zig
@@ -364,7 +364,7 @@ pub fn insertNode(self: *Range, node: *Node, frame: *Frame) !void {
// records browsers do (one for the split-off node, one for
// the inserted node).
const second = try t.splitText(offset, frame);
- _ = try parent.insertBefore(node, second._proto.asNode(), frame);
+ _ = try parent.insertBefore(node, second.asCData().asNode(), frame);
} else {
_ = try parent.insertBefore(node, container.nextSibling(), frame);
}
diff --git a/src/browser/webapi/cdata/CDATASection.zig b/src/browser/webapi/cdata/CDATASection.zig
index ed638c172..f775b1dae 100644
--- a/src/browser/webapi/cdata/CDATASection.zig
+++ b/src/browser/webapi/cdata/CDATASection.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+
const js = @import("../../js/js.zig");
const Text = @import("Text.zig");
@@ -24,7 +26,8 @@ const CDATASection = @This();
pub const Proto = Text;
-_proto: *Text,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *Text else void = undefined,
pub const JsApi = struct {
pub const bridge = js.Bridge(CDATASection);
diff --git a/src/browser/webapi/cdata/Comment.zig b/src/browser/webapi/cdata/Comment.zig
index 0ceb91c04..37ea7d2e2 100644
--- a/src/browser/webapi/cdata/Comment.zig
+++ b/src/browser/webapi/cdata/Comment.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+
const js = @import("../../js/js.zig");
const Frame = @import("../../Frame.zig");
@@ -25,7 +27,8 @@ const Comment = @This();
pub const Proto = CData;
-_proto: *CData,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *CData else void = undefined,
pub fn init(str: ?js.NullableString, frame: *Frame) !*Comment {
const node = try Frame.node_factory.createComment(frame, if (str) |s| s.value else "");
diff --git a/src/browser/webapi/cdata/ProcessingInstruction.zig b/src/browser/webapi/cdata/ProcessingInstruction.zig
index 3c57238f6..5c5ea3ff9 100644
--- a/src/browser/webapi/cdata/ProcessingInstruction.zig
+++ b/src/browser/webapi/cdata/ProcessingInstruction.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+
const js = @import("../../js/js.zig");
const CData = @import("../CData.zig");
@@ -24,7 +26,7 @@ const ProcessingInstruction = @This();
pub const Proto = CData;
-_proto: *CData,
+_proto_canary: if (lp.IS_DEBUG) *CData else void = undefined,
_target: []const u8,
pub fn getTarget(self: *const ProcessingInstruction) []const u8 {
diff --git a/src/browser/webapi/cdata/Text.zig b/src/browser/webapi/cdata/Text.zig
index 91300f850..e27a61590 100644
--- a/src/browser/webapi/cdata/Text.zig
+++ b/src/browser/webapi/cdata/Text.zig
@@ -17,8 +17,10 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
const std = @import("std");
+const lp = @import("lightpanda");
const js = @import("../../js/js.zig");
+const Factory = @import("../../Factory.zig");
const Frame = @import("../../Frame.zig");
const Node = @import("../Node.zig");
const CData = @import("../CData.zig");
@@ -29,7 +31,13 @@ const Text = @This();
pub const Proto = CData;
-_proto: *CData,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *CData else void = undefined,
+
+// Takes a const text but returns a mutable proto; see Node.subtype.
+pub fn asCData(self: *const Text) *CData {
+ return Factory.protoOf(self);
+}
pub fn init(str: ?js.NullableString, frame: *Frame) !*Text {
const node = try Frame.node_factory.createTextNode(frame, if (str) |s| s.value else "");
@@ -38,13 +46,13 @@ pub fn init(str: ?js.NullableString, frame: *Frame) !*Text {
// This Text node's own data (getWholeText below spans adjacent Text nodes).
pub fn ownData(self: *const Text) []const u8 {
- return self._proto._data.str();
+ return Factory.protoOf(self)._data.str();
}
// The concatenated data of the contiguous exclusive Text nodes (adjacent
// Text siblings on both sides of this one), in tree order.
pub fn getWholeText(self: *Text, frame: *Frame) ![]const u8 {
- const node = self._proto.asNode();
+ const node = Factory.protoOf(self).asNode();
var first = node;
while (first.previousSibling()) |prev| {
@@ -57,7 +65,7 @@ pub fn getWholeText(self: *Text, frame: *Frame) ![]const u8 {
// Common case: no adjacent text nodes, return our data directly.
const has_next_text = if (node.nextSibling()) |next| isExclusiveTextNode(next) else false;
if (first == node and !has_next_text) {
- return self._proto._data.str();
+ return Factory.protoOf(self)._data.str();
}
var buf: std.ArrayList(u8) = .empty;
@@ -74,11 +82,11 @@ fn isExclusiveTextNode(node: *Node) bool {
}
pub fn getAssignedSlot(self: *Text, frame: *Frame) ?*Slot {
- return slotting.findSlot(self._proto.asNode(), true, frame);
+ return slotting.findSlot(Factory.protoOf(self).asNode(), true, frame);
}
pub fn splitText(self: *Text, offset: usize, frame: *Frame) !*Text {
- const data = self._proto._data.str();
+ const data = Factory.protoOf(self)._data.str();
const byte_offset = CData.utf16OffsetToUtf8(data, offset) catch return error.IndexSizeError;
@@ -86,7 +94,7 @@ pub fn splitText(self: *Text, offset: usize, frame: *Frame) !*Text {
const new_node = try Frame.node_factory.createTextNode(frame, new_data);
const new_text = new_node.as(Text);
- const node = self._proto.asNode();
+ const node = Factory.protoOf(self).asNode();
// Per DOM spec splitText: insert first (step 7a), then update ranges (7b-7e),
// then truncate original node (step 8).
@@ -103,8 +111,8 @@ pub fn splitText(self: *Text, offset: usize, frame: *Frame) !*Text {
// Step 8: truncate original node via replaceData(offset, count, "").
// Use replaceData instead of setData so live range updates fire
// (matters for detached text nodes where steps 7b-7e were skipped).
- const length = self._proto.getLength();
- try self._proto.replaceData(offset, length - offset, "", frame);
+ const length = Factory.protoOf(self).getLength();
+ try Factory.protoOf(self).replaceData(offset, length - offset, "", frame);
return new_text;
}
diff --git a/src/browser/webapi/element/html/Anchor.zig b/src/browser/webapi/element/html/Anchor.zig
index 7ee163470..54563d1fe 100644
--- a/src/browser/webapi/element/html/Anchor.zig
+++ b/src/browser/webapi/element/html/Anchor.zig
@@ -16,8 +16,10 @@
// 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 lp = @import("lightpanda");
const std = @import("std");
const js = @import("../../../js/js.zig");
+const Factory = @import("../../../Factory.zig");
const Frame = @import("../../../Frame.zig");
const URL = @import("../../../URL.zig");
@@ -28,13 +30,14 @@ const HtmlElement = @import("../Html.zig");
const Anchor = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *Anchor) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asConstElement(self: *const Anchor) *const Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Anchor) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Area.zig b/src/browser/webapi/element/html/Area.zig
index 81f73ea0b..ba79696af 100644
--- a/src/browser/webapi/element/html/Area.zig
+++ b/src/browser/webapi/element/html/Area.zig
@@ -13,8 +13,10 @@
// 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 lp = @import("lightpanda");
const std = @import("std");
const js = @import("../../../js/js.zig");
+const Factory = @import("../../../Factory.zig");
const Frame = @import("../../../Frame.zig");
const URL = @import("../../../URL.zig");
@@ -28,13 +30,14 @@ const Area = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *Area) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asConstElement(self: *const Area) *const Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Area) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Audio.zig b/src/browser/webapi/element/html/Audio.zig
index 2c9f807c3..2cf152a08 100644
--- a/src/browser/webapi/element/html/Audio.zig
+++ b/src/browser/webapi/element/html/Audio.zig
@@ -19,6 +19,7 @@
const lp = @import("lightpanda");
const js = @import("../../../js/js.zig");
+const Factory = @import("../../../Factory.zig");
const Frame = @import("../../../Frame.zig");
const Node = @import("../../Node.zig");
@@ -31,7 +32,8 @@ const Audio = @This();
pub const Proto = Media;
-_proto: *Media,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *Media else void = undefined,
pub fn constructor(maybe_url: ?String, frame: *Frame) !*Media {
const node = try Frame.node_factory.createElementNS(frame, .html, "audio", null);
@@ -48,11 +50,11 @@ pub fn constructor(maybe_url: ?String, frame: *Frame) !*Media {
}
pub fn asMedia(self: *Audio) *Media {
- return self._proto;
+ return Factory.protoOf(self);
}
pub fn asElement(self: *Audio) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Audio) *Node {
diff --git a/src/browser/webapi/element/html/BR.zig b/src/browser/webapi/element/html/BR.zig
index f101d0077..2f9c67824 100644
--- a/src/browser/webapi/element/html/BR.zig
+++ b/src/browser/webapi/element/html/BR.zig
@@ -1,3 +1,5 @@
+const lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Node = @import("../../Node.zig");
const Element = @import("../../Element.zig");
@@ -7,10 +9,11 @@ const BR = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *BR) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *BR) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Base.zig b/src/browser/webapi/element/html/Base.zig
index e22bfd0fe..0e157c3e6 100644
--- a/src/browser/webapi/element/html/Base.zig
+++ b/src/browser/webapi/element/html/Base.zig
@@ -1,3 +1,5 @@
+const lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const URL = @import("../../../URL.zig");
const Frame = @import("../../../Frame.zig");
@@ -10,10 +12,11 @@ const Base = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *Base) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Base) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Body.zig b/src/browser/webapi/element/html/Body.zig
index d4914fc76..5602f3cc0 100644
--- a/src/browser/webapi/element/html/Body.zig
+++ b/src/browser/webapi/element/html/Body.zig
@@ -18,6 +18,7 @@
const lp = @import("lightpanda");
const js = @import("../../../js/js.zig");
+const Factory = @import("../../../Factory.zig");
const Frame = @import("../../../Frame.zig");
const Node = @import("../../Node.zig");
@@ -31,10 +32,11 @@ const Body = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *Body) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Body) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Button.zig b/src/browser/webapi/element/html/Button.zig
index 823cdf13b..0ee5acf83 100644
--- a/src/browser/webapi/element/html/Button.zig
+++ b/src/browser/webapi/element/html/Button.zig
@@ -16,9 +16,11 @@
// 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 lp = @import("lightpanda");
const std = @import("std");
const js = @import("../../../js/js.zig");
+const Factory = @import("../../../Factory.zig");
const Frame = @import("../../../Frame.zig");
const Node = @import("../../Node.zig");
@@ -34,16 +36,16 @@ const Button = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
_custom_validity: ?[]const u8 = null,
_validity: ?*ValidityState = null,
_popover_target: ?*Element = null,
pub fn asElement(self: *Button) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asConstElement(self: *const Button) *const Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Button) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Canvas.zig b/src/browser/webapi/element/html/Canvas.zig
index 9c3ef96ed..e9c301a15 100644
--- a/src/browser/webapi/element/html/Canvas.zig
+++ b/src/browser/webapi/element/html/Canvas.zig
@@ -16,8 +16,10 @@
// 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 lp = @import("lightpanda");
const std = @import("std");
const js = @import("../../../js/js.zig");
+const Factory = @import("../../../Factory.zig");
const Frame = @import("../../../Frame.zig");
const Node = @import("../../Node.zig");
const Element = @import("../../Element.zig");
@@ -32,14 +34,14 @@ const Execution = js.Execution;
const Canvas = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
_cached: ?DrawingContext = null,
pub fn asElement(self: *Canvas) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asConstElement(self: *const Canvas) *const Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Canvas) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Custom.zig b/src/browser/webapi/element/html/Custom.zig
index c6ed76973..5b2ce0110 100644
--- a/src/browser/webapi/element/html/Custom.zig
+++ b/src/browser/webapi/element/html/Custom.zig
@@ -20,6 +20,7 @@ const std = @import("std");
const lp = @import("lightpanda");
const js = @import("../../../js/js.zig");
+const Factory = @import("../../../Factory.zig");
const Frame = @import("../../../Frame.zig");
const Node = @import("../../Node.zig");
@@ -35,14 +36,14 @@ const String = lp.String;
const Custom = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
_tag_name: String,
_definition: ?*CustomElementDefinition,
_connected_callback_invoked: bool = false,
_disconnected_callback_invoked: bool = false,
pub fn asElement(self: *Custom) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Custom) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/DList.zig b/src/browser/webapi/element/html/DList.zig
index 353c0120e..0a22e0396 100644
--- a/src/browser/webapi/element/html/DList.zig
+++ b/src/browser/webapi/element/html/DList.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Node = @import("../../Node.zig");
const Element = @import("../../Element.zig");
@@ -24,10 +26,11 @@ const HtmlElement = @import("../Html.zig");
const DList = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *DList) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *DList) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Data.zig b/src/browser/webapi/element/html/Data.zig
index d4bc50d54..baeb5b41c 100644
--- a/src/browser/webapi/element/html/Data.zig
+++ b/src/browser/webapi/element/html/Data.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Frame = @import("../../../Frame.zig");
@@ -27,10 +29,11 @@ const Data = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *Data) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Data) *Node {
diff --git a/src/browser/webapi/element/html/DataList.zig b/src/browser/webapi/element/html/DataList.zig
index 93ec1a406..ef85c9fe4 100644
--- a/src/browser/webapi/element/html/DataList.zig
+++ b/src/browser/webapi/element/html/DataList.zig
@@ -1,3 +1,5 @@
+const lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Node = @import("../../Node.zig");
const Element = @import("../../Element.zig");
@@ -7,10 +9,11 @@ const DataList = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *DataList) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *DataList) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Details.zig b/src/browser/webapi/element/html/Details.zig
index 30c4134be..ed077be58 100644
--- a/src/browser/webapi/element/html/Details.zig
+++ b/src/browser/webapi/element/html/Details.zig
@@ -1,3 +1,5 @@
+const lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Frame = @import("../../../Frame.zig");
@@ -9,13 +11,14 @@ const Details = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *Details) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asConstElement(self: *const Details) *const Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Details) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Dialog.zig b/src/browser/webapi/element/html/Dialog.zig
index 5765f51a4..805c37b2d 100644
--- a/src/browser/webapi/element/html/Dialog.zig
+++ b/src/browser/webapi/element/html/Dialog.zig
@@ -1,3 +1,5 @@
+const lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Frame = @import("../../../Frame.zig");
@@ -10,13 +12,14 @@ const Dialog = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *Dialog) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asConstElement(self: *const Dialog) *const Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Dialog) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Directory.zig b/src/browser/webapi/element/html/Directory.zig
index 1c6d8ff00..bf5bb248e 100644
--- a/src/browser/webapi/element/html/Directory.zig
+++ b/src/browser/webapi/element/html/Directory.zig
@@ -1,3 +1,5 @@
+const lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Frame = @import("../../../Frame.zig");
const Node = @import("../../Node.zig");
@@ -8,10 +10,11 @@ const Directory = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *Directory) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Directory) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Div.zig b/src/browser/webapi/element/html/Div.zig
index 6a7edb125..88fa70476 100644
--- a/src/browser/webapi/element/html/Div.zig
+++ b/src/browser/webapi/element/html/Div.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Node = @import("../../Node.zig");
const Element = @import("../../Element.zig");
@@ -24,10 +26,11 @@ const HtmlElement = @import("../Html.zig");
const Div = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *Div) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Div) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Embed.zig b/src/browser/webapi/element/html/Embed.zig
index b66e94f74..1ee55547f 100644
--- a/src/browser/webapi/element/html/Embed.zig
+++ b/src/browser/webapi/element/html/Embed.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Frame = @import("../../../Frame.zig");
const Node = @import("../../Node.zig");
@@ -25,13 +27,14 @@ const HtmlElement = @import("../Html.zig");
const Embed = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *Embed) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asConstElement(self: *const Embed) *const Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Embed) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/FieldSet.zig b/src/browser/webapi/element/html/FieldSet.zig
index 717e115af..00e8e1f92 100644
--- a/src/browser/webapi/element/html/FieldSet.zig
+++ b/src/browser/webapi/element/html/FieldSet.zig
@@ -1,3 +1,5 @@
+const lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Frame = @import("../../../Frame.zig");
const Node = @import("../../Node.zig");
@@ -8,10 +10,11 @@ const FieldSet = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *FieldSet) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *FieldSet) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Font.zig b/src/browser/webapi/element/html/Font.zig
index 0b198518c..9517d93a6 100644
--- a/src/browser/webapi/element/html/Font.zig
+++ b/src/browser/webapi/element/html/Font.zig
@@ -1,3 +1,5 @@
+const lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Frame = @import("../../../Frame.zig");
const Node = @import("../../Node.zig");
@@ -8,10 +10,11 @@ const Font = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *Font) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Font) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Form.zig b/src/browser/webapi/element/html/Form.zig
index 65c0872a0..ee970e536 100644
--- a/src/browser/webapi/element/html/Form.zig
+++ b/src/browser/webapi/element/html/Form.zig
@@ -16,8 +16,10 @@
// 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 lp = @import("lightpanda");
const std = @import("std");
const js = @import("../../../js/js.zig");
+const Factory = @import("../../../Factory.zig");
const Frame = @import("../../../Frame.zig");
const Node = @import("../../Node.zig");
@@ -33,7 +35,7 @@ pub const TextArea = @import("TextArea.zig");
const Form = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
// Prevents submission of the form while we're in the process of submitting
// the form. You can imagine an onsubmit = () => form.submit() endless loop.
@@ -44,13 +46,13 @@ _firing_submission_events: bool = false,
_constructing_entry_list: bool = false,
pub fn asHtmlElement(self: *Form) *HtmlElement {
- return self._proto;
+ return Factory.protoOf(self);
}
fn asConstElement(self: *const Form) *const Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asElement(self: *Form) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Form) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/FrameSet.zig b/src/browser/webapi/element/html/FrameSet.zig
index f218da810..404a34e96 100644
--- a/src/browser/webapi/element/html/FrameSet.zig
+++ b/src/browser/webapi/element/html/FrameSet.zig
@@ -1,6 +1,7 @@
const lp = @import("lightpanda");
const js = @import("../../../js/js.zig");
+const Factory = @import("../../../Factory.zig");
const Frame = @import("../../../Frame.zig");
const Node = @import("../../Node.zig");
const Element = @import("../../Element.zig");
@@ -13,10 +14,11 @@ const FrameSet = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *FrameSet) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *FrameSet) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Generic.zig b/src/browser/webapi/element/html/Generic.zig
index a5b2ec26c..a4c9d3e6e 100644
--- a/src/browser/webapi/element/html/Generic.zig
+++ b/src/browser/webapi/element/html/Generic.zig
@@ -19,6 +19,7 @@
const lp = @import("lightpanda");
const js = @import("../../../js/js.zig");
+const Factory = @import("../../../Factory.zig");
const Node = @import("../../Node.zig");
const Element = @import("../../Element.zig");
@@ -31,10 +32,10 @@ const Generic = @This();
pub const Proto = HtmlElement;
_tag_name: String,
_tag: Element.Tag,
-_proto: *HtmlElement,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *Generic) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Generic) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/HR.zig b/src/browser/webapi/element/html/HR.zig
index ad98db6ed..fa3573c92 100644
--- a/src/browser/webapi/element/html/HR.zig
+++ b/src/browser/webapi/element/html/HR.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Node = @import("../../Node.zig");
const Element = @import("../../Element.zig");
@@ -24,10 +26,11 @@ const HtmlElement = @import("../Html.zig");
const HR = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *HR) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *HR) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Head.zig b/src/browser/webapi/element/html/Head.zig
index c69e843b5..bb17950c3 100644
--- a/src/browser/webapi/element/html/Head.zig
+++ b/src/browser/webapi/element/html/Head.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Node = @import("../../Node.zig");
const Element = @import("../../Element.zig");
@@ -24,10 +26,11 @@ const HtmlElement = @import("../Html.zig");
const Head = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *Head) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Head) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Heading.zig b/src/browser/webapi/element/html/Heading.zig
index 5711b2ccf..dac7d5378 100644
--- a/src/browser/webapi/element/html/Heading.zig
+++ b/src/browser/webapi/element/html/Heading.zig
@@ -19,6 +19,7 @@
const lp = @import("lightpanda");
const js = @import("../../../js/js.zig");
+const Factory = @import("../../../Factory.zig");
const Node = @import("../../Node.zig");
const Element = @import("../../Element.zig");
@@ -29,12 +30,12 @@ const String = lp.String;
const Heading = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
_tag_name: String,
_tag: Element.Tag,
pub fn asElement(self: *Heading) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Heading) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Html.zig b/src/browser/webapi/element/html/Html.zig
index 0441baab2..f8de33c0b 100644
--- a/src/browser/webapi/element/html/Html.zig
+++ b/src/browser/webapi/element/html/Html.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Node = @import("../../Node.zig");
const Element = @import("../../Element.zig");
@@ -24,10 +26,11 @@ const HtmlElement = @import("../Html.zig");
const Html = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *Html) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Html) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/IFrame.zig b/src/browser/webapi/element/html/IFrame.zig
index 21d0503b4..8849c8f6b 100644
--- a/src/browser/webapi/element/html/IFrame.zig
+++ b/src/browser/webapi/element/html/IFrame.zig
@@ -16,9 +16,11 @@
// 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 lp = @import("lightpanda");
const std = @import("std");
const js = @import("../../../js/js.zig");
+const Factory = @import("../../../Factory.zig");
const Frame = @import("../../../Frame.zig");
const Node = @import("../../Node.zig");
@@ -32,13 +34,13 @@ const HtmlElement = @import("../Html.zig");
const IFrame = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
_src: []const u8 = "",
_executed: bool = false,
_window: ?*Window = null,
pub fn asElement(self: *IFrame) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *IFrame) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Image.zig b/src/browser/webapi/element/html/Image.zig
index e75e7f9df..62608385b 100644
--- a/src/browser/webapi/element/html/Image.zig
+++ b/src/browser/webapi/element/html/Image.zig
@@ -1,5 +1,7 @@
+const lp = @import("lightpanda");
const std = @import("std");
const js = @import("../../../js/js.zig");
+const Factory = @import("../../../Factory.zig");
const Frame = @import("../../../Frame.zig");
const Node = @import("../../Node.zig");
const Element = @import("../../Element.zig");
@@ -8,7 +10,8 @@ const HtmlElement = @import("../Html.zig");
const Image = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn constructor(w_: ?u32, h_: ?u32, frame: *Frame) !*Image {
const node = try Frame.node_factory.createElementNS(frame, .html, "img", null);
@@ -26,10 +29,10 @@ pub fn constructor(w_: ?u32, h_: ?u32, frame: *Frame) !*Image {
}
pub fn asElement(self: *Image) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asConstElement(self: *const Image) *const Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Image) *Node {
return self.asElement().asNode();
@@ -130,7 +133,7 @@ pub fn imageAddedCallback(self: *Image, frame: *Frame) !void {
const src = element.getAttributeSafe(comptime .wrap("src")) orelse return;
if (src.len == 0) return;
- try frame.queueLoad(self._proto);
+ try frame.queueLoad(Factory.protoOf(self));
}
pub const JsApi = struct {
diff --git a/src/browser/webapi/element/html/Input.zig b/src/browser/webapi/element/html/Input.zig
index 0eb523419..3ebbf3178 100644
--- a/src/browser/webapi/element/html/Input.zig
+++ b/src/browser/webapi/element/html/Input.zig
@@ -20,6 +20,7 @@ const std = @import("std");
const lp = @import("lightpanda");
const js = @import("../../../js/js.zig");
+const Factory = @import("../../../Factory.zig");
const Frame = @import("../../../Frame.zig");
const Node = @import("../../Node.zig");
@@ -80,7 +81,7 @@ pub const Type = enum {
}
};
-_proto: *HtmlElement,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
_default_value: ?[]const u8 = null,
_default_checked: bool = false,
_value: ?[]const u8 = null,
@@ -122,10 +123,10 @@ fn dispatchInputEvent(self: *Input, data: ?[]const u8, input_type: []const u8, f
}
pub fn asElement(self: *Input) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asConstElement(self: *const Input) *const Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Input) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/LI.zig b/src/browser/webapi/element/html/LI.zig
index 9caa1907f..a209ff33f 100644
--- a/src/browser/webapi/element/html/LI.zig
+++ b/src/browser/webapi/element/html/LI.zig
@@ -16,8 +16,10 @@
// 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 lp = @import("lightpanda");
const std = @import("std");
const js = @import("../../../js/js.zig");
+const Factory = @import("../../../Factory.zig");
const Frame = @import("../../../Frame.zig");
const Node = @import("../../Node.zig");
const Element = @import("../../Element.zig");
@@ -26,10 +28,11 @@ const HtmlElement = @import("../Html.zig");
const LI = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *LI) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *LI) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Label.zig b/src/browser/webapi/element/html/Label.zig
index fd4da498f..2285e229c 100644
--- a/src/browser/webapi/element/html/Label.zig
+++ b/src/browser/webapi/element/html/Label.zig
@@ -1,5 +1,7 @@
+const lp = @import("lightpanda");
const std = @import("std");
const js = @import("../../../js/js.zig");
+const Factory = @import("../../../Factory.zig");
const Frame = @import("../../../Frame.zig");
const Node = @import("../../Node.zig");
const Element = @import("../../Element.zig");
@@ -10,10 +12,11 @@ const Label = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *Label) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Label) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Legend.zig b/src/browser/webapi/element/html/Legend.zig
index 27d8a1fa4..0c1661298 100644
--- a/src/browser/webapi/element/html/Legend.zig
+++ b/src/browser/webapi/element/html/Legend.zig
@@ -1,3 +1,5 @@
+const lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Node = @import("../../Node.zig");
const Element = @import("../../Element.zig");
@@ -7,10 +9,11 @@ const Legend = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *Legend) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Legend) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Link.zig b/src/browser/webapi/element/html/Link.zig
index af33fcf11..8c29f36f5 100644
--- a/src/browser/webapi/element/html/Link.zig
+++ b/src/browser/webapi/element/html/Link.zig
@@ -16,8 +16,10 @@
// 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 lp = @import("lightpanda");
const std = @import("std");
const js = @import("../../../js/js.zig");
+const Factory = @import("../../../Factory.zig");
const Frame = @import("../../../Frame.zig");
const Node = @import("../../Node.zig");
@@ -29,7 +31,7 @@ const HtmlElement = @import("../Html.zig");
const Link = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
// Cached CSSStyleSheet for an external `rel=stylesheet` once
// `Frame.loadExternalStylesheet` has registered it. Re-fetches (href
// mutated on a connected link) reuse this sheet via `replaceSync` so the
@@ -38,10 +40,10 @@ _proto: *HtmlElement,
_sheet: ?*@import("../../css/CSSStyleSheet.zig") = null,
pub fn asElement(self: *Link) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asConstElement(self: *const Link) *const Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Link) *Node {
return self.asElement().asNode();
@@ -232,26 +234,26 @@ pub fn linkAddedCallback(self: *Link, frame: *Frame) !void {
if (std.mem.eql(u8, rel, "preload")) {
const as = element.getAttributeSafe(comptime .wrap("as")) orelse "";
if (std.ascii.eqlIgnoreCase(as, "script")) {
- if (Frame.preload.scriptHint(frame, self._proto, href)) {
+ if (Frame.preload.scriptHint(frame, Factory.protoOf(self), href)) {
// load/error fires when the fetch settles
return;
}
}
// synthetic load, fires next tick
- return frame.queueLoad(self._proto);
+ return frame.queueLoad(Factory.protoOf(self));
}
if (std.mem.eql(u8, rel, "modulepreload")) {
// "as" defaults to script in this case
const as = element.getAttributeSafe(comptime .wrap("as")) orelse "";
if (as.len == 0 or std.ascii.eqlIgnoreCase(as, "script")) {
- if (Frame.preload.moduleHint(frame, self._proto, href)) {
+ if (Frame.preload.moduleHint(frame, Factory.protoOf(self), href)) {
// load/error fires when the fetch settles
return;
}
}
// synthetic load, fires next tick
- return frame.queueLoad(self._proto);
+ return frame.queueLoad(Factory.protoOf(self));
}
}
diff --git a/src/browser/webapi/element/html/Map.zig b/src/browser/webapi/element/html/Map.zig
index ee95dbe99..8864f892c 100644
--- a/src/browser/webapi/element/html/Map.zig
+++ b/src/browser/webapi/element/html/Map.zig
@@ -1,3 +1,5 @@
+const lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Node = @import("../../Node.zig");
const Element = @import("../../Element.zig");
@@ -7,10 +9,11 @@ const Map = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *Map) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Map) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Marquee.zig b/src/browser/webapi/element/html/Marquee.zig
index c9601176d..804ee34fa 100644
--- a/src/browser/webapi/element/html/Marquee.zig
+++ b/src/browser/webapi/element/html/Marquee.zig
@@ -1,6 +1,8 @@
+const lp = @import("lightpanda");
const std = @import("std");
const js = @import("../../../js/js.zig");
+const Factory = @import("../../../Factory.zig");
const Frame = @import("../../../Frame.zig");
const Node = @import("../../Node.zig");
const Element = @import("../../Element.zig");
@@ -10,10 +12,11 @@ const Marquee = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *Marquee) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Marquee) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Meta.zig b/src/browser/webapi/element/html/Meta.zig
index 7c869c290..5ff50eff4 100644
--- a/src/browser/webapi/element/html/Meta.zig
+++ b/src/browser/webapi/element/html/Meta.zig
@@ -16,9 +16,11 @@
// 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 lp = @import("lightpanda");
const std = @import("std");
const js = @import("../../../js/js.zig");
+const Factory = @import("../../../Factory.zig");
const Frame = @import("../../../Frame.zig");
const Node = @import("../../Node.zig");
const Element = @import("../../Element.zig");
@@ -32,10 +34,11 @@ pub const Proto = HtmlElement;
// Create a different alias we can use when in such ambiguous cases.
const MetaElement = Meta;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *Meta) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Meta) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Meter.zig b/src/browser/webapi/element/html/Meter.zig
index 922a60502..cae055854 100644
--- a/src/browser/webapi/element/html/Meter.zig
+++ b/src/browser/webapi/element/html/Meter.zig
@@ -1,3 +1,5 @@
+const lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Frame = @import("../../../Frame.zig");
const Node = @import("../../Node.zig");
@@ -8,10 +10,11 @@ const Meter = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *Meter) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Meter) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Mod.zig b/src/browser/webapi/element/html/Mod.zig
index ac6c02223..ef51d64c6 100644
--- a/src/browser/webapi/element/html/Mod.zig
+++ b/src/browser/webapi/element/html/Mod.zig
@@ -1,6 +1,7 @@
const lp = @import("lightpanda");
const js = @import("../../../js/js.zig");
+const Factory = @import("../../../Factory.zig");
const Node = @import("../../Node.zig");
const Element = @import("../../Element.zig");
const HtmlElement = @import("../Html.zig");
@@ -13,10 +14,10 @@ pub const Proto = HtmlElement;
_tag_name: String,
_tag: Element.Tag,
-_proto: *HtmlElement,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *Mod) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Mod) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/OL.zig b/src/browser/webapi/element/html/OL.zig
index d2c452157..aa44e3c42 100644
--- a/src/browser/webapi/element/html/OL.zig
+++ b/src/browser/webapi/element/html/OL.zig
@@ -16,8 +16,10 @@
// 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 lp = @import("lightpanda");
const std = @import("std");
const js = @import("../../../js/js.zig");
+const Factory = @import("../../../Factory.zig");
const Frame = @import("../../../Frame.zig");
const Node = @import("../../Node.zig");
const Element = @import("../../Element.zig");
@@ -26,10 +28,11 @@ const HtmlElement = @import("../Html.zig");
const OL = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *OL) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *OL) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Object.zig b/src/browser/webapi/element/html/Object.zig
index b4f1a1a7e..8ca2703c6 100644
--- a/src/browser/webapi/element/html/Object.zig
+++ b/src/browser/webapi/element/html/Object.zig
@@ -1,3 +1,5 @@
+const lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Node = @import("../../Node.zig");
const Element = @import("../../Element.zig");
@@ -7,10 +9,11 @@ const Object = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *Object) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Object) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/OptGroup.zig b/src/browser/webapi/element/html/OptGroup.zig
index 82e7e6684..23d788ac5 100644
--- a/src/browser/webapi/element/html/OptGroup.zig
+++ b/src/browser/webapi/element/html/OptGroup.zig
@@ -1,3 +1,5 @@
+const lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Frame = @import("../../../Frame.zig");
const Node = @import("../../Node.zig");
@@ -8,10 +10,11 @@ const OptGroup = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *OptGroup) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *OptGroup) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Option.zig b/src/browser/webapi/element/html/Option.zig
index 46d5c4ecb..7ec0d244a 100644
--- a/src/browser/webapi/element/html/Option.zig
+++ b/src/browser/webapi/element/html/Option.zig
@@ -20,6 +20,7 @@ const std = @import("std");
const lp = @import("lightpanda");
const js = @import("../../../js/js.zig");
+const Factory = @import("../../../Factory.zig");
const Frame = @import("../../../Frame.zig");
const Node = @import("../../Node.zig");
@@ -32,17 +33,17 @@ const Option = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
_value: ?[]const u8 = null,
_selected: bool = false,
_default_selected: bool = false,
_disabled: bool = false,
pub fn asElement(self: *Option) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asConstElement(self: *const Option) *const Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Option) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Output.zig b/src/browser/webapi/element/html/Output.zig
index 0fb343f41..11b2aa1e0 100644
--- a/src/browser/webapi/element/html/Output.zig
+++ b/src/browser/webapi/element/html/Output.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Frame = @import("../../../Frame.zig");
@@ -29,10 +31,11 @@ const Output = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *Output) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Output) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Paragraph.zig b/src/browser/webapi/element/html/Paragraph.zig
index 0714e1897..abf6faf65 100644
--- a/src/browser/webapi/element/html/Paragraph.zig
+++ b/src/browser/webapi/element/html/Paragraph.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Node = @import("../../Node.zig");
const Element = @import("../../Element.zig");
@@ -24,10 +26,11 @@ const HtmlElement = @import("../Html.zig");
const Paragraph = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *Paragraph) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Paragraph) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Param.zig b/src/browser/webapi/element/html/Param.zig
index 7eaa04155..8c1164091 100644
--- a/src/browser/webapi/element/html/Param.zig
+++ b/src/browser/webapi/element/html/Param.zig
@@ -1,3 +1,5 @@
+const lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Frame = @import("../../../Frame.zig");
const Node = @import("../../Node.zig");
@@ -8,10 +10,11 @@ const Param = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *Param) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Param) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Picture.zig b/src/browser/webapi/element/html/Picture.zig
index 5e50bbb61..dc69571e4 100644
--- a/src/browser/webapi/element/html/Picture.zig
+++ b/src/browser/webapi/element/html/Picture.zig
@@ -1,3 +1,5 @@
+const lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Node = @import("../../Node.zig");
const Element = @import("../../Element.zig");
@@ -7,10 +9,11 @@ const Picture = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *Picture) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Picture) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Pre.zig b/src/browser/webapi/element/html/Pre.zig
index 3ef89d15c..eaf797a6d 100644
--- a/src/browser/webapi/element/html/Pre.zig
+++ b/src/browser/webapi/element/html/Pre.zig
@@ -1,3 +1,5 @@
+const lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Node = @import("../../Node.zig");
const Element = @import("../../Element.zig");
@@ -7,10 +9,11 @@ const Pre = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *Pre) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Pre) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Progress.zig b/src/browser/webapi/element/html/Progress.zig
index d8a5f9acc..e0869d28f 100644
--- a/src/browser/webapi/element/html/Progress.zig
+++ b/src/browser/webapi/element/html/Progress.zig
@@ -1,3 +1,5 @@
+const lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Frame = @import("../../../Frame.zig");
const Node = @import("../../Node.zig");
@@ -8,10 +10,11 @@ const Progress = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *Progress) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Progress) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Quote.zig b/src/browser/webapi/element/html/Quote.zig
index f132096d1..ee9b4ca68 100644
--- a/src/browser/webapi/element/html/Quote.zig
+++ b/src/browser/webapi/element/html/Quote.zig
@@ -1,6 +1,7 @@
const lp = @import("lightpanda");
const js = @import("../../../js/js.zig");
+const Factory = @import("../../../Factory.zig");
const Frame = @import("../../../Frame.zig");
const Node = @import("../../Node.zig");
const Element = @import("../../Element.zig");
@@ -14,10 +15,10 @@ pub const Proto = HtmlElement;
_tag_name: String,
_tag: Element.Tag,
-_proto: *HtmlElement,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *Quote) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Quote) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Script.zig b/src/browser/webapi/element/html/Script.zig
index c30c09399..57db5064a 100644
--- a/src/browser/webapi/element/html/Script.zig
+++ b/src/browser/webapi/element/html/Script.zig
@@ -19,6 +19,7 @@ const std = @import("std");
const lp = @import("lightpanda");
const js = @import("../../../js/js.zig");
+const Factory = @import("../../../Factory.zig");
const Frame = @import("../../../Frame.zig");
const Node = @import("../../Node.zig");
@@ -30,18 +31,18 @@ const Script = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
_src: []const u8 = "",
_executed: bool = false,
// dynamic scripts are forced to be async by default
_force_async: bool = true,
pub fn asElement(self: *Script) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asConstElement(self: *const Script) *const Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Script) *Node {
diff --git a/src/browser/webapi/element/html/Select.zig b/src/browser/webapi/element/html/Select.zig
index 7345ae39c..48bbb7298 100644
--- a/src/browser/webapi/element/html/Select.zig
+++ b/src/browser/webapi/element/html/Select.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Frame = @import("../../../Frame.zig");
@@ -32,16 +34,16 @@ const Select = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
_selected_index_set: bool = false,
_custom_validity: ?[]const u8 = null,
_validity: ?*ValidityState = null,
pub fn asElement(self: *Select) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asConstElement(self: *const Select) *const Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Select) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Slot.zig b/src/browser/webapi/element/html/Slot.zig
index 169ed5ccd..a14e53e24 100644
--- a/src/browser/webapi/element/html/Slot.zig
+++ b/src/browser/webapi/element/html/Slot.zig
@@ -1,5 +1,7 @@
+const lp = @import("lightpanda");
const std = @import("std");
const js = @import("../../../js/js.zig");
+const Factory = @import("../../../Factory.zig");
const Frame = @import("../../../Frame.zig");
const Node = @import("../../Node.zig");
const Element = @import("../../Element.zig");
@@ -11,7 +13,7 @@ const Slot = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
// DOM spec "assigned nodes". Maintained by slotting.assignSlottables; always
// empty while the slot isn't in a shadow tree.
_assigned: std.ArrayList(*Node) = .empty,
@@ -20,11 +22,11 @@ _assigned: std.ArrayList(*Node) = .empty,
_manually_assigned: std.ArrayList(*Node) = .empty,
pub fn asElement(self: *Slot) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asConstElement(self: *const Slot) *const Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Slot) *Node {
diff --git a/src/browser/webapi/element/html/Source.zig b/src/browser/webapi/element/html/Source.zig
index 5e45a100f..1db9d63ad 100644
--- a/src/browser/webapi/element/html/Source.zig
+++ b/src/browser/webapi/element/html/Source.zig
@@ -1,5 +1,7 @@
+const lp = @import("lightpanda");
const std = @import("std");
const js = @import("../../../js/js.zig");
+const Factory = @import("../../../Factory.zig");
const Frame = @import("../../../Frame.zig");
const Node = @import("../../Node.zig");
const Element = @import("../../Element.zig");
@@ -9,13 +11,14 @@ const Source = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *Source) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asConstElement(self: *const Source) *const Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Source) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Span.zig b/src/browser/webapi/element/html/Span.zig
index 9afee3d26..125252cd0 100644
--- a/src/browser/webapi/element/html/Span.zig
+++ b/src/browser/webapi/element/html/Span.zig
@@ -1,3 +1,5 @@
+const lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Node = @import("../../Node.zig");
const Element = @import("../../Element.zig");
@@ -7,10 +9,11 @@ const Span = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *Span) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Span) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Style.zig b/src/browser/webapi/element/html/Style.zig
index 1fc7ef552..23276545d 100644
--- a/src/browser/webapi/element/html/Style.zig
+++ b/src/browser/webapi/element/html/Style.zig
@@ -16,8 +16,10 @@
// 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 lp = @import("lightpanda");
const std = @import("std");
const js = @import("../../../js/js.zig");
+const Factory = @import("../../../Factory.zig");
const Frame = @import("../../../Frame.zig");
const Node = @import("../../Node.zig");
@@ -27,14 +29,14 @@ const HtmlElement = @import("../Html.zig");
const Style = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
_sheet: ?*CSSStyleSheet = null,
pub fn asElement(self: *Style) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asConstElement(self: *const Style) *const Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Style) *Node {
return self.asElement().asNode();
@@ -116,7 +118,7 @@ pub fn styleAddedCallback(self: *Style, frame: *Frame) !void {
return;
}
- try frame.queueLoad(self._proto);
+ try frame.queueLoad(Factory.protoOf(self));
}
pub const JsApi = struct {
diff --git a/src/browser/webapi/element/html/Table.zig b/src/browser/webapi/element/html/Table.zig
index 110910023..c7b56891d 100644
--- a/src/browser/webapi/element/html/Table.zig
+++ b/src/browser/webapi/element/html/Table.zig
@@ -1,3 +1,5 @@
+const lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Node = @import("../../Node.zig");
const Frame = @import("../../../Frame.zig");
@@ -9,10 +11,11 @@ const Table = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *Table) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Table) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/TableCaption.zig b/src/browser/webapi/element/html/TableCaption.zig
index 0c8da33d5..fedc32cb0 100644
--- a/src/browser/webapi/element/html/TableCaption.zig
+++ b/src/browser/webapi/element/html/TableCaption.zig
@@ -1,3 +1,5 @@
+const lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Node = @import("../../Node.zig");
const Element = @import("../../Element.zig");
@@ -7,10 +9,11 @@ const TableCaption = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *TableCaption) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *TableCaption) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/TableCell.zig b/src/browser/webapi/element/html/TableCell.zig
index 73635f8dc..7abd67205 100644
--- a/src/browser/webapi/element/html/TableCell.zig
+++ b/src/browser/webapi/element/html/TableCell.zig
@@ -2,6 +2,7 @@ const std = @import("std");
const lp = @import("lightpanda");
const js = @import("../../../js/js.zig");
+const Factory = @import("../../../Factory.zig");
const Frame = @import("../../../Frame.zig");
const Node = @import("../../Node.zig");
const Element = @import("../../Element.zig");
@@ -15,10 +16,10 @@ pub const Proto = HtmlElement;
_tag_name: String,
_tag: Element.Tag,
-_proto: *HtmlElement,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *TableCell) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *TableCell) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/TableCol.zig b/src/browser/webapi/element/html/TableCol.zig
index 196a26ae8..55558a97e 100644
--- a/src/browser/webapi/element/html/TableCol.zig
+++ b/src/browser/webapi/element/html/TableCol.zig
@@ -1,6 +1,7 @@
const lp = @import("lightpanda");
const js = @import("../../../js/js.zig");
+const Factory = @import("../../../Factory.zig");
const Node = @import("../../Node.zig");
const Element = @import("../../Element.zig");
const HtmlElement = @import("../Html.zig");
@@ -13,10 +14,10 @@ pub const Proto = HtmlElement;
_tag_name: String,
_tag: Element.Tag,
-_proto: *HtmlElement,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *TableCol) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *TableCol) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/TableRow.zig b/src/browser/webapi/element/html/TableRow.zig
index ff9eec942..6191ed084 100644
--- a/src/browser/webapi/element/html/TableRow.zig
+++ b/src/browser/webapi/element/html/TableRow.zig
@@ -1,3 +1,5 @@
+const lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Node = @import("../../Node.zig");
const Frame = @import("../../../Frame.zig");
@@ -9,10 +11,11 @@ const TableRow = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *TableRow) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *TableRow) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/TableSection.zig b/src/browser/webapi/element/html/TableSection.zig
index e396de34d..e996ceec6 100644
--- a/src/browser/webapi/element/html/TableSection.zig
+++ b/src/browser/webapi/element/html/TableSection.zig
@@ -1,6 +1,7 @@
const lp = @import("lightpanda");
const js = @import("../../../js/js.zig");
+const Factory = @import("../../../Factory.zig");
const Node = @import("../../Node.zig");
const Frame = @import("../../../Frame.zig");
const Element = @import("../../Element.zig");
@@ -15,10 +16,10 @@ pub const Proto = HtmlElement;
_tag_name: String,
_tag: Element.Tag,
-_proto: *HtmlElement,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *TableSection) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *TableSection) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Template.zig b/src/browser/webapi/element/html/Template.zig
index 68af063b0..d84550fb9 100644
--- a/src/browser/webapi/element/html/Template.zig
+++ b/src/browser/webapi/element/html/Template.zig
@@ -20,6 +20,7 @@ const std = @import("std");
const lp = @import("lightpanda");
const js = @import("../../../js/js.zig");
+const Factory = @import("../../../Factory.zig");
const Frame = @import("../../../Frame.zig");
const Node = @import("../../Node.zig");
@@ -34,15 +35,15 @@ const Template = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
_content: *DocumentFragment,
pub fn asElement(self: *Template) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asConstElement(self: *const Template) *const Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Template) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/TextArea.zig b/src/browser/webapi/element/html/TextArea.zig
index 3f19c0d3a..5f488b9e8 100644
--- a/src/browser/webapi/element/html/TextArea.zig
+++ b/src/browser/webapi/element/html/TextArea.zig
@@ -16,8 +16,10 @@
// 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 lp = @import("lightpanda");
const std = @import("std");
const js = @import("../../../js/js.zig");
+const Factory = @import("../../../Factory.zig");
const Frame = @import("../../../Frame.zig");
const Node = @import("../../Node.zig");
@@ -33,7 +35,7 @@ const TextArea = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
_value: ?[]const u8 = null,
_selection_start: u32 = 0,
@@ -67,10 +69,10 @@ fn dispatchInputEvent(self: *TextArea, data: ?[]const u8, input_type: []const u8
}
pub fn asElement(self: *TextArea) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asConstElement(self: *const TextArea) *const Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *TextArea) *Node {
return self.asElement().asNode();
@@ -102,7 +104,7 @@ pub fn setDefaultValue(self: *TextArea, value: []const u8, frame: *Frame) !void
const node = self.asNode();
if (node.firstChild()) |child| {
if (child.is(Node.CData.Text)) |txt| {
- txt._proto._data = try frame.dupeSSO(value);
+ txt.asCData()._data = try frame.dupeSSO(value);
return;
}
}
diff --git a/src/browser/webapi/element/html/Time.zig b/src/browser/webapi/element/html/Time.zig
index 9232f7489..3bfb88069 100644
--- a/src/browser/webapi/element/html/Time.zig
+++ b/src/browser/webapi/element/html/Time.zig
@@ -1,3 +1,5 @@
+const lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Frame = @import("../../../Frame.zig");
const Node = @import("../../Node.zig");
@@ -8,10 +10,11 @@ const Time = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *Time) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Time) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Title.zig b/src/browser/webapi/element/html/Title.zig
index c81ae6031..bdc4f8622 100644
--- a/src/browser/webapi/element/html/Title.zig
+++ b/src/browser/webapi/element/html/Title.zig
@@ -1,3 +1,5 @@
+const lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Node = @import("../../Node.zig");
const Element = @import("../../Element.zig");
@@ -7,10 +9,11 @@ const Title = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *Title) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Title) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Track.zig b/src/browser/webapi/element/html/Track.zig
index 3e3e10514..4d29d3939 100644
--- a/src/browser/webapi/element/html/Track.zig
+++ b/src/browser/webapi/element/html/Track.zig
@@ -20,6 +20,7 @@ const std = @import("std");
const lp = @import("lightpanda");
const js = @import("../../../js/js.zig");
+const Factory = @import("../../../Factory.zig");
const Node = @import("../../Node.zig");
const Element = @import("../../Element.zig");
@@ -31,14 +32,14 @@ const Track = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
_kind: String,
_ready_state: ReadyState,
const ReadyState = enum(u8) { none, loading, loaded, @"error" };
pub fn asElement(self: *Track) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Track) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/UL.zig b/src/browser/webapi/element/html/UL.zig
index 5d69779e2..372377d24 100644
--- a/src/browser/webapi/element/html/UL.zig
+++ b/src/browser/webapi/element/html/UL.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Node = @import("../../Node.zig");
const Element = @import("../../Element.zig");
@@ -24,10 +26,11 @@ const HtmlElement = @import("../Html.zig");
const UL = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
pub fn asElement(self: *UL) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *UL) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Unknown.zig b/src/browser/webapi/element/html/Unknown.zig
index 336adc6da..6561a5256 100644
--- a/src/browser/webapi/element/html/Unknown.zig
+++ b/src/browser/webapi/element/html/Unknown.zig
@@ -19,6 +19,7 @@
const lp = @import("lightpanda");
const js = @import("../../../js/js.zig");
+const Factory = @import("../../../Factory.zig");
const Node = @import("../../Node.zig");
const Element = @import("../../Element.zig");
@@ -29,11 +30,11 @@ const String = lp.String;
const Unknown = @This();
pub const Proto = HtmlElement;
-_proto: *HtmlElement,
+_proto_canary: if (lp.IS_DEBUG) *HtmlElement else void = undefined,
_tag_name: String,
pub fn asElement(self: *Unknown) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Unknown) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/html/Video.zig b/src/browser/webapi/element/html/Video.zig
index 4daff3160..ccd3e1b4f 100644
--- a/src/browser/webapi/element/html/Video.zig
+++ b/src/browser/webapi/element/html/Video.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Frame = @import("../../../Frame.zig");
@@ -27,18 +29,19 @@ const Video = @This();
pub const Proto = Media;
-_proto: *Media,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *Media else void = undefined,
pub fn asMedia(self: *Video) *Media {
- return self._proto;
+ return Factory.protoOf(self);
}
pub fn asElement(self: *Video) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asConstElement(self: *const Video) *const Element {
- return self._proto.asConstElement();
+ return Factory.protoOf(self).asConstElement();
}
pub fn asNode(self: *Video) *Node {
diff --git a/src/browser/webapi/element/svg/A.zig b/src/browser/webapi/element/svg/A.zig
index 0ce9f09d6..cb7009bf4 100644
--- a/src/browser/webapi/element/svg/A.zig
+++ b/src/browser/webapi/element/svg/A.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Frame = @import("../../../Frame.zig");
@@ -29,10 +31,11 @@ const Graphics = @import("Graphics.zig");
const A = @This();
pub const Proto = Graphics;
-_proto: *Graphics,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *Graphics else void = undefined,
pub fn asElement(self: *A) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *A) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/svg/Circle.zig b/src/browser/webapi/element/svg/Circle.zig
index e14cf41cf..c3f73d1d2 100644
--- a/src/browser/webapi/element/svg/Circle.zig
+++ b/src/browser/webapi/element/svg/Circle.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Frame = @import("../../../Frame.zig");
@@ -28,10 +30,11 @@ const AnimatedLength = @import("../../svg/AnimatedLength.zig");
const Circle = @This();
pub const Proto = Geometry;
-_proto: *Geometry,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *Geometry else void = undefined,
pub fn asElement(self: *Circle) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Circle) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/svg/ClipPath.zig b/src/browser/webapi/element/svg/ClipPath.zig
index 152fb3895..76d302de9 100644
--- a/src/browser/webapi/element/svg/ClipPath.zig
+++ b/src/browser/webapi/element/svg/ClipPath.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Frame = @import("../../../Frame.zig");
@@ -30,10 +32,11 @@ const Svg = @import("../Svg.zig");
const ClipPath = @This();
pub const Proto = Svg;
-_proto: *Svg,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *Svg else void = undefined,
pub fn asElement(self: *ClipPath) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *ClipPath) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/svg/Defs.zig b/src/browser/webapi/element/svg/Defs.zig
index ec3a15e30..46081cf45 100644
--- a/src/browser/webapi/element/svg/Defs.zig
+++ b/src/browser/webapi/element/svg/Defs.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Node = @import("../../Node.zig");
@@ -26,10 +28,11 @@ const Graphics = @import("Graphics.zig");
const Defs = @This();
pub const Proto = Graphics;
-_proto: *Graphics,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *Graphics else void = undefined,
pub fn asElement(self: *Defs) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Defs) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/svg/Desc.zig b/src/browser/webapi/element/svg/Desc.zig
index 9c87fc62e..a8edcde9c 100644
--- a/src/browser/webapi/element/svg/Desc.zig
+++ b/src/browser/webapi/element/svg/Desc.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Node = @import("../../Node.zig");
const Element = @import("../../Element.zig");
@@ -24,10 +26,11 @@ const Svg = @import("../Svg.zig");
const Desc = @This();
pub const Proto = Svg;
-_proto: *Svg,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *Svg else void = undefined,
pub fn asElement(self: *Desc) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Desc) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/svg/Ellipse.zig b/src/browser/webapi/element/svg/Ellipse.zig
index 8f2266407..56adb4f0c 100644
--- a/src/browser/webapi/element/svg/Ellipse.zig
+++ b/src/browser/webapi/element/svg/Ellipse.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Frame = @import("../../../Frame.zig");
@@ -28,10 +30,11 @@ const AnimatedLength = @import("../../svg/AnimatedLength.zig");
const Ellipse = @This();
pub const Proto = Geometry;
-_proto: *Geometry,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *Geometry else void = undefined,
pub fn asElement(self: *Ellipse) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Ellipse) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/svg/ForeignObject.zig b/src/browser/webapi/element/svg/ForeignObject.zig
index 4004e0212..e0ab7784e 100644
--- a/src/browser/webapi/element/svg/ForeignObject.zig
+++ b/src/browser/webapi/element/svg/ForeignObject.zig
@@ -16,9 +16,11 @@
// 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 lp = @import("lightpanda");
const std = @import("std");
const js = @import("../../../js/js.zig");
+const Factory = @import("../../../Factory.zig");
const Frame = @import("../../../Frame.zig");
const Node = @import("../../Node.zig");
const Element = @import("../../Element.zig");
@@ -31,10 +33,11 @@ const Graphics = @import("Graphics.zig");
const ForeignObject = @This();
pub const Proto = Graphics;
-_proto: *Graphics,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *Graphics else void = undefined,
pub fn asElement(self: *ForeignObject) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *ForeignObject) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/svg/G.zig b/src/browser/webapi/element/svg/G.zig
index 88514c893..01c94b339 100644
--- a/src/browser/webapi/element/svg/G.zig
+++ b/src/browser/webapi/element/svg/G.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Node = @import("../../Node.zig");
@@ -26,10 +28,11 @@ const Graphics = @import("Graphics.zig");
const G = @This();
pub const Proto = Graphics;
-_proto: *Graphics,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *Graphics else void = undefined,
pub fn asElement(self: *G) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *G) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/svg/Generic.zig b/src/browser/webapi/element/svg/Generic.zig
index 5a7a91417..7d4660041 100644
--- a/src/browser/webapi/element/svg/Generic.zig
+++ b/src/browser/webapi/element/svg/Generic.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Node = @import("../../Node.zig");
@@ -26,11 +28,11 @@ const Svg = @import("../Svg.zig");
const Generic = @This();
pub const Proto = Svg;
-_proto: *Svg,
+_proto_canary: if (lp.IS_DEBUG) *Svg else void = undefined,
_tag: Element.Tag,
pub fn asElement(self: *Generic) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Generic) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/svg/Image.zig b/src/browser/webapi/element/svg/Image.zig
index a01218444..6e0d058bc 100644
--- a/src/browser/webapi/element/svg/Image.zig
+++ b/src/browser/webapi/element/svg/Image.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Frame = @import("../../../Frame.zig");
@@ -28,10 +30,11 @@ const Graphics = @import("Graphics.zig");
const Image = @This();
pub const Proto = Graphics;
-_proto: *Graphics,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *Graphics else void = undefined,
pub fn asElement(self: *Image) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Image) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/svg/Line.zig b/src/browser/webapi/element/svg/Line.zig
index d47e72b3c..323e1b3e4 100644
--- a/src/browser/webapi/element/svg/Line.zig
+++ b/src/browser/webapi/element/svg/Line.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Frame = @import("../../../Frame.zig");
@@ -28,10 +30,11 @@ const AnimatedLength = @import("../../svg/AnimatedLength.zig");
const Line = @This();
pub const Proto = Geometry;
-_proto: *Geometry,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *Geometry else void = undefined,
pub fn asElement(self: *Line) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Line) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/svg/LinearGradient.zig b/src/browser/webapi/element/svg/LinearGradient.zig
index 7a92e803e..a29c4d510 100644
--- a/src/browser/webapi/element/svg/LinearGradient.zig
+++ b/src/browser/webapi/element/svg/LinearGradient.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Frame = @import("../../../Frame.zig");
@@ -29,10 +31,11 @@ const GradientElement = @import("GradientElement.zig");
const LinearGradient = @This();
pub const Proto = GradientElement;
-_proto: *GradientElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *GradientElement else void = undefined,
pub fn asElement(self: *LinearGradient) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *LinearGradient) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/svg/Marker.zig b/src/browser/webapi/element/svg/Marker.zig
index 73209cd7d..3d1200ff4 100644
--- a/src/browser/webapi/element/svg/Marker.zig
+++ b/src/browser/webapi/element/svg/Marker.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Frame = @import("../../../Frame.zig");
@@ -30,10 +32,11 @@ const Svg = @import("../Svg.zig");
const Marker = @This();
pub const Proto = Svg;
-_proto: *Svg,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *Svg else void = undefined,
pub fn asElement(self: *Marker) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Marker) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/svg/Mask.zig b/src/browser/webapi/element/svg/Mask.zig
index 92dde0a64..26378cde5 100644
--- a/src/browser/webapi/element/svg/Mask.zig
+++ b/src/browser/webapi/element/svg/Mask.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Frame = @import("../../../Frame.zig");
@@ -30,10 +32,11 @@ const Svg = @import("../Svg.zig");
const Mask = @This();
pub const Proto = Svg;
-_proto: *Svg,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *Svg else void = undefined,
pub fn asElement(self: *Mask) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Mask) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/svg/Metadata.zig b/src/browser/webapi/element/svg/Metadata.zig
index 434e0ec1f..636b8edbc 100644
--- a/src/browser/webapi/element/svg/Metadata.zig
+++ b/src/browser/webapi/element/svg/Metadata.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Node = @import("../../Node.zig");
@@ -26,10 +28,11 @@ const Svg = @import("../Svg.zig");
const Metadata = @This();
pub const Proto = Svg;
-_proto: *Svg,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *Svg else void = undefined,
pub fn asElement(self: *Metadata) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Metadata) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/svg/Path.zig b/src/browser/webapi/element/svg/Path.zig
index 15d4d79c0..ccdb78e42 100644
--- a/src/browser/webapi/element/svg/Path.zig
+++ b/src/browser/webapi/element/svg/Path.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Node = @import("../../Node.zig");
@@ -26,10 +28,11 @@ const Geometry = @import("Geometry.zig");
const Path = @This();
pub const Proto = Geometry;
-_proto: *Geometry,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *Geometry else void = undefined,
pub fn asElement(self: *Path) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Path) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/svg/Pattern.zig b/src/browser/webapi/element/svg/Pattern.zig
index 639812707..d30aa0066 100644
--- a/src/browser/webapi/element/svg/Pattern.zig
+++ b/src/browser/webapi/element/svg/Pattern.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Frame = @import("../../../Frame.zig");
@@ -32,10 +34,11 @@ const Svg = @import("../Svg.zig");
const Pattern = @This();
pub const Proto = Svg;
-_proto: *Svg,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *Svg else void = undefined,
pub fn asElement(self: *Pattern) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Pattern) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/svg/Polygon.zig b/src/browser/webapi/element/svg/Polygon.zig
index dac7e8741..cf7074bb2 100644
--- a/src/browser/webapi/element/svg/Polygon.zig
+++ b/src/browser/webapi/element/svg/Polygon.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Frame = @import("../../../Frame.zig");
@@ -28,10 +30,11 @@ const PointList = @import("../../svg/PointList.zig");
const Polygon = @This();
pub const Proto = Geometry;
-_proto: *Geometry,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *Geometry else void = undefined,
pub fn asElement(self: *Polygon) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Polygon) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/svg/Polyline.zig b/src/browser/webapi/element/svg/Polyline.zig
index a4e267af8..02e0d0346 100644
--- a/src/browser/webapi/element/svg/Polyline.zig
+++ b/src/browser/webapi/element/svg/Polyline.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Frame = @import("../../../Frame.zig");
@@ -28,10 +30,11 @@ const PointList = @import("../../svg/PointList.zig");
const Polyline = @This();
pub const Proto = Geometry;
-_proto: *Geometry,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *Geometry else void = undefined,
pub fn asElement(self: *Polyline) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Polyline) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/svg/RadialGradient.zig b/src/browser/webapi/element/svg/RadialGradient.zig
index 041ad36fc..981dd4c9c 100644
--- a/src/browser/webapi/element/svg/RadialGradient.zig
+++ b/src/browser/webapi/element/svg/RadialGradient.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Frame = @import("../../../Frame.zig");
@@ -29,10 +31,11 @@ const GradientElement = @import("GradientElement.zig");
const RadialGradient = @This();
pub const Proto = GradientElement;
-_proto: *GradientElement,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *GradientElement else void = undefined,
pub fn asElement(self: *RadialGradient) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *RadialGradient) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/svg/Rect.zig b/src/browser/webapi/element/svg/Rect.zig
index 99d0a1e8c..2cde221c1 100644
--- a/src/browser/webapi/element/svg/Rect.zig
+++ b/src/browser/webapi/element/svg/Rect.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Frame = @import("../../../Frame.zig");
const Node = @import("../../Node.zig");
@@ -26,10 +28,11 @@ const AnimatedLength = @import("../../svg/AnimatedLength.zig");
const Rect = @This();
pub const Proto = Geometry;
-_proto: *Geometry,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *Geometry else void = undefined,
pub fn asElement(self: *Rect) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Rect) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/svg/Stop.zig b/src/browser/webapi/element/svg/Stop.zig
index 845c9f863..dfc88c7ed 100644
--- a/src/browser/webapi/element/svg/Stop.zig
+++ b/src/browser/webapi/element/svg/Stop.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Frame = @import("../../../Frame.zig");
@@ -29,10 +31,11 @@ const Svg = @import("../Svg.zig");
const Stop = @This();
pub const Proto = Svg;
-_proto: *Svg,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *Svg else void = undefined,
pub fn asElement(self: *Stop) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Stop) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/svg/Svg.zig b/src/browser/webapi/element/svg/Svg.zig
index b0d9d88ed..4e2f4f467 100644
--- a/src/browser/webapi/element/svg/Svg.zig
+++ b/src/browser/webapi/element/svg/Svg.zig
@@ -16,9 +16,11 @@
// 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 lp = @import("lightpanda");
const std = @import("std");
const js = @import("../../../js/js.zig");
+const Factory = @import("../../../Factory.zig");
const Frame = @import("../../../Frame.zig");
const Node = @import("../../Node.zig");
@@ -39,10 +41,11 @@ const Graphics = @import("Graphics.zig");
const Svg = @This();
pub const Proto = Graphics;
-_proto: *Graphics,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *Graphics else void = undefined,
pub fn asElement(self: *Svg) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Svg) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/svg/Switch.zig b/src/browser/webapi/element/svg/Switch.zig
index 2c528b32d..8d7b5e77a 100644
--- a/src/browser/webapi/element/svg/Switch.zig
+++ b/src/browser/webapi/element/svg/Switch.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Node = @import("../../Node.zig");
@@ -26,10 +28,11 @@ const Graphics = @import("Graphics.zig");
const Switch = @This();
pub const Proto = Graphics;
-_proto: *Graphics,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *Graphics else void = undefined,
pub fn asElement(self: *Switch) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Switch) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/svg/Symbol.zig b/src/browser/webapi/element/svg/Symbol.zig
index c0793c9c4..4718c74b3 100644
--- a/src/browser/webapi/element/svg/Symbol.zig
+++ b/src/browser/webapi/element/svg/Symbol.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Node = @import("../../Node.zig");
@@ -26,10 +28,11 @@ const Graphics = @import("Graphics.zig");
const Symbol = @This();
pub const Proto = Graphics;
-_proto: *Graphics,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *Graphics else void = undefined,
pub fn asElement(self: *Symbol) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Symbol) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/svg/TSpan.zig b/src/browser/webapi/element/svg/TSpan.zig
index a2021df02..c7175bf6b 100644
--- a/src/browser/webapi/element/svg/TSpan.zig
+++ b/src/browser/webapi/element/svg/TSpan.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Node = @import("../../Node.zig");
@@ -26,10 +28,11 @@ const TextPositioning = @import("TextPositioning.zig");
const TSpan = @This();
pub const Proto = TextPositioning;
-_proto: *TextPositioning,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *TextPositioning else void = undefined,
pub fn asElement(self: *TSpan) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *TSpan) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/svg/Text.zig b/src/browser/webapi/element/svg/Text.zig
index bc4ed94b2..a4bb67e90 100644
--- a/src/browser/webapi/element/svg/Text.zig
+++ b/src/browser/webapi/element/svg/Text.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Node = @import("../../Node.zig");
@@ -26,10 +28,11 @@ const TextPositioning = @import("TextPositioning.zig");
const Text = @This();
pub const Proto = TextPositioning;
-_proto: *TextPositioning,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *TextPositioning else void = undefined,
pub fn asElement(self: *Text) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Text) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/svg/TextPath.zig b/src/browser/webapi/element/svg/TextPath.zig
index 627bb4605..dd5213292 100644
--- a/src/browser/webapi/element/svg/TextPath.zig
+++ b/src/browser/webapi/element/svg/TextPath.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Frame = @import("../../../Frame.zig");
@@ -31,10 +33,11 @@ const TextContent = @import("TextContent.zig");
const TextPath = @This();
pub const Proto = TextContent;
-_proto: *TextContent,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *TextContent else void = undefined,
pub fn asElement(self: *TextPath) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *TextPath) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/svg/Title.zig b/src/browser/webapi/element/svg/Title.zig
index 65660827e..b12707012 100644
--- a/src/browser/webapi/element/svg/Title.zig
+++ b/src/browser/webapi/element/svg/Title.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Node = @import("../../Node.zig");
@@ -26,10 +28,11 @@ const Svg = @import("../Svg.zig");
const Title = @This();
pub const Proto = Svg;
-_proto: *Svg,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *Svg else void = undefined,
pub fn asElement(self: *Title) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Title) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/svg/Use.zig b/src/browser/webapi/element/svg/Use.zig
index 8aa3b253f..300cfd3c3 100644
--- a/src/browser/webapi/element/svg/Use.zig
+++ b/src/browser/webapi/element/svg/Use.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Frame = @import("../../../Frame.zig");
@@ -28,10 +30,11 @@ const Graphics = @import("Graphics.zig");
const Use = @This();
pub const Proto = Graphics;
-_proto: *Graphics,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *Graphics else void = undefined,
pub fn asElement(self: *Use) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *Use) *Node {
return self.asElement().asNode();
diff --git a/src/browser/webapi/element/svg/View.zig b/src/browser/webapi/element/svg/View.zig
index 5554fced4..69a849828 100644
--- a/src/browser/webapi/element/svg/View.zig
+++ b/src/browser/webapi/element/svg/View.zig
@@ -16,6 +16,8 @@
// 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 lp = @import("lightpanda");
+const Factory = @import("../../../Factory.zig");
const js = @import("../../../js/js.zig");
const Node = @import("../../Node.zig");
@@ -26,10 +28,11 @@ const Svg = @import("../Svg.zig");
const View = @This();
pub const Proto = Svg;
-_proto: *Svg,
+_pad: bool = false,
+_proto_canary: if (lp.IS_DEBUG) *Svg else void = undefined,
pub fn asElement(self: *View) *Element {
- return self._proto.asElement();
+ return Factory.protoOf(self).asElement();
}
pub fn asNode(self: *View) *Node {
return self.asElement().asNode();