2019-06-15 17:49:44 -03:00
|
|
|
#pragma once
|
|
|
|
|
|
2019-06-15 18:41:15 -03:00
|
|
|
#include <LibHTML/Layout/LayoutNode.h>
|
2019-10-03 10:20:13 -03:00
|
|
|
#include <LibHTML/Layout/LineBox.h>
|
2019-06-15 17:49:44 -03:00
|
|
|
|
|
|
|
|
class Element;
|
|
|
|
|
|
2019-10-07 04:50:31 -03:00
|
|
|
class LayoutBlock : public LayoutNodeWithStyle {
|
2019-06-15 17:49:44 -03:00
|
|
|
public:
|
2019-10-04 07:12:39 -03:00
|
|
|
LayoutBlock(const Node*, NonnullRefPtr<StyleProperties>);
|
2019-06-15 17:49:44 -03:00
|
|
|
virtual ~LayoutBlock() override;
|
|
|
|
|
|
|
|
|
|
virtual const char* class_name() const override { return "LayoutBlock"; }
|
|
|
|
|
|
2019-06-20 18:00:26 -03:00
|
|
|
virtual void layout() override;
|
2019-09-25 06:40:37 -03:00
|
|
|
virtual void render(RenderingContext&) override;
|
2019-06-20 18:00:26 -03:00
|
|
|
|
2019-07-08 12:42:23 -03:00
|
|
|
virtual LayoutNode& inline_wrapper() override;
|
|
|
|
|
|
2019-10-03 10:20:13 -03:00
|
|
|
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;
|
|
|
|
|
|
2019-06-15 17:49:44 -03:00
|
|
|
private:
|
2019-07-01 02:28:37 -03:00
|
|
|
virtual bool is_block() const override { return true; }
|
|
|
|
|
|
2019-10-05 18:47:06 -03:00
|
|
|
NonnullRefPtr<StyleProperties> style_for_anonymous_block() const;
|
|
|
|
|
|
2019-10-03 10:20:13 -03:00
|
|
|
void layout_inline_children();
|
|
|
|
|
void layout_block_children();
|
|
|
|
|
|
2019-07-01 02:28:37 -03:00
|
|
|
void compute_width();
|
2019-08-18 03:37:53 -03:00
|
|
|
void compute_position();
|
2019-07-01 02:28:37 -03:00
|
|
|
void compute_height();
|
2019-10-03 10:20:13 -03:00
|
|
|
|
|
|
|
|
Vector<LineBox> m_line_boxes;
|
2019-06-15 17:49:44 -03:00
|
|
|
};
|
2019-10-09 16:25:29 -03:00
|
|
|
|
|
|
|
|
template<typename Callback>
|
|
|
|
|
void LayoutNode::for_each_fragment_of_this(Callback callback)
|
|
|
|
|
{
|
|
|
|
|
auto& block = *containing_block();
|
|
|
|
|
for (auto& line_box : block.line_boxes()) {
|
|
|
|
|
for (auto& fragment : line_box.fragments()) {
|
|
|
|
|
if (callback(fragment) == IterationDecision::Break)
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|