mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 02:14:57 +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:
parent
9858e2632c
commit
958b395418
3 changed files with 27 additions and 1 deletions
|
@ -1,4 +1,5 @@
|
|||
#include <LibHTML/CSS/StyleResolver.h>
|
||||
#include <LibHTML/DOM/Document.h>
|
||||
#include <LibHTML/DOM/HTMLImageElement.h>
|
||||
#include <LibHTML/Layout/LayoutImage.h>
|
||||
|
||||
|
@ -22,3 +23,18 @@ RefPtr<LayoutNode> HTMLImageElement::create_layout_node(const StyleResolver& res
|
|||
return nullptr;
|
||||
return adopt(*new LayoutImage(*this, move(style)));
|
||||
}
|
||||
|
||||
const GraphicsBitmap* HTMLImageElement::bitmap() const
|
||||
{
|
||||
if (!m_bitmap) {
|
||||
URL src_url = document().complete_url(this->src());
|
||||
if (src_url.protocol() == "file") {
|
||||
m_bitmap = GraphicsBitmap::load_from_file(src_url.path());
|
||||
} else {
|
||||
// FIXME: Implement! This whole thing should be at a different layer though..
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
return m_bitmap;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue