diff options
author | Bobby Holley <bobbyholley@gmail.com> | 2016-09-20 16:51:48 -0700 |
---|---|---|
committer | Bobby Holley <bobbyholley@gmail.com> | 2016-09-20 17:16:27 -0700 |
commit | e6bbff110a017019ac31cf0700b1e722d8a1c61b (patch) | |
tree | efb5493ebd4a202c1c53b40bf785b8b00becfc16 /components/script/layout_wrapper.rs | |
parent | 66c736194d1a6d3af1303a070aa96fec4534187c (diff) | |
download | servo-e6bbff110a017019ac31cf0700b1e722d8a1c61b.tar.gz servo-e6bbff110a017019ac31cf0700b1e722d8a1c61b.zip |
Split out is_element and is_text_node into a helper trait.
Diffstat (limited to 'components/script/layout_wrapper.rs')
-rw-r--r-- | components/script/layout_wrapper.rs | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/components/script/layout_wrapper.rs b/components/script/layout_wrapper.rs index 5411deb91a8..f8eb5236882 100644 --- a/components/script/layout_wrapper.rs +++ b/components/script/layout_wrapper.rs @@ -58,7 +58,7 @@ use style::attr::AttrValue; use style::computed_values::display; use style::context::SharedStyleContext; use style::data::PrivateStyleData; -use style::dom::{OpaqueNode, PresentationalHintsSynthetizer, TDocument, TElement, TNode, UnsafeNode}; +use style::dom::{NodeInfo, OpaqueNode, PresentationalHintsSynthetizer, TDocument, TElement, TNode, UnsafeNode}; use style::element_state::*; use style::properties::{ComputedValues, PropertyDeclarationBlock}; use style::refcell::{Ref, RefCell, RefMut}; @@ -111,6 +111,18 @@ impl<'ln> ServoLayoutNode<'ln> { } } +impl<'ln> NodeInfo for ServoLayoutNode<'ln> { + fn is_element(&self) -> bool { + unsafe { + self.node.is_element_for_layout() + } + } + + fn is_text_node(&self) -> bool { + self.script_type_id() == NodeTypeId::CharacterData(CharacterDataTypeId::Text) + } +} + impl<'ln> TNode for ServoLayoutNode<'ln> { type ConcreteElement = ServoLayoutElement<'ln>; type ConcreteDocument = ServoLayoutDocument<'ln>; @@ -128,16 +140,6 @@ impl<'ln> TNode for ServoLayoutNode<'ln> { transmute(node) } - fn is_text_node(&self) -> bool { - self.script_type_id() == NodeTypeId::CharacterData(CharacterDataTypeId::Text) - } - - fn is_element(&self) -> bool { - unsafe { - self.node.is_element_for_layout() - } - } - fn dump(self) { self.dump_indent(0); } @@ -727,6 +729,15 @@ impl<'ln> ServoThreadSafeLayoutNode<'ln> { } } +impl<'ln> NodeInfo for ServoThreadSafeLayoutNode<'ln> { + fn is_element(&self) -> bool { + if let Some(LayoutNodeType::Element(_)) = self.type_id() { true } else { false } + } + fn is_text_node(&self) -> bool { + if let Some(LayoutNodeType::Text) = self.type_id() { true } else { false } + } +} + impl<'ln> ThreadSafeLayoutNode for ServoThreadSafeLayoutNode<'ln> { type ConcreteThreadSafeLayoutElement = ServoThreadSafeLayoutElement<'ln>; type ChildrenIterator = ThreadSafeLayoutNodeChildrenIterator<Self>; |