mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 16:15:10 +00:00
66 lines
1.8 KiB
C++
66 lines
1.8 KiB
C++
/*
|
|
* Copyright (c) 2020, the SerenityOS developers.
|
|
* Copyright (c) 2022, Luke Wilde <lukew@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibWeb/DOM/AbstractRange.h>
|
|
|
|
namespace Web::DOM {
|
|
|
|
class Range final : public AbstractRange {
|
|
public:
|
|
using WrapperType = Bindings::RangeWrapper;
|
|
|
|
virtual ~Range() override;
|
|
|
|
static NonnullRefPtr<Range> create(Document&);
|
|
static NonnullRefPtr<Range> create(Window&);
|
|
static NonnullRefPtr<Range> create(Node& start_container, u32 start_offset, Node& end_container, u32 end_offset);
|
|
static NonnullRefPtr<Range> create_with_global_object(Bindings::WindowObject&);
|
|
|
|
// FIXME: There are a ton of methods missing here.
|
|
|
|
ExceptionOr<void> set_start(Node& node, u32 offset);
|
|
ExceptionOr<void> set_end(Node& node, u32 offset);
|
|
ExceptionOr<void> set_start_before(Node& node);
|
|
ExceptionOr<void> set_start_after(Node& node);
|
|
ExceptionOr<void> set_end_before(Node& node);
|
|
ExceptionOr<void> set_end_after(Node& node);
|
|
|
|
// https://dom.spec.whatwg.org/#dom-range-start_to_start
|
|
enum HowToCompareBoundaryPoints : u16 {
|
|
START_TO_START = 0,
|
|
START_TO_END = 1,
|
|
END_TO_END = 2,
|
|
END_TO_START = 3,
|
|
};
|
|
|
|
ExceptionOr<i16> compare_boundary_points(u16 how, Range const& source_range) const;
|
|
|
|
NonnullRefPtr<Range> inverted() const;
|
|
NonnullRefPtr<Range> normalized() const;
|
|
NonnullRefPtr<Range> clone_range() const;
|
|
|
|
NonnullRefPtr<Node> common_ancestor_container() const;
|
|
|
|
private:
|
|
explicit Range(Document&);
|
|
|
|
Range(Node& start_container, u32 start_offset, Node& end_container, u32 end_offset);
|
|
|
|
Node& root();
|
|
Node const& root() const;
|
|
|
|
enum class StartOrEnd {
|
|
Start,
|
|
End,
|
|
};
|
|
|
|
ExceptionOr<void> set_start_or_end(Node& node, u32 offset, StartOrEnd start_or_end);
|
|
};
|
|
|
|
}
|