layout: Parameterize content box query (#38935)

Parameterize and rename both `Layout::content_box_query` and
`Layout::content_boxes_query` to support the query of rendered padding
area and content area that accounts for transform and scroll. Both of
these query have been misleading for a time since they are using border
box, instead of content box of a Node.

This PR adds a new type `layout_api::BoxAreaType` to be passed from
`ScriptThread` to `LayoutThread` to query the respective area. It is
then used for the query within `IntersectionObserver` to pass several
WPTs.

Testing: Existing WPT Coverage.

---------

Signed-off-by: Jo Steven Novaryo <jo.steven.novaryo@huawei.com>
This commit is contained in:
Jo Steven Novaryo 2025-08-27 10:27:53 +08:00 committed by GitHub
parent 32aba08be7
commit 10ca3b6fde
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 125 additions and 125 deletions

View file

@ -26,8 +26,8 @@ use js::jsapi::JSObject;
use js::rust::HandleObject;
use keyboard_types::Modifiers;
use layout_api::{
GenericLayoutData, HTMLCanvasData, HTMLMediaData, LayoutElementType, LayoutNodeType, QueryMsg,
SVGElementData, StyleData, TrustedNodeAddress,
BoxAreaType, GenericLayoutData, HTMLCanvasData, HTMLMediaData, LayoutElementType,
LayoutNodeType, QueryMsg, SVGElementData, StyleData, TrustedNodeAddress,
};
use libc::{self, c_void, uintptr_t};
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
@ -943,11 +943,18 @@ impl Node {
}
pub(crate) fn content_box(&self) -> Option<Rect<Au>> {
self.owner_window().content_box_query(self)
self.owner_window()
.box_area_query(self, BoxAreaType::Content)
}
pub(crate) fn content_boxes(&self) -> Vec<Rect<Au>> {
self.owner_window().content_boxes_query(self)
pub(crate) fn border_box(&self) -> Option<Rect<Au>> {
self.owner_window()
.box_area_query(self, BoxAreaType::Border)
}
pub(crate) fn border_boxes(&self) -> Vec<Rect<Au>> {
self.owner_window()
.box_areas_query(self, BoxAreaType::Border)
}
pub(crate) fn client_rect(&self) -> Rect<i32> {