aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmltextareaelement.rs
diff options
context:
space:
mode:
authorMatt Brubeck <mbrubeck@limpet.net>2016-04-27 11:22:02 -0700
committerMatt Brubeck <mbrubeck@limpet.net>2016-04-28 14:32:14 -0700
commit659305fe0a8f94e950ca64fab5ccef9949abd295 (patch)
treeac836803ac3fba799a4b4f73c24b4d0d2d208d6f /components/script/dom/htmltextareaelement.rs
parentdba878dfb278619bf2d808c0c21758a937ec6bb7 (diff)
downloadservo-659305fe0a8f94e950ca64fab5ccef9949abd295.tar.gz
servo-659305fe0a8f94e950ca64fab5ccef9949abd295.zip
Use byte indices instead of char indices for text runs
Replace character indices with UTF-8 byte offsets throughout the code dealing with text shaping and breaking. This eliminates a lot of complexity when converting from one to the other, and interoperates better with the rest of the Rust ecosystem.
Diffstat (limited to 'components/script/dom/htmltextareaelement.rs')
-rw-r--r--components/script/dom/htmltextareaelement.rs13
1 files changed, 6 insertions, 7 deletions
diff --git a/components/script/dom/htmltextareaelement.rs b/components/script/dom/htmltextareaelement.rs
index d3eb7827031..739cb04eb15 100644
--- a/components/script/dom/htmltextareaelement.rs
+++ b/components/script/dom/htmltextareaelement.rs
@@ -47,7 +47,7 @@ pub trait LayoutHTMLTextAreaElementHelpers {
#[allow(unsafe_code)]
unsafe fn get_value_for_layout(self) -> String;
#[allow(unsafe_code)]
- unsafe fn get_absolute_selection_for_layout(self) -> Option<Range<usize>>;
+ unsafe fn selection_for_layout(self) -> Option<Range<usize>>;
#[allow(unsafe_code)]
fn get_cols(self) -> u32;
#[allow(unsafe_code)]
@@ -63,13 +63,12 @@ impl LayoutHTMLTextAreaElementHelpers for LayoutJS<HTMLTextAreaElement> {
#[allow(unrooted_must_root)]
#[allow(unsafe_code)]
- unsafe fn get_absolute_selection_for_layout(self) -> Option<Range<usize>> {
- if (*self.unsafe_get()).upcast::<Element>().focus_state() {
- Some((*self.unsafe_get()).textinput.borrow_for_layout()
- .get_absolute_selection_range())
- } else {
- None
+ unsafe fn selection_for_layout(self) -> Option<Range<usize>> {
+ if !(*self.unsafe_get()).upcast::<Element>().focus_state() {
+ return None;
}
+ let textinput = (*self.unsafe_get()).textinput.borrow_for_layout();
+ Some(textinput.get_absolute_selection_range())
}
#[allow(unsafe_code)]