| 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 part of $LIBRARYNAME; | 5 part of $LIBRARYNAME; |
| 6 | 6 |
| 7 typedef void RemoveFrameRequestMapping(int id); | 7 typedef void RemoveFrameRequestMapping(int id); |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * The task object representing animation-frame requests. | 10 * The task object representing animation-frame requests. |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 set location(value) { | 180 set location(value) { |
| 181 _location = value; | 181 _location = value; |
| 182 } | 182 } |
| 183 | 183 |
| 184 // Native getter and setter to access raw Location object. | 184 // Native getter and setter to access raw Location object. |
| 185 dynamic get _location => JS('Location|Null', '#.location', this); | 185 dynamic get _location => JS('Location|Null', '#.location', this); |
| 186 set _location(value) { | 186 set _location(value) { |
| 187 JS('void', '#.location = #', this, value); | 187 JS('void', '#.location = #', this, value); |
| 188 } | 188 } |
| 189 | 189 |
| 190 $endif |
| 191 |
| 190 /** | 192 /** |
| 191 * Called to draw an animation frame and then request the window to repaint | 193 * Called to draw an animation frame and then request the window to repaint |
| 192 * after [callback] has finished (creating the animation). | 194 * after [callback] has finished (creating the animation). |
| 193 * | 195 * |
| 194 * Use this method only if you need to later call [cancelAnimationFrame]. If | 196 * Use this method only if you need to later call [cancelAnimationFrame]. If |
| 195 * not, the preferred Dart idiom is to set animation frames by calling | 197 * not, the preferred Dart idiom is to set animation frames by calling |
| 196 * [animationFrame], which returns a Future. | 198 * [animationFrame], which returns a Future. |
| 197 * | 199 * |
| 198 * Returns a non-zero valued integer to represent the request id for this | 200 * Returns a non-zero valued integer to represent the request id for this |
| 199 * request. This value only needs to be saved if you intend to call | 201 * request. This value only needs to be saved if you intend to call |
| 200 * [cancelAnimationFrame] so you can specify the particular animation to | 202 * [cancelAnimationFrame] so you can specify the particular animation to |
| 201 * cancel. | 203 * cancel. |
| 202 * | 204 * |
| 203 * Note: The supplied [callback] needs to call [requestAnimationFrame] again | 205 * Note: The supplied [callback] needs to call [requestAnimationFrame] again |
| 204 * for the animation to continue. | 206 * for the animation to continue. |
| 205 */ | 207 */ |
| 206 @DomName('Window.requestAnimationFrame') | 208 @DomName('Window.requestAnimationFrame') |
| 207 int requestAnimationFrame(FrameRequestCallback callback) { | 209 int requestAnimationFrame(FrameRequestCallback callback) { |
| 210 $if DART2JS |
| 208 _ensureRequestAnimationFrame(); | 211 _ensureRequestAnimationFrame(); |
| 212 $endif |
| 209 if (identical(Zone.current, Zone.ROOT)) { | 213 if (identical(Zone.current, Zone.ROOT)) { |
| 210 return _requestAnimationFrame(callback); | 214 return _requestAnimationFrame(callback); |
| 211 } | 215 } |
| 212 var spec = new AnimationFrameRequestSpecification(this, callback); | 216 var spec = new AnimationFrameRequestSpecification(this, callback); |
| 213 var task = Zone.current.createTask/*<AnimationFrameTask>*/( | 217 var task = Zone.current.createTask/*<AnimationFrameTask>*/( |
| 214 _createAnimationFrameTask, spec); | 218 _createAnimationFrameTask, spec); |
| 215 AnimationFrameTask._tasks[task.id] = task; | 219 AnimationFrameTask._tasks[task.id] = task; |
| 216 return task.id; | 220 return task.id; |
| 217 } | 221 } |
| 218 | 222 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 233 } | 237 } |
| 234 | 238 |
| 235 /** | 239 /** |
| 236 * Cancels an animation frame request. | 240 * Cancels an animation frame request. |
| 237 * | 241 * |
| 238 * ## Other resources | 242 * ## Other resources |
| 239 * | 243 * |
| 240 * * [Window.cancelAnimationFrame](https://developer.mozilla.org/en-US/docs/We
b/API/Window.cancelAnimationFrame) | 244 * * [Window.cancelAnimationFrame](https://developer.mozilla.org/en-US/docs/We
b/API/Window.cancelAnimationFrame) |
| 241 * from MDN. | 245 * from MDN. |
| 242 */ | 246 */ |
| 247 @DomName('Window.cancelAnimationFrame') |
| 243 void cancelAnimationFrame(int id) { | 248 void cancelAnimationFrame(int id) { |
| 244 _ensureRequestAnimationFrame(); | 249 _ensureRequestAnimationFrame(); |
| 245 var task = AnimationFrameTask._tasks.remove(id); | 250 var task = AnimationFrameTask._tasks.remove(id); |
| 246 if (task == null) { | 251 if (task == null) { |
| 247 // Assume that the animation frame request wasn't intercepted by a zone. | 252 // Assume that the animation frame request wasn't intercepted by a zone. |
| 248 _cancelAnimationFrame(id); | 253 _cancelAnimationFrame(id); |
| 249 return; | 254 return; |
| 250 } | 255 } |
| 251 task.cancel(this); | 256 task.cancel(this); |
| 252 } | 257 } |
| 253 | 258 |
| 259 $if DART2JS |
| 254 @JSName('requestAnimationFrame') | 260 @JSName('requestAnimationFrame') |
| 255 int _requestAnimationFrame(FrameRequestCallback callback) native; | 261 int _requestAnimationFrame(FrameRequestCallback callback) native; |
| 256 | 262 |
| 257 @JSName('cancelAnimationFrame') | 263 @JSName('cancelAnimationFrame') |
| 258 void _cancelAnimationFrame(int id) native; | 264 void _cancelAnimationFrame(int id) native; |
| 259 | 265 |
| 260 _ensureRequestAnimationFrame() { | 266 _ensureRequestAnimationFrame() { |
| 261 if (JS('bool', | 267 if (JS('bool', |
| 262 '!!(#.requestAnimationFrame && #.cancelAnimationFrame)', this, this)) | 268 '!!(#.requestAnimationFrame && #.cancelAnimationFrame)', this, this)) |
| 263 return; | 269 return; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 294 @SupportedBrowser(SupportedBrowser.IE, '10.0') | 300 @SupportedBrowser(SupportedBrowser.IE, '10.0') |
| 295 @Experimental() | 301 @Experimental() |
| 296 IdbFactory get indexedDB => | 302 IdbFactory get indexedDB => |
| 297 JS('IdbFactory|Null', // If not supported, returns null. | 303 JS('IdbFactory|Null', // If not supported, returns null. |
| 298 '#.indexedDB || #.webkitIndexedDB || #.mozIndexedDB', | 304 '#.indexedDB || #.webkitIndexedDB || #.mozIndexedDB', |
| 299 this, this, this); | 305 this, this, this); |
| 300 | 306 |
| 301 /// The debugging console for this window. | 307 /// The debugging console for this window. |
| 302 @DomName('Window.console') | 308 @DomName('Window.console') |
| 303 Console get console => Console._safeConsole; | 309 Console get console => Console._safeConsole; |
| 304 | |
| 305 $else | |
| 306 /** | |
| 307 * Called to draw an animation frame and then request the window to repaint | |
| 308 * after [callback] has finished (creating the animation). | |
| 309 * | |
| 310 * Use this method only if you need to later call [cancelAnimationFrame]. If | |
| 311 * not, the preferred Dart idiom is to set animation frames by calling | |
| 312 * [animationFrame], which returns a Future. | |
| 313 * | |
| 314 * Returns a non-zero valued integer to represent the request id for this | |
| 315 * request. This value only needs to be saved if you intend to call | |
| 316 * [cancelAnimationFrame] so you can specify the particular animation to | |
| 317 * cancel. | |
| 318 * | |
| 319 * Note: The supplied [callback] needs to call [requestAnimationFrame] again | |
| 320 * for the animation to continue. | |
| 321 */ | |
| 322 @DomName('Window.requestAnimationFrame') | |
| 323 int requestAnimationFrame(FrameRequestCallback callback) { | |
| 324 return _requestAnimationFrame(_wrapZone(callback)); | |
| 325 } | |
| 326 $endif | 310 $endif |
| 327 | 311 |
| 328 /** | 312 /** |
| 329 * Access a sandboxed file system of the specified `size`. If `persistent` is | 313 * Access a sandboxed file system of the specified `size`. If `persistent` is |
| 330 * true, the application will request permission from the user to create | 314 * true, the application will request permission from the user to create |
| 331 * lasting storage. This storage cannot be freed without the user's | 315 * lasting storage. This storage cannot be freed without the user's |
| 332 * permission. Returns a [Future] whose value stores a reference to the | 316 * permission. Returns a [Future] whose value stores a reference to the |
| 333 * sandboxed file system for use. Because the file system is sandboxed, | 317 * sandboxed file system for use. Because the file system is sandboxed, |
| 334 * applications cannot access file systems created in other web pages. | 318 * applications cannot access file systems created in other web pages. |
| 335 */ | 319 */ |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 {bool useCapture: false}) { | 479 {bool useCapture: false}) { |
| 496 $if DART2JS | 480 $if DART2JS |
| 497 // Specify the generic type for _ElementEventStreamImpl only in dart2js to | 481 // Specify the generic type for _ElementEventStreamImpl only in dart2js to |
| 498 // avoid checked mode errors in dartium. | 482 // avoid checked mode errors in dartium. |
| 499 return new _ElementListEventStreamImpl<BeforeUnloadEvent>(e, _eventType, use
Capture); | 483 return new _ElementListEventStreamImpl<BeforeUnloadEvent>(e, _eventType, use
Capture); |
| 500 $else | 484 $else |
| 501 return new _ElementListEventStreamImpl(e, _eventType, useCapture); | 485 return new _ElementListEventStreamImpl(e, _eventType, useCapture); |
| 502 $endif | 486 $endif |
| 503 } | 487 } |
| 504 } | 488 } |
| OLD | NEW |