mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-09 09:39:13 +00:00
AK+LibJS+LibWeb+LibRegex: Replace AK::Utf16Data with AK::Utf16String
This commit is contained in:
parent
a43cb15e81
commit
9582895759
Notes:
github-actions[bot]
2025-07-18 16:46:53 +00:00
Author: https://github.com/trflynn89
Commit: 9582895759
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5388
Reviewed-by: https://github.com/shannonbooth ✅
22 changed files with 101 additions and 222 deletions
|
@ -384,9 +384,9 @@ void canonicalize_whitespace(DOM::BoundaryPoint boundary, bool fix_collapsed_spa
|
|||
auto parent_white_space_collapse = resolved_keyword(*start_node->parent(), CSS::PropertyID::WhiteSpaceCollapse);
|
||||
|
||||
// FIXME: Find a way to get code points directly from the UTF-8 string
|
||||
auto start_node_data = *start_node->text_content();
|
||||
auto utf16_code_units = MUST(AK::utf8_to_utf16(start_node_data));
|
||||
auto offset_minus_one_code_point = Utf16View { utf16_code_units }.code_point_at(start_offset - 1);
|
||||
auto start_node_data = Utf16String::from_utf8(*start_node->text_content());
|
||||
auto offset_minus_one_code_point = start_node_data.code_point_at(start_offset - 1);
|
||||
|
||||
if (parent_white_space_collapse != CSS::Keyword::Preserve && (offset_minus_one_code_point == 0x20 || offset_minus_one_code_point == 0xA0)) {
|
||||
--start_offset;
|
||||
continue;
|
||||
|
@ -437,9 +437,9 @@ void canonicalize_whitespace(DOM::BoundaryPoint boundary, bool fix_collapsed_spa
|
|||
auto parent_white_space_collapse = resolved_keyword(*end_node->parent(), CSS::PropertyID::WhiteSpaceCollapse);
|
||||
|
||||
// FIXME: Find a way to get code points directly from the UTF-8 string
|
||||
auto end_node_data = *end_node->text_content();
|
||||
auto utf16_code_units = MUST(AK::utf8_to_utf16(end_node_data));
|
||||
auto offset_code_point = Utf16View { utf16_code_units }.code_point_at(end_offset);
|
||||
auto end_node_data = Utf16String::from_utf8(*end_node->text_content());
|
||||
auto offset_code_point = end_node_data.code_point_at(end_offset);
|
||||
|
||||
if (parent_white_space_collapse != CSS::Keyword::Preserve && (offset_code_point == 0x20 || offset_code_point == 0xA0)) {
|
||||
// 1. If fix collapsed space is true, and collapse spaces is true, and the end offsetth
|
||||
// code unit of end node's data is a space (0x0020): call deleteData(end offset, 1)
|
||||
|
@ -556,16 +556,14 @@ void canonicalize_whitespace(DOM::BoundaryPoint boundary, bool fix_collapsed_spa
|
|||
// 1. Remove the first code unit from replacement whitespace, and let element be that
|
||||
// code unit.
|
||||
// FIXME: Find a way to get code points directly from the UTF-8 string
|
||||
auto replacement_whitespace_utf16 = MUST(AK::utf8_to_utf16(replacement_whitespace));
|
||||
auto replacement_whitespace_utf16_view = Utf16View { replacement_whitespace_utf16 };
|
||||
replacement_whitespace = MUST(String::from_utf16({ replacement_whitespace_utf16_view.substring_view(1) }));
|
||||
auto element = replacement_whitespace_utf16_view.code_point_at(0);
|
||||
auto replacement_whitespace_utf16 = Utf16String::from_utf8(replacement_whitespace);
|
||||
replacement_whitespace = MUST(replacement_whitespace_utf16.substring_view(1).to_utf8());
|
||||
auto element = replacement_whitespace_utf16.code_point_at(0);
|
||||
|
||||
// 2. If element is not the same as the start offsetth code unit of start node's data:
|
||||
auto start_node_data = *start_node->text_content();
|
||||
auto start_node_utf16 = MUST(AK::utf8_to_utf16(start_node_data));
|
||||
auto start_node_utf16_view = Utf16View { start_node_utf16 };
|
||||
auto start_node_code_point = start_node_utf16_view.code_point_at(start_offset);
|
||||
auto start_node_data = Utf16String::from_utf8(*start_node->text_content());
|
||||
auto start_node_code_point = start_node_data.code_point_at(start_offset);
|
||||
|
||||
if (element != start_node_code_point) {
|
||||
// 1. Call insertData(start offset, element) on start node.
|
||||
auto& start_node_character_data = static_cast<DOM::CharacterData&>(*start_node);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue