Implement concept of dirty root

This commit is contained in:
Anthony Ramine 2020-04-27 17:54:06 +02:00
parent 518c0660c6
commit 036f123c4e
11 changed files with 251 additions and 64 deletions

View file

@ -30,6 +30,10 @@ impl<'a> RecalcStyleAndConstructFlows<'a> {
RecalcStyleAndConstructFlows { context: context }
}
pub fn context(&self) -> &LayoutContext<'a> {
&self.context
}
/// Consumes this traversal context, returning ownership of the shared layout
/// context to the caller.
pub fn destroy(self) -> LayoutContext<'a> {
@ -183,6 +187,19 @@ where
fn process(&mut self, node: &ConcreteThreadSafeLayoutNode);
}
#[allow(unsafe_code)]
#[inline]
pub unsafe fn construct_flows_at_ancestors<'dom>(
context: &LayoutContext,
mut node: impl LayoutNode<'dom>,
) {
while let Some(element) = node.traversal_parent() {
element.set_dirty_descendants();
node = element.as_node();
construct_flows_at(context, node);
}
}
/// The flow construction traversal, which builds flows for styled nodes.
#[inline]
#[allow(unsafe_code)]

View file

@ -34,7 +34,7 @@ use crate::data::{LayoutData, LayoutDataFlags, StyleAndLayoutData};
use atomic_refcell::{AtomicRef, AtomicRefMut};
use script_layout_interface::wrapper_traits::GetStyleAndOpaqueLayoutData;
use script_layout_interface::wrapper_traits::{ThreadSafeLayoutElement, ThreadSafeLayoutNode};
use style::dom::{NodeInfo, TNode};
use style::dom::{NodeInfo, TElement, TNode};
use style::selector_parser::RestyleDamage;
use style::values::computed::counters::ContentItem;
use style::values::generics::counters::Content;
@ -148,7 +148,13 @@ where
}
let damage = {
let data = node.get_style_and_layout_data().unwrap();
let data = match node.get_style_and_layout_data() {
Some(data) => data,
None => panic!(
"could not get style and layout data for <{}>",
node.as_element().unwrap().local_name()
),
};
if !data
.layout_data