layout: Take into account text-indent for justification (#31777)

This change makes it so that when calculating the space added between
words for justification, text-indent is taken into account.

Fixes #31775.
This commit is contained in:
Martin Robinson 2024-03-21 16:58:03 +01:00 committed by GitHub
parent 755701f4f6
commit 841bd91784
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 142 additions and 1 deletions

View file

@ -989,13 +989,18 @@ impl<'a, 'b> InlineFormattingContextState<'a, 'b> {
match self.current_line.count_justification_opportunities() {
0 => Length::zero(),
num_justification_opportunities => {
(available_space - line_length) / (num_justification_opportunities as f32)
(available_space - text_indent - line_length) /
(num_justification_opportunities as f32)
},
}
},
_ => Length::zero(),
};
// If the content overflows the line, then justification adjustment will become negative. In
// that case, do not make any adjustment for justification.
let justification_adjustment = justification_adjustment.max(Length::zero());
(adjusted_line_start, justification_adjustment)
}