mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
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>
This commit is contained in:
parent
93abdf7cb5
commit
3f93de7f54
3 changed files with 4 additions and 5 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -3741,7 +3741,6 @@ dependencies = [
|
||||||
"style_traits",
|
"style_traits",
|
||||||
"unicode-bidi",
|
"unicode-bidi",
|
||||||
"unicode-script",
|
"unicode-script",
|
||||||
"unicode-segmentation",
|
|
||||||
"url",
|
"url",
|
||||||
"webrender_api",
|
"webrender_api",
|
||||||
"webrender_traits",
|
"webrender_traits",
|
||||||
|
|
|
@ -47,7 +47,6 @@ style = { workspace = true }
|
||||||
style_traits = { workspace = true }
|
style_traits = { workspace = true }
|
||||||
unicode-bidi = { workspace = true }
|
unicode-bidi = { workspace = true }
|
||||||
unicode-script = { workspace = true }
|
unicode-script = { workspace = true }
|
||||||
unicode-segmentation = { workspace = true }
|
|
||||||
url = { workspace = true }
|
url = { workspace = true }
|
||||||
webrender_api = { workspace = true }
|
webrender_api = { workspace = true }
|
||||||
webrender_traits = { workspace = true }
|
webrender_traits = { workspace = true }
|
||||||
|
|
|
@ -5,11 +5,11 @@
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::char::{ToLowercase, ToUppercase};
|
use std::char::{ToLowercase, ToUppercase};
|
||||||
|
|
||||||
|
use icu_segmenter::WordSegmenter;
|
||||||
use style::computed_values::white_space_collapse::T as WhiteSpaceCollapse;
|
use style::computed_values::white_space_collapse::T as WhiteSpaceCollapse;
|
||||||
use style::values::computed::TextDecorationLine;
|
use style::values::computed::TextDecorationLine;
|
||||||
use style::values::specified::text::TextTransformCase;
|
use style::values::specified::text::TextTransformCase;
|
||||||
use unicode_bidi::Level;
|
use unicode_bidi::Level;
|
||||||
use unicode_segmentation::UnicodeSegmentation;
|
|
||||||
|
|
||||||
use super::text_run::TextRun;
|
use super::text_run::TextRun;
|
||||||
use super::{InlineBox, InlineBoxIdentifier, InlineBoxes, InlineFormattingContext, InlineItem};
|
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();
|
let mut output_string = String::new();
|
||||||
output_string.reserve(string.len());
|
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;
|
let mut byte_index = 0;
|
||||||
for character in string.chars() {
|
for character in string.chars() {
|
||||||
let current_byte_index = byte_index;
|
let current_byte_index = byte_index;
|
||||||
byte_index += character.len_utf8();
|
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 {
|
if *next_index == current_byte_index {
|
||||||
bounds.next();
|
bounds.next();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue