mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-02-04 06:23:45 +00:00
Merge pull request #1409 from lightpanda-io/cleanup
zig fmt, remove unused code
This commit is contained in:
@@ -872,7 +872,7 @@ pub fn startHeapProfiler(self: *Context) void {
|
||||
self.heap_profiler = heap_profiler;
|
||||
}
|
||||
|
||||
pub fn stopHeapProfiler(self: *Context) !struct{[]const u8, []const u8} {
|
||||
pub fn stopHeapProfiler(self: *Context) !struct { []const u8, []const u8 } {
|
||||
var ls: js.Local.Scope = undefined;
|
||||
self.localScope(&ls);
|
||||
defer ls.deinit();
|
||||
@@ -893,5 +893,5 @@ pub fn stopHeapProfiler(self: *Context) !struct{[]const u8, []const u8} {
|
||||
break :blk try ls.local.jsStringToZig(string_handle, .{});
|
||||
};
|
||||
|
||||
return .{allocating, snapshot};
|
||||
return .{ allocating, snapshot };
|
||||
}
|
||||
|
||||
@@ -134,11 +134,3 @@ pub fn removeContext(self: *ExecutionWorld) void {
|
||||
self.env.isolate.notifyContextDisposed();
|
||||
_ = self.context_arena.reset(.{ .retain_with_limit = CONTEXT_ARENA_RETAIN });
|
||||
}
|
||||
|
||||
pub fn terminateExecution(self: *const ExecutionWorld) void {
|
||||
self.env.isolate.terminateExecution();
|
||||
}
|
||||
|
||||
pub fn resumeExecution(self: *const ExecutionWorld) void {
|
||||
self.env.isolate.cancelTerminateExecution();
|
||||
}
|
||||
|
||||
@@ -1190,7 +1190,8 @@ fn _debugValue(self: *const Local, js_val: js.Value, seen: *std.AutoHashMapUnman
|
||||
const js_obj = js_val.toObject();
|
||||
{
|
||||
// explicit scope because gop will become invalid in recursive call
|
||||
const gop = try seen.getOrPut(self.call_arena, js_obj.getId());
|
||||
const obj_id: u32 = @bitCast(v8.v8__Object__GetIdentityHash(js_obj.handle));
|
||||
const gop = try seen.getOrPut(self.call_arena, obj_id);
|
||||
if (gop.found_existing) {
|
||||
return writer.writeAll("<circular>\n");
|
||||
}
|
||||
|
||||
@@ -31,10 +31,6 @@ const Object = @This();
|
||||
local: *const js.Local,
|
||||
handle: *const v8.Object,
|
||||
|
||||
pub fn getId(self: Object) u32 {
|
||||
return @bitCast(v8.v8__Object__GetIdentityHash(self.handle));
|
||||
}
|
||||
|
||||
pub fn has(self: Object, key: anytype) bool {
|
||||
const ctx = self.local.ctx;
|
||||
const key_handle = if (@TypeOf(key) == *const v8.String) key else ctx.isolate.initStringHandle(key);
|
||||
|
||||
@@ -32,12 +32,8 @@ pub fn init(self: *TryCatch, l: *const js.Local) void {
|
||||
v8.v8__TryCatch__CONSTRUCT(&self.handle, l.isolate.handle);
|
||||
}
|
||||
|
||||
pub fn hasCaught(self: TryCatch) bool {
|
||||
return v8.v8__TryCatch__HasCaught(&self.handle);
|
||||
}
|
||||
|
||||
pub fn caught(self: TryCatch, allocator: Allocator) ?Caught {
|
||||
if (!self.hasCaught()) {
|
||||
if (!v8.v8__TryCatch__HasCaught(&self.handle)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -81,10 +81,6 @@ pub const ArrayBuffer = struct {
|
||||
pub const Exception = struct {
|
||||
local: *const Local,
|
||||
handle: *const v8.Value,
|
||||
|
||||
pub fn exception(self: Exception, allocator: Allocator) ![]const u8 {
|
||||
return self.local.valueToString(self.handel, .{ .allocator = allocator });
|
||||
}
|
||||
};
|
||||
|
||||
// These are simple types that we can convert to JS with only an isolate. This
|
||||
|
||||
@@ -49,7 +49,7 @@ pub fn dispatch(self: *NavigationEventTarget, event_type: DispatchType, page: *P
|
||||
|
||||
if (comptime IS_DEBUG) {
|
||||
if (page.js.local == null) {
|
||||
log.fatal(.bug, "null context scope", .{.src = "NavigationEventTarget.dispatch", .url = page.url});
|
||||
log.fatal(.bug, "null context scope", .{ .src = "NavigationEventTarget.dispatch", .url = page.url });
|
||||
std.debug.assert(page.js.local != null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ pub fn callPullIfNeeded(self: *ReadableStream) !void {
|
||||
|
||||
if (comptime IS_DEBUG) {
|
||||
if (self._page.js.local == null) {
|
||||
log.fatal(.bug, "null context scope", .{.src = "ReadableStream.callPullIfNeeded", .url = self._page.url});
|
||||
log.fatal(.bug, "null context scope", .{ .src = "ReadableStream.callPullIfNeeded", .url = self._page.url });
|
||||
std.debug.assert(self._page.js.local != null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ pub fn enqueue(self: *ReadableStreamDefaultController, chunk: Chunk) !void {
|
||||
|
||||
if (comptime IS_DEBUG) {
|
||||
if (self._page.js.local == null) {
|
||||
log.fatal(.bug, "null context scope", .{.src = "ReadableStreamDefaultController.enqueue", .url = self._page.url});
|
||||
log.fatal(.bug, "null context scope", .{ .src = "ReadableStreamDefaultController.enqueue", .url = self._page.url });
|
||||
std.debug.assert(self._page.js.local != null);
|
||||
}
|
||||
}
|
||||
@@ -113,7 +113,7 @@ pub fn close(self: *ReadableStreamDefaultController) !void {
|
||||
|
||||
if (comptime IS_DEBUG) {
|
||||
if (self._page.js.local == null) {
|
||||
log.fatal(.bug, "null context scope", .{.src = "ReadableStreamDefaultController.close", .url = self._page.url});
|
||||
log.fatal(.bug, "null context scope", .{ .src = "ReadableStreamDefaultController.close", .url = self._page.url });
|
||||
std.debug.assert(self._page.js.local != null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -771,11 +771,6 @@ const IsolatedWorld = struct {
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
pub fn createContextAndLoadPolyfills(self: *IsolatedWorld, page: *Page) !void {
|
||||
// We need to recreate the isolated world context
|
||||
try self.createContext(page);
|
||||
}
|
||||
};
|
||||
|
||||
// This is a generic because when we send a result we have two different
|
||||
|
||||
@@ -190,7 +190,7 @@ fn createIsolatedWorld(cmd: anytype) !void {
|
||||
|
||||
const world = try bc.createIsolatedWorld(params.worldName, params.grantUniveralAccess);
|
||||
const page = bc.session.currentPage() orelse return error.PageNotLoaded;
|
||||
try world.createContextAndLoadPolyfills(page);
|
||||
try world.createContext(page);
|
||||
const js_context = &world.executor.context.?;
|
||||
|
||||
// Create the auxdata json for the contextCreated event
|
||||
@@ -292,7 +292,7 @@ pub fn pageRemove(bc: anytype) !void {
|
||||
|
||||
pub fn pageCreated(bc: anytype, page: *Page) !void {
|
||||
for (bc.isolated_worlds.items) |*isolated_world| {
|
||||
try isolated_world.createContextAndLoadPolyfills(page);
|
||||
try isolated_world.createContext(page);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user