Lightpanda: the headless browser designed for AI and automation
use StaticStringMap for lookup
Karl Seguin09a40926346d
diff --git a/src/browser/Frame.zig b/src/browser/Frame.zigindex 3a3924f26..e55af9316 100644--- a/src/browser/Frame.zig+++ b/src/browser/Frame.zig@@ -3151,11 +3151,8 @@ const SubmitFormOpts = struct {pub fn submitForm(self: *Frame, submitter_: ?*Element, form_: ?*Element.Html.Form, submit_opts: SubmitFormOpts) !void {const form = form_ orelse return;- // Interactive submission (submit button, requestSubmit) of a- // disconnected form does nothing; the programmatic form.submit() is- // exempt from the connectedness requirement (HTML "cannot navigate"- // only applies its connected clause to non-form elements).- if (submit_opts.fire_event and !form.asElement().asNode().isConnected()) {+ if (submit_opts.fire_event and form.asNode().isConnected() == false) {+ // interactive submission (e.g. submit button) noop if the form is disconnectedreturn;}diff --git a/src/browser/frame/user_input.zig b/src/browser/frame/user_input.zigindex 32f0c4456..3248974eb 100644--- a/src/browser/frame/user_input.zig+++ b/src/browser/frame/user_input.zig@@ -221,7 +221,7 @@ fn hasClickActivationBehavior(node: *Node) bool {fn isEditingHost(node: *Node) bool {const element = node.is(Element) orelse return false;const value = element.getAttributeSafe(.wrap("contenteditable")) orelse return false;- return !std.ascii.eqlIgnoreCase(value, "false");+ return std.ascii.eqlIgnoreCase(value, "false") == false;}// A mousedown on editable content focuses its editing host: the outermostdiff --git a/src/browser/webapi/EventTarget.zig b/src/browser/webapi/EventTarget.zigindex 0da77ee3b..454a88c64 100644--- a/src/browser/webapi/EventTarget.zig+++ b/src/browser/webapi/EventTarget.zig@@ -107,11 +107,13 @@ const AddEventListenerOptions = union(enum) {// event types are passive by default on the window, the document, and the// html and body elements.fn defaultPassiveValue(self: *EventTarget, typ: []const u8) bool {- const scroll_blocking = std.mem.eql(u8, typ, "touchstart") or- std.mem.eql(u8, typ, "touchmove") or- std.mem.eql(u8, typ, "wheel") or- std.mem.eql(u8, typ, "mousewheel");- if (!scroll_blocking) {+ const scroll_blocking_event_types = std.StaticStringMap(void).initComptime(.{+ .{"touchstart", {}},+ .{"touchmove", {}},+ .{"wheel", {}},+ .{"mousewheel", {}},+ });+ if (scroll_blocking_event_types.has(typ) == false) {return false;}diff --git a/src/browser/webapi/WebDriver.zig b/src/browser/webapi/WebDriver.zigindex 77bc445b8..140df74ea 100644--- a/src/browser/webapi/WebDriver.zig+++ b/src/browser/webapi/WebDriver.zig@@ -56,7 +56,6 @@ pub fn getComputedLabel(_: *const WebDriver, element: *Element, frame: *Frame) !// synchronously so the events are observable when the testdriver promise// resolves.pub fn click(_: *const WebDriver, element: *Element, frame: *Frame) !void {- // Disabled form controls don't receive real click events at all.if (element.is(Element.Html)) |html| {switch (html._type) {inline .button, .input, .textarea, .select => |i| {