Skip to content

Commit

Permalink
More fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mrobinson committed Oct 5, 2023
1 parent fdf4257 commit 5b81062
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions components/layout_2020/flow/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1356,18 +1356,26 @@ impl TextRun {
let mut text_run_inline_size = Length::zero();
let mut iterator = runs.iter().enumerate();
while let Some((run_index, run)) = iterator.next() {
if ifc.linebreak_before_new_content {
ifc.finish_current_line_and_reset(layout_context);
text_run_inline_size = Length::zero();
}

// If this whitespace forces a line break, finish the line and reset everything.
if self.glyph_run_is_whitespace_ending_with_preserved_newline(run) {
if ifc.linebreak_before_new_content {
ifc.finish_current_line_and_reset(layout_context);
text_run_inline_size = Length::zero();
}

// TODO: We shouldn't need to force the creation of a TextRun here, but only TextRuns are
// influencing line height calculation of lineboxes (and not all inline boxes on a line).
// Once that is fixed, we can avoid adding an empty TextRun here.
add_glyphs_to_current_line(ifc, glyphs.drain(..).collect(), text_run_inline_size);

// We need to ensure that the appropriate space for a linebox is created even if there
// was no other content on this line. We mark the line as having content (needing a
// advance) and having at least the height associated with this nesting of inline boxes.
ifc.current_line.has_content = true;
ifc.current_line
.max_block_size
.max_assign(ifc.current_line_max_block_size());

// Defer the actual line break until we've cleared all ending inline boxes.
ifc.linebreak_before_new_content = true;

continue;
}

Expand All @@ -1387,11 +1395,6 @@ impl TextRun {
continue;
}

if ifc.linebreak_before_new_content {
ifc.finish_current_line_and_reset(layout_context);
text_run_inline_size = Length::zero();
}

let advance_from_glyph_run = Length::from(run.glyph_store.total_advance());
let new_potential_inline_end_position =
advance_from_glyph_run + text_run_inline_size + ifc.current_line.inline_position;
Expand Down

0 comments on commit 5b81062

Please sign in to comment.