mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-09 17:49:40 +00:00
LibWeb+LibGfx: Make IntersectionObserver checks edge-inclusive
This fixes an issue where 0x0 rectangles were not considered to be intersecting, even when they fell inside (or were adjacent to) the viewport.
This commit is contained in:
parent
4e653c99bb
commit
31a69ce887
Notes:
github-actions[bot]
2025-02-16 17:10:02 +00:00
Author: https://github.com/awesomekling
Commit: 31a69ce887
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3593
3 changed files with 11 additions and 6 deletions
|
@ -395,6 +395,12 @@ public:
|
||||||
&& other.top() < bottom();
|
&& other.top() < bottom();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] bool edge_adjacent_intersects(Rect<T> const& other) const
|
||||||
|
{
|
||||||
|
return max(left(), other.left()) <= min(right(), other.right())
|
||||||
|
&& max(top(), other.top()) <= min(bottom(), other.bottom());
|
||||||
|
}
|
||||||
|
|
||||||
template<typename Container>
|
template<typename Container>
|
||||||
[[nodiscard]] bool intersects(Container const& others) const
|
[[nodiscard]] bool intersects(Container const& others) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -4583,7 +4583,7 @@ void Document::run_the_update_intersection_observations_steps(HighResolutionTime
|
||||||
// 8. Let isIntersecting be true if targetRect and rootBounds intersect or are edge-adjacent, even if the
|
// 8. Let isIntersecting be true if targetRect and rootBounds intersect or are edge-adjacent, even if the
|
||||||
// intersection has zero area (because rootBounds or targetRect have zero area).
|
// intersection has zero area (because rootBounds or targetRect have zero area).
|
||||||
CSSPixelRect target_rect_as_pixel_rect(target_rect->x(), target_rect->y(), target_rect->width(), target_rect->height());
|
CSSPixelRect target_rect_as_pixel_rect(target_rect->x(), target_rect->y(), target_rect->width(), target_rect->height());
|
||||||
is_intersecting = target_rect_as_pixel_rect.intersects(root_bounds);
|
is_intersecting = target_rect_as_pixel_rect.edge_adjacent_intersects(root_bounds);
|
||||||
|
|
||||||
// 9. If targetArea is non-zero, let intersectionRatio be intersectionArea divided by targetArea.
|
// 9. If targetArea is non-zero, let intersectionRatio be intersectionArea divided by targetArea.
|
||||||
// Otherwise, let intersectionRatio be 1 if isIntersecting is true, or 0 if isIntersecting is false.
|
// Otherwise, let intersectionRatio be 1 if isIntersecting is true, or 0 if isIntersecting is false.
|
||||||
|
|
|
@ -2,10 +2,9 @@ Harness status: OK
|
||||||
|
|
||||||
Found 5 tests
|
Found 5 tests
|
||||||
|
|
||||||
2 Pass
|
5 Pass
|
||||||
3 Fail
|
|
||||||
Pass IntersectionObserver should detect and report edge-adjacent and zero-area intersections.
|
Pass IntersectionObserver should detect and report edge-adjacent and zero-area intersections.
|
||||||
Pass First rAF.
|
Pass First rAF.
|
||||||
Fail Set transform=translateY(200px) on target.
|
Pass Set transform=translateY(200px) on target.
|
||||||
Fail Set transform=translateY(201px) on target.
|
Pass Set transform=translateY(201px) on target.
|
||||||
Fail Set transform=translateY(185px) on target.
|
Pass Set transform=translateY(185px) on target.
|
Loading…
Add table
Add a link
Reference in a new issue