Use the passed-in reflow root rather than the one stored in the SharedLayoutContext.

This commit is contained in:
Ms2ger 2015-07-09 13:08:56 +02:00 committed by Ms2ger
parent f6e3146de2
commit 9f91984415
4 changed files with 47 additions and 35 deletions

View file

@ -9,6 +9,7 @@ use context::LayoutContext;
use css::matching::{ApplicableDeclarations, ElementMatchMethods, MatchMethods, StyleSharingResult};
use flow::{MutableFlowUtils, PostorderFlowTraversal, PreorderFlowTraversal};
use flow::{self, Flow};
use gfx::display_list::OpaqueNode;
use incremental::{self, BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW, RestyleDamage};
use script::layout_interface::ReflowGoal;
use selectors::bloom::BloomFilter;
@ -50,7 +51,9 @@ thread_local!(
///
/// If one does not exist, a new one will be made for you. If it is out of date,
/// it will be cleared and reused.
fn take_task_local_bloom_filter(parent_node: Option<LayoutNode>, layout_context: &LayoutContext)
fn take_task_local_bloom_filter(parent_node: Option<LayoutNode>,
root: OpaqueNode,
layout_context: &LayoutContext)
-> Box<BloomFilter> {
STYLE_BLOOM.with(|style_bloom| {
match (parent_node, style_bloom.borrow_mut().take()) {
@ -62,7 +65,7 @@ fn take_task_local_bloom_filter(parent_node: Option<LayoutNode>, layout_context:
// No bloom filter for this thread yet.
(Some(parent), None) => {
let mut bloom_filter = box BloomFilter::new();
insert_ancestors_into_bloom_filter(&mut bloom_filter, parent, layout_context);
insert_ancestors_into_bloom_filter(&mut bloom_filter, parent, root);
bloom_filter
}
// Found cached bloom filter.
@ -75,7 +78,7 @@ fn take_task_local_bloom_filter(parent_node: Option<LayoutNode>, layout_context:
// Oh no. the cached parent is stale. I guess we need a new one. Reuse the existing
// allocation to avoid malloc churn.
bloom_filter.clear();
insert_ancestors_into_bloom_filter(&mut bloom_filter, parent, layout_context);
insert_ancestors_into_bloom_filter(&mut bloom_filter, parent, root);
}
bloom_filter
},
@ -96,14 +99,14 @@ fn put_task_local_bloom_filter(bf: Box<BloomFilter>,
/// "Ancestors" in this context is inclusive of ourselves.
fn insert_ancestors_into_bloom_filter(bf: &mut Box<BloomFilter>,
mut n: LayoutNode,
layout_context: &LayoutContext) {
root: OpaqueNode) {
debug!("[{}] Inserting ancestors.", tid());
let mut ancestors = 0;
loop {
ancestors += 1;
n.insert_into_bloom_filter(&mut **bf);
n = match n.layout_parent_node(layout_context.shared) {
n = match n.layout_parent_node(root) {
None => break,
Some(p) => p,
};
@ -135,6 +138,7 @@ pub trait PostorderNodeMutTraversal {
#[derive(Copy, Clone)]
pub struct RecalcStyleForNode<'a> {
pub layout_context: &'a LayoutContext<'a>,
pub root: OpaqueNode,
}
impl<'a> PreorderDomTraversal for RecalcStyleForNode<'a> {
@ -148,10 +152,10 @@ impl<'a> PreorderDomTraversal for RecalcStyleForNode<'a> {
node.initialize_layout_data();
// Get the parent node.
let parent_opt = node.layout_parent_node(self.layout_context.shared);
let parent_opt = node.layout_parent_node(self.root);
// Get the style bloom filter.
let mut bf = take_task_local_bloom_filter(parent_opt, self.layout_context);
let mut bf = take_task_local_bloom_filter(parent_opt, self.root, self.layout_context);
let nonincremental_layout = opts::get().nonincremental_layout;
if nonincremental_layout || node.is_dirty() {
@ -239,6 +243,7 @@ impl<'a> PreorderDomTraversal for RecalcStyleForNode<'a> {
#[derive(Copy, Clone)]
pub struct ConstructFlows<'a> {
pub layout_context: &'a LayoutContext<'a>,
pub root: OpaqueNode,
}
impl<'a> PostorderDomTraversal for ConstructFlows<'a> {
@ -283,7 +288,7 @@ impl<'a> PostorderDomTraversal for ConstructFlows<'a> {
assert_eq!(old_node, unsafe_layout_node);
assert_eq!(old_generation, self.layout_context.shared.generation);
match node.layout_parent_node(self.layout_context.shared) {
match node.layout_parent_node(self.root) {
None => {
debug!("[{}] - {:X}, and deleting BF.", tid(), unsafe_layout_node.0);
// If this is the reflow root, eat the task-local bloom filter.