mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-07 21:17:07 +09:00
LibWeb: Always compare attribute names directly
Attributes are already stored with their names in lowercase, so we can do a direct comparison instead of a case-insensitive one.
This commit is contained in:
parent
bc8a97589f
commit
6f4df83917
Notes:
github-actions[bot]
2025-06-05 11:11:21 +00:00
Author: https://github.com/AtkinsSJ
Commit: 6f4df83917
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4995
7 changed files with 13 additions and 13 deletions
|
@ -61,17 +61,17 @@ bool HTMLBodyElement::is_presentational_hint(FlyString const& name) const
|
|||
void HTMLBodyElement::apply_presentational_hints(GC::Ref<CSS::CascadedProperties> cascaded_properties) const
|
||||
{
|
||||
for_each_attribute([&](auto& name, auto& value) {
|
||||
if (name.equals_ignoring_ascii_case("bgcolor"sv)) {
|
||||
if (name == HTML::AttributeNames::bgcolor) {
|
||||
// https://html.spec.whatwg.org/multipage/rendering.html#the-page:rules-for-parsing-a-legacy-colour-value
|
||||
auto color = parse_legacy_color_value(value);
|
||||
if (color.has_value())
|
||||
cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::BackgroundColor, CSS::CSSColorValue::create_from_color(color.value(), CSS::ColorSyntax::Legacy));
|
||||
} else if (name.equals_ignoring_ascii_case("text"sv)) {
|
||||
} else if (name == HTML::AttributeNames::text) {
|
||||
// https://html.spec.whatwg.org/multipage/rendering.html#the-page:rules-for-parsing-a-legacy-colour-value-2
|
||||
auto color = parse_legacy_color_value(value);
|
||||
if (color.has_value())
|
||||
cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::Color, CSS::CSSColorValue::create_from_color(color.value(), CSS::ColorSyntax::Legacy));
|
||||
} else if (name.equals_ignoring_ascii_case("background"sv)) {
|
||||
} else if (name == HTML::AttributeNames::background) {
|
||||
VERIFY(m_background_style_value);
|
||||
cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::BackgroundImage, *m_background_style_value);
|
||||
}
|
||||
|
@ -114,22 +114,22 @@ void HTMLBodyElement::attribute_changed(FlyString const& name, Optional<String>
|
|||
{
|
||||
Base::attribute_changed(name, old_value, value, namespace_);
|
||||
|
||||
if (name.equals_ignoring_ascii_case("link"sv)) {
|
||||
if (name == HTML::AttributeNames::link) {
|
||||
// https://html.spec.whatwg.org/multipage/rendering.html#the-page:rules-for-parsing-a-legacy-colour-value-3
|
||||
auto color = parse_legacy_color_value(value.value_or(String {}));
|
||||
if (color.has_value())
|
||||
document().set_normal_link_color(color.value());
|
||||
} else if (name.equals_ignoring_ascii_case("alink"sv)) {
|
||||
} else if (name == HTML::AttributeNames::alink) {
|
||||
// https://html.spec.whatwg.org/multipage/rendering.html#the-page:rules-for-parsing-a-legacy-colour-value-5
|
||||
auto color = parse_legacy_color_value(value.value_or(String {}));
|
||||
if (color.has_value())
|
||||
document().set_active_link_color(color.value());
|
||||
} else if (name.equals_ignoring_ascii_case("vlink"sv)) {
|
||||
} else if (name == HTML::AttributeNames::vlink) {
|
||||
// https://html.spec.whatwg.org/multipage/rendering.html#the-page:rules-for-parsing-a-legacy-colour-value-4
|
||||
auto color = parse_legacy_color_value(value.value_or(String {}));
|
||||
if (color.has_value())
|
||||
document().set_visited_link_color(color.value());
|
||||
} else if (name.equals_ignoring_ascii_case("background"sv)) {
|
||||
} else if (name == HTML::AttributeNames::background) {
|
||||
// https://html.spec.whatwg.org/multipage/rendering.html#the-page:attr-background
|
||||
if (auto maybe_background_url = document().encoding_parse_url(value.value_or(String {})); maybe_background_url.has_value()) {
|
||||
m_background_style_value = CSS::ImageStyleValue::create(maybe_background_url.value());
|
||||
|
|
|
@ -190,7 +190,7 @@ void HTMLCanvasElement::attribute_changed(FlyString const& local_name, Optional<
|
|||
{
|
||||
Base::attribute_changed(local_name, old_value, value, namespace_);
|
||||
|
||||
if (local_name.equals_ignoring_ascii_case(HTML::AttributeNames::width) || local_name.equals_ignoring_ascii_case(HTML::AttributeNames::height)) {
|
||||
if (local_name.is_one_of(HTML::AttributeNames::width, HTML::AttributeNames::height)) {
|
||||
notify_context_about_canvas_size_change();
|
||||
reset_context_to_default_state();
|
||||
if (auto layout_node = this->layout_node())
|
||||
|
|
|
@ -33,7 +33,7 @@ bool HTMLDivElement::is_presentational_hint(FlyString const& name) const
|
|||
void HTMLDivElement::apply_presentational_hints(GC::Ref<CSS::CascadedProperties> cascaded_properties) const
|
||||
{
|
||||
for_each_attribute([&](auto& name, auto& value) {
|
||||
if (name.equals_ignoring_ascii_case("align"sv)) {
|
||||
if (name == HTML::AttributeNames::align) {
|
||||
if (value.equals_ignoring_ascii_case("left"sv))
|
||||
cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::Keyword::LibwebLeft));
|
||||
else if (value.equals_ignoring_ascii_case("right"sv))
|
||||
|
|
|
@ -40,7 +40,7 @@ void HTMLHeadingElement::apply_presentational_hints(GC::Ref<CSS::CascadedPropert
|
|||
{
|
||||
HTMLElement::apply_presentational_hints(cascaded_properties);
|
||||
for_each_attribute([&](auto& name, auto& value) {
|
||||
if (name.equals_ignoring_ascii_case("align"sv)) {
|
||||
if (name == HTML::AttributeNames::align) {
|
||||
if (value == "left"sv)
|
||||
cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::Keyword::Left));
|
||||
else if (value == "right"sv)
|
||||
|
|
|
@ -40,7 +40,7 @@ void HTMLParagraphElement::apply_presentational_hints(GC::Ref<CSS::CascadedPrope
|
|||
{
|
||||
HTMLElement::apply_presentational_hints(cascaded_properties);
|
||||
for_each_attribute([&](auto& name, auto& value) {
|
||||
if (name.equals_ignoring_ascii_case("align"sv)) {
|
||||
if (name == HTML::AttributeNames::align) {
|
||||
if (value == "left"sv)
|
||||
cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::Keyword::Left));
|
||||
else if (value == "right"sv)
|
||||
|
|
|
@ -41,7 +41,7 @@ void HTMLPreElement::apply_presentational_hints(GC::Ref<CSS::CascadedProperties>
|
|||
HTMLElement::apply_presentational_hints(cascaded_properties);
|
||||
|
||||
for_each_attribute([&](auto const& name, auto const&) {
|
||||
if (name.equals_ignoring_ascii_case(HTML::AttributeNames::wrap)) {
|
||||
if (name == HTML::AttributeNames::wrap) {
|
||||
cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::TextWrapMode, CSS::CSSKeywordValue::create(CSS::Keyword::Wrap));
|
||||
}
|
||||
});
|
||||
|
|
|
@ -40,7 +40,7 @@ void HTMLTableCaptionElement::apply_presentational_hints(GC::Ref<CSS::CascadedPr
|
|||
{
|
||||
HTMLElement::apply_presentational_hints(cascaded_properties);
|
||||
for_each_attribute([&](auto& name, auto& value) {
|
||||
if (name.equals_ignoring_ascii_case("align"sv)) {
|
||||
if (name == HTML::AttributeNames::align) {
|
||||
if (value == "bottom"sv)
|
||||
cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::CaptionSide, CSS::CSSKeywordValue::create(CSS::Keyword::Bottom));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue