1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 06:18:12 +00:00

LibHTML: Support rendering <img src> with file:// URLs

We can now show images loaded from local file:// URLs. Pretty neat :^)
This commit is contained in:
Andreas Kling 2019-10-05 23:41:14 +02:00
parent 9858e2632c
commit 958b395418
3 changed files with 27 additions and 1 deletions

View file

@ -18,6 +18,9 @@ void LayoutImage::layout()
auto& font = Font::default_font();
rect().set_width(font.width(node().alt()) + 16);
rect().set_height(font.glyph_height() + 16);
} else {
rect().set_width(node().bitmap()->width());
rect().set_height(node().bitmap()->height());
}
LayoutReplaced::layout();
@ -29,11 +32,13 @@ void LayoutImage::render(RenderingContext& context)
context.painter().set_font(Font::default_font());
StylePainter::paint_frame(context.painter(), rect(), FrameShape::Container, FrameShadow::Sunken, 2);
context.painter().draw_text(rect(), node().alt(), TextAlignment::Center, Color::White);
} else {
context.painter().draw_scaled_bitmap(rect(), *node().bitmap(), node().bitmap()->rect());
}
LayoutReplaced::render(context);
}
bool LayoutImage::renders_as_alt_text() const
{
return true;
return !node().bitmap();
}