Repository navigation
layout: Consider transform for bounding box queries - #37871
Conversation
9075106 to
b14d011
Compare
|
🔨 Triggering try run (#16068624961) for Linux (WPT) |
|
Test results for linux-wpt from try job (#16068624961): Flaky unexpected result (12)
Stable unexpected results that are known to be intermittent (25)
Stable unexpected results (22)
|
|
|
Details About the Calculation of Transformation MatrixScroll Tree & Transformation MatrixDefinition:
Within a scroll tree node, a reference frame represent a transform that would apply for an painting object and its children. Basically, reference frame was represented by the transformation matrix that was composed out of two component, that is transform origin and the collective transform itself. See https://drafts.csswg.org/css-transforms/#transformation-matrix-computation. Note that, a transformation matrix, the transform origin is relative to the element itself. Traversing Scroll Node Tree To Calculate the Current Transformation MatrixDefinition Let's check what do we have currently at Servo for these kind of queries. To calculate these queries we would have:
Ideally we could just multiply the matrices that would affect an element. However, note that a matrix within a reference frame is relative to the element that creates it (i.e., within element's coordinate space) and the bounding rect that we have is relative to the document. To handle this, for each step of the transformation, we could convert the box into the coordinate space of the reference frame. Right now the conversion only include the translations to correctly position the transform origin, but we would also includes zoom (i.e., scaling) in the future. To handle that, this PR add an additional attribute Note that, both of these does not prevent the caching of the transform, since they are linear transformation that could be represented by the transformation matrix. |
xiaochengh
left a comment
There was a problem hiding this comment.
This is really nice! LGTM.
|
Could you resolve merge conflicts? And then let me know when it's ready to merge. Thank you! |
b431a08 to
e0cae5c
Compare
|
Rebased! @xiaochengh |
mrobinson
left a comment
There was a problem hiding this comment.
I could see attaching the scroll tree node to the BoxFragment being good for memory usage if it ultimately allows us to remove the expensive hit testing data structure we sent to the compositor.
| /// TODO(stevennovaryo): Rename and parameterize the function, allowing padding area | ||
| /// query and possibly, query without consideration of transform. |
There was a problem hiding this comment.
Why will this be useful, out of curiosity? Instead of this TODO, I would open an issue as maybe this requires a bit of design discussion.
There was a problem hiding this comment.
It is useful for intersection observer, specifically in getting the root intersection rectangle https://w3c.github.io/IntersectionObserver/#intersectionobserver-root-intersection-rectangle. Where we need to use padding rect instead of border rect in the query.
As for query without transformation, I suppose it is just a preliminary thoughts. Currently, I think that it is better to kept them separate. Will file an issue for this (after addressing all comments).
|
|
||
| let new_spatial_id = stacking_context_tree.push_reference_frame( | ||
| reference_frame_data.origin.to_webrender(), | ||
| frame_origin_for_query, |
There was a problem hiding this comment.
Is this truly the right value to use for this? It isn't taking into account any of the information from ancestors such as scroll offsets and transforms...
There was a problem hiding this comment.
Yes, we need this find the correct offset (relative to the document) when a transformation happens. And, the offset of the given rect in the queries was without any transform (and in fact, is using the cumulative box as well).
29efaef to
71fa07e
Compare
71fa07e to
f869286
Compare
|
Still LGTM. Pinging @mrobinson for another round of review... |
f869286 to
43d41eb
Compare
|
I made a change to this PR which ensured that the stacking context tree is available for geometry queries and it seems to have introduced some panics. A bit more investigation is necessary here, I think. |
Signed-off-by: Martin Robinson <[email protected]>
ac13b1c to
c58f8ab
Compare
|
The assertion seems to have caught an issue with float fragments which weren't having scroll nodes assigned properly. |
|
I suspect there is going to be an issue with |
|
🔨 Triggering try run (#16599804308) for Linux (WPT) |
|
Test results for linux-wpt from try job (#16599804308): Flaky unexpected result (13)
Stable unexpected results that are known to be intermittent (22)
Stable unexpected results (4)
|
|
|
Signed-off-by: Jo Steven Novaryo <[email protected]>
Signed-off-by: Jo Steven Novaryo <[email protected]>
|
🤖 Opened new upstream WPT pull request (web-platform-tests/wpt#54044) with upstreamable changes. |
|
Thanks for tidying up the codes! The recent WPT errors caused by assigning the wrong spatial nodes for this context. We should not assign the scroll node since it would affects only the children of the fragment.
Thanks for catching the issue with float fragments, it should be assigned with correct nodes as well.
Added minimal WPTs for scroll, It should be correct as long as a BoxFragment went through the stacking context construction phases. If not, it could find the closest parent that does and calculate the transformation from there. Since fragment that does not went through that phases is not creating any frame, it would present a correct calculation. |
|
🔨 Triggering try run (#16614693519) for Linux (WPT) |
|
Test results for linux-wpt from try job (#16614693519): Flaky unexpected result (25)
Stable unexpected results that are known to be intermittent (23)
|
|
✨ Try run (#16614693519) succeeded. |
The recent changes that cached the Scroll Tree present an opportunity to calculate the queries that consider transform and scroll (dubbed as post composite queries) accurately.
This PR propose a solution for this calculation by noting the lowest scroll tree nodes that would affect a fragment. To do this, each fragment would store a new attribute
spatial_tree_node-- scroll tree node id that we could use for the query. This referencing is considered because the scroll tree node construction is managed by the fragment itself. Therefore it would ease the managing the possibly stale reference and future query cache invalidation considering the development of incremental layout.The bounding box query then could transform the bounding content rect of a fragment using the computed current transformation matrix.
Fixes: #35768
Testing: Existing and new WPT