layout: Add a query for getting the effective overflow of an element and use it in script#42251
Conversation
| if element | ||
| .upcast::<Node>() | ||
| .effective_overflow_without_reflow() | ||
| .is_some_and(|overflow_axes| { | ||
| overflow_axes.x != Overflow::Visible || overflow_axes.y != Overflow::Visible | ||
| }) | ||
| { |
There was a problem hiding this comment.
We are not supposed to use style() here anyway, since it would reflow the fragment tree. Unfortunately (or fortunately?) this fixes also reveals some failures, and /intersection-observer/animating.html becoming intermittent.
I take a look at it and it is possibly caused by either timing related issues or whether we matches the implementation of other user agents (and the WPTs) or not. There are some section within the spec that doesn't really matches the implementation of UAs.
Looking to check the failures more in the patch specific for ensuring the conformance.
There was a problem hiding this comment.
I think we need a bit more investigation about why these tests are becoming intermittent. Causing a test to become intermittent isn't a great outcome.
There was a problem hiding this comment.
Further investigation shows that by the time we are observing the element, the animation already went through 30% of it therefore the first observation passes records not intersecting.
servo/tests/wpt/tests/intersection-observer/animating.html
Lines 43 to 51 in d70ab4e
I am suspecting the slow down is caused by running test in parallel in local machine, since running the single test results in stable passes.
Considering these changes, I have increased the duration of the animation to increase the leniency, as there are no need to measure such performance in WPT test anyway. What do you think of the changes?
| if !self.has_css_layout_box() || !self.establish_scroll_container() || !self.has_overflow() | ||
| { | ||
| return; | ||
| } |
There was a problem hiding this comment.
Although the spec mentioned scrolling box for which I understand that we need to check whether the element has scrollable overflow. The very next clauses directly specify that we need to have an overflow as well.
This would prevent us from performing unnecessary operation on a element that is not supposed to be scrollable since overflow could be ignored further in the pipeline.
mrobinson
left a comment
There was a problem hiding this comment.
It feels like you should be able to make a test case where this matters. For instance, replaced elements and some table parts do not establish a scrolling box. Without a test, it's a bit hard to see what this is solving as it just adds failures.
|
|
||
| // Step 10 | ||
| if !self.has_css_layout_box() || !self.has_scrolling_box() || !self.has_overflow() { | ||
| if !self.has_css_layout_box() || !self.establish_scroll_container() || !self.has_overflow() |
There was a problem hiding this comment.
This change moves the line further from the specification:
Step 10 from https://drafts.csswg.org/cssom-view/#dom-element-scroll:
If the element does not have any associated box, the element has no associated scrolling box, or the element has no overflow, return a resolved Promise and abort the remaining steps.
There was a problem hiding this comment.
Thanks for the review!
I am renaming the Node.has_scrolling_box to Node.establishes_scroll_container, since the previous implementation is not following the definition (being closer to scroll container definition rather than scrolling box).
Honestly, I am unable to find the concrete definition in the spec. Being removed in w3c/csswg-drafts@f19b64a (being removed maybe by accident?).
I guess we could follow this definition and define scrolling box for Node and establishes scroll container maybe using the one within Element separately.
What do you think?
There was a problem hiding this comment.
Ah, I wasn't aware of the recent deletion so I'll need to take a closer look. Thanks for the link.
| // TODO: Is this the right thing to do? Maybe `Document` should be ignored and viewport | ||
| // should be represented by the root of the DOM flat tree. | ||
| if self.is::<Document>() { | ||
| return true; | ||
| } | ||
| let Some(element) = self.downcast::<Element>() else { | ||
| // Shadow roots and other nodes are not scrolling boxes. |
There was a problem hiding this comment.
Perhaps it makes sense to preserve this method since it is an implementation of the specification, but properly implement this last step?
There was a problem hiding this comment.
I was deleting this before because in terms of logic it is almost identical to the former Node.has_scrolling_box and it is not being used anywhere.
I guess |
|
🤖 Opened new upstream WPT pull request (web-platform-tests/wpt#57481) with upstreamable changes. |
14ac256 to
d336f6d
Compare
|
📝 Transplanted new upstreamable changes to existing upstream WPT pull request (web-platform-tests/wpt#57481). |
d336f6d to
726abe6
Compare
|
📝 Transplanted new upstreamable changes to existing upstream WPT pull request (web-platform-tests/wpt#57481). |
|
Sorry @mrobinson, I have added a WPT of What do you think of the current state? Since scrolling box definition is missing, and the condition checked in scroll doesn't change whether we uses the deleted definition of scrolling box or just scroll container (because we checked whether they have overflow afterwards), we could possibly leave it as is, leave some TODOs and put up an issue about this in cssom. |
|
📝 Transplanted new upstreamable changes to existing upstream WPT pull request (web-platform-tests/wpt#57481). |
Added an implementation based on this. Please let me know if this align and appropriate. Thanks! |
ba7c34c to
b187ff1
Compare
|
📝 Transplanted new upstreamable changes to existing upstream WPT pull request (web-platform-tests/wpt#57481). |
b187ff1 to
def0706
Compare
|
✍ Updated existing upstream WPT pull request (web-platform-tests/wpt#57481) title and body. |
| // > Elements and viewports have an associated scrolling box if the element or viewport has a scrolling mechanism, | ||
| // > or it overflows its content area and the used value of the overflow-x or overflow-y property is not | ||
| // > overflow/hidden or overflow/clip. [CSS3-BOX] | ||
| // TODO: handle scrolling mechanism. |
There was a problem hiding this comment.
Please expand this comment. "handle scrolling mechanism" is very vague. I'm not sure what it means.
There was a problem hiding this comment.
I believe it is something that is already very vague from the spec, for now I am mentioning that it is something that depends on the spec. But we could add some possible definition like whether scrolling mechanism means that the element have a scrollbar. What do you think?
|
📝 Transplanted new upstreamable changes to existing upstream WPT pull request (web-platform-tests/wpt#57481). |
Signed-off-by: Jo Steven Novaryo <[email protected]>
Signed-off-by: Jo Steven Novaryo <[email protected]>
Signed-off-by: Jo Steven Novaryo <[email protected]>
ec2272a to
58c7999
Compare
|
📝 Transplanted new upstreamable changes to existing upstream WPT pull request (web-platform-tests/wpt#57481). |
script
Signed-off-by: Martin Robinson <[email protected]>
|
✍ Updated existing upstream WPT pull request (web-platform-tests/wpt#57481) title and body. |
mrobinson
left a comment
There was a problem hiding this comment.
Please be careful when modifying functions or their visibility that they have the minimum visibility necessary. Generally this is pub(crate) if it needs to be public.
Signed-off-by: Martin Robinson <[email protected]>
|
📝 Transplanted new upstreamable changes to existing upstream WPT pull request (web-platform-tests/wpt#57481). |
1 similar comment
|
📝 Transplanted new upstreamable changes to existing upstream WPT pull request (web-platform-tests/wpt#57481). |
Thanks! It does make more sense to expose this to crate. |
…ection algo (#42204) Depends on #42251 for the overflow query. Use containing block queries to implement the iteration of step [3.2.7. Compute the Intersection of a Target Element and the Root](https://w3c.github.io/IntersectionObserver/#compute-the-intersection) within `IntersectionObserver` algorithm. Contrary to the algorithm in the spec that maps the coordinate space of the element for each iteration, we uses bounding client rect queries to get the appropriate clip rect. And, to handle the mapping between different coordinate spaces of iframes, we use a simple translation. Due to the platform limitation, currently it would only handle the same `ScriptThread` browsing context. Therefore innaccuracy any usage with cross origin iframes is expected. Testing: Existing and new WPTs. Part of: #35767 Co-authored-by: Josh Matthews [[email protected]]([email protected]) --------- Signed-off-by: Josh Matthews <[email protected]> Signed-off-by: Jo Steven Novaryo <[email protected]> Co-authored-by: Josh Matthews <[email protected]>
…and use it in `script` (servo#42251) In layout calculation within script, Instead of relying on the computed values for overflow, query the overflow from layout for its used value to accurately reflect whether an element establish a scroll container. This query will be used for `IntersectionObserver` as well. Testing: There are new `IntersectionObserver` WPT failures: - `intersection-observer/isIntersecting-change-events.html` - `intersection-observer/containing-block.html` The failures are more than likely a false positive because intersection observation steps wasn't supposed to trigger a reflow, but it was before. It could be caused by the implementation of `IntersectionObserver` in major UAs being a little bit different from the spec in the calculation of `threshold` and `isIntersecting` . --------- Signed-off-by: Jo Steven Novaryo <[email protected]> Signed-off-by: Martin Robinson <[email protected]> Co-authored-by: Martin Robinson <[email protected]> (cherry picked from commit a672397)
In layout calculation within script, Instead of relying on the computed values for overflow, query the overflow from layout for its used value to accurately reflect whether an element establish a scroll container. This query will be used for
IntersectionObserveras well.Testing: There are new
IntersectionObserverWPT failures:intersection-observer/isIntersecting-change-events.htmlintersection-observer/containing-block.htmlThe failures are more than likely a false positive because intersection observation steps wasn't supposed to trigger a reflow, but it was before. It could be caused by the implementation of
IntersectionObserverin major UAs being a little bit different from the spec in the calculation ofthresholdandisIntersecting.