ladybird/Libraries/LibHTML/Layout/LayoutReplaced.cpp
Andreas Kling ee567cdc3d 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.
2019-10-05 23:29:01 +02:00

24 lines
634 B
C++

#include <LibHTML/DOM/Element.h>
#include <LibHTML/Layout/LayoutBlock.h>
#include <LibHTML/Layout/LayoutReplaced.h>
LayoutReplaced::LayoutReplaced(const Element& element, NonnullRefPtr<StyleProperties> style)
: LayoutNode(&element, move(style))
{
// FIXME: Allow non-inline replaced elements.
set_inline(true);
}
LayoutReplaced::~LayoutReplaced()
{
}
void LayoutReplaced::split_into_lines(LayoutBlock& container)
{
layout();
if (container.line_boxes().is_empty())
container.line_boxes().append(LineBox());
container.line_boxes().last().add_fragment(*this, 0, 0, rect().width(), rect().height());
}