cleanup a not-so-great rebase

This commit is contained in:
Karl Seguin
2026-02-19 13:21:41 +08:00
parent bb01a5cb31
commit db2927eea7
4 changed files with 18 additions and 14 deletions

View File

@@ -226,7 +226,6 @@ frames_sorted: bool = true,
// DOM version used to invalidate cached state of "live" collections
version: usize = 0,
// This is maybe not great. It's a counter on the number of events that we're
// waiting on before triggering the "load" event. Essentially, we need all
// synchronous scripts and all iframes to be loaded. Scripts are handled by the
@@ -236,7 +235,7 @@ _pending_loads: u32,
_parent_notified: if (IS_DEBUG) bool else void = if (IS_DEBUG) false else {},
_type: enum { root, frame }, // only used for logs right now
_req_id: ?u32 = null,
_req_id: u32 = 0,
_navigated_options: ?NavigatedOpts = null,
pub fn init(self: *Page, id: u32, session: *Session, parent: ?*Page) !void {
@@ -1202,15 +1201,17 @@ pub fn iframeAddedCallback(self: *Page, iframe: *Element.Html.IFrame) !void {
return;
}
const session = self._session;
iframe._executed = true;
const page_frame = try self.arena.create(Page);
try Page.init(page_frame, self._session, self);
try Page.init(page_frame, session.nextPageId(), session, self);
self._pending_loads += 1;
page_frame.iframe = iframe;
iframe._content_window = page_frame.window;
page_frame.navigate(src, .{.reason = .initialFrameNavigation}) catch |err| {
page_frame.navigate(src, .{ .reason = .initialFrameNavigation }) catch |err| {
log.warn(.page, "iframe navigate failure", .{ .url = src, .err = err });
self._pending_loads -= 1;
iframe._content_window = null;

View File

@@ -91,12 +91,9 @@ pub fn deinit(self: *Session) void {
pub fn createPage(self: *Session) !*Page {
lp.assert(self.page == null, "Session.createPage - page not null", .{});
const id = self.page_id_gen +% 1;
self.page_id_gen = id;
self.page = @as(Page, undefined);
const page = &self.page.?;
try Page.init(page, id, self, null);
try Page.init(page, self.nextPageId(), self, null);
// Creates a new NavigationEventTarget for this page.
try self.navigation.onNewPage(page);
@@ -135,7 +132,7 @@ pub fn replacePage(self: *Session) !*Page {
var current = self.page.?;
const page_id = current.id;
const parent = current._parent;
const parent = current.parent;
current.deinit();
self.browser.env.memoryPressureNotification(.moderate);
@@ -335,12 +332,12 @@ fn processScheduledNavigation(self: *Session, current_page: *Page) !*Page {
const page_id, const parent = blk: {
const page = &self.page.?;
const page_id = page.id;
const parent = page._parent;
const parent = page.parent;
browser.http_client.abort();
self.removePage();
break :blk .{page_id, parent};
break :blk .{ page_id, parent };
};
self.page = @as(Page, undefined);
@@ -361,3 +358,9 @@ fn processScheduledNavigation(self: *Session, current_page: *Page) !*Page {
return page;
}
pub fn nextPageId(self: *Session) u32 {
const id = self.page_id_gen +% 1;
self.page_id_gen = id;
return id;
}

View File

@@ -342,7 +342,6 @@ pub fn click(self: *HtmlElement, page: *Page) !void {
try page._event_manager.dispatch(self.asEventTarget(), event);
}
<<<<<<< HEAD
// TODO: Per spec, hidden is a tristate: true | false | "until-found".
// We only support boolean for now; "until-found" would need bridge union support.
pub fn getHidden(self: *HtmlElement) bool {
@@ -374,7 +373,6 @@ pub fn setTabIndex(self: *HtmlElement, value: i32, page: *Page) !void {
try self.asElement().setAttributeSafe(comptime .wrap("tabindex"), .wrap(str), page);
}
pub fn getAttributeFunction(
self: *HtmlElement,
listener_type: GlobalEventHandler,

View File

@@ -250,9 +250,10 @@ pub fn pageNavigate(bc: anytype, event: *const Notification.PageNavigate) !void
else => unreachable,
},
.address_bar => null,
.initialFrameNavigation => "initialFrameNavigation",
};
if (reason_) |reason| {
if (reason != .initialFrameNavigation) {
if (event.opts.reason != .initialFrameNavigation) {
try cdp.sendEvent("Page.frameScheduledNavigation", .{
.frameId = frame_id,
.delay = 0,
@@ -346,6 +347,7 @@ pub fn pageNavigated(arena: Allocator, bc: anytype, event: *const Notification.P
else => unreachable,
},
.address_bar => null,
.initialFrameNavigation => "initialFrameNavigation",
};
if (reason_ != null) {