mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Auto merge of #7251 - nox:text-transform-length-change, r=SimonSapin
Correctly handle length-changing mappings in text-transform <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7251) <!-- Reviewable:end -->
This commit is contained in:
commit
39b7508aa2
5 changed files with 27 additions and 9 deletions
|
@ -503,8 +503,9 @@ impl RunMapping {
|
|||
|
||||
/// Accounts for `text-transform`.
|
||||
///
|
||||
/// FIXME(#4311, pcwalton): Case mapping can change length of the string; case mapping should
|
||||
/// be language-specific; `full-width`; use graphemes instead of characters.
|
||||
/// FIXME(#4311, pcwalton): Title-case mapping can change length of the string;
|
||||
/// case mapping should be language-specific; `full-width`;
|
||||
/// use graphemes instead of characters.
|
||||
fn apply_style_transform_if_necessary(string: &mut String,
|
||||
first_character_position: usize,
|
||||
text_transform: text_transform::T)
|
||||
|
@ -515,8 +516,8 @@ fn apply_style_transform_if_necessary(string: &mut String,
|
|||
let original = string[first_character_position..].to_owned();
|
||||
string.truncate(first_character_position);
|
||||
let mut count = 0;
|
||||
for character in original.chars() {
|
||||
string.push(character.to_uppercase().next().unwrap());
|
||||
for ch in original.chars().flat_map(|ch| ch.to_uppercase()) {
|
||||
string.push(ch);
|
||||
count += 1;
|
||||
}
|
||||
count
|
||||
|
@ -525,8 +526,8 @@ fn apply_style_transform_if_necessary(string: &mut String,
|
|||
let original = string[first_character_position..].to_owned();
|
||||
string.truncate(first_character_position);
|
||||
let mut count = 0;
|
||||
for character in original.chars() {
|
||||
string.push(character.to_lowercase().next().unwrap());
|
||||
for ch in original.chars().flat_map(|ch| ch.to_lowercase()) {
|
||||
string.push(ch);
|
||||
count += 1;
|
||||
}
|
||||
count
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue