diff options
author | Martin Robinson <mrobinson@igalia.com> | 2024-08-29 16:51:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-29 14:51:39 +0000 |
commit | 3f93de7f5494191ee659de9b5a340b329a25879b (patch) | |
tree | bd891e7a215e6420d7c571add9e848cb312eb0ce /components/layout_2020/flow/inline/construct.rs | |
parent | 93abdf7cb56fa9db6aa160d63e8773292c5e7520 (diff) | |
download | servo-3f93de7f5494191ee659de9b5a340b329a25879b.tar.gz servo-3f93de7f5494191ee659de9b5a340b329a25879b.zip |
layout: Stop using `unicode-segmentation` in layout (#33250)
`layout` already uses `icu_segmentation` so there's no need to pull in
another segmenter. This reduces the number of segmenters used in the
crate to 2 from 3.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Diffstat (limited to 'components/layout_2020/flow/inline/construct.rs')
-rw-r--r-- | components/layout_2020/flow/inline/construct.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/components/layout_2020/flow/inline/construct.rs b/components/layout_2020/flow/inline/construct.rs index ecce2e5f8e4..901f8a91c54 100644 --- a/components/layout_2020/flow/inline/construct.rs +++ b/components/layout_2020/flow/inline/construct.rs @@ -5,11 +5,11 @@ use std::borrow::Cow; use std::char::{ToLowercase, ToUppercase}; +use icu_segmenter::WordSegmenter; use style::computed_values::white_space_collapse::T as WhiteSpaceCollapse; use style::values::computed::TextDecorationLine; use style::values::specified::text::TextTransformCase; use unicode_bidi::Level; -use unicode_segmentation::UnicodeSegmentation; use super::text_run::TextRun; use super::{InlineBox, InlineBoxIdentifier, InlineBoxes, InlineFormattingContext, InlineItem}; @@ -601,13 +601,14 @@ fn capitalize_string(string: &str, allow_word_at_start: bool) -> String { let mut output_string = String::new(); output_string.reserve(string.len()); - let mut bounds = string.unicode_word_indices().peekable(); + let word_segmenter = WordSegmenter::new_auto(); + let mut bounds = word_segmenter.segment_str(string).peekable(); let mut byte_index = 0; for character in string.chars() { let current_byte_index = byte_index; byte_index += character.len_utf8(); - if let Some((next_index, _)) = bounds.peek() { + if let Some(next_index) = bounds.peek() { if *next_index == current_byte_index { bounds.next(); |