mirror of
https://github.com/servo/servo
synced 2026-05-14 10:56:44 +02:00
This PR fixes an issue where the Shadow DOM roots were incorrectly identified as the document roots in scroll and dimension calculations. The previous check `*self.root_element() == *self` returned true for shadow roots which caused `scrollTop`, `scrollLeft`, `clientWidth` to return viewport dimensions instead of actual dimensions. The previous check was replaced with the already existing `self.is_document_element()` to check for actual roots. Testing: - This causes `shadow-dom/scroll-restore-shadow.html` to start passing. - It was also locally tested on the tests given by @rayguo17 ( [clientWidth Test](https://github.com/servo/servo/issues/41002#issue-3684265503) and [scrollTop Test](https://github.com/servo/servo/issues/41002#issuecomment-3605214797) ) Test results: ``` No build type specified so assuming `--dev`. shadow_host_client_width: 300 shadow_root_element_client_width: 300 No build type specified so assuming `--dev`. shadow host scrollTop: 0 shadow_root_element_scrollTop: 0 document root element scrollTop: 536 Button in shadow DOM clicked ``` Fixes: #41002 --------- Signed-off-by: zen-zap <pandaashutosh340@gmail.com>