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

LibWeb: Stop rendering the src (URL) as image alt attribute fallback

If an image element has no alt attribute, other browsers don't fall back
to using the src attribute like we did.

This gave us a janky look while loading pages that other browsers don't
have, and it's not like seeing a partial URL is really helpful to the
user anyway.
This commit is contained in:
Andreas Kling 2023-12-28 10:18:00 +01:00
parent f1e01a681e
commit 473f3a0931

View file

@ -58,8 +58,6 @@ void ImagePaintable::paint(PaintContext& context, PaintPhase phase) const
context.recording_painter().set_font(Platform::FontPlugin::the().default_font());
context.recording_painter().paint_frame(enclosing_rect, context.palette(), Gfx::FrameStyle::SunkenContainer);
auto alt = image_element.get_attribute_value(HTML::AttributeNames::alt);
if (alt.is_empty())
alt = image_element.get_attribute_value(HTML::AttributeNames::src);
context.recording_painter().draw_text(enclosing_rect, alt, Gfx::TextAlignment::Center, computed_values().color(), Gfx::TextElision::Right);
} else if (auto bitmap = layout_box().image_provider().current_image_bitmap(image_rect.size().to_type<int>())) {
ScopedCornerRadiusClip corner_clip { context, image_rect, normalized_border_radii_data(ShrinkRadiiForBorders::Yes) };