mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-12-15 15:58:57 +00:00
Merge pull request #1212 from lightpanda-io/cdp-dom-outerhtml
Some checks failed
e2e-test / zig build release (push) Has been cancelled
zig-test / zig build dev (push) Has been cancelled
zig-test / zig test (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
e2e-test / cdp-and-hyperfine-bench (push) Has been cancelled
e2e-test / perf-fmt (push) Has been cancelled
zig-test / browser fetch (push) Has been cancelled
zig-test / perf-fmt (push) Has been cancelled
nightly build / build-linux-x86_64 (push) Has been cancelled
nightly build / build-linux-aarch64 (push) Has been cancelled
nightly build / build-macos-aarch64 (push) Has been cancelled
nightly build / build-macos-x86_64 (push) Has been cancelled
wpt / web platform tests json output (push) Has been cancelled
wpt / perf-fmt (push) Has been cancelled
Some checks failed
e2e-test / zig build release (push) Has been cancelled
zig-test / zig build dev (push) Has been cancelled
zig-test / zig test (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
e2e-test / cdp-and-hyperfine-bench (push) Has been cancelled
e2e-test / perf-fmt (push) Has been cancelled
zig-test / browser fetch (push) Has been cancelled
zig-test / perf-fmt (push) Has been cancelled
nightly build / build-linux-x86_64 (push) Has been cancelled
nightly build / build-linux-aarch64 (push) Has been cancelled
nightly build / build-macos-aarch64 (push) Has been cancelled
nightly build / build-macos-x86_64 (push) Has been cancelled
wpt / web platform tests json output (push) Has been cancelled
wpt / perf-fmt (push) Has been cancelled
cdp: DOM.getouterHTML
This commit is contained in:
@@ -44,6 +44,7 @@ pub fn processMessage(cmd: anytype) !void {
|
|||||||
grantPermissions,
|
grantPermissions,
|
||||||
getWindowForTarget,
|
getWindowForTarget,
|
||||||
setDownloadBehavior,
|
setDownloadBehavior,
|
||||||
|
close,
|
||||||
}, cmd.input.action) orelse return error.UnknownMethod;
|
}, cmd.input.action) orelse return error.UnknownMethod;
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
@@ -54,6 +55,7 @@ pub fn processMessage(cmd: anytype) !void {
|
|||||||
.grantPermissions => return grantPermissions(cmd),
|
.grantPermissions => return grantPermissions(cmd),
|
||||||
.getWindowForTarget => return getWindowForTarget(cmd),
|
.getWindowForTarget => return getWindowForTarget(cmd),
|
||||||
.setDownloadBehavior => return setDownloadBehavior(cmd),
|
.setDownloadBehavior => return setDownloadBehavior(cmd),
|
||||||
|
.close => return cmd.sendResult(null, .{}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ const css = @import("../../browser/dom/css.zig");
|
|||||||
const parser = @import("../../browser/netsurf.zig");
|
const parser = @import("../../browser/netsurf.zig");
|
||||||
const dom_node = @import("../../browser/dom/node.zig");
|
const dom_node = @import("../../browser/dom/node.zig");
|
||||||
const Element = @import("../../browser/dom/element.zig").Element;
|
const Element = @import("../../browser/dom/element.zig").Element;
|
||||||
|
const dump = @import("../../browser/dump.zig");
|
||||||
|
|
||||||
pub fn processMessage(cmd: anytype) !void {
|
pub fn processMessage(cmd: anytype) !void {
|
||||||
const action = std.meta.stringToEnum(enum {
|
const action = std.meta.stringToEnum(enum {
|
||||||
@@ -41,6 +42,7 @@ pub fn processMessage(cmd: anytype) !void {
|
|||||||
getBoxModel,
|
getBoxModel,
|
||||||
requestChildNodes,
|
requestChildNodes,
|
||||||
getFrameOwner,
|
getFrameOwner,
|
||||||
|
getOuterHTML,
|
||||||
}, cmd.input.action) orelse return error.UnknownMethod;
|
}, cmd.input.action) orelse return error.UnknownMethod;
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
@@ -58,6 +60,7 @@ pub fn processMessage(cmd: anytype) !void {
|
|||||||
.getBoxModel => return getBoxModel(cmd),
|
.getBoxModel => return getBoxModel(cmd),
|
||||||
.requestChildNodes => return requestChildNodes(cmd),
|
.requestChildNodes => return requestChildNodes(cmd),
|
||||||
.getFrameOwner => return getFrameOwner(cmd),
|
.getFrameOwner => return getFrameOwner(cmd),
|
||||||
|
.getOuterHTML => return getOuterHTML(cmd),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -494,6 +497,27 @@ fn getFrameOwner(cmd: anytype) !void {
|
|||||||
return cmd.sendResult(.{ .nodeId = node.id, .backendNodeId = node.id }, .{});
|
return cmd.sendResult(.{ .nodeId = node.id, .backendNodeId = node.id }, .{});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn getOuterHTML(cmd: anytype) !void {
|
||||||
|
const params = (try cmd.params(struct {
|
||||||
|
nodeId: ?Node.Id = null,
|
||||||
|
backendNodeId: ?Node.Id = null,
|
||||||
|
objectId: ?[]const u8 = null,
|
||||||
|
includeShadowDOM: bool = false,
|
||||||
|
})) orelse return error.InvalidParams;
|
||||||
|
|
||||||
|
if (params.includeShadowDOM) {
|
||||||
|
log.warn(.cdp, "not implemented", .{ .feature = "DOM.getOuterHTML: Not implemented includeShadowDOM parameter" });
|
||||||
|
}
|
||||||
|
const bc = cmd.browser_context orelse return error.BrowserContextNotLoaded;
|
||||||
|
|
||||||
|
const node = try getNode(cmd.arena, bc, params.nodeId, params.backendNodeId, params.objectId);
|
||||||
|
|
||||||
|
var aw = std.Io.Writer.Allocating.init(cmd.arena);
|
||||||
|
try dump.writeNode(node._node, .{}, &aw.writer);
|
||||||
|
|
||||||
|
return cmd.sendResult(.{ .outerHTML = aw.written() }, .{});
|
||||||
|
}
|
||||||
|
|
||||||
const testing = @import("../testing.zig");
|
const testing = @import("../testing.zig");
|
||||||
|
|
||||||
test "cdp.dom: getSearchResults unknown search id" {
|
test "cdp.dom: getSearchResults unknown search id" {
|
||||||
|
|||||||
Reference in New Issue
Block a user