LibHTML: Implement basic layout for inline <img alt>

LayoutReplaced objects can now participate in inline layout.

It's very hackish, but basically LayoutReplaced will just add itself to
the last line in the containing block.

This patch gets rid of the idea that only LayoutInline subclasses can
be split into lines, by moving the split_into_lines() virtual up to
LayoutNode and overriding it in LayoutReplaced.
This commit is contained in:
Andreas Kling 2019-10-05 23:20:35 +02:00
parent f150134de9
commit ee567cdc3d
Notes: sideshowbarker 2024-07-19 11:48:29 +09:00
11 changed files with 75 additions and 15 deletions

View file

@ -1,4 +1,6 @@
#include <LibHTML/CSS/StyleResolver.h>
#include <LibHTML/DOM/HTMLImageElement.h>
#include <LibHTML/Layout/LayoutImage.h>
HTMLImageElement::HTMLImageElement(Document& document, const String& tag_name)
: HTMLElement(document, tag_name)
@ -8,3 +10,15 @@ HTMLImageElement::HTMLImageElement(Document& document, const String& tag_name)
HTMLImageElement::~HTMLImageElement()
{
}
RefPtr<LayoutNode> HTMLImageElement::create_layout_node(const StyleResolver& resolver, const StyleProperties* parent_style) const
{
auto style = resolver.resolve_style(*this, parent_style);
auto display_property = style->property("display");
String display = display_property.has_value() ? display_property.release_value()->to_string() : "inline";
if (display == "none")
return nullptr;
return adopt(*new LayoutImage(*this, move(style)));
}