Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4465)

Unified Diff: client/base/AnimationScheduler.dart

Issue 8277005: Make the AnimationController class future compatible, and also change it to (Closed) Base URL: http://dart.googlecode.com/svn/trunk/dart/
Patch Set: Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/base/AnimationScheduler.dart
===================================================================
--- client/base/AnimationScheduler.dart (revision 386)
+++ client/base/AnimationScheduler.dart (working copy)
@@ -43,7 +43,7 @@
bool _isMobileSafari = false;
Css _safariHackCss;
int _frameCount = 0;
- bool _webkitAnimationFrameMaybeAvailable = true;
+ bool _animationFrameMaybeAvailable = true;
AnimationScheduler()
: _callbacks = new List<CallbackData>() {
@@ -93,17 +93,35 @@
if (USE_INTERVALS) {
_intervalId = window.setInterval(_step, MS_PER_FRAME);
} else {
- if (_webkitAnimationFrameMaybeAvailable) {
+ if (_animationFrameMaybeAvailable) {
+ // First try to see if the browser supports the requestAnimationFrame API,
+ // and if that check fails, fall back to using WebKit/Mozilla/IE specific
+ // versions of the API.
try {
// TODO(jacobr): passing in document should not be required.
- _intervalId = window.webkitRequestAnimationFrame(
+ _intervalId = window.requestAnimationFrame(
Jacob 2011/10/17 18:24:57 This approach would cause multiple exceptions to b
(int ignored) { _step(); }, document);
// TODO(jacobr) fix this odd type error.
} catch (var e) {
- _webkitAnimationFrameMaybeAvailable = false;
+ try {
+ _intervalId = window.webkitRequestAnimationFrame(
+ (int ignored) { _step(); }, document);
+ } catch (var e) {
+ try {
Jacob 2011/10/17 18:24:57 at some point, window.mozRequestAnimationFrame mig
+ _intervalId = window.mozRequestAnimationFrame(
+ (int ignored) { _step(); }, document);
+ } catch (e) {
+ try {
+ _intervalId = window.msRequestAnimationFrame(
+ (int ignored) { _step(); }, document);
+ } catch (var e) {
+ _animationFrameMaybeAvailable = false;
+ }
+ }
+ }
}
}
- if (!_webkitAnimationFrameMaybeAvailable) {
+ if (!_animationFrameMaybeAvailable) {
_intervalId = window.setTimeout(() { _step(); }, MS_PER_FRAME);
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698