mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-06-11 01:25:53 -04:00
pass arena into handlers (consistent with other handlers)
This commit is contained in:
@@ -778,6 +778,18 @@ pub const BrowserContext = struct {
|
||||
try @import("domains/fetch.zig").requestAuthRequired(self, data);
|
||||
}
|
||||
|
||||
pub fn onConsoleMessage(ctx: *anyopaque, msg: *const Notification.ConsoleMessage) !void {
|
||||
const self: *BrowserContext = @ptrCast(@alignCast(ctx));
|
||||
defer self.resetNotificationArena();
|
||||
return @import("domains/console.zig").consoleMessage(self.notification_arena, self, msg);
|
||||
}
|
||||
|
||||
pub fn onRuntimeConsoleMessage(ctx: *anyopaque, msg: *const Notification.ConsoleMessage) !void {
|
||||
const self: *BrowserContext = @ptrCast(@alignCast(ctx));
|
||||
defer self.resetNotificationArena();
|
||||
return @import("domains/runtime.zig").consoleMessage(self.notification_arena, self, msg);
|
||||
}
|
||||
|
||||
fn resetNotificationArena(self: *BrowserContext) void {
|
||||
defer _ = self.cdp.notification_arena.reset(.{ .retain_with_limit = 1024 * 64 });
|
||||
}
|
||||
@@ -849,20 +861,6 @@ pub const BrowserContext = struct {
|
||||
|
||||
try cdp.client.sendJSONRaw(buf);
|
||||
}
|
||||
|
||||
pub fn onConsoleMessage(ctx: *anyopaque, msg: *const Notification.ConsoleMessage) !void {
|
||||
const self: *BrowserContext = @ptrCast(@alignCast(ctx));
|
||||
defer self.resetNotificationArena();
|
||||
|
||||
return @import("domains/console.zig").consoleMessage(self, msg);
|
||||
}
|
||||
|
||||
pub fn onRuntimeConsoleMessage(ctx: *anyopaque, msg: *const Notification.ConsoleMessage) !void {
|
||||
const self: *BrowserContext = @ptrCast(@alignCast(ctx));
|
||||
defer self.resetNotificationArena();
|
||||
|
||||
return @import("domains/runtime.zig").consoleMessage(self, msg);
|
||||
}
|
||||
};
|
||||
|
||||
/// see: https://chromium.googlesource.com/chromium/src/+/master/third_party/blink/renderer/bindings/core/v8/V8BindingDesign.md#world
|
||||
|
||||
@@ -22,6 +22,8 @@ const id = @import("../id.zig");
|
||||
const CDP = @import("../CDP.zig");
|
||||
const Notification = @import("../../Notification.zig");
|
||||
|
||||
const Allocator = std.mem.Allocator;
|
||||
|
||||
pub fn processMessage(cmd: *CDP.Command) !void {
|
||||
const action = std.meta.stringToEnum(enum {
|
||||
enable,
|
||||
@@ -57,11 +59,11 @@ const ConsoleMessage = struct {
|
||||
columns: ?u32 = null,
|
||||
};
|
||||
|
||||
pub fn consoleMessage(bc: *CDP.BrowserContext, event: *const Notification.ConsoleMessage) !void {
|
||||
pub fn consoleMessage(arena: Allocator, bc: *CDP.BrowserContext, event: *const Notification.ConsoleMessage) !void {
|
||||
const session_id = bc.session_id orelse return;
|
||||
|
||||
// format values
|
||||
var aw: std.io.Writer.Allocating = .init(bc.notification_arena);
|
||||
var aw: std.io.Writer.Allocating = .init(arena);
|
||||
const w = &aw.writer;
|
||||
for (event.values, 0..) |v, i| {
|
||||
if (i != 0) try w.writeByte(' ');
|
||||
|
||||
@@ -23,6 +23,8 @@ const js = @import("../../browser/js/js.zig");
|
||||
const CDP = @import("../CDP.zig");
|
||||
const Notification = @import("../../Notification.zig");
|
||||
|
||||
const Allocator = std.mem.Allocator;
|
||||
|
||||
pub fn processMessage(cmd: *CDP.Command) !void {
|
||||
const action = std.meta.stringToEnum(enum {
|
||||
enable,
|
||||
@@ -125,7 +127,7 @@ const ConsoleMessage = struct {
|
||||
args: []RemoteObject,
|
||||
};
|
||||
|
||||
pub fn consoleMessage(bc: *CDP.BrowserContext, event: *const Notification.ConsoleMessage) !void {
|
||||
pub fn consoleMessage(arena: Allocator, bc: *CDP.BrowserContext, event: *const Notification.ConsoleMessage) !void {
|
||||
const session_id = bc.session_id orelse return;
|
||||
const frame = bc.session.currentFrame() orelse return error.FrameNotLoaded;
|
||||
|
||||
@@ -134,7 +136,6 @@ pub fn consoleMessage(bc: *CDP.BrowserContext, event: *const Notification.Consol
|
||||
defer ls.deinit();
|
||||
|
||||
const context_id = bc.inspector_session.inspector.getContextId(&ls.local);
|
||||
const arena = bc.notification_arena;
|
||||
|
||||
var args: std.ArrayList(RemoteObject) = .empty;
|
||||
for (event.values) |value| {
|
||||
|
||||
Reference in New Issue
Block a user