diff options
author | Andreas Kling <kling@serenityos.org> | 2021-06-01 10:01:11 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-01 10:01:11 +0200 |
commit | 12a42edd13f6bd2def0ff045389ab289fbcb0b83 (patch) | |
tree | 9f3d082658ba039879a8ecfc81bb870f05ba611f /Userland | |
parent | a8ae8b24deab52e851381c4385c316c57ce47d6a (diff) | |
download | serenity-12a42edd13f6bd2def0ff045389ab289fbcb0b83.zip |
Everywhere: codepoint => code point
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibGUI/IconView.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/VimEditingEngine.h | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/GlobalObject.cpp | 18 | ||||
-rw-r--r-- | Userland/Libraries/LibPDF/Renderer.cpp | 10 | ||||
-rw-r--r-- | Userland/Libraries/LibRegex/RegexParser.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibTTF/Cmap.cpp | 36 | ||||
-rw-r--r-- | Userland/Libraries/LibTTF/Cmap.h | 8 | ||||
-rw-r--r-- | Userland/Libraries/LibTTF/Font.cpp | 16 | ||||
-rw-r--r-- | Userland/Libraries/LibTTF/Font.h | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibVT/EscapeSequenceParser.cpp | 8 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/Parser/Tokenizer.cpp | 328 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/Parser/Tokenizer.h | 10 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/Position.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Page/EditEventHandler.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Page/EventHandler.cpp | 6 | ||||
-rw-r--r-- | Userland/Shell/Tests/brace-exp.sh | 2 |
16 files changed, 232 insertions, 232 deletions
diff --git a/Userland/Libraries/LibGUI/IconView.cpp b/Userland/Libraries/LibGUI/IconView.cpp index 5f0795bbf4..dac7d2ddb8 100644 --- a/Userland/Libraries/LibGUI/IconView.cpp +++ b/Userland/Libraries/LibGUI/IconView.cpp @@ -435,8 +435,8 @@ void IconView::get_item_rects(int item_index, ItemData& item_data, const Gfx::Fo Utf8View utf8_view(item_data.text); auto it = utf8_view.begin(); for (; it != utf8_view.end(); ++it) { - auto codepoint = *it; - auto glyph_width = font.glyph_width(codepoint); + auto code_point = *it; + auto glyph_width = font.glyph_width(code_point); if ((current_line_width + glyph_width + font.glyph_spacing()) > available_width) { item_data.wrapped_text_lines.append(item_data.text.substring_view(current_line_start, utf8_view.byte_offset_of(it) - current_line_start)); current_line_start = utf8_view.byte_offset_of(it); diff --git a/Userland/Libraries/LibGUI/VimEditingEngine.h b/Userland/Libraries/LibGUI/VimEditingEngine.h index 74ebb705ac..44e10d531e 100644 --- a/Userland/Libraries/LibGUI/VimEditingEngine.h +++ b/Userland/Libraries/LibGUI/VimEditingEngine.h @@ -84,7 +84,7 @@ public: EndOfWord, // End of a WORD. EndOfWORD, - // Characters (or Unicode codepoints based on how pedantic you want to + // Characters (or Unicode code points based on how pedantic you want to // get). Character, // Used for find-mode. diff --git a/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp b/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp index 158d638e2e..7d9d92b498 100644 --- a/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp @@ -248,15 +248,15 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::parse_int) } } - auto parse_digit = [&](u32 codepoint, i32 radix) -> Optional<i32> { + auto parse_digit = [&](u32 code_point, i32 radix) -> Optional<i32> { i32 digit = -1; - if (isdigit(codepoint)) - digit = codepoint - '0'; - else if (islower(codepoint)) - digit = 10 + (codepoint - 'a'); - else if (isupper(codepoint)) - digit = 10 + (codepoint - 'A'); + if (isdigit(code_point)) + digit = code_point - '0'; + else if (islower(code_point)) + digit = 10 + (code_point - 'a'); + else if (isupper(code_point)) + digit = 10 + (code_point - 'A'); if (digit == -1 || digit >= radix) return {}; @@ -265,8 +265,8 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::parse_int) bool had_digits = false; double number = 0; - for (auto codepoint : Utf8View(s)) { - auto digit = parse_digit(codepoint, radix); + for (auto code_point : Utf8View(s)) { + auto digit = parse_digit(code_point, radix); if (!digit.has_value()) break; had_digits = true; diff --git a/Userland/Libraries/LibPDF/Renderer.cpp b/Userland/Libraries/LibPDF/Renderer.cpp index 94296cf0aa..a66ce740f9 100644 --- a/Userland/Libraries/LibPDF/Renderer.cpp +++ b/Userland/Libraries/LibPDF/Renderer.cpp @@ -534,7 +534,7 @@ void Renderer::show_text(const String& string, int shift) auto utf = Utf8View(string); auto& font = text_state().font; - for (auto codepoint : utf) { + for (auto code_point : utf) { // FIXME: Don't calculate this matrix for every character auto& text_rendering_matrix = calculate_text_rendering_matrix(); @@ -542,14 +542,14 @@ void Renderer::show_text(const String& string, int shift) text_position.set_y(static_cast<float>(m_bitmap->height()) - text_position.y()); // FIXME: For some reason, the space character in LiberationSerif is drawn as an exclamation point - if (codepoint != 0x20) - m_painter.draw_glyph(text_position.to_type<int>(), codepoint, *text_state().font, state().paint_color); + if (code_point != 0x20) + m_painter.draw_glyph(text_position.to_type<int>(), code_point, *text_state().font, state().paint_color); - auto glyph_width = static_cast<float>(font->glyph_width(codepoint)); + auto glyph_width = static_cast<float>(font->glyph_width(code_point)); auto tx = (glyph_width - static_cast<float>(shift) / 1000.0f); tx += text_state().character_spacing; - if (codepoint == ' ') + if (code_point == ' ') tx += text_state().word_spacing; tx *= text_state().horizontal_scaling; diff --git a/Userland/Libraries/LibRegex/RegexParser.cpp b/Userland/Libraries/LibRegex/RegexParser.cpp index 7c5c34cf85..88adb77cf3 100644 --- a/Userland/Libraries/LibRegex/RegexParser.cpp +++ b/Userland/Libraries/LibRegex/RegexParser.cpp @@ -1485,7 +1485,7 @@ bool ECMA262Parser::parse_nonempty_class_ranges(Vector<CompareTypeAndValuePair>& if (try_skip("u")) { if (auto code_point = read_digits(ReadDigitsInitialZeroState::Allow, true, 4); code_point.has_value()) { - // FIXME: While codepoint ranges are supported, codepoint matches as "Char" are not! + // FIXME: While code point ranges are supported, code point matches as "Char" are not! return { { .code_point = code_point.value(), .is_character_class = false } }; } else if (!unicode) { // '\u' is allowed in non-unicode mode, just matches 'u'. diff --git a/Userland/Libraries/LibTTF/Cmap.cpp b/Userland/Libraries/LibTTF/Cmap.cpp index 4e017c848d..37c6ce99e4 100644 --- a/Userland/Libraries/LibTTF/Cmap.cpp +++ b/Userland/Libraries/LibTTF/Cmap.cpp @@ -75,72 +75,72 @@ Optional<Cmap::Subtable> Cmap::subtable(u32 index) const } // FIXME: This only handles formats 4 (SegmentToDelta) and 12 (SegmentedCoverage) for now. -u32 Cmap::Subtable::glyph_id_for_codepoint(u32 codepoint) const +u32 Cmap::Subtable::glyph_id_for_code_point(u32 code_point) const { switch (format()) { case Format::SegmentToDelta: - return glyph_id_for_codepoint_table_4(codepoint); + return glyph_id_for_code_point_table_4(code_point); case Format::SegmentedCoverage: - return glyph_id_for_codepoint_table_12(codepoint); + return glyph_id_for_code_point_table_12(code_point); default: return 0; } } -u32 Cmap::Subtable::glyph_id_for_codepoint_table_4(u32 codepoint) const +u32 Cmap::Subtable::glyph_id_for_code_point_table_4(u32 code_point) const { u32 segcount_x2 = be_u16(m_slice.offset_pointer((u32)Table4Offsets::SegCountX2)); if (m_slice.size() < segcount_x2 * (u32)Table4Sizes::NonConstMultiplier + (u32)Table4Sizes::Constant) { return 0; } for (u32 offset = 0; offset < segcount_x2; offset += 2) { - u32 end_codepoint = be_u16(m_slice.offset_pointer((u32)Table4Offsets::EndConstBase + offset)); - if (codepoint > end_codepoint) { + u32 end_code_point = be_u16(m_slice.offset_pointer((u32)Table4Offsets::EndConstBase + offset)); + if (code_point > end_code_point) { continue; } - u32 start_codepoint = be_u16(m_slice.offset_pointer((u32)Table4Offsets::StartConstBase + segcount_x2 + offset)); - if (codepoint < start_codepoint) { + u32 start_code_point = be_u16(m_slice.offset_pointer((u32)Table4Offsets::StartConstBase + segcount_x2 + offset)); + if (code_point < start_code_point) { break; } u32 delta = be_u16(m_slice.offset_pointer((u32)Table4Offsets::DeltaConstBase + segcount_x2 * 2 + offset)); u32 range = be_u16(m_slice.offset_pointer((u32)Table4Offsets::RangeConstBase + segcount_x2 * 3 + offset)); if (range == 0) { - return (codepoint + delta) & 0xffff; + return (code_point + delta) & 0xffff; } - u32 glyph_offset = (u32)Table4Offsets::GlyphOffsetConstBase + segcount_x2 * 3 + offset + range + (codepoint - start_codepoint) * 2; + u32 glyph_offset = (u32)Table4Offsets::GlyphOffsetConstBase + segcount_x2 * 3 + offset + range + (code_point - start_code_point) * 2; VERIFY(glyph_offset + 2 <= m_slice.size()); return (be_u16(m_slice.offset_pointer(glyph_offset)) + delta) & 0xffff; } return 0; } -u32 Cmap::Subtable::glyph_id_for_codepoint_table_12(u32 codepoint) const +u32 Cmap::Subtable::glyph_id_for_code_point_table_12(u32 code_point) const { u32 num_groups = be_u32(m_slice.offset_pointer((u32)Table12Offsets::NumGroups)); VERIFY(m_slice.size() >= (u32)Table12Sizes::Header + (u32)Table12Sizes::Record * num_groups); for (u32 offset = 0; offset < num_groups * (u32)Table12Sizes::Record; offset += (u32)Table12Sizes::Record) { - u32 start_codepoint = be_u32(m_slice.offset_pointer((u32)Table12Offsets::Record_StartCode + offset)); - if (codepoint < start_codepoint) { + u32 start_code_point = be_u32(m_slice.offset_pointer((u32)Table12Offsets::Record_StartCode + offset)); + if (code_point < start_code_point) { break; } - u32 end_codepoint = be_u32(m_slice.offset_pointer((u32)Table12Offsets::Record_EndCode + offset)); - if (codepoint > end_codepoint) { + u32 end_code_point = be_u32(m_slice.offset_pointer((u32)Table12Offsets::Record_EndCode + offset)); + if (code_point > end_code_point) { continue; } u32 glyph_offset = be_u32(m_slice.offset_pointer((u32)Table12Offsets::Record_StartGlyph + offset)); - return codepoint - start_codepoint + glyph_offset; + return code_point - start_code_point + glyph_offset; } return 0; } -u32 Cmap::glyph_id_for_codepoint(u32 codepoint) const +u32 Cmap::glyph_id_for_code_point(u32 code_point) const { auto opt_subtable = subtable(m_active_index); if (!opt_subtable.has_value()) { return 0; } auto subtable = opt_subtable.value(); - return subtable.glyph_id_for_codepoint(codepoint); + return subtable.glyph_id_for_code_point(code_point); } Optional<Cmap> Cmap::from_slice(const ReadonlyBytes& slice) diff --git a/Userland/Libraries/LibTTF/Cmap.h b/Userland/Libraries/LibTTF/Cmap.h index 4452e273e9..539907e83d 100644 --- a/Userland/Libraries/LibTTF/Cmap.h +++ b/Userland/Libraries/LibTTF/Cmap.h @@ -44,7 +44,7 @@ public: { } // Returns 0 if glyph not found. This corresponds to the "missing glyph" - u32 glyph_id_for_codepoint(u32 codepoint) const; + u32 glyph_id_for_code_point(u32 code_point) const; Platform platform_id() const; u16 encoding_id() const { return m_encoding_id; } Format format() const; @@ -73,8 +73,8 @@ public: Record = 12, }; - u32 glyph_id_for_codepoint_table_4(u32 codepoint) const; - u32 glyph_id_for_codepoint_table_12(u32 codepoint) const; + u32 glyph_id_for_code_point_table_4(u32 code_point) const; + u32 glyph_id_for_code_point_table_12(u32 code_point) const; ReadonlyBytes m_slice; u16 m_raw_platform_id { 0 }; @@ -86,7 +86,7 @@ public: Optional<Subtable> subtable(u32 index) const; void set_active_index(u32 index) { m_active_index = index; } // Returns 0 if glyph not found. This corresponds to the "missing glyph" - u32 glyph_id_for_codepoint(u32 codepoint) const; + u32 glyph_id_for_code_point(u32 code_point) const; private: enum class Offsets { diff --git a/Userland/Libraries/LibTTF/Font.cpp b/Userland/Libraries/LibTTF/Font.cpp index 026b5d8a05..f2ac36754e 100644 --- a/Userland/Libraries/LibTTF/Font.cpp +++ b/Userland/Libraries/LibTTF/Font.cpp @@ -501,7 +501,7 @@ bool Font::is_fixed_width() const { // FIXME: Read this information from the font file itself. // FIXME: Although, it appears some application do similar hacks - return glyph_metrics(glyph_id_for_codepoint('.'), 1, 1).advance_width == glyph_metrics(glyph_id_for_codepoint('X'), 1, 1).advance_width; + return glyph_metrics(glyph_id_for_code_point('.'), 1, 1).advance_width == glyph_metrics(glyph_id_for_code_point('X'), 1, 1).advance_width; } int ScaledFont::width(const StringView& string) const @@ -513,8 +513,8 @@ int ScaledFont::width(const StringView& string) const int ScaledFont::width(const Utf8View& utf8) const { int width = 0; - for (u32 codepoint : utf8) { - u32 glyph_id = glyph_id_for_codepoint(codepoint); + for (u32 code_point : utf8) { + u32 glyph_id = glyph_id_for_code_point(code_point); auto metrics = glyph_metrics(glyph_id); width += metrics.advance_width; } @@ -525,7 +525,7 @@ int ScaledFont::width(const Utf32View& utf32) const { int width = 0; for (size_t i = 0; i < utf32.length(); i++) { - u32 glyph_id = glyph_id_for_codepoint(utf32.code_points()[i]); + u32 glyph_id = glyph_id_for_code_point(utf32.code_points()[i]); auto metrics = glyph_metrics(glyph_id); width += metrics.advance_width; } @@ -545,7 +545,7 @@ RefPtr<Gfx::Bitmap> ScaledFont::raster_glyph(u32 glyph_id) const Gfx::Glyph ScaledFont::glyph(u32 code_point) const { - auto id = glyph_id_for_codepoint(code_point); + auto id = glyph_id_for_code_point(code_point); auto bitmap = raster_glyph(id); auto metrics = glyph_metrics(id); return Gfx::Glyph(bitmap, metrics.left_side_bearing, metrics.advance_width, metrics.ascender); @@ -553,21 +553,21 @@ Gfx::Glyph ScaledFont::glyph(u32 code_point) const u8 ScaledFont::glyph_width(size_t code_point) const { - auto id = glyph_id_for_codepoint(code_point); + auto id = glyph_id_for_code_point(code_point); auto metrics = glyph_metrics(id); return metrics.advance_width; } int ScaledFont::glyph_or_emoji_width(u32 code_point) const { - auto id = glyph_id_for_codepoint(code_point); + auto id = glyph_id_for_code_point(code_point); auto metrics = glyph_metrics(id); return metrics.advance_width; } u8 ScaledFont::glyph_fixed_width() const { - return glyph_metrics(glyph_id_for_codepoint(' ')).advance_width; + return glyph_metrics(glyph_id_for_code_point(' ')).advance_width; } } diff --git a/Userland/Libraries/LibTTF/Font.h b/Userland/Libraries/LibTTF/Font.h index cba23f66fd..d5f5aacaf9 100644 --- a/Userland/Libraries/LibTTF/Font.h +++ b/Userland/Libraries/LibTTF/Font.h @@ -54,7 +54,7 @@ public: RefPtr<Gfx::Bitmap> raster_glyph(u32 glyph_id, float x_scale, float y_scale) const; u32 glyph_count() const; u16 units_per_em() const; - u32 glyph_id_for_codepoint(u32 codepoint) const { return m_cmap.glyph_id_for_codepoint(codepoint); } + u32 glyph_id_for_code_point(u32 code_point) const { return m_cmap.glyph_id_for_code_point(code_point); } String family() const; String variant() const; u16 weight() const; @@ -110,7 +110,7 @@ public: m_x_scale = (point_width * dpi_x) / (POINTS_PER_INCH * units_per_em); m_y_scale = (point_height * dpi_y) / (POINTS_PER_INCH * units_per_em); } - u32 glyph_id_for_codepoint(u32 codepoint) const { return m_font->glyph_id_for_codepoint(codepoint); } + u32 glyph_id_for_code_point(u32 code_point) const { return m_font->glyph_id_for_code_point(code_point); } ScaledFontMetrics metrics() const { return m_font->metrics(m_x_scale, m_y_scale); } ScaledGlyphMetrics glyph_metrics(u32 glyph_id) const { return m_font->glyph_metrics(glyph_id, m_x_scale, m_y_scale); } RefPtr<Gfx::Bitmap> raster_glyph(u32 glyph_id) const; @@ -120,7 +120,7 @@ public: virtual u8 presentation_size() const override { return m_point_height; } virtual u16 weight() const override { return m_font->weight(); } virtual Gfx::Glyph glyph(u32 code_point) const override; - virtual bool contains_glyph(u32 code_point) const override { return m_font->glyph_id_for_codepoint(code_point) > 0; } + virtual bool contains_glyph(u32 code_point) const override { return m_font->glyph_id_for_code_point(code_point) > 0; } virtual u8 glyph_width(size_t ch) const override; virtual int glyph_or_emoji_width(u32 code_point) const override; virtual u8 glyph_height() const override { return m_point_height; } diff --git a/Userland/Libraries/LibVT/EscapeSequenceParser.cpp b/Userland/Libraries/LibVT/EscapeSequenceParser.cpp index dc2fd1e411..9d3a059bc6 100644 --- a/Userland/Libraries/LibVT/EscapeSequenceParser.cpp +++ b/Userland/Libraries/LibVT/EscapeSequenceParser.cpp @@ -39,10 +39,10 @@ Vector<EscapeSequenceParser::OscParameter> EscapeSequenceParser::osc_parameters( void EscapeSequenceParser::perform_action(EscapeSequenceStateMachine::Action action, u8 byte) { auto advance_utf8 = [&](u8 byte) { - u32 new_codepoint = m_code_point; - new_codepoint <<= 6; - new_codepoint |= byte & 0x3f; - return new_codepoint; + u32 new_code_point = m_code_point; + new_code_point <<= 6; + new_code_point |= byte & 0x3f; + return new_code_point; }; switch (action) { diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Tokenizer.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Tokenizer.cpp index e9ddf30a93..d15e1664ef 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Tokenizer.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Tokenizer.cpp @@ -20,179 +20,179 @@ static inline void log_parse_error(const SourceLocation& location = SourceLocati dbgln_if(CSS_TOKENIZER_TRACE, "Parse error (css tokenization) {} ", location); } -static inline bool is_surrogate(u32 codepoint) +static inline bool is_surrogate(u32 code_point) { - return (codepoint & 0xfffff800) == 0xd800; + return (code_point & 0xfffff800) == 0xd800; } -static inline bool is_quotation_mark(u32 codepoint) +static inline bool is_quotation_mark(u32 code_point) { - return codepoint == 0x22; + return code_point == 0x22; } -static inline bool is_greater_than_maximum_allowed_codepoint(u32 codepoint) +static inline bool is_greater_than_maximum_allowed_code_point(u32 code_point) { - return codepoint > 0x10FFFF; + return code_point > 0x10FFFF; } -static inline bool is_hex_digit(u32 codepoint) +static inline bool is_hex_digit(u32 code_point) { - return isxdigit(codepoint); + return isxdigit(code_point); } -static inline bool is_low_line(u32 codepoint) +static inline bool is_low_line(u32 code_point) { - return codepoint == 0x5F; + return code_point == 0x5F; } -static inline bool is_non_ascii(u32 codepoint) +static inline bool is_non_ascii(u32 code_point) { - return codepoint >= 0x80; + return code_point >= 0x80; } -static inline bool is_name_start_codepoint(u32 codepoint) +static inline bool is_name_start_code_point(u32 code_point) { - return isalpha(codepoint) || is_non_ascii(codepoint) || is_low_line(codepoint); + return isalpha(code_point) || is_non_ascii(code_point) || is_low_line(code_point); } -static inline bool is_hyphen_minus(u32 codepoint) +static inline bool is_hyphen_minus(u32 code_point) { - return codepoint == 0x2D; + return code_point == 0x2D; } -static inline bool is_name_codepoint(u32 codepoint) +static inline bool is_name_code_point(u32 code_point) { - return is_name_start_codepoint(codepoint) || isdigit(codepoint) || is_hyphen_minus(codepoint); + return is_name_start_code_point(code_point) || isdigit(code_point) || is_hyphen_minus(code_point); } -static inline bool is_non_printable(u32 codepoint) +static inline bool is_non_printable(u32 code_point) { - return codepoint <= 0x8 || codepoint == 0xB || (codepoint >= 0xE && codepoint <= 0x1F) || codepoint == 0x7F; + return code_point <= 0x8 || code_point == 0xB || (code_point >= 0xE && code_point <= 0x1F) || code_point == 0x7F; } -static inline bool is_number_sign(u32 codepoint) +static inline bool is_number_sign(u32 code_point) { - return codepoint == 0x23; + return code_point == 0x23; } -static inline bool is_reverse_solidus(u32 codepoint) +static inline bool is_reverse_solidus(u32 code_point) { - return codepoint == 0x5C; + return code_point == 0x5C; } -static inline bool is_apostrophe(u32 codepoint) +static inline bool is_apostrophe(u32 code_point) { - return codepoint == 0x27; + return code_point == 0x27; } -static inline bool is_left_paren(u32 codepoint) +static inline bool is_left_paren(u32 code_point) { - return codepoint == 0x28; + return code_point == 0x28; } -static inline bool is_right_paren(u32 codepoint) +static inline bool is_right_paren(u32 code_point) { - return codepoint == 0x29; + return code_point == 0x29; } -static inline bool is_plus_sign(u32 codepoint) +static inline bool is_plus_sign(u32 code_point) { - return codepoint == 0x2B; + return code_point == 0x2B; } -static inline bool is_comma(u32 codepoint) +static inline bool is_comma(u32 code_point) { - return codepoint == 0x2C; + return code_point == 0x2C; } -static inline bool is_full_stop(u32 codepoint) +static inline bool is_full_stop(u32 code_point) { - return codepoint == 0x2E; + return code_point == 0x2E; } -static inline bool is_newline(u32 codepoint) +static inline bool is_newline(u32 code_point) { - return codepoint == 0xA; + return code_point == 0xA; } -static inline bool is_asterisk(u32 codepoint) +static inline bool is_asterisk(u32 code_point) { - return codepoint == 0x2A; + return code_point == 0x2A; } -static inline bool is_solidus(u32 codepoint) +static inline bool is_solidus(u32 code_point) { - return codepoint == 0x2F; + return code_point == 0x2F; } -static inline bool is_colon(u32 codepoint) +static inline bool is_colon(u32 code_point) { - return codepoint == 0x3A; + return code_point == 0x3A; } -static inline bool is_semicolon(u32 codepoint) +static inline bool is_semicolon(u32 code_point) { - return codepoint == 0x3B; + return code_point == 0x3B; } -static inline bool is_less_than_sign(u32 codepoint) +static inline bool is_less_than_sign(u32 code_point) { - return codepoint == 0x3C; + return code_point == 0x3C; } -static inline bool is_greater_than_sign(u32 codepoint) +static inline bool is_greater_than_sign(u32 code_point) { - return codepoint == 0x3E; + return code_point == 0x3E; } -static inline bool is_at(u32 codepoint) +static inline bool is_at(u32 code_point) { - return codepoint == 0x40; + return code_point == 0x40; } -static inline bool is_open_square_bracket(u32 codepoint) +static inline bool is_open_square_bracket(u32 code_point) { - return codepoint == 0x5B; + return code_point == 0x5B; } -static inline bool is_closed_square_bracket(u32 codepoint) +static inline bool is_closed_square_bracket(u32 code_point) { - return codepoint == 0x5D; + return code_point == 0x5D; } -static inline bool is_open_curly_bracket(u32 codepoint) +static inline bool is_open_curly_bracket(u32 code_point) { - return codepoint == 0x7B; + return code_point == 0x7B; } -static inline bool is_closed_curly_bracket(u32 codepoint) +static inline bool is_closed_curly_bracket(u32 code_point) { - return codepoint == 0x7D; + return code_point == 0x7D; } -static inline bool is_whitespace(u32 codepoint) +static inline bool is_whitespace(u32 code_point) { - return codepoint == 0x9 || codepoint == 0xA || codepoint == 0x20; + return code_point == 0x9 || code_point == 0xA || code_point == 0x20; } -static inline bool is_percent(u32 codepoint) +static inline bool is_percent(u32 code_point) { - return codepoint == 0x25; + return code_point == 0x25; } -static inline bool is_exclamation_mark(u32 codepoint) +static inline bool is_exclamation_mark(u32 code_point) { - return codepoint == 0x21; + return code_point == 0x21; } -static inline bool is_e(u32 codepoint) +static inline bool is_e(u32 code_point) { - return codepoint == 0x65; + return code_point == 0x65; } -static inline bool is_E(u32 codepoint) +static inline bool is_E(u32 code_point) { - return codepoint == 0x45; + return code_point == 0x45; } namespace Web::CSS { @@ -222,17 +222,17 @@ Vector<Token> Tokenizer::parse() } } -Optional<u32> Tokenizer::next_codepoint() +Optional<u32> Tokenizer::next_code_point() { if (m_utf8_iterator == m_utf8_view.end()) return {}; m_prev_utf8_iterator = m_utf8_iterator; ++m_utf8_iterator; - dbgln_if(CSS_TOKENIZER_TRACE, "(Tokenizer) Next codepoint: {:c}", (char)*m_prev_utf8_iterator); + dbgln_if(CSS_TOKENIZER_TRACE, "(Tokenizer) Next code_point: {:c}", (char)*m_prev_utf8_iterator); return *m_prev_utf8_iterator; } -Optional<u32> Tokenizer::peek_codepoint(size_t offset) const +Optional<u32> Tokenizer::peek_code_point(size_t offset) const { auto it = m_utf8_iterator; for (size_t i = 0; i < offset && it != m_utf8_view.end(); ++i) @@ -292,32 +292,32 @@ Token Tokenizer::create_value_token(Token::TokenType type, u32 value) return token; } -u32 Tokenizer::consume_escaped_codepoint() +u32 Tokenizer::consume_escaped_code_point() { - auto codepoint = next_codepoint(); + auto code_point = next_code_point(); - if (!codepoint.has_value()) { + if (!code_point.has_value()) { log_parse_error(); return REPLACEMENT_CHARACTER; } - auto input = codepoint.value(); + auto input = code_point.value(); if (is_hex_digit(input)) { StringBuilder builder; builder.append_code_point(input); size_t counter = 0; - while (is_hex_digit(peek_codepoint().value()) && counter++ < 5) { - builder.append_code_point(next_codepoint().value()); + while (is_hex_digit(peek_code_point().value()) && counter++ < 5) { + builder.append_code_point(next_code_point().value()); } - if (is_whitespace(peek_codepoint().value())) { - (void)next_codepoint(); + if (is_whitespace(peek_code_point().value())) { + (void)next_code_point(); } auto unhexed = strtoul(builder.to_string().characters(), nullptr, 16); - if (unhexed == 0 || is_surrogate(unhexed) || is_greater_than_maximum_allowed_codepoint(unhexed)) { + if (unhexed == 0 || is_surrogate(unhexed) || is_greater_than_maximum_allowed_code_point(unhexed)) { return REPLACEMENT_CHARACTER; } @@ -336,8 +336,8 @@ Token Tokenizer::consume_an_ident_like_token() { auto string = consume_a_name(); - if (string.equals_ignoring_case("url") && is_left_paren(peek_codepoint().value())) { - (void)next_codepoint(); + if (string.equals_ignoring_case("url") && is_left_paren(peek_code_point().value())) { + (void)next_code_point(); for (;;) { auto maybe_whitespace = peek_twin().value(); @@ -345,7 +345,7 @@ Token Tokenizer::consume_an_ident_like_token() break; } - (void)next_codepoint(); + (void)next_code_point(); } auto next_two = peek_twin().value(); @@ -357,8 +357,8 @@ Token Tokenizer::consume_an_ident_like_token() return consume_a_url_token(); } - if (is_left_paren(peek_codepoint().value())) { - (void)next_codepoint(); + if (is_left_paren(peek_code_point().value())) { + (void)next_code_point(); return create_value_token(Token::TokenType::Function, string); } @@ -371,32 +371,32 @@ CSSNumber Tokenizer::consume_a_number() StringBuilder repr; Token::NumberType type = Token::NumberType::Integer; - auto next_input = peek_codepoint().value(); + auto next_input = peek_code_point().value(); if (is_plus_sign(next_input) || is_hyphen_minus(next_input)) { - repr.append_code_point(next_codepoint().value()); + repr.append_code_point(next_code_point().value()); } for (;;) { - auto digits = peek_codepoint().value(); + auto digits = peek_code_point().value(); if (!isdigit(digits)) break; - repr.append_code_point(next_codepoint().value()); + repr.append_code_point(next_code_point().value()); } auto maybe_number = peek_twin().value(); if (is_full_stop(maybe_number.first) && isdigit(maybe_number.second)) { - repr.append_code_point(next_codepoint().value()); - repr.append_code_point(next_codepoint().value()); + repr.append_code_point(next_code_point().value()); + repr.append_code_point(next_code_point().value()); type = Token::NumberType::Number; for (;;) { - auto digits = peek_codepoint(); + auto digits = peek_code_point(); if (digits.has_value() && !isdigit(digits.value())) break; - repr.append_code_point(next_codepoint().value()); + repr.append_code_point(next_code_point().value()); } } @@ -404,23 +404,23 @@ CSSNumber Tokenizer::consume_a_number() if (is_E(maybe_exp.first) || is_e(maybe_exp.first)) { if (is_plus_sign(maybe_exp.second) || is_hyphen_minus(maybe_exp.second)) { if (isdigit(maybe_exp.third)) { - repr.append_code_point(next_codepoint().value()); - repr.append_code_point(next_codepoint().value()); - repr.append_code_point(next_codepoint().value()); + repr.append_code_point(next_code_point().value()); + repr.append_code_point(next_code_point().value()); + repr.append_code_point(next_code_point().value()); } } else if (isdigit(maybe_exp.second)) { - repr.append_code_point(next_codepoint().value()); - repr.append_code_point(next_codepoint().value()); + repr.append_code_point(next_code_point().value()); + repr.append_code_point(next_code_point().value()); } type = Token::NumberType::Number; for (;;) { - auto digits = peek_codepoint().value(); + auto digits = peek_code_point().value(); if (!isdigit(digits)) break; - repr.append_code_point(next_codepoint().value()); + repr.append_code_point(next_code_point().value()); } } @@ -432,66 +432,66 @@ String Tokenizer::consume_a_name() StringBuilder result; for (;;) { - auto input = next_codepoint().value(); + auto input = next_code_point().value(); - if (is_name_codepoint(input)) { + if (is_name_code_point(input)) { result.append_code_point(input); continue; } - auto next = peek_codepoint(); + auto next = peek_code_point(); if (next.has_value() && is_valid_escape_sequence({ input, next.value() })) { - result.append_code_point(consume_escaped_codepoint()); + result.append_code_point(consume_escaped_code_point()); continue; } break; } - reconsume_current_input_codepoint(); + reconsume_current_input_code_point(); return result.to_string(); } Token Tokenizer::consume_a_url_token() { auto token = create_new_token(Token::TokenType::Url); for (;;) { - if (!is_whitespace(peek_codepoint().value())) { + if (!is_whitespace(peek_code_point().value())) { break; } - (void)next_codepoint(); + (void)next_code_point(); } for (;;) { - auto codepoint = peek_codepoint(); - if (!codepoint.has_value()) { + auto code_point = peek_code_point(); + if (!code_point.has_value()) { log_parse_error(); return token; } - auto input = codepoint.value(); + auto input = code_point.value(); if (is_right_paren(input)) { - (void)next_codepoint(); + (void)next_code_point(); return token; } if (is_whitespace(input)) { for (;;) { - if (!is_whitespace(peek_codepoint().value())) { + if (!is_whitespace(peek_code_point().value())) { break; } - codepoint = next_codepoint(); + code_point = next_code_point(); } - if (!codepoint.has_value()) { + if (!code_point.has_value()) { log_parse_error(); return token; } - input = codepoint.value(); + input = code_point.value(); if (is_right_paren(input)) { return token; @@ -503,30 +503,30 @@ Token Tokenizer::consume_a_url_token() if (is_quotation_mark(input) || is_apostrophe(input) || is_left_paren(input) || is_non_printable(input)) { log_parse_error(); - (void)next_codepoint(); + (void)next_code_point(); consume_the_remnants_of_a_bad_url(); return create_new_token(Token::TokenType::BadUrl); } if (is_reverse_solidus(input)) { if (is_valid_escape_sequence()) { - token.m_value.append_code_point(consume_escaped_codepoint()); + token.m_value.append_code_point(consume_escaped_code_point()); } else { log_parse_error(); - (void)next_codepoint(); + (void)next_code_point(); consume_the_remnants_of_a_bad_url(); return create_new_token(Token::TokenType::BadUrl); } } - token.m_value.append_code_point(next_codepoint().value()); + token.m_value.append_code_point(next_code_point().value()); } } void Tokenizer::consume_the_remnants_of_a_bad_url() { for (;;) { - auto next = peek_codepoint(); + auto next = peek_code_point(); if (!next.has_value()) { return; @@ -535,19 +535,19 @@ void Tokenizer::consume_the_remnants_of_a_bad_url() auto input = next.value(); if (is_right_paren(input)) { - (void)next_codepoint(); + (void)next_code_point(); return; } if (is_valid_escape_sequence()) { - [[maybe_unused]] auto cp = consume_escaped_codepoint(); + [[maybe_unused]] auto cp = consume_escaped_code_point(); } - (void)next_codepoint(); + (void)next_code_point(); } } -void Tokenizer::reconsume_current_input_codepoint() +void Tokenizer::reconsume_current_input_code_point() { m_utf8_iterator = m_prev_utf8_iterator; } @@ -566,8 +566,8 @@ Token Tokenizer::consume_a_numeric_token() return token; } - if (is_percent(peek_codepoint().value())) { - (void)next_codepoint(); + if (is_percent(peek_code_point().value())) { + (void)next_code_point(); auto token = create_new_token(Token::TokenType::Percentage); token.m_value.append(number.value); @@ -632,12 +632,12 @@ bool Tokenizer::would_start_an_identifier() bool Tokenizer::would_start_an_identifier(U32Triplet values) { if (is_hyphen_minus(values.first)) { - if (is_name_start_codepoint(values.second) || is_hyphen_minus(values.second) || is_valid_escape_sequence(values.to_twin_23())) + if (is_name_start_code_point(values.second) || is_hyphen_minus(values.second) || is_valid_escape_sequence(values.to_twin_23())) return true; return false; } - if (is_name_start_codepoint(values.first)) { + if (is_name_start_code_point(values.first)) { return true; } @@ -650,39 +650,39 @@ bool Tokenizer::would_start_an_identifier(U32Triplet values) return false; } -Token Tokenizer::consume_string_token(u32 ending_codepoint) +Token Tokenizer::consume_string_token(u32 ending_code_point) { auto token = create_new_token(Token::TokenType::String); for (;;) { - auto codepoint = next_codepoint(); + auto code_point = next_code_point(); - if (!codepoint.has_value()) { + if (!code_point.has_value()) { log_parse_error(); return token; } - auto input = codepoint.value(); + auto input = code_point.value(); - if (input == ending_codepoint) + if (input == ending_code_point) return token; if (is_newline(input)) { - reconsume_current_input_codepoint(); + reconsume_current_input_code_point(); return create_new_token(Token::TokenType::BadString); } if (is_reverse_solidus(input)) { - auto next_input = peek_codepoint(); + auto next_input = peek_code_point(); if (!next_input.has_value()) continue; if (is_newline(next_input.value())) { - (void)next_codepoint(); + (void)next_code_point(); continue; } - auto escaped = consume_escaped_codepoint(); + auto escaped = consume_escaped_code_point(); token.m_value.append_code_point(escaped); } @@ -703,8 +703,8 @@ start: if (!(is_solidus(twin.first) && is_asterisk(twin.second))) return; - (void)next_codepoint(); - (void)next_codepoint(); + (void)next_code_point(); + (void)next_code_point(); for (;;) { auto peek_inner = peek_twin(); @@ -716,12 +716,12 @@ start: auto twin_inner = peek_inner.value(); if (is_asterisk(twin_inner.first) && is_solidus(twin_inner.second)) { - (void)next_codepoint(); - (void)next_codepoint(); + (void)next_code_point(); + (void)next_code_point(); goto start; } - (void)next_codepoint(); + (void)next_code_point(); } } @@ -729,19 +729,19 @@ Token Tokenizer::consume_a_token() { consume_comments(); - auto codepoint = next_codepoint(); + auto code_point = next_code_point(); - if (!codepoint.has_value()) { + if (!code_point.has_value()) { return create_new_token(Token::TokenType::EndOfFile); } - auto input = codepoint.value(); + auto input = code_point.value(); if (is_whitespace(input)) { dbgln_if(CSS_TOKENIZER_TRACE, "is whitespace"); - while (is_whitespace(peek_codepoint().value())) - (void)next_codepoint(); + while (is_whitespace(peek_code_point().value())) + (void)next_code_point(); return create_new_token(Token::TokenType::Whitespace); } @@ -754,10 +754,10 @@ Token Tokenizer::consume_a_token() if (is_number_sign(input)) { dbgln_if(CSS_TOKENIZER_TRACE, "is number sign"); - auto next_input = peek_codepoint().value(); + auto next_input = peek_code_point().value(); auto maybe_escape = peek_twin().value(); - if (is_name_codepoint(next_input) || is_valid_escape_sequence(maybe_escape)) { + if (is_name_code_point(next_input) || is_valid_escape_sequence(maybe_escape)) { auto token = create_new_token(Token::TokenType::Hash); if (would_start_an_identifier()) @@ -790,7 +790,7 @@ Token Tokenizer::consume_a_token() if (is_plus_sign(input)) { dbgln_if(CSS_TOKENIZER_TRACE, "is plus sign"); if (starts_with_a_number()) { - reconsume_current_input_codepoint(); + reconsume_current_input_code_point(); return consume_a_numeric_token(); } @@ -805,20 +805,20 @@ Token Tokenizer::consume_a_token() if (is_hyphen_minus(input)) { dbgln_if(CSS_TOKENIZER_TRACE, "is hyphen minus"); if (starts_with_a_number()) { - reconsume_current_input_codepoint(); + reconsume_current_input_code_point(); return consume_a_numeric_token(); } auto next_twin = peek_twin().value(); if (is_hyphen_minus(next_twin.first) && is_greater_than_sign(next_twin.second)) { - (void)next_codepoint(); - (void)next_codepoint(); + (void)next_code_point(); + (void)next_code_point(); return create_new_token(Token::TokenType::CDC); } if (would_start_an_identifier()) { - reconsume_current_input_codepoint(); + reconsume_current_input_code_point(); return consume_an_ident_like_token(); } @@ -828,7 +828,7 @@ Token Tokenizer::consume_a_token() if (is_full_stop(input)) { dbgln_if(CSS_TOKENIZER_TRACE, "is full stop"); if (starts_with_a_number()) { - reconsume_current_input_codepoint(); + reconsume_current_input_code_point(); return consume_a_numeric_token(); } @@ -850,9 +850,9 @@ Token Tokenizer::consume_a_token() auto maybe_cdo = peek_triplet().value(); if (is_exclamation_mark(maybe_cdo.first) && is_hyphen_minus(maybe_cdo.second) && is_hyphen_minus(maybe_cdo.third)) { - (void)next_codepoint(); - (void)next_codepoint(); - (void)next_codepoint(); + (void)next_code_point(); + (void)next_code_point(); + (void)next_code_point(); return create_new_token(Token::TokenType::CDO); } @@ -879,7 +879,7 @@ Token Tokenizer::consume_a_token() if (is_reverse_solidus(input)) { dbgln_if(CSS_TOKENIZER_TRACE, "is reverse solidus"); if (is_valid_escape_sequence()) { - reconsume_current_input_codepoint(); + reconsume_current_input_code_point(); return consume_an_ident_like_token(); } @@ -904,13 +904,13 @@ Token Tokenizer::consume_a_token() if (isdigit(input)) { dbgln_if(CSS_TOKENIZER_TRACE, "is digit"); - reconsume_current_input_codepoint(); + reconsume_current_input_code_point(); return consume_a_numeric_token(); } - if (is_name_start_codepoint(input)) { + if (is_name_start_code_point(input)) { dbgln_if(CSS_TOKENIZER_TRACE, "is name start"); - reconsume_current_input_codepoint(); + reconsume_current_input_code_point(); return consume_an_ident_like_token(); } diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Tokenizer.h b/Userland/Libraries/LibWeb/CSS/Parser/Tokenizer.h index 3548242bc3..ea4b961b63 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Tokenizer.h +++ b/Userland/Libraries/LibWeb/CSS/Parser/Tokenizer.h @@ -71,8 +71,8 @@ public: [[nodiscard]] Vector<Token> parse(); private: - [[nodiscard]] Optional<u32> next_codepoint(); - [[nodiscard]] Optional<u32> peek_codepoint(size_t offset = 0) const; + [[nodiscard]] Optional<u32> next_code_point(); + [[nodiscard]] Optional<u32> peek_code_point(size_t offset = 0) const; [[nodiscard]] Optional<U32Twin> peek_twin() const; [[nodiscard]] Optional<U32Triplet> peek_triplet() const; @@ -80,16 +80,16 @@ private: [[nodiscard]] static Token create_value_token(Token::TokenType, String value); [[nodiscard]] static Token create_value_token(Token::TokenType, u32 value); [[nodiscard]] Token consume_a_token(); - [[nodiscard]] Token consume_string_token(u32 ending_codepoint); + [[nodiscard]] Token consume_string_token(u32 ending_code_point); [[nodiscard]] Token consume_a_numeric_token(); [[nodiscard]] Token consume_an_ident_like_token(); [[nodiscard]] CSSNumber consume_a_number(); [[nodiscard]] String consume_a_name(); - [[nodiscard]] u32 consume_escaped_codepoint(); + [[nodiscard]] u32 consume_escaped_code_point(); [[nodiscard]] Token consume_a_url_token(); void consume_the_remnants_of_a_bad_url(); void consume_comments(); - void reconsume_current_input_codepoint(); + void reconsume_current_input_code_point(); [[nodiscard]] bool is_valid_escape_sequence(); [[nodiscard]] static bool is_valid_escape_sequence(U32Twin); [[nodiscard]] bool would_start_an_identifier(); diff --git a/Userland/Libraries/LibWeb/DOM/Position.cpp b/Userland/Libraries/LibWeb/DOM/Position.cpp index 155e94ecbe..e4dc8cd67c 100644 --- a/Userland/Libraries/LibWeb/DOM/Position.cpp +++ b/Userland/Libraries/LibWeb/DOM/Position.cpp @@ -39,7 +39,7 @@ bool Position::increment_offset() for (auto iterator = text.begin(); !iterator.done(); ++iterator) { if (text.byte_offset_of(iterator) >= m_offset) { - // NOTE: If the current offset is inside a multi-byte codepoint, it will be moved to the start of the next codepoint. + // NOTE: If the current offset is inside a multi-byte code point, it will be moved to the start of the next code point. m_offset = text.byte_offset_of(++iterator); return true; } @@ -66,7 +66,7 @@ bool Position::decrement_offset() last_smaller_offset = text.byte_offset_of(iterator); } - // NOTE: If the current offset is inside a multi-byte codepoint, it will be moved to the start of that codepoint. + // NOTE: If the current offset is inside a multi-byte code point, it will be moved to the start of that code point. m_offset = last_smaller_offset; return true; } diff --git a/Userland/Libraries/LibWeb/Page/EditEventHandler.cpp b/Userland/Libraries/LibWeb/Page/EditEventHandler.cpp index a9246df1e6..c1f96546aa 100644 --- a/Userland/Libraries/LibWeb/Page/EditEventHandler.cpp +++ b/Userland/Libraries/LibWeb/Page/EditEventHandler.cpp @@ -26,11 +26,11 @@ void EditEventHandler::handle_delete_character_after(const DOM::Position& cursor auto& node = *static_cast<DOM::Text*>(const_cast<DOM::Node*>(cursor_position.node())); auto& text = node.data(); - auto codepoint_length = Utf8View(text).iterator_at_byte_offset(cursor_position.offset()).code_point_length_in_bytes(); + auto code_point_length = Utf8View(text).iterator_at_byte_offset(cursor_position.offset()).code_point_length_in_bytes(); StringBuilder builder; builder.append(text.substring_view(0, cursor_position.offset())); - builder.append(text.substring_view(cursor_position.offset() + codepoint_length)); + builder.append(text.substring_view(cursor_position.offset() + code_point_length)); node.set_data(builder.to_string()); m_frame.did_edit({}); diff --git a/Userland/Libraries/LibWeb/Page/EventHandler.cpp b/Userland/Libraries/LibWeb/Page/EventHandler.cpp index 31fd4c9cc4..c5f61c058c 100644 --- a/Userland/Libraries/LibWeb/Page/EventHandler.cpp +++ b/Userland/Libraries/LibWeb/Page/EventHandler.cpp @@ -379,10 +379,10 @@ bool EventHandler::focus_previous_element() return false; } -constexpr bool should_ignore_keydown_event(u32 codepoint) +constexpr bool should_ignore_keydown_event(u32 code_point) { - // FIXME: There are probably also keys with non-zero codepoints that should be filtered out. - return codepoint == 0; + // FIXME: There are probably also keys with non-zero code points that should be filtered out. + return code_point == 0; } bool EventHandler::handle_keydown(KeyCode key, unsigned modifiers, u32 code_point) diff --git a/Userland/Shell/Tests/brace-exp.sh b/Userland/Shell/Tests/brace-exp.sh index e283d4410d..482e9cb126 100644 --- a/Userland/Shell/Tests/brace-exp.sh +++ b/Userland/Shell/Tests/brace-exp.sh @@ -11,7 +11,7 @@ if not test "$(echo {a,b,,})" = "a b " { fail normal brace expansion with two if not test "$(echo {a..c})" = "a b c" { fail range brace expansion, alpha } if not test "$(echo {0..3})" = "0 1 2 3" { fail range brace expansion, number } -if not test "$(echo {😂..😄})" = "😂 😃 😄" { fail range brace expansion, unicode codepoint } +if not test "$(echo {😂..😄})" = "😂 😃 😄" { fail range brace expansion, unicode code point } # Make sure that didn't mess with dots and commas in normal barewords if not test .. = ".." { fail range brace expansion delimiter affects normal barewords } |