mirror of
https://github.com/servo/servo.git
synced 2025-08-09 15:35:34 +01:00
script: Prevent "scroll to fragment" from scrolling offscreen (#32129)
Previously, the "scroll to fragment" operation could scroll past the end of the screen, because the scroll position was not clamped to viewport boundaries. Correct this by using the `Window::scroll()` method which handles this case. In addition, ensure that `Window`'s `current_viewport` member is initialized properly when it is created.
This commit is contained in:
parent
bef6c295aa
commit
1440406e91
6 changed files with 60 additions and 20 deletions
|
@ -0,0 +1,3 @@
|
|||
[scroll-position-vertical-lr.html]
|
||||
[Fragment Navigation: Scroll to block start position in vertical-lr writing mode]
|
||||
expected: FAIL
|
|
@ -621660,6 +621660,13 @@
|
|||
}
|
||||
]
|
||||
],
|
||||
"scroll-position-inline-nearest.html": [
|
||||
"4aab0aa5e5a1e4a3eea82282be2344586a9a6d02",
|
||||
[
|
||||
null,
|
||||
{}
|
||||
]
|
||||
],
|
||||
"scroll-position-vertical-lr.html": [
|
||||
"57d99440e114968e7dcd1b61ebf2d18c7bca987b",
|
||||
[
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
[scroll-position-vertical-lr.html]
|
||||
[Fragment Navigation: Scroll to block start position in vertical-lr writing mode]
|
||||
expected: FAIL
|
|
@ -0,0 +1,30 @@
|
|||
<!DOCTYPE html>
|
||||
<html style="writing-mode: vertical-lr;">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Fragment Navigation: inline start position should not scroll out of content range</title>
|
||||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#scroll-to-the-fragment-identifier">
|
||||
<link rel="author" href="mailto:mrobinson@igalia.com" title="Martin Robinson">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<!-- When scrolling to this fragment the viewport inline position should not
|
||||
change because, it is already fully enclosed by the viewport and page width. -->
|
||||
<div id="test1" style="position: absolute; top: 5000px; left: 100px; height: 100px; width: 100px;"></div>
|
||||
<script>
|
||||
|
||||
var t = async_test("ScrollToFragment");
|
||||
t.step(() => {
|
||||
location.hash = "test1";
|
||||
setTimeout(t.step_func(() => {
|
||||
assert_true(window.scrollY > 0);
|
||||
assert_true(window.scrollY < 5000);
|
||||
assert_equals(window.scrollX, 0);
|
||||
t.done();
|
||||
}));
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue