diff options
Diffstat (limited to 'components/script/textinput.rs')
-rw-r--r-- | components/script/textinput.rs | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/components/script/textinput.rs b/components/script/textinput.rs index ffd707c5d27..56e3fa98631 100644 --- a/components/script/textinput.rs +++ b/components/script/textinput.rs @@ -8,10 +8,10 @@ use clipboard_provider::ClipboardProvider; use dom::keyboardevent::{KeyboardEvent, key_value}; use msg::constellation_msg::{ALT, CONTROL, SHIFT, SUPER}; use msg::constellation_msg::{Key, KeyModifiers}; -use range::Range; use std::borrow::ToOwned; use std::cmp::{max, min}; use std::default::Default; +use std::ops::Range; use std::usize; use util::str::DOMString; @@ -220,10 +220,12 @@ impl<T: ClipboardProvider> TextInput<T> { /// If there is no selection, returns an empty range at the insertion point. pub fn get_absolute_selection_range(&self) -> Range<usize> { match self.get_sorted_selection() { - Some((begin, _end)) => - Range::new(self.get_absolute_point_for_text_point(&begin), self.selection_len()), - None => - Range::new(self.get_absolute_insertion_point(), 0) + Some((begin, end)) => self.get_absolute_point_for_text_point(&begin) .. + self.get_absolute_point_for_text_point(&end), + None => { + let insertion_point = self.get_absolute_insertion_point(); + insertion_point .. insertion_point + } } } @@ -235,11 +237,6 @@ impl<T: ClipboardProvider> TextInput<T> { Some(text) } - /// The length of the selected text in UTF-8 bytes. - fn selection_len(&self) -> usize { - self.fold_selection_slices(0, |len, slice| *len += slice.len()) - } - /// The length of the selected text in UTF-16 code units. fn selection_utf16_len(&self) -> usize { self.fold_selection_slices(0usize, |