aboutsummaryrefslogtreecommitdiffstats
path: root/components/gfx/text
diff options
context:
space:
mode:
authorMartin Robinson <mrobinson@igalia.com>2024-06-03 16:46:53 +0200
committerGitHub <noreply@github.com>2024-06-03 14:46:53 +0000
commit48ab8d8847eadd0c94f43307860e880d4802a075 (patch)
tree97245f3828503dc45d5ee95210435e6e618fb060 /components/gfx/text
parent00b77ce73cc743c56551c43dbbe66362a5f9eb36 (diff)
downloadservo-48ab8d8847eadd0c94f43307860e880d4802a075.tar.gz
servo-48ab8d8847eadd0c94f43307860e880d4802a075.zip
layout: Add a `InlineFormattingContextBuilder` (#32415)
The main change here is that collapsed and `text-transform`'d text is computed as it's processed by DOM traversal. This single transformed text is stored in the root of the `InlineFormattingContext`. This will eventually allow performing linebreaking and shaping of the entire inline formatting context at once. Allowing for intelligent processing of linebreaking and also shaping across elements. This matches more closely what LayoutNG does. This shouldn't have any (or negligable) behavioral changes, but will allow us to prevent linebreaking inside of clusters in a followup change. Co-authored-by: Rakhi Sharma <atbrakhi@igalia.com>
Diffstat (limited to 'components/gfx/text')
-rw-r--r--components/gfx/text/glyph.rs20
1 files changed, 19 insertions, 1 deletions
diff --git a/components/gfx/text/glyph.rs b/components/gfx/text/glyph.rs
index 30705ab9d0f..fd608e7ebaa 100644
--- a/components/gfx/text/glyph.rs
+++ b/components/gfx/text/glyph.rs
@@ -440,7 +440,14 @@ pub struct GlyphStore {
/// Used to check if fast path should be used in glyph iteration.
has_detailed_glyphs: bool,
+
+ /// Whether or not this glyph store contains only glyphs for whitespace.
is_whitespace: bool,
+
+ /// Whether or not this glyph store contains only a single glyph for a single
+ /// preserved newline.
+ is_single_preserved_newline: bool,
+
is_rtl: bool,
}
@@ -448,7 +455,12 @@ impl<'a> GlyphStore {
/// Initializes the glyph store, but doesn't actually shape anything.
///
/// Use the `add_*` methods to store glyph data.
- pub fn new(length: usize, is_whitespace: bool, is_rtl: bool) -> GlyphStore {
+ pub fn new(
+ length: usize,
+ is_whitespace: bool,
+ is_single_preserved_newline: bool,
+ is_rtl: bool,
+ ) -> GlyphStore {
assert!(length > 0);
GlyphStore {
@@ -458,6 +470,7 @@ impl<'a> GlyphStore {
total_word_separators: 0,
has_detailed_glyphs: false,
is_whitespace,
+ is_single_preserved_newline,
is_rtl,
}
}
@@ -794,4 +807,9 @@ impl GlyphRun {
Ordering::Equal
}
}
+
+ #[inline]
+ pub fn is_single_preserved_newline(&self) -> bool {
+ self.glyph_store.is_single_preserved_newline
+ }
}