removed restyledamage

This commit is contained in:
Clark Gaebel 2014-10-07 14:12:18 -04:00
parent d12c6e7383
commit a29dc2c979
4 changed files with 49 additions and 98 deletions

View file

@ -34,7 +34,6 @@ use fragment::{InlineBlockFragmentInfo, InputFragment, InputFragmentInfo, Specif
use fragment::{TableCellFragment, TableColumnFragment, TableColumnFragmentInfo, TableFragment}; use fragment::{TableCellFragment, TableColumnFragment, TableColumnFragmentInfo, TableFragment};
use fragment::{TableRowFragment, TableWrapperFragment, UnscannedTextFragment}; use fragment::{TableRowFragment, TableWrapperFragment, UnscannedTextFragment};
use fragment::{UnscannedTextFragmentInfo}; use fragment::{UnscannedTextFragmentInfo};
use incremental::RestyleDamage;
use inline::{InlineFragments, InlineFlow}; use inline::{InlineFragments, InlineFlow};
use parallel; use parallel;
use table_wrapper::TableWrapperFlow; use table_wrapper::TableWrapperFlow;
@ -89,7 +88,7 @@ pub enum ConstructionItem {
/// Inline fragments and associated {ib} splits that have not yet found flows. /// Inline fragments and associated {ib} splits that have not yet found flows.
InlineFragmentsConstructionItem(InlineFragmentsConstructionResult), InlineFragmentsConstructionItem(InlineFragmentsConstructionResult),
/// Potentially ignorable whitespace. /// Potentially ignorable whitespace.
WhitespaceConstructionItem(OpaqueNode, Arc<ComputedValues>, RestyleDamage), WhitespaceConstructionItem(OpaqueNode, Arc<ComputedValues>),
/// TableColumn Fragment /// TableColumn Fragment
TableColumnFragmentConstructionItem(Fragment), TableColumnFragmentConstructionItem(Fragment),
} }
@ -442,15 +441,13 @@ impl<'a> FlowConstructor<'a> {
abs_descendants.push_descendants(kid_abs_descendants); abs_descendants.push_descendants(kid_abs_descendants);
} }
ConstructionItemConstructionResult(WhitespaceConstructionItem(whitespace_node, ConstructionItemConstructionResult(WhitespaceConstructionItem(whitespace_node,
whitespace_style, whitespace_style)) => {
whitespace_damage)) => {
// Add whitespace results. They will be stripped out later on when // Add whitespace results. They will be stripped out later on when
// between block elements, and retained when between inline elements. // between block elements, and retained when between inline elements.
let fragment_info = let fragment_info =
UnscannedTextFragment(UnscannedTextFragmentInfo::from_text(" ".to_string())); UnscannedTextFragment(UnscannedTextFragmentInfo::from_text(" ".to_string()));
let mut fragment = Fragment::from_opaque_node_and_style(whitespace_node, let mut fragment = Fragment::from_opaque_node_and_style(whitespace_node,
whitespace_style, whitespace_style,
whitespace_damage,
fragment_info); fragment_info);
inline_fragment_accumulator.fragments.push(&mut fragment); inline_fragment_accumulator.fragments.push(&mut fragment);
} }
@ -610,14 +607,11 @@ impl<'a> FlowConstructor<'a> {
abs_descendants.push_descendants(kid_abs_descendants); abs_descendants.push_descendants(kid_abs_descendants);
} }
ConstructionItemConstructionResult(WhitespaceConstructionItem(whitespace_node, ConstructionItemConstructionResult(WhitespaceConstructionItem(whitespace_node,
whitespace_style, whitespace_style)) => {
whitespace_damage))
=> {
// Instantiate the whitespace fragment. // Instantiate the whitespace fragment.
let fragment_info = UnscannedTextFragment(UnscannedTextFragmentInfo::from_text(" ".to_string())); let fragment_info = UnscannedTextFragment(UnscannedTextFragmentInfo::from_text(" ".to_string()));
let mut fragment = Fragment::from_opaque_node_and_style(whitespace_node, let mut fragment = Fragment::from_opaque_node_and_style(whitespace_node,
whitespace_style, whitespace_style,
whitespace_damage,
fragment_info); fragment_info);
fragment_accumulator.fragments.push(&mut fragment) fragment_accumulator.fragments.push(&mut fragment)
} }
@ -659,8 +653,7 @@ impl<'a> FlowConstructor<'a> {
let opaque_node = OpaqueNodeMethods::from_thread_safe_layout_node(node); let opaque_node = OpaqueNodeMethods::from_thread_safe_layout_node(node);
return ConstructionItemConstructionResult(WhitespaceConstructionItem( return ConstructionItemConstructionResult(WhitespaceConstructionItem(
opaque_node, opaque_node,
node.style().clone(), node.style().clone()))
node.restyle_damage()))
} }
// If this is generated content, then we need to initialize the accumulator with the // If this is generated content, then we need to initialize the accumulator with the
@ -1206,9 +1199,6 @@ impl FlowConstructionUtils for FlowRef {
{ {
let kid_base = flow::mut_base(new_child.get_mut()); let kid_base = flow::mut_base(new_child.get_mut());
base.restyle_damage.insert(kid_base.restyle_damage.propagate_up());
kid_base.parallel.parent = parallel::mut_owned_flow_to_unsafe_flow(self); kid_base.parallel.parent = parallel::mut_owned_flow_to_unsafe_flow(self);
} }

View file

@ -7,8 +7,6 @@
use css::node_style::StyledNode; use css::node_style::StyledNode;
use construct::FlowConstructor; use construct::FlowConstructor;
use context::LayoutContext; use context::LayoutContext;
use incremental;
use incremental::RestyleDamage;
use util::{LayoutDataAccess, LayoutDataWrapper}; use util::{LayoutDataAccess, LayoutDataWrapper};
use wrapper::{LayoutElement, LayoutNode, PostorderNodeMutTraversal, ThreadSafeLayoutNode}; use wrapper::{LayoutElement, LayoutNode, PostorderNodeMutTraversal, ThreadSafeLayoutNode};
use wrapper::{TLayoutNode}; use wrapper::{TLayoutNode};
@ -333,7 +331,7 @@ trait PrivateMatchMethods {
style: &mut Option<Arc<ComputedValues>>, style: &mut Option<Arc<ComputedValues>>,
applicable_declarations_cache: &mut applicable_declarations_cache: &mut
ApplicableDeclarationsCache, ApplicableDeclarationsCache,
shareable: bool) -> RestyleDamage; shareable: bool);
fn share_style_with_candidate_if_possible(&self, fn share_style_with_candidate_if_possible(&self,
parent_node: Option<LayoutNode>, parent_node: Option<LayoutNode>,
@ -348,7 +346,7 @@ impl<'ln> PrivateMatchMethods for LayoutNode<'ln> {
style: &mut Option<Arc<ComputedValues>>, style: &mut Option<Arc<ComputedValues>>,
applicable_declarations_cache: &mut applicable_declarations_cache: &mut
ApplicableDeclarationsCache, ApplicableDeclarationsCache,
shareable: bool) -> RestyleDamage { shareable: bool) {
let this_style; let this_style;
let cacheable; let cacheable;
match parent_style { match parent_style {
@ -380,9 +378,7 @@ impl<'ln> PrivateMatchMethods for LayoutNode<'ln> {
applicable_declarations_cache.insert(applicable_declarations, this_style.clone()); applicable_declarations_cache.insert(applicable_declarations, this_style.clone());
} }
let damage = incremental::compute_damage(style, &*this_style);
*style = Some(this_style); *style = Some(this_style);
damage
} }
@ -472,15 +468,10 @@ impl<'ln> MatchMethods for LayoutNode<'ln> {
match self.share_style_with_candidate_if_possible(parent.clone(), candidate) { match self.share_style_with_candidate_if_possible(parent.clone(), candidate) {
Some(shared_style) => { Some(shared_style) => {
// Yay, cache hit. Share the style. // Yay, cache hit. Share the style.
let damage = { let mut layout_data_ref = self.mutate_layout_data();
let mut layout_data_ref = self.mutate_layout_data(); let shared_data = &mut layout_data_ref.as_mut().unwrap().shared_data;
let shared_data = &mut layout_data_ref.as_mut().unwrap().shared_data; let style = &mut shared_data.style;
let style = &mut shared_data.style; *style = Some(shared_style);
let damage = incremental::compute_damage(style, &*shared_style);
*style = Some(shared_style);
damage
};
ThreadSafeLayoutNode::new(self).set_restyle_damage(damage);
return StyleWasShared(i) return StyleWasShared(i)
} }
None => {} None => {}
@ -613,71 +604,61 @@ impl<'ln> MatchMethods for LayoutNode<'ln> {
// //
// FIXME(pcwalton): Isolate this unsafety into the `wrapper` module to allow // FIXME(pcwalton): Isolate this unsafety into the `wrapper` module to allow
// enforced safe, race-free access to the parent style. // enforced safe, race-free access to the parent style.
let (down_restyle_damage, parent_style) = match parent { let parent_style = match parent {
None => (RestyleDamage::empty(), None), None => None,
Some(parent_node) => { Some(parent_node) => {
let parent_layout_data = parent_node.borrow_layout_data_unchecked(); let parent_layout_data = parent_node.borrow_layout_data_unchecked();
match *parent_layout_data { match *parent_layout_data {
None => fail!("no parent data?!"), None => fail!("no parent data?!"),
Some(ref parent_layout_data) => { Some(ref parent_layout_data) => {
let down_restyle_damage =
parent_layout_data.data.restyle_damage.propagate_down();
match parent_layout_data.shared_data.style { match parent_layout_data.shared_data.style {
None => fail!("parent hasn't been styled yet?!"), None => fail!("parent hasn't been styled yet?!"),
Some(ref style) => (down_restyle_damage, Some(style)), Some(ref style) => Some(style),
} }
} }
} }
} }
}; };
let mut damage = down_restyle_damage; let mut layout_data_ref = self.mutate_layout_data();
match &mut *layout_data_ref {
{ &None => fail!("no layout data"),
let mut layout_data_ref = self.mutate_layout_data(); &Some(ref mut layout_data) => {
match &mut *layout_data_ref { match self.type_id() {
&None => fail!("no layout data"), Some(TextNodeTypeId) => {
&Some(ref mut layout_data) => { // Text nodes get a copy of the parent style. This ensures
match self.type_id() { // that during fragment construction any non-inherited
Some(TextNodeTypeId) => { // CSS properties (such as vertical-align) are correctly
// Text nodes get a copy of the parent style. This ensures // set on the fragment(s).
// that during fragment construction any non-inherited let cloned_parent_style = parent_style.unwrap().clone();
// CSS properties (such as vertical-align) are correctly layout_data.shared_data.style = Some(cloned_parent_style);
// set on the fragment(s). }
let cloned_parent_style = parent_style.unwrap().clone(); _ => {
layout_data.shared_data.style = Some(cloned_parent_style); self.cascade_node_pseudo_element(
parent_style,
applicable_declarations.normal.as_slice(),
&mut layout_data.shared_data.style,
applicable_declarations_cache,
applicable_declarations.normal_shareable);
if applicable_declarations.before.len() > 0 {
self.cascade_node_pseudo_element(
Some(layout_data.shared_data.style.as_ref().unwrap()),
applicable_declarations.before.as_slice(),
&mut layout_data.data.before_style,
applicable_declarations_cache,
false);
} }
_ => { if applicable_declarations.after.len() > 0 {
damage = damage self.cascade_node_pseudo_element(
| self.cascade_node_pseudo_element( Some(layout_data.shared_data.style.as_ref().unwrap()),
parent_style, applicable_declarations.after.as_slice(),
applicable_declarations.normal.as_slice(), &mut layout_data.data.after_style,
&mut layout_data.shared_data.style, applicable_declarations_cache,
applicable_declarations_cache, false);
applicable_declarations.normal_shareable);
if applicable_declarations.before.len() > 0 {
damage = damage
| self.cascade_node_pseudo_element(
Some(layout_data.shared_data.style.as_ref().unwrap()),
applicable_declarations.before.as_slice(),
&mut layout_data.data.before_style,
applicable_declarations_cache,
false);
}
if applicable_declarations.after.len() > 0 {
damage = damage
| self.cascade_node_pseudo_element(Some(layout_data.shared_data.style.as_ref().unwrap()),
applicable_declarations.after.as_slice(),
&mut layout_data.data.after_style,
applicable_declarations_cache,
false);
}
} }
} }
} }
} }
} }
ThreadSafeLayoutNode::new(self).set_restyle_damage(damage);
} }
} }

View file

@ -13,7 +13,6 @@ use floats::{ClearBoth, ClearLeft, ClearRight, ClearType};
use flow::Flow; use flow::Flow;
use flow; use flow;
use flow_ref::FlowRef; use flow_ref::FlowRef;
use incremental::RestyleDamage;
use inline::{InlineFragmentContext, InlineMetrics}; use inline::{InlineFragmentContext, InlineMetrics};
use layout_debug; use layout_debug;
use model::{Auto, IntrinsicISizes, MaybeAuto, Specified, specified}; use model::{Auto, IntrinsicISizes, MaybeAuto, Specified, specified};
@ -89,9 +88,6 @@ pub struct Fragment {
/// The CSS style of this fragment. /// The CSS style of this fragment.
pub style: Arc<ComputedValues>, pub style: Arc<ComputedValues>,
/// The incremental damage done to this fragment during the current layout round.
pub restyle_damage: RestyleDamage,
/// The position of this fragment relative to its owning flow. /// The position of this fragment relative to its owning flow.
/// The size includes padding and border, but not margin. /// The size includes padding and border, but not margin.
pub border_box: LogicalRect<Au>, pub border_box: LogicalRect<Au>,
@ -444,7 +440,6 @@ impl Fragment {
Fragment { Fragment {
node: OpaqueNodeMethods::from_thread_safe_layout_node(node), node: OpaqueNodeMethods::from_thread_safe_layout_node(node),
style: style, style: style,
restyle_damage: node.restyle_damage(),
border_box: LogicalRect::zero(writing_mode), border_box: LogicalRect::zero(writing_mode),
border_padding: LogicalMargin::zero(writing_mode), border_padding: LogicalMargin::zero(writing_mode),
margin: LogicalMargin::zero(writing_mode), margin: LogicalMargin::zero(writing_mode),
@ -463,7 +458,6 @@ impl Fragment {
Fragment { Fragment {
node: OpaqueNodeMethods::from_thread_safe_layout_node(node), node: OpaqueNodeMethods::from_thread_safe_layout_node(node),
style: style, style: style,
restyle_damage: node.restyle_damage(),
border_box: LogicalRect::zero(writing_mode), border_box: LogicalRect::zero(writing_mode),
border_padding: LogicalMargin::zero(writing_mode), border_padding: LogicalMargin::zero(writing_mode),
margin: LogicalMargin::zero(writing_mode), margin: LogicalMargin::zero(writing_mode),
@ -490,7 +484,6 @@ impl Fragment {
Fragment { Fragment {
node: OpaqueNodeMethods::from_thread_safe_layout_node(node), node: OpaqueNodeMethods::from_thread_safe_layout_node(node),
style: Arc::new(node_style), style: Arc::new(node_style),
restyle_damage: node.restyle_damage(),
border_box: LogicalRect::zero(writing_mode), border_box: LogicalRect::zero(writing_mode),
border_padding: LogicalMargin::zero(writing_mode), border_padding: LogicalMargin::zero(writing_mode),
margin: LogicalMargin::zero(writing_mode), margin: LogicalMargin::zero(writing_mode),
@ -504,14 +497,12 @@ impl Fragment {
/// Constructs a new `Fragment` instance from an opaque node. /// Constructs a new `Fragment` instance from an opaque node.
pub fn from_opaque_node_and_style(node: OpaqueNode, pub fn from_opaque_node_and_style(node: OpaqueNode,
style: Arc<ComputedValues>, style: Arc<ComputedValues>,
restyle_damage: RestyleDamage,
specific: SpecificFragmentInfo) specific: SpecificFragmentInfo)
-> Fragment { -> Fragment {
let writing_mode = style.writing_mode; let writing_mode = style.writing_mode;
Fragment { Fragment {
node: node, node: node,
style: style, style: style,
restyle_damage: restyle_damage,
border_box: LogicalRect::zero(writing_mode), border_box: LogicalRect::zero(writing_mode),
border_padding: LogicalMargin::zero(writing_mode), border_padding: LogicalMargin::zero(writing_mode),
margin: LogicalMargin::zero(writing_mode), margin: LogicalMargin::zero(writing_mode),
@ -534,7 +525,6 @@ impl Fragment {
Fragment { Fragment {
node: self.node, node: self.node,
style: self.style.clone(), style: self.style.clone(),
restyle_damage: self.restyle_damage,
border_box: LogicalRect::from_point_size( border_box: LogicalRect::from_point_size(
self.style.writing_mode, self.border_box.start, size), self.style.writing_mode, self.border_box.start, size),
border_padding: self.border_padding, border_padding: self.border_padding,

View file

@ -11,7 +11,6 @@ use flow::{BaseFlow, FlowClass, Flow, InlineFlowClass, MutableFlowUtils};
use flow; use flow;
use fragment::{Fragment, InlineBlockFragment, ScannedTextFragment, ScannedTextFragmentInfo}; use fragment::{Fragment, InlineBlockFragment, ScannedTextFragment, ScannedTextFragmentInfo};
use fragment::{SplitInfo}; use fragment::{SplitInfo};
use incremental;
use layout_debug; use layout_debug;
use model::IntrinsicISizes; use model::IntrinsicISizes;
use text; use text;
@ -764,22 +763,13 @@ pub struct InlineFlow {
impl InlineFlow { impl InlineFlow {
pub fn from_fragments(node: ThreadSafeLayoutNode, fragments: InlineFragments) -> InlineFlow { pub fn from_fragments(node: ThreadSafeLayoutNode, fragments: InlineFragments) -> InlineFlow {
let fragment_damage = InlineFlow {
fragments.fragments.iter().fold(
incremental::RestyleDamage::empty(),
|dmg, frag| dmg | frag.restyle_damage);
let mut ret = InlineFlow {
base: BaseFlow::new(node), base: BaseFlow::new(node),
fragments: fragments, fragments: fragments,
lines: Vec::new(), lines: Vec::new(),
minimum_block_size_above_baseline: Au(0), minimum_block_size_above_baseline: Au(0),
minimum_depth_below_baseline: Au(0), minimum_depth_below_baseline: Au(0),
}; }
ret.base.restyle_damage.insert(fragment_damage);
ret
} }
pub fn build_display_list_inline(&mut self, layout_context: &LayoutContext) { pub fn build_display_list_inline(&mut self, layout_context: &LayoutContext) {