diff options
author | Matt Brubeck <mbrubeck@limpet.net> | 2016-04-28 14:52:02 -0700 |
---|---|---|
committer | Matt Brubeck <mbrubeck@limpet.net> | 2016-04-28 14:54:07 -0700 |
commit | c4872d95445636ef4dec45cbfc5c2d643c4b9441 (patch) | |
tree | e264cb26ec0ff6ece0b5f503d5f438d33d755c00 /components/script/textinput.rs | |
parent | 659305fe0a8f94e950ca64fab5ccef9949abd295 (diff) | |
download | servo-c4872d95445636ef4dec45cbfc5c2d643c4b9441.tar.gz servo-c4872d95445636ef4dec45cbfc5c2d643c4b9441.zip |
Replace range::Range with std::ops::Range in script
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, |