
Inline layout is now done by LayoutBlock. Blocks with inline children will split them into line boxes during layout. A LayoutBlock can have zero or more LineBox objects. Each LineBox represents one visual line. A LineBox can have any number of LineBoxFragment children. A fragment is an offset+length into a specific LayoutNode. To paint a LayoutBlock with inline children, we walk its line boxes, and walk their fragments, painting each fragment at a time by calling LineBoxFragment::render(), which in turn calls the LayoutNode via LayoutText::render_fragment(). Hit testing works similarly. This is very incomplete and has many bugs, but should make it easier for us to move forward with this code.
38 lines
958 B
C++
38 lines
958 B
C++
#pragma once
|
|
|
|
#include <LibHTML/Layout/LayoutNode.h>
|
|
#include <LibHTML/Layout/LineBox.h>
|
|
|
|
class Element;
|
|
|
|
class LayoutBlock : public LayoutNode {
|
|
public:
|
|
LayoutBlock(const Node*, 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; }
|
|
|
|
void layout_inline_children();
|
|
void layout_block_children();
|
|
|
|
void compute_width();
|
|
void compute_position();
|
|
void compute_height();
|
|
|
|
Vector<LineBox> m_line_boxes;
|
|
};
|