LibWeb+LibUnicode+WebContent: Port DOM:CharacterData to UTF-16

This replaces the underlying storage of CharacterData with Utf16String
and deals with the fallout.
This commit is contained in:
Timothy Flynn 2025-07-24 12:05:52 -04:00 committed by Jelle Raaijmakers
parent cb85eac3d8
commit 8b6e3cb735
Notes: github-actions[bot] 2025-07-24 17:01:33 +00:00
56 changed files with 233 additions and 245 deletions

View file

@ -650,7 +650,7 @@ void ConnectionFromClient::get_dom_node_inner_html(u64 page_id, Web::UniqueNodeI
html = element.inner_html().release_value_but_fixme_should_propagate_errors();
} else if (dom_node->is_text() || dom_node->is_comment()) {
auto const& character_data = static_cast<Web::DOM::CharacterData const&>(*dom_node);
html = character_data.data();
html = character_data.data().to_utf8_but_should_be_ported_to_utf16();
} else {
return;
}
@ -671,7 +671,7 @@ void ConnectionFromClient::get_dom_node_outer_html(u64 page_id, Web::UniqueNodeI
html = element.outer_html().release_value_but_fixme_should_propagate_errors();
} else if (dom_node->is_text() || dom_node->is_comment()) {
auto const& character_data = static_cast<Web::DOM::CharacterData const&>(*dom_node);
html = character_data.data();
html = character_data.data().to_utf8_but_should_be_ported_to_utf16();
} else {
return;
}
@ -692,7 +692,7 @@ void ConnectionFromClient::set_dom_node_outer_html(u64 page_id, Web::UniqueNodeI
element.set_outer_html(html).release_value_but_fixme_should_propagate_errors();
} else if (dom_node->is_text() || dom_node->is_comment()) {
auto& character_data = static_cast<Web::DOM::CharacterData&>(*dom_node);
character_data.set_data(html);
character_data.set_data(Utf16String::from_utf8(html));
} else {
async_did_finish_editing_dom_node(page_id, {});
return;
@ -710,7 +710,7 @@ void ConnectionFromClient::set_dom_node_text(u64 page_id, Web::UniqueNodeID node
}
auto& character_data = static_cast<Web::DOM::CharacterData&>(*dom_node);
character_data.set_data(text);
character_data.set_data(Utf16String::from_utf8(text));
async_did_finish_editing_dom_node(page_id, character_data.unique_id());
}
@ -804,7 +804,7 @@ void ConnectionFromClient::create_child_text_node(u64 page_id, Web::UniqueNodeID
return;
}
auto text_node = dom_node->realm().create<Web::DOM::Text>(dom_node->document(), "text"_string);
auto text_node = dom_node->realm().create<Web::DOM::Text>(dom_node->document(), "text"_utf16);
dom_node->append_child(text_node).release_value_but_fixme_should_propagate_errors();
async_did_finish_editing_dom_node(page_id, text_node->unique_id());

View file

@ -667,7 +667,7 @@ void PageClient::page_did_mutate_dom(FlyString const& type, Web::DOM::Node const
mutation = WebView::AttributeMutation { *attribute_name, element.attribute(*attribute_name) };
} else if (type == Web::DOM::MutationType::characterData) {
auto const& character_data = as<Web::DOM::CharacterData>(target);
mutation = WebView::CharacterDataMutation { character_data.data() };
mutation = WebView::CharacterDataMutation { character_data.data().to_utf8_but_should_be_ported_to_utf16() };
} else if (type == Web::DOM::MutationType::childList) {
Vector<Web::UniqueNodeID> added;
added.ensure_capacity(added_nodes.length());