diff options
-rw-r--r-- | components/servo/Cargo.lock | 7 | ||||
-rw-r--r-- | components/style/Cargo.toml | 1 | ||||
-rw-r--r-- | components/style/lib.rs | 2 | ||||
-rw-r--r-- | components/style/properties/longhand/inherited_text.mako.rs | 5 | ||||
-rw-r--r-- | ports/cef/Cargo.lock | 7 | ||||
-rw-r--r-- | ports/geckolib/Cargo.lock | 7 | ||||
-rw-r--r-- | tests/unit/style/parsing/inherited_text.rs | 4 |
7 files changed, 32 insertions, 1 deletions
diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock index 9b02c390859..211f46106ee 100644 --- a/components/servo/Cargo.lock +++ b/components/servo/Cargo.lock @@ -2300,6 +2300,7 @@ dependencies = [ "string_cache 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)", "style_traits 0.0.1", "time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-segmentation 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "util 0.0.1", "walkdir 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2474,6 +2475,11 @@ dependencies = [ ] [[package]] +name = "unicode-segmentation" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] name = "unicode-xid" version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2987,6 +2993,7 @@ dependencies = [ "checksum unicode-bidi 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c1f7ceb96afdfeedee42bade65a0d585a6a0106f681b6749c8ff4daa8df30b3f" "checksum unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "26643a2f83bac55f1976fb716c10234485f9202dcd65cfbdf9da49867b271172" "checksum unicode-script 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e5430ae21ef212551680d0021fc7dbd936e8b268c5ea8fdae8814e0b2496d80f" +"checksum unicode-segmentation 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b905d0fc2a1f0befd86b0e72e31d1787944efef9d38b9358a9e92a69757f7e3b" "checksum unicode-xid 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "36dff09cafb4ec7c8cf0023eb0b686cb6ce65499116a12201c9e11840ca01beb" "checksum unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1f2ae5ddb18e1c92664717616dd9549dde73f539f01bd7b77c2edb2446bdff91" "checksum url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "afe9ec54bc4db14bc8744b7fed060d785ac756791450959b2248443319d5b119" diff --git a/components/style/Cargo.toml b/components/style/Cargo.toml index 77eff5926ac..17872258f07 100644 --- a/components/style/Cargo.toml +++ b/components/style/Cargo.toml @@ -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} diff --git a/components/style/lib.rs b/components/style/lib.rs index 1d9ac21be93..53d8102b6fa 100644 --- a/components/style/lib.rs +++ b/components/style/lib.rs @@ -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; diff --git a/components/style/properties/longhand/inherited_text.mako.rs b/components/style/properties/longhand/inherited_text.mako.rs index 2d9c93dc836..e775c3d588d 100644 --- a/components/style/properties/longhand/inherited_text.mako.rs +++ b/components/style/properties/longhand/inherited_text.mako.rs @@ -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) } } diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock index 268c5b610c6..1e44021bfbf 100644 --- a/ports/cef/Cargo.lock +++ b/ports/cef/Cargo.lock @@ -2183,6 +2183,7 @@ dependencies = [ "string_cache 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)", "style_traits 0.0.1", "time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-segmentation 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "util 0.0.1", "walkdir 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2339,6 +2340,11 @@ dependencies = [ ] [[package]] +name = "unicode-segmentation" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] name = "unicode-xid" version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2839,6 +2845,7 @@ dependencies = [ "checksum unicode-bidi 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c1f7ceb96afdfeedee42bade65a0d585a6a0106f681b6749c8ff4daa8df30b3f" "checksum unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "26643a2f83bac55f1976fb716c10234485f9202dcd65cfbdf9da49867b271172" "checksum unicode-script 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e5430ae21ef212551680d0021fc7dbd936e8b268c5ea8fdae8814e0b2496d80f" +"checksum unicode-segmentation 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b905d0fc2a1f0befd86b0e72e31d1787944efef9d38b9358a9e92a69757f7e3b" "checksum unicode-xid 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "36dff09cafb4ec7c8cf0023eb0b686cb6ce65499116a12201c9e11840ca01beb" "checksum unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1f2ae5ddb18e1c92664717616dd9549dde73f539f01bd7b77c2edb2446bdff91" "checksum url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "afe9ec54bc4db14bc8744b7fed060d785ac756791450959b2248443319d5b119" diff --git a/ports/geckolib/Cargo.lock b/ports/geckolib/Cargo.lock index 48090925a69..b8ab9212803 100644 --- a/ports/geckolib/Cargo.lock +++ b/ports/geckolib/Cargo.lock @@ -394,6 +394,7 @@ dependencies = [ "smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "style_traits 0.0.1", "time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-segmentation 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "util 0.0.1", "walkdir 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -470,6 +471,11 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] +name = "unicode-segmentation" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] name = "unreachable" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -587,6 +593,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)" = "3c7ec6d62a20df54e07ab3b78b9a3932972f4b7981de295563686849eb3989af" "checksum unicode-bidi 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c1f7ceb96afdfeedee42bade65a0d585a6a0106f681b6749c8ff4daa8df30b3f" "checksum unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "26643a2f83bac55f1976fb716c10234485f9202dcd65cfbdf9da49867b271172" +"checksum unicode-segmentation 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b905d0fc2a1f0befd86b0e72e31d1787944efef9d38b9358a9e92a69757f7e3b" "checksum unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1f2ae5ddb18e1c92664717616dd9549dde73f539f01bd7b77c2edb2446bdff91" "checksum url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "afe9ec54bc4db14bc8744b7fed060d785ac756791450959b2248443319d5b119" "checksum utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1ca13c08c41c9c3e04224ed9ff80461d97e121589ff27c753a16cb10830ae0f" diff --git a/tests/unit/style/parsing/inherited_text.rs b/tests/unit/style/parsing/inherited_text.rs index 4248107b0c0..1154e4b6bd5 100644 --- a/tests/unit/style/parsing/inherited_text.rs +++ b/tests/unit/style/parsing/inherited_text.rs @@ -43,4 +43,8 @@ fn text_emphasis_style_longhand_should_parse_properly() { let unicode_string = parse_longhand!(text_emphasis_style, "\"\\25B2\""); let unicode_string_struct = SpecifiedValue::String("▲".to_string()); assert_eq!(unicode_string, unicode_string_struct); + + let devanagari_string = parse_longhand!(text_emphasis_style, "\"षि\""); + let devanagari_string_struct = SpecifiedValue::String("षि".to_string()); + assert_eq!(devanagari_string, devanagari_string_struct); } |