diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-09-21 19:59:52 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-21 19:59:52 -0500 |
commit | 614e9ca840baacfa427ec78db99258a83b75e135 (patch) | |
tree | d6cb654bac3501ca10ae03db707375d94b275c12 /components/script_layout_interface/wrapper_traits.rs | |
parent | f357afc94ac437c4323bcc4d46c2767ccef73b73 (diff) | |
parent | 63124bab66b945dea16ece366a790a693c38a452 (diff) | |
download | servo-614e9ca840baacfa427ec78db99258a83b75e135.tar.gz servo-614e9ca840baacfa427ec78db99258a83b75e135.zip |
Auto merge of #13172 - bholley:display_enum, r=emilio
stylo: avoid traversing non element/text nodes in style and layout
r? @emilio
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13172)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script_layout_interface/wrapper_traits.rs')
-rw-r--r-- | components/script_layout_interface/wrapper_traits.rs | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/components/script_layout_interface/wrapper_traits.rs b/components/script_layout_interface/wrapper_traits.rs index 20ddca94cf4..dcb1f68cfb4 100644 --- a/components/script_layout_interface/wrapper_traits.rs +++ b/components/script_layout_interface/wrapper_traits.rs @@ -15,7 +15,7 @@ use std::sync::Arc; use string_cache::{Atom, Namespace}; use style::computed_values::display; use style::context::SharedStyleContext; -use style::dom::{PresentationalHintsSynthetizer, TNode}; +use style::dom::{LayoutIterator, NodeInfo, PresentationalHintsSynthetizer, TNode}; use style::dom::OpaqueNode; use style::properties::ServoComputedValues; use style::refcell::{Ref, RefCell}; @@ -81,10 +81,10 @@ pub trait LayoutNode: TNode { fn init_style_and_layout_data(&self, data: OpaqueStyleAndLayoutData); fn get_style_and_layout_data(&self) -> Option<OpaqueStyleAndLayoutData>; - fn rev_children(self) -> ReverseChildrenIterator<Self> { - ReverseChildrenIterator { + fn rev_children(self) -> LayoutIterator<ReverseChildrenIterator<Self>> { + LayoutIterator(ReverseChildrenIterator { current: self.last_child(), - } + }) } fn traverse_preorder(self) -> TreeIterator<Self> { @@ -137,7 +137,7 @@ impl<ConcreteNode> Iterator for TreeIterator<ConcreteNode> /// A thread-safe version of `LayoutNode`, used during flow construction. This type of layout /// node does not allow any parents or siblings of nodes to be accessed, to avoid races. -pub trait ThreadSafeLayoutNode: Clone + Copy + Sized + PartialEq { +pub trait ThreadSafeLayoutNode: Clone + Copy + NodeInfo + PartialEq + Sized { type ConcreteThreadSafeLayoutElement: ThreadSafeLayoutElement<ConcreteThreadSafeLayoutNode = Self> + ::selectors::Element<Impl=ServoSelectorImpl>; @@ -169,10 +169,7 @@ pub trait ThreadSafeLayoutNode: Clone + Copy + Sized + PartialEq { fn debug_id(self) -> usize; /// Returns an iterator over this node's children. - fn children(&self) -> Self::ChildrenIterator; - - #[inline] - fn is_element(&self) -> bool { if let Some(LayoutNodeType::Element(_)) = self.type_id() { true } else { false } } + fn children(&self) -> LayoutIterator<Self::ChildrenIterator>; /// If this is an element, accesses the element data. Fails if this is not an element node. #[inline] |