Skip to content
Permalink
Browse files

Set dirty descendants if node is connected

  • Loading branch information...
ferjm committed Mar 23, 2019
1 parent 6bf1ca2 commit 59c634b259f3b481a228c50b32dc8e68c013a609
Showing with 10 additions and 16 deletions.
  1. +1 −1 components/layout_thread/dom_wrapper.rs
  2. +1 −1 components/script/dom/document.rs
  3. +8 −14 components/script/dom/node.rs
@@ -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(),

0 comments on commit 59c634b

Please sign in to comment.
You can’t perform that action at this time.