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

Side by Side Diff: lib/dom/templates/html/frog/impl_Window.darttemplate

Issue 10450033: Revert "Add cancelAnimationFrame" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 class $CLASSNAME$EXTENDS$IMPLEMENTS native "@*DOMWindow" { 5 class $CLASSNAME$EXTENDS$IMPLEMENTS native "@*DOMWindow" {
6 6
7 _DocumentImpl get document() native "return this.document;"; 7 _DocumentImpl get document() native "return this.document;";
8 8
9 Window get _top() native "return this.top;"; 9 Window get _top() native "return this.top;";
10 10
11 // Override top to return secure wrapper. 11 // Override top to return secure wrapper.
12 Window get top() => _DOMWindowCrossFrameImpl._createSafe(_top); 12 Window get top() => _DOMWindowCrossFrameImpl._createSafe(_top);
13 13
14 void requestLayoutFrame(TimeoutHandler callback) { 14 void requestLayoutFrame(TimeoutHandler callback) {
15 _addMeasurementFrameCallback(callback); 15 _addMeasurementFrameCallback(callback);
16 } 16 }
17 17
18 /** @domName DOMWindow.requestAnimationFrame */ 18 /** @domName DOMWindow.requestAnimationFrame */
19 int requestAnimationFrame(RequestAnimationFrameCallback callback) { 19 int requestAnimationFrame(RequestAnimationFrameCallback callback) native '''
20 _ensureRequestAnimationFrame(); 20 if (!window.requestAnimationFrame) {
21 return _requestAnimationFrame(callback); 21 window.requestAnimationFrame =
22 } 22 window.webkitRequestAnimationFrame ||
23 window.mozRequestAnimationFrame ||
24 window.msRequestAnimationFrame ||
25 window.oRequestAnimationFrame ||
26 function (callback) {
27 window.setTimeout(callback, 16 /* 16ms ~= 60fps */);
28 };
29 }
30 return window.requestAnimationFrame(callback);
31 ''';
23 32
24 void cancelAnimationFrame(id) { 33 // Protect member 'requestAnimationFrame'.
25 _ensureRequestAnimationFrame(); 34 _requestAnimationFrame() native 'requestAnimationFrame';
26 _cancelAnimationFrame(id);
27 }
28
29 int _requestAnimationFrame(RequestAnimationFrameCallback callback)
30 native 'requestAnimationFrame';
31
32 void _cancelAnimationFrame(int id)
33 native 'cancelAnimationFrame';
34
35 _ensureRequestAnimationFrame() native '''
36 if (this.requestAnimationFrame && this.cancelAnimationFrame) return;
37 vendors = ['ms', 'moz', 'webkit', 'o', ''];
38 for (var i = 0; i < vendors.length && !this.requestAnimationFrame; ++i) {
39 this.requestAnimationFrame = this[vendors[i] + 'RequestAnimationFrame'];
40 this.cancelAnimationFrame =
41 this[vendors[i]+'CancelAnimationFrame'] ||
42 this[vendors[i]+'CancelRequestAnimationFrame'];
43 }
44 if (this.requestAnimationFrame && this.cancelAnimationFrame) return;
45 this.requestAnimationFrame = function(callback) {
46 window.setTimeout(callback, 16 /* 16ms ~= 60fps */);
47 };
48 this.cancelAnimationFrame = function(id) { clearTimeout(id); }
49 ''';
50 35
51 $!MEMBERS 36 $!MEMBERS
52 } 37 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698