From 4ea714e6d22917eb6c95b2be9dec4bf8bb7da757 Mon Sep 17 00:00:00 2001 From: Ashwin Naren Date: Wed, 3 Sep 2025 05:16:20 -0700 Subject: [PATCH] script: Calculate proper border box for resizeobserver (#38988) Implements more of calculate_box_size, ensuring that the proper rectangle is returned when the border box is requested. Testing: WPT Fixes: Partially #38811 --------- Signed-off-by: Ashwin Naren Co-authored-by: Jo Steven Novaryo <65610990+stevennovaryo@users.noreply.github.com> --- components/script/dom/resizeobserver.rs | 13 +++++++-- .../wpt/meta/resize-observer/observe.html.ini | 28 ++++++++++++++++--- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/components/script/dom/resizeobserver.rs b/components/script/dom/resizeobserver.rs index 9ef69729787..ce3d9a03c4d 100644 --- a/components/script/dom/resizeobserver.rs +++ b/components/script/dom/resizeobserver.rs @@ -311,11 +311,18 @@ fn calculate_box_size(target: &Element, observed_box: &ResizeObserverBoxOptions) // but the spec will expand to cover all fragments. target .upcast::() - .border_boxes() - .pop() + .content_box() .unwrap_or_else(Rect::zero) }, - // TODO(#31182): add support for border box, and device pixel size, calculations. + ResizeObserverBoxOptions::Border_box => { + // Note: only taking first fragment, + // but the spec will expand to cover all fragments. + target + .upcast::() + .border_box() + .unwrap_or_else(Rect::zero) + }, + // TODO(#31182): add support for device pixel size calculations. _ => Rect::zero(), } } diff --git a/tests/wpt/meta/resize-observer/observe.html.ini b/tests/wpt/meta/resize-observer/observe.html.ini index 2f1fca50001..c92096f2799 100644 --- a/tests/wpt/meta/resize-observer/observe.html.ini +++ b/tests/wpt/meta/resize-observer/observe.html.ini @@ -1,8 +1,4 @@ [observe.html] - expected: TIMEOUT - [guard] - expected: NOTRUN - [test8: simple content-box observation] expected: [PASS, FAIL] @@ -11,3 +7,27 @@ [test10: simple border-box observation] expected: [PASS, FAIL] + + [test11: simple observation with vertical writing mode] + expected: FAIL + + [test12: no observation is fired after the change of writing mode when box's specified size comes from logical size properties.] + expected: FAIL + + [test13: an observation is fired after the change of writing mode when box's specified size comes from physical size properties.] + expected: FAIL + + [test14: observe the same target but using a different box should override the previous one] + expected: FAIL + + [test15: an observation is fired with box dimensions 0 when element's display property is set to inline] + expected: FAIL + + [test16: observations fire once with 0x0 size for non-replaced inline elements] + expected: FAIL + + [test17: Box sizing snd Resize Observer notifications] + expected: FAIL + + [test18: an observation is fired when device-pixel-content-box is being observed] + expected: FAIL