mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +00:00
Remove root context check from Env
This was only added [very briefly] when Env managed Origins, which it no longer does.
This commit is contained in:
@@ -332,12 +332,11 @@ pub fn deinit(self: *Page, abort_http: bool) void {
|
||||
session.releaseArena(qn.arena);
|
||||
}
|
||||
|
||||
const is_root = self.parent == null;
|
||||
session.browser.env.destroyContext(self.js, is_root);
|
||||
session.browser.env.destroyContext(self.js);
|
||||
|
||||
self._script_manager.shutdown = true;
|
||||
|
||||
if (is_root) {
|
||||
if (self.parent == null) {
|
||||
session.browser.http_client.abort();
|
||||
} else if (abort_http) {
|
||||
// a small optimization, it's faster to abort _everything_ on the root
|
||||
|
||||
@@ -276,7 +276,7 @@ pub fn replacePage(self: *Session) !*Page {
|
||||
|
||||
var current = self.page.?;
|
||||
const frame_id = current._frame_id;
|
||||
current.deinit(false);
|
||||
current.deinit(true);
|
||||
|
||||
self.resetPageResources();
|
||||
self.browser.env.memoryPressureNotification(.moderate);
|
||||
|
||||
@@ -342,7 +342,7 @@ pub fn createContext(self: *Env, page: *Page) !*Context {
|
||||
return context;
|
||||
}
|
||||
|
||||
pub fn destroyContext(self: *Env, context: *Context, is_root: bool) void {
|
||||
pub fn destroyContext(self: *Env, context: *Context) void {
|
||||
for (self.contexts[0..self.context_count], 0..) |ctx, i| {
|
||||
if (ctx == context) {
|
||||
// Swap with last element and decrement count
|
||||
@@ -365,14 +365,6 @@ pub fn destroyContext(self: *Env, context: *Context, is_root: bool) void {
|
||||
}
|
||||
|
||||
context.deinit();
|
||||
|
||||
if (is_root) {
|
||||
// When the root is destroyed, all of our contexts should be gone.
|
||||
// Origin cleanup happens in Session.resetPageResources.
|
||||
if (comptime IS_DEBUG) {
|
||||
std.debug.assert(self.context_count == 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn runMicrotasks(self: *Env) void {
|
||||
|
||||
@@ -759,7 +759,7 @@ const IsolatedWorld = struct {
|
||||
|
||||
pub fn removeContext(self: *IsolatedWorld) !void {
|
||||
const ctx = self.context orelse return error.NoIsolatedContextToRemove;
|
||||
self.browser.env.destroyContext(ctx, false);
|
||||
self.browser.env.destroyContext(ctx);
|
||||
self.context = null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user