mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-05 15:49:15 +00:00
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:
parent
cb85eac3d8
commit
8b6e3cb735
Notes:
github-actions[bot]
2025-07-24 17:01:33 +00:00
Author: https://github.com/trflynn89
Commit: 8b6e3cb735
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5592
Reviewed-by: https://github.com/gmta ✅
56 changed files with 233 additions and 245 deletions
|
@ -754,7 +754,7 @@ static WebIDL::ExceptionOr<String> serialize_comment(DOM::Comment const& comment
|
|||
if (comment.data().contains("--"sv))
|
||||
return WebIDL::InvalidStateError::create(comment.realm(), "Comment data contains two adjacent hyphens"_string);
|
||||
|
||||
if (comment.data().ends_with('-'))
|
||||
if (comment.data().ends_with("-"sv))
|
||||
return WebIDL::InvalidStateError::create(comment.realm(), "Comment data ends with a hyphen"_string);
|
||||
}
|
||||
|
||||
|
@ -776,7 +776,7 @@ static WebIDL::ExceptionOr<String> serialize_text(DOM::Text const& text, Require
|
|||
// 1. If the require well-formed flag is set (its value is true), and node's data contains characters that are not matched by the XML Char production,
|
||||
// then throw an exception; the serialization of this node's data would not be well-formed.
|
||||
if (require_well_formed == RequireWellFormed::Yes) {
|
||||
for (u32 code_point : text.data().code_points()) {
|
||||
for (u32 code_point : text.data()) {
|
||||
if (!is_valid_xml_char(code_point))
|
||||
return WebIDL::InvalidStateError::create(text.realm(), "Text contains characters not allowed in XML"_string);
|
||||
}
|
||||
|
@ -786,16 +786,16 @@ static WebIDL::ExceptionOr<String> serialize_text(DOM::Text const& text, Require
|
|||
auto markup = text.data();
|
||||
|
||||
// 3. Replace any occurrences of "&" in markup by "&".
|
||||
markup = MUST(markup.replace("&"sv, "&"sv, ReplaceMode::All));
|
||||
markup = markup.replace("&"sv, "&"sv, ReplaceMode::All);
|
||||
|
||||
// 4. Replace any occurrences of "<" in markup by "<".
|
||||
markup = MUST(markup.replace("<"sv, "<"sv, ReplaceMode::All));
|
||||
markup = markup.replace("<"sv, "<"sv, ReplaceMode::All);
|
||||
|
||||
// 5. Replace any occurrences of ">" in markup by ">".
|
||||
markup = MUST(markup.replace(">"sv, ">"sv, ReplaceMode::All));
|
||||
markup = markup.replace(">"sv, ">"sv, ReplaceMode::All);
|
||||
|
||||
// 6. Return the value of markup.
|
||||
return markup;
|
||||
return markup.to_utf8_but_should_be_ported_to_utf16();
|
||||
}
|
||||
|
||||
// https://w3c.github.io/DOM-Parsing/#xml-serializing-a-documentfragment-node
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue