mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-03 17:58:55 +02:00
Before this patch, it could happen that `PresShell::GoToAnchor()` was called while loading a document. This method did not know about text fragments before, and would scroll the anchor (ie., the first text directive) to the top of the view. This was noticeable for pages that took longer to load, where the text directive was scrolled to the center first, and then to the top. This patch saves the desired vertical scroll position as a member in `PresShell` and makes `GoToAnchor()` scroll to the center as well. Additionally, this patch updates the test file target document to make it more mobile-friendly. Differential Revision: https://phabricator.services.mozilla.com/D216039
26 lines
721 B
HTML
26 lines
721 B
HTML
<!DOCTYPE html>
|
|
<title>
|
|
Ensuring a text directive is scrolled to the center of the view port instead of the top.
|
|
</title>
|
|
<script src="stash.js"></script>
|
|
<script>
|
|
function checkScroll() {
|
|
const results = {hasScrolled: window.scrollY != 0};
|
|
let key = (new URL(document.location)).searchParams.get("key");
|
|
stashResultsThenClose(key, results);
|
|
};
|
|
window.onload = () => {
|
|
window.requestAnimationFrame(function() {
|
|
window.requestAnimationFrame(checkScroll);
|
|
})
|
|
}
|
|
</script>
|
|
<body>
|
|
<script>
|
|
document.addEventListener("DOMContentLoaded", () => {
|
|
// trigger a layout flush
|
|
_ = document.body.getBoundingClientRect();
|
|
});
|
|
</script>
|
|
<div style="margin-top: 20vh; margin-bottom: 100vh">Scroll to me</div>
|
|
</body>
|