-
Notifications
You must be signed in to change notification settings - Fork 227
Cdp node children #502
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cdp node children #502
Conversation
Include direct descendant, with hooks for other serialization options. Don't include parentId if null.
Add Node writer. Different CDP messages want different child depths. For now, only support immediate children, but the new writer should make it easy to support variable.
I think we have 2 issues with this approach:
I think we shouldn't store the children of the node into the registry but compute and return them on demand, with the correct depth. Moreover the current code generates a crash.
this patch fix the issue: diff --git i/src/cdp/Node.zig w/src/cdp/Node.zig
index ed682a0..7cdb34f 100644
--- i/src/cdp/Node.zig
+++ w/src/cdp/Node.zig
@@ -94,14 +94,16 @@ pub const Registry = struct {
// but, just in case, let's try to keep things tidy.
errdefer _ = self.lookup_by_node.remove(n);
+ const node = try self.node_pool.create();
+ errdefer self.node_pool.destroy(node);
+
+ node_lookup_gop.value_ptr.* = node;
+
const id = self.node_id;
self.node_id = id + 1;
const child_nodes = try self.registerChildNodes(n);
- const node = try self.node_pool.create();
- errdefer self.node_pool.destroy(node);
-
node.* = .{
._node = n,
.id = id,
@@ -125,7 +127,6 @@ pub const Registry = struct {
// // TODO
// }
- node_lookup_gop.value_ptr.* = node;
try self.lookup_by_id.putNoClobber(self.allocator, id, node);
return node;
} |
Node registry now only tracks the node id (which we need to be consistent) and the underlying parser.Node. All other data is loaded on-demand (i.e. when we serialize the node). This allows us to serialize node values as they appear when they are serialized, as opposed to when they are registered.
Not just the children, other properties, like the value! I changed the CDP Node to just be the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I suppose later we can pass in the ParentID, no need to fetch and register it, except for the top level nodes.
There's a netsurf function to get the parent node, so it would be pretty easy to add now. However, there's this DOM.setChildNodes event (https://chromedevtools.github.io/devtools-protocol/tot/DOM/#event-setChildNodes) that we might have to raise. If we do, then we'd need to do that whenever we get a parent. So I'm waiting to see if we do, in fact, need to raise that event, before dealing with the parent. |
I was working in an older version of this branch patched with the fix mention here: After pulling the latest changes I get a
I will investigate tomorrow |
Fixed here: |
Add child nodes to CDP registry.
Add custom CDP Node writer to deal with different messages requiring a different representation (i.e. differnent child depth) of a node.