Serenity Operating System
1/*
2 * Copyright (c) 2022, Luke Wilde <lukew@serenityos.org>
3 * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
4 *
5 * SPDX-License-Identifier: BSD-2-Clause
6 */
7
8#pragma once
9
10#include <LibWeb/DOM/AbstractRange.h>
11
12namespace Web::DOM {
13
14// NOTE: We must use GCP instead of NNGCP here, otherwise the generated code cannot default initialize this struct.
15// They will never be null, as they are marked as required and non-null in the dictionary.
16struct StaticRangeInit {
17 JS::GCPtr<Node> start_container;
18 u32 start_offset { 0 };
19 JS::GCPtr<Node> end_container;
20 u32 end_offset { 0 };
21};
22
23class StaticRange final : public AbstractRange {
24 WEB_PLATFORM_OBJECT(StaticRange, AbstractRange);
25
26public:
27 static WebIDL::ExceptionOr<JS::NonnullGCPtr<StaticRange>> construct_impl(JS::Realm&, StaticRangeInit& init);
28
29 StaticRange(Node& start_container, u32 start_offset, Node& end_container, u32 end_offset);
30 virtual ~StaticRange() override;
31
32 virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
33};
34
35}