script: Fix resize observer depth calculation for Shadow DOM. (#36230)

Follow the specification more closely by using the flat tree when
calculating depth for the resize observer.

Testing: Newly passing WPT test.
Fixes: #36092

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
Josh Matthews 2025-03-31 12:01:16 -04:00 committed by GitHub
parent aca5c3b7ca
commit 7382efa209
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 1 additions and 6 deletions

View file

@ -296,7 +296,7 @@ impl ResizeObservation {
/// <https://drafts.csswg.org/resize-observer/#calculate-depth-for-node>
fn calculate_depth_for_node(target: &Element) -> ResizeObservationDepth {
let node = target.upcast::<Node>();
let depth = node.ancestors().count();
let depth = node.inclusive_ancestors_in_flat_tree().count() - 1;
ResizeObservationDepth(depth)
}

View file

@ -1,5 +0,0 @@
[calculate-depth-for-node.html]
expected: ERROR
["Calculate depth for node" algorithm with Shadow DOM]
expected: FAIL