aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout/construct.rs
diff options
context:
space:
mode:
authorClark Gaebel <cgaebel@mozilla.com>2014-10-06 11:40:05 -0400
committerClark Gaebel <cgaebel@mozilla.com>2014-10-09 12:55:21 -0400
commitd12c6e7383e0be0a64a4f00f1416323038516395 (patch)
tree1b959fd51cd51a91a8a562c91423a9af724897bb /components/layout/construct.rs
parent510f8a817f8144dd5046886d4ca7c612f19a3d08 (diff)
downloadservo-d12c6e7383e0be0a64a4f00f1416323038516395.tar.gz
servo-d12c6e7383e0be0a64a4f00f1416323038516395.zip
Incremental Style Recalc
This patch puts in the initial framework for incremental reflow. Nodes' styles are no longer recalculated unless the node has changed. I've been hacking on the general problem of incremental reflow for the past couple weeks, and I've yet to get a full implementation that actually passes all the reftests + wikipedia + cnn. Therefore, I'm going to try to land the different parts of it one by one. This patch only does incremental style recalc, without incremental flow construction, inline-size bubbling, reflow, or display lists. Those will be coming in that order as I finish them. At least with this strategy, I can land a working version of incremental reflow, even if not yet complete. r? @pcwalton
Diffstat (limited to 'components/layout/construct.rs')
-rw-r--r--components/layout/construct.rs20
1 files changed, 15 insertions, 5 deletions
diff --git a/components/layout/construct.rs b/components/layout/construct.rs
index 826a59a7ead..3e0b66fb38e 100644
--- a/components/layout/construct.rs
+++ b/components/layout/construct.rs
@@ -34,6 +34,7 @@ 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;
@@ -88,7 +89,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>),
+ WhitespaceConstructionItem(OpaqueNode, Arc<ComputedValues>, RestyleDamage),
/// TableColumn Fragment
TableColumnFragmentConstructionItem(Fragment),
}
@@ -441,13 +442,15 @@ impl<'a> FlowConstructor<'a> {
abs_descendants.push_descendants(kid_abs_descendants);
}
ConstructionItemConstructionResult(WhitespaceConstructionItem(whitespace_node,
- whitespace_style)) => {
+ whitespace_style,
+ whitespace_damage)) => {
// 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);
}
@@ -607,12 +610,14 @@ impl<'a> FlowConstructor<'a> {
abs_descendants.push_descendants(kid_abs_descendants);
}
ConstructionItemConstructionResult(WhitespaceConstructionItem(whitespace_node,
- whitespace_style))
+ whitespace_style,
+ whitespace_damage))
=> {
// 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)
}
@@ -654,7 +659,8 @@ impl<'a> FlowConstructor<'a> {
let opaque_node = OpaqueNodeMethods::from_thread_safe_layout_node(node);
return ConstructionItemConstructionResult(WhitespaceConstructionItem(
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
@@ -1196,12 +1202,16 @@ impl FlowConstructionUtils for FlowRef {
///
/// This must not be public because only the layout constructor can do this.
fn add_new_child(&mut self, mut new_child: FlowRef) {
+ let base = flow::mut_base(self.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);
}
- let base = flow::mut_base(self.get_mut());
base.children.push_back(new_child);
let _ = base.parallel.children_count.fetch_add(1, Relaxed);
let _ = base.parallel.children_and_absolute_descendant_count.fetch_add(1, Relaxed);