41 std::shared_ptr
<render_item
> m_element
;
42 int m_rendered_min_width
;
44 explicit line_box_item(const std::shared_ptr
<render_item
>& element
) : m_element(element
), m_rendered_min_width(0) {}
45 line_box_item() = default;
46 line_box_item(const line_box_item
& el
) = default;
47 line_box_item(line_box_item
&&) = default;
49 int height() const { return right() - left(); }
50 const std::shared_ptr
<render_item
>& get_el() const { return m_element
; }
51 virtual position
& pos();
52 virtual void place_to(int x
, int y
);
53 virtual int width() const;
54 virtual int top() const;
55 virtual int bottom() const;
56 virtual int right() const;
57 virtual int left() const;
58 virtual element_type
get_type() const { return type_text_part
; }
59 virtual int get_rendered_min_width() const { return m_rendered_min_width
; }
60 virtual void set_rendered_min_width(int min_width
) { m_rendered_min_width
= min_width
; }
63 class lbi_start
: public line_box_item
68 explicit lbi_start(const std::shared_ptr
<render_item
>& element
);
70 void place_to(int x
, int y
) override
;
71 int width() const override
;
72 position
& pos() override
{ return m_pos
; }
73 int top() const override
;
74 int bottom() const override
;
75 int right() const override
;
76 int left() const override
;
77 element_type
get_type() const override
{ return type_inline_start
; }
78 int get_rendered_min_width() const override
{ return width(); }
81 class lbi_end
: public lbi_start
84 explicit lbi_end(const std::shared_ptr
<render_item
>& element
);
86 void place_to(int x
, int y
) override
;
87 int right() const override
;
88 int left() const override
;
89 element_type
get_type() const override
{ return type_inline_end
; }
92 class lbi_continue
: public lbi_start
95 explicit lbi_continue(const std::shared_ptr
<render_item
>& element
);
97 void place_to(int x
, int y
) override
;
98 int right() const override
;
99 int left() const override
;
100 int width() const override
;
101 element_type
get_type() const override
{ return type_inline_continue
; }
111 va_context() : baseline(0) {}
120 int m_default_line_height
;
121 font_metrics m_font_metrics
;
123 text_align m_text_align
;
125 std::list
< std::unique_ptr
<line_box_item
> > m_items
;
127 line_box(int top
, int left
, int right
, int line_height
, const font_metrics
& fm
, text_align align
) :
134 m_default_line_height(line_height
),
142 int bottom() const { return m_top
+ height(); }
143 int top() const { return m_top
; }
144 int right() const { return m_left
+ width(); }
145 int left() const { return m_left
; }
146 int height() const { return m_height
; }
147 int width() const { return m_width
; }
148 int line_right() const { return m_right
; }
149 int min_width() const { return m_min_width
; }
151 void add_item(std::unique_ptr
<line_box_item
> item
);
152 bool can_hold(const std::unique_ptr
<line_box_item
>& item
, white_space ws
) const;
153 bool is_empty() const;
154 int baseline() const;
155 int top_margin() const;
156 int bottom_margin() const;
157 void y_shift(int shift
);
158 std::list
< std::unique_ptr
<line_box_item
> > finish(bool last_box
, const containing_block_context
&containing_block_size
);
159 std::list
< std::unique_ptr
<line_box_item
> > new_width(int left
, int right
);
160 std::shared_ptr
<render_item
> get_last_text_part() const;
161 std::shared_ptr
<render_item
> get_first_text_part() const;
162 std::list
< std::unique_ptr
<line_box_item
> >& items() { return m_items
; }
164 bool have_last_space() const;
165 bool is_break_only() const;
166 static int calc_va_baseline(const va_context
& current
, vertical_align va
, const font_metrics
& new_font
, int top
, int bottom
);
170 #endif //LH_LINE_BOX_H