mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 15:13:28 +00:00
rename ts => timestamp, ctx => notify_ctx
This commit is contained in:
@@ -139,7 +139,7 @@ pub const Session = struct {
|
||||
jstypes: [Types.len]usize = undefined,
|
||||
|
||||
// recipient of notification, passed as the first parameter to notify
|
||||
ctx: *anyopaque,
|
||||
notify_ctx: *anyopaque,
|
||||
notify_func: *const fn (ctx: *anyopaque, notification: *const Notification) anyerror!void,
|
||||
|
||||
fn init(self: *Session, browser: *Browser, ctx: anytype) !void {
|
||||
@@ -159,9 +159,9 @@ pub const Session = struct {
|
||||
const allocator = app.allocator;
|
||||
self.* = .{
|
||||
.app = app,
|
||||
.ctx = any_ctx,
|
||||
.env = undefined,
|
||||
.browser = browser,
|
||||
.notify_ctx = any_ctx,
|
||||
.inspector = undefined,
|
||||
.notify_func = ContextStruct.notify,
|
||||
.http_client = browser.http_client,
|
||||
@@ -281,7 +281,7 @@ pub const Session = struct {
|
||||
}
|
||||
|
||||
fn notify(self: *const Session, notification: *const Notification) void {
|
||||
self.notify_func(self.ctx, notification) catch |err| {
|
||||
self.notify_func(self.notify_ctx, notification) catch |err| {
|
||||
log.err("notify {}: {}", .{ std.meta.activeTag(notification.*), err });
|
||||
};
|
||||
}
|
||||
@@ -386,7 +386,7 @@ pub const Page = struct {
|
||||
var request = try self.newHTTPRequest(.GET, url, .{ .navigation = true });
|
||||
defer request.deinit();
|
||||
|
||||
session.notify(&.{ .page_navigate = .{ .url = url, .ts = timestamp() } });
|
||||
session.notify(&.{ .page_navigate = .{ .url = url, .timestamp = timestamp() } });
|
||||
var response = try request.sendSync(.{});
|
||||
|
||||
// would be different than self.url in the case of a redirect
|
||||
@@ -428,7 +428,7 @@ pub const Page = struct {
|
||||
self.raw_data = arr.items;
|
||||
}
|
||||
|
||||
session.notify(&.{ .page_navigated = .{ .url = url, .ts = timestamp() } });
|
||||
session.notify(&.{ .page_navigated = .{ .url = url, .timestamp = timestamp() } });
|
||||
}
|
||||
|
||||
pub const ClickResult = union(enum) {
|
||||
|
||||
@@ -198,7 +198,7 @@ pub fn pageNavigate(bc: anytype, event: *const Notification.PageEvent) !void {
|
||||
.name = "init",
|
||||
.frameId = target_id,
|
||||
.loaderId = loader_id,
|
||||
.timestamp = event.ts,
|
||||
.timestamp = event.timestamp,
|
||||
}, .{ .session_id = session_id });
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ pub fn pageNavigated(bc: anytype, event: *const Notification.PageEvent) !void {
|
||||
std.debug.assert(bc.session.page != null);
|
||||
|
||||
var cdp = bc.cdp;
|
||||
const ts = event.ts;
|
||||
const timestamp = event.timestamp;
|
||||
const loader_id = bc.loader_id;
|
||||
const target_id = bc.target_id orelse unreachable;
|
||||
const session_id = bc.session_id orelse unreachable;
|
||||
@@ -236,7 +236,7 @@ pub fn pageNavigated(bc: anytype, event: *const Notification.PageEvent) !void {
|
||||
// TODO: partially hard coded
|
||||
try cdp.sendEvent(
|
||||
"Page.domContentEventFired",
|
||||
.{ .timestamp = ts },
|
||||
.{ .timestamp = timestamp },
|
||||
.{ .session_id = session_id },
|
||||
);
|
||||
|
||||
@@ -244,7 +244,7 @@ pub fn pageNavigated(bc: anytype, event: *const Notification.PageEvent) !void {
|
||||
// TODO: partially hard coded
|
||||
if (bc.page_life_cycle_events) {
|
||||
try cdp.sendEvent("Page.lifecycleEvent", LifecycleEvent{
|
||||
.timestamp = ts,
|
||||
.timestamp = timestamp,
|
||||
.name = "DOMContentLoaded",
|
||||
.frameId = target_id,
|
||||
.loaderId = loader_id,
|
||||
@@ -254,14 +254,14 @@ pub fn pageNavigated(bc: anytype, event: *const Notification.PageEvent) !void {
|
||||
// loadEventFired event
|
||||
try cdp.sendEvent(
|
||||
"Page.loadEventFired",
|
||||
.{ .timestamp = ts },
|
||||
.{ .timestamp = timestamp },
|
||||
.{ .session_id = session_id },
|
||||
);
|
||||
|
||||
// lifecycle DOMContentLoaded event
|
||||
if (bc.page_life_cycle_events) {
|
||||
try cdp.sendEvent("Page.lifecycleEvent", LifecycleEvent{
|
||||
.timestamp = ts,
|
||||
.timestamp = timestamp,
|
||||
.name = "load",
|
||||
.frameId = target_id,
|
||||
.loaderId = loader_id,
|
||||
|
||||
@@ -5,7 +5,7 @@ pub const Notification = union(enum) {
|
||||
page_navigated: PageEvent,
|
||||
|
||||
pub const PageEvent = struct {
|
||||
ts: u32,
|
||||
timestamp: u32,
|
||||
url: *const URL,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user