diff options
Diffstat (limited to 'src/components/main/layout/flow.rs')
-rw-r--r-- | src/components/main/layout/flow.rs | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/components/main/layout/flow.rs b/src/components/main/layout/flow.rs index 38fd16974b3..6dd1654e746 100644 --- a/src/components/main/layout/flow.rs +++ b/src/components/main/layout/flow.rs @@ -32,6 +32,8 @@ use layout::context::LayoutContext; use layout::display_list_builder::{DisplayListBuilder, ExtraDisplayListData}; use layout::inline::{InlineFlowData}; use layout::float_context::{FloatContext, Invalid, FloatType}; +use layout::incremental::RestyleDamage; +use css::node_style::StyledNode; use std::cell::Cell; use std::uint; @@ -45,6 +47,7 @@ use servo_util::tree::{TreeNode, TreeNodeRef, TreeUtils}; /// The type of the formatting context and data specific to each context, such as line box /// structures or float lists. +#[deriving(Clone)] pub enum FlowContext { AbsoluteFlow(@mut FlowData), BlockFlow(@mut BlockFlowData), @@ -64,12 +67,6 @@ pub enum FlowContextType { Flow_Table } -impl Clone for FlowContext { - fn clone(&self) -> FlowContext { - *self - } -} - impl FlowContext { pub fn teardown(&self) { match *self { @@ -84,6 +81,9 @@ impl FlowContext { /// Like traverse_preorder, but don't end the whole traversal if the callback /// returns false. + // + // FIXME: Unify this with traverse_preorder_prune, which takes a separate + // 'prune' function. fn partially_traverse_preorder(&self, callback: &fn(FlowContext) -> bool) { if !callback((*self).clone()) { return; @@ -157,6 +157,7 @@ impl TreeNodeRef<FlowData> for FlowContext { /// `CommonFlowInfo`? pub struct FlowData { node: AbstractNode<LayoutView>, + restyle_damage: RestyleDamage, parent: Option<FlowContext>, first_child: Option<FlowContext>, @@ -225,6 +226,7 @@ impl FlowData { pub fn new(id: int, node: AbstractNode<LayoutView>) -> FlowData { FlowData { node: node, + restyle_damage: node.restyle_damage(), parent: None, first_child: None, @@ -264,6 +266,15 @@ impl<'self> FlowContext { } } + /// A convenience method to return the restyle damage of this flow. Fails if the flow is + /// currently being borrowed mutably. + #[inline(always)] + pub fn restyle_damage(&self) -> RestyleDamage { + do self.with_base |info| { + info.restyle_damage + } + } + pub fn inline(&self) -> @mut InlineFlowData { match *self { InlineFlow(info) => info, @@ -448,7 +459,8 @@ impl<'self> FlowContext { }; do self.with_base |base| { - fmt!("f%? %? floats %? size %?", base.id, repr, base.num_floats, base.position) + fmt!("f%? %? floats %? size %? damage %?", base.id, repr, base.num_floats, + base.position, base.restyle_damage) } } } |