forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1861541 [wpt PR 42796] - Improve scroller loop for intersection o…
…bserver scroll margin, a=testonly Automatic update from web-platform-tests Improve scroller loop for intersection observer scroll margin Now if there are scroll margins, collect the intermediate scrollers into a vector in RootAndTarget when walking the containing block chain in RootAndTarget::ComputeRelationship() instead of walk the containing block chain again in ClipToRoot(). For scroll margin, ClipToRoot() now calls ApplyClip() in a loop instead of calling itself recursively. Bug: 1485750 Change-Id: I0be9ff83df91969c9253235e11387dbe48042a82 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4977999 Reviewed-by: Traian Captan <[email protected]> Commit-Queue: Xianzhu Wang <[email protected]> Cr-Commit-Position: refs/heads/main@{#1218947} -- wpt-commits: 8ffb3d9a7243e4d115f38b631dd87c50957e8115 wpt-pr: 42796
- Loading branch information
1 parent
a970a37
commit 2ec732a
Showing
2 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
testing/web-platform/tests/intersection-observer/scroll-margin-not-contained.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<!DOCTYPE html> | ||
<meta name="viewport" content="width=device-width,initial-scale=1"> | ||
<link rel="help" href="https://www.w3.org/TR/intersection-observer/#dom-intersectionobserver-scrollmargin"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="./resources/intersection-observer-test-utils.js"></script> | ||
|
||
<style> | ||
#scroller { width: 100px; height: 100px; overflow: hidden; background-color: gray; position: absolute; } | ||
#target { width: 50px; height: 50px; background-color: green; } | ||
</style> | ||
|
||
<div id=root> | ||
<div id=scroller> | ||
<div id=target></div> | ||
</div> | ||
</div> | ||
|
||
<script> | ||
let entries = []; | ||
|
||
window.onload = function() { | ||
runTestCycle(testIntersection, "Test scroll margin intersection"); | ||
|
||
const observer = new IntersectionObserver( | ||
es => entries = entries.concat(es), | ||
{ | ||
root: document.querySelector("#root"), | ||
scrollMargin: "10px" | ||
} | ||
); | ||
observer.observe(target); | ||
}; | ||
|
||
function testIntersection() { | ||
assert_equals(entries.length, 1, "IntersectionObserverEntryCount"); | ||
// Not insecting because root is not in the containing block chain of target. | ||
assert_false(entries[0].isIntersecting, "isIntersecting"); | ||
} | ||
</script> |
39 changes: 39 additions & 0 deletions
39
testing/web-platform/tests/intersection-observer/scroll-margin-with-border-outline.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<!DOCTYPE html> | ||
<meta name="viewport" content="width=device-width,initial-scale=1"> | ||
<link rel="help" href="https://www.w3.org/TR/intersection-observer/#dom-intersectionobserver-scrollmargin"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="./resources/intersection-observer-test-utils.js"></script> | ||
|
||
<style> | ||
#scroller { width: 100px; height: 100px; overflow: hidden; background-color: gray; border: 10px solid black; outline: 10px solid blue; } | ||
#spacer { width: 50px; height: 100px; } | ||
#target { width: 50px; height: 50px; background-color: green; } | ||
</style> | ||
|
||
<div id=scroller> | ||
<div id=spacer></div> | ||
<div id=target></div> | ||
</div> | ||
|
||
<script> | ||
let entries = []; | ||
|
||
window.onload = function() { | ||
runTestCycle(testIntersection, "Test scroll margin intersection"); | ||
|
||
const observer = new IntersectionObserver( | ||
es => entries = entries.concat(es), | ||
{ | ||
scrollMargin: "10px" | ||
} | ||
); | ||
observer.observe(target); | ||
}; | ||
|
||
function testIntersection() { | ||
assert_equals(entries.length, 1, "IntersectionObserverEntryCount"); | ||
assert_true(entries[0].isIntersecting, "isIntersecting"); | ||
assert_approx_equals(entries[0].intersectionRatio, 0.2, 0.001, "intersectionRatio"); | ||
} | ||
</script> |