[profview] Use requestAnimationFrame to schedule a render

This is more idiomatic than using a Promise.

Change-Id: I61443e90ef1c0c589284851ea9be410153919eb5
Reviewed-on: https://chromium-review.googlesource.com/c/456278
Reviewed-by: Jaroslav Sevcik <jarin@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58828}
This commit is contained in:
Leszek Swirski 2017-03-17 12:21:03 +00:00 committed by Commit Bot
parent 57fa8f5ba3
commit d92705e53b

View File

@ -55,6 +55,7 @@ function setCallTreeState(state, callTreeState) {
let main = {
currentState : emptyState(),
renderPending : false,
setMode(mode) {
if (mode !== main.currentState.mode) {
@ -197,7 +198,11 @@ let main = {
},
delayRender() {
Promise.resolve().then(() => {
if (main.renderPending) return;
main.renderPending = true;
window.requestAnimationFrame(() => {
main.renderPending = false;
for (let c of components) {
c.render(main.currentState);
}