aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout/inline.rs
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2018-01-10 18:08:38 +0530
committerManish Goregaokar <manishsmail@gmail.com>2018-01-24 12:51:33 +0530
commitf3c81fcda8a16e9f3d7a30a9f67b0a03d618e630 (patch)
treee331b00e118054c627e1c5de4731b12716dd0781 /components/layout/inline.rs
parentbda560d01b6a9452a9124957f39b99a701aac25c (diff)
downloadservo-f3c81fcda8a16e9f3d7a30a9f67b0a03d618e630.tar.gz
servo-f3c81fcda8a16e9f3d7a30a9f67b0a03d618e630.zip
Share line breaking state across text runs
Fixes #874
Diffstat (limited to 'components/layout/inline.rs')
-rw-r--r--components/layout/inline.rs17
1 files changed, 15 insertions, 2 deletions
diff --git a/components/layout/inline.rs b/components/layout/inline.rs
index a934b95bafe..c5be5b33390 100644
--- a/components/layout/inline.rs
+++ b/components/layout/inline.rs
@@ -554,7 +554,6 @@ impl LineBreaker {
layout_context: &LayoutContext) {
// Undo any whitespace stripping from previous reflows.
fragment.reset_text_range_and_inline_size();
-
// Determine initial placement for the fragment if we need to.
//
// Also, determine whether we can legally break the line before, or
@@ -566,7 +565,21 @@ impl LineBreaker {
self.pending_line.green_zone = line_bounds.size;
false
} else {
- fragment.white_space().allow_wrap()
+ // In case of Foo<span style="...">bar</span>, the line breaker will
+ // set the "suppress line break before" flag for the second fragment.
+ //
+ // In case of Foo<span>bar</span> the second fragment ("bar") will
+ // start _within_ a glyph run, so we also avoid breaking there
+ //
+ // is_on_glyph_run_boundary does a binary search, but this is ok
+ // because the result will be cached and reused in
+ // `calculate_split_position` later
+ if fragment.suppress_line_break_before() ||
+ !fragment.is_on_glyph_run_boundary() {
+ false
+ } else {
+ fragment.white_space().allow_wrap()
+ }
};
debug!("LineBreaker: trying to append to line {} \