mirror of
https://github.com/servo/servo.git
synced 2025-09-30 00:29:14 +01:00
script/layout: Ensure a StackingContextTree before IntersectionObserver geometry queries (#38473)
IntersectionObserver needs to be able to query node geometry without forcing a layout. A previous layout could have run without needing a `StackingContextTree`. In that case the layout-less query should finish building the `StackingContextTree` before doing the query. Add a new type of layout API which requests that layout finishes building the StackingContextTree. This change also slightly simplifies and corrects the naming of `Element` APIs around client box queries. Testing: This should fix intermittent failures in WPT tests. Fixes: #38380. Fixes: #38390. Closes: #38400. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
757dbc0eda
commit
44a11a7c6c
12 changed files with 78 additions and 59 deletions
|
@ -408,6 +408,7 @@ impl IntersectionObserver {
|
|||
///
|
||||
/// <https://w3c.github.io/IntersectionObserver/#intersectionobserver-root-intersection-rectangle>
|
||||
pub(crate) fn root_intersection_rectangle(&self, document: &Document) -> Option<Rect<Au>> {
|
||||
let window = document.window();
|
||||
let intersection_rectangle = match &self.root {
|
||||
// Handle if root is an element.
|
||||
Some(ElementOrDocument::Element(element)) => {
|
||||
|
@ -419,7 +420,7 @@ impl IntersectionObserver {
|
|||
|
||||
// > Otherwise, it’s the result of getting the bounding box for the intersection root.
|
||||
// TODO: replace this once getBoundingBox() is implemented correctly.
|
||||
DomRoot::upcast::<Node>(element.clone()).bounding_content_box_no_reflow()
|
||||
window.content_box_query_without_reflow(&DomRoot::upcast::<Node>(element.clone()))
|
||||
},
|
||||
// Handle if root is a Document, which includes implicit root and explicit Document root.
|
||||
_ => {
|
||||
|
@ -503,7 +504,9 @@ impl IntersectionObserver {
|
|||
// This is what we are currently using for getBoundingBox(). However, it is not correct,
|
||||
// mainly because it is not considering transform and scroll offset.
|
||||
// TODO: replace this once getBoundingBox() is implemented correctly.
|
||||
let maybe_target_rect = target.upcast::<Node>().bounding_content_box_no_reflow();
|
||||
let maybe_target_rect = document
|
||||
.window()
|
||||
.content_box_query_without_reflow(target.upcast::<Node>());
|
||||
|
||||
// Following the implementation of Gecko, we will skip further processing if these
|
||||
// information not available. This would also handle display none element.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue