Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/browser/dom/comment.zig
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub const Comment = struct {

pub fn constructor(data: ?[]const u8, state: *const SessionState) !*parser.Comment {
return parser.documentCreateComment(
parser.documentHTMLToDocument(state.document.?),
parser.documentHTMLToDocument(state.window.document.?),
data orelse "",
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/browser/dom/document.zig
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ pub const Document = struct {

pub fn constructor(state: *const SessionState) !*parser.DocumentHTML {
const doc = try parser.documentCreateDocument(
try parser.documentHTMLGetTitle(state.document.?),
try parser.documentHTMLGetTitle(state.window.document.?),
);

// we have to work w/ document instead of html document.
const ddoc = parser.documentHTMLToDocument(doc);
const ccur = parser.documentHTMLToDocument(state.document.?);
const ccur = parser.documentHTMLToDocument(state.window.document.?);
try parser.documentSetDocumentURI(ddoc, try parser.documentGetDocumentURI(ccur));
try parser.documentSetInputEncoding(ddoc, try parser.documentGetInputEncoding(ccur));

Expand Down
2 changes: 1 addition & 1 deletion src/browser/dom/document_fragment.zig
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub const DocumentFragment = struct {

pub fn constructor(state: *const SessionState) !*parser.DocumentFragment {
return parser.documentCreateDocumentFragment(
parser.documentHTMLToDocument(state.document.?),
parser.documentHTMLToDocument(state.window.document.?),
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/browser/dom/intersection_observer.zig
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub const IntersectionObserver = struct {
// new IntersectionObserver(callback, options) [not supported yet]
pub fn constructor(callback: Env.Callback, options_: ?IntersectionObserverOptions, state: *SessionState) !IntersectionObserver {
var options = IntersectionObserverOptions{
.root = parser.documentToNode(parser.documentHTMLToDocument(state.document.?)),
.root = parser.documentToNode(parser.documentHTMLToDocument(state.window.document.?)),
.rootMargin = "0px 0px 0px 0px",
.threshold = &.{0.0},
};
Expand Down Expand Up @@ -142,7 +142,7 @@ pub const IntersectionObserverEntry = struct {
// Returns a DOMRectReadOnly for the intersection observer's root.
pub fn get_rootBounds(self: *const IntersectionObserverEntry) !Element.DOMRect {
const root = self.options.root.?;
if (@intFromPtr(root) == @intFromPtr(self.state.document.?)) {
if (@intFromPtr(root) == @intFromPtr(self.state.window.document.?)) {
return self.state.renderer.boundingRect();
}

Expand Down
2 changes: 1 addition & 1 deletion src/browser/dom/processing_instruction.zig
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub const ProcessingInstruction = struct {
// a simple workaround.
pub fn _cloneNode(self: *parser.ProcessingInstruction, _: ?bool, state: *SessionState) !*parser.ProcessingInstruction {
return try parser.documentCreateProcessingInstruction(
@ptrCast(state.document),
@ptrCast(state.window.document.?),
try get_target(self),
(try get_data(self)) orelse "",
);
Expand Down
2 changes: 1 addition & 1 deletion src/browser/dom/text.zig
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub const Text = struct {

pub fn constructor(data: ?[]const u8, state: *const SessionState) !*parser.Text {
return parser.documentCreateTextNode(
parser.documentHTMLToDocument(state.document.?),
parser.documentHTMLToDocument(state.window.document.?),
data orelse "",
);
}
Expand Down
1 change: 0 additions & 1 deletion src/browser/env.zig
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ pub const SessionState = struct {
arena: std.mem.Allocator,
http_client: *HttpClient,
cookie_jar: *storage.CookieJar,
document: ?*parser.DocumentHTML,

// dangerous, but set by the JS framework
// shorter-lived than the arena above, which
Expand Down
4 changes: 0 additions & 4 deletions src/browser/page.zig
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ pub const Page = struct {
.window_clicked_event_node = .{ .func = windowClicked },
.state = .{
.arena = arena,
.document = null,
.url = &self.url,
.window = &self.window,
.renderer = &self.renderer,
Expand Down Expand Up @@ -277,9 +276,6 @@ pub const Page = struct {

// https://html.spec.whatwg.org/#read-html

// update the sessions state
self.state.document = html_doc;

// browse the DOM tree to retrieve scripts
// TODO execute the synchronous scripts during the HTL parsing.
// TODO fetch the script resources concurrently but execute them in the
Expand Down
2 changes: 1 addition & 1 deletion src/main_wpt.zig
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ fn run(arena: Allocator, test_file: []const u8, loader: *FileLoader, err_out: *?
try polyfill.load(arena, runner.scope);

// loop over the scripts.
const doc = parser.documentHTMLToDocument(runner.state.document.?);
const doc = parser.documentHTMLToDocument(runner.state.window.document.?);
const scripts = try parser.documentGetElementsByTagName(doc, "script");
const script_count = try parser.nodeListLength(scripts);
for (0..script_count) |i| {
Expand Down
1 change: 0 additions & 1 deletion src/testing.zig
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,6 @@ pub const JsRunner = struct {
self.state = .{
.arena = arena,
.loop = &self.loop,
.document = document,
.url = &self.url,
.window = &self.window,
.renderer = &self.renderer,
Expand Down