Introduce more layout helpers to make selection_for_layout be safe

This commit is contained in:
Anthony Ramine 2020-04-01 11:35:07 +02:00
parent 28e5abe606
commit d9e4f7a0ba
3 changed files with 30 additions and 18 deletions

View file

@ -1478,14 +1478,13 @@ impl<'dom> LayoutNodeHelpers<'dom> for LayoutDom<'dom, Node> {
panic!("not text!")
}
#[allow(unsafe_code)]
fn selection(self) -> Option<Range<usize>> {
if let Some(area) = self.downcast::<HTMLTextAreaElement>() {
return unsafe { area.selection_for_layout() };
return area.selection_for_layout();
}
if let Some(input) = self.downcast::<HTMLInputElement>() {
return unsafe { input.selection_for_layout() };
return input.selection_for_layout();
}
None