mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-30 15:41:48 +00:00
dom: nodelist: use unmanaged arraylist
This commit is contained in:
@@ -228,7 +228,7 @@ pub const Document = struct {
|
|||||||
if (try parser.nodeType(next.?) != .element) {
|
if (try parser.nodeType(next.?) != .element) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try list.append(next.?);
|
try list.append(alloc, next.?);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,7 +237,7 @@ pub const Document = struct {
|
|||||||
|
|
||||||
// walk over the node tree fo find the node by id.
|
// walk over the node tree fo find the node by id.
|
||||||
const e = try parser.documentGetElementById(self, selectors[1..]) orelse return list;
|
const e = try parser.documentGetElementById(self, selectors[1..]) orelse return list;
|
||||||
try list.append(parser.elementToNode(e));
|
try list.append(alloc, parser.elementToNode(e));
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -247,7 +247,7 @@ pub const Element = struct {
|
|||||||
if (try parser.nodeType(next.?) != .element) {
|
if (try parser.nodeType(next.?) != .element) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try list.append(next.?);
|
try list.append(alloc, next.?);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,7 +256,7 @@ pub const Element = struct {
|
|||||||
|
|
||||||
// walk over the node tree fo find the node by id.
|
// walk over the node tree fo find the node by id.
|
||||||
const n = try getElementById(self, selectors[1..]) orelse return list;
|
const n = try getElementById(self, selectors[1..]) orelse return list;
|
||||||
try list.append(n);
|
try list.append(alloc, n);
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ pub const Node = struct {
|
|||||||
|
|
||||||
var n = try parser.nodeFirstChild(self) orelse return list;
|
var n = try parser.nodeFirstChild(self) orelse return list;
|
||||||
while (true) {
|
while (true) {
|
||||||
try list.append(n);
|
try list.append(alloc, n);
|
||||||
n = try parser.nodeNextSibling(n) orelse return list;
|
n = try parser.nodeNextSibling(n) orelse return list;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,14 +18,14 @@ pub const NodeList = struct {
|
|||||||
pub const mem_guarantied = true;
|
pub const mem_guarantied = true;
|
||||||
pub const Exception = DOMException;
|
pub const Exception = DOMException;
|
||||||
|
|
||||||
const NodesArrayList = std.ArrayList(*parser.Node);
|
const NodesArrayList = std.ArrayListUnmanaged(*parser.Node);
|
||||||
|
|
||||||
nodes: NodesArrayList,
|
nodes: NodesArrayList,
|
||||||
|
|
||||||
pub fn init(alloc: std.mem.Allocator) !*NodeList {
|
pub fn init(alloc: std.mem.Allocator) !*NodeList {
|
||||||
const list = try alloc.create(NodeList);
|
const list = try alloc.create(NodeList);
|
||||||
list.* = NodeList{
|
list.* = NodeList{
|
||||||
.nodes = NodesArrayList.init(alloc),
|
.nodes = NodesArrayList{},
|
||||||
};
|
};
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
@@ -33,12 +33,12 @@ pub const NodeList = struct {
|
|||||||
|
|
||||||
pub fn deinit(self: *NodeList, alloc: std.mem.Allocator) void {
|
pub fn deinit(self: *NodeList, alloc: std.mem.Allocator) void {
|
||||||
// TODO unref all nodes
|
// TODO unref all nodes
|
||||||
self.nodes.deinit();
|
self.nodes.deinit(alloc);
|
||||||
alloc.destroy(self);
|
alloc.destroy(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn append(self: *NodeList, node: *parser.Node) !void {
|
pub fn append(self: *NodeList, alloc: std.mem.Allocator, node: *parser.Node) !void {
|
||||||
try self.nodes.append(node);
|
try self.nodes.append(alloc, node);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_length(self: *NodeList) u32 {
|
pub fn get_length(self: *NodeList) u32 {
|
||||||
|
|||||||
Reference in New Issue
Block a user