ladybird/Libraries/LibHTML/Layout/LayoutBlock.h
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

40 lines
1 KiB
C++

#pragma once
#include <LibHTML/Layout/LayoutNode.h>
#include <LibHTML/Layout/LineBox.h>
class Element;
class LayoutBlock : public LayoutNodeWithStyle {
public:
LayoutBlock(const Node*, NonnullRefPtr<StyleProperties>);
virtual ~LayoutBlock() override;
virtual const char* class_name() const override { return "LayoutBlock"; }
virtual void layout() override;
virtual void render(RenderingContext&) override;
virtual LayoutNode& inline_wrapper() override;
bool children_are_inline() const;
Vector<LineBox>& line_boxes() { return m_line_boxes; }
const Vector<LineBox>& line_boxes() const { return m_line_boxes; }
virtual HitTestResult hit_test(const Point&) const override;
private:
virtual bool is_block() const override { return true; }
NonnullRefPtr<StyleProperties> style_for_anonymous_block() const;
void layout_inline_children();
void layout_block_children();
void compute_width();
void compute_position();
void compute_height();
Vector<LineBox> m_line_boxes;
};