diff --git a/AK/URLParser.cpp b/AK/URLParser.cpp index 8b5a9ffb6f..d5a40d933e 100644 --- a/AK/URLParser.cpp +++ b/AK/URLParser.cpp @@ -227,7 +227,7 @@ URL URLParser::parse(Badge, const StringView& raw_input, URL const* base_ur bool password_token_seen = false; Utf8View input(processed_input); - Utf8CodepointIterator iterator = input.begin(); + Utf8CodePointIterator iterator = input.begin(); auto get_remaining = [&input, &iterator] { return input.substring_view(iterator - input.begin() + iterator.code_point_length_in_bytes()).as_string(); diff --git a/AK/Utf8View.cpp b/AK/Utf8View.cpp index 8d6074aa9f..e90a1f0912 100644 --- a/AK/Utf8View.cpp +++ b/AK/Utf8View.cpp @@ -36,17 +36,17 @@ const unsigned char* Utf8View::end_ptr() const return begin_ptr() + m_string.length(); } -Utf8CodepointIterator Utf8View::begin() const +Utf8CodePointIterator Utf8View::begin() const { return { begin_ptr(), m_string.length() }; } -Utf8CodepointIterator Utf8View::end() const +Utf8CodePointIterator Utf8View::end() const { return { end_ptr(), 0 }; } -Utf8CodepointIterator Utf8View::iterator_at_byte_offset(size_t byte_offset) const +Utf8CodePointIterator Utf8View::iterator_at_byte_offset(size_t byte_offset) const { size_t current_offset = 0; for (auto iterator = begin(); !iterator.done(); ++iterator) { @@ -57,7 +57,7 @@ Utf8CodepointIterator Utf8View::iterator_at_byte_offset(size_t byte_offset) cons return end(); } -size_t Utf8View::byte_offset_of(const Utf8CodepointIterator& it) const +size_t Utf8View::byte_offset_of(const Utf8CodePointIterator& it) const { VERIFY(it.m_ptr >= begin_ptr()); VERIFY(it.m_ptr <= end_ptr()); @@ -173,23 +173,23 @@ bool Utf8View::starts_with(const Utf8View& start) const return true; } -Utf8CodepointIterator::Utf8CodepointIterator(const unsigned char* ptr, size_t length) +Utf8CodePointIterator::Utf8CodePointIterator(const unsigned char* ptr, size_t length) : m_ptr(ptr) , m_length(length) { } -bool Utf8CodepointIterator::operator==(const Utf8CodepointIterator& other) const +bool Utf8CodePointIterator::operator==(const Utf8CodePointIterator& other) const { return m_ptr == other.m_ptr && m_length == other.m_length; } -bool Utf8CodepointIterator::operator!=(const Utf8CodepointIterator& other) const +bool Utf8CodePointIterator::operator!=(const Utf8CodePointIterator& other) const { return !(*this == other); } -Utf8CodepointIterator& Utf8CodepointIterator::operator++() +Utf8CodePointIterator& Utf8CodePointIterator::operator++() { VERIFY(m_length > 0); @@ -206,7 +206,7 @@ Utf8CodepointIterator& Utf8CodepointIterator::operator++() return *this; } -size_t Utf8CodepointIterator::code_point_length_in_bytes() const +size_t Utf8CodePointIterator::code_point_length_in_bytes() const { VERIFY(m_length > 0); size_t code_point_length_in_bytes = 0; @@ -216,7 +216,7 @@ size_t Utf8CodepointIterator::code_point_length_in_bytes() const return code_point_length_in_bytes; } -u32 Utf8CodepointIterator::operator*() const +u32 Utf8CodePointIterator::operator*() const { VERIFY(m_length > 0); @@ -240,7 +240,7 @@ u32 Utf8CodepointIterator::operator*() const return code_point_value_so_far; } -Optional Utf8CodepointIterator::peek(size_t offset) const +Optional Utf8CodePointIterator::peek(size_t offset) const { if (offset == 0) { if (this->done()) diff --git a/AK/Utf8View.h b/AK/Utf8View.h index 2acf627d29..585e9a4200 100644 --- a/AK/Utf8View.h +++ b/AK/Utf8View.h @@ -14,21 +14,21 @@ namespace AK { class Utf8View; -class Utf8CodepointIterator { +class Utf8CodePointIterator { friend class Utf8View; public: - Utf8CodepointIterator() = default; - ~Utf8CodepointIterator() = default; + Utf8CodePointIterator() = default; + ~Utf8CodePointIterator() = default; - bool operator==(const Utf8CodepointIterator&) const; - bool operator!=(const Utf8CodepointIterator&) const; - Utf8CodepointIterator& operator++(); + bool operator==(const Utf8CodePointIterator&) const; + bool operator!=(const Utf8CodePointIterator&) const; + Utf8CodePointIterator& operator++(); u32 operator*() const; // NOTE: This returns {} if the peek is at or past EOF. Optional peek(size_t offset = 0) const; - ssize_t operator-(const Utf8CodepointIterator& other) const + ssize_t operator-(const Utf8CodePointIterator& other) const { return m_ptr - other.m_ptr; } @@ -37,14 +37,14 @@ public: bool done() const { return m_length == 0; } private: - Utf8CodepointIterator(const unsigned char*, size_t); + Utf8CodePointIterator(const unsigned char*, size_t); const unsigned char* m_ptr { nullptr }; size_t m_length; }; class Utf8View { public: - using Iterator = Utf8CodepointIterator; + using Iterator = Utf8CodePointIterator; Utf8View() = default; explicit Utf8View(const String&); @@ -54,13 +54,13 @@ public: const StringView& as_string() const { return m_string; } - Utf8CodepointIterator begin() const; - Utf8CodepointIterator end() const; - Utf8CodepointIterator iterator_at_byte_offset(size_t) const; + Utf8CodePointIterator begin() const; + Utf8CodePointIterator end() const; + Utf8CodePointIterator iterator_at_byte_offset(size_t) const; const unsigned char* bytes() const { return begin_ptr(); } size_t byte_length() const { return m_string.length(); } - size_t byte_offset_of(const Utf8CodepointIterator&) const; + size_t byte_offset_of(const Utf8CodePointIterator&) const; Utf8View substring_view(size_t byte_offset, size_t byte_length) const; Utf8View substring_view(size_t byte_offset) const { return substring_view(byte_offset, byte_length() - byte_offset); } @@ -70,7 +70,7 @@ public: bool is_empty() const { return m_string.is_empty(); } bool starts_with(const Utf8View&) const; - size_t iterator_offset(const Utf8CodepointIterator& it) const + size_t iterator_offset(const Utf8CodePointIterator& it) const { return byte_offset_of(it); } @@ -103,5 +103,5 @@ private: } -using AK::Utf8CodepointIterator; +using AK::Utf8CodePointIterator; using AK::Utf8View; diff --git a/Tests/AK/TestUtf8.cpp b/Tests/AK/TestUtf8.cpp index 522de3dcc9..6d0187fab9 100644 --- a/Tests/AK/TestUtf8.cpp +++ b/Tests/AK/TestUtf8.cpp @@ -71,7 +71,7 @@ TEST_CASE(validate_invalid_ut8) TEST_CASE(iterate_utf8) { Utf8View view("Some weird characters \u00A9\u266A\uA755"); - Utf8CodepointIterator iterator = view.begin(); + Utf8CodePointIterator iterator = view.begin(); EXPECT(*iterator == 'S'); EXPECT(iterator.peek().has_value() && iterator.peek().value() == 'S'); @@ -98,7 +98,7 @@ TEST_CASE(iterate_utf8) EXPECT(iterator.done()); EXPECT(!iterator.peek(0).has_value()); - EXPECT_CRASH("Dereferencing Utf8CodepointIterator which is already done.", [&iterator] { + EXPECT_CRASH("Dereferencing Utf8CodePointIterator which is already done.", [&iterator] { *iterator; return Test::Crash::Failure::DidNotCrash; }); diff --git a/Userland/Libraries/LibJS/Runtime/StringIterator.h b/Userland/Libraries/LibJS/Runtime/StringIterator.h index b72be9b4f4..0321930266 100644 --- a/Userland/Libraries/LibJS/Runtime/StringIterator.h +++ b/Userland/Libraries/LibJS/Runtime/StringIterator.h @@ -20,14 +20,14 @@ public: explicit StringIterator(Object& prototype, String string); virtual ~StringIterator() override; - Utf8CodepointIterator& iterator() { return m_iterator; } + Utf8CodePointIterator& iterator() { return m_iterator; } bool done() const { return m_done; } private: friend class StringIteratorPrototype; String m_string; - Utf8CodepointIterator m_iterator; + Utf8CodePointIterator m_iterator; bool m_done { false }; }; diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Tokenizer.h b/Userland/Libraries/LibWeb/CSS/Parser/Tokenizer.h index 2f25beef66..3548242bc3 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Tokenizer.h +++ b/Userland/Libraries/LibWeb/CSS/Parser/Tokenizer.h @@ -99,7 +99,7 @@ private: String m_decoded_input; Utf8View m_utf8_view; - AK::Utf8CodepointIterator m_utf8_iterator; - AK::Utf8CodepointIterator m_prev_utf8_iterator; + AK::Utf8CodePointIterator m_utf8_iterator; + AK::Utf8CodePointIterator m_prev_utf8_iterator; }; } diff --git a/Userland/Libraries/LibWeb/HTML/Parser/HTMLTokenizer.cpp b/Userland/Libraries/LibWeb/HTML/Parser/HTMLTokenizer.cpp index 4d5ec0ebe7..7d716a8532 100644 --- a/Userland/Libraries/LibWeb/HTML/Parser/HTMLTokenizer.cpp +++ b/Userland/Libraries/LibWeb/HTML/Parser/HTMLTokenizer.cpp @@ -2675,7 +2675,7 @@ bool HTMLTokenizer::consumed_as_part_of_an_attribute() const return m_return_state == State::AttributeValueUnquoted || m_return_state == State::AttributeValueSingleQuoted || m_return_state == State::AttributeValueDoubleQuoted; } -void HTMLTokenizer::restore_to(const Utf8CodepointIterator& new_iterator) +void HTMLTokenizer::restore_to(const Utf8CodePointIterator& new_iterator) { if (new_iterator != m_prev_utf8_iterator) { auto diff = m_prev_utf8_iterator - new_iterator; diff --git a/Userland/Libraries/LibWeb/HTML/Parser/HTMLTokenizer.h b/Userland/Libraries/LibWeb/HTML/Parser/HTMLTokenizer.h index da9945ed78..0024bcb08f 100644 --- a/Userland/Libraries/LibWeb/HTML/Parser/HTMLTokenizer.h +++ b/Userland/Libraries/LibWeb/HTML/Parser/HTMLTokenizer.h @@ -146,7 +146,7 @@ private: bool consumed_as_part_of_an_attribute() const; - void restore_to(const Utf8CodepointIterator& new_iterator); + void restore_to(const Utf8CodePointIterator& new_iterator); auto& nth_last_position(size_t n = 0) { return m_source_positions.at(m_source_positions.size() - 1 - n); } State m_state { State::Data }; @@ -159,8 +159,8 @@ private: StringView m_input; Utf8View m_utf8_view; - Utf8CodepointIterator m_utf8_iterator; - Utf8CodepointIterator m_prev_utf8_iterator; + Utf8CodePointIterator m_utf8_iterator; + Utf8CodePointIterator m_prev_utf8_iterator; HTMLToken m_current_token;