mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 07:03:29 +00:00
Merge pull request #628 from lightpanda-io/init_netsurf_at_page_creation
Init netsurf at page creation
This commit is contained in:
@@ -152,6 +152,10 @@ pub const Session = struct {
|
|||||||
pub fn createPage(self: *Session) !*Page {
|
pub fn createPage(self: *Session) !*Page {
|
||||||
std.debug.assert(self.page == null);
|
std.debug.assert(self.page == null);
|
||||||
|
|
||||||
|
// Start netsurf memory arena.
|
||||||
|
// We need to init this early as JS event handlers may be registered through Runtime.evaluate before the first html doc is loaded
|
||||||
|
try parser.init();
|
||||||
|
|
||||||
const page_arena = &self.browser.page_arena;
|
const page_arena = &self.browser.page_arena;
|
||||||
_ = page_arena.reset(.{ .retain_with_limit = 1 * 1024 * 1024 });
|
_ = page_arena.reset(.{ .retain_with_limit = 1 * 1024 * 1024 });
|
||||||
|
|
||||||
@@ -393,9 +397,6 @@ pub const Page = struct {
|
|||||||
fn loadHTMLDoc(self: *Page, reader: anytype, charset: []const u8) !void {
|
fn loadHTMLDoc(self: *Page, reader: anytype, charset: []const u8) !void {
|
||||||
const arena = self.arena;
|
const arena = self.arena;
|
||||||
|
|
||||||
// start netsurf memory arena.
|
|
||||||
try parser.init();
|
|
||||||
|
|
||||||
log.debug("parse html with charset {s}", .{charset});
|
log.debug("parse html with charset {s}", .{charset});
|
||||||
|
|
||||||
const ccharset = try arena.dupeZ(u8, charset);
|
const ccharset = try arena.dupeZ(u8, charset);
|
||||||
|
|||||||
@@ -121,7 +121,6 @@ const TestContext = struct {
|
|||||||
if (opts.html) |html| {
|
if (opts.html) |html| {
|
||||||
if (bc.session_id == null) bc.session_id = "SID-X";
|
if (bc.session_id == null) bc.session_id = "SID-X";
|
||||||
parser.deinit();
|
parser.deinit();
|
||||||
try parser.init();
|
|
||||||
const page = try bc.session.createPage();
|
const page = try bc.session.createPage();
|
||||||
page.doc = (try Document.init(html)).doc;
|
page.doc = (try Document.init(html)).doc;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user