mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:07:35 +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
762 changed files with 8315 additions and 8316 deletions
File diff suppressed because it is too large
Load diff
|
@ -42,7 +42,7 @@ Optional<StringView> extract_character_encoding_from_meta_element(String const&
|
|||
GenericLexer lexer(lowercase_string);
|
||||
|
||||
for (;;) {
|
||||
auto charset_index = lexer.remaining().find("charset");
|
||||
auto charset_index = lexer.remaining().find("charset"sv);
|
||||
if (!charset_index.has_value())
|
||||
return {};
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -14,54 +14,54 @@ String HTMLToken::to_string() const
|
|||
|
||||
switch (type()) {
|
||||
case HTMLToken::Type::DOCTYPE:
|
||||
builder.append("DOCTYPE");
|
||||
builder.append(" { name: '");
|
||||
builder.append("DOCTYPE"sv);
|
||||
builder.append(" { name: '"sv);
|
||||
builder.append(doctype_data().name);
|
||||
builder.append("' }");
|
||||
builder.append("' }"sv);
|
||||
break;
|
||||
case HTMLToken::Type::StartTag:
|
||||
builder.append("StartTag");
|
||||
builder.append("StartTag"sv);
|
||||
break;
|
||||
case HTMLToken::Type::EndTag:
|
||||
builder.append("EndTag");
|
||||
builder.append("EndTag"sv);
|
||||
break;
|
||||
case HTMLToken::Type::Comment:
|
||||
builder.append("Comment");
|
||||
builder.append("Comment"sv);
|
||||
break;
|
||||
case HTMLToken::Type::Character:
|
||||
builder.append("Character");
|
||||
builder.append("Character"sv);
|
||||
break;
|
||||
case HTMLToken::Type::EndOfFile:
|
||||
builder.append("EndOfFile");
|
||||
builder.append("EndOfFile"sv);
|
||||
break;
|
||||
case HTMLToken::Type::Invalid:
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
if (type() == HTMLToken::Type::StartTag || type() == HTMLToken::Type::EndTag) {
|
||||
builder.append(" { name: '");
|
||||
builder.append(" { name: '"sv);
|
||||
builder.append(tag_name());
|
||||
builder.append("', { ");
|
||||
builder.append("', { "sv);
|
||||
for_each_attribute([&](auto& attribute) {
|
||||
builder.append(attribute.local_name);
|
||||
builder.append("=\"");
|
||||
builder.append("=\""sv);
|
||||
builder.append(attribute.value);
|
||||
builder.append("\" ");
|
||||
builder.append("\" "sv);
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
builder.append("} }");
|
||||
builder.append("} }"sv);
|
||||
}
|
||||
|
||||
if (is_comment()) {
|
||||
builder.append(" { data: '");
|
||||
builder.append(" { data: '"sv);
|
||||
builder.append(comment());
|
||||
builder.append("' }");
|
||||
builder.append("' }"sv);
|
||||
}
|
||||
|
||||
if (is_character()) {
|
||||
builder.append(" { data: '");
|
||||
builder.append(" { data: '"sv);
|
||||
builder.append_code_point(code_point());
|
||||
builder.append("' }");
|
||||
builder.append("' }"sv);
|
||||
}
|
||||
|
||||
if (type() == HTMLToken::Type::Character) {
|
||||
|
|
|
@ -407,22 +407,22 @@ _StartOfFunction:
|
|||
BEGIN_STATE(MarkupDeclarationOpen)
|
||||
{
|
||||
DONT_CONSUME_NEXT_INPUT_CHARACTER;
|
||||
if (consume_next_if_match("--")) {
|
||||
if (consume_next_if_match("--"sv)) {
|
||||
create_new_token(HTMLToken::Type::Comment);
|
||||
m_current_token.set_start_position({}, nth_last_position(3));
|
||||
SWITCH_TO(CommentStart);
|
||||
}
|
||||
if (consume_next_if_match("DOCTYPE", CaseSensitivity::CaseInsensitive)) {
|
||||
if (consume_next_if_match("DOCTYPE"sv, CaseSensitivity::CaseInsensitive)) {
|
||||
SWITCH_TO(DOCTYPE);
|
||||
}
|
||||
if (consume_next_if_match("[CDATA[")) {
|
||||
if (consume_next_if_match("[CDATA["sv)) {
|
||||
// We keep the parser optional so that syntax highlighting can be lexer-only.
|
||||
// The parser registers itself with the lexer it creates.
|
||||
if (m_parser != nullptr && m_parser->adjusted_current_node().namespace_() != Namespace::HTML) {
|
||||
SWITCH_TO(CDATASection);
|
||||
} else {
|
||||
create_new_token(HTMLToken::Type::Comment);
|
||||
m_current_builder.append("[CDATA[");
|
||||
m_current_builder.append("[CDATA["sv);
|
||||
SWITCH_TO_WITH_UNCLEAN_BUILDER(BogusComment);
|
||||
}
|
||||
}
|
||||
|
@ -595,10 +595,10 @@ _StartOfFunction:
|
|||
}
|
||||
ANYTHING_ELSE
|
||||
{
|
||||
if (to_ascii_uppercase(current_input_character.value()) == 'P' && consume_next_if_match("UBLIC", CaseSensitivity::CaseInsensitive)) {
|
||||
if (to_ascii_uppercase(current_input_character.value()) == 'P' && consume_next_if_match("UBLIC"sv, CaseSensitivity::CaseInsensitive)) {
|
||||
SWITCH_TO(AfterDOCTYPEPublicKeyword);
|
||||
}
|
||||
if (to_ascii_uppercase(current_input_character.value()) == 'S' && consume_next_if_match("YSTEM", CaseSensitivity::CaseInsensitive)) {
|
||||
if (to_ascii_uppercase(current_input_character.value()) == 'S' && consume_next_if_match("YSTEM"sv, CaseSensitivity::CaseInsensitive)) {
|
||||
SWITCH_TO(AfterDOCTYPESystemKeyword);
|
||||
}
|
||||
log_parse_error();
|
||||
|
@ -1487,7 +1487,7 @@ _StartOfFunction:
|
|||
}
|
||||
ANYTHING_ELSE
|
||||
{
|
||||
m_current_builder.append("--");
|
||||
m_current_builder.append("--"sv);
|
||||
RECONSUME_IN(Comment);
|
||||
}
|
||||
}
|
||||
|
@ -1498,7 +1498,7 @@ _StartOfFunction:
|
|||
{
|
||||
ON('-')
|
||||
{
|
||||
m_current_builder.append("--!");
|
||||
m_current_builder.append("--!"sv);
|
||||
SWITCH_TO_WITH_UNCLEAN_BUILDER(CommentEndDash);
|
||||
}
|
||||
ON('>')
|
||||
|
@ -1515,7 +1515,7 @@ _StartOfFunction:
|
|||
}
|
||||
ANYTHING_ELSE
|
||||
{
|
||||
m_current_builder.append("--!");
|
||||
m_current_builder.append("--!"sv);
|
||||
RECONSUME_IN(Comment);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue