| OLD | NEW |
| 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) native ''' | 19 int requestAnimationFrame(RequestAnimationFrameCallback callback) { |
| 20 if (!window.requestAnimationFrame) { | 20 _ensureRequestAnimationFrame(); |
| 21 window.requestAnimationFrame = | 21 return _requestAnimationFrame(callback); |
| 22 window.webkitRequestAnimationFrame || | 22 } |
| 23 window.mozRequestAnimationFrame || | 23 |
| 24 window.msRequestAnimationFrame || | 24 void cancelAnimationFrame(id) { |
| 25 window.oRequestAnimationFrame || | 25 _ensureRequestAnimationFrame(); |
| 26 function (callback) { | 26 _cancelAnimationFrame(id); |
| 27 window.setTimeout(callback, 16 /* 16ms ~= 60fps */); | 27 } |
| 28 }; | 28 |
| 29 } | 29 int _requestAnimationFrame(RequestAnimationFrameCallback callback) |
| 30 return window.requestAnimationFrame(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); } |
| 31 '''; | 49 '''; |
| 32 | 50 |
| 33 // Protect member 'requestAnimationFrame'. | |
| 34 _requestAnimationFrame() native 'requestAnimationFrame'; | |
| 35 | |
| 36 $!MEMBERS | 51 $!MEMBERS |
| 37 } | 52 } |
| OLD | NEW |