mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-02-04 14:33:47 +00:00
Walk document for doctype
This commit is contained in:
@@ -491,7 +491,13 @@ pub fn elementsFromPoint(self: *Document, x: f64, y: f64, page: *Page) ![]const
|
|||||||
return result.items;
|
return result.items;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn getDocType(_: *const Document) ?*DocumentType {
|
pub fn getDocType(self: *Document) ?*Node {
|
||||||
|
var tw = @import("TreeWalker.zig").Full.init(self.asNode(), .{});
|
||||||
|
while (tw.next()) |node| {
|
||||||
|
if (node._type == .document_type) {
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -215,6 +215,15 @@ pub fn getDocType(self: *HTMLDocument, page: *Page) !*DocumentType {
|
|||||||
if (self._document_type) |dt| {
|
if (self._document_type) |dt| {
|
||||||
return dt;
|
return dt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var tw = @import("TreeWalker.zig").Full.init(self.asNode(), .{});
|
||||||
|
while (tw.next()) |node| {
|
||||||
|
if (node._type == .document_type) {
|
||||||
|
self._document_type = node.as(DocumentType);
|
||||||
|
return self._document_type.?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
self._document_type = try page._factory.node(DocumentType{
|
self._document_type = try page._factory.node(DocumentType{
|
||||||
._proto = undefined,
|
._proto = undefined,
|
||||||
._name = "html",
|
._name = "html",
|
||||||
|
|||||||
Reference in New Issue
Block a user