mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 12:44:43 +00:00
Merge pull request #1546 from lightpanda-io/document_createEvent
add more types to document.createEvent
This commit is contained in:
@@ -324,19 +324,38 @@ pub fn createRange(_: *const Document, page: *Page) !*Range {
|
|||||||
|
|
||||||
pub fn createEvent(_: *const Document, event_type: []const u8, page: *Page) !*@import("Event.zig") {
|
pub fn createEvent(_: *const Document, event_type: []const u8, page: *Page) !*@import("Event.zig") {
|
||||||
const Event = @import("Event.zig");
|
const Event = @import("Event.zig");
|
||||||
|
if (event_type.len > 100) {
|
||||||
|
return error.NotSupported;
|
||||||
|
}
|
||||||
|
const normalized = std.ascii.lowerString(&page.buf, event_type);
|
||||||
|
|
||||||
if (std.ascii.eqlIgnoreCase(event_type, "event") or std.ascii.eqlIgnoreCase(event_type, "events") or std.ascii.eqlIgnoreCase(event_type, "htmlevents")) {
|
if (std.mem.eql(u8, normalized, "event") or std.mem.eql(u8, normalized, "events") or std.mem.eql(u8, normalized, "htmlevents")) {
|
||||||
return Event.init("", null, page);
|
return Event.init("", null, page);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (std.ascii.eqlIgnoreCase(event_type, "customevent") or std.ascii.eqlIgnoreCase(event_type, "customevents")) {
|
if (std.mem.eql(u8, normalized, "customevent") or std.mem.eql(u8, normalized, "customevents")) {
|
||||||
const CustomEvent = @import("event/CustomEvent.zig");
|
const CustomEvent = @import("event/CustomEvent.zig");
|
||||||
const custom_event = try CustomEvent.init("", null, page);
|
return (try CustomEvent.init("", null, page)).asEvent();
|
||||||
return custom_event.asEvent();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (std.ascii.eqlIgnoreCase(event_type, "messageevent")) {
|
if (std.mem.eql(u8, normalized, "keyboardevent")) {
|
||||||
return error.NotSupported;
|
const KeyboardEvent = @import("event/KeyboardEvent.zig");
|
||||||
|
return (try KeyboardEvent.init("", null, page)).asEvent();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (std.mem.eql(u8, normalized, "mouseevent") or std.mem.eql(u8, normalized, "mouseevents")) {
|
||||||
|
const MouseEvent = @import("event/MouseEvent.zig");
|
||||||
|
return (try MouseEvent.init("", null, page)).asEvent();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (std.mem.eql(u8, normalized, "messageevent")) {
|
||||||
|
const MessageEvent = @import("event/MessageEvent.zig");
|
||||||
|
return (try MessageEvent.init("", null, page)).asEvent();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (std.mem.eql(u8, normalized, "uievent") or std.mem.eql(u8, normalized, "uievents")) {
|
||||||
|
const UIEvent = @import("event/UIEvent.zig");
|
||||||
|
return (try UIEvent.init("", null, page)).asEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
return error.NotSupported;
|
return error.NotSupported;
|
||||||
|
|||||||
Reference in New Issue
Block a user