Bug 1637767 [wpt PR 23580] - ScrollAnchoring: Prioritize focus/find-in-page during anchor selection., a=testonly

Automatic update from web-platform-tests
ScrollAnchoring: Prioritize focus/find-in-page during anchor selection.

This patch updates the scroll anchoring selection to consider
- focused element
- find-in-page active match results

If an anchor is selected out of those candidates, then it is used.
Otherwise, we proceed with the DOM traversal.

This is updated due to changes in the spec:
396d0cf9dc

Fixed: 1066924, 1066982
R=chrishtr@chromium.org, flackr@chromium.org

Change-Id: I1af88dfdeea374c17161b86981b10fbdcecc3a1a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2199603
Commit-Queue: Chris Harrelson <chrishtr@chromium.org>
Reviewed-by: Chris Harrelson <chrishtr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#768809}

--

wpt-commits: 3f7e4a75423bb6025be6011e4c86ac53939f4d15
wpt-pr: 23580
This commit is contained in:
Vladimir Levin 2020-05-21 10:18:31 +00:00 коммит произвёл moz-wptsync-bot
Родитель 63f7a52ec8
Коммит bdf56b8d7f
1 изменённых файлов: 46 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,46 @@
<!DOCTYPE html>
<meta charset="utf8">
<title>CSS Scroll Anchoring: prioritize focused element</title>
<link rel="author" title="Vladimir Levin" href="mailto:vmpstr@chromium.org">
<link rel="help" href="https://drafts.csswg.org/css-scroll-anchoring/#anchor-node-selection">
<meta name="assert" content="anchor selection prioritized focused element">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
body { height: 4000px }
.spacer { height: 100px }
#growing { height: 100px }
#focused { height: 10px }
</style>
<div class=spacer></div>
<div class=spacer></div>
<div class=spacer></div>
<div class=spacer></div>
<div id=growing></div>
<div class=spacer></div>
<div id=focused tabindex=0></div>
<div class=spacer></div>
<div class=spacer></div>
<script>
async_test((t) => {
document.scrollingElement.scrollTop = 150;
focused.focus();
const target_rect = focused.getBoundingClientRect();
growing.style.height = "3000px";
requestAnimationFrame(() => {
t.step(() => {
const new_rect = focused.getBoundingClientRect();
assert_equals(new_rect.x, target_rect.x, "x coordinate");
assert_equals(new_rect.y, target_rect.y, "y coordinate");
assert_not_equals(document.scrollingElement.scrollTop, 150, "scroll adjusted");
});
t.done();
});
}, "Anchor selection prioritized focused element.");
</script>