ladybird/Libraries/LibHTML/Layout/LayoutReplaced.cpp
Andreas Kling 749e3f0f30 LibHTML: Add LayoutNodeWithStyle class, make LayoutText style-less
Since LayoutText always inherits style, it shouldn't store any style of
its own. This patch adds a LayoutNodeWithStyle class to sit between
LayoutNode and everyone who wants to inherit from LayoutNode except
LayoutText :^)

Since LayoutText can never have children, we also know that the parent
of any LayoutNode is always going to be a LayoutNodeWithStyle.
So this patch makes LayoutNode::parent() return LayoutNodeWithStyle*.
2019-10-07 10:56:44 +02:00

23 lines
643 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)
: LayoutNodeWithStyle(&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());
}