mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-26 22:38:51 +00:00
Everywhere: Add sv suffix to strings relying on StringView(char const*)
Each of these strings would previously rely on StringView's char const* constructor overload, which would call __builtin_strlen on the string. Since we now have operator ""sv, we can replace these with much simpler versions. This opens the door to being able to remove StringView(char const*). No functional changes.
This commit is contained in:
parent
e5f09ea170
commit
3f3f45580a
Notes:
sideshowbarker
2024-07-17 09:27:05 +09:00
Author: https://github.com/sin-ack
Commit: 3f3f45580a
Pull-request: https://github.com/SerenityOS/serenity/pull/14555
Reviewed-by: https://github.com/Dexesttp ✅
Reviewed-by: https://github.com/kleinesfilmroellchen
762 changed files with 8315 additions and 8316 deletions
|
@ -393,16 +393,16 @@ DOM::QuirksMode HTMLParser::which_quirks_mode(HTMLToken const& doctype_token) co
|
|||
auto const& public_identifier = doctype_token.doctype_data().public_identifier;
|
||||
auto const& system_identifier = doctype_token.doctype_data().system_identifier;
|
||||
|
||||
if (public_identifier.equals_ignoring_case("-//W3O//DTD W3 HTML Strict 3.0//EN//"))
|
||||
if (public_identifier.equals_ignoring_case("-//W3O//DTD W3 HTML Strict 3.0//EN//"sv))
|
||||
return DOM::QuirksMode::Yes;
|
||||
|
||||
if (public_identifier.equals_ignoring_case("-/W3C/DTD HTML 4.0 Transitional/EN"))
|
||||
if (public_identifier.equals_ignoring_case("-/W3C/DTD HTML 4.0 Transitional/EN"sv))
|
||||
return DOM::QuirksMode::Yes;
|
||||
|
||||
if (public_identifier.equals_ignoring_case("HTML"))
|
||||
if (public_identifier.equals_ignoring_case("HTML"sv))
|
||||
return DOM::QuirksMode::Yes;
|
||||
|
||||
if (system_identifier.equals_ignoring_case("http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd"))
|
||||
if (system_identifier.equals_ignoring_case("http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd"sv))
|
||||
return DOM::QuirksMode::Yes;
|
||||
|
||||
for (auto& public_id : s_quirks_public_ids) {
|
||||
|
@ -411,24 +411,24 @@ DOM::QuirksMode HTMLParser::which_quirks_mode(HTMLToken const& doctype_token) co
|
|||
}
|
||||
|
||||
if (doctype_token.doctype_data().missing_system_identifier) {
|
||||
if (public_identifier.starts_with("-//W3C//DTD HTML 4.01 Frameset//", CaseSensitivity::CaseInsensitive))
|
||||
if (public_identifier.starts_with("-//W3C//DTD HTML 4.01 Frameset//"sv, CaseSensitivity::CaseInsensitive))
|
||||
return DOM::QuirksMode::Yes;
|
||||
|
||||
if (public_identifier.starts_with("-//W3C//DTD HTML 4.01 Transitional//", CaseSensitivity::CaseInsensitive))
|
||||
if (public_identifier.starts_with("-//W3C//DTD HTML 4.01 Transitional//"sv, CaseSensitivity::CaseInsensitive))
|
||||
return DOM::QuirksMode::Yes;
|
||||
}
|
||||
|
||||
if (public_identifier.starts_with("-//W3C//DTD XHTML 1.0 Frameset//", CaseSensitivity::CaseInsensitive))
|
||||
if (public_identifier.starts_with("-//W3C//DTD XHTML 1.0 Frameset//"sv, CaseSensitivity::CaseInsensitive))
|
||||
return DOM::QuirksMode::Limited;
|
||||
|
||||
if (public_identifier.starts_with("-//W3C//DTD XHTML 1.0 Transitional//", CaseSensitivity::CaseInsensitive))
|
||||
if (public_identifier.starts_with("-//W3C//DTD XHTML 1.0 Transitional//"sv, CaseSensitivity::CaseInsensitive))
|
||||
return DOM::QuirksMode::Limited;
|
||||
|
||||
if (!doctype_token.doctype_data().missing_system_identifier) {
|
||||
if (public_identifier.starts_with("-//W3C//DTD HTML 4.01 Frameset//", CaseSensitivity::CaseInsensitive))
|
||||
if (public_identifier.starts_with("-//W3C//DTD HTML 4.01 Frameset//"sv, CaseSensitivity::CaseInsensitive))
|
||||
return DOM::QuirksMode::Limited;
|
||||
|
||||
if (public_identifier.starts_with("-//W3C//DTD HTML 4.01 Transitional//", CaseSensitivity::CaseInsensitive))
|
||||
if (public_identifier.starts_with("-//W3C//DTD HTML 4.01 Transitional//"sv, CaseSensitivity::CaseInsensitive))
|
||||
return DOM::QuirksMode::Limited;
|
||||
}
|
||||
|
||||
|
@ -1884,7 +1884,7 @@ void HTMLParser::handle_in_body(HTMLToken& token)
|
|||
(void)m_stack_of_open_elements.pop();
|
||||
token.acknowledge_self_closing_flag_if_set();
|
||||
auto type_attribute = token.attribute(HTML::AttributeNames::type);
|
||||
if (type_attribute.is_null() || !type_attribute.equals_ignoring_case("hidden")) {
|
||||
if (type_attribute.is_null() || !type_attribute.equals_ignoring_case("hidden"sv)) {
|
||||
m_frameset_ok = false;
|
||||
}
|
||||
return;
|
||||
|
@ -2620,7 +2620,7 @@ void HTMLParser::handle_in_table(HTMLToken& token)
|
|||
}
|
||||
if (token.is_start_tag() && token.tag_name() == HTML::TagNames::input) {
|
||||
auto type_attribute = token.attribute(HTML::AttributeNames::type);
|
||||
if (type_attribute.is_null() || !type_attribute.equals_ignoring_case("hidden")) {
|
||||
if (type_attribute.is_null() || !type_attribute.equals_ignoring_case("hidden"sv)) {
|
||||
goto AnythingElse;
|
||||
}
|
||||
|
||||
|
@ -3468,18 +3468,18 @@ String HTMLParser::serialize_html_fragment(DOM::Node const& node)
|
|||
for (auto& ch : string) {
|
||||
// 1. Replace any occurrence of the "&" character by the string "&".
|
||||
if (ch == '&')
|
||||
builder.append("&");
|
||||
builder.append("&"sv);
|
||||
// 2. Replace any occurrences of the U+00A0 NO-BREAK SPACE character by the string " ".
|
||||
else if (ch == '\xA0')
|
||||
builder.append(" ");
|
||||
builder.append(" "sv);
|
||||
// 3. If the algorithm was invoked in the attribute mode, replace any occurrences of the """ character by the string """.
|
||||
else if (ch == '"' && attribute_mode == AttributeMode::Yes)
|
||||
builder.append(""");
|
||||
builder.append("""sv);
|
||||
// 4. If the algorithm was not invoked in the attribute mode, replace any occurrences of the "<" character by the string "<", and any occurrences of the ">" character by the string ">".
|
||||
else if (ch == '<' && attribute_mode == AttributeMode::No)
|
||||
builder.append("<");
|
||||
builder.append("<"sv);
|
||||
else if (ch == '>' && attribute_mode == AttributeMode::No)
|
||||
builder.append(">");
|
||||
builder.append(">"sv);
|
||||
else
|
||||
builder.append(ch);
|
||||
}
|
||||
|
@ -3544,7 +3544,7 @@ String HTMLParser::serialize_html_fragment(DOM::Node const& node)
|
|||
// FIXME: -> If the attribute is in some other namespace:
|
||||
// The attribute's serialized name is the attribute's qualified name.
|
||||
|
||||
builder.append("=\"");
|
||||
builder.append("=\""sv);
|
||||
builder.append(escape_string(value, AttributeMode::Yes));
|
||||
builder.append('"');
|
||||
});
|
||||
|
@ -3559,7 +3559,7 @@ String HTMLParser::serialize_html_fragment(DOM::Node const& node)
|
|||
// 7. Append the value of running the HTML fragment serialization algorithm on the current node element (thus recursing into this algorithm for that element),
|
||||
// followed by a U+003C LESS-THAN SIGN character (<), a U+002F SOLIDUS character (/), tagname again, and finally a U+003E GREATER-THAN SIGN character (>).
|
||||
builder.append(serialize_html_fragment(element));
|
||||
builder.append("</");
|
||||
builder.append("</"sv);
|
||||
builder.append(tag_name);
|
||||
builder.append('>');
|
||||
|
||||
|
@ -3594,9 +3594,9 @@ String HTMLParser::serialize_html_fragment(DOM::Node const& node)
|
|||
|
||||
// 1. Append the literal string "<!--" (U+003C LESS-THAN SIGN, U+0021 EXCLAMATION MARK, U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS),
|
||||
// followed by the value of current node's data IDL attribute, followed by the literal string "-->" (U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS, U+003E GREATER-THAN SIGN).
|
||||
builder.append("<!--");
|
||||
builder.append("<!--"sv);
|
||||
builder.append(comment_node.data());
|
||||
builder.append("-->");
|
||||
builder.append("-->"sv);
|
||||
return IterationDecision::Continue;
|
||||
}
|
||||
|
||||
|
@ -3606,7 +3606,7 @@ String HTMLParser::serialize_html_fragment(DOM::Node const& node)
|
|||
|
||||
// 1. Append the literal string "<?" (U+003C LESS-THAN SIGN, U+003F QUESTION MARK), followed by the value of current node's target IDL attribute,
|
||||
// followed by a single U+0020 SPACE character, followed by the value of current node's data IDL attribute, followed by a single U+003E GREATER-THAN SIGN character (>).
|
||||
builder.append("<?");
|
||||
builder.append("<?"sv);
|
||||
builder.append(processing_instruction_node.target());
|
||||
builder.append(' ');
|
||||
builder.append(processing_instruction_node.data());
|
||||
|
@ -3621,7 +3621,7 @@ String HTMLParser::serialize_html_fragment(DOM::Node const& node)
|
|||
// 1. Append the literal string "<!DOCTYPE" (U+003C LESS-THAN SIGN, U+0021 EXCLAMATION MARK, U+0044 LATIN CAPITAL LETTER D, U+004F LATIN CAPITAL LETTER O,
|
||||
// U+0043 LATIN CAPITAL LETTER C, U+0054 LATIN CAPITAL LETTER T, U+0059 LATIN CAPITAL LETTER Y, U+0050 LATIN CAPITAL LETTER P, U+0045 LATIN CAPITAL LETTER E),
|
||||
// followed by a space (U+0020 SPACE), followed by the value of current node's name IDL attribute, followed by the literal string ">" (U+003E GREATER-THAN SIGN).
|
||||
builder.append("<!DOCTYPE ");
|
||||
builder.append("<!DOCTYPE "sv);
|
||||
builder.append(document_type_node.name());
|
||||
builder.append('>');
|
||||
return IterationDecision::Continue;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue