aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/element.rs
diff options
context:
space:
mode:
authorMartin Robinson <mrobinson@igalia.com>2024-12-19 20:24:42 +0100
committerGitHub <noreply@github.com>2024-12-19 19:24:42 +0000
commit50c9c727788bfb3b7b108eacd404321542598530 (patch)
tree000321dfeb4c9c5ea4f8ce2945ee40255b26fc74 /components/script/dom/element.rs
parentb7460bcb844e3c6e6c887cc9f3d818f0454b0ea3 (diff)
downloadservo-50c9c727788bfb3b7b108eacd404321542598530.tar.gz
servo-50c9c727788bfb3b7b108eacd404321542598530.zip
layout: Lay out Shadow DOM elements (#34701)
When an element is a shadow root, lay out the shadow root elements instead of the non-shadow children. This fixes some tests and introduces some failures, due to bugs in the Shadow DOM implementation. In general, this is very low impact as the Shadow DOM is still disabled by default. At least this gets elements rendering when the preference is turned on though. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Diffstat (limited to 'components/script/dom/element.rs')
-rw-r--r--components/script/dom/element.rs21
1 files changed, 13 insertions, 8 deletions
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs
index 44838256cf5..2bef3e3508f 100644
--- a/components/script/dom/element.rs
+++ b/components/script/dom/element.rs
@@ -558,19 +558,24 @@ impl Element {
};
shadow_root.bind_to_tree(&bind_context);
- self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage);
+ let node = self.upcast::<Node>();
+ node.dirty(NodeDamage::OtherNodeDamage);
+ node.rev_version();
Ok(shadow_root)
}
pub fn detach_shadow(&self) {
- if let Some(ref shadow_root) = self.shadow_root() {
- self.upcast::<Node>().note_dirty_descendants();
- shadow_root.detach();
- self.ensure_rare_data().shadow_root = None;
- } else {
- debug_assert!(false, "Trying to detach a non-attached shadow root");
- }
+ let Some(ref shadow_root) = self.shadow_root() else {
+ unreachable!("Trying to detach a non-attached shadow root");
+ };
+
+ let node = self.upcast::<Node>();
+ node.note_dirty_descendants();
+ node.rev_version();
+
+ shadow_root.detach();
+ self.ensure_rare_data().shadow_root = None;
}
// https://html.spec.whatwg.org/multipage/#translation-mode