1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 07:37: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:
sin-ack 2022-07-11 17:32:29 +00:00 committed by Andreas Kling
parent e5f09ea170
commit 3f3f45580a
762 changed files with 8315 additions and 8316 deletions

View file

@ -56,7 +56,7 @@ JS_DEFINE_NATIVE_FUNCTION(CSSNamespace::supports)
}
// Otherwise, if property is a custom property name string, return true.
// FIXME: This check is not enough to make sure this is a valid custom property name, but it's close enough.
else if (property_name.starts_with("--") && property_name.length() >= 3) {
else if (property_name.starts_with("--"sv) && property_name.length() >= 3) {
return JS::Value(true);
}

View file

@ -183,7 +183,7 @@ static JS::ThrowCompletionOr<HTML::Window*> impl_from(JS::VM& vm, JS::GlobalObje
auto* this_object = MUST(this_value.to_object(global_object));
if (StringView("WindowObject") != this_object->class_name())
if ("WindowObject"sv != this_object->class_name())
return vm.throw_completion<JS::TypeError>(global_object, JS::ErrorType::NotAnObjectOfType, "WindowObject");
return &static_cast<WindowObject*>(this_object)->impl();
}

View file

@ -25,7 +25,7 @@ public:
virtual ~CSSFontFaceRule() override = default;
virtual StringView class_name() const override { return "CSSFontFaceRule"; }
virtual StringView class_name() const override { return "CSSFontFaceRule"sv; }
virtual Type type() const override { return Type::FontFace; }
FontFace const& font_face() const { return m_font_face; }

View file

@ -40,7 +40,7 @@ public:
NonnullRefPtr<CSSStyleSheet> style_sheet_for_bindings() { return *m_style_sheet; }
void set_style_sheet(RefPtr<CSSStyleSheet> const& style_sheet) { m_style_sheet = style_sheet; }
virtual StringView class_name() const override { return "CSSImportRule"; };
virtual StringView class_name() const override { return "CSSImportRule"sv; };
virtual Type type() const override { return Type::Import; };
private:

View file

@ -31,21 +31,21 @@ String CSSMediaRule::serialized() const
StringBuilder builder;
// 1. The string "@media", followed by a single SPACE (U+0020).
builder.append("@media ");
builder.append("@media "sv);
// 2. The result of performing serialize a media query list on rules media query list.
builder.append(condition_text());
// 3. A single SPACE (U+0020), followed by the string "{", i.e., LEFT CURLY BRACKET (U+007B), followed by a newline.
builder.append(" {\n");
builder.append(" {\n"sv);
// 4. The result of performing serialize a CSS rule on each rule in the rules cssRules list, separated by a newline and indented by two spaces.
for (size_t i = 0; i < css_rules().length(); i++) {
auto rule = css_rules().item(i);
if (i != 0)
builder.append("\n");
builder.append(" ");
builder.append("\n"sv);
builder.append(" "sv);
builder.append(rule->css_text());
}
// 5. A newline, followed by the string "}", i.e., RIGHT CURLY BRACKET (U+007D)
builder.append("\n}");
builder.append("\n}"sv);
return builder.to_string();
}

View file

@ -27,7 +27,7 @@ public:
virtual ~CSSMediaRule() = default;
virtual StringView class_name() const override { return "CSSMediaRule"; };
virtual StringView class_name() const override { return "CSSMediaRule"sv; };
virtual Type type() const override { return Type::Media; };
virtual String condition_text() const override;

View file

@ -38,7 +38,7 @@ public:
virtual Optional<StyleProperty> property(PropertyID) const = 0;
virtual DOM::ExceptionOr<void> set_property(PropertyID, StringView css_text, StringView priority = "") = 0;
virtual DOM::ExceptionOr<void> set_property(PropertyID, StringView css_text, StringView priority = ""sv) = 0;
virtual DOM::ExceptionOr<String> remove_property(PropertyID) = 0;
DOM::ExceptionOr<void> set_property(StringView property_name, StringView css_text, StringView priority);

View file

@ -32,7 +32,7 @@ public:
NonnullRefPtrVector<Selector> const& selectors() const { return m_selectors; }
CSSStyleDeclaration const& declaration() const { return m_declaration; }
virtual StringView class_name() const override { return "CSSStyleRule"; };
virtual StringView class_name() const override { return "CSSStyleRule"sv; };
virtual Type type() const override { return Type::Style; };
String selector_text() const;

View file

@ -34,17 +34,17 @@ String CSSSupportsRule::serialized() const
StringBuilder builder;
builder.append("@supports ");
builder.append("@supports "sv);
builder.append(condition_text());
builder.append(" {\n");
builder.append(" {\n"sv);
for (size_t i = 0; i < css_rules().length(); i++) {
auto rule = css_rules().item(i);
if (i != 0)
builder.append("\n");
builder.append(" ");
builder.append("\n"sv);
builder.append(" "sv);
builder.append(rule->css_text());
}
builder.append("\n}");
builder.append("\n}"sv);
return builder.to_string();
}

View file

@ -30,7 +30,7 @@ public:
virtual ~CSSSupportsRule() = default;
virtual StringView class_name() const override { return "CSSSupportsRule"; };
virtual StringView class_name() const override { return "CSSSupportsRule"sv; };
virtual Type type() const override { return Type::Supports; };
String condition_text() const override;

View file

@ -284,14 +284,14 @@ String MediaCondition::to_string() const
builder.append(feature->to_string());
break;
case Type::Not:
builder.append("not ");
builder.append("not "sv);
builder.append(conditions.first().to_string());
break;
case Type::And:
builder.join(" and ", conditions);
builder.join(" and "sv, conditions);
break;
case Type::Or:
builder.join(" or ", conditions);
builder.join(" or "sv, conditions);
break;
case Type::GeneralEnclosed:
builder.append(general_enclosed->to_string());
@ -323,12 +323,12 @@ String MediaQuery::to_string() const
StringBuilder builder;
if (m_negated)
builder.append("not ");
builder.append("not "sv);
if (m_negated || m_media_type != MediaType::All || !m_media_condition) {
builder.append(CSS::to_string(m_media_type));
if (m_media_condition)
builder.append(" and ");
builder.append(" and "sv);
}
if (m_media_condition) {
@ -386,7 +386,7 @@ String serialize_a_media_query_list(NonnullRefPtrVector<MediaQuery> const& media
// 2. Serialize each media query in the list of media queries, in the same order as they
// appear in the media query list, and then serialize the list.
StringBuilder builder;
builder.join(", ", media_queries);
builder.join(", "sv, media_queries);
return builder.to_string();
}

View file

@ -24,11 +24,11 @@ String Declaration::to_string() const
StringBuilder builder;
serialize_an_identifier(builder, m_name);
builder.append(": ");
builder.join(" ", m_values);
builder.append(": "sv);
builder.join(' ', m_values);
if (m_important == Important::Yes)
builder.append(" !important");
builder.append(" !important"sv);
return builder.to_string();
}

View file

@ -409,9 +409,9 @@ Parser::ParseErrorOr<Selector::SimpleSelector> Parser::parse_attribute_simple_se
auto const& case_sensitivity_part = attribute_tokens.next_token();
if (case_sensitivity_part.is(Token::Type::Ident)) {
auto case_sensitivity = case_sensitivity_part.token().ident();
if (case_sensitivity.equals_ignoring_case("i")) {
if (case_sensitivity.equals_ignoring_case("i"sv)) {
simple_selector.attribute().case_type = Selector::SimpleSelector::Attribute::CaseType::CaseInsensitiveMatch;
} else if (case_sensitivity.equals_ignoring_case("s")) {
} else if (case_sensitivity.equals_ignoring_case("s"sv)) {
simple_selector.attribute().case_type = Selector::SimpleSelector::Attribute::CaseType::CaseSensitiveMatch;
} else {
dbgln_if(CSS_PARSER_DEBUG, "Expected a \"i\" or \"s\" attribute selector case sensitivity identifier, got: '{}'", case_sensitivity_part.to_debug_string());
@ -490,39 +490,39 @@ Parser::ParseErrorOr<Selector::SimpleSelector> Parser::parse_pseudo_simple_selec
};
};
if (pseudo_name.equals_ignoring_case("active")) {
if (pseudo_name.equals_ignoring_case("active"sv)) {
return make_pseudo_class_selector(Selector::SimpleSelector::PseudoClass::Type::Active);
} else if (pseudo_name.equals_ignoring_case("checked")) {
} else if (pseudo_name.equals_ignoring_case("checked"sv)) {
return make_pseudo_class_selector(Selector::SimpleSelector::PseudoClass::Type::Checked);
} else if (pseudo_name.equals_ignoring_case("disabled")) {
} else if (pseudo_name.equals_ignoring_case("disabled"sv)) {
return make_pseudo_class_selector(Selector::SimpleSelector::PseudoClass::Type::Disabled);
} else if (pseudo_name.equals_ignoring_case("empty")) {
} else if (pseudo_name.equals_ignoring_case("empty"sv)) {
return make_pseudo_class_selector(Selector::SimpleSelector::PseudoClass::Type::Empty);
} else if (pseudo_name.equals_ignoring_case("enabled")) {
} else if (pseudo_name.equals_ignoring_case("enabled"sv)) {
return make_pseudo_class_selector(Selector::SimpleSelector::PseudoClass::Type::Enabled);
} else if (pseudo_name.equals_ignoring_case("first-child")) {
} else if (pseudo_name.equals_ignoring_case("first-child"sv)) {
return make_pseudo_class_selector(Selector::SimpleSelector::PseudoClass::Type::FirstChild);
} else if (pseudo_name.equals_ignoring_case("first-of-type")) {
} else if (pseudo_name.equals_ignoring_case("first-of-type"sv)) {
return make_pseudo_class_selector(Selector::SimpleSelector::PseudoClass::Type::FirstOfType);
} else if (pseudo_name.equals_ignoring_case("focus")) {
} else if (pseudo_name.equals_ignoring_case("focus"sv)) {
return make_pseudo_class_selector(Selector::SimpleSelector::PseudoClass::Type::Focus);
} else if (pseudo_name.equals_ignoring_case("focus-within")) {
} else if (pseudo_name.equals_ignoring_case("focus-within"sv)) {
return make_pseudo_class_selector(Selector::SimpleSelector::PseudoClass::Type::FocusWithin);
} else if (pseudo_name.equals_ignoring_case("hover")) {
} else if (pseudo_name.equals_ignoring_case("hover"sv)) {
return make_pseudo_class_selector(Selector::SimpleSelector::PseudoClass::Type::Hover);
} else if (pseudo_name.equals_ignoring_case("last-child")) {
} else if (pseudo_name.equals_ignoring_case("last-child"sv)) {
return make_pseudo_class_selector(Selector::SimpleSelector::PseudoClass::Type::LastChild);
} else if (pseudo_name.equals_ignoring_case("last-of-type")) {
} else if (pseudo_name.equals_ignoring_case("last-of-type"sv)) {
return make_pseudo_class_selector(Selector::SimpleSelector::PseudoClass::Type::LastOfType);
} else if (pseudo_name.equals_ignoring_case("link")) {
} else if (pseudo_name.equals_ignoring_case("link"sv)) {
return make_pseudo_class_selector(Selector::SimpleSelector::PseudoClass::Type::Link);
} else if (pseudo_name.equals_ignoring_case("only-child")) {
} else if (pseudo_name.equals_ignoring_case("only-child"sv)) {
return make_pseudo_class_selector(Selector::SimpleSelector::PseudoClass::Type::OnlyChild);
} else if (pseudo_name.equals_ignoring_case("only-of-type")) {
} else if (pseudo_name.equals_ignoring_case("only-of-type"sv)) {
return make_pseudo_class_selector(Selector::SimpleSelector::PseudoClass::Type::OnlyOfType);
} else if (pseudo_name.equals_ignoring_case("root")) {
} else if (pseudo_name.equals_ignoring_case("root"sv)) {
return make_pseudo_class_selector(Selector::SimpleSelector::PseudoClass::Type::Root);
} else if (pseudo_name.equals_ignoring_case("visited")) {
} else if (pseudo_name.equals_ignoring_case("visited"sv)) {
return make_pseudo_class_selector(Selector::SimpleSelector::PseudoClass::Type::Visited);
}
@ -605,7 +605,7 @@ Parser::ParseErrorOr<Selector::SimpleSelector> Parser::parse_pseudo_simple_selec
: Selector::SimpleSelector::PseudoClass::Type::Where,
.argument_selector_list = move(argument_selector_list) }
};
} else if (pseudo_function.name().equals_ignoring_case("not")) {
} else if (pseudo_function.name().equals_ignoring_case("not"sv)) {
auto function_token_stream = TokenStream(pseudo_function.values());
auto not_selector = TRY(parse_a_selector_list(function_token_stream, SelectorType::Standalone));
@ -817,7 +817,7 @@ NonnullRefPtr<MediaQuery> Parser::parse_media_query(TokenStream<ComponentValue>&
return media_query;
// `[ and <media-condition-without-or> ]?`
if (auto maybe_and = tokens.next_token(); maybe_and.is(Token::Type::Ident) && maybe_and.token().ident().equals_ignoring_case("and")) {
if (auto maybe_and = tokens.next_token(); maybe_and.is(Token::Type::Ident) && maybe_and.token().ident().equals_ignoring_case("and"sv)) {
if (auto media_condition = parse_media_condition(tokens, MediaCondition::AllowOr::No)) {
tokens.skip_whitespace();
if (tokens.has_next_token())
@ -964,12 +964,12 @@ Optional<MediaFeature> Parser::parse_media_feature(TokenStream<ComponentValue>&
return MediaFeatureName { MediaFeatureName::Type::Normal, id.value() };
}
if (allow_min_max_prefix && (name.starts_with("min-", CaseSensitivity::CaseInsensitive) || name.starts_with("max-", CaseSensitivity::CaseInsensitive))) {
if (allow_min_max_prefix && (name.starts_with("min-"sv, CaseSensitivity::CaseInsensitive) || name.starts_with("max-"sv, CaseSensitivity::CaseInsensitive))) {
auto adjusted_name = name.substring_view(4);
if (auto id = media_feature_id_from_string(adjusted_name); id.has_value() && media_feature_type_is_range(id.value())) {
transaction.commit();
return MediaFeatureName {
name.starts_with("min-", CaseSensitivity::CaseInsensitive) ? MediaFeatureName::Type::Min : MediaFeatureName::Type::Max,
name.starts_with("min-"sv, CaseSensitivity::CaseInsensitive) ? MediaFeatureName::Type::Min : MediaFeatureName::Type::Max,
id.value()
};
}
@ -1345,7 +1345,7 @@ OwnPtr<Supports::Condition> Parser::parse_supports_condition(TokenStream<Compone
auto& peeked_token = tokens.peek_token();
// `not <supports-in-parens>`
if (peeked_token.is(Token::Type::Ident) && peeked_token.token().ident().equals_ignoring_case("not")) {
if (peeked_token.is(Token::Type::Ident) && peeked_token.token().ident().equals_ignoring_case("not"sv)) {
tokens.next_token();
tokens.skip_whitespace();
auto child = parse_supports_in_parens(tokens);
@ -1367,9 +1367,9 @@ OwnPtr<Supports::Condition> Parser::parse_supports_condition(TokenStream<Compone
if (!token.is(Token::Type::Ident))
return {};
auto ident = token.token().ident();
if (ident.equals_ignoring_case("and"))
if (ident.equals_ignoring_case("and"sv))
return Supports::Condition::Type::And;
if (ident.equals_ignoring_case("or"))
if (ident.equals_ignoring_case("or"sv))
return Supports::Condition::Type::Or;
return {};
};
@ -1957,7 +1957,7 @@ Optional<Declaration> Parser::consume_a_declaration(TokenStream<T>& tokens)
Optional<size_t> important_index;
for (size_t i = declaration_values.size() - 1; i > 0; i--) {
auto value = declaration_values[i];
if (value.is(Token::Type::Ident) && value.token().ident().equals_ignoring_case("important")) {
if (value.is(Token::Type::Ident) && value.token().ident().equals_ignoring_case("important"sv)) {
important_index = i;
break;
}
@ -2314,7 +2314,7 @@ Optional<AK::URL> Parser::parse_url_function(ComponentValue const& component_val
// FIXME: Handle data: urls (RFC2397)
auto convert_string_to_url = [&](StringView& url_string) -> Optional<AK::URL> {
if (url_string.starts_with("data:", CaseSensitivity::CaseInsensitive)) {
if (url_string.starts_with("data:"sv, CaseSensitivity::CaseInsensitive)) {
auto data_url = AK::URL(url_string);
switch (allowed_data_url_type) {
@ -2337,7 +2337,7 @@ Optional<AK::URL> Parser::parse_url_function(ComponentValue const& component_val
auto url_string = component_value.token().url();
return convert_string_to_url(url_string);
}
if (component_value.is_function() && component_value.function().name().equals_ignoring_case("url")) {
if (component_value.is_function() && component_value.function().name().equals_ignoring_case("url"sv)) {
auto& function_values = component_value.function().values();
// FIXME: Handle url-modifiers. https://www.w3.org/TR/css-values-4/#url-modifiers
for (size_t i = 0; i < function_values.size(); ++i) {
@ -2509,7 +2509,7 @@ Optional<StyleProperty> Parser::convert_to_style_property(Declaration const& dec
auto property_id = property_id_from_string(property_name);
if (property_id == PropertyID::Invalid) {
if (property_name.starts_with("--")) {
if (property_name.starts_with("--"sv)) {
property_id = PropertyID::Custom;
} else if (has_ignored_vendor_prefix(property_name)) {
return {};
@ -2542,11 +2542,11 @@ RefPtr<StyleValue> Parser::parse_builtin_value(ComponentValue const& component_v
{
if (component_value.is(Token::Type::Ident)) {
auto ident = component_value.token().ident();
if (ident.equals_ignoring_case("inherit"))
if (ident.equals_ignoring_case("inherit"sv))
return InheritStyleValue::the();
if (ident.equals_ignoring_case("initial"))
if (ident.equals_ignoring_case("initial"sv))
return InitialStyleValue::the();
if (ident.equals_ignoring_case("unset"))
if (ident.equals_ignoring_case("unset"sv))
return UnsetStyleValue::the();
// FIXME: Implement `revert` and `revert-layer` keywords, from Cascade4 and Cascade5 respectively
}
@ -2595,10 +2595,10 @@ RefPtr<StyleValue> Parser::parse_dynamic_value(ComponentValue const& component_v
if (component_value.is_function()) {
auto& function = component_value.function();
if (function.name().equals_ignoring_case("calc"))
if (function.name().equals_ignoring_case("calc"sv))
return parse_calculated_value(function.values());
if (function.name().equals_ignoring_case("var")) {
if (function.name().equals_ignoring_case("var"sv)) {
// Declarations using `var()` should already be parsed as an UnresolvedStyleValue before this point.
VERIFY_NOT_REACHED();
}
@ -2658,7 +2658,7 @@ Optional<Length> Parser::parse_length(ComponentValue const& component_value)
return dimension->length();
// FIXME: auto isn't a length!
if (component_value.is(Token::Type::Ident) && component_value.token().ident().equals_ignoring_case("auto"))
if (component_value.is(Token::Type::Ident) && component_value.token().ident().equals_ignoring_case("auto"sv))
return Length::make_auto();
return {};
@ -2751,7 +2751,7 @@ Optional<UnicodeRange> Parser::parse_unicode_range(TokenStream<ComponentValue>&
// All options start with 'u'/'U'.
auto& u = tokens.next_token();
if (!(u.is(Token::Type::Ident) && u.token().ident().equals_ignoring_case("u"))) {
if (!(u.is(Token::Type::Ident) && u.token().ident().equals_ignoring_case("u"sv))) {
dbgln_if(CSS_PARSER_DEBUG, "CSSParser: <urange> does not start with 'u'");
return {};
}
@ -2883,7 +2883,7 @@ Optional<UnicodeRange> Parser::parse_unicode_range(StringView text)
// 2. Interpret the consumed code points as a hexadecimal number,
// with the U+003F QUESTION MARK (?) code points replaced by U+0030 DIGIT ZERO (0) code points.
// This is the start value.
auto start_value_string = start_value_code_points.replace("?", "0", ReplaceMode::All);
auto start_value_string = start_value_code_points.replace("?"sv, "0"sv, ReplaceMode::All);
auto maybe_start_value = AK::StringUtils::convert_to_uint_from_hex<u32>(start_value_string);
if (!maybe_start_value.has_value()) {
dbgln_if(CSS_PARSER_DEBUG, "CSSParser: <urange> ?-converted start value did not parse as hex number.");
@ -2894,7 +2894,7 @@ Optional<UnicodeRange> Parser::parse_unicode_range(StringView text)
// 3. Interpret the consumed code points as a hexadecimal number again,
// with the U+003F QUESTION MARK (?) code points replaced by U+0046 LATIN CAPITAL LETTER F (F) code points.
// This is the end value.
auto end_value_string = start_value_code_points.replace("?", "F", ReplaceMode::All);
auto end_value_string = start_value_code_points.replace("?"sv, "F"sv, ReplaceMode::All);
auto maybe_end_value = AK::StringUtils::convert_to_uint_from_hex<u32>(end_value_string);
if (!maybe_end_value.has_value()) {
dbgln_if(CSS_PARSER_DEBUG, "CSSParser: <urange> ?-converted end value did not parse as hex number.");
@ -2965,7 +2965,7 @@ RefPtr<StyleValue> Parser::parse_dimension_value(ComponentValue const& component
if (component_value.is(Token::Type::Number) && !(m_context.in_quirks_mode() && property_has_quirk(m_context.current_property_id(), Quirk::UnitlessLength)))
return {};
if (component_value.is(Token::Type::Ident) && component_value.token().ident().equals_ignoring_case("auto"))
if (component_value.is(Token::Type::Ident) && component_value.token().ident().equals_ignoring_case("auto"sv))
return LengthStyleValue::create(Length::make_auto());
auto dimension = parse_dimension(component_value);
@ -4770,7 +4770,7 @@ RefPtr<StyleValue> Parser::parse_transform_value(Vector<ComponentValue> const& c
tokens.skip_whitespace();
auto& part = tokens.next_token();
if (part.is(Token::Type::Ident) && part.token().ident().equals_ignoring_case("none")) {
if (part.is(Token::Type::Ident) && part.token().ident().equals_ignoring_case("none"sv)) {
if (!transformations.is_empty())
return nullptr;
tokens.skip_whitespace();
@ -5306,11 +5306,11 @@ Optional<Selector::SimpleSelector::ANPlusBPattern> Parser::parse_a_n_plus_b_patt
// odd | even
if (first_value.is(Token::Type::Ident)) {
auto ident = first_value.token().ident();
if (ident.equals_ignoring_case("odd")) {
if (ident.equals_ignoring_case("odd"sv)) {
transaction.commit();
return Selector::SimpleSelector::ANPlusBPattern { 2, 1 };
}
if (ident.equals_ignoring_case("even")) {
if (ident.equals_ignoring_case("even"sv)) {
transaction.commit();
return Selector::SimpleSelector::ANPlusBPattern { 2, 0 };
}
@ -5781,9 +5781,9 @@ bool Parser::has_ignored_vendor_prefix(StringView string)
{
if (!string.starts_with('-'))
return false;
if (string.starts_with("--"))
if (string.starts_with("--"sv))
return false;
if (string.starts_with("-libweb-"))
if (string.starts_with("-libweb-"sv))
return false;
return true;
}
@ -5800,7 +5800,7 @@ RefPtr<StyleValue> Parser::parse_css_value(Badge<StyleComputer>, ParsingContext
if (tokens.is_empty() || property_id == CSS::PropertyID::Invalid || property_id == CSS::PropertyID::Custom)
return {};
Parser parser(context, "");
Parser parser(context, ""sv);
TokenStream<ComponentValue> token_stream { tokens };
auto result = parser.parse_css_value(property_id, token_stream);
if (result.is_error())

View file

@ -429,7 +429,7 @@ Token Tokenizer::consume_an_ident_like_token()
// If strings value is an ASCII case-insensitive match for "url", and the next input code
// point is U+0028 LEFT PARENTHESIS ((), consume it.
if (string.equals_ignoring_case("url") && is_left_paren(peek_code_point())) {
if (string.equals_ignoring_case("url"sv) && is_left_paren(peek_code_point())) {
(void)next_code_point();
// While the next two input code points are whitespace, consume the next input code point.

View file

@ -10,9 +10,9 @@ namespace Web::CSS {
PreferredColorScheme preferred_color_scheme_from_string(String const& value)
{
if (value.equals_ignoring_case("light"))
if (value.equals_ignoring_case("light"sv))
return PreferredColorScheme::Light;
if (value.equals_ignoring_case("dark"))
if (value.equals_ignoring_case("dark"sv))
return PreferredColorScheme::Dark;
return PreferredColorScheme::Auto;
}

View file

@ -151,22 +151,22 @@ String Selector::SimpleSelector::serialize() const
if (!attribute.value.is_null()) {
switch (attribute.match_type) {
case Selector::SimpleSelector::Attribute::MatchType::ExactValueMatch:
s.append("=");
s.append("="sv);
break;
case Selector::SimpleSelector::Attribute::MatchType::ContainsWord:
s.append("~=");
s.append("~="sv);
break;
case Selector::SimpleSelector::Attribute::MatchType::ContainsString:
s.append("*=");
s.append("*="sv);
break;
case Selector::SimpleSelector::Attribute::MatchType::StartsWithSegment:
s.append("|=");
s.append("|="sv);
break;
case Selector::SimpleSelector::Attribute::MatchType::StartsWithString:
s.append("^=");
s.append("^="sv);
break;
case Selector::SimpleSelector::Attribute::MatchType::EndsWithString:
s.append("$=");
s.append("$="sv);
break;
default:
break;
@ -180,10 +180,10 @@ String Selector::SimpleSelector::serialize() const
// (the line just above is an addition to CSS OM to match Selectors Level 4 last draft)
switch (attribute.case_type) {
case Selector::SimpleSelector::Attribute::CaseType::CaseInsensitiveMatch:
s.append(" i");
s.append(" i"sv);
break;
case Selector::SimpleSelector::Attribute::CaseType::CaseSensitiveMatch:
s.append(" s");
s.append(" s"sv);
break;
default:
break;
@ -304,16 +304,16 @@ String Selector::serialize() const
// so we have to check that one.
switch (compound_selectors()[i + 1].combinator) {
case Selector::Combinator::ImmediateChild:
s.append("> ");
s.append("> "sv);
break;
case Selector::Combinator::NextSibling:
s.append("+ ");
s.append("+ "sv);
break;
case Selector::Combinator::SubsequentSibling:
s.append("~ ");
s.append("~ "sv);
break;
case Selector::Combinator::Column:
s.append("|| ");
s.append("|| "sv);
break;
default:
break;
@ -322,7 +322,7 @@ String Selector::serialize() const
// 4. If this is the last part of the chain of the selector and there is a pseudo-element,
// append "::" followed by the name of the pseudo-element, to s.
if (compound_selector.simple_selectors.last().type == Selector::SimpleSelector::Type::PseudoElement) {
s.append("::");
s.append("::"sv);
s.append(pseudo_element_name(compound_selector.simple_selectors.last().pseudo_element()));
}
}
@ -336,21 +336,21 @@ String serialize_a_group_of_selectors(NonnullRefPtrVector<Selector> const& selec
{
// To serialize a group of selectors serialize each selector in the group of selectors and then serialize a comma-separated list of these serializations.
StringBuilder builder;
builder.join(", ", selectors);
builder.join(", "sv, selectors);
return builder.to_string();
}
Optional<Selector::PseudoElement> pseudo_element_from_string(StringView name)
{
if (name.equals_ignoring_case("after")) {
if (name.equals_ignoring_case("after"sv)) {
return Selector::PseudoElement::After;
} else if (name.equals_ignoring_case("before")) {
} else if (name.equals_ignoring_case("before"sv)) {
return Selector::PseudoElement::Before;
} else if (name.equals_ignoring_case("first-letter")) {
} else if (name.equals_ignoring_case("first-letter"sv)) {
return Selector::PseudoElement::FirstLetter;
} else if (name.equals_ignoring_case("first-line")) {
} else if (name.equals_ignoring_case("first-line"sv)) {
return Selector::PseudoElement::FirstLine;
} else if (name.equals_ignoring_case("marker")) {
} else if (name.equals_ignoring_case("marker"sv)) {
return Selector::PseudoElement::Marker;
}
return {};

View file

@ -61,7 +61,7 @@ public:
result.append("n");
// - A is -1: Append "-n" to result.
else if (step_size == -1)
result.append("-n");
result.append("-n"sv);
// - A is non-zero: Serialize A and append it to result, then append "n" to result.
else if (step_size != 0)
result.appendff("{}n", step_size);

View file

@ -112,7 +112,7 @@ void serialize_a_url(StringBuilder& builder, StringView url)
{
// To serialize a URL means to create a string represented by "url(",
// followed by the serialization of the URL as a string, followed by ")".
builder.append("url(");
builder.append("url("sv);
serialize_a_string(builder, url.to_string());
builder.append(')');
}

View file

@ -563,7 +563,7 @@ bool StyleComputer::expand_unresolved_values(DOM::Element& element, StringView p
if (!custom_property_name_token.is(Parser::Token::Type::Ident))
return false;
auto custom_property_name = custom_property_name_token.token().ident();
if (!custom_property_name.starts_with("--"))
if (!custom_property_name.starts_with("--"sv))
return false;
// Detect dependency cycles. https://www.w3.org/TR/css-variables-1/#cycles
@ -962,15 +962,15 @@ void StyleComputer::compute_font(StyleProperties& style, DOM::Element const* ele
}
}
int slope = Gfx::name_to_slope("Normal");
int slope = Gfx::name_to_slope("Normal"sv);
// FIXME: Implement oblique <angle>
if (font_style->is_identifier()) {
switch (static_cast<IdentifierStyleValue const&>(*font_style).id()) {
case CSS::ValueID::Italic:
slope = Gfx::name_to_slope("Italic");
slope = Gfx::name_to_slope("Italic"sv);
break;
case CSS::ValueID::Oblique:
slope = Gfx::name_to_slope("Oblique");
slope = Gfx::name_to_slope("Oblique"sv);
break;
case CSS::ValueID::Normal:
default:

View file

@ -272,7 +272,7 @@ String BackgroundStyleValue::to_string() const
StringBuilder builder;
for (size_t i = 0; i < m_layer_count; i++) {
if (i)
builder.append(", ");
builder.append(", "sv);
if (i == m_layer_count - 1)
builder.appendff("{} ", m_color->to_string());
builder.appendff("{} {} {} {} {} {} {}", get_layer_value_string(m_image, i), get_layer_value_string(m_position, i), get_layer_value_string(m_size, i), get_layer_value_string(m_repeat, i), get_layer_value_string(m_attachment, i), get_layer_value_string(m_origin, i), get_layer_value_string(m_clip, i));
@ -1530,7 +1530,7 @@ String ShadowStyleValue::to_string() const
StringBuilder builder;
builder.appendff("{} {} {} {} {}", m_color.to_string(), m_offset_x.to_string(), m_offset_y.to_string(), m_blur_radius.to_string(), m_spread_distance.to_string());
if (m_placement == ShadowPlacement::Inner)
builder.append(" inset");
builder.append(" inset"sv);
return builder.to_string();
}
@ -1582,7 +1582,7 @@ String TransformationStyleValue::to_string() const
StringBuilder builder;
builder.append(CSS::to_string(m_transform_function));
builder.append('(');
builder.join(", ", m_values);
builder.join(", "sv, m_values);
builder.append(')');
return builder.to_string();

View file

@ -101,9 +101,9 @@ String Supports::Condition::to_string() const
case Type::Not:
return String::formatted("not {}", children.first().to_string());
case Type::And:
return String::join(" and ", children);
return String::join(" and "sv, children);
case Type::Or:
return String::join(" or ", children);
return String::join(" or "sv, children);
}
VERIFY_NOT_REACHED();
}

View file

@ -131,17 +131,17 @@ void parse_attributes(ParsedCookie& parsed_cookie, StringView unparsed_attribute
void process_attribute(ParsedCookie& parsed_cookie, StringView attribute_name, StringView attribute_value)
{
if (attribute_name.equals_ignoring_case("Expires")) {
if (attribute_name.equals_ignoring_case("Expires"sv)) {
on_expires_attribute(parsed_cookie, attribute_value);
} else if (attribute_name.equals_ignoring_case("Max-Age")) {
} else if (attribute_name.equals_ignoring_case("Max-Age"sv)) {
on_max_age_attribute(parsed_cookie, attribute_value);
} else if (attribute_name.equals_ignoring_case("Domain")) {
} else if (attribute_name.equals_ignoring_case("Domain"sv)) {
on_domain_attribute(parsed_cookie, attribute_value);
} else if (attribute_name.equals_ignoring_case("Path")) {
} else if (attribute_name.equals_ignoring_case("Path"sv)) {
on_path_attribute(parsed_cookie, attribute_value);
} else if (attribute_name.equals_ignoring_case("Secure")) {
} else if (attribute_name.equals_ignoring_case("Secure"sv)) {
on_secure_attribute(parsed_cookie);
} else if (attribute_name.equals_ignoring_case("HttpOnly")) {
} else if (attribute_name.equals_ignoring_case("HttpOnly"sv)) {
on_http_only_attribute(parsed_cookie);
}
}

View file

@ -50,7 +50,7 @@ public:
HTML
};
static NonnullRefPtr<Document> create(const AK::URL& url = "about:blank")
static NonnullRefPtr<Document> create(const AK::URL& url = "about:blank"sv)
{
return adopt_ref(*new Document(url));
}
@ -190,7 +190,7 @@ public:
JS::Realm& realm();
JS::Interpreter& interpreter();
JS::Value run_javascript(StringView source, StringView filename = "(unknown)");
JS::Value run_javascript(StringView source, StringView filename = "(unknown)"sv);
ExceptionOr<NonnullRefPtr<Element>> create_element(String const& tag_name);
ExceptionOr<NonnullRefPtr<Element>> create_element_ns(String const& namespace_, String const& qualified_name);

View file

@ -685,10 +685,10 @@ void Element::serialize_pseudo_elements_as_json(JsonArraySerializer<StringBuilde
if (!pseudo_element_node)
continue;
auto object = MUST(children_array.add_object());
MUST(object.add("name", String::formatted("::{}", CSS::pseudo_element_name(static_cast<CSS::Selector::PseudoElement>(i)))));
MUST(object.add("type", "pseudo-element"));
MUST(object.add("parent-id", id()));
MUST(object.add("pseudo-element", i));
MUST(object.add("name"sv, String::formatted("::{}", CSS::pseudo_element_name(static_cast<CSS::Selector::PseudoElement>(i)))));
MUST(object.add("type"sv, "pseudo-element"));
MUST(object.add("parent-id"sv, id()));
MUST(object.add("pseudo-element"sv, i));
MUST(object.finish());
}
}

View file

@ -187,13 +187,13 @@ void EventDispatcher::invoke(Event::PathEntry& struct_, Event& event, Event::Pha
// 2. If events type attribute value is a match for any of the strings in the first column in the following table,
// set events type attribute value to the string in the second column on the same row as the matching string, and return otherwise.
if (event.type() == "animationend")
event.set_type("webkitAnimationEnd");
event.set_type("webkitAnimationEnd"sv);
else if (event.type() == "animationiteration")
event.set_type("webkitAnimationIteration");
event.set_type("webkitAnimationIteration"sv);
else if (event.type() == "animationstart")
event.set_type("webkitAnimationStart");
event.set_type("webkitAnimationStart"sv);
else if (event.type() == "transitionend")
event.set_type("webkitTransitionEnd");
event.set_type("webkitTransitionEnd"sv);
else
return;

View file

@ -987,16 +987,16 @@ bool Node::is_uninteresting_whitespace_node() const
void Node::serialize_tree_as_json(JsonObjectSerializer<StringBuilder>& object) const
{
MUST(object.add("name", node_name().view()));
MUST(object.add("id", id()));
MUST(object.add("name"sv, node_name().view()));
MUST(object.add("id"sv, id()));
if (is_document()) {
MUST(object.add("type", "document"));
MUST(object.add("type"sv, "document"));
} else if (is_element()) {
MUST(object.add("type", "element"));
MUST(object.add("type"sv, "element"));
auto const* element = static_cast<DOM::Element const*>(this);
if (element->has_attributes()) {
auto attributes = MUST(object.add_object("attributes"));
auto attributes = MUST(object.add_object("attributes"sv));
element->for_each_attribute([&attributes](auto& name, auto& value) {
MUST(attributes.add(name, value));
});
@ -1006,7 +1006,7 @@ void Node::serialize_tree_as_json(JsonObjectSerializer<StringBuilder>& object) c
if (element->is_browsing_context_container()) {
auto const* container = static_cast<HTML::BrowsingContextContainer const*>(element);
if (auto const* content_document = container->content_document()) {
auto children = MUST(object.add_array("children"));
auto children = MUST(object.add_array("children"sv));
JsonObjectSerializer<StringBuilder> content_document_object = MUST(children.add_object());
content_document->serialize_tree_as_json(content_document_object);
MUST(content_document_object.finish());
@ -1014,10 +1014,10 @@ void Node::serialize_tree_as_json(JsonObjectSerializer<StringBuilder>& object) c
}
}
} else if (is_text()) {
MUST(object.add("type", "text"));
MUST(object.add("type"sv, "text"));
auto text_node = static_cast<DOM::Text const*>(this);
MUST(object.add("text", text_node->data()));
MUST(object.add("text"sv, text_node->data()));
} else if (is_comment()) {
MUST(object.add("type"sv, "comment"sv));
MUST(object.add("data"sv, static_cast<DOM::Comment const&>(*this).data()));
@ -1026,7 +1026,7 @@ void Node::serialize_tree_as_json(JsonObjectSerializer<StringBuilder>& object) c
MUST((object.add("visible"sv, !!layout_node())));
if (has_child_nodes()) {
auto children = MUST(object.add_array("children"));
auto children = MUST(object.add_array("children"sv));
for_each_child([&children](DOM::Node& child) {
if (child.is_uninteresting_whitespace_node())
return;

View file

@ -35,7 +35,7 @@ namespace Web {
static void indent(StringBuilder& builder, int levels)
{
for (int i = 0; i < levels; i++)
builder.append(" ");
builder.append(" "sv);
}
void dump_tree(DOM::Node const& node)
@ -49,13 +49,13 @@ void dump_tree(StringBuilder& builder, DOM::Node const& node)
{
static int indent = 0;
for (int i = 0; i < indent; ++i)
builder.append(" ");
builder.append(" "sv);
if (is<DOM::Element>(node)) {
builder.appendff("<{}", verify_cast<DOM::Element>(node).local_name());
verify_cast<DOM::Element>(node).for_each_attribute([&](auto& name, auto& value) {
builder.appendff(" {}={}", name, value);
});
builder.append(">\n");
builder.append(">\n"sv);
} else if (is<DOM::Text>(node)) {
builder.appendff("\"{}\"\n", verify_cast<DOM::Text>(node).data());
} else {
@ -89,7 +89,7 @@ void dump_tree(StringBuilder& builder, Layout::Node const& layout_node, bool sho
{
static size_t indent = 0;
for (size_t i = 0; i < indent; ++i)
builder.append(" ");
builder.append(" "sv);
FlyString tag_name;
if (layout_node.is_anonymous())
@ -115,28 +115,28 @@ void dump_tree(StringBuilder& builder, Layout::Node const& layout_node, bool sho
identifier = builder.to_string();
}
char const* nonbox_color_on = "";
char const* box_color_on = "";
char const* svg_box_color_on = "";
char const* positioned_color_on = "";
char const* floating_color_on = "";
char const* inline_block_color_on = "";
char const* line_box_color_on = "";
char const* fragment_color_on = "";
char const* flex_color_on = "";
char const* color_off = "";
StringView nonbox_color_on = ""sv;
StringView box_color_on = ""sv;
StringView svg_box_color_on = ""sv;
StringView positioned_color_on = ""sv;
StringView floating_color_on = ""sv;
StringView inline_block_color_on = ""sv;
StringView line_box_color_on = ""sv;
StringView fragment_color_on = ""sv;
StringView flex_color_on = ""sv;
StringView color_off = ""sv;
if (interactive) {
nonbox_color_on = "\033[33m";
box_color_on = "\033[34m";
svg_box_color_on = "\033[31m";
positioned_color_on = "\033[31;1m";
floating_color_on = "\033[32;1m";
inline_block_color_on = "\033[36;1m";
line_box_color_on = "\033[34;1m";
fragment_color_on = "\033[35;1m";
flex_color_on = "\033[34;1m";
color_off = "\033[0m";
nonbox_color_on = "\033[33m"sv;
box_color_on = "\033[34m"sv;
svg_box_color_on = "\033[31m"sv;
positioned_color_on = "\033[31;1m"sv;
floating_color_on = "\033[32;1m"sv;
inline_block_color_on = "\033[36;1m"sv;
line_box_color_on = "\033[34;1m"sv;
fragment_color_on = "\033[35;1m"sv;
flex_color_on = "\033[34;1m"sv;
color_off = "\033[0m"sv;
}
if (!is<Layout::Box>(layout_node)) {
@ -150,7 +150,7 @@ void dump_tree(StringBuilder& builder, Layout::Node const& layout_node, bool sho
color_off);
if (interactive)
builder.appendff(" @{:p}", &layout_node);
builder.append("\n");
builder.append("\n"sv);
} else {
auto& box = verify_cast<Layout::Box>(layout_node);
StringView color_on = is<Layout::SVGBox>(box) ? svg_box_color_on : box_color_on;
@ -226,7 +226,7 @@ void dump_tree(StringBuilder& builder, Layout::Node const& layout_node, bool sho
builder.appendff(" children: {}", box.children_are_inline() ? "inline" : "not-inline");
builder.append("\n");
builder.append("\n"sv);
}
if (is<Layout::BlockContainer>(layout_node) && static_cast<Layout::BlockContainer const&>(layout_node).children_are_inline()) {
@ -234,7 +234,7 @@ void dump_tree(StringBuilder& builder, Layout::Node const& layout_node, bool sho
for (size_t line_box_index = 0; block.paint_box() && line_box_index < block.paint_box()->line_boxes().size(); ++line_box_index) {
auto& line_box = block.paint_box()->line_boxes()[line_box_index];
for (size_t i = 0; i < indent; ++i)
builder.append(" ");
builder.append(" "sv);
builder.appendff(" {}line {}{} width: {}, height: {}, bottom: {}, baseline: {}\n",
line_box_color_on,
line_box_index,
@ -246,7 +246,7 @@ void dump_tree(StringBuilder& builder, Layout::Node const& layout_node, bool sho
for (size_t fragment_index = 0; fragment_index < line_box.fragments().size(); ++fragment_index) {
auto& fragment = line_box.fragments()[fragment_index];
for (size_t i = 0; i < indent; ++i)
builder.append(" ");
builder.append(" "sv);
builder.appendff(" {}frag {}{} from {} ",
fragment_color_on,
fragment_index,
@ -260,7 +260,7 @@ void dump_tree(StringBuilder& builder, Layout::Node const& layout_node, bool sho
fragment.absolute_rect().to_string());
if (is<Layout::TextNode>(fragment.layout_node())) {
for (size_t i = 0; i < indent; ++i)
builder.append(" ");
builder.append(" "sv);
auto& layout_text = static_cast<Layout::TextNode const&>(fragment.layout_node());
auto fragment_text = layout_text.text_for_rendering().substring(fragment.start(), fragment.length());
builder.appendff(" \"{}\"\n", fragment_text);
@ -282,7 +282,7 @@ void dump_tree(StringBuilder& builder, Layout::Node const& layout_node, bool sho
for (auto& property : properties) {
for (size_t i = 0; i < indent; ++i)
builder.append(" ");
builder.append(" "sv);
builder.appendff(" ({}: {})\n", property.name, property.value);
}
}
@ -303,10 +303,10 @@ void dump_selector(CSS::Selector const& selector)
void dump_selector(StringBuilder& builder, CSS::Selector const& selector)
{
builder.append(" CSS::Selector:\n");
builder.append(" CSS::Selector:\n"sv);
for (auto& relative_selector : selector.compound_selectors()) {
builder.append(" ");
builder.append(" "sv);
char const* relation_description = "";
switch (relative_selector.combinator) {
@ -455,22 +455,22 @@ void dump_selector(StringBuilder& builder, CSS::Selector const& selector)
} else if (pseudo_class.type == CSS::Selector::SimpleSelector::PseudoClass::Type::Not
|| pseudo_class.type == CSS::Selector::SimpleSelector::PseudoClass::Type::Is
|| pseudo_class.type == CSS::Selector::SimpleSelector::PseudoClass::Type::Where) {
builder.append("([");
builder.append("(["sv);
for (auto& selector : pseudo_class.argument_selector_list)
dump_selector(builder, selector);
builder.append("])");
builder.append("])"sv);
} else if ((pseudo_class.type == CSS::Selector::SimpleSelector::PseudoClass::Type::NthChild)
|| (pseudo_class.type == CSS::Selector::SimpleSelector::PseudoClass::Type::NthLastChild)
|| (pseudo_class.type == CSS::Selector::SimpleSelector::PseudoClass::Type::NthOfType)
|| (pseudo_class.type == CSS::Selector::SimpleSelector::PseudoClass::Type::NthLastOfType)) {
builder.appendff("(step={}, offset={}", pseudo_class.nth_child_pattern.step_size, pseudo_class.nth_child_pattern.offset);
if (!pseudo_class.argument_selector_list.is_empty()) {
builder.append(", selectors=[");
builder.append(", selectors=["sv);
for (auto const& child_selector : pseudo_class.argument_selector_list)
dump_selector(builder, child_selector);
builder.append("]");
builder.append("]"sv);
}
builder.append(")");
builder.append(")"sv);
}
}
@ -529,9 +529,9 @@ void dump_selector(StringBuilder& builder, CSS::Selector const& selector)
}
if (i != relative_selector.simple_selectors.size() - 1)
builder.append(", ");
builder.append(", "sv);
}
builder.append("\n");
builder.append("\n"sv);
}
}
@ -573,14 +573,14 @@ void dump_font_face_rule(StringBuilder& builder, CSS::CSSFontFaceRule const& rul
builder.appendff("font-family: {}\n", font_face.font_family());
indent(builder, indent_levels + 1);
builder.append("sources:\n");
builder.append("sources:\n"sv);
for (auto const& source : font_face.sources()) {
indent(builder, indent_levels + 2);
builder.appendff("url={}, format={}\n", source.url, source.format.value_or("???"));
}
indent(builder, indent_levels + 1);
builder.append("unicode-ranges:\n");
builder.append("unicode-ranges:\n"sv);
for (auto const& unicode_range : font_face.unicode_ranges()) {
indent(builder, indent_levels + 2);
builder.appendff("{}\n", unicode_range.to_string());
@ -619,20 +619,20 @@ void dump_style_rule(StringBuilder& builder, CSS::CSSStyleRule const& rule, int
dump_selector(builder, selector);
}
indent(builder, indent_levels);
builder.append(" Declarations:\n");
builder.append(" Declarations:\n"sv);
auto& style_declaration = verify_cast<CSS::PropertyOwningCSSStyleDeclaration>(rule.declaration());
for (auto& property : style_declaration.properties()) {
indent(builder, indent_levels);
builder.appendff(" {}: '{}'", CSS::string_from_property_id(property.property_id), property.value->to_string());
if (property.important == CSS::Important::Yes)
builder.append(" \033[31;1m!important\033[0m");
builder.append(" \033[31;1m!important\033[0m"sv);
builder.append('\n');
}
for (auto& property : style_declaration.custom_properties()) {
indent(builder, indent_levels);
builder.appendff(" {}: '{}'", property.key, property.value.value->to_string());
if (property.value.important == CSS::Important::Yes)
builder.append(" \033[31;1m!important\033[0m");
builder.append(" \033[31;1m!important\033[0m"sv);
builder.append('\n');
}
}

View file

@ -35,7 +35,7 @@ NonnullRefPtr<DOM::Document> DOMParser::parse_from_string(String const& string,
// 4. Start parser and let it run until it has consumed all the characters just inserted into the input stream.
// FIXME: This is to match the default URL. Instead, pass in this's relevant global object's associated Document's URL.
parser->run("about:blank");
parser->run("about:blank"sv);
} else {
// -> Otherwise

View file

@ -27,7 +27,7 @@ Vector<DOMStringMap::NameValuePair> DOMStringMap::get_name_value_pairs() const
// in the order that those attributes are listed in the element's attribute list, add a name-value pair to list whose name is the attribute's name with the first five characters removed and whose value
// is the attribute's value.
m_associated_element->for_each_attribute([&](auto& name, auto& value) {
if (!name.starts_with("data-"))
if (!name.starts_with("data-"sv))
return;
auto name_after_starting_data = name.view().substring_view(5);
@ -102,7 +102,7 @@ DOM::ExceptionOr<void> DOMStringMap::set_value_of_new_named_property(String cons
// 3. Insert the string data- at the front of name.
// NOTE: This is done out of order because StringBuilder doesn't have prepend.
builder.append("data-");
builder.append("data-"sv);
for (size_t character_index = 0; character_index < name.length(); ++character_index) {
// 1. If name contains a U+002D HYPHEN-MINUS character (-) followed by an ASCII lower alpha, then throw a "SyntaxError" DOMException.
@ -147,7 +147,7 @@ bool DOMStringMap::delete_existing_named_property(String const& name)
// 2. Insert the string data- at the front of name.
// NOTE: This is done out of order because StringBuilder doesn't have prepend.
builder.append("data-");
builder.append("data-"sv);
for (auto character : name) {
// 1. For each ASCII upper alpha in name, insert a U+002D HYPHEN-MINUS character (-) before the character and replace the character with the same character converted to ASCII lowercase.

View file

@ -22,15 +22,15 @@ HTMLBodyElement::~HTMLBodyElement() = default;
void HTMLBodyElement::apply_presentational_hints(CSS::StyleProperties& style) const
{
for_each_attribute([&](auto& name, auto& value) {
if (name.equals_ignoring_case("bgcolor")) {
if (name.equals_ignoring_case("bgcolor"sv)) {
auto color = Color::from_string(value);
if (color.has_value())
style.set_property(CSS::PropertyID::BackgroundColor, CSS::ColorStyleValue::create(color.value()));
} else if (name.equals_ignoring_case("text")) {
} else if (name.equals_ignoring_case("text"sv)) {
auto color = Color::from_string(value);
if (color.has_value())
style.set_property(CSS::PropertyID::Color, CSS::ColorStyleValue::create(color.value()));
} else if (name.equals_ignoring_case("background")) {
} else if (name.equals_ignoring_case("background"sv)) {
VERIFY(m_background_style_value);
style.set_property(CSS::PropertyID::BackgroundImage, *m_background_style_value);
}
@ -40,19 +40,19 @@ void HTMLBodyElement::apply_presentational_hints(CSS::StyleProperties& style) co
void HTMLBodyElement::parse_attribute(FlyString const& name, String const& value)
{
HTMLElement::parse_attribute(name, value);
if (name.equals_ignoring_case("link")) {
if (name.equals_ignoring_case("link"sv)) {
auto color = Color::from_string(value);
if (color.has_value())
document().set_link_color(color.value());
} else if (name.equals_ignoring_case("alink")) {
} else if (name.equals_ignoring_case("alink"sv)) {
auto color = Color::from_string(value);
if (color.has_value())
document().set_active_link_color(color.value());
} else if (name.equals_ignoring_case("vlink")) {
} else if (name.equals_ignoring_case("vlink"sv)) {
auto color = Color::from_string(value);
if (color.has_value())
document().set_visited_link_color(color.value());
} else if (name.equals_ignoring_case("background")) {
} else if (name.equals_ignoring_case("background"sv)) {
m_background_style_value = CSS::ImageStyleValue::create(document().parse_url(value));
}

View file

@ -56,7 +56,7 @@ String HTMLButtonElement::type() const
auto value = attribute(HTML::AttributeNames::type);
#define __ENUMERATE_HTML_BUTTON_TYPE_ATTRIBUTE(keyword, _) \
if (value.equals_ignoring_case(#keyword)) \
if (value.equals_ignoring_case(#keyword##sv)) \
return #keyword;
ENUMERATE_HTML_BUTTON_TYPE_ATTRIBUTES
#undef __ENUMERATE_HTML_BUTTON_TYPE_ATTRIBUTE
@ -70,7 +70,7 @@ HTMLButtonElement::TypeAttributeState HTMLButtonElement::type_state() const
auto value = attribute(HTML::AttributeNames::type);
#define __ENUMERATE_HTML_BUTTON_TYPE_ATTRIBUTE(keyword, state) \
if (value.equals_ignoring_case(#keyword)) \
if (value.equals_ignoring_case(#keyword##sv)) \
return HTMLButtonElement::TypeAttributeState::state;
ENUMERATE_HTML_BUTTON_TYPE_ATTRIBUTES
#undef __ENUMERATE_HTML_BUTTON_TYPE_ATTRIBUTE

View file

@ -40,10 +40,10 @@ HTMLElement::ContentEditableState HTMLElement::content_editable_state() const
{
auto contenteditable = attribute(HTML::AttributeNames::contenteditable);
// "true", an empty string or a missing value map to the "true" state.
if ((!contenteditable.is_null() && contenteditable.is_empty()) || contenteditable.equals_ignoring_case("true"))
if ((!contenteditable.is_null() && contenteditable.is_empty()) || contenteditable.equals_ignoring_case("true"sv))
return ContentEditableState::True;
// "false" maps to the "false" state.
if (contenteditable.equals_ignoring_case("false"))
if (contenteditable.equals_ignoring_case("false"sv))
return ContentEditableState::False;
// Having no such attribute or an invalid value maps to the "inherit" state.
return ContentEditableState::Inherit;
@ -80,15 +80,15 @@ String HTMLElement::content_editable() const
// https://html.spec.whatwg.org/multipage/interaction.html#contenteditable
DOM::ExceptionOr<void> HTMLElement::set_content_editable(String const& content_editable)
{
if (content_editable.equals_ignoring_case("inherit")) {
if (content_editable.equals_ignoring_case("inherit"sv)) {
remove_attribute(HTML::AttributeNames::contenteditable);
return {};
}
if (content_editable.equals_ignoring_case("true")) {
if (content_editable.equals_ignoring_case("true"sv)) {
set_attribute(HTML::AttributeNames::contenteditable, "true");
return {};
}
if (content_editable.equals_ignoring_case("false")) {
if (content_editable.equals_ignoring_case("false"sv)) {
set_attribute(HTML::AttributeNames::contenteditable, "false");
return {};
}

View file

@ -20,7 +20,7 @@ HTMLFontElement::~HTMLFontElement() = default;
void HTMLFontElement::apply_presentational_hints(CSS::StyleProperties& style) const
{
for_each_attribute([&](auto& name, auto& value) {
if (name.equals_ignoring_case("color")) {
if (name.equals_ignoring_case("color"sv)) {
auto color = Color::from_string(value);
if (color.has_value())
style.set_property(CSS::PropertyID::Color, CSS::ColorStyleValue::create(color.value()));

View file

@ -167,7 +167,7 @@ static bool is_form_control(DOM::Element const& element)
}
if (is<HTMLInputElement>(element)
&& !element.get_attribute(HTML::AttributeNames::type).equals_ignoring_case("image")) {
&& !element.get_attribute(HTML::AttributeNames::type).equals_ignoring_case("image"sv)) {
return true;
}

View file

@ -227,7 +227,7 @@ void HTMLInputElement::parse_attribute(FlyString const& name, String const& valu
HTMLInputElement::TypeAttributeState HTMLInputElement::parse_type_attribute(StringView type)
{
#define __ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE(keyword, state) \
if (type.equals_ignoring_case(#keyword)) \
if (type.equals_ignoring_case(#keyword##sv)) \
return HTMLInputElement::TypeAttributeState::state;
ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTES
#undef __ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE

View file

@ -175,7 +175,7 @@ void HTMLObjectElement::resource_did_load()
// FIXME: For now, ignore application/ MIME types as we cannot render yet them anyways. We will need to implement the MIME type sniffing
// algorithm in order to map all unknown MIME types to "application/octet-stream".
else if (auto type = resource()->mime_type(); !type.starts_with("application/"))
else if (auto type = resource()->mime_type(); !type.starts_with("application/"sv))
tentative_type = move(type);
// 2. If tentative type is not application/octet-stream, then let resource type be tentative type and jump to the step below labeled handler.
@ -195,7 +195,7 @@ static bool is_xml_mime_type(StringView resource_type)
return false;
// An XML MIME type is any MIME type whose subtype ends in "+xml" or whose essence is "text/xml" or "application/xml". [RFC7303]
if (mime_type->subtype().ends_with("+xml"))
if (mime_type->subtype().ends_with("+xml"sv))
return true;
return mime_type->essence().is_one_of("text/xml"sv, "application/xml"sv);

View file

@ -162,7 +162,7 @@ void HTMLScriptElement::prepare_script()
if (is_javascript_mime_type_essence_match(script_block_type.trim_whitespace())) {
// - If the script block's type string with leading and trailing ASCII whitespace stripped is a JavaScript MIME type essence match, the script's type is "classic".
m_script_type = ScriptType::Classic;
} else if (script_block_type.equals_ignoring_case("module")) {
} else if (script_block_type.equals_ignoring_case("module"sv)) {
// - If the script block's type string is an ASCII case-insensitive match for the string "module", the script's type is "module".
m_script_type = ScriptType::Module;
} else {
@ -217,13 +217,13 @@ void HTMLScriptElement::prepare_script()
event = event.trim_whitespace();
// 4. If for is not an ASCII case-insensitive match for the string "window", then return. The script is not executed.
if (!for_.equals_ignoring_case("window")) {
if (!for_.equals_ignoring_case("window"sv)) {
dbgln("HTMLScriptElement: Refusing to run classic script because the provided 'for' attribute is not equal to 'window'");
return;
}
// 5. If event is not an ASCII case-insensitive match for either the string "onload" or the string "onload()", then return. The script is not executed.
if (!event.equals_ignoring_case("onload") && !event.equals_ignoring_case("onload()")) {
if (!event.equals_ignoring_case("onload"sv) && !event.equals_ignoring_case("onload()"sv)) {
dbgln("HTMLScriptElement: Refusing to run classic script because the provided 'event' attribute is not equal to 'onload' or 'onload()'");
return;
}

File diff suppressed because it is too large Load diff

View file

@ -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 {};

View file

@ -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 "&amp;".
if (ch == '&')
builder.append("&amp;");
builder.append("&amp;"sv);
// 2. Replace any occurrences of the U+00A0 NO-BREAK SPACE character by the string "&nbsp;".
else if (ch == '\xA0')
builder.append("&nbsp;");
builder.append("&nbsp;"sv);
// 3. If the algorithm was invoked in the attribute mode, replace any occurrences of the """ character by the string "&quot;".
else if (ch == '"' && attribute_mode == AttributeMode::Yes)
builder.append("&quot;");
builder.append("&quot;"sv);
// 4. If the algorithm was not invoked in the attribute mode, replace any occurrences of the "<" character by the string "&lt;", and any occurrences of the ">" character by the string "&gt;".
else if (ch == '<' && attribute_mode == AttributeMode::No)
builder.append("&lt;");
builder.append("&lt;"sv);
else if (ch == '>' && attribute_mode == AttributeMode::No)
builder.append("&gt;");
builder.append("&gt;"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;

View file

@ -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) {

View file

@ -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);
}
}

View file

@ -22,11 +22,11 @@ NonnullRefPtr<ClassicScript> ClassicScript::create(String filename, StringView s
// 2. If muted errors is true, then set baseURL to about:blank.
if (muted_errors == MutedErrors::Yes)
base_url = "about:blank";
base_url = "about:blank"sv;
// 3. If scripting is disabled for settings, then set source to the empty string.
if (environment_settings_object.is_scripting_disabled())
source = "";
source = ""sv;
// 4. Let script be a new classic script that this algorithm will subsequently initialize.
auto script = adopt_ref(*new ClassicScript(move(base_url), move(filename), environment_settings_object));

View file

@ -31,7 +31,7 @@ void WorkerDebugConsoleClient::end_group()
// 2.3. Printer(logLevel, args[, options]), https://console.spec.whatwg.org/#printer
JS::ThrowCompletionOr<JS::Value> WorkerDebugConsoleClient::printer(JS::Console::LogLevel log_level, PrinterArguments arguments)
{
String indent = String::repeated(" ", m_group_stack_depth);
String indent = String::repeated(" "sv, m_group_stack_depth);
if (log_level == JS::Console::LogLevel::Trace) {
auto trace = arguments.get<JS::Console::Trace>();

View file

@ -592,7 +592,7 @@ String Node::debug_description() const
builder.appendff(".{}", class_name);
}
} else {
builder.append("(anonymous)");
builder.append("(anonymous)"sv);
}
return builder.to_string();
}

View file

@ -142,9 +142,9 @@ bool FrameLoader::parse_document(DOM::Document& document, ByteBuffer const& data
parser->run(document.url());
return true;
}
if (mime_type.ends_with("+xml") || mime_type.is_one_of("text/xml", "application/xml"))
if (mime_type.ends_with("+xml"sv) || mime_type.is_one_of("text/xml", "application/xml"))
return build_xml_document(document, data);
if (mime_type.starts_with("image/"))
if (mime_type.starts_with("image/"sv))
return build_image_document(document, data);
if (mime_type == "text/plain" || mime_type == "application/json")
return build_text_document(document, data);

View file

@ -76,7 +76,7 @@ void ImageLoader::resource_did_load()
}
m_redirects_count = 0;
if (!resource()->mime_type().starts_with("image/")) {
if (!resource()->mime_type().starts_with("image/"sv)) {
m_loading_state = LoadingState::Failed;
if (on_fail)
on_fail();

View file

@ -103,14 +103,14 @@ void Resource::did_load(Badge<ResourceLoader>, ReadonlyBytes data, HashMap<Strin
// FIXME: "The Quite OK Image Format" doesn't have an official mime type yet,
// and servers like nginx will send a generic octet-stream mime type instead.
// Let's use image/x-qoi for now, which is also what our Core::MimeData uses & would guess.
if (m_mime_type == "application/octet-stream" && url().path().ends_with(".qoi"))
if (m_mime_type == "application/octet-stream" && url().path().ends_with(".qoi"sv))
m_mime_type = "image/x-qoi";
} else if (url().protocol() == "data" && !url().data_mime_type().is_empty()) {
dbgln_if(RESOURCE_DEBUG, "This is a data URL with mime-type _{}_", url().data_mime_type());
m_mime_type = url().data_mime_type();
} else {
auto content_type_options = headers.get("X-Content-Type-Options");
if (content_type_options.value_or("").equals_ignoring_case("nosniff")) {
if (content_type_options.value_or("").equals_ignoring_case("nosniff"sv)) {
m_mime_type = "text/plain";
} else {
m_mime_type = Core::guess_mime_type_based_on_filename(url().path());

View file

@ -302,7 +302,7 @@ void ResourceLoader::load(LoadRequest& request, Function<void(ReadonlyBytes, Has
if (status_code.has_value())
error_builder.appendff("Load failed: {}", *status_code);
else
error_builder.append("Load failed");
error_builder.append("Load failed"sv);
log_failure(request, error_builder.string_view());
if (error_callback)
error_callback(error_builder.to_string(), {});

View file

@ -42,7 +42,7 @@ static bool contains_only_http_token_code_points(StringView string)
// https://mimesniff.spec.whatwg.org/#http-token-code-point
// An HTTP token code point is U+0021 (!), U+0023 (#), U+0024 ($), U+0025 (%), U+0026 (&), U+0027 ('), U+002A (*),
// U+002B (+), U+002D (-), U+002E (.), U+005E (^), U+005F (_), U+0060 (`), U+007C (|), U+007E (~), or an ASCII alphanumeric.
constexpr auto is_certain_non_ascii_alphanumeric = is_any_of("!#$%&'*+-.^_`|~");
constexpr auto is_certain_non_ascii_alphanumeric = is_any_of("!#$%&'*+-.^_`|~"sv);
for (char ch : string) {
if (!is_certain_non_ascii_alphanumeric(ch) && !is_ascii_alphanumeric(ch))
return false;
@ -56,7 +56,7 @@ Optional<MimeType> MimeType::from_string(StringView string)
// https://fetch.spec.whatwg.org/#http-whitespace
// HTTP whitespace is U+000A LF, U+000D CR, or an HTTP tab or space.
// An HTTP tab or space is U+0009 TAB or U+0020 SPACE.
constexpr char const* http_whitespace = "\n\r\t ";
constexpr auto http_whitespace = "\n\r\t "sv;
// 1. Remove any leading and trailing HTTP whitespace from input.
auto trimmed_string = string.trim(http_whitespace, TrimMode::Both);

View file

@ -78,7 +78,7 @@ public:
result.append(protocol());
// 3. Append "://" to result.
result.append("://");
result.append("://"sv);
// 4. Append origin's host, serialized, to result.
result.append(host());

View file

@ -234,7 +234,7 @@ bool EventHandler::handle_mouseup(Gfx::IntPoint const& position, unsigned button
auto url = document->parse_url(href);
dbgln("Web::EventHandler: Clicking on a link to {}", url);
if (button == GUI::MouseButton::Primary) {
if (href.starts_with("javascript:")) {
if (href.starts_with("javascript:"sv)) {
document->run_javascript(href.substring_view(11, href.length() - 11));
} else if (!url.fragment().is_null() && url.equals(document->url(), AK::URL::ExcludeFragment::Yes)) {
m_browsing_context.scroll_to_anchor(url.fragment());

View file

@ -31,7 +31,7 @@ void ProgressPaintable::paint(PaintContext& context, PaintPhase phase) const
if (phase == PaintPhase::Foreground) {
// FIXME: This does not support floating point value() and max()
Gfx::StylePainter::paint_progressbar(context.painter(), enclosing_int_rect(absolute_rect()), context.palette(), 0, layout_box().dom_node().max(), layout_box().dom_node().value(), "");
Gfx::StylePainter::paint_progressbar(context.painter(), enclosing_int_rect(absolute_rect()), context.palette(), 0, layout_box().dom_node().max(), layout_box().dom_node().value(), ""sv);
}
}

View file

@ -405,7 +405,7 @@ void StackingContext::dump(int indent) const
if (m_box.computed_values().z_index().has_value())
builder.appendff("{}", m_box.computed_values().z_index().value());
else
builder.append("auto");
builder.append("auto"sv);
builder.append(')');
auto affine_transform = combine_transformations_2d(m_box.computed_values().transformations());

View file

@ -21,18 +21,18 @@ void SVGGraphicsElement::apply_presentational_hints(CSS::StyleProperties& style)
{
CSS::Parser::ParsingContext parsing_context { document() };
for_each_attribute([&](auto& name, auto& value) {
if (name.equals_ignoring_case("fill")) {
if (name.equals_ignoring_case("fill"sv)) {
// FIXME: The `fill` attribute and CSS `fill` property are not the same! But our support is limited enough that they are equivalent for now.
if (auto fill_value = parse_css_value(parsing_context, value, CSS::PropertyID::Fill))
style.set_property(CSS::PropertyID::Fill, fill_value.release_nonnull());
} else if (name.equals_ignoring_case("stroke")) {
} else if (name.equals_ignoring_case("stroke"sv)) {
// FIXME: The `stroke` attribute and CSS `stroke` property are not the same! But our support is limited enough that they are equivalent for now.
if (auto stroke_value = parse_css_value(parsing_context, value, CSS::PropertyID::Stroke))
style.set_property(CSS::PropertyID::Stroke, stroke_value.release_nonnull());
} else if (name.equals_ignoring_case("stroke-width")) {
} else if (name.equals_ignoring_case("stroke-width"sv)) {
if (auto stroke_width_value = parse_css_value(parsing_context, value, CSS::PropertyID::StrokeWidth))
style.set_property(CSS::PropertyID::StrokeWidth, stroke_width_value.release_nonnull());
} else if (name.equals_ignoring_case("transform")) {
} else if (name.equals_ignoring_case("transform"sv)) {
if (auto transform = parse_css_value(parsing_context, value, CSS::PropertyID::Transform))
style.set_property(CSS::PropertyID::Transform, transform.release_nonnull());
}

View file

@ -299,7 +299,7 @@ JS::ThrowCompletionOr<size_t> WebAssemblyObject::instantiate_module(Wasm::Module
if (link_result.is_error()) {
// FIXME: Throw a LinkError.
StringBuilder builder;
builder.append("LinkError: Missing ");
builder.append("LinkError: Missing "sv);
builder.join(' ', link_result.error().missing_imports);
return vm.throw_completion<JS::TypeError>(global_object, builder.build());
}

View file

@ -161,7 +161,7 @@ String XMLHttpRequest::get_text_response() const
if (mime_type.essence().is_one_of("text/xml"sv, "application/xml"sv))
return true;
return mime_type.subtype().ends_with("+xml");
return mime_type.subtype().ends_with("+xml"sv);
};
// 3. If xhrs response type is the empty string, charset is null, and the result of get a final MIME type for xhr is an XML MIME type,
@ -171,7 +171,7 @@ String XMLHttpRequest::get_text_response() const
// 4. If charset is null, then set charset to UTF-8.
if (!charset.has_value())
charset = "UTF-8";
charset = "UTF-8"sv;
// 5. Return the result of running decode on xhrs received bytes using fallback encoding charset.
auto* decoder = TextCodec::decoder_for(charset.value());
@ -300,7 +300,7 @@ Optional<Vector<String>> XMLHttpRequest::get_decode_and_split(String const& head
// 3. Remove all HTTP tab or space from the start and end of value.
// https://fetch.spec.whatwg.org/#http-tab-or-space
// An HTTP tab or space is U+0009 TAB or U+0020 SPACE.
auto trimmed_value = value.to_string().trim("\t ", TrimMode::Both);
auto trimmed_value = value.to_string().trim("\t "sv, TrimMode::Both);
// 4. Append value to values.
values.append(move(trimmed_value));
@ -374,7 +374,7 @@ Optional<MimeSniff::MimeType> XMLHttpRequest::extract_mime_type(HashMap<String,
// https://fetch.spec.whatwg.org/#forbidden-header-name
static bool is_forbidden_header_name(String const& header_name)
{
if (header_name.starts_with("Proxy-", CaseSensitivity::CaseInsensitive) || header_name.starts_with("Sec-", CaseSensitivity::CaseInsensitive))
if (header_name.starts_with("Proxy-"sv, CaseSensitivity::CaseInsensitive) || header_name.starts_with("Sec-"sv, CaseSensitivity::CaseInsensitive))
return true;
auto lowercase_header_name = header_name.to_lowercase();
@ -699,9 +699,9 @@ String XMLHttpRequest::get_all_response_headers() const
for (auto& key : keys) {
builder.append(key);
builder.append(": ");
builder.append(": "sv);
builder.append(m_response_headers.get(key).value());
builder.append("\r\n");
builder.append("\r\n"sv);
}
return builder.to_string();
}