mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Make the STYLE_BLOOM global private.
This commit is contained in:
parent
44b0bddf41
commit
4381107c21
2 changed files with 37 additions and 32 deletions
|
@ -13,16 +13,12 @@ use gfx::display_list::OpaqueNode;
|
|||
use script_layout_interface::restyle_damage::{BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW, REPAINT, RestyleDamage};
|
||||
use script_layout_interface::wrapper_traits::{LayoutNode, ThreadSafeLayoutNode};
|
||||
use std::mem;
|
||||
use style::context::StyleContext;
|
||||
use style::dom::TNode;
|
||||
use style::matching::MatchMethods;
|
||||
use style::properties::ServoComputedValues;
|
||||
use style::selector_impl::ServoSelectorImpl;
|
||||
use style::servo::SharedStyleContext;
|
||||
use style::traversal::{DomTraversalContext, STYLE_BLOOM};
|
||||
use style::traversal::{put_thread_local_bloom_filter, recalc_style_at};
|
||||
use style::traversal::{DomTraversalContext, remove_from_bloom_filter, recalc_style_at};
|
||||
use util::opts;
|
||||
use util::tid::tid;
|
||||
use wrapper::{LayoutNodeLayoutData, ThreadSafeLayoutNodeHelpers};
|
||||
|
||||
pub struct RecalcStyleAndConstructFlows<'lc> {
|
||||
|
@ -122,29 +118,7 @@ fn construct_flows_at<'a, N: LayoutNode>(context: &'a LayoutContext<'a>, root: O
|
|||
node.set_dirty_descendants(false);
|
||||
}
|
||||
|
||||
let unsafe_layout_node = node.to_unsafe();
|
||||
|
||||
let (mut bf, old_node, old_generation) =
|
||||
STYLE_BLOOM.with(|style_bloom| {
|
||||
mem::replace(&mut *style_bloom.borrow_mut(), None)
|
||||
.expect("The bloom filter should have been set by style recalc.")
|
||||
});
|
||||
|
||||
assert_eq!(old_node, unsafe_layout_node);
|
||||
assert_eq!(old_generation, context.shared_context().generation);
|
||||
|
||||
match node.layout_parent_node(root) {
|
||||
None => {
|
||||
debug!("[{}] - {:X}, and deleting BF.", tid(), unsafe_layout_node.0);
|
||||
// If this is the reflow root, eat the thread-local bloom filter.
|
||||
}
|
||||
Some(parent) => {
|
||||
// Otherwise, put it back, but remove this node.
|
||||
node.remove_from_bloom_filter(&mut *bf);
|
||||
let unsafe_parent = parent.to_unsafe();
|
||||
put_thread_local_bloom_filter(bf, &unsafe_parent, &context.shared_context());
|
||||
},
|
||||
};
|
||||
remove_from_bloom_filter(context, root, node);
|
||||
}
|
||||
|
||||
/// The bubble-inline-sizes traversal, the first part of layout computation. This computes
|
||||
|
|
|
@ -37,7 +37,7 @@ pub type Generation = u32;
|
|||
/// will no longer be the for the parent of the node we're currently on. When
|
||||
/// this happens, the thread local bloom filter will be thrown away and rebuilt.
|
||||
thread_local!(
|
||||
pub static STYLE_BLOOM: RefCell<Option<(Box<BloomFilter>, UnsafeNode, Generation)>> = RefCell::new(None));
|
||||
static STYLE_BLOOM: RefCell<Option<(Box<BloomFilter>, UnsafeNode, Generation)>> = RefCell::new(None));
|
||||
|
||||
/// Returns the thread local bloom filter.
|
||||
///
|
||||
|
@ -79,9 +79,9 @@ fn take_thread_local_bloom_filter<N, Impl: SelectorImplExt>(parent_node: Option<
|
|||
})
|
||||
}
|
||||
|
||||
pub fn put_thread_local_bloom_filter<Impl: SelectorImplExt>(bf: Box<BloomFilter>,
|
||||
unsafe_node: &UnsafeNode,
|
||||
context: &SharedStyleContext<Impl>) {
|
||||
fn put_thread_local_bloom_filter<Impl: SelectorImplExt>(bf: Box<BloomFilter>,
|
||||
unsafe_node: &UnsafeNode,
|
||||
context: &SharedStyleContext<Impl>) {
|
||||
STYLE_BLOOM.with(move |style_bloom| {
|
||||
assert!(style_bloom.borrow().is_none(),
|
||||
"Putting into a never-taken thread-local bloom filter");
|
||||
|
@ -108,6 +108,37 @@ fn insert_ancestors_into_bloom_filter<N>(bf: &mut Box<BloomFilter>,
|
|||
debug!("[{}] Inserted {} ancestors.", tid(), ancestors);
|
||||
}
|
||||
|
||||
pub fn remove_from_bloom_filter<'a, N, C, Impl>(context: &C, root: OpaqueNode, node: N)
|
||||
where N: TNode,
|
||||
Impl: SelectorImplExt + 'a,
|
||||
C: StyleContext<'a, Impl>
|
||||
{
|
||||
let unsafe_layout_node = node.to_unsafe();
|
||||
|
||||
let (mut bf, old_node, old_generation) =
|
||||
STYLE_BLOOM.with(|style_bloom| {
|
||||
style_bloom.borrow_mut()
|
||||
.take()
|
||||
.expect("The bloom filter should have been set by style recalc.")
|
||||
});
|
||||
|
||||
assert_eq!(old_node, unsafe_layout_node);
|
||||
assert_eq!(old_generation, context.shared_context().generation);
|
||||
|
||||
match node.layout_parent_node(root) {
|
||||
None => {
|
||||
debug!("[{}] - {:X}, and deleting BF.", tid(), unsafe_layout_node.0);
|
||||
// If this is the reflow root, eat the thread-local bloom filter.
|
||||
}
|
||||
Some(parent) => {
|
||||
// Otherwise, put it back, but remove this node.
|
||||
node.remove_from_bloom_filter(&mut *bf);
|
||||
let unsafe_parent = parent.to_unsafe();
|
||||
put_thread_local_bloom_filter(bf, &unsafe_parent, &context.shared_context());
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
pub trait DomTraversalContext<N: TNode> {
|
||||
type SharedContext: Sync + 'static;
|
||||
fn new<'a>(&'a Self::SharedContext, OpaqueNode) -> Self;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue