Lightpanda: the headless browser designed for AI and automation
Merge branch 'main' into zig-0.17
Karl Seguinab4cc02bdc33
diff --cc src/browser/StyleManager.zigindex 3b8c57ae7,7aca392dd..405324daa--- a/src/browser/StyleManager.zig+++ b/src/browser/StyleManager.zig@@@ -1362,9 -1369,9 +1369,9 @@@ const Visibility = struct// element — per CSS Cascade §6.1 any normal-origin author rule beats UA// origin regardless of specificity, so `.x { display: flex }` on a// `<div class="x" hidden>` must report visible.- pub fn finish(p: *Cascaded, el: *Element, priorities: *const Priorities(Declared)) void {- fn finish(p: *Cascaded, el: *Element, frame: *Frame, priorities: *const Priorities(Declared)) void {++ pub fn finish(p: *Cascaded, el: *Element, frame: *Frame, priorities: *const Priorities(Declared)) void {p.author_display = priorities.get(.display) != 0;- if (!p.author_display and matchesUaDisplayNoneRule(el)) {+ if (!p.author_display and matchesUaDisplayNoneRule(el, frame)) {p.display = .none;}}diff --cc src/browser/clutter.zigindex 33469b6c5,bf9db8868..e8ff74bd9--- a/src/browser/clutter.zig+++ b/src/browser/clutter.zig@@@ -972,12 -974,17 +974,18 @@@ test "clutter: the HTML dump leaves outry dump.render(state, .{}, &aw.writer, frame);const out = aw.written();- try testing.expectEqual(true, std.mem.indexOf(u8, out, "wild lactobacillaceae") != null);+ try testing.expectEqual(true, std.mem.find(u8, out, "wild lactobacillaceae") != null);// Neither node renders, so RenderTree never yields either one; the set// still has to hold them, because the HTML dump walks the DOM itself.- try testing.expectEqual(null, std.mem.indexOf(u8, out, "__DATA__"));- try testing.expectEqual(null, std.mem.indexOf(u8, out, "Accept our cookies"));- try testing.expectEqual(null, std.mem.indexOf(u8, out, "Trending now"));+ try testing.expectEqual(null, std.mem.find(u8, out, "__DATA__"));+ try testing.expectEqual(null, std.mem.find(u8, out, "Accept our cookies"));+ try testing.expectEqual(null, std.mem.find(u8, out, "Trending now"));+++ // Inside the selection too: the walk records what it skips.- try testing.expectEqual(null, std.mem.indexOf(u8, out, "INNER_SCRIPT"));- try testing.expectEqual(null, std.mem.indexOf(u8, out, "INNER_HIDDEN"));- try testing.expectEqual(null, std.mem.indexOf(u8, out, "INNER_ARIA"));- try testing.expectEqual(null, std.mem.indexOf(u8, out, "INNER_TEMPLATE"));++ try testing.expectEqual(null, std.mem.find(u8, out, "INNER_SCRIPT"));++ try testing.expectEqual(null, std.mem.find(u8, out, "INNER_HIDDEN"));++ try testing.expectEqual(null, std.mem.find(u8, out, "INNER_ARIA"));++ try testing.expectEqual(null, std.mem.find(u8, out, "INNER_TEMPLATE"));}fn extract(html: []const u8) ![]const u8 {diff --cc src/browser/webapi/selector/List.zigindex 8a121f51a,29599744b..35216a6f0--- a/src/browser/webapi/selector/List.zig+++ b/src/browser/webapi/selector/List.zig@@@ -1045,7 -1065,19 +1065,19 @@@ pub const NthCache = structof_type_from_end: u32,};- const TypeCounts = [@typeInfo(Node.Element.Tag).@"enum".field_names.len]u32;+ const TypeCounts = struct {- tags: [@typeInfo(Node.Element.Tag).@"enum".fields.len]u32 = @splat(0),++ tags: [@typeInfo(Node.Element.Tag).@"enum".field_names.len]u32 = @splat(0),+ // Custom and unknown elements share a Tag, so those count by name.+ names: std.StringHashMapUnmanaged(u32) = .empty,++ fn get(self: *TypeCounts, allocator: std.mem.Allocator, el: *Node.Element) !*u32 {+ const tag = el.getTag();+ return switch (tag) {+ .custom, .unknown => (try self.names.getOrPutValue(allocator, el.getTagNameLower(), 0)).value_ptr,- else => &self.tags[@intFromEnum(tag)],++ else => &self.tags[@backingInt(tag)],+ };+ }+ };pub fn deinit(self: *NthCache) void {self.entries.deinit(self.allocator);@@@ -1087,12 -1119,10 +1119,9 @@@while (it.next()) |child| {const el = child.is(Node.Element) orelse continue;seen_count += 1;- const tag = @backingInt(el.getTag());- seen_types[tag] += 1;--const ordinals = self.entries.getPtr(child).?;ordinals.child_from_end = child_count - seen_count + 1;- ordinals.of_type_from_end = type_counts[tag] - seen_types[tag] + 1;+ ordinals.of_type_from_end = (try type_counts.get(self.allocator, el)).* - ordinals.of_type + 1;}}};