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 @DocsEditable() | 7 @DocsEditable() |
8 $if DART2JS | 8 $if DART2JS |
9 $(ANNOTATIONS)@Native("Window,DOMWindow") | 9 $(ANNOTATIONS)@Native("Window,DOMWindow") |
10 $(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS { | 10 $(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 set location(value) { | 89 set location(value) { |
90 _location = value; | 90 _location = value; |
91 } | 91 } |
92 | 92 |
93 // Native getter and setter to access raw Location object. | 93 // Native getter and setter to access raw Location object. |
94 dynamic get _location => JS('Location|Null', '#.location', this); | 94 dynamic get _location => JS('Location|Null', '#.location', this); |
95 set _location(value) { | 95 set _location(value) { |
96 JS('void', '#.location = #', this, value); | 96 JS('void', '#.location = #', this, value); |
97 } | 97 } |
98 | 98 |
99 $endif | |
100 | |
101 /** | 99 /** |
102 * Called to draw an animation frame and then request the window to repaint | 100 * Called to draw an animation frame and then request the window to repaint |
103 * after [callback] has finished (creating the animation). | 101 * after [callback] has finished (creating the animation). |
104 * | 102 * |
105 * Use this method only if you need to later call [cancelAnimationFrame]. If | 103 * Use this method only if you need to later call [cancelAnimationFrame]. If |
106 * not, the preferred Dart idiom is to set animation frames by calling | 104 * not, the preferred Dart idiom is to set animation frames by calling |
107 * [animationFrame], which returns a Future. | 105 * [animationFrame], which returns a Future. |
108 * | 106 * |
109 * Returns a non-zero valued integer to represent the request id for this | 107 * Returns a non-zero valued integer to represent the request id for this |
110 * request. This value only needs to be saved if you intend to call | 108 * request. This value only needs to be saved if you intend to call |
111 * [cancelAnimationFrame] so you can specify the particular animation to | 109 * [cancelAnimationFrame] so you can specify the particular animation to |
112 * cancel. | 110 * cancel. |
113 * | 111 * |
114 * Note: The supplied [callback] needs to call [requestAnimationFrame] again | 112 * Note: The supplied [callback] needs to call [requestAnimationFrame] again |
115 * for the animation to continue. | 113 * for the animation to continue. |
116 */ | 114 */ |
117 @DomName('Window.requestAnimationFrame') | 115 @DomName('Window.requestAnimationFrame') |
118 int requestAnimationFrame(FrameRequestCallback callback) { | 116 int requestAnimationFrame(FrameRequestCallback callback) { |
119 $if DART2JS | |
120 _ensureRequestAnimationFrame(); | 117 _ensureRequestAnimationFrame(); |
121 $endif | |
122 return _requestAnimationFrame(_wrapZone/*<num, dynamic>*/(callback)); | 118 return _requestAnimationFrame(_wrapZone/*<num, dynamic>*/(callback)); |
123 } | 119 } |
124 | 120 |
125 /** | 121 /** |
126 * Cancels an animation frame request. | 122 * Cancels an animation frame request. |
127 * | 123 * |
128 * ## Other resources | 124 * ## Other resources |
129 * | 125 * |
130 * * [Window.cancelAnimationFrame](https://developer.mozilla.org/en-US/docs/We
b/API/Window.cancelAnimationFrame) | 126 * * [Window.cancelAnimationFrame](https://developer.mozilla.org/en-US/docs/We
b/API/Window.cancelAnimationFrame) |
131 * from MDN. | 127 * from MDN. |
132 */ | 128 */ |
133 @DomName('Window.cancelAnimationFrame') | |
134 void cancelAnimationFrame(int id) { | 129 void cancelAnimationFrame(int id) { |
135 $if DART2JS | |
136 _ensureRequestAnimationFrame(); | 130 _ensureRequestAnimationFrame(); |
137 $endif | |
138 _cancelAnimationFrame(id); | 131 _cancelAnimationFrame(id); |
139 } | 132 } |
140 | 133 |
141 $if DART2JS | |
142 @JSName('requestAnimationFrame') | 134 @JSName('requestAnimationFrame') |
143 int _requestAnimationFrame(FrameRequestCallback callback) native; | 135 int _requestAnimationFrame(FrameRequestCallback callback) native; |
144 | 136 |
145 @JSName('cancelAnimationFrame') | 137 @JSName('cancelAnimationFrame') |
146 void _cancelAnimationFrame(int id) native; | 138 void _cancelAnimationFrame(int id) native; |
147 | 139 |
148 _ensureRequestAnimationFrame() { | 140 _ensureRequestAnimationFrame() { |
149 if (JS('bool', | 141 if (JS('bool', |
150 '!!(#.requestAnimationFrame && #.cancelAnimationFrame)', this, this)) | 142 '!!(#.requestAnimationFrame && #.cancelAnimationFrame)', this, this)) |
151 return; | 143 return; |
(...skipping 30 matching lines...) Expand all Loading... |
182 @SupportedBrowser(SupportedBrowser.IE, '10.0') | 174 @SupportedBrowser(SupportedBrowser.IE, '10.0') |
183 @Experimental() | 175 @Experimental() |
184 IdbFactory get indexedDB => | 176 IdbFactory get indexedDB => |
185 JS('IdbFactory|Null', // If not supported, returns null. | 177 JS('IdbFactory|Null', // If not supported, returns null. |
186 '#.indexedDB || #.webkitIndexedDB || #.mozIndexedDB', | 178 '#.indexedDB || #.webkitIndexedDB || #.mozIndexedDB', |
187 this, this, this); | 179 this, this, this); |
188 | 180 |
189 /// The debugging console for this window. | 181 /// The debugging console for this window. |
190 @DomName('Window.console') | 182 @DomName('Window.console') |
191 Console get console => Console._safeConsole; | 183 Console get console => Console._safeConsole; |
| 184 |
| 185 $else |
| 186 /** |
| 187 * Called to draw an animation frame and then request the window to repaint |
| 188 * after [callback] has finished (creating the animation). |
| 189 * |
| 190 * Use this method only if you need to later call [cancelAnimationFrame]. If |
| 191 * not, the preferred Dart idiom is to set animation frames by calling |
| 192 * [animationFrame], which returns a Future. |
| 193 * |
| 194 * Returns a non-zero valued integer to represent the request id for this |
| 195 * request. This value only needs to be saved if you intend to call |
| 196 * [cancelAnimationFrame] so you can specify the particular animation to |
| 197 * cancel. |
| 198 * |
| 199 * Note: The supplied [callback] needs to call [requestAnimationFrame] again |
| 200 * for the animation to continue. |
| 201 */ |
| 202 @DomName('Window.requestAnimationFrame') |
| 203 int requestAnimationFrame(FrameRequestCallback callback) { |
| 204 return _requestAnimationFrame(_wrapZone(callback)); |
| 205 } |
192 $endif | 206 $endif |
193 | 207 |
194 /** | 208 /** |
195 * Access a sandboxed file system of the specified `size`. If `persistent` is | 209 * Access a sandboxed file system of the specified `size`. If `persistent` is |
196 * true, the application will request permission from the user to create | 210 * true, the application will request permission from the user to create |
197 * lasting storage. This storage cannot be freed without the user's | 211 * lasting storage. This storage cannot be freed without the user's |
198 * permission. Returns a [Future] whose value stores a reference to the | 212 * permission. Returns a [Future] whose value stores a reference to the |
199 * sandboxed file system for use. Because the file system is sandboxed, | 213 * sandboxed file system for use. Because the file system is sandboxed, |
200 * applications cannot access file systems created in other web pages. | 214 * applications cannot access file systems created in other web pages. |
201 */ | 215 */ |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 {bool useCapture: false}) { | 375 {bool useCapture: false}) { |
362 $if DART2JS | 376 $if DART2JS |
363 // Specify the generic type for _ElementEventStreamImpl only in dart2js to | 377 // Specify the generic type for _ElementEventStreamImpl only in dart2js to |
364 // avoid checked mode errors in dartium. | 378 // avoid checked mode errors in dartium. |
365 return new _ElementListEventStreamImpl<BeforeUnloadEvent>(e, _eventType, use
Capture); | 379 return new _ElementListEventStreamImpl<BeforeUnloadEvent>(e, _eventType, use
Capture); |
366 $else | 380 $else |
367 return new _ElementListEventStreamImpl(e, _eventType, useCapture); | 381 return new _ElementListEventStreamImpl(e, _eventType, useCapture); |
368 $endif | 382 $endif |
369 } | 383 } |
370 } | 384 } |
OLD | NEW |