mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:37:46 +00:00
LibWeb: Make LineBuilder assign height to empty line boxes
This ensures that <br> produces empty line boxes with the line-height property as their height.
This commit is contained in:
parent
093a598c87
commit
b60e19fd34
2 changed files with 7 additions and 5 deletions
|
@ -12,7 +12,7 @@ namespace Web::Layout {
|
||||||
LineBuilder::LineBuilder(InlineFormattingContext& context)
|
LineBuilder::LineBuilder(InlineFormattingContext& context)
|
||||||
: m_context(context)
|
: m_context(context)
|
||||||
{
|
{
|
||||||
begin_new_line();
|
begin_new_line(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
LineBuilder::~LineBuilder()
|
LineBuilder::~LineBuilder()
|
||||||
|
@ -25,12 +25,13 @@ void LineBuilder::break_line()
|
||||||
{
|
{
|
||||||
update_last_line();
|
update_last_line();
|
||||||
m_context.containing_block().line_boxes().append(LineBox());
|
m_context.containing_block().line_boxes().append(LineBox());
|
||||||
begin_new_line();
|
begin_new_line(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LineBuilder::begin_new_line()
|
void LineBuilder::begin_new_line(bool increment_y)
|
||||||
{
|
{
|
||||||
m_current_y += m_max_height_on_current_line;
|
if (increment_y)
|
||||||
|
m_current_y += max(m_max_height_on_current_line, m_context.containing_block().line_height());
|
||||||
auto space = m_context.available_space_for_line(m_current_y);
|
auto space = m_context.available_space_for_line(m_current_y);
|
||||||
m_available_width_for_current_line = space.right - space.left;
|
m_available_width_for_current_line = space.right - space.left;
|
||||||
m_max_height_on_current_line = 0;
|
m_max_height_on_current_line = 0;
|
||||||
|
|
|
@ -19,7 +19,6 @@ public:
|
||||||
~LineBuilder();
|
~LineBuilder();
|
||||||
|
|
||||||
void break_line();
|
void break_line();
|
||||||
void begin_new_line();
|
|
||||||
void append_box(Box&);
|
void append_box(Box&);
|
||||||
void append_text_chunk(TextNode&, size_t offset_in_node, size_t length_in_node, float width, float height);
|
void append_text_chunk(TextNode&, size_t offset_in_node, size_t length_in_node, float width, float height);
|
||||||
|
|
||||||
|
@ -36,6 +35,8 @@ public:
|
||||||
void remove_last_line_if_empty();
|
void remove_last_line_if_empty();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void begin_new_line(bool increment_y);
|
||||||
|
|
||||||
bool should_break(LayoutMode, float next_item_width, bool should_force_break);
|
bool should_break(LayoutMode, float next_item_width, bool should_force_break);
|
||||||
|
|
||||||
InlineFormattingContext& m_context;
|
InlineFormattingContext& m_context;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue