mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:17:34 +00:00
LibWeb: Scroll to the "start" in Document::scroll_to_fragment()
Implements spec comment.
This commit is contained in:
parent
7458c27c4b
commit
c5d91dce8b
3 changed files with 40 additions and 2 deletions
1
Tests/LibWeb/Text/expected/scroll-to-fragment.txt
Normal file
1
Tests/LibWeb/Text/expected/scroll-to-fragment.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Take test The page has been scrolled to y: 562.59375
|
35
Tests/LibWeb/Text/input/scroll-to-fragment.html
Normal file
35
Tests/LibWeb/Text/input/scroll-to-fragment.html
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<style type="text/css">
|
||||||
|
#top {
|
||||||
|
margin-top: 500px;
|
||||||
|
padding-top: 100px;
|
||||||
|
background-color: navy;
|
||||||
|
width: 100%;
|
||||||
|
height: 50px;
|
||||||
|
}
|
||||||
|
.picture {
|
||||||
|
background: magenta !important;
|
||||||
|
position: relative;
|
||||||
|
height: 50px;
|
||||||
|
width: 100%;
|
||||||
|
margin-bottom: 1000px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<a style="font-size: 50px" href="#top" id="link">Take test</a>
|
||||||
|
<div id="top"></div>
|
||||||
|
<div class="picture"></div>
|
||||||
|
<script src="include.js"></script>
|
||||||
|
<script>
|
||||||
|
asyncTest(done => {
|
||||||
|
let completed = false;
|
||||||
|
document.addEventListener("scroll", event => {
|
||||||
|
if (completed)
|
||||||
|
return;
|
||||||
|
completed = true;
|
||||||
|
println("The page has been scrolled to y: " + window.scrollY);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById("link").click();
|
||||||
|
});
|
||||||
|
</script>
|
|
@ -1842,8 +1842,10 @@ void Document::scroll_to_the_fragment()
|
||||||
// FIXME: 5. Run the ancestor hidden-until-found revealing algorithm on target.
|
// FIXME: 5. Run the ancestor hidden-until-found revealing algorithm on target.
|
||||||
|
|
||||||
// 6. Scroll target into view, with behavior set to "auto", block set to "start", and inline set to "nearest". [CSSOMVIEW]
|
// 6. Scroll target into view, with behavior set to "auto", block set to "start", and inline set to "nearest". [CSSOMVIEW]
|
||||||
// FIXME: Do this properly!
|
ScrollIntoViewOptions scroll_options;
|
||||||
(void)target->scroll_into_view();
|
scroll_options.block = Bindings::ScrollLogicalPosition::Start;
|
||||||
|
scroll_options.inline_ = Bindings::ScrollLogicalPosition::Nearest;
|
||||||
|
(void)target->scroll_into_view(scroll_options);
|
||||||
|
|
||||||
// 7. Run the focusing steps for target, with the Document's viewport as the fallback target.
|
// 7. Run the focusing steps for target, with the Document's viewport as the fallback target.
|
||||||
// FIXME: Pass the Document's viewport somehow.
|
// FIXME: Pass the Document's viewport somehow.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue