mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Introduce <LayoutDom<Element>>::focus_state
This commit is contained in:
parent
295f120425
commit
28e5abe606
3 changed files with 14 additions and 2 deletions
|
@ -592,6 +592,18 @@ pub trait LayoutElementHelpers<'dom> {
|
|||
fn get_attr_vals_for_layout(self, name: &LocalName) -> Vec<&'dom AttrValue>;
|
||||
}
|
||||
|
||||
impl<'dom> LayoutDom<'dom, Element> {
|
||||
#[allow(unsafe_code)]
|
||||
pub(super) fn focus_state(self) -> bool {
|
||||
unsafe {
|
||||
self.unsafe_get()
|
||||
.state
|
||||
.get()
|
||||
.contains(ElementState::IN_FOCUS_STATE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'dom> LayoutElementHelpers<'dom> for LayoutDom<'dom, Element> {
|
||||
#[allow(unsafe_code)]
|
||||
#[inline]
|
||||
|
|
|
@ -780,7 +780,7 @@ impl<'dom> LayoutHTMLInputElementHelpers<'dom> for LayoutDom<'dom, HTMLInputElem
|
|||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn selection_for_layout(self) -> Option<Range<usize>> {
|
||||
if !(*self.unsafe_get()).upcast::<Element>().focus_state() {
|
||||
if !self.upcast::<Element>().focus_state() {
|
||||
return None;
|
||||
}
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ impl LayoutHTMLTextAreaElementHelpers for LayoutDom<'_, HTMLTextAreaElement> {
|
|||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn selection_for_layout(self) -> Option<Range<usize>> {
|
||||
if !(*self.unsafe_get()).upcast::<Element>().focus_state() {
|
||||
if !self.upcast::<Element>().focus_state() {
|
||||
return None;
|
||||
}
|
||||
let textinput = (*self.unsafe_get()).textinput.borrow_for_layout();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue