mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Kill ServoLayoutElement::note_dirty_descendant
There is no need to set the dirty descendants flag unsafely from the layout side for elements with pending restyles, we can do that on the DOM side when draining the restyles from the Document.
This commit is contained in:
parent
9972aee81f
commit
8a0775fc89
5 changed files with 8 additions and 48 deletions
|
@ -712,21 +712,6 @@ impl<'le> ServoLayoutElement<'le> {
|
|||
pub unsafe fn set_has_snapshot(&self) {
|
||||
self.as_node().node.set_flag(NodeFlags::HAS_SNAPSHOT, true);
|
||||
}
|
||||
|
||||
pub unsafe fn note_dirty_descendant(&self) {
|
||||
use selectors::Element;
|
||||
|
||||
let mut current = Some(*self);
|
||||
while let Some(el) = current {
|
||||
// FIXME(bholley): Ideally we'd have the invariant that any element
|
||||
// with has_dirty_descendants also has the bit set on all its
|
||||
// ancestors. However, there are currently some corner-cases where
|
||||
// we get that wrong. I have in-flight patches to fix all this
|
||||
// stuff up, so we just always propagate this bit for now.
|
||||
el.set_dirty_descendants();
|
||||
current = el.parent_element();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn as_element<'dom>(node: LayoutDom<'dom, Node>) -> Option<ServoLayoutElement<'dom>> {
|
||||
|
|
|
@ -87,7 +87,6 @@ use script_traits::{ConstellationControlMsg, LayoutControlMsg, LayoutMsg as Cons
|
|||
use script_traits::{DrawAPaintImageResult, IFrameSizeMsg, PaintWorkletError, WindowSizeType};
|
||||
use script_traits::{Painter, WebrenderIpcSender};
|
||||
use script_traits::{ScrollState, UntrustedNodeAddress, WindowSizeData};
|
||||
use selectors::Element;
|
||||
use servo_arc::Arc as ServoArc;
|
||||
use servo_atoms::Atom;
|
||||
use servo_config::opts;
|
||||
|
@ -1463,13 +1462,6 @@ impl LayoutThread {
|
|||
for (el, restyle) in restyles {
|
||||
let el = unsafe { ServoLayoutNode::new(&el).as_element().unwrap() };
|
||||
|
||||
// Propagate the descendant bit up the ancestors. Do this before
|
||||
// the restyle calculation so that we can also do it for new
|
||||
// unstyled nodes, which the descendants bit helps us find.
|
||||
if let Some(parent) = el.parent_element() {
|
||||
unsafe { parent.note_dirty_descendant() };
|
||||
}
|
||||
|
||||
// If we haven't styled this node yet, we don't need to track a
|
||||
// restyle.
|
||||
let style_data = match el.get_data() {
|
||||
|
|
|
@ -719,21 +719,6 @@ impl<'le> ServoLayoutElement<'le> {
|
|||
pub unsafe fn set_has_snapshot(&self) {
|
||||
self.as_node().node.set_flag(NodeFlags::HAS_SNAPSHOT, true);
|
||||
}
|
||||
|
||||
pub unsafe fn note_dirty_descendant(&self) {
|
||||
use selectors::Element;
|
||||
|
||||
let mut current = Some(*self);
|
||||
while let Some(el) = current {
|
||||
// FIXME(bholley): Ideally we'd have the invariant that any element
|
||||
// with has_dirty_descendants also has the bit set on all its
|
||||
// ancestors. However, there are currently some corner-cases where
|
||||
// we get that wrong. I have in-flight patches to fix all this
|
||||
// stuff up, so we just always propagate this bit for now.
|
||||
el.set_dirty_descendants();
|
||||
current = el.parent_element();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn as_element<'dom>(node: LayoutDom<'dom, Node>) -> Option<ServoLayoutElement<'dom>> {
|
||||
|
|
|
@ -70,7 +70,6 @@ use script_traits::{ConstellationControlMsg, LayoutControlMsg, LayoutMsg as Cons
|
|||
use script_traits::{DrawAPaintImageResult, PaintWorkletError};
|
||||
use script_traits::{Painter, WebrenderIpcSender};
|
||||
use script_traits::{ScrollState, UntrustedNodeAddress, WindowSizeData};
|
||||
use selectors::Element;
|
||||
use servo_arc::Arc as ServoArc;
|
||||
use servo_atoms::Atom;
|
||||
use servo_config::opts;
|
||||
|
@ -1109,13 +1108,6 @@ impl LayoutThread {
|
|||
for (el, restyle) in restyles {
|
||||
let el = unsafe { ServoLayoutNode::new(&el).as_element().unwrap() };
|
||||
|
||||
// Propagate the descendant bit up the ancestors. Do this before
|
||||
// the restyle calculation so that we can also do it for new
|
||||
// unstyled nodes, which the descendants bit helps us find.
|
||||
if let Some(parent) = el.parent_element() {
|
||||
unsafe { parent.note_dirty_descendant() };
|
||||
}
|
||||
|
||||
// If we haven't styled this node yet, we don't need to track a
|
||||
// restyle.
|
||||
let style_data = match el.get_data() {
|
||||
|
|
|
@ -3587,8 +3587,14 @@ impl Document {
|
|||
self.pending_restyles
|
||||
.borrow_mut()
|
||||
.drain()
|
||||
.filter(|(k, _)| k.upcast::<Node>().get_flag(NodeFlags::IS_CONNECTED))
|
||||
.map(|(k, v)| (k.upcast::<Node>().to_trusted_node_address(), v))
|
||||
.filter_map(|(elem, restyle)| {
|
||||
let node = elem.upcast::<Node>();
|
||||
if !node.get_flag(NodeFlags::IS_CONNECTED) {
|
||||
return None;
|
||||
}
|
||||
node.note_dirty_descendants();
|
||||
Some((node.to_trusted_node_address(), restyle))
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue