aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout_2020/flow/text_run.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/layout_2020/flow/text_run.rs')
-rw-r--r--components/layout_2020/flow/text_run.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/components/layout_2020/flow/text_run.rs b/components/layout_2020/flow/text_run.rs
index bccedebea5d..fbdcaf4a161 100644
--- a/components/layout_2020/flow/text_run.rs
+++ b/components/layout_2020/flow/text_run.rs
@@ -150,7 +150,7 @@ impl TextRunSegment {
// If this whitespace forces a line break, queue up a hard line break the next time we
// see any content. We don't line break immediately, because we'd like to finish processing
// any ongoing inline boxes before ending the line.
- if text_run.glyph_run_is_preserved_newline(run) {
+ if text_run.glyph_run_is_preserved_newline(self, run) {
ifc.defer_forced_line_break();
continue;
}
@@ -429,7 +429,11 @@ impl TextRun {
self.prevent_soft_wrap_opportunity_at_end;
}
- pub(super) fn glyph_run_is_preserved_newline(&self, run: &GlyphRun) -> bool {
+ pub(super) fn glyph_run_is_preserved_newline(
+ &self,
+ text_run_segment: &TextRunSegment,
+ run: &GlyphRun,
+ ) -> bool {
if !run.glyph_store.is_whitespace() || run.range.length() != ByteIndex(1) {
return false;
}
@@ -442,7 +446,8 @@ impl TextRun {
return false;
}
- let byte = self.text.as_bytes().get(run.range.begin().to_usize());
+ let byte_offset = (text_run_segment.range.begin() + run.range.begin()).to_usize();
+ let byte = self.text.as_bytes().get(byte_offset);
byte == Some(&b'\n')
}
}