mirror of
https://github.com/servo/servo.git
synced 2025-09-27 15:20:09 +01:00
layout: Use ServoThreadSafeLayoutNode
in more places (#38626)
Use `ServoThreadSafeLayoutNode` in more places in layout rather than `ServoLayoutNode`. The former is meant to be used during layout, but layout 2020 was written against the latter. In general, this reduces the amount of conversion to the thread-safe version in many places in layout. In addition, an unused iterator from the `script` crate `ServoThreadSafeLayoutNodeChildrenIterator` is replaced with the child iterator from `layout`. The `layout` version must be directly in `script` now as it uses the dangerous variants of `next_sibling` and `first_child`, which allow encapsulating the unsafe bits into one module. This will ultimately be useful for storing the layout data of pseudo-element children of pseudo-elements properly. Testing: This should not change any behavior and thus is covered by existing tests. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
parent
20ad1ce84e
commit
ee7c1d9109
20 changed files with 258 additions and 321 deletions
|
@ -116,6 +116,14 @@ impl<T: MallocSizeOf> MallocSizeOf for [T] {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: MallocConditionalSizeOf> MallocConditionalSizeOf for [T] {
|
||||
fn conditional_size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
||||
self.iter()
|
||||
.map(|element| element.conditional_size_of(ops))
|
||||
.sum()
|
||||
}
|
||||
}
|
||||
|
||||
/// For use on types where size_of() returns 0.
|
||||
#[macro_export]
|
||||
macro_rules! malloc_size_of_is_0(
|
||||
|
@ -352,6 +360,23 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl<A: MallocConditionalSizeOf> MallocConditionalSizeOf for smallvec::SmallVec<A>
|
||||
where
|
||||
A: smallvec::Array,
|
||||
A::Item: MallocConditionalSizeOf,
|
||||
{
|
||||
fn conditional_size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
||||
if !self.spilled() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
self.shallow_size_of(ops) +
|
||||
self.iter()
|
||||
.map(|element| element.conditional_size_of(ops))
|
||||
.sum::<usize>()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: MallocSizeOf> MallocSizeOf for BinaryHeap<T> {
|
||||
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
||||
self.iter().map(|element| element.size_of(ops)).sum()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue