From 95cbbc3b4534c512e791a3b5dfbd651e21e6e2ba Mon Sep 17 00:00:00 2001 From: Karl Seguin Date: Tue, 8 Jul 2025 18:30:33 +0800 Subject: [PATCH] add dummy ResizeObserver --- src/browser/dom/dom.zig | 2 ++ src/browser/dom/resize_observer.zig | 54 +++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 src/browser/dom/resize_observer.zig diff --git a/src/browser/dom/dom.zig b/src/browser/dom/dom.zig index a82a80ed..13e8a801 100644 --- a/src/browser/dom/dom.zig +++ b/src/browser/dom/dom.zig @@ -23,6 +23,7 @@ const NamedNodeMap = @import("namednodemap.zig").NamedNodeMap; const DOMTokenList = @import("token_list.zig"); const NodeList = @import("nodelist.zig"); const Node = @import("node.zig"); +const ResizeObserver = @import("resize_observer.zig"); const MutationObserver = @import("mutation_observer.zig"); const IntersectionObserver = @import("intersection_observer.zig"); const DOMParser = @import("dom_parser.zig").DOMParser; @@ -40,6 +41,7 @@ pub const Interfaces = .{ NodeList.Interfaces, Node.Node, Node.Interfaces, + ResizeObserver.Interfaces, MutationObserver.Interfaces, IntersectionObserver.Interfaces, DOMParser, diff --git a/src/browser/dom/resize_observer.zig b/src/browser/dom/resize_observer.zig new file mode 100644 index 00000000..4f1e37c3 --- /dev/null +++ b/src/browser/dom/resize_observer.zig @@ -0,0 +1,54 @@ +// Copyright (C) 2023-2025 Lightpanda (Selecy SAS) +// +// Francis Bouvier +// Pierre Tachoire +// +// 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 . + +const Env = @import("../env.zig").Env; +const parser = @import("../netsurf.zig"); + +pub const Interfaces = .{ + ResizeObserver, +}; + +// WEB IDL https://drafts.csswg.org/resize-observer/#resize-observer-interface +pub const ResizeObserver = struct { + pub fn constructor(cbk: Env.Function) ResizeObserver { + _ = cbk; + return .{}; + } + + pub fn _observe(self: *const ResizeObserver, element: *parser.Element, options_: ?Options) void { + _ = self; + _ = element; + _ = options_; + return; + } + + pub fn _unobserve(self: *const ResizeObserver, element: *parser.Element) void { + _ = self; + _ = element; + return; + } + + // TODO + pub fn _disconnect(self: *ResizeObserver) void { + _ = self; + } +}; + +const Options = struct { + box: []const u8, +};