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

Everywhere: Rename equals_ignoring_case => equals_ignoring_ascii_case

Let's make it clear that these functions deal with ASCII case only.
This commit is contained in:
Andreas Kling 2023-03-10 08:48:54 +01:00
parent 03cc45e5a2
commit a504ac3e2a
76 changed files with 480 additions and 476 deletions

View file

@ -30,15 +30,15 @@ JS::ThrowCompletionOr<void> HTMLBodyElement::initialize(JS::Realm& realm)
void HTMLBodyElement::apply_presentational_hints(CSS::StyleProperties& style) const
{
for_each_attribute([&](auto& name, auto& value) {
if (name.equals_ignoring_case("bgcolor"sv)) {
if (name.equals_ignoring_ascii_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"sv)) {
} else if (name.equals_ignoring_ascii_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"sv)) {
} else if (name.equals_ignoring_ascii_case("background"sv)) {
VERIFY(m_background_style_value);
style.set_property(CSS::PropertyID::BackgroundImage, *m_background_style_value);
}
@ -48,19 +48,19 @@ void HTMLBodyElement::apply_presentational_hints(CSS::StyleProperties& style) co
void HTMLBodyElement::parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value)
{
HTMLElement::parse_attribute(name, value);
if (name.equals_ignoring_case("link"sv)) {
if (name.equals_ignoring_ascii_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"sv)) {
} else if (name.equals_ignoring_ascii_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"sv)) {
} else if (name.equals_ignoring_ascii_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"sv)) {
} else if (name.equals_ignoring_ascii_case("background"sv)) {
m_background_style_value = CSS::ImageStyleValue::create(document().parse_url(value));
m_background_style_value->on_animate = [this] {
if (layout_node()) {

View file

@ -64,7 +64,7 @@ DeprecatedString HTMLButtonElement::type() const
auto value = attribute(HTML::AttributeNames::type);
#define __ENUMERATE_HTML_BUTTON_TYPE_ATTRIBUTE(keyword, _) \
if (value.equals_ignoring_case(#keyword##sv)) \
if (value.equals_ignoring_ascii_case(#keyword##sv)) \
return #keyword;
ENUMERATE_HTML_BUTTON_TYPE_ATTRIBUTES
#undef __ENUMERATE_HTML_BUTTON_TYPE_ATTRIBUTE
@ -78,7 +78,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##sv)) \
if (value.equals_ignoring_ascii_case(#keyword##sv)) \
return HTMLButtonElement::TypeAttributeState::state;
ENUMERATE_HTML_BUTTON_TYPE_ATTRIBUTES
#undef __ENUMERATE_HTML_BUTTON_TYPE_ATTRIBUTE

View file

@ -64,7 +64,7 @@ DeprecatedString HTMLElement::dir() const
{
auto dir = attribute(HTML::AttributeNames::dir);
#define __ENUMERATE_HTML_ELEMENT_DIR_ATTRIBUTE(keyword) \
if (dir.equals_ignoring_case(#keyword##sv)) \
if (dir.equals_ignoring_ascii_case(#keyword##sv)) \
return #keyword##sv;
ENUMERATE_HTML_ELEMENT_DIR_ATTRIBUTES
#undef __ENUMERATE_HTML_ELEMENT_DIR_ATTRIBUTE
@ -81,10 +81,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"sv))
if ((!contenteditable.is_null() && contenteditable.is_empty()) || contenteditable.equals_ignoring_ascii_case("true"sv))
return ContentEditableState::True;
// "false" maps to the "false" state.
if (contenteditable.equals_ignoring_case("false"sv))
if (contenteditable.equals_ignoring_ascii_case("false"sv))
return ContentEditableState::False;
// Having no such attribute or an invalid value maps to the "inherit" state.
return ContentEditableState::Inherit;
@ -121,15 +121,15 @@ DeprecatedString HTMLElement::content_editable() const
// https://html.spec.whatwg.org/multipage/interaction.html#contenteditable
WebIDL::ExceptionOr<void> HTMLElement::set_content_editable(DeprecatedString const& content_editable)
{
if (content_editable.equals_ignoring_case("inherit"sv)) {
if (content_editable.equals_ignoring_ascii_case("inherit"sv)) {
remove_attribute(HTML::AttributeNames::contenteditable);
return {};
}
if (content_editable.equals_ignoring_case("true"sv)) {
if (content_editable.equals_ignoring_ascii_case("true"sv)) {
MUST(set_attribute(HTML::AttributeNames::contenteditable, "true"));
return {};
}
if (content_editable.equals_ignoring_case("false"sv)) {
if (content_editable.equals_ignoring_ascii_case("false"sv)) {
MUST(set_attribute(HTML::AttributeNames::contenteditable, "false"));
return {};
}

View file

@ -29,7 +29,7 @@ JS::ThrowCompletionOr<void> HTMLFontElement::initialize(JS::Realm& realm)
void HTMLFontElement::apply_presentational_hints(CSS::StyleProperties& style) const
{
for_each_attribute([&](auto& name, auto& value) {
if (name.equals_ignoring_case("color"sv)) {
if (name.equals_ignoring_ascii_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

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

View file

@ -29,7 +29,7 @@ void HTMLHeadingElement::apply_presentational_hints(CSS::StyleProperties& style)
{
HTMLElement::apply_presentational_hints(style);
for_each_attribute([&](auto& name, auto& value) {
if (name.equals_ignoring_case("align"sv)) {
if (name.equals_ignoring_ascii_case("align"sv)) {
if (value == "left"sv)
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Left));
else if (value == "right"sv)

View file

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

View file

@ -29,7 +29,7 @@ void HTMLParagraphElement::apply_presentational_hints(CSS::StyleProperties& styl
{
HTMLElement::apply_presentational_hints(style);
for_each_attribute([&](auto& name, auto& value) {
if (name.equals_ignoring_case("align"sv)) {
if (name.equals_ignoring_ascii_case("align"sv)) {
if (value == "left"sv)
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Left));
else if (value == "right"sv)

View file

@ -29,7 +29,7 @@ void HTMLPreElement::apply_presentational_hints(CSS::StyleProperties& style) con
HTMLElement::apply_presentational_hints(style);
for_each_attribute([&](auto const& name, auto const&) {
if (name.equals_ignoring_case(HTML::AttributeNames::wrap))
if (name.equals_ignoring_ascii_case(HTML::AttributeNames::wrap))
style.set_property(CSS::PropertyID::WhiteSpace, CSS::IdentifierStyleValue::create(CSS::ValueID::PreWrap));
});
}

View file

@ -29,7 +29,7 @@ void HTMLTableCaptionElement::apply_presentational_hints(CSS::StyleProperties& s
{
HTMLElement::apply_presentational_hints(style);
for_each_attribute([&](auto& name, auto& value) {
if (name.equals_ignoring_case("align"sv)) {
if (name.equals_ignoring_ascii_case("align"sv)) {
if (value == "bottom"sv)
style.set_property(CSS::PropertyID::CaptionSide, CSS::IdentifierStyleValue::create(CSS::ValueID::Bottom));
}

View file

@ -36,7 +36,7 @@ void HTMLTableCellElement::apply_presentational_hints(CSS::StyleProperties& styl
return;
}
if (name == HTML::AttributeNames::align) {
if (value.equals_ignoring_case("center"sv) || value.equals_ignoring_case("middle"sv)) {
if (value.equals_ignoring_ascii_case("center"sv) || value.equals_ignoring_ascii_case("middle"sv)) {
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::LibwebCenter));
} else {
if (auto parsed_value = parse_css_value(CSS::Parser::ParsingContext { document() }, value.view(), CSS::PropertyID::TextAlign))

View file

@ -413,16 +413,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//"sv))
if (public_identifier.equals_ignoring_ascii_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"sv))
if (public_identifier.equals_ignoring_ascii_case("-/W3C/DTD HTML 4.0 Transitional/EN"sv))
return DOM::QuirksMode::Yes;
if (public_identifier.equals_ignoring_case("HTML"sv))
if (public_identifier.equals_ignoring_ascii_case("HTML"sv))
return DOM::QuirksMode::Yes;
if (system_identifier.equals_ignoring_case("http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd"sv))
if (system_identifier.equals_ignoring_ascii_case("http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd"sv))
return DOM::QuirksMode::Yes;
for (auto& public_id : s_quirks_public_ids) {
@ -1922,7 +1922,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"sv)) {
if (type_attribute.is_null() || !type_attribute.equals_ignoring_ascii_case("hidden"sv)) {
m_frameset_ok = false;
}
return;
@ -2698,7 +2698,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"sv)) {
if (type_attribute.is_null() || !type_attribute.equals_ignoring_ascii_case("hidden"sv)) {
goto AnythingElse;
}