mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-12-17 08:48:58 +00:00
Add support for CDP's DOM.requestChildNodes
https://github.com/lightpanda-io/browser/issues/866
This commit is contained in:
@@ -38,6 +38,7 @@ pub fn processMessage(cmd: anytype) !void {
|
||||
scrollIntoViewIfNeeded,
|
||||
getContentQuads,
|
||||
getBoxModel,
|
||||
requestChildNodes,
|
||||
}, cmd.input.action) orelse return error.UnknownMethod;
|
||||
|
||||
switch (action) {
|
||||
@@ -53,6 +54,7 @@ pub fn processMessage(cmd: anytype) !void {
|
||||
.scrollIntoViewIfNeeded => return scrollIntoViewIfNeeded(cmd),
|
||||
.getContentQuads => return getContentQuads(cmd),
|
||||
.getBoxModel => return getBoxModel(cmd),
|
||||
.requestChildNodes => return requestChildNodes(cmd),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -433,6 +435,29 @@ fn getBoxModel(cmd: anytype) !void {
|
||||
} }, .{});
|
||||
}
|
||||
|
||||
fn requestChildNodes(cmd: anytype) !void {
|
||||
const params = (try cmd.params(struct {
|
||||
nodeId: Node.Id,
|
||||
depth: i32 = 1,
|
||||
pierce: bool = false,
|
||||
})) orelse return error.InvalidParams;
|
||||
|
||||
const bc = cmd.browser_context orelse return error.BrowserContextNotLoaded;
|
||||
const session_id = bc.session_id orelse return error.SessionIdNotLoaded;
|
||||
const node = bc.node_registry.lookup_by_id.get(params.nodeId) orelse {
|
||||
return error.InvalidNode;
|
||||
};
|
||||
|
||||
try cmd.sendEvent("DOM.setChildNodes", .{
|
||||
.parentId = node.id,
|
||||
.nodes = bc.nodeWriter(node, .{.depth = params.depth, .exclude_root = true}),
|
||||
}, .{
|
||||
.session_id = session_id,
|
||||
});
|
||||
|
||||
return cmd.sendResult(null, .{});
|
||||
}
|
||||
|
||||
const testing = @import("../testing.zig");
|
||||
|
||||
test "cdp.dom: getSearchResults unknown search id" {
|
||||
|
||||
Reference in New Issue
Block a user