1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 23:37:36 +00:00

LibWeb: Use WebIDL typedefs in Range/AbstractRange

In the public APIs which have their types exposed through IDL.
This commit is contained in:
Shannon Booth 2024-01-04 09:14:41 +13:00 committed by Andreas Kling
parent b6123df492
commit ee431e6911
4 changed files with 24 additions and 21 deletions

View file

@ -10,6 +10,7 @@
#include <LibWeb/DOM/AbstractRange.h>
#include <LibWeb/Selection/Selection.h>
#include <LibWeb/WebIDL/Types.h>
namespace Web::DOM {
@ -29,15 +30,15 @@ class Range final : public AbstractRange {
public:
[[nodiscard]] static JS::NonnullGCPtr<Range> create(Document&);
[[nodiscard]] static JS::NonnullGCPtr<Range> create(HTML::Window&);
[[nodiscard]] static JS::NonnullGCPtr<Range> create(Node& start_container, u32 start_offset, Node& end_container, u32 end_offset);
[[nodiscard]] static JS::NonnullGCPtr<Range> create(Node& start_container, WebIDL::UnsignedLong start_offset, Node& end_container, WebIDL::UnsignedLong end_offset);
static WebIDL::ExceptionOr<JS::NonnullGCPtr<Range>> construct_impl(JS::Realm&);
virtual ~Range() override;
// FIXME: There are a ton of methods missing here.
WebIDL::ExceptionOr<void> set_start(Node& node, u32 offset);
WebIDL::ExceptionOr<void> set_end(Node& node, u32 offset);
WebIDL::ExceptionOr<void> set_start(Node& node, WebIDL::UnsignedLong offset);
WebIDL::ExceptionOr<void> set_end(Node& node, WebIDL::UnsignedLong offset);
WebIDL::ExceptionOr<void> set_start_before(Node& node);
WebIDL::ExceptionOr<void> set_start_after(Node& node);
WebIDL::ExceptionOr<void> set_end_before(Node& node);
@ -47,14 +48,14 @@ public:
WebIDL::ExceptionOr<void> select_node_contents(Node&);
// https://dom.spec.whatwg.org/#dom-range-start_to_start
enum HowToCompareBoundaryPoints : u16 {
enum HowToCompareBoundaryPoints : WebIDL::UnsignedShort {
START_TO_START = 0,
START_TO_END = 1,
END_TO_END = 2,
END_TO_START = 3,
};
WebIDL::ExceptionOr<i16> compare_boundary_points(u16 how, Range const& source_range) const;
WebIDL::ExceptionOr<WebIDL::Short> compare_boundary_points(WebIDL::UnsignedShort how, Range const& source_range) const;
JS::NonnullGCPtr<Range> inverted() const;
JS::NonnullGCPtr<Range> normalized() const;
@ -70,8 +71,8 @@ public:
}
bool intersects_node(Node const&) const;
WebIDL::ExceptionOr<bool> is_point_in_range(Node const&, u32 offset) const;
WebIDL::ExceptionOr<i16> compare_point(Node const&, u32 offset) const;
WebIDL::ExceptionOr<bool> is_point_in_range(Node const&, WebIDL::UnsignedLong offset) const;
WebIDL::ExceptionOr<WebIDL::Short> compare_point(Node const&, WebIDL::UnsignedLong offset) const;
WebIDL::ExceptionOr<void> delete_contents();
WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> extract_contents();
@ -94,7 +95,7 @@ public:
private:
explicit Range(Document&);
Range(Node& start_container, u32 start_offset, Node& end_container, u32 end_offset);
Range(Node& start_container, WebIDL::UnsignedLong start_offset, Node& end_container, WebIDL::UnsignedLong end_offset);
virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override;