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::{TableRowFragment, TableWrapperFragment, UnscannedTextFragment};
use fragment::{UnscannedTextFragmentInfo};
use incremental::RestyleDamage;
use inline::{InlineFragments, InlineFlow};
use parallel;
use table_wrapper::TableWrapperFlow;
@ -89,7 +88,7 @@ pub enum ConstructionItem {
/// Inline fragments and associated {ib} splits that have not yet found flows.
InlineFragmentsConstructionItem(InlineFragmentsConstructionResult),
/// Potentially ignorable whitespace.
WhitespaceConstructionItem(OpaqueNode, Arc<ComputedValues>, RestyleDamage),
WhitespaceConstructionItem(OpaqueNode, Arc<ComputedValues>),
/// TableColumn Fragment
TableColumnFragmentConstructionItem(Fragment),
}
@ -442,15 +441,13 @@ impl<'a> FlowConstructor<'a> {
abs_descendants.push_descendants(kid_abs_descendants);
}
ConstructionItemConstructionResult(WhitespaceConstructionItem(whitespace_node,
whitespace_style,
whitespace_damage)) => {
whitespace_style)) => {
// Add whitespace results. They will be stripped out later on when
// between block elements, and retained when between inline elements.
let fragment_info =
UnscannedTextFragment(UnscannedTextFragmentInfo::from_text(" ".to_string()));
let mut fragment = Fragment::from_opaque_node_and_style(whitespace_node,
whitespace_style,
whitespace_damage,
fragment_info);
inline_fragment_accumulator.fragments.push(&mut fragment);
}
@ -610,14 +607,11 @@ impl<'a> FlowConstructor<'a> {
abs_descendants.push_descendants(kid_abs_descendants);
}
ConstructionItemConstructionResult(WhitespaceConstructionItem(whitespace_node,
whitespace_style,
whitespace_damage))
=> {
whitespace_style)) => {
// Instantiate the whitespace fragment.
let fragment_info = UnscannedTextFragment(UnscannedTextFragmentInfo::from_text(" ".to_string()));
let mut fragment = Fragment::from_opaque_node_and_style(whitespace_node,
whitespace_style,
whitespace_damage,
fragment_info);
fragment_accumulator.fragments.push(&mut fragment)
}
@ -659,8 +653,7 @@ impl<'a> FlowConstructor<'a> {
let opaque_node = OpaqueNodeMethods::from_thread_safe_layout_node(node);
return ConstructionItemConstructionResult(WhitespaceConstructionItem(
opaque_node,
node.style().clone(),
node.restyle_damage()))
node.style().clone()))
}
// 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());
base.restyle_damage.insert(kid_base.restyle_damage.propagate_up());
kid_base.parallel.parent = parallel::mut_owned_flow_to_unsafe_flow(self);
}

View file

@ -7,8 +7,6 @@
use css::node_style::StyledNode;
use construct::FlowConstructor;
use context::LayoutContext;
use incremental;
use incremental::RestyleDamage;
use util::{LayoutDataAccess, LayoutDataWrapper};
use wrapper::{LayoutElement, LayoutNode, PostorderNodeMutTraversal, ThreadSafeLayoutNode};
use wrapper::{TLayoutNode};
@ -333,7 +331,7 @@ trait PrivateMatchMethods {
style: &mut Option<Arc<ComputedValues>>,
applicable_declarations_cache: &mut
ApplicableDeclarationsCache,
shareable: bool) -> RestyleDamage;
shareable: bool);
fn share_style_with_candidate_if_possible(&self,
parent_node: Option<LayoutNode>,
@ -348,7 +346,7 @@ impl<'ln> PrivateMatchMethods for LayoutNode<'ln> {
style: &mut Option<Arc<ComputedValues>>,
applicable_declarations_cache: &mut
ApplicableDeclarationsCache,
shareable: bool) -> RestyleDamage {
shareable: bool) {
let this_style;
let cacheable;
match parent_style {
@ -380,9 +378,7 @@ impl<'ln> PrivateMatchMethods for LayoutNode<'ln> {
applicable_declarations_cache.insert(applicable_declarations, this_style.clone());
}
let damage = incremental::compute_damage(style, &*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) {
Some(shared_style) => {
// Yay, cache hit. Share the style.
let damage = {
let mut layout_data_ref = self.mutate_layout_data();
let shared_data = &mut layout_data_ref.as_mut().unwrap().shared_data;
let style = &mut shared_data.style;
let damage = incremental::compute_damage(style, &*shared_style);
*style = Some(shared_style);
damage
};
ThreadSafeLayoutNode::new(self).set_restyle_damage(damage);
let mut layout_data_ref = self.mutate_layout_data();
let shared_data = &mut layout_data_ref.as_mut().unwrap().shared_data;
let style = &mut shared_data.style;
*style = Some(shared_style);
return StyleWasShared(i)
}
None => {}
@ -613,71 +604,61 @@ impl<'ln> MatchMethods for LayoutNode<'ln> {
//
// FIXME(pcwalton): Isolate this unsafety into the `wrapper` module to allow
// enforced safe, race-free access to the parent style.
let (down_restyle_damage, parent_style) = match parent {
None => (RestyleDamage::empty(), None),
let parent_style = match parent {
None => None,
Some(parent_node) => {
let parent_layout_data = parent_node.borrow_layout_data_unchecked();
match *parent_layout_data {
None => fail!("no parent 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 {
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"),
&Some(ref mut layout_data) => {
match self.type_id() {
Some(TextNodeTypeId) => {
// Text nodes get a copy of the parent style. This ensures
// that during fragment construction any non-inherited
// CSS properties (such as vertical-align) are correctly
// set on the fragment(s).
let cloned_parent_style = parent_style.unwrap().clone();
layout_data.shared_data.style = Some(cloned_parent_style);
let mut layout_data_ref = self.mutate_layout_data();
match &mut *layout_data_ref {
&None => fail!("no layout data"),
&Some(ref mut layout_data) => {
match self.type_id() {
Some(TextNodeTypeId) => {
// Text nodes get a copy of the parent style. This ensures
// that during fragment construction any non-inherited
// CSS properties (such as vertical-align) are correctly
// 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);
}
_ => {
damage = damage
| 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 {
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);
}
if applicable_declarations.after.len() > 0 {
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;
use flow_ref::FlowRef;
use incremental::RestyleDamage;
use inline::{InlineFragmentContext, InlineMetrics};
use layout_debug;
use model::{Auto, IntrinsicISizes, MaybeAuto, Specified, specified};
@ -89,9 +88,6 @@ pub struct Fragment {
/// The CSS style of this fragment.
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 size includes padding and border, but not margin.
pub border_box: LogicalRect<Au>,
@ -444,7 +440,6 @@ impl Fragment {
Fragment {
node: OpaqueNodeMethods::from_thread_safe_layout_node(node),
style: style,
restyle_damage: node.restyle_damage(),
border_box: LogicalRect::zero(writing_mode),
border_padding: LogicalMargin::zero(writing_mode),
margin: LogicalMargin::zero(writing_mode),
@ -463,7 +458,6 @@ impl Fragment {
Fragment {
node: OpaqueNodeMethods::from_thread_safe_layout_node(node),
style: style,
restyle_damage: node.restyle_damage(),
border_box: LogicalRect::zero(writing_mode),
border_padding: LogicalMargin::zero(writing_mode),
margin: LogicalMargin::zero(writing_mode),
@ -490,7 +484,6 @@ impl Fragment {
Fragment {
node: OpaqueNodeMethods::from_thread_safe_layout_node(node),
style: Arc::new(node_style),
restyle_damage: node.restyle_damage(),
border_box: LogicalRect::zero(writing_mode),
border_padding: LogicalMargin::zero(writing_mode),
margin: LogicalMargin::zero(writing_mode),
@ -504,14 +497,12 @@ impl Fragment {
/// Constructs a new `Fragment` instance from an opaque node.
pub fn from_opaque_node_and_style(node: OpaqueNode,
style: Arc<ComputedValues>,
restyle_damage: RestyleDamage,
specific: SpecificFragmentInfo)
-> Fragment {
let writing_mode = style.writing_mode;
Fragment {
node: node,
style: style,
restyle_damage: restyle_damage,
border_box: LogicalRect::zero(writing_mode),
border_padding: LogicalMargin::zero(writing_mode),
margin: LogicalMargin::zero(writing_mode),
@ -534,7 +525,6 @@ impl Fragment {
Fragment {
node: self.node,
style: self.style.clone(),
restyle_damage: self.restyle_damage,
border_box: LogicalRect::from_point_size(
self.style.writing_mode, self.border_box.start, size),
border_padding: self.border_padding,

View file

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