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

Unified Diff: lib/html/frog/html_frog.dart

Issue 10448020: Revert "Revert "Add cancelAnimationFrame"" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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:
Download patch
« no previous file with comments | « lib/dom/templates/html/interface/interface_Window.darttemplate ('k') | tests/html/html.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/html/frog/html_frog.dart
diff --git a/lib/html/frog/html_frog.dart b/lib/html/frog/html_frog.dart
index b6c15e0ebfedaed23560919f3590e72cbb6647f6..28e8a657cb29b250b18469e0750ef703fd69b90a 100644
--- a/lib/html/frog/html_frog.dart
+++ b/lib/html/frog/html_frog.dart
@@ -16375,22 +16375,37 @@ class _WindowImpl extends _EventTargetImpl implements Window native "@*DOMWindow
}
/** @domName DOMWindow.requestAnimationFrame */
- int requestAnimationFrame(RequestAnimationFrameCallback callback) native '''
- if (!window.requestAnimationFrame) {
- window.requestAnimationFrame =
- window.webkitRequestAnimationFrame ||
- window.mozRequestAnimationFrame ||
- window.msRequestAnimationFrame ||
- window.oRequestAnimationFrame ||
- function (callback) {
- window.setTimeout(callback, 16 /* 16ms ~= 60fps */);
- };
- }
- return window.requestAnimationFrame(callback);
-''';
+ int requestAnimationFrame(RequestAnimationFrameCallback callback) {
+ _ensureRequestAnimationFrame();
+ return _requestAnimationFrame(callback);
+ }
+
+ void cancelAnimationFrame(id) {
+ _ensureRequestAnimationFrame();
+ _cancelAnimationFrame(id);
+ }
- // Protect member 'requestAnimationFrame'.
- _requestAnimationFrame() native 'requestAnimationFrame';
+ int _requestAnimationFrame(RequestAnimationFrameCallback callback)
+ native 'requestAnimationFrame';
+
+ void _cancelAnimationFrame(int id)
+ native 'cancelAnimationFrame';
+
+ _ensureRequestAnimationFrame() native '''
+ if (this.requestAnimationFrame && this.cancelAnimationFrame) return;
+ var vendors = ['ms', 'moz', 'webkit', 'o'];
+ for (var i = 0; i < vendors.length && !this.requestAnimationFrame; ++i) {
+ this.requestAnimationFrame = this[vendors[i] + 'RequestAnimationFrame'];
+ this.cancelAnimationFrame =
+ this[vendors[i]+'CancelAnimationFrame'] ||
+ this[vendors[i]+'CancelRequestAnimationFrame'];
+ }
+ if (this.requestAnimationFrame && this.cancelAnimationFrame) return;
+ this.requestAnimationFrame = function(callback) {
+ return window.setTimeout(callback, 16 /* 16ms ~= 60fps */);
+ };
+ this.cancelAnimationFrame = function(id) { clearTimeout(id); }
+''';
_WindowEventsImpl get on() =>
@@ -34611,6 +34626,8 @@ interface Window extends EventTarget {
/** @domName DOMWindow.webkitRequestAnimationFrame */
int requestAnimationFrame(RequestAnimationFrameCallback callback);
+ void cancelAnimationFrame(int id);
+
/**
* @domName EventTarget.addEventListener, EventTarget.removeEventListener, EventTarget.dispatchEvent
« no previous file with comments | « lib/dom/templates/html/interface/interface_Window.darttemplate ('k') | tests/html/html.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698