new NavigationEventTarget on new page

This commit is contained in:
Muki Kiboigo
2025-11-05 08:35:28 -08:00
parent 38c6a9bd9d
commit 92ddb5640d
2 changed files with 9 additions and 0 deletions

View File

@@ -47,6 +47,12 @@ index: usize = 0,
entries: std.ArrayListUnmanaged(*NavigationHistoryEntry) = .empty,
next_entry_id: usize = 0,
pub fn resetForNewPage(self: *Navigation) void {
// libdom will automatically clean this up when a new page is made.
// We must create a new target whenever we create a new page.
self.proto = NavigationEventTarget{};
}
pub fn get_canGoBack(self: *const Navigation) bool {
return self.index > 0;
}

View File

@@ -104,6 +104,9 @@ pub const Session = struct {
// We need to init this early as JS event handlers may be registered through Runtime.evaluate before the first html doc is loaded
parser.init();
// creates a new event target for Navigation
self.navigation.resetForNewPage();
const page_arena = &self.browser.page_arena;
_ = page_arena.reset(.{ .retain_with_limit = 1 * 1024 * 1024 });
_ = self.browser.state_pool.reset(.{ .retain_with_limit = 4 * 1024 });