Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Page refreshes: Replace remaining calls to nextAnimationFrame by nextRepaint #1102

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/core/drive/visit.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { FetchMethod, FetchRequest } from "../../http/fetch_request"
import { getAnchor } from "../url"
import { PageSnapshot } from "./page_snapshot"
import { getHistoryMethodForAction, uuid } from "../../util"
import { getHistoryMethodForAction, uuid, nextRepaint } from "../../util"
import { StreamMessage } from "../streams/stream_message"
import { ViewTransitioner } from "./view_transitioner"

Expand Down Expand Up @@ -418,9 +418,7 @@ export class Visit {

async render(callback) {
this.cancelRender()
await new Promise((resolve) => {
this.frame = requestAnimationFrame(() => resolve())
})
this.frame = await nextRepaint()
await callback()
delete this.frame
}
Expand Down
8 changes: 4 additions & 4 deletions src/core/frames/frame_renderer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { activateScriptElement, nextAnimationFrame } from "../../util"
import { activateScriptElement, nextRepaint } from "../../util"
import { Renderer } from "../renderer"

export class FrameRenderer extends Renderer {
Expand All @@ -25,14 +25,14 @@ export class FrameRenderer extends Renderer {
}

async render() {
await nextAnimationFrame()
await nextRepaint()
this.preservingPermanentElements(() => {
this.loadFrameElement()
})
this.scrollFrameIntoView()
await nextAnimationFrame()
await nextRepaint()
this.focusFirstAutofocusableElement()
await nextAnimationFrame()
await nextRepaint()
this.activateScriptElements()
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/streams/stream_message_renderer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Bardo } from "../bardo"
import { getPermanentElementById, queryPermanentElementsAll } from "../snapshot"
import { around, elementIsFocusable, nextAnimationFrame, queryAutofocusableElement, uuid } from "../../util"
import { around, elementIsFocusable, nextRepaint, queryAutofocusableElement, uuid } from "../../util"

export class StreamMessageRenderer {
render({ fragment }) {
Expand Down Expand Up @@ -57,7 +57,7 @@ async function withAutofocusFromFragment(fragment, callback) {
}

callback()
await nextAnimationFrame()
await nextRepaint()

const hasNoActiveElement = document.activeElement == null || document.activeElement == document.body

Expand Down