mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +00:00
click event dispastched from CDP should be trusted
This commit is contained in:
@@ -3255,7 +3255,7 @@ pub fn triggerMouseClick(self: *Page, x: f64, y: f64) !void {
|
|||||||
.type = self._type,
|
.type = self._type,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const event = (try @import("webapi/event/MouseEvent.zig").init("click", .{
|
const event = (try @import("webapi/event/MouseEvent.zig").initTrusted(comptime .wrap("click"), .{
|
||||||
.bubbles = true,
|
.bubbles = true,
|
||||||
.cancelable = true,
|
.cancelable = true,
|
||||||
.composed = true,
|
.composed = true,
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ const EventTarget = @import("../EventTarget.zig");
|
|||||||
const UIEvent = @import("UIEvent.zig");
|
const UIEvent = @import("UIEvent.zig");
|
||||||
const PointerEvent = @import("PointerEvent.zig");
|
const PointerEvent = @import("PointerEvent.zig");
|
||||||
|
|
||||||
|
const Allocator = std.mem.Allocator;
|
||||||
|
|
||||||
const MouseEvent = @This();
|
const MouseEvent = @This();
|
||||||
|
|
||||||
pub const MouseButton = enum(u8) {
|
pub const MouseButton = enum(u8) {
|
||||||
@@ -83,12 +85,21 @@ pub fn init(typ: []const u8, _opts: ?Options, page: *Page) !*MouseEvent {
|
|||||||
const arena = try page.getArena(.{ .debug = "MouseEvent" });
|
const arena = try page.getArena(.{ .debug = "MouseEvent" });
|
||||||
errdefer page.releaseArena(arena);
|
errdefer page.releaseArena(arena);
|
||||||
const type_string = try String.init(arena, typ, .{});
|
const type_string = try String.init(arena, typ, .{});
|
||||||
|
return initWithTrusted(arena, type_string, _opts, false, page);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn initTrusted(typ: String, _opts: ?Options, page: *Page) !*MouseEvent {
|
||||||
|
const arena = try page.getArena(.{ .debug = "MouseEvent.trusted" });
|
||||||
|
errdefer page.releaseArena(arena);
|
||||||
|
return initWithTrusted(arena, typ, _opts, true, page);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn initWithTrusted(arena: Allocator, typ: String, _opts: ?Options, trusted: bool, page: *Page) !*MouseEvent {
|
||||||
const opts = _opts orelse Options{};
|
const opts = _opts orelse Options{};
|
||||||
|
|
||||||
const event = try page._factory.uiEvent(
|
const event = try page._factory.uiEvent(
|
||||||
arena,
|
arena,
|
||||||
type_string,
|
typ,
|
||||||
MouseEvent{
|
MouseEvent{
|
||||||
._type = .generic,
|
._type = .generic,
|
||||||
._proto = undefined,
|
._proto = undefined,
|
||||||
@@ -106,7 +117,7 @@ pub fn init(typ: []const u8, _opts: ?Options, page: *Page) !*MouseEvent {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
Event.populatePrototypes(event, opts, false);
|
Event.populatePrototypes(event, opts, trusted);
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user