browser: inject document URL

This commit is contained in:
Pierre Tachoire
2024-02-29 13:37:08 +01:00
parent 08e2365d75
commit 399c7def51
2 changed files with 8 additions and 1 deletions

View File

@@ -224,7 +224,9 @@ pub const Page = struct {
// TODO set document.readyState to interactive // TODO set document.readyState to interactive
// https://html.spec.whatwg.org/#reporting-document-loading-status // https://html.spec.whatwg.org/#reporting-document-loading-status
// TODO inject the URL to the document including the fragment. // inject the URL to the document including the fragment.
try parser.documentSetDocumentURI(doc, self.rawuri orelse "about:blank");
// TODO set the referrer to the document. // TODO set the referrer to the document.
self.session.window.replaceDocument(doc); self.session.window.replaceDocument(doc);

View File

@@ -1653,6 +1653,11 @@ pub inline fn documentGetDocumentURI(doc: *Document) ![]const u8 {
return strToData(s.?); return strToData(s.?);
} }
pub fn documentSetDocumentURI(doc: *Document, uri: []const u8) !void {
const err = documentVtable(doc).dom_document_set_uri.?(doc, try strFromData(uri));
try DOMErr(err);
}
pub inline fn documentGetInputEncoding(doc: *Document) ![]const u8 { pub inline fn documentGetInputEncoding(doc: *Document) ![]const u8 {
var s: ?*String = undefined; var s: ?*String = undefined;
const err = documentVtable(doc).dom_document_get_input_encoding.?(doc, &s); const err = documentVtable(doc).dom_document_get_input_encoding.?(doc, &s);