1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:47:44 +00:00

LibWeb: Port CharacterData from DeprecatedString to String

The existing implementation has some pre-existing issues where it is
incorrectly assumes that byte offsets are given through the IDL instead
of UTF-16 code units. While making these changes, leave some FIXMEs for
that.
This commit is contained in:
Shannon Booth 2023-09-07 21:36:05 +12:00 committed by Andreas Kling
parent 3b12a13f17
commit b603e860af
18 changed files with 87 additions and 81 deletions

View file

@ -14,12 +14,12 @@
namespace Web::DOM {
Text::Text(Document& document, String const& data)
: CharacterData(document, NodeType::TEXT_NODE, data.to_deprecated_string())
: CharacterData(document, NodeType::TEXT_NODE, data)
{
}
Text::Text(Document& document, NodeType type, String const& data)
: CharacterData(document, type, data.to_deprecated_string())
: CharacterData(document, type, data)
{
}
@ -63,7 +63,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Text>> Text::split_text(size_t offset)
auto new_data = TRY(substring_data(offset, count));
// 5. Let new node be a new Text node, with the same node document as node. Set new nodes data to new data.
auto new_node = heap().allocate<Text>(realm(), document(), MUST(String::from_deprecated_string(new_data)));
auto new_node = heap().allocate<Text>(realm(), document(), new_data);
// 6. Let parent be nodes parent.
JS::GCPtr<Node> parent = this->parent();
@ -100,7 +100,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Text>> Text::split_text(size_t offset)
}
// 8. Replace data with node node, offset offset, count count, and data the empty string.
TRY(replace_data(offset, count, ""));
TRY(replace_data(offset, count, String {}));
// 9. Return new node.
return new_node;