From 024571dfa38dbe63cb2a591571e2465b5d882686 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Thu, 22 Jan 2015 13:49:10 +0100 Subject: [PATCH] Use chars().count() rather than char_len(). The latter is obsolete in current Rust. --- components/gfx/font.rs | 2 +- components/gfx/text/shaping/harfbuzz.rs | 2 +- components/layout/text.rs | 4 ++-- components/script/dom/htmlinputelement.rs | 2 +- components/script/textinput.rs | 8 ++++---- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/components/gfx/font.rs b/components/gfx/font.rs index 708a6f4b93d..653eff5e5f3 100644 --- a/components/gfx/font.rs +++ b/components/gfx/font.rs @@ -157,7 +157,7 @@ impl Font { Some(glyphs) => return (*glyphs).clone(), } - let mut glyphs = GlyphStore::new(text.char_len() as int, + let mut glyphs = GlyphStore::new(text.chars().count() as int, options.flags.contains(IS_WHITESPACE_SHAPING_FLAG)); shaper.as_ref().unwrap().shape_text(text, options, &mut glyphs); diff --git a/components/gfx/text/shaping/harfbuzz.rs b/components/gfx/text/shaping/harfbuzz.rs index e02f15bdc45..98b287ba086 100644 --- a/components/gfx/text/shaping/harfbuzz.rs +++ b/components/gfx/text/shaping/harfbuzz.rs @@ -274,7 +274,7 @@ impl Shaper { let glyph_data = ShapedGlyphData::new(buffer); let glyph_count = glyph_data.len(); let byte_max = text.len() as int; - let char_max = text.char_len() as int; + let char_max = text.chars().count() as int; // GlyphStore records are indexed by character, not byte offset. // so, we must be careful to increment this when saving glyph entries. diff --git a/components/layout/text.rs b/components/layout/text.rs index f57aee50f7b..324604281b4 100644 --- a/components/layout/text.rs +++ b/components/layout/text.rs @@ -138,7 +138,7 @@ impl TextRunScanner { }; let mut new_line_pos = Vec::new(); - let old_length = CharIndex(run_text.as_slice().char_len() as int); + let old_length = CharIndex(run_text.chars().count() as int); last_whitespace = util::transform_text(in_fragment.as_slice(), compression, last_whitespace, @@ -146,7 +146,7 @@ impl TextRunScanner { &mut new_line_pos); new_line_positions.push(NewLinePositions(new_line_pos)); - let added_chars = CharIndex(run_text.as_slice().char_len() as int) - old_length; + let added_chars = CharIndex(run_text.chars().count() as int) - old_length; new_ranges.push(Range::new(char_total, added_chars)); char_total = char_total + added_chars; } diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs index 55f7a102ce3..507f6d05818 100644 --- a/components/script/dom/htmlinputelement.rs +++ b/components/script/dom/htmlinputelement.rs @@ -161,7 +161,7 @@ impl LayoutHTMLInputElementHelpers for JS { InputType::InputReset => get_raw_attr_value(self).unwrap_or_else(|| DEFAULT_RESET_VALUE.to_owned()), InputType::InputPassword => { let raw = get_raw_textinput_value(self); - String::from_char(raw.char_len(), '●') + raw.chars().map(|_| '●').collect() } _ => get_raw_textinput_value(self), } diff --git a/components/script/textinput.rs b/components/script/textinput.rs index c2c183d022c..4c4226738cf 100644 --- a/components/script/textinput.rs +++ b/components/script/textinput.rs @@ -135,7 +135,7 @@ impl TextInput { let new_lines = { let prefix = self.lines[begin.line].slice_chars(0, begin.index); - let suffix = self.lines[end.line].slice_chars(end.index, self.lines[end.line].char_len()); + let suffix = self.lines[end.line].slice_chars(end.index, self.lines[end.line].chars().count()); let lines_prefix = self.lines.slice(0, begin.line); let lines_suffix = self.lines.slice(end.line + 1, self.lines.len()); @@ -150,7 +150,7 @@ impl TextInput { insert_lines[0] = new_line; let last_insert_lines_index = insert_lines.len() - 1; - self.edit_point.index = insert_lines[last_insert_lines_index].char_len(); + self.edit_point.index = insert_lines[last_insert_lines_index].chars().count(); self.edit_point.line = begin.line + last_insert_lines_index; insert_lines[last_insert_lines_index].push_str(suffix); @@ -167,7 +167,7 @@ impl TextInput { /// Return the length of the current line under the editing point. fn current_line_length(&self) -> uint { - self.lines[self.edit_point.line].char_len() + self.lines[self.edit_point.line].chars().count() } /// Adjust the editing point position by a given of lines. The resulting column is @@ -260,7 +260,7 @@ impl TextInput { }); let last_line = self.lines.len() - 1; self.edit_point.line = last_line; - self.edit_point.index = self.lines[last_line].char_len(); + self.edit_point.index = self.lines[last_line].chars().count(); } /// Remove the current selection.