aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/textinput.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/textinput.rs')
-rw-r--r--components/script/textinput.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/components/script/textinput.rs b/components/script/textinput.rs
index 35b49ee57a4..343b114bf2d 100644
--- a/components/script/textinput.rs
+++ b/components/script/textinput.rs
@@ -8,6 +8,7 @@ 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;
@@ -154,6 +155,15 @@ impl<T: ClipboardProvider> TextInput<T> {
})
}
+ 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)
+ }
+ }
+
pub fn get_selection_text(&self) -> Option<String> {
self.get_sorted_selection().map(|(begin, end)| {
if begin.line != end.line {