Replace SessionState directly with the Page.

This commit is contained in:
Karl Seguin
2025-05-27 18:35:35 +08:00
parent 1d0876af4d
commit 7d9951aa3c
34 changed files with 562 additions and 603 deletions

View File

@@ -555,7 +555,7 @@ const IsolatedWorld = struct {
// Currently we have only 1 page/frame and thus also only 1 state in the isolate world.
pub fn createContext(self: *IsolatedWorld, page: *Page) !void {
if (self.executor.scope != null) return error.Only1IsolatedContextSupported;
_ = try self.executor.startScope(&page.window, &page.state, {}, false);
_ = try self.executor.startScope(&page.window, page, {}, false);
}
};

View File

@@ -383,6 +383,7 @@ fn getContentQuads(cmd: anytype) !void {
})) orelse return error.InvalidParams;
const bc = cmd.browser_context orelse return error.BrowserContextNotLoaded;
const page = bc.session.currentPage() orelse return error.PageNotLoaded;
const node = try getNode(cmd.arena, bc, params.nodeId, params.backendNodeId, params.objectId);
@@ -397,7 +398,7 @@ fn getContentQuads(cmd: anytype) !void {
// Elements like SVGElement may have multiple quads.
const element = parser.nodeToElement(node._node);
const rect = try Element._getBoundingClientRect(element, &bc.session.page.?.state);
const rect = try Element._getBoundingClientRect(element, page);
const quad = rectToQuad(rect);
return cmd.sendResult(.{ .quads = &.{quad} }, .{});
@@ -411,6 +412,7 @@ fn getBoxModel(cmd: anytype) !void {
})) orelse return error.InvalidParams;
const bc = cmd.browser_context orelse return error.BrowserContextNotLoaded;
const page = bc.session.currentPage() orelse return error.PageNotLoaded;
const node = try getNode(cmd.arena, bc, params.nodeId, params.backendNodeId, params.objectId);
@@ -418,7 +420,7 @@ fn getBoxModel(cmd: anytype) !void {
if (try parser.nodeType(node._node) != .element) return error.NodeIsNotAnElement;
const element = parser.nodeToElement(node._node);
const rect = try Element._getBoundingClientRect(element, &bc.session.page.?.state);
const rect = try Element._getBoundingClientRect(element, page);
const quad = rectToQuad(rect);
return cmd.sendResult(.{ .model = BoxModel{