237 // Calculate desired delay. frameDurationAtIndex() tells us how long the
238 // current frame wants to be visible. Reduce this by the amount of time
239 // we've spent drawing since we advanced to this frame, so that the
240 // animation appears to run at the correct framerate regardless of drawing
241 // lag. (In the common case, the drawing lag for the next frame will be
242 // similar, and thus the frame will actually be visible for almost the exact
243 // same amount of time it requests to be visible.)
244 double delay = frameDurationAtIndex(m_currentFrame);
245 if (m_lastAnimationFrameTime != 0)
246 delay -= (currentTime() - m_lastAnimationFrameTime);
247 if (delay < 0)
248 delay = 0;
249