Move the definition of ServoThreadSafeLayoutNode::selection to script.

This commit is contained in:
Ms2ger 2016-06-07 10:30:52 +02:00
parent 0f1f99a4bf
commit 093b7b7710
2 changed files with 19 additions and 11 deletions

View file

@ -68,6 +68,7 @@ use std::cmp::max;
use std::default::Default;
use std::iter::{self, FilterMap, Peekable};
use std::mem;
use std::ops::Range;
use string_cache::{Atom, Namespace, QualName};
use style::selector_impl::ServoSelectorImpl;
use util::thread_state;
@ -960,6 +961,7 @@ pub trait LayoutNodeHelpers {
unsafe fn init_style_and_layout_data(&self, OpaqueStyleAndLayoutData);
fn text_content(&self) -> String;
fn selection(&self) -> Option<Range<usize>>;
}
impl LayoutNodeHelpers for LayoutJS<Node> {
@ -1067,6 +1069,19 @@ impl LayoutNodeHelpers for LayoutJS<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() };
}
if let Some(input) = self.downcast::<HTMLInputElement>() {
return unsafe { input.selection_for_layout() };
}
None
}
}