mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-28 02:27:19 +02:00
LibWeb: Avoid String<->ByteString src conversion in HTMLImageElement
We already have the src attribute stored as a String, so it's completely wasteful to convert it to a ByteString. We were even doing it twice when loading each image.
This commit is contained in:
Notes:
sideshowbarker
2024-07-17 09:41:18 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/7e2d9bfd53 Pull-request: https://github.com/SerenityOS/serenity/pull/22496 Reviewed-by: https://github.com/LucasChollet
@@ -353,8 +353,9 @@ ErrorOr<void> HTMLImageElement::update_the_image_data(bool restart_animations, b
|
||||
// and it has a src attribute specified whose value is not the empty string,
|
||||
// then set selected source to the value of the element's src attribute
|
||||
// and set selected pixel density to 1.0.
|
||||
if (!uses_srcset_or_picture() && has_attribute(HTML::AttributeNames::src) && !deprecated_attribute(HTML::AttributeNames::src).is_empty()) {
|
||||
selected_source = TRY(String::from_byte_string(deprecated_attribute(HTML::AttributeNames::src)));
|
||||
auto maybe_src_attribute = attribute(HTML::AttributeNames::src);
|
||||
if (!uses_srcset_or_picture() && maybe_src_attribute.has_value() && !maybe_src_attribute.value().is_empty()) {
|
||||
selected_source = maybe_src_attribute.release_value();
|
||||
selected_pixel_density = 1.0f;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user