LibHTML: Support width/height attributes on images

This commit is contained in:
Conrad Pankoff 2019-10-06 23:15:30 +11:00 committed by Andreas Kling
parent 088237a25f
commit b240500107
Notes: sideshowbarker 2024-07-19 11:47:12 +09:00
3 changed files with 34 additions and 3 deletions

View file

@ -29,6 +29,32 @@ void HTMLImageElement::load_image(const String& src)
}
}
int HTMLImageElement::preferred_width() const
{
bool ok = false;
int width = attribute("width").to_int(ok);
if (ok)
return width;
if (m_bitmap)
return m_bitmap->width();
return 0;
}
int HTMLImageElement::preferred_height() const
{
bool ok = false;
int height = attribute("height").to_int(ok);
if (ok)
return height;
if (m_bitmap)
return m_bitmap->height();
return 0;
}
RefPtr<LayoutNode> HTMLImageElement::create_layout_node(const StyleResolver& resolver, const StyleProperties* parent_style) const
{
auto style = resolver.resolve_style(*this, parent_style);