mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 15:13:28 +00:00
Keep reference of current Page in Session
Signed-off-by: Francis Bouvier <francis@lightpanda.io>
This commit is contained in:
committed by
Pierre Tachoire
parent
4444d8a008
commit
bcf4083f9c
@@ -73,6 +73,7 @@ pub const Session = struct {
|
|||||||
window: Window,
|
window: Window,
|
||||||
// TODO move the shed to the browser?
|
// TODO move the shed to the browser?
|
||||||
storageShed: storage.Shed,
|
storageShed: storage.Shed,
|
||||||
|
page: ?*Page = null,
|
||||||
|
|
||||||
jstypes: [Types.len]usize = undefined,
|
jstypes: [Types.len]usize = undefined,
|
||||||
|
|
||||||
@@ -95,6 +96,8 @@ pub const Session = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn deinit(self: *Session) void {
|
fn deinit(self: *Session) void {
|
||||||
|
if (self.page) |page| page.end();
|
||||||
|
|
||||||
self.env.deinit();
|
self.env.deinit();
|
||||||
self.arena.deinit();
|
self.arena.deinit();
|
||||||
|
|
||||||
@@ -130,10 +133,12 @@ pub const Page = struct {
|
|||||||
alloc: std.mem.Allocator,
|
alloc: std.mem.Allocator,
|
||||||
session: *Session,
|
session: *Session,
|
||||||
) Page {
|
) Page {
|
||||||
return Page{
|
var page = Page{
|
||||||
.arena = std.heap.ArenaAllocator.init(alloc),
|
.arena = std.heap.ArenaAllocator.init(alloc),
|
||||||
.session = session,
|
.session = session,
|
||||||
};
|
};
|
||||||
|
session.page = &page;
|
||||||
|
return page;
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset js env and mem arena.
|
// reset js env and mem arena.
|
||||||
@@ -149,6 +154,7 @@ pub const Page = struct {
|
|||||||
|
|
||||||
pub fn deinit(self: *Page) void {
|
pub fn deinit(self: *Page) void {
|
||||||
self.arena.deinit();
|
self.arena.deinit();
|
||||||
|
self.session.page = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// dump writes the page content into the given file.
|
// dump writes the page content into the given file.
|
||||||
|
|||||||
Reference in New Issue
Block a user