mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
Set dirty descendants if node is connected
This commit is contained in:
parent
6bf1ca20a2
commit
59c634b259
3 changed files with 10 additions and 16 deletions
|
@ -569,7 +569,7 @@ impl<'le> TElement for ServoLayoutElement<'le> {
|
|||
}
|
||||
|
||||
unsafe fn set_dirty_descendants(&self) {
|
||||
debug_assert!(self.as_node().is_in_document());
|
||||
debug_assert!(self.as_node().is_connected());
|
||||
self.as_node()
|
||||
.node
|
||||
.set_flag(NodeFlags::HAS_DIRTY_DESCENDANTS, true)
|
||||
|
|
|
@ -645,7 +645,7 @@ impl Document {
|
|||
}
|
||||
|
||||
pub fn content_and_heritage_changed(&self, node: &Node) {
|
||||
if node.is_in_doc() {
|
||||
if node.is_connected() {
|
||||
node.note_dirty_descendants();
|
||||
}
|
||||
|
||||
|
|
|
@ -572,7 +572,7 @@ impl Node {
|
|||
|
||||
// FIXME(emilio): This and the function below should move to Element.
|
||||
pub fn note_dirty_descendants(&self) {
|
||||
debug_assert!(self.is_in_doc());
|
||||
debug_assert!(self.is_connected());
|
||||
|
||||
for ancestor in self.inclusive_ancestors(ShadowIncluding::Yes) {
|
||||
if ancestor.get_flag(NodeFlags::HAS_DIRTY_DESCENDANTS) {
|
||||
|
@ -611,11 +611,15 @@ impl Node {
|
|||
|
||||
match self.type_id() {
|
||||
NodeTypeId::CharacterData(CharacterDataTypeId::Text(TextTypeId::Text)) => {
|
||||
if let Some(parent) = self.composed_parent_node() {
|
||||
parent.downcast::<Element>().unwrap().restyle(damage)
|
||||
}
|
||||
self.parent_node.get().unwrap().dirty(damage)
|
||||
},
|
||||
NodeTypeId::Element(_) => self.downcast::<Element>().unwrap().restyle(damage),
|
||||
NodeTypeId::DocumentFragment(DocumentFragmentTypeId::ShadowRoot) => self
|
||||
.downcast::<ShadowRoot>()
|
||||
.unwrap()
|
||||
.Host()
|
||||
.upcast::<Element>()
|
||||
.restyle(damage),
|
||||
_ => {},
|
||||
};
|
||||
}
|
||||
|
@ -965,16 +969,6 @@ impl Node {
|
|||
self.is_connected() && self.owner_doc().browsing_context().is_some()
|
||||
}
|
||||
|
||||
fn composed_parent_node(&self) -> Option<DomRoot<Node>> {
|
||||
let parent = self.parent_node.get();
|
||||
if let Some(ref parent) = parent {
|
||||
if let Some(shadow_root) = parent.downcast::<ShadowRoot>() {
|
||||
return Some(DomRoot::from_ref(shadow_root.Host().upcast::<Node>()));
|
||||
}
|
||||
}
|
||||
parent
|
||||
}
|
||||
|
||||
pub fn children(&self) -> impl Iterator<Item = DomRoot<Node>> {
|
||||
SimpleNodeIterator {
|
||||
current: self.GetFirstChild(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue