mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-02-04 14:33:47 +00:00
add missing handlescope
This commit is contained in:
@@ -176,12 +176,14 @@ pub fn getRemoteObject(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Gets a value by object ID regardless of which context it is in.
|
// Gets a value by object ID regardless of which context it is in.
|
||||||
// Our TaggedAnyOpaque stores the "resolved" ptr value (the most specific _type,
|
// Our TaggedOpaque stores the "resolved" ptr value (the most specific _type,
|
||||||
// e.g. we store the ptr to the Div not the EventTarget). But, this is asking for
|
// e.g. we store the ptr to the Div not the EventTarget). But, this is asking for
|
||||||
// the pointer to the Node, so we need to use the same resolution mechanism which
|
// the pointer to the Node, so we need to use the same resolution mechanism which
|
||||||
// is used when we're calling a function to turn the Div into a Node, which is
|
// is used when we're calling a function to turn the Div into a Node, which is
|
||||||
// what Context.typeTaggedAnyOpaque does.
|
// what TaggedOpaque.fromJS does.
|
||||||
pub fn getNodePtr(self: *const Inspector, allocator: Allocator, object_id: []const u8) !*anyopaque {
|
pub fn getNodePtr(self: *const Inspector, allocator: Allocator, object_id: []const u8, local: *js.Local) !*anyopaque {
|
||||||
|
// just to indicate that the caller is responsible for ensure there's a local environment
|
||||||
|
_ = local;
|
||||||
const unwrapped = try self.session.unwrapObject(allocator, object_id);
|
const unwrapped = try self.session.unwrapObject(allocator, object_id);
|
||||||
// The values context and groupId are not used here
|
// The values context and groupId are not used here
|
||||||
const js_val = unwrapped.value;
|
const js_val = unwrapped.value;
|
||||||
|
|||||||
@@ -392,15 +392,20 @@ fn scrollIntoViewIfNeeded(cmd: anytype) !void {
|
|||||||
return cmd.sendResult(null, .{});
|
return cmd.sendResult(null, .{});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn getNode(arena: Allocator, browser_context: anytype, node_id: ?Node.Id, backend_node_id: ?Node.Id, object_id: ?[]const u8) !*Node {
|
fn getNode(arena: Allocator, bc: anytype, node_id: ?Node.Id, backend_node_id: ?Node.Id, object_id: ?[]const u8) !*Node {
|
||||||
const input_node_id = node_id orelse backend_node_id;
|
const input_node_id = node_id orelse backend_node_id;
|
||||||
if (input_node_id) |input_node_id_| {
|
if (input_node_id) |input_node_id_| {
|
||||||
return browser_context.node_registry.lookup_by_id.get(input_node_id_) orelse return error.NodeNotFound;
|
return bc.node_registry.lookup_by_id.get(input_node_id_) orelse return error.NodeNotFound;
|
||||||
}
|
}
|
||||||
if (object_id) |object_id_| {
|
if (object_id) |object_id_| {
|
||||||
|
const page = bc.session.currentPage() orelse return error.PageNotLoaded;
|
||||||
|
var ls: js.Local.Scope = undefined;
|
||||||
|
page.js.localScope(&ls);
|
||||||
|
defer ls.deinit();
|
||||||
|
|
||||||
// Retrieve the object from which ever context it is in.
|
// Retrieve the object from which ever context it is in.
|
||||||
const parser_node = try browser_context.inspector.getNodePtr(arena, object_id_);
|
const parser_node = try bc.inspector.getNodePtr(arena, object_id_, &ls.local);
|
||||||
return try browser_context.node_registry.register(@ptrCast(@alignCast(parser_node)));
|
return try bc.node_registry.register(@ptrCast(@alignCast(parser_node)));
|
||||||
}
|
}
|
||||||
return error.MissingParams;
|
return error.MissingParams;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user