mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 15:13:28 +00:00
dom: add collection get_next comment
This commit is contained in:
@@ -26,8 +26,15 @@ pub const HTMLCollection = struct {
|
|||||||
cur_idx: ?u32 = undefined,
|
cur_idx: ?u32 = undefined,
|
||||||
cur_node: ?*parser.Node = undefined,
|
cur_node: ?*parser.Node = undefined,
|
||||||
|
|
||||||
// next iterates hover the DOM tree to return the next following node or
|
// get_next iterates over the DOM tree to return the next following node or
|
||||||
// null at the end.
|
// null at the end.
|
||||||
|
//
|
||||||
|
// This implementation is a zig version of Netsurf code.
|
||||||
|
// http://source.netsurf-browser.org/libdom.git/tree/src/html/html_collection.c#n177
|
||||||
|
//
|
||||||
|
// The iteration is a depth first as required by the specification.
|
||||||
|
// https://dom.spec.whatwg.org/#htmlcollection
|
||||||
|
// https://dom.spec.whatwg.org/#concept-tree-order
|
||||||
fn get_next(root: *parser.Node, cur: *parser.Node) ?*parser.Node {
|
fn get_next(root: *parser.Node, cur: *parser.Node) ?*parser.Node {
|
||||||
// TODO deinit next
|
// TODO deinit next
|
||||||
var next = parser.nodeFirstChild(cur);
|
var next = parser.nodeFirstChild(cur);
|
||||||
@@ -61,7 +68,7 @@ pub const HTMLCollection = struct {
|
|||||||
return parser.nodeNextSibling(prev);
|
return parser.nodeNextSibling(prev);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// _get_length computes the collection's length dynamically according to
|
/// get_length computes the collection's length dynamically according to
|
||||||
/// the current root structure.
|
/// the current root structure.
|
||||||
// TODO: nodes retrieved must be de-referenced.
|
// TODO: nodes retrieved must be de-referenced.
|
||||||
pub fn get_length(self: *HTMLCollection, allocator: std.mem.Allocator) !u32 {
|
pub fn get_length(self: *HTMLCollection, allocator: std.mem.Allocator) !u32 {
|
||||||
|
|||||||
Reference in New Issue
Block a user