13894 Use Unicode Segmentation's graphemes

Add test with multi-character grapheme

Run cargo update
This commit is contained in:
Jesse Kipp 2016-10-23 21:33:25 -04:00
parent bfd966f819
commit 06db231f5f
7 changed files with 32 additions and 1 deletions

View file

@ -53,6 +53,7 @@ smallvec = "0.1"
string_cache = {version = "0.2.26", features = ["heap_size"], optional = true}
style_traits = {path = "../style_traits"}
time = "0.1"
unicode-segmentation = "0.1.2"
url = "1.2"
util = {path = "../util"}
plugins = {path = "../plugins", optional = true}

View file

@ -87,6 +87,8 @@ extern crate smallvec;
#[macro_use]
extern crate style_traits;
extern crate time;
#[allow(unused_extern_crates)]
extern crate unicode_segmentation;
extern crate url;
extern crate util;

View file

@ -741,6 +741,7 @@ ${helpers.single_keyword("text-align-last",
use computed_values::writing_mode::T as writing_mode;
use cssparser::ToCss;
use std::fmt;
use unicode_segmentation::UnicodeSegmentation;
use values::LocalToCss;
use values::NoViewportPercentage;
@ -889,7 +890,9 @@ ${helpers.single_keyword("text-align-last",
},
SpecifiedValue::None => computed_value::T::None,
SpecifiedValue::String(ref s) => {
let string = s.chars().next().as_ref().map(ToString::to_string).unwrap_or_default();
// Passing `true` to iterate over extended grapheme clusters, following
// recommendation at http://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries
let string = s.graphemes(true).next().unwrap_or("").to_string();
computed_value::T::String(string)
}
}