Skip to content

Lightpanda: the headless browser designed for AI and automation

Add correct license header

Karl Seguin00a0517df300
diff --git a/src/browser/frame/node_factory.zig b/src/browser/frame/node_factory.zig
index ddd0aa083..024b6614e 100644
--- a/src/browser/frame/node_factory.zig
+++ b/src/browser/frame/node_factory.zig
@@ -929,8 +929,9 @@ pub fn createElementNS(frame: *Frame, namespace: Element.Namespace, name: []cons
asUint("polyline") => return createSvgElementT(frame, Geometry.Polyline, name, attribute_iterator, .{ ._proto = undefined }),
else => {},
},
- 13 => if (std.mem.eql(u8, name, "foreignObject")) {
- return createSvgElementT(frame, Graphics.ForeignObject, name, attribute_iterator, .{ ._proto = undefined });
+ 13 => switch (@as(u104, @bitCast(name[0..13].*))) {
+ asUint("foreignObject") => return createSvgElementT(frame, Graphics.ForeignObject, name, attribute_iterator, .{ ._proto = undefined }),
+ else => {},
},
else => {},
}
diff --git a/src/browser/webapi/element/Svg.zig b/src/browser/webapi/element/Svg.zig
index 86e0eeb3b..442d60402 100644
--- a/src/browser/webapi/element/Svg.zig
+++ b/src/browser/webapi/element/Svg.zig
@@ -56,7 +56,9 @@ pub fn is(self: *Svg, comptime T: type) ?*T {
}
}
}
- if (self._type == .graphics) return self._type.graphics.is(T);
+ if (self._type == .graphics) {
+ return self._type.graphics.is(T);
+ }
return null;
}
diff --git a/src/browser/webapi/element/svg/Desc.zig b/src/browser/webapi/element/svg/Desc.zig
index 25551c121..0ce39857c 100644
--- a/src/browser/webapi/element/svg/Desc.zig
+++ b/src/browser/webapi/element/svg/Desc.zig
@@ -1,5 +1,20 @@
-// Copyright (C) 2023-2026 Lightpanda (Selecy SAS)
-// SPDX-License-Identifier: AGPL-3.0-or-later
+// Copyright (C) 2023-2026 Lightpanda (Selecy SAS)
+//
+// Francis Bouvier <[email protected]>
+// Pierre Tachoire <[email protected]>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see <https://www.gnu.org/licenses/>.
const js = @import("../../../js/js.zig");
const Node = @import("../../Node.zig");
diff --git a/src/browser/webapi/element/svg/ForeignObject.zig b/src/browser/webapi/element/svg/ForeignObject.zig
index d44a7547b..aa1d6db2e 100644
--- a/src/browser/webapi/element/svg/ForeignObject.zig
+++ b/src/browser/webapi/element/svg/ForeignObject.zig
@@ -1,5 +1,20 @@
-// Copyright (C) 2023-2026 Lightpanda (Selecy SAS)
-// SPDX-License-Identifier: AGPL-3.0-or-later
+// Copyright (C) 2023-2026 Lightpanda (Selecy SAS)
+//
+// Francis Bouvier <[email protected]>
+// Pierre Tachoire <[email protected]>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see <https://www.gnu.org/licenses/>.
const std = @import("std");
@@ -7,8 +22,10 @@ const js = @import("../../../js/js.zig");
const Frame = @import("../../../Frame.zig");
const Node = @import("../../Node.zig");
const Element = @import("../../Element.zig");
-const AnimatedLength = @import("../../svg/AnimatedLength.zig");
+
const PathData = @import("../../svg/PathData.zig");
+const AnimatedLength = @import("../../svg/AnimatedLength.zig");
+
const Graphics = @import("Graphics.zig");
const ForeignObject = @This();
@@ -21,20 +38,6 @@ pub fn asNode(self: *ForeignObject) *Node {
return self.asElement().asNode();
}
-pub const JsApi = struct {
- pub const bridge = js.Bridge(ForeignObject);
- pub const Meta = struct {
- pub const name = "SVGForeignObjectElement";
- pub const prototype_chain = bridge.prototypeChain();
- pub var class_id: bridge.ClassId = undefined;
- };
-
- pub const x = bridge.accessor(ForeignObject.getX, null, .{});
- pub const y = bridge.accessor(ForeignObject.getY, null, .{});
- pub const width = bridge.accessor(ForeignObject.getWidth, null, .{});
- pub const height = bridge.accessor(ForeignObject.getHeight, null, .{});
-};
-
pub fn getX(self: *ForeignObject, frame: *Frame) !*AnimatedLength {
return AnimatedLength.getOrCreate(self.asElement(), .x, frame);
}
@@ -53,11 +56,26 @@ pub fn getBounds(self: *ForeignObject, frame: *Frame) !PathData.Bounds {
const y = (try self.getY(frame)).getBaseVal().getValue(frame);
const width = (try self.getWidth(frame)).getBaseVal().getValue(frame);
const height = (try self.getHeight(frame)).getBaseVal().getValue(frame);
- if (!std.math.isFinite(x) or !std.math.isFinite(y) or
- !std.math.isFinite(width) or !std.math.isFinite(height))
- {
+
+ if (!std.math.isFinite(x) or !std.math.isFinite(y) or !std.math.isFinite(width) or !std.math.isFinite(height)) {
+ return .{};
+ }
+ if (width <= 0 or height <= 0) {
return .{};
}
- if (width <= 0 or height <= 0) return .{};
return .{ .min_x = x, .min_y = y, .max_x = x + width, .max_y = y + height };
}
+
+pub const JsApi = struct {
+ pub const bridge = js.Bridge(ForeignObject);
+ pub const Meta = struct {
+ pub const name = "SVGForeignObjectElement";
+ pub const prototype_chain = bridge.prototypeChain();
+ pub var class_id: bridge.ClassId = undefined;
+ };
+
+ pub const x = bridge.accessor(ForeignObject.getX, null, .{});
+ pub const y = bridge.accessor(ForeignObject.getY, null, .{});
+ pub const width = bridge.accessor(ForeignObject.getWidth, null, .{});
+ pub const height = bridge.accessor(ForeignObject.getHeight, null, .{});
+};
diff --git a/src/browser/webapi/element/svg/Graphics.zig b/src/browser/webapi/element/svg/Graphics.zig
index 25a0ddfbe..d9b4dc269 100644
--- a/src/browser/webapi/element/svg/Graphics.zig
+++ b/src/browser/webapi/element/svg/Graphics.zig
@@ -132,13 +132,13 @@ fn accumulateChildren(parent: *Graphics, matrix: PathData.Matrix, bounds: *PathD
});
while (cursors.items.len != 0) {
- const cursor = &cursors.items[cursors.items.len - 1];
- const node = cursor.next orelse {
+ const top = cursors.items.len - 1;
+ const node = cursors.items[top].next orelse {
_ = cursors.pop();
continue;
};
- cursor.next = node.nextSibling();
- const parent_matrix = cursor.matrix;
+ cursors.items[top].next = node.nextSibling();
+ const parent_matrix = cursors.items[top].matrix;
const element = node.is(Element) orelse continue;
if (element._namespace != .svg) continue;
diff --git a/src/browser/webapi/element/svg/Metadata.zig b/src/browser/webapi/element/svg/Metadata.zig
index 0429e38da..ec1085c84 100644
--- a/src/browser/webapi/element/svg/Metadata.zig
+++ b/src/browser/webapi/element/svg/Metadata.zig
@@ -1,9 +1,26 @@
-// Copyright (C) 2023-2026 Lightpanda (Selecy SAS)
-// SPDX-License-Identifier: AGPL-3.0-or-later
+// Copyright (C) 2023-2026 Lightpanda (Selecy SAS)
+//
+// Francis Bouvier <[email protected]>
+// Pierre Tachoire <[email protected]>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see <https://www.gnu.org/licenses/>.
const js = @import("../../../js/js.zig");
+
const Node = @import("../../Node.zig");
const Element = @import("../../Element.zig");
+
const Svg = @import("../Svg.zig");
const Metadata = @This();
diff --git a/src/browser/webapi/element/svg/Switch.zig b/src/browser/webapi/element/svg/Switch.zig
index 1322edf7d..4e3059eaa 100644
--- a/src/browser/webapi/element/svg/Switch.zig
+++ b/src/browser/webapi/element/svg/Switch.zig
@@ -1,9 +1,26 @@
-// Copyright (C) 2023-2026 Lightpanda (Selecy SAS)
-// SPDX-License-Identifier: AGPL-3.0-or-later
+// Copyright (C) 2023-2026 Lightpanda (Selecy SAS)
+//
+// Francis Bouvier <[email protected]>
+// Pierre Tachoire <[email protected]>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see <https://www.gnu.org/licenses/>.
const js = @import("../../../js/js.zig");
+
const Node = @import("../../Node.zig");
const Element = @import("../../Element.zig");
+
const Graphics = @import("Graphics.zig");
const Switch = @This();
diff --git a/src/browser/webapi/element/svg/Symbol.zig b/src/browser/webapi/element/svg/Symbol.zig
index 45a51e886..0737e54ca 100644
--- a/src/browser/webapi/element/svg/Symbol.zig
+++ b/src/browser/webapi/element/svg/Symbol.zig
@@ -1,9 +1,26 @@
-// Copyright (C) 2023-2026 Lightpanda (Selecy SAS)
-// SPDX-License-Identifier: AGPL-3.0-or-later
+// Copyright (C) 2023-2026 Lightpanda (Selecy SAS)
+//
+// Francis Bouvier <[email protected]>
+// Pierre Tachoire <[email protected]>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see <https://www.gnu.org/licenses/>.
const js = @import("../../../js/js.zig");
+
const Node = @import("../../Node.zig");
const Element = @import("../../Element.zig");
+
const Graphics = @import("Graphics.zig");
const Symbol = @This();
diff --git a/src/browser/webapi/element/svg/Title.zig b/src/browser/webapi/element/svg/Title.zig
index 74455107a..6f9f0daa9 100644
--- a/src/browser/webapi/element/svg/Title.zig
+++ b/src/browser/webapi/element/svg/Title.zig
@@ -1,9 +1,26 @@
-// Copyright (C) 2023-2026 Lightpanda (Selecy SAS)
-// SPDX-License-Identifier: AGPL-3.0-or-later
+// Copyright (C) 2023-2026 Lightpanda (Selecy SAS)
+//
+// Francis Bouvier <[email protected]>
+// Pierre Tachoire <[email protected]>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see <https://www.gnu.org/licenses/>.
const js = @import("../../../js/js.zig");
+
const Node = @import("../../Node.zig");
const Element = @import("../../Element.zig");
+
const Svg = @import("../Svg.zig");
const Title = @This();
diff --git a/src/browser/webapi/element/svg/View.zig b/src/browser/webapi/element/svg/View.zig
index 3b14fe3fa..204577613 100644
--- a/src/browser/webapi/element/svg/View.zig
+++ b/src/browser/webapi/element/svg/View.zig
@@ -1,9 +1,26 @@
-// Copyright (C) 2023-2026 Lightpanda (Selecy SAS)
-// SPDX-License-Identifier: AGPL-3.0-or-later
+// Copyright (C) 2023-2026 Lightpanda (Selecy SAS)
+//
+// Francis Bouvier <[email protected]>
+// Pierre Tachoire <[email protected]>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see <https://www.gnu.org/licenses/>.
const js = @import("../../../js/js.zig");
+
const Node = @import("../../Node.zig");
const Element = @import("../../Element.zig");
+
const Svg = @import("../Svg.zig");
const View = @This();