aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmltextareaelement.rs
diff options
context:
space:
mode:
authorAnthony Ramine <nox@nox.paris>2020-04-01 11:35:07 +0200
committerAnthony Ramine <nox@nox.paris>2020-04-01 11:40:56 +0200
commitd9e4f7a0ba3f5853174d1aa0185932de9cb5ae06 (patch)
tree8c8e31d12678a36e692b3271025984614fd1a3aa /components/script/dom/htmltextareaelement.rs
parent28e5abe60667653464336ce04a274a907c807d83 (diff)
downloadservo-d9e4f7a0ba3f5853174d1aa0185932de9cb5ae06.tar.gz
servo-d9e4f7a0ba3f5853174d1aa0185932de9cb5ae06.zip
Introduce more layout helpers to make selection_for_layout be safe
Diffstat (limited to 'components/script/dom/htmltextareaelement.rs')
-rwxr-xr-xcomponents/script/dom/htmltextareaelement.rs18
1 files changed, 12 insertions, 6 deletions
diff --git a/components/script/dom/htmltextareaelement.rs b/components/script/dom/htmltextareaelement.rs
index 1cfd6903302..38fa642ca4c 100755
--- a/components/script/dom/htmltextareaelement.rs
+++ b/components/script/dom/htmltextareaelement.rs
@@ -57,8 +57,7 @@ pub struct HTMLTextAreaElement {
pub trait LayoutHTMLTextAreaElementHelpers {
fn value_for_layout(self) -> String;
- #[allow(unsafe_code)]
- unsafe fn selection_for_layout(self) -> Option<Range<usize>>;
+ fn selection_for_layout(self) -> Option<Range<usize>>;
fn get_cols(self) -> u32;
fn get_rows(self) -> u32;
}
@@ -74,6 +73,15 @@ impl<'dom> LayoutDom<'dom, HTMLTextAreaElement> {
}
}
+ fn textinput_sorted_selection_offsets_range(self) -> Range<UTF8Bytes> {
+ unsafe {
+ self.unsafe_get()
+ .textinput
+ .borrow_for_layout()
+ .sorted_selection_offsets_range()
+ }
+ }
+
fn placeholder(self) -> &'dom str {
unsafe { self.unsafe_get().placeholder.borrow_for_layout() }
}
@@ -94,14 +102,12 @@ impl LayoutHTMLTextAreaElementHelpers for LayoutDom<'_, HTMLTextAreaElement> {
}
}
- #[allow(unsafe_code)]
- unsafe fn selection_for_layout(self) -> Option<Range<usize>> {
+ fn selection_for_layout(self) -> Option<Range<usize>> {
if !self.upcast::<Element>().focus_state() {
return None;
}
- let textinput = (*self.unsafe_get()).textinput.borrow_for_layout();
Some(UTF8Bytes::unwrap_range(
- textinput.sorted_selection_offsets_range(),
+ self.textinput_sorted_selection_offsets_range(),
))
}