mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
Move the flag getters to LayoutNodeHelpers.
This commit is contained in:
parent
32ee62b4c8
commit
849eb7837a
2 changed files with 26 additions and 34 deletions
|
@ -53,7 +53,7 @@ use script::dom::htmlimageelement::LayoutHTMLImageElementHelpers;
|
||||||
use script::dom::htmlinputelement::{HTMLInputElement, LayoutHTMLInputElementHelpers};
|
use script::dom::htmlinputelement::{HTMLInputElement, LayoutHTMLInputElementHelpers};
|
||||||
use script::dom::htmltextareaelement::LayoutHTMLTextAreaElementHelpers;
|
use script::dom::htmltextareaelement::LayoutHTMLTextAreaElementHelpers;
|
||||||
use script::dom::node::{Node, NodeTypeId};
|
use script::dom::node::{Node, NodeTypeId};
|
||||||
use script::dom::node::{LayoutNodeHelpers, RawLayoutNodeHelpers, SharedLayoutData};
|
use script::dom::node::{LayoutNodeHelpers, SharedLayoutData};
|
||||||
use script::dom::node::{HAS_CHANGED, IS_DIRTY, HAS_DIRTY_SIBLINGS, HAS_DIRTY_DESCENDANTS};
|
use script::dom::node::{HAS_CHANGED, IS_DIRTY, HAS_DIRTY_SIBLINGS, HAS_DIRTY_DESCENDANTS};
|
||||||
use script::dom::text::Text;
|
use script::dom::text::Text;
|
||||||
use smallvec::VecLike;
|
use smallvec::VecLike;
|
||||||
|
@ -439,17 +439,13 @@ impl<'le> ::selectors::Element for LayoutElement<'le> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_hover_state(&self) -> bool {
|
fn get_hover_state(&self) -> bool {
|
||||||
let node = NodeCast::from_layout_js(&self.element);
|
let node = NodeCast::from_layout_js(&self.element);
|
||||||
unsafe {
|
node.get_hover_state_for_layout()
|
||||||
(*node.unsafe_get()).get_hover_state_for_layout()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_focus_state(&self) -> bool {
|
fn get_focus_state(&self) -> bool {
|
||||||
let node = NodeCast::from_layout_js(&self.element);
|
let node = NodeCast::from_layout_js(&self.element);
|
||||||
unsafe {
|
node.get_focus_state_for_layout()
|
||||||
(*node.unsafe_get()).get_focus_state_for_layout()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -462,17 +458,13 @@ impl<'le> ::selectors::Element for LayoutElement<'le> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_disabled_state(&self) -> bool {
|
fn get_disabled_state(&self) -> bool {
|
||||||
let node = NodeCast::from_layout_js(&self.element);
|
let node = NodeCast::from_layout_js(&self.element);
|
||||||
unsafe {
|
node.get_disabled_state_for_layout()
|
||||||
(*node.unsafe_get()).get_disabled_state_for_layout()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_enabled_state(&self) -> bool {
|
fn get_enabled_state(&self) -> bool {
|
||||||
let node = NodeCast::from_layout_js(&self.element);
|
let node = NodeCast::from_layout_js(&self.element);
|
||||||
unsafe {
|
node.get_enabled_state_for_layout()
|
||||||
(*node.unsafe_get()).get_enabled_state_for_layout()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -1085,6 +1085,11 @@ pub trait LayoutNodeHelpers {
|
||||||
unsafe fn layout_data_mut(&self) -> RefMut<Option<LayoutData>>;
|
unsafe fn layout_data_mut(&self) -> RefMut<Option<LayoutData>>;
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
unsafe fn layout_data_unchecked(&self) -> *const Option<LayoutData>;
|
unsafe fn layout_data_unchecked(&self) -> *const Option<LayoutData>;
|
||||||
|
|
||||||
|
fn get_hover_state_for_layout(&self) -> bool;
|
||||||
|
fn get_focus_state_for_layout(&self) -> bool;
|
||||||
|
fn get_disabled_state_for_layout(&self) -> bool;
|
||||||
|
fn get_enabled_state_for_layout(&self) -> bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LayoutNodeHelpers for LayoutJS<Node> {
|
impl LayoutNodeHelpers for LayoutJS<Node> {
|
||||||
|
@ -1174,39 +1179,34 @@ impl LayoutNodeHelpers for LayoutJS<Node> {
|
||||||
unsafe fn layout_data_unchecked(&self) -> *const Option<LayoutData> {
|
unsafe fn layout_data_unchecked(&self) -> *const Option<LayoutData> {
|
||||||
(*self.unsafe_get()).layout_data.borrow_unchecked()
|
(*self.unsafe_get()).layout_data.borrow_unchecked()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
pub trait RawLayoutNodeHelpers {
|
|
||||||
#[allow(unsafe_code)]
|
|
||||||
unsafe fn get_hover_state_for_layout(&self) -> bool;
|
|
||||||
#[allow(unsafe_code)]
|
|
||||||
unsafe fn get_focus_state_for_layout(&self) -> bool;
|
|
||||||
#[allow(unsafe_code)]
|
|
||||||
unsafe fn get_disabled_state_for_layout(&self) -> bool;
|
|
||||||
#[allow(unsafe_code)]
|
|
||||||
unsafe fn get_enabled_state_for_layout(&self) -> bool;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RawLayoutNodeHelpers for Node {
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
unsafe fn get_hover_state_for_layout(&self) -> bool {
|
fn get_hover_state_for_layout(&self) -> bool {
|
||||||
self.flags.get().contains(IN_HOVER_STATE)
|
unsafe {
|
||||||
|
self.get_flag(IN_HOVER_STATE)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
unsafe fn get_focus_state_for_layout(&self) -> bool {
|
fn get_focus_state_for_layout(&self) -> bool {
|
||||||
self.flags.get().contains(IN_FOCUS_STATE)
|
unsafe {
|
||||||
|
self.get_flag(IN_FOCUS_STATE)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
unsafe fn get_disabled_state_for_layout(&self) -> bool {
|
fn get_disabled_state_for_layout(&self) -> bool {
|
||||||
self.flags.get().contains(IN_DISABLED_STATE)
|
unsafe {
|
||||||
|
self.get_flag(IN_DISABLED_STATE)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
unsafe fn get_enabled_state_for_layout(&self) -> bool {
|
fn get_enabled_state_for_layout(&self) -> bool {
|
||||||
self.flags.get().contains(IN_ENABLED_STATE)
|
unsafe {
|
||||||
|
self.get_flag(IN_ENABLED_STATE)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue