mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
Replace range::Range with std::ops::Range in script
This commit is contained in:
parent
659305fe0a
commit
c4872d9544
9 changed files with 14 additions and 23 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue