Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const Allocator = std.mem.Allocator;

const log = @import("log.zig");
const Http = @import("http/Http.zig");
const Platform = @import("browser/js/js.zig").Platform;
const Platform = @import("browser/js/Platform.zig");

const Telemetry = @import("telemetry/telemetry.zig").Telemetry;
const Notification = @import("notification.zig").Notification;
Expand Down
2 changes: 1 addition & 1 deletion src/browser/State.zig
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ style_sheet: ?*StyleSheet = null,

// for dom/document
active_element: ?*parser.Element = null,
adopted_style_sheets: ?js.JsObject = null,
adopted_style_sheets: ?js.Object = null,

// for HTMLSelectElement
// By default, if no option is explicitly selected, the first option should
Expand Down
16 changes: 8 additions & 8 deletions src/browser/console/console.zig
Original file line number Diff line number Diff line change
Expand Up @@ -28,39 +28,39 @@ pub const Console = struct {
timers: std.StringHashMapUnmanaged(u32) = .{},
counts: std.StringHashMapUnmanaged(u32) = .{},

pub fn _lp(values: []js.JsObject, page: *Page) !void {
pub fn _lp(values: []js.Object, page: *Page) !void {
if (values.len == 0) {
return;
}
log.fatal(.console, "lightpanda", .{ .args = try serializeValues(values, page) });
}

pub fn _log(values: []js.JsObject, page: *Page) !void {
pub fn _log(values: []js.Object, page: *Page) !void {
if (values.len == 0) {
return;
}
log.info(.console, "info", .{ .args = try serializeValues(values, page) });
}

pub fn _info(values: []js.JsObject, page: *Page) !void {
pub fn _info(values: []js.Object, page: *Page) !void {
return _log(values, page);
}

pub fn _debug(values: []js.JsObject, page: *Page) !void {
pub fn _debug(values: []js.Object, page: *Page) !void {
if (values.len == 0) {
return;
}
log.debug(.console, "debug", .{ .args = try serializeValues(values, page) });
}

pub fn _warn(values: []js.JsObject, page: *Page) !void {
pub fn _warn(values: []js.Object, page: *Page) !void {
if (values.len == 0) {
return;
}
log.warn(.console, "warn", .{ .args = try serializeValues(values, page) });
}

pub fn _error(values: []js.JsObject, page: *Page) !void {
pub fn _error(values: []js.Object, page: *Page) !void {
if (values.len == 0) {
return;
}
Expand Down Expand Up @@ -132,7 +132,7 @@ pub const Console = struct {
log.warn(.console, "timer stop", .{ .label = label, .elapsed = elapsed - kv.value });
}

pub fn _assert(assertion: js.JsObject, values: []js.JsObject, page: *Page) !void {
pub fn _assert(assertion: js.Object, values: []js.Object, page: *Page) !void {
if (assertion.isTruthy()) {
return;
}
Expand All @@ -143,7 +143,7 @@ pub const Console = struct {
log.info(.console, "assertion failed", .{ .values = serialized_values });
}

fn serializeValues(values: []js.JsObject, page: *Page) ![]const u8 {
fn serializeValues(values: []js.Object, page: *Page) ![]const u8 {
if (values.len == 0) {
return "";
}
Expand Down
2 changes: 1 addition & 1 deletion src/browser/crypto/crypto.zig
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const uuidv4 = @import("../../id.zig").uuidv4;
pub const Crypto = struct {
_not_empty: bool = true,

pub fn _getRandomValues(_: *const Crypto, js_obj: js.JsObject) !js.JsObject {
pub fn _getRandomValues(_: *const Crypto, js_obj: js.Object) !js.Object {
var into = try js_obj.toZig(Crypto, "getRandomValues", RandomValues);
const buf = into.asBuffer();
if (buf.len > 65_536) {
Expand Down
14 changes: 7 additions & 7 deletions src/browser/dom/Animation.zig
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ const Page = @import("../page.zig").Page;

const Animation = @This();

effect: ?js.JsObject,
timeline: ?js.JsObject,
effect: ?js.Object,
timeline: ?js.Object,
ready_resolver: ?js.PromiseResolver,
finished_resolver: ?js.PromiseResolver,

pub fn constructor(effect: ?js.JsObject, timeline: ?js.JsObject) !Animation {
pub fn constructor(effect: ?js.Object, timeline: ?js.Object) !Animation {
return .{
.effect = if (effect) |eo| try eo.persist() else null,
.timeline = if (timeline) |to| try to.persist() else null,
Expand Down Expand Up @@ -65,19 +65,19 @@ pub fn get_ready(self: *Animation, page: *Page) !js.Promise {
return self.ready_resolver.?.promise();
}

pub fn get_effect(self: *const Animation) ?js.JsObject {
pub fn get_effect(self: *const Animation) ?js.Object {
return self.effect;
}

pub fn set_effect(self: *Animation, effect: js.JsObject) !void {
pub fn set_effect(self: *Animation, effect: js.Object) !void {
self.effect = try effect.persist();
}

pub fn get_timeline(self: *const Animation) ?js.JsObject {
pub fn get_timeline(self: *const Animation) ?js.Object {
return self.timeline;
}

pub fn set_timeline(self: *Animation, timeline: js.JsObject) !void {
pub fn set_timeline(self: *Animation, timeline: js.Object) !void {
self.timeline = try timeline.persist();
}

Expand Down
26 changes: 13 additions & 13 deletions src/browser/dom/MessageChannel.zig
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,18 @@ pub const MessagePort = struct {
onmessageerror_cbk: ?js.Function = null,
// This is the queue of messages to dispatch to THIS MessagePort when the
// MessagePort is started.
queue: std.ArrayListUnmanaged(js.JsObject) = .empty,
queue: std.ArrayListUnmanaged(js.Object) = .empty,

pub const PostMessageOption = union(enum) {
transfer: js.JsObject,
transfer: js.Object,
options: Opts,

pub const Opts = struct {
transfer: js.JsObject,
transfer: js.Object,
};
};

pub fn _postMessage(self: *MessagePort, obj: js.JsObject, opts_: ?PostMessageOption, page: *Page) !void {
pub fn _postMessage(self: *MessagePort, obj: js.Object, opts_: ?PostMessageOption, page: *Page) !void {
if (self.closed) {
return;
}
Expand Down Expand Up @@ -150,7 +150,7 @@ pub const MessagePort = struct {

// called from our pair. If port1.postMessage("x") is called, then this
// will be called on port2.
fn dispatchOrQueue(self: *MessagePort, obj: js.JsObject, arena: Allocator) !void {
fn dispatchOrQueue(self: *MessagePort, obj: js.Object, arena: Allocator) !void {
// our pair should have checked this already
std.debug.assert(self.closed == false);

Expand All @@ -165,7 +165,7 @@ pub const MessagePort = struct {
return self.queue.append(arena, try obj.persist());
}

fn dispatch(self: *MessagePort, obj: js.JsObject) !void {
fn dispatch(self: *MessagePort, obj: js.Object) !void {
// obj is already persisted, don't use `MessageEvent.constructor`, but
// go directly to `init`, which assumes persisted objects.
var evt = try MessageEvent.init(.{ .data = obj });
Expand Down Expand Up @@ -205,12 +205,12 @@ pub const MessageEvent = struct {
pub const union_make_copy = true;

proto: parser.Event,
data: ?js.JsObject,
data: ?js.Object,

// You would think if port1 sends to port2, the source would be port2
// (which is how I read the documentation), but it appears to always be
// null. It can always be set explicitly via the constructor;
source: ?js.JsObject,
source: ?js.Object,

origin: []const u8,

Expand All @@ -224,8 +224,8 @@ pub const MessageEvent = struct {
ports: []*MessagePort,

const Options = struct {
data: ?js.JsObject = null,
source: ?js.JsObject = null,
data: ?js.Object = null,
source: ?js.Object = null,
origin: []const u8 = "",
lastEventId: []const u8 = "",
ports: []*MessagePort = &.{},
Expand All @@ -241,7 +241,7 @@ pub const MessageEvent = struct {
});
}

// This is like "constructor", but it assumes js.JsObjects have already been
// This is like "constructor", but it assumes js.Objects have already been
// persisted. Necessary because this `new MessageEvent()` can be called
// directly from JS OR from a port.postMessage. In the latter case, data
// may have already been persisted (as it might need to be queued);
Expand All @@ -261,15 +261,15 @@ pub const MessageEvent = struct {
};
}

pub fn get_data(self: *const MessageEvent) !?js.JsObject {
pub fn get_data(self: *const MessageEvent) !?js.Object {
return self.data;
}

pub fn get_origin(self: *const MessageEvent) []const u8 {
return self.origin;
}

pub fn get_source(self: *const MessageEvent) ?js.JsObject {
pub fn get_source(self: *const MessageEvent) ?js.Object {
return self.source;
}

Expand Down
4 changes: 2 additions & 2 deletions src/browser/dom/document.zig
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ pub const Document = struct {
return &.{};
}

pub fn get_adoptedStyleSheets(self: *parser.Document, page: *Page) !js.JsObject {
pub fn get_adoptedStyleSheets(self: *parser.Document, page: *Page) !js.Object {
const state = try page.getOrCreateNodeState(@ptrCast(@alignCast(self)));
if (state.adopted_style_sheets) |obj| {
return obj;
Expand All @@ -309,7 +309,7 @@ pub const Document = struct {
return obj;
}

pub fn set_adoptedStyleSheets(self: *parser.Document, sheets: js.JsObject, page: *Page) !void {
pub fn set_adoptedStyleSheets(self: *parser.Document, sheets: js.Object, page: *Page) !void {
const state = try page.getOrCreateNodeState(@ptrCast(@alignCast(self)));
state.adopted_style_sheets = try sheets.persist();
}
Expand Down
2 changes: 1 addition & 1 deletion src/browser/dom/element.zig
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ pub const Element = struct {
return sr;
}

pub fn _animate(self: *parser.Element, effect: js.JsObject, opts: js.JsObject) !Animation {
pub fn _animate(self: *parser.Element, effect: js.Object, opts: js.Object) !Animation {
_ = self;
_ = opts;
return Animation.constructor(effect, null);
Expand Down
2 changes: 1 addition & 1 deletion src/browser/dom/node_iterator.zig
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub const NodeIterator = struct {
// One of the few cases where null and undefined resolve to different default.
// We need the raw JsObject so that we can probe the tri state:
// null, undefined or i32.
pub const WhatToShow = js.JsObject;
pub const WhatToShow = js.Object;

pub const NodeIteratorOpts = union(enum) {
function: js.Function,
Expand Down
3 changes: 1 addition & 2 deletions src/browser/dom/nodelist.zig
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const js = @import("../js/js.zig");
const log = @import("../../log.zig");
const parser = @import("../netsurf.zig");


const NodeUnion = @import("node.zig").Union;
const Node = @import("node.zig").Node;

Expand Down Expand Up @@ -174,7 +173,7 @@ pub const NodeList = struct {
}

// TODO entries() https://developer.mozilla.org/en-US/docs/Web/API/NodeList/entries
pub fn postAttach(self: *NodeList, js_this: js.JsThis) !void {
pub fn postAttach(self: *NodeList, js_this: js.This) !void {
const len = self.get_length();
for (0..len) |i| {
const node = try self._item(@intCast(i)) orelse unreachable;
Expand Down
6 changes: 3 additions & 3 deletions src/browser/dom/performance.zig
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,10 @@ pub const PerformanceMark = struct {
pub const prototype = *PerformanceEntry;

proto: PerformanceEntry,
detail: ?js.JsObject,
detail: ?js.Object,

const Options = struct {
detail: ?js.JsObject = null,
detail: ?js.Object = null,
startTime: ?f64 = null,
};

Expand All @@ -171,7 +171,7 @@ pub const PerformanceMark = struct {
return .{ .proto = proto, .detail = detail };
}

pub fn get_detail(self: *const PerformanceMark) ?js.JsObject {
pub fn get_detail(self: *const PerformanceMark) ?js.Object {
return self.detail;
}
};
Expand Down
6 changes: 3 additions & 3 deletions src/browser/dom/shadow_root.zig
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub const ShadowRoot = struct {
mode: Mode,
host: *parser.Element,
proto: *parser.DocumentFragment,
adopted_style_sheets: ?js.JsObject = null,
adopted_style_sheets: ?js.Object = null,

pub const Mode = enum {
open,
Expand All @@ -45,7 +45,7 @@ pub const ShadowRoot = struct {
return Element.toInterface(self.host);
}

pub fn get_adoptedStyleSheets(self: *ShadowRoot, page: *Page) !js.JsObject {
pub fn get_adoptedStyleSheets(self: *ShadowRoot, page: *Page) !js.Object {
if (self.adopted_style_sheets) |obj| {
return obj;
}
Expand All @@ -55,7 +55,7 @@ pub const ShadowRoot = struct {
return obj;
}

pub fn set_adoptedStyleSheets(self: *ShadowRoot, sheets: js.JsObject) !void {
pub fn set_adoptedStyleSheets(self: *ShadowRoot, sheets: js.Object) !void {
self.adopted_style_sheets = try sheets.persist();
}

Expand Down
2 changes: 1 addition & 1 deletion src/browser/dom/token_list.zig
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ pub const DOMTokenList = struct {
}

// TODO handle thisArg
pub fn _forEach(self: *parser.TokenList, cbk: js.Function, this_arg: js.JsObject) !void {
pub fn _forEach(self: *parser.TokenList, cbk: js.Function, this_arg: js.Object) !void {
var entries = _entries(self);
while (try entries._next()) |entry| {
var result: js.Function.Result = undefined;
Expand Down
2 changes: 1 addition & 1 deletion src/browser/dom/tree_walker.zig
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub const TreeWalker = struct {
// One of the few cases where null and undefined resolve to different default.
// We need the raw JsObject so that we can probe the tri state:
// null, undefined or i32.
pub const WhatToShow = js.JsObject;
pub const WhatToShow = js.Object;

pub const TreeWalkerOpts = union(enum) {
function: js.Function,
Expand Down
8 changes: 4 additions & 4 deletions src/browser/events/custom_event.zig
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ pub const CustomEvent = struct {
pub const union_make_copy = true;

proto: parser.Event,
detail: ?js.JsObject,
detail: ?js.Object,

const CustomEventInit = struct {
bubbles: bool = false,
cancelable: bool = false,
composed: bool = false,
detail: ?js.JsObject = null,
detail: ?js.Object = null,
};

pub fn constructor(event_type: []const u8, opts_: ?CustomEventInit) !CustomEvent {
Expand All @@ -54,7 +54,7 @@ pub const CustomEvent = struct {
};
}

pub fn get_detail(self: *CustomEvent) ?js.JsObject {
pub fn get_detail(self: *CustomEvent) ?js.Object {
return self.detail;
}

Expand All @@ -65,7 +65,7 @@ pub const CustomEvent = struct {
event_type: []const u8,
can_bubble: bool,
cancelable: bool,
maybe_detail: ?js.JsObject,
maybe_detail: ?js.Object,
) !void {
// This function can only be called after the constructor has called.
// So we assume proto is initialized already by constructor.
Expand Down
2 changes: 1 addition & 1 deletion src/browser/events/event.zig
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ pub const EventHandler = struct {

pub const Listener = union(enum) {
function: js.Function,
object: js.JsObject,
object: js.Object,

pub fn callback(self: Listener, target: *parser.EventTarget) !?js.Function {
return switch (self) {
Expand Down
Loading