diff options
-rw-r--r-- | components/layout/traversal.rs | 15 | ||||
-rw-r--r-- | components/script/dom/node.rs | 12 | ||||
-rw-r--r-- | components/script/layout_wrapper.rs | 19 | ||||
-rw-r--r-- | components/script_layout_interface/lib.rs | 6 | ||||
-rw-r--r-- | components/script_layout_interface/wrapper_traits.rs | 2 |
5 files changed, 18 insertions, 36 deletions
diff --git a/components/layout/traversal.rs b/components/layout/traversal.rs index 3ec1f2f85a5..849e7b2087a 100644 --- a/components/layout/traversal.rs +++ b/components/layout/traversal.rs @@ -118,16 +118,13 @@ impl<'lc, N> DomTraversalContext<N> for RecalcStyleAndConstructFlows<'lc> return false; } - // If this node has been marked as damaged in some way, we need to - // traverse it for layout. - if child.has_changed() { - return true; - } - match child.as_element() { - Some(el) => el.styling_mode() != StylingMode::Stop, - // Aside from the has_changed case above, we want to traverse non-element children - // in two additional cases: + // Elements should be traversed if they need styling or flow construction. + Some(el) => el.styling_mode() != StylingMode::Stop || + el.as_node().to_threadsafe().restyle_damage() != RestyleDamage::empty(), + + // Text nodes never need styling. However, there are two cases they may need + // flow construction: // (1) They child doesn't yet have layout data (preorder traversal initializes it). // (2) The parent element has restyle damage (so the text flow also needs fixup). None => child.get_raw_data().is_none() || diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 5ef7a79ea48..dbe32a167b8 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -143,8 +143,6 @@ bitflags! { pub flags NodeFlags: u8 { #[doc = "Specifies whether this node is in a document."] const IS_IN_DOC = 0x01, - #[doc = "Specifies whether this node _must_ be reflowed regardless of style differences."] - const HAS_CHANGED = 0x02, #[doc = "Specifies whether this node needs style recalc on next reflow."] const IS_DIRTY = 0x04, #[doc = "Specifies whether this node has descendants (inclusive of itself) which \ @@ -169,7 +167,7 @@ bitflags! { impl NodeFlags { pub fn new() -> NodeFlags { - HAS_CHANGED | IS_DIRTY | HAS_DIRTY_DESCENDANTS + IS_DIRTY | HAS_DIRTY_DESCENDANTS } } @@ -422,14 +420,6 @@ impl Node { self.flags.set(flags); } - pub fn has_changed(&self) -> bool { - self.get_flag(HAS_CHANGED) - } - - pub fn set_has_changed(&self, state: bool) { - self.set_flag(HAS_CHANGED, state) - } - pub fn is_dirty(&self) -> bool { self.get_flag(IS_DIRTY) } diff --git a/components/script/layout_wrapper.rs b/components/script/layout_wrapper.rs index 9a46b65d92a..5dd5e5082ce 100644 --- a/components/script/layout_wrapper.rs +++ b/components/script/layout_wrapper.rs @@ -36,7 +36,7 @@ use dom::bindings::js::LayoutJS; use dom::characterdata::LayoutCharacterDataHelpers; use dom::document::{Document, LayoutDocumentHelpers, PendingRestyle}; use dom::element::{Element, LayoutElementHelpers, RawLayoutElementHelpers}; -use dom::node::{CAN_BE_FRAGMENTED, DIRTY_ON_VIEWPORT_SIZE_CHANGE, HAS_CHANGED, HAS_DIRTY_DESCENDANTS, IS_DIRTY}; +use dom::node::{CAN_BE_FRAGMENTED, DIRTY_ON_VIEWPORT_SIZE_CHANGE, HAS_DIRTY_DESCENDANTS, IS_DIRTY}; use dom::node::{LayoutNodeHelpers, Node}; use dom::text::Text; use gfx_traits::ByteIndex; @@ -62,7 +62,7 @@ use style::computed_values::display; use style::context::SharedStyleContext; use style::data::ElementData; use style::dom::{LayoutIterator, NodeInfo, OpaqueNode, PresentationalHintsSynthetizer, TElement, TNode}; -use style::dom::{TRestyleDamage, UnsafeNode}; +use style::dom::UnsafeNode; use style::element_state::*; use style::properties::{ComputedValues, PropertyDeclarationBlock}; use style::selector_impl::{NonTSPseudoClass, PseudoElement, RestyleDamage, ServoSelectorImpl}; @@ -259,12 +259,7 @@ impl<'ln> LayoutNode for ServoLayoutNode<'ln> { self.get_jsmanaged().take_style_and_layout_data() } - fn has_changed(&self) -> bool { - unsafe { self.node.get_flag(HAS_CHANGED) } - } - unsafe fn clear_dirty_bits(&self) { - self.node.set_flag(HAS_CHANGED, false); self.node.set_flag(IS_DIRTY, false); self.node.set_flag(HAS_DIRTY_DESCENDANTS, false); } @@ -335,8 +330,8 @@ impl<'ln> ServoLayoutNode<'ln> { } fn debug_str(self) -> String { - format!("{:?}: changed={} dirty={} dirty_descendants={}", - self.script_type_id(), self.has_changed(), + format!("{:?}: dirty={} dirty_descendants={}", + self.script_type_id(), self.as_element().map_or(false, |el| el.deprecated_dirty_bit_is_set()), self.as_element().map_or(false, |el| el.has_dirty_descendants())) } @@ -453,7 +448,7 @@ impl<'le> TElement for ServoLayoutElement<'le> { } fn set_restyle_damage(self, damage: RestyleDamage) { - self.get_partial_layout_data().unwrap().borrow_mut().restyle_damage = damage; + self.get_partial_layout_data().unwrap().borrow_mut().restyle_damage |= damage; } #[inline] @@ -879,9 +874,7 @@ impl<'ln> ThreadSafeLayoutNode for ServoThreadSafeLayoutNode<'ln> { } fn restyle_damage(self) -> RestyleDamage { - if self.node.has_changed() { - RestyleDamage::rebuild_and_reflow() - } else if self.is_text_node() { + if self.is_text_node() { let parent = self.node.parent_node().unwrap().as_element().unwrap(); let parent_data = parent.get_partial_layout_data().unwrap().borrow(); parent_data.restyle_damage diff --git a/components/script_layout_interface/lib.rs b/components/script_layout_interface/lib.rs index 284f6f33498..ff86579631c 100644 --- a/components/script_layout_interface/lib.rs +++ b/components/script_layout_interface/lib.rs @@ -51,6 +51,7 @@ use libc::c_void; use std::sync::atomic::AtomicIsize; use style::atomic_refcell::AtomicRefCell; use style::data::ElementData; +use style::dom::TRestyleDamage; use style::selector_impl::RestyleDamage; pub struct PartialPersistentLayoutData { @@ -71,7 +72,10 @@ impl PartialPersistentLayoutData { pub fn new() -> Self { PartialPersistentLayoutData { style_data: ElementData::new(), - restyle_damage: RestyleDamage::empty(), + // FIXME(bholley): This is needed for now to make sure we do frame + // construction after initial styling. This will go away shortly when + // we move restyle damage into the style system. + restyle_damage: RestyleDamage::rebuild_and_reflow(), parallel: DomParallelInfo::new(), } } diff --git a/components/script_layout_interface/wrapper_traits.rs b/components/script_layout_interface/wrapper_traits.rs index 8de7d757be1..283e8def80a 100644 --- a/components/script_layout_interface/wrapper_traits.rs +++ b/components/script_layout_interface/wrapper_traits.rs @@ -86,8 +86,6 @@ pub trait LayoutNode: GetLayoutData + TNode { unsafe fn init_style_and_layout_data(&self, data: OpaqueStyleAndLayoutData); unsafe fn take_style_and_layout_data(&self) -> OpaqueStyleAndLayoutData; - fn has_changed(&self) -> bool; - unsafe fn clear_dirty_bits(&self); fn rev_children(self) -> LayoutIterator<ReverseChildrenIterator<Self>> { |