mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-07-30 17:25:58 -04:00
design: add explicit Proto declaration to every type
This is groundwork for eventually removing the _proto: *X` field from some types (in order to save 8 bytes per, e.g. Node). For now, all `_proto: *X` fields are untouched, BUT, all compile-time chain walking now happens against this new declaration.
This commit is contained in:
@@ -380,10 +380,7 @@ fn svgPrototypeTypes(comptime Child: type) []const type {
|
||||
var T = Child;
|
||||
|
||||
while (T != EventTarget) {
|
||||
if (!@hasField(T, "_proto")) {
|
||||
@compileError(@typeName(T) ++ " does not lead to EventTarget through _proto");
|
||||
}
|
||||
T = reflect.Struct(@FieldType(T, "_proto"));
|
||||
T = reflect.Proto(T) orelse @compileError(@typeName(T) ++ " does not lead to EventTarget through Proto");
|
||||
types = &[_]type{T} ++ types;
|
||||
}
|
||||
|
||||
@@ -425,7 +422,7 @@ pub fn destroy(self: *Factory, value: anytype) void {
|
||||
}
|
||||
}
|
||||
|
||||
if (comptime @hasField(S, "_proto")) {
|
||||
if (comptime reflect.Proto(S) != null) {
|
||||
self.destroyChain(value, 0, std.mem.Alignment.@"1");
|
||||
} else {
|
||||
self.destroyStandalone(value);
|
||||
@@ -451,7 +448,7 @@ fn destroyChain(
|
||||
const new_size = current_size + @sizeOf(S);
|
||||
const new_align = std.mem.Alignment.max(old_align, std.mem.Alignment.of(S));
|
||||
|
||||
if (@hasField(S, "_proto")) {
|
||||
if (comptime reflect.Proto(S) != null) {
|
||||
self.destroyChain(value._proto, new_size, new_align);
|
||||
} else {
|
||||
// no proto so this is the head of the chain.
|
||||
|
||||
@@ -22,6 +22,7 @@ const string = @import("../../string.zig");
|
||||
|
||||
const Page = @import("../Page.zig");
|
||||
const Frame = @import("../Frame.zig");
|
||||
const reflect = @import("../reflect.zig");
|
||||
|
||||
const js = @import("js.zig");
|
||||
const Local = @import("Local.zig");
|
||||
@@ -547,15 +548,14 @@ fn errorLocal(comptime T: type, local: *const Local, info: anytype) Local {
|
||||
};
|
||||
}
|
||||
|
||||
// Upcast a Node-descendant instance to *Node by walking the _proto chain.
|
||||
// Upcast a Node-descendant instance to *Node by walking the Proto chain.
|
||||
// Not every node type defines an asNode() helper (e.g. Comment, Text), but
|
||||
// inheritsOrIs guarantees Node is in the chain
|
||||
fn protoNode(comptime T: type, instance: *T) *@import("../webapi/Node.zig") {
|
||||
if (T == @import("../webapi/Node.zig")) {
|
||||
return instance;
|
||||
}
|
||||
const Proto = @typeInfo(std.meta.fieldInfo(T, ._proto).type).pointer.child;
|
||||
return protoNode(Proto, instance._proto);
|
||||
return protoNode(reflect.Proto(T).?, instance._proto);
|
||||
}
|
||||
|
||||
fn handleError(comptime T: type, comptime F: type, local: *const Local, err: anyerror, info: anytype) void {
|
||||
|
||||
@@ -25,6 +25,7 @@ const Page = @import("../Page.zig");
|
||||
|
||||
const js = @import("js.zig");
|
||||
const bridge = @import("bridge.zig");
|
||||
const reflect = @import("../reflect.zig");
|
||||
const Caller = @import("Caller.zig");
|
||||
const Context = @import("Context.zig");
|
||||
const Isolate = @import("Isolate.zig");
|
||||
@@ -1380,12 +1381,7 @@ fn findFinalizerType(comptime T: type) ?type {
|
||||
if (@hasDecl(S, "acquireRef")) {
|
||||
return S;
|
||||
}
|
||||
if (@hasField(S, "_proto")) {
|
||||
const ProtoPtr = std.meta.fieldInfo(S, ._proto).type;
|
||||
const ProtoChild = @typeInfo(ProtoPtr).pointer.child;
|
||||
return findFinalizerType(ProtoChild);
|
||||
}
|
||||
return null;
|
||||
return findFinalizerType(reflect.Proto(S) orelse return null);
|
||||
}
|
||||
|
||||
// Generate a function that follows the _proto pointer chain to get to the finalizer type
|
||||
@@ -1398,10 +1394,8 @@ fn finalizerPtrGetter(comptime T: type, comptime FT: type) *const fn (*T) *FT {
|
||||
}
|
||||
}.get;
|
||||
}
|
||||
if (@hasField(S, "_proto")) {
|
||||
const ProtoPtr = std.meta.fieldInfo(S, ._proto).type;
|
||||
const ProtoChild = @typeInfo(ProtoPtr).pointer.child;
|
||||
const childGetter = comptime finalizerPtrGetter(ProtoChild, FT);
|
||||
if (reflect.Proto(S)) |P| {
|
||||
const childGetter = comptime finalizerPtrGetter(P, FT);
|
||||
return struct {
|
||||
fn get(v: *T) *FT {
|
||||
return childGetter(v._proto);
|
||||
|
||||
@@ -21,6 +21,7 @@ const lp = @import("lightpanda");
|
||||
|
||||
const js = @import("js.zig");
|
||||
const bridge = @import("bridge.zig");
|
||||
const reflect = @import("../reflect.zig");
|
||||
|
||||
// Not ideal, but its children have special constructor rules (can be extended
|
||||
// can't be instantiated). And rather than coming up with a generic definition
|
||||
@@ -693,11 +694,7 @@ fn protoIndexLookup(comptime JsApi: type) ?u16 {
|
||||
@setEvalBranchQuota(100_000);
|
||||
comptime {
|
||||
const T = JsApi.bridge.type;
|
||||
if (!@hasField(T, "_proto")) {
|
||||
return null;
|
||||
}
|
||||
const Ptr = std.meta.fieldInfo(T, ._proto).type;
|
||||
const F = @typeInfo(Ptr).pointer.child;
|
||||
const F = reflect.Proto(T) orelse return null;
|
||||
// Look up in the provided API list
|
||||
for (JsApis, 0..) |Api, i| {
|
||||
if (Api == F.JsApi) {
|
||||
|
||||
@@ -20,6 +20,7 @@ const std = @import("std");
|
||||
const lp = @import("lightpanda");
|
||||
|
||||
const Frame = @import("../Frame.zig");
|
||||
const reflect = @import("../reflect.zig");
|
||||
|
||||
const js = @import("js.zig");
|
||||
const Caller = @import("Caller.zig");
|
||||
@@ -805,10 +806,7 @@ fn prototypeChainLength(comptime T: type) usize {
|
||||
|
||||
// Given a Type, gets its prototype Type (if any)
|
||||
fn PrototypeType(comptime T: type) ?type {
|
||||
if (!@hasField(T, "_proto")) {
|
||||
return null;
|
||||
}
|
||||
return Struct(std.meta.fieldInfo(T, ._proto).type);
|
||||
return reflect.Proto(T);
|
||||
}
|
||||
|
||||
fn flattenTypes(comptime Types: []const type) [countFlattenedTypes(Types)]type {
|
||||
@@ -1305,7 +1303,7 @@ pub const JsApis = blk: {
|
||||
break :blk base ++ [_]type{@import("../webapi/WebDriver.zig").JsApi};
|
||||
};
|
||||
|
||||
// Whether Child is Ancestor or inherits from it, following the _proto chain.
|
||||
// Whether Child is Ancestor or inherits from it, following the Proto chain.
|
||||
pub fn inheritsOrIs(comptime Child: type, comptime Ancestor: type) bool {
|
||||
comptime {
|
||||
const target = Ancestor.bridge.type;
|
||||
@@ -1314,10 +1312,7 @@ pub fn inheritsOrIs(comptime Child: type, comptime Ancestor: type) bool {
|
||||
if (T == target) {
|
||||
return true;
|
||||
}
|
||||
if (!@hasField(T, "_proto")) {
|
||||
return false;
|
||||
}
|
||||
T = @typeInfo(std.meta.fieldInfo(T, ._proto).type).pointer.child;
|
||||
T = reflect.Proto(T) orelse return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,19 @@
|
||||
// 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/>.
|
||||
|
||||
// The prototype ("parent") type of T, as declared by its `pub const Proto`.
|
||||
// This decl is the single source of truth for prototype-chain discovery;
|
||||
// a `_proto` field, where one exists, is only storage and must agree.
|
||||
pub fn Proto(comptime T: type) ?type {
|
||||
if (!@hasDecl(T, "Proto")) {
|
||||
return null;
|
||||
}
|
||||
if (@hasField(T, "_proto") and @FieldType(T, "_proto") != *T.Proto) {
|
||||
@compileError(@typeName(T) ++ ": _proto field and Proto decl disagree");
|
||||
}
|
||||
return T.Proto;
|
||||
}
|
||||
|
||||
// Gets the Parent of child.
|
||||
// HtmlElement.of(script) -> *HTMLElement
|
||||
pub fn Struct(comptime T: type) type {
|
||||
|
||||
@@ -31,6 +31,8 @@ const Execution = js.Execution;
|
||||
|
||||
const AbortSignal = @This();
|
||||
|
||||
pub const Proto = EventTarget;
|
||||
|
||||
const Dependend = union(enum) {
|
||||
signal: *AbortSignal,
|
||||
model_context_tool: *ModelContextTool,
|
||||
|
||||
@@ -29,6 +29,8 @@ const Execution = js.Execution;
|
||||
|
||||
const BroadcastChannel = @This();
|
||||
|
||||
pub const Proto = EventTarget;
|
||||
|
||||
_proto: *EventTarget,
|
||||
_exec: *Execution,
|
||||
_name: lp.String,
|
||||
|
||||
@@ -32,10 +32,21 @@ const String = lp.String;
|
||||
|
||||
const CData = @This();
|
||||
|
||||
pub const Proto = Node;
|
||||
|
||||
_type: Type,
|
||||
_proto: *Node,
|
||||
_data: String = .empty,
|
||||
|
||||
pub const Type = union(enum) {
|
||||
text: Text,
|
||||
comment: Comment,
|
||||
// This should be under Text, but that would require storing a _type union
|
||||
// in text, which would add 8 bytes to every text node.
|
||||
cdata_section: CDATASection,
|
||||
processing_instruction: *ProcessingInstruction,
|
||||
};
|
||||
|
||||
/// Count UTF-16 code units in a UTF-8 string.
|
||||
/// 4-byte UTF-8 sequences (codepoints >= U+10000) produce 2 UTF-16 code units (surrogate pair),
|
||||
/// everything else produces 1.
|
||||
@@ -180,15 +191,6 @@ fn utf16RangeToUtf8(data: []const u8, utf16_start: usize, utf16_end: usize) !str
|
||||
return .{ .start = start, .end = i };
|
||||
}
|
||||
|
||||
pub const Type = union(enum) {
|
||||
text: Text,
|
||||
comment: Comment,
|
||||
// This should be under Text, but that would require storing a _type union
|
||||
// in text, which would add 8 bytes to every text node.
|
||||
cdata_section: CDATASection,
|
||||
processing_instruction: *ProcessingInstruction,
|
||||
};
|
||||
|
||||
pub fn asNode(self: *CData) *Node {
|
||||
return self._proto;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@ const RO = @import("DOMMatrixReadOnly.zig");
|
||||
|
||||
const DOMMatrix = @This();
|
||||
|
||||
pub const Proto = RO;
|
||||
|
||||
_proto: *RO,
|
||||
|
||||
pub fn init(init_: ?js.Value, exec: *const js.Execution) !*DOMMatrix {
|
||||
|
||||
@@ -22,6 +22,8 @@ const RO = @import("DOMPointReadOnly.zig");
|
||||
|
||||
const DOMPoint = @This();
|
||||
|
||||
pub const Proto = RO;
|
||||
|
||||
_proto: *RO,
|
||||
|
||||
pub fn init(x_: ?f64, y_: ?f64, z_: ?f64, w_: ?f64, exec: *const js.Execution) !*DOMPoint {
|
||||
|
||||
@@ -26,6 +26,8 @@ pub const Data = RO.Data;
|
||||
|
||||
const DOMRect = @This();
|
||||
|
||||
pub const Proto = RO;
|
||||
|
||||
_proto: *RO,
|
||||
|
||||
pub fn init(x_: ?f64, y_: ?f64, width_: ?f64, height_: ?f64, exec: *const js.Execution) !*DOMRect {
|
||||
|
||||
@@ -37,6 +37,8 @@ const Allocator = std.mem.Allocator;
|
||||
|
||||
const DedicatedWorkerGlobalScope = @This();
|
||||
|
||||
pub const Proto = WorkerGlobalScope;
|
||||
|
||||
_proto: *WorkerGlobalScope,
|
||||
_worker: *Worker,
|
||||
_closed: bool = false,
|
||||
|
||||
@@ -50,6 +50,8 @@ const IS_DEBUG = @import("builtin").mode == .Debug;
|
||||
|
||||
const Document = @This();
|
||||
|
||||
pub const Proto = Node;
|
||||
|
||||
_type: Type,
|
||||
_proto: *Node,
|
||||
_frame: ?*Frame = null,
|
||||
|
||||
@@ -28,6 +28,8 @@ const Selector = @import("selector/Selector.zig");
|
||||
|
||||
const DocumentFragment = @This();
|
||||
|
||||
pub const Proto = Node;
|
||||
|
||||
_type: Type,
|
||||
_proto: *Node,
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@ const Node = @import("Node.zig");
|
||||
|
||||
const DocumentType = @This();
|
||||
|
||||
pub const Proto = Node;
|
||||
|
||||
_proto: *Node,
|
||||
_name: []const u8,
|
||||
_public_id: []const u8,
|
||||
|
||||
@@ -46,6 +46,8 @@ const String = lp.String;
|
||||
|
||||
const Element = @This();
|
||||
|
||||
pub const Proto = Node;
|
||||
|
||||
pub const DatasetLookup = std.AutoHashMapUnmanaged(*Element, *DOMStringMap);
|
||||
pub const StyleLookup = std.AutoHashMapUnmanaged(*Element, *CSSStyleProperties);
|
||||
pub const ClassListLookup = std.AutoHashMapUnmanaged(*Element, *collections.DOMTokenList);
|
||||
|
||||
@@ -26,6 +26,8 @@ const Blob = @import("Blob.zig");
|
||||
|
||||
const File = @This();
|
||||
|
||||
pub const Proto = Blob;
|
||||
|
||||
_proto: *Blob,
|
||||
_name: []const u8,
|
||||
_last_modified: i64,
|
||||
|
||||
@@ -33,6 +33,8 @@ const Allocator = std.mem.Allocator;
|
||||
/// https://developer.mozilla.org/en-US/docs/Web/API/FileReader
|
||||
const FileReader = @This();
|
||||
|
||||
pub const Proto = EventTarget;
|
||||
|
||||
_rc: lp.RC = .{},
|
||||
_exec: *Execution,
|
||||
_proto: *EventTarget,
|
||||
|
||||
@@ -28,6 +28,8 @@ const collections = @import("collections.zig");
|
||||
|
||||
const HTMLDocument = @This();
|
||||
|
||||
pub const Proto = Document;
|
||||
|
||||
_proto: *Document,
|
||||
_document_type: ?*DocumentType = null,
|
||||
|
||||
|
||||
@@ -29,6 +29,8 @@ const Execution = js.Execution;
|
||||
|
||||
const MessagePort = @This();
|
||||
|
||||
pub const Proto = EventTarget;
|
||||
|
||||
_proto: *EventTarget,
|
||||
|
||||
// The context this port lives in. The two ends of an entangled pair can be in
|
||||
|
||||
@@ -42,6 +42,8 @@ pub const AssignedSlotLookup = std.AutoHashMapUnmanaged(*Node, *Element.Html.Slo
|
||||
|
||||
const Node = @This();
|
||||
|
||||
pub const Proto = EventTarget;
|
||||
|
||||
_type: Type,
|
||||
_proto: *EventTarget,
|
||||
_parent: ?*Node = null,
|
||||
|
||||
@@ -29,6 +29,8 @@ const Allocator = std.mem.Allocator;
|
||||
|
||||
const Notification = @This();
|
||||
|
||||
pub const Proto = EventTarget;
|
||||
|
||||
_rc: lp.RC = .{},
|
||||
_arena: Allocator,
|
||||
_proto: *EventTarget,
|
||||
|
||||
@@ -444,6 +444,8 @@ pub const Entry = struct {
|
||||
};
|
||||
|
||||
pub const Mark = struct {
|
||||
pub const Proto = Entry;
|
||||
|
||||
_proto: *Entry,
|
||||
_detail: ?js.Value.Global,
|
||||
|
||||
@@ -489,6 +491,8 @@ pub const Mark = struct {
|
||||
};
|
||||
|
||||
pub const Measure = struct {
|
||||
pub const Proto = Entry;
|
||||
|
||||
_proto: *Entry,
|
||||
_detail: ?js.Value.Global,
|
||||
|
||||
|
||||
@@ -31,6 +31,8 @@ const String = lp.String;
|
||||
|
||||
const Range = @This();
|
||||
|
||||
pub const Proto = AbstractRange;
|
||||
|
||||
_proto: *AbstractRange,
|
||||
|
||||
pub fn init(frame: *Frame) !*Range {
|
||||
|
||||
@@ -29,6 +29,8 @@ pub fn registerTypes() []const type {
|
||||
|
||||
const Screen = @This();
|
||||
|
||||
pub const Proto = EventTarget;
|
||||
|
||||
_proto: *EventTarget,
|
||||
_orientation: ?*Orientation = null,
|
||||
|
||||
@@ -72,6 +74,8 @@ pub const JsApi = struct {
|
||||
};
|
||||
|
||||
pub const Orientation = struct {
|
||||
pub const Proto = EventTarget;
|
||||
|
||||
_proto: *EventTarget,
|
||||
|
||||
pub fn init(frame: *Frame) !*Orientation {
|
||||
|
||||
@@ -26,6 +26,8 @@ const Element = @import("Element.zig");
|
||||
|
||||
const ShadowRoot = @This();
|
||||
|
||||
pub const Proto = DocumentFragment;
|
||||
|
||||
pub const Mode = enum {
|
||||
open,
|
||||
closed,
|
||||
|
||||
@@ -45,6 +45,8 @@ const log = lp.log;
|
||||
|
||||
const SharedWorker = @This();
|
||||
|
||||
pub const Proto = EventTarget;
|
||||
|
||||
_proto: *EventTarget,
|
||||
_port: *MessagePort,
|
||||
_on_error: ?js.Function.Global = null,
|
||||
|
||||
@@ -36,6 +36,8 @@ const IS_DEBUG = @import("builtin").mode == .Debug;
|
||||
|
||||
const SharedWorkerGlobalScope = @This();
|
||||
|
||||
pub const Proto = WorkerGlobalScope;
|
||||
|
||||
_proto: *WorkerGlobalScope,
|
||||
_arena: Allocator,
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@ const AbstractRange = @import("AbstractRange.zig");
|
||||
|
||||
const StaticRange = @This();
|
||||
|
||||
pub const Proto = AbstractRange;
|
||||
|
||||
// The boundary points and `collapsed` accessor live on the shared AbstractRange
|
||||
// prototype. Unlike Range, a StaticRange is *static*: the factory keeps it out
|
||||
// of the frame's live-range list, so DOM mutations never move its boundaries.
|
||||
|
||||
@@ -22,6 +22,8 @@ const EventTarget = @import("EventTarget.zig");
|
||||
|
||||
const VisualViewport = @This();
|
||||
|
||||
pub const Proto = EventTarget;
|
||||
|
||||
_proto: *EventTarget,
|
||||
|
||||
pub fn asEventTarget(self: *VisualViewport) *EventTarget {
|
||||
|
||||
@@ -64,6 +64,8 @@ pub fn registerTypes() []const type {
|
||||
|
||||
const Window = @This();
|
||||
|
||||
pub const Proto = EventTarget;
|
||||
|
||||
_proto: *EventTarget,
|
||||
_frame: *Frame,
|
||||
_document: *Document,
|
||||
|
||||
@@ -36,6 +36,8 @@ const IS_DEBUG = @import("builtin").mode == .Debug;
|
||||
|
||||
const Worker = @This();
|
||||
|
||||
pub const Proto = EventTarget;
|
||||
|
||||
pub const WorkerType = enum {
|
||||
classic,
|
||||
module,
|
||||
|
||||
@@ -57,6 +57,8 @@ const Allocator = std.mem.Allocator;
|
||||
|
||||
const WorkerGlobalScope = @This();
|
||||
|
||||
pub const Proto = EventTarget;
|
||||
|
||||
_type: Type,
|
||||
_frame: *Frame,
|
||||
_is_module: bool,
|
||||
|
||||
@@ -23,6 +23,8 @@ const Node = @import("Node.zig");
|
||||
|
||||
const XMLDocument = @This();
|
||||
|
||||
pub const Proto = Document;
|
||||
|
||||
_proto: *Document,
|
||||
|
||||
pub fn asDocument(self: *XMLDocument) *Document {
|
||||
|
||||
@@ -22,6 +22,8 @@ const Text = @import("Text.zig");
|
||||
|
||||
const CDATASection = @This();
|
||||
|
||||
pub const Proto = Text;
|
||||
|
||||
_proto: *Text,
|
||||
|
||||
pub const JsApi = struct {
|
||||
|
||||
@@ -23,6 +23,8 @@ const CData = @import("../CData.zig");
|
||||
|
||||
const Comment = @This();
|
||||
|
||||
pub const Proto = CData;
|
||||
|
||||
_proto: *CData,
|
||||
|
||||
pub fn init(str: ?js.NullableString, frame: *Frame) !*Comment {
|
||||
|
||||
@@ -22,6 +22,8 @@ const CData = @import("../CData.zig");
|
||||
|
||||
const ProcessingInstruction = @This();
|
||||
|
||||
pub const Proto = CData;
|
||||
|
||||
_proto: *CData,
|
||||
_target: []const u8,
|
||||
|
||||
|
||||
@@ -27,6 +27,8 @@ const slotting = @import("../element/slotting.zig");
|
||||
|
||||
const Text = @This();
|
||||
|
||||
pub const Proto = CData;
|
||||
|
||||
_proto: *CData,
|
||||
|
||||
pub fn init(str: ?js.NullableString, frame: *Frame) !*Text {
|
||||
|
||||
@@ -30,6 +30,8 @@ const IS_DEBUG = @import("builtin").mode == .Debug;
|
||||
|
||||
const HTMLFormControlsCollection = @This();
|
||||
|
||||
pub const Proto = HTMLCollection;
|
||||
|
||||
_proto: *HTMLCollection,
|
||||
|
||||
// The refcount lives on the proto, but anchoring the finalizer here lets
|
||||
|
||||
@@ -25,6 +25,8 @@ const HTMLCollection = @import("HTMLCollection.zig");
|
||||
|
||||
const HTMLOptionsCollection = @This();
|
||||
|
||||
pub const Proto = HTMLCollection;
|
||||
|
||||
_proto: *HTMLCollection,
|
||||
_select: *@import("../element/html/Select.zig"),
|
||||
|
||||
|
||||
@@ -29,6 +29,8 @@ const HTMLFormControlsCollection = @import("HTMLFormControlsCollection.zig");
|
||||
|
||||
const RadioNodeList = @This();
|
||||
|
||||
pub const Proto = NodeList;
|
||||
|
||||
_proto: *NodeList,
|
||||
_name: []const u8,
|
||||
_form_collection: *HTMLFormControlsCollection,
|
||||
|
||||
@@ -25,6 +25,8 @@ const CSSStyleDeclaration = @import("CSSStyleDeclaration.zig");
|
||||
|
||||
const CSSStyleProperties = @This();
|
||||
|
||||
pub const Proto = CSSStyleDeclaration;
|
||||
|
||||
_proto: *CSSStyleDeclaration,
|
||||
|
||||
pub fn init(element: ?*Element, is_computed: bool, frame: *Frame) !*CSSStyleProperties {
|
||||
|
||||
@@ -6,6 +6,8 @@ const CSSStyleProperties = @import("CSSStyleProperties.zig");
|
||||
|
||||
const CSSStyleRule = @This();
|
||||
|
||||
pub const Proto = CSSRule;
|
||||
|
||||
_proto: *CSSRule,
|
||||
_selector_text: []const u8 = "",
|
||||
_style: ?*CSSStyleProperties = null,
|
||||
|
||||
@@ -32,6 +32,8 @@ const Allocator = std.mem.Allocator;
|
||||
|
||||
const FontFaceSet = @This();
|
||||
|
||||
pub const Proto = EventTarget;
|
||||
|
||||
_rc: lp.RC = .{},
|
||||
_proto: *EventTarget,
|
||||
_arena: Allocator,
|
||||
|
||||
@@ -24,6 +24,8 @@ const MediaQuery = @import("../../css/MediaQuery.zig");
|
||||
|
||||
const MediaQueryList = @This();
|
||||
|
||||
pub const Proto = EventTarget;
|
||||
|
||||
_proto: *EventTarget,
|
||||
_media: []const u8,
|
||||
|
||||
|
||||
@@ -41,6 +41,8 @@ pub fn registerTypes() []const type {
|
||||
|
||||
pub const Attribute = @This();
|
||||
|
||||
pub const Proto = Node;
|
||||
|
||||
_proto: *Node,
|
||||
_name: String,
|
||||
_value: String,
|
||||
|
||||
@@ -103,6 +103,8 @@ const IS_DEBUG = @import("builtin").mode == .Debug;
|
||||
|
||||
const HtmlElement = @This();
|
||||
|
||||
pub const Proto = Element;
|
||||
|
||||
_type: Type,
|
||||
_proto: *Element,
|
||||
|
||||
|
||||
@@ -41,6 +41,8 @@ pub const Stop = @import("svg/Stop.zig");
|
||||
const String = lp.String;
|
||||
|
||||
const Svg = @This();
|
||||
|
||||
pub const Proto = Element;
|
||||
_type: Type,
|
||||
_proto: *Element,
|
||||
_tag_name: String, // Svg elements are case-preserving
|
||||
|
||||
@@ -26,6 +26,8 @@ const Element = @import("../../Element.zig");
|
||||
const HtmlElement = @import("../Html.zig");
|
||||
|
||||
const Anchor = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
_proto: *HtmlElement,
|
||||
|
||||
pub fn asElement(self: *Anchor) *Element {
|
||||
|
||||
@@ -26,6 +26,8 @@ const HtmlElement = @import("../Html.zig");
|
||||
|
||||
const Area = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
|
||||
_proto: *HtmlElement,
|
||||
|
||||
pub fn asElement(self: *Area) *Element {
|
||||
|
||||
@@ -29,6 +29,8 @@ const String = lp.String;
|
||||
|
||||
const Audio = @This();
|
||||
|
||||
pub const Proto = Media;
|
||||
|
||||
_proto: *Media,
|
||||
|
||||
pub fn constructor(maybe_url: ?String, frame: *Frame) !*Media {
|
||||
|
||||
@@ -5,6 +5,8 @@ const HtmlElement = @import("../Html.zig");
|
||||
|
||||
const BR = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
|
||||
_proto: *HtmlElement,
|
||||
|
||||
pub fn asElement(self: *BR) *Element {
|
||||
|
||||
@@ -8,6 +8,8 @@ const HtmlElement = @import("../Html.zig");
|
||||
|
||||
const Base = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
|
||||
_proto: *HtmlElement,
|
||||
|
||||
pub fn asElement(self: *Base) *Element {
|
||||
|
||||
@@ -29,6 +29,8 @@ const String = lp.String;
|
||||
|
||||
const Body = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
|
||||
_proto: *HtmlElement,
|
||||
|
||||
pub fn asElement(self: *Body) *Element {
|
||||
|
||||
@@ -32,6 +32,8 @@ const popover = @import("../popover.zig");
|
||||
|
||||
const Button = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
|
||||
_proto: *HtmlElement,
|
||||
_custom_validity: ?[]const u8 = null,
|
||||
_validity: ?*ValidityState = null,
|
||||
|
||||
@@ -30,6 +30,8 @@ const OffscreenCanvas = @import("../../canvas/OffscreenCanvas.zig");
|
||||
const Execution = js.Execution;
|
||||
|
||||
const Canvas = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
_proto: *HtmlElement,
|
||||
_cached: ?DrawingContext = null,
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@ const log = lp.log;
|
||||
const String = lp.String;
|
||||
|
||||
const Custom = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
_proto: *HtmlElement,
|
||||
_tag_name: String,
|
||||
_definition: ?*CustomElementDefinition,
|
||||
|
||||
@@ -22,6 +22,8 @@ const Element = @import("../../Element.zig");
|
||||
const HtmlElement = @import("../Html.zig");
|
||||
|
||||
const DList = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
_proto: *HtmlElement,
|
||||
|
||||
pub fn asElement(self: *DList) *Element {
|
||||
|
||||
@@ -25,6 +25,8 @@ const HtmlElement = @import("../Html.zig");
|
||||
|
||||
const Data = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
|
||||
_proto: *HtmlElement,
|
||||
|
||||
pub fn asElement(self: *Data) *Element {
|
||||
|
||||
@@ -5,6 +5,8 @@ const HtmlElement = @import("../Html.zig");
|
||||
|
||||
const DataList = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
|
||||
_proto: *HtmlElement,
|
||||
|
||||
pub fn asElement(self: *DataList) *Element {
|
||||
|
||||
@@ -7,6 +7,8 @@ const HtmlElement = @import("../Html.zig");
|
||||
|
||||
const Details = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
|
||||
_proto: *HtmlElement,
|
||||
|
||||
pub fn asElement(self: *Details) *Element {
|
||||
|
||||
@@ -8,6 +8,8 @@ const HtmlElement = @import("../Html.zig");
|
||||
|
||||
const Dialog = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
|
||||
_proto: *HtmlElement,
|
||||
|
||||
pub fn asElement(self: *Dialog) *Element {
|
||||
|
||||
@@ -6,6 +6,8 @@ const HtmlElement = @import("../Html.zig");
|
||||
|
||||
const Directory = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
|
||||
_proto: *HtmlElement,
|
||||
|
||||
pub fn asElement(self: *Directory) *Element {
|
||||
|
||||
@@ -22,6 +22,8 @@ const Element = @import("../../Element.zig");
|
||||
const HtmlElement = @import("../Html.zig");
|
||||
|
||||
const Div = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
_proto: *HtmlElement,
|
||||
|
||||
pub fn asElement(self: *Div) *Element {
|
||||
|
||||
@@ -23,6 +23,8 @@ const Element = @import("../../Element.zig");
|
||||
const HtmlElement = @import("../Html.zig");
|
||||
|
||||
const Embed = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
_proto: *HtmlElement,
|
||||
|
||||
pub fn asElement(self: *Embed) *Element {
|
||||
|
||||
@@ -6,6 +6,8 @@ const HtmlElement = @import("../Html.zig");
|
||||
|
||||
const FieldSet = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
|
||||
_proto: *HtmlElement,
|
||||
|
||||
pub fn asElement(self: *FieldSet) *Element {
|
||||
|
||||
@@ -6,6 +6,8 @@ const HtmlElement = @import("../Html.zig");
|
||||
|
||||
const Font = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
|
||||
_proto: *HtmlElement,
|
||||
|
||||
pub fn asElement(self: *Font) *Element {
|
||||
|
||||
@@ -31,6 +31,8 @@ pub const Select = @import("Select.zig");
|
||||
pub const TextArea = @import("TextArea.zig");
|
||||
|
||||
const Form = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
_proto: *HtmlElement,
|
||||
|
||||
// Prevents submission of the form while we're in the process of submitting
|
||||
|
||||
@@ -11,6 +11,8 @@ const String = lp.String;
|
||||
|
||||
const FrameSet = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
|
||||
_proto: *HtmlElement,
|
||||
|
||||
pub fn asElement(self: *FrameSet) *Element {
|
||||
|
||||
@@ -27,6 +27,8 @@ const HtmlElement = @import("../Html.zig");
|
||||
const String = lp.String;
|
||||
|
||||
const Generic = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
_tag_name: String,
|
||||
_tag: Element.Tag,
|
||||
_proto: *HtmlElement,
|
||||
|
||||
@@ -22,6 +22,8 @@ const Element = @import("../../Element.zig");
|
||||
const HtmlElement = @import("../Html.zig");
|
||||
|
||||
const HR = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
_proto: *HtmlElement,
|
||||
|
||||
pub fn asElement(self: *HR) *Element {
|
||||
|
||||
@@ -22,6 +22,8 @@ const Element = @import("../../Element.zig");
|
||||
const HtmlElement = @import("../Html.zig");
|
||||
|
||||
const Head = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
_proto: *HtmlElement,
|
||||
|
||||
pub fn asElement(self: *Head) *Element {
|
||||
|
||||
@@ -27,6 +27,8 @@ const HtmlElement = @import("../Html.zig");
|
||||
const String = lp.String;
|
||||
|
||||
const Heading = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
_proto: *HtmlElement,
|
||||
_tag_name: String,
|
||||
_tag: Element.Tag,
|
||||
|
||||
@@ -22,6 +22,8 @@ const Element = @import("../../Element.zig");
|
||||
const HtmlElement = @import("../Html.zig");
|
||||
|
||||
const Html = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
_proto: *HtmlElement,
|
||||
|
||||
pub fn asElement(self: *Html) *Element {
|
||||
|
||||
@@ -30,6 +30,8 @@ const DOMTokenList = @import("../../collections.zig").DOMTokenList;
|
||||
const HtmlElement = @import("../Html.zig");
|
||||
|
||||
const IFrame = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
_proto: *HtmlElement,
|
||||
_src: []const u8 = "",
|
||||
_executed: bool = false,
|
||||
|
||||
@@ -6,6 +6,8 @@ const Element = @import("../../Element.zig");
|
||||
const HtmlElement = @import("../Html.zig");
|
||||
|
||||
const Image = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
_proto: *HtmlElement,
|
||||
|
||||
pub fn constructor(w_: ?u32, h_: ?u32, frame: *Frame) !*Image {
|
||||
|
||||
@@ -38,6 +38,8 @@ const String = lp.String;
|
||||
|
||||
const Input = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
|
||||
pub const Type = enum {
|
||||
text,
|
||||
password,
|
||||
|
||||
@@ -24,6 +24,8 @@ const Element = @import("../../Element.zig");
|
||||
const HtmlElement = @import("../Html.zig");
|
||||
|
||||
const LI = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
_proto: *HtmlElement,
|
||||
|
||||
pub fn asElement(self: *LI) *Element {
|
||||
|
||||
@@ -8,6 +8,8 @@ const TreeWalker = @import("../../TreeWalker.zig");
|
||||
|
||||
const Label = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
|
||||
_proto: *HtmlElement,
|
||||
|
||||
pub fn asElement(self: *Label) *Element {
|
||||
|
||||
@@ -5,6 +5,8 @@ const HtmlElement = @import("../Html.zig");
|
||||
|
||||
const Legend = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
|
||||
_proto: *HtmlElement,
|
||||
|
||||
pub fn asElement(self: *Legend) *Element {
|
||||
|
||||
@@ -27,6 +27,8 @@ const DOMTokenList = @import("../../collections.zig").DOMTokenList;
|
||||
const HtmlElement = @import("../Html.zig");
|
||||
|
||||
const Link = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
_proto: *HtmlElement,
|
||||
// Cached CSSStyleSheet for an external `rel=stylesheet` once
|
||||
// `Frame.loadExternalStylesheet` has registered it. Re-fetches (href
|
||||
|
||||
@@ -5,6 +5,8 @@ const HtmlElement = @import("../Html.zig");
|
||||
|
||||
const Map = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
|
||||
_proto: *HtmlElement,
|
||||
|
||||
pub fn asElement(self: *Map) *Element {
|
||||
|
||||
@@ -8,6 +8,8 @@ const HtmlElement = @import("../Html.zig");
|
||||
|
||||
const Marquee = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
|
||||
_proto: *HtmlElement,
|
||||
|
||||
pub fn asElement(self: *Marquee) *Element {
|
||||
|
||||
@@ -30,6 +30,8 @@ const MediaError = @import("../../media/MediaError.zig");
|
||||
|
||||
const Media = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
|
||||
pub const ReadyState = enum(u16) {
|
||||
HAVE_NOTHING = 0,
|
||||
HAVE_METADATA = 1,
|
||||
|
||||
@@ -23,6 +23,8 @@ const Element = @import("../../Element.zig");
|
||||
const HtmlElement = @import("../Html.zig");
|
||||
|
||||
const Meta = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
// Because we have a JsApi.Meta, "Meta" can be ambiguous in some scopes.
|
||||
// Create a different alias we can use when in such ambiguous cases.
|
||||
const MetaElement = Meta;
|
||||
|
||||
@@ -6,6 +6,8 @@ const HtmlElement = @import("../Html.zig");
|
||||
|
||||
const Meter = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
|
||||
_proto: *HtmlElement,
|
||||
|
||||
pub fn asElement(self: *Meter) *Element {
|
||||
|
||||
@@ -9,6 +9,8 @@ const String = lp.String;
|
||||
|
||||
const Mod = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
|
||||
_tag_name: String,
|
||||
_tag: Element.Tag,
|
||||
_proto: *HtmlElement,
|
||||
|
||||
@@ -24,6 +24,8 @@ const Element = @import("../../Element.zig");
|
||||
const HtmlElement = @import("../Html.zig");
|
||||
|
||||
const OL = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
_proto: *HtmlElement,
|
||||
|
||||
pub fn asElement(self: *OL) *Element {
|
||||
|
||||
@@ -5,6 +5,8 @@ const HtmlElement = @import("../Html.zig");
|
||||
|
||||
const Object = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
|
||||
_proto: *HtmlElement,
|
||||
|
||||
pub fn asElement(self: *Object) *Element {
|
||||
|
||||
@@ -6,6 +6,8 @@ const HtmlElement = @import("../Html.zig");
|
||||
|
||||
const OptGroup = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
|
||||
_proto: *HtmlElement,
|
||||
|
||||
pub fn asElement(self: *OptGroup) *Element {
|
||||
|
||||
@@ -30,6 +30,8 @@ const String = lp.String;
|
||||
|
||||
const Option = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
|
||||
_proto: *HtmlElement,
|
||||
_value: ?[]const u8 = null,
|
||||
_selected: bool = false,
|
||||
|
||||
@@ -27,6 +27,8 @@ const HtmlElement = @import("../Html.zig");
|
||||
|
||||
const Output = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
|
||||
_proto: *HtmlElement,
|
||||
|
||||
pub fn asElement(self: *Output) *Element {
|
||||
|
||||
@@ -22,6 +22,8 @@ const Element = @import("../../Element.zig");
|
||||
const HtmlElement = @import("../Html.zig");
|
||||
|
||||
const Paragraph = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
_proto: *HtmlElement,
|
||||
|
||||
pub fn asElement(self: *Paragraph) *Element {
|
||||
|
||||
@@ -6,6 +6,8 @@ const HtmlElement = @import("../Html.zig");
|
||||
|
||||
const Param = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
|
||||
_proto: *HtmlElement,
|
||||
|
||||
pub fn asElement(self: *Param) *Element {
|
||||
|
||||
@@ -5,6 +5,8 @@ const HtmlElement = @import("../Html.zig");
|
||||
|
||||
const Picture = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
|
||||
_proto: *HtmlElement,
|
||||
|
||||
pub fn asElement(self: *Picture) *Element {
|
||||
|
||||
@@ -5,6 +5,8 @@ const HtmlElement = @import("../Html.zig");
|
||||
|
||||
const Pre = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
|
||||
_proto: *HtmlElement,
|
||||
|
||||
pub fn asElement(self: *Pre) *Element {
|
||||
|
||||
@@ -6,6 +6,8 @@ const HtmlElement = @import("../Html.zig");
|
||||
|
||||
const Progress = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
|
||||
_proto: *HtmlElement,
|
||||
|
||||
pub fn asElement(self: *Progress) *Element {
|
||||
|
||||
@@ -10,6 +10,8 @@ const String = lp.String;
|
||||
|
||||
const Quote = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
|
||||
_tag_name: String,
|
||||
_tag: Element.Tag,
|
||||
_proto: *HtmlElement,
|
||||
|
||||
@@ -26,6 +26,8 @@ const HtmlElement = @import("../Html.zig");
|
||||
|
||||
const Script = @This();
|
||||
|
||||
pub const Proto = HtmlElement;
|
||||
|
||||
_proto: *HtmlElement,
|
||||
_src: []const u8 = "",
|
||||
_executed: bool = false,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user