LibWeb: Port Document encoding_parse_url and parse_url to Optional<URL>

This ports two more APIs away from URL::is_valid.
This commit is contained in:
Shannon Booth 2025-01-23 19:40:57 +13:00 committed by Tim Ledbetter
parent cfe9b7a82b
commit 22a7cd9700
Notes: github-actions[bot] 2025-01-27 00:04:07 +00:00
26 changed files with 135 additions and 107 deletions
Libraries/LibWeb/HTML

View file

@ -125,12 +125,13 @@ void HTMLBodyElement::attribute_changed(FlyString const& name, Optional<String>
document().set_visited_link_color(color.value());
} else if (name.equals_ignoring_ascii_case("background"sv)) {
// https://html.spec.whatwg.org/multipage/rendering.html#the-page:attr-background
m_background_style_value = CSS::ImageStyleValue::create(document().encoding_parse_url(value.value_or(String {})));
m_background_style_value->on_animate = [this] {
if (paintable()) {
paintable()->set_needs_display();
}
};
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());
m_background_style_value->on_animate = [this] {
if (paintable())
paintable()->set_needs_display();
};
}
}
#undef __ENUMERATE