aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/devtools.rs
diff options
context:
space:
mode:
authorSimon Wülker <simon.wuelker@arcor.de>2025-02-05 14:16:36 +0100
committerGitHub <noreply@github.com>2025-02-05 13:16:36 +0000
commit09bfaf51b0eddce9daf343fdfe48cbdbc024f300 (patch)
treebb537532274e44edad0b98f05764ad460384850e /components/script/devtools.rs
parent2bd96633d487fd991ee7e8f03156e5124e06c768 (diff)
downloadservo-09bfaf51b0eddce9daf343fdfe48cbdbc024f300.tar.gz
servo-09bfaf51b0eddce9daf343fdfe48cbdbc024f300.zip
Inform the devtools about shadow roots on a node (#35294)
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
Diffstat (limited to 'components/script/devtools.rs')
-rw-r--r--components/script/devtools.rs35
1 files changed, 18 insertions, 17 deletions
diff --git a/components/script/devtools.rs b/components/script/devtools.rs
index fdf9c991bd2..7718486c14d 100644
--- a/components/script/devtools.rs
+++ b/components/script/devtools.rs
@@ -162,23 +162,24 @@ pub(crate) fn handle_get_children(
})
.collect();
- let children: Vec<_> = parent
- .children()
- .enumerate()
- .filter_map(|(i, child)| {
- // Filter whitespace only text nodes that are not inline level
- // https://firefox-source-docs.mozilla.org/devtools-user/page_inspector/how_to/examine_and_edit_html/index.html#whitespace-only-text-nodes
- let prev_inline = i > 0 && inline[i - 1];
- let next_inline = i < inline.len() - 1 && inline[i + 1];
-
- let info = child.summarize();
- if !is_whitespace(&info) {
- return Some(info);
- }
-
- (prev_inline && next_inline).then_some(info)
- })
- .collect();
+ let mut children = vec![];
+ if let Some(shadow_root) = parent.downcast::<Element>().and_then(Element::shadow_root) {
+ children.push(shadow_root.upcast::<Node>().summarize());
+ }
+ let children_iter = parent.children().enumerate().filter_map(|(i, child)| {
+ // Filter whitespace only text nodes that are not inline level
+ // https://firefox-source-docs.mozilla.org/devtools-user/page_inspector/how_to/examine_and_edit_html/index.html#whitespace-only-text-nodes
+ let prev_inline = i > 0 && inline[i - 1];
+ let next_inline = i < inline.len() - 1 && inline[i + 1];
+
+ let info = child.summarize();
+ if !is_whitespace(&info) {
+ return Some(info);
+ }
+
+ (prev_inline && next_inline).then_some(info)
+ });
+ children.extend(children_iter);
reply.send(Some(children)).unwrap();
},