diff --git a/Userland/Libraries/LibWeb/DOM/AbstractRange.cpp b/Userland/Libraries/LibWeb/DOM/AbstractRange.cpp index 8a32a55974..9a99a7cc62 100644 --- a/Userland/Libraries/LibWeb/DOM/AbstractRange.cpp +++ b/Userland/Libraries/LibWeb/DOM/AbstractRange.cpp @@ -10,7 +10,7 @@ namespace Web::DOM { -AbstractRange::AbstractRange(Node& start_container, u32 start_offset, Node& end_container, u32 end_offset) +AbstractRange::AbstractRange(Node& start_container, WebIDL::UnsignedLong start_offset, Node& end_container, WebIDL::UnsignedLong end_offset) : Bindings::PlatformObject(start_container.realm()) , m_start_container(start_container) , m_start_offset(start_offset) diff --git a/Userland/Libraries/LibWeb/DOM/AbstractRange.h b/Userland/Libraries/LibWeb/DOM/AbstractRange.h index af8b04bad3..054c83bec2 100644 --- a/Userland/Libraries/LibWeb/DOM/AbstractRange.h +++ b/Userland/Libraries/LibWeb/DOM/AbstractRange.h @@ -9,9 +9,11 @@ #include #include +#include namespace Web::DOM { +// https://dom.spec.whatwg.org/#abstractrange class AbstractRange : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(AbstractRange, Bindings::PlatformObject); @@ -20,11 +22,11 @@ public: Node* start_container() { return m_start_container.ptr(); } Node const* start_container() const { return m_start_container.ptr(); } - unsigned start_offset() const { return m_start_offset; } + WebIDL::UnsignedLong start_offset() const { return m_start_offset; } Node* end_container() { return m_end_container.ptr(); } Node const* end_container() const { return m_end_container.ptr(); } - unsigned end_offset() const { return m_end_offset; } + WebIDL::UnsignedLong end_offset() const { return m_end_offset; } // https://dom.spec.whatwg.org/#range-collapsed bool collapsed() const @@ -34,16 +36,16 @@ public: } protected: - AbstractRange(Node& start_container, u32 start_offset, Node& end_container, u32 end_offset); + AbstractRange(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; JS::NonnullGCPtr m_start_container; - u32 m_start_offset; + WebIDL::UnsignedLong m_start_offset; JS::NonnullGCPtr m_end_container; - u32 m_end_offset; + WebIDL::UnsignedLong m_end_offset; }; } diff --git a/Userland/Libraries/LibWeb/DOM/Range.cpp b/Userland/Libraries/LibWeb/DOM/Range.cpp index 1a35748bf2..ff1778e36f 100644 --- a/Userland/Libraries/LibWeb/DOM/Range.cpp +++ b/Userland/Libraries/LibWeb/DOM/Range.cpp @@ -44,7 +44,7 @@ JS::NonnullGCPtr Range::create(Document& document) return realm.heap().allocate(realm, document); } -JS::NonnullGCPtr Range::create(Node& start_container, u32 start_offset, Node& end_container, u32 end_offset) +JS::NonnullGCPtr Range::create(Node& start_container, WebIDL::UnsignedLong start_offset, Node& end_container, WebIDL::UnsignedLong end_offset) { auto& realm = start_container.realm(); return realm.heap().allocate(realm, start_container, start_offset, end_container, end_offset); @@ -61,7 +61,7 @@ Range::Range(Document& document) { } -Range::Range(Node& start_container, u32 start_offset, Node& end_container, u32 end_offset) +Range::Range(Node& start_container, WebIDL::UnsignedLong start_offset, Node& end_container, WebIDL::UnsignedLong end_offset) : AbstractRange(start_container, start_offset, end_container, end_offset) { live_ranges().set(this); @@ -207,13 +207,13 @@ WebIDL::ExceptionOr Range::set_start_or_end(Node& node, u32 offset, StartO } // https://dom.spec.whatwg.org/#concept-range-bp-set -WebIDL::ExceptionOr Range::set_start(Node& node, u32 offset) +WebIDL::ExceptionOr Range::set_start(Node& node, WebIDL::UnsignedLong offset) { // The setStart(node, offset) method steps are to set the start of this to boundary point (node, offset). return set_start_or_end(node, offset, StartOrEnd::Start); } -WebIDL::ExceptionOr Range::set_end(Node& node, u32 offset) +WebIDL::ExceptionOr Range::set_end(Node& node, WebIDL::UnsignedLong offset) { // The setEnd(node, offset) method steps are to set the end of this to boundary point (node, offset). return set_start_or_end(node, offset, StartOrEnd::End); @@ -276,7 +276,7 @@ WebIDL::ExceptionOr Range::set_end_after(Node& node) } // https://dom.spec.whatwg.org/#dom-range-compareboundarypoints -WebIDL::ExceptionOr Range::compare_boundary_points(u16 how, Range const& source_range) const +WebIDL::ExceptionOr Range::compare_boundary_points(WebIDL::UnsignedShort how, Range const& source_range) const { // 1. If how is not one of // - START_TO_START, @@ -499,7 +499,7 @@ bool Range::intersects_node(Node const& node) const } // https://dom.spec.whatwg.org/#dom-range-ispointinrange -WebIDL::ExceptionOr Range::is_point_in_range(Node const& node, u32 offset) const +WebIDL::ExceptionOr Range::is_point_in_range(Node const& node, WebIDL::UnsignedLong offset) const { // 1. If node’s root is different from this’s root, return false. if (&node.root() != &root()) @@ -524,7 +524,7 @@ WebIDL::ExceptionOr Range::is_point_in_range(Node const& node, u32 offset) } // https://dom.spec.whatwg.org/#dom-range-comparepoint -WebIDL::ExceptionOr Range::compare_point(Node const& node, u32 offset) const +WebIDL::ExceptionOr Range::compare_point(Node const& node, WebIDL::UnsignedLong offset) const { // 1. If node’s root is different from this’s root, then throw a "WrongDocumentError" DOMException. if (&node.root() != &root()) diff --git a/Userland/Libraries/LibWeb/DOM/Range.h b/Userland/Libraries/LibWeb/DOM/Range.h index 146c08a5a7..57f7a2cd83 100644 --- a/Userland/Libraries/LibWeb/DOM/Range.h +++ b/Userland/Libraries/LibWeb/DOM/Range.h @@ -10,6 +10,7 @@ #include #include +#include namespace Web::DOM { @@ -29,15 +30,15 @@ class Range final : public AbstractRange { public: [[nodiscard]] static JS::NonnullGCPtr create(Document&); [[nodiscard]] static JS::NonnullGCPtr create(HTML::Window&); - [[nodiscard]] static JS::NonnullGCPtr create(Node& start_container, u32 start_offset, Node& end_container, u32 end_offset); + [[nodiscard]] static JS::NonnullGCPtr create(Node& start_container, WebIDL::UnsignedLong start_offset, Node& end_container, WebIDL::UnsignedLong end_offset); static WebIDL::ExceptionOr> construct_impl(JS::Realm&); virtual ~Range() override; // FIXME: There are a ton of methods missing here. - WebIDL::ExceptionOr set_start(Node& node, u32 offset); - WebIDL::ExceptionOr set_end(Node& node, u32 offset); + WebIDL::ExceptionOr set_start(Node& node, WebIDL::UnsignedLong offset); + WebIDL::ExceptionOr set_end(Node& node, WebIDL::UnsignedLong offset); WebIDL::ExceptionOr set_start_before(Node& node); WebIDL::ExceptionOr set_start_after(Node& node); WebIDL::ExceptionOr set_end_before(Node& node); @@ -47,14 +48,14 @@ public: WebIDL::ExceptionOr 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 compare_boundary_points(u16 how, Range const& source_range) const; + WebIDL::ExceptionOr compare_boundary_points(WebIDL::UnsignedShort how, Range const& source_range) const; JS::NonnullGCPtr inverted() const; JS::NonnullGCPtr normalized() const; @@ -70,8 +71,8 @@ public: } bool intersects_node(Node const&) const; - WebIDL::ExceptionOr is_point_in_range(Node const&, u32 offset) const; - WebIDL::ExceptionOr compare_point(Node const&, u32 offset) const; + WebIDL::ExceptionOr is_point_in_range(Node const&, WebIDL::UnsignedLong offset) const; + WebIDL::ExceptionOr compare_point(Node const&, WebIDL::UnsignedLong offset) const; WebIDL::ExceptionOr delete_contents(); WebIDL::ExceptionOr> 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;