mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Move the definition of ServoThreadSafeLayoutNode::selection to script.
This commit is contained in:
parent
0f1f99a4bf
commit
093b7b7710
2 changed files with 19 additions and 11 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue