Skip to content

Commit

Permalink
Some more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mrobinson committed Oct 30, 2023
1 parent 34e4308 commit 01994f6
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions components/layout_2020/flow/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ impl LineUnderConstruction {
}
}

/// The current unbreakable segment under construction for a inline formatting context.
/// The current unbreakable segment under construction for an inline formatting context.
/// Items accumulate here until we reach a soft line break opportunity during processing
/// of inline content or we reach the end of the formatting context.
struct UnbreakableSegmentUnderConstruction {
Expand Down Expand Up @@ -401,18 +401,12 @@ impl<'a, 'b> InlineFormattingContextState<'a, 'b> {
.max(self.current_line.max_block_size)
}

fn current_nesting_level_style(&self) -> &ComputedValues {
match self.inline_box_state_stack.last() {
fn propagate_current_nesting_level_white_space_style(&mut self) {
let style = match self.inline_box_state_stack.last() {
Some(inline_box_state) => &inline_box_state.style,
None => self.containing_block.style,
}
}

fn propagate_current_nesting_level_white_space_style(&mut self) {
self.white_space = self
.current_nesting_level_style()
.get_inherited_text()
.white_space;
};
self.white_space = style.get_inherited_text().white_space;
}

/// Start laying out a particular [`InlineBox`] into line items. This will push
Expand Down Expand Up @@ -486,8 +480,6 @@ impl<'a, 'b> InlineFormattingContextState<'a, 'b> {
/// [`LineItem`]s and turn them into [`Fragment`]s, then reset the
/// [`InlineFormattingContextState`] preparing it for laying out a new line.
fn finish_current_line_and_reset(&mut self) {
self.linebreak_before_new_content = false;

let mut line_items = std::mem::take(&mut self.current_line.line_items);

// From <https://www.w3.org/TR/css-text-3/#white-space-phase-2>:
Expand All @@ -509,7 +501,11 @@ impl<'a, 'b> InlineFormattingContextState<'a, 'b> {

let had_inline_advance =
self.current_line.inline_position != self.current_line.start_position.inline;
let effective_block_advance = if self.current_line.has_content || had_inline_advance {

let effective_block_advance = if self.current_line.has_content ||
had_inline_advance ||
self.linebreak_before_new_content
{
self.current_line_max_block_size()
} else {
Length::zero()
Expand Down Expand Up @@ -854,17 +850,20 @@ impl<'a, 'b> InlineFormattingContextState<'a, 'b> {
// 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.
self.current_line.has_content = true;
//self.current_line.has_content = true;
self.current_line
.max_block_size
.max_assign(self.current_line_max_block_size());
}

fn possibly_flush_deferred_forced_line_break(&mut self) {
if self.linebreak_before_new_content {
self.commit_current_segment_to_line();
self.process_line_break();
if !self.linebreak_before_new_content {
return;
}

self.commit_current_segment_to_line();
self.process_line_break();
self.linebreak_before_new_content = false;
}

fn push_line_item_to_unbreakable_segment(&mut self, line_item: LineItem) {
Expand Down Expand Up @@ -1672,7 +1671,7 @@ impl TextRun {

//{
// let text = &self.text[run.range.begin().to_usize()..run.range.end().to_usize()];
// println!("Processing: {text:?}");
// println!("Processing: '{text:?}'");
//}

// If this whitespace forces a line break, queue up a hard line break the next time we
Expand Down

0 comments on commit 01994f6

Please sign in to comment.