mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 12:44:43 +00:00
Give EventManager.dispatch and explicit error set
This allows potentially recursive callers to use an implicit error set return.
This commit is contained in:
@@ -157,7 +157,18 @@ pub fn remove(self: *EventManager, target: *EventTarget, typ: []const u8, callba
|
||||
}
|
||||
}
|
||||
|
||||
pub fn dispatch(self: *EventManager, target: *EventTarget, event: *Event) !void {
|
||||
// Dispatching can be recursive from the compiler's point of view, so we need to
|
||||
// give it an explicit error set so that other parts of the code can use and
|
||||
// inferred error.
|
||||
const DispatchError = error{
|
||||
OutOfMemory,
|
||||
StringTooLarge,
|
||||
JSExecCallback,
|
||||
CompilationError,
|
||||
ExecutionError,
|
||||
JsException,
|
||||
};
|
||||
pub fn dispatch(self: *EventManager, target: *EventTarget, event: *Event) DispatchError!void {
|
||||
if (comptime IS_DEBUG) {
|
||||
log.debug(.event, "eventManager.dispatch", .{ .type = event._type_string.str(), .bubbles = event._bubbles });
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ pub fn setOnSelectionChange(self: *Input, listener: ?js.Function) !void {
|
||||
}
|
||||
}
|
||||
|
||||
fn dispatchSelectionChangeEvent(self: *Input, page: *Page) anyerror!void {
|
||||
fn dispatchSelectionChangeEvent(self: *Input, page: *Page) !void {
|
||||
const event = try Event.init("selectionchange", .{ .bubbles = true }, page);
|
||||
defer if (!event._v8_handoff) event.deinit(false);
|
||||
try page._event_manager.dispatch(self.asElement().asEventTarget(), event);
|
||||
|
||||
Reference in New Issue
Block a user