OLD | NEW |
| (Empty) |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 // DO NOT EDIT | |
6 // Auto-generated dart:html library. | |
7 | |
8 /** | |
9 * HTML elements and other resources for web-based applications that need to | |
10 * interact with the browser and the DOM (Document Object Model). | |
11 * | |
12 * This library includes DOM element types, CSS styling, local storage, | |
13 * media, speech, events, and more. | |
14 * To get started, | |
15 * check out the [Element] class, the base class for many of the HTML | |
16 * DOM types. | |
17 * | |
18 * ## Other resources | |
19 * | |
20 * * If you've never written a web app before, try our | |
21 * tutorials—[A Game of Darts](http://dartlang.org/docs/tutorials). | |
22 * | |
23 * * To see some web-based Dart apps in action and to play with the code, | |
24 * download | |
25 * [Dart Editor](http://www.dartlang.org/#get-started) | |
26 * and run its built-in examples. | |
27 * | |
28 * * For even more examples, see | |
29 * [Dart HTML5 Samples](https://github.com/dart-lang/dart-html5-samples) | |
30 * on Github. | |
31 */ | |
32 library dart.dom.html; | |
33 | |
34 import 'dart:async'; | |
35 import 'dart:collection'; | |
36 import 'dart:_internal' hide Symbol; | |
37 import 'dart:html_common'; | |
38 import 'dart:indexed_db'; | |
39 import 'dart:indexed_db' show indexed_dbBlinkMap; | |
40 import 'dart:isolate'; | |
41 import 'dart:js' as js; | |
42 import "dart:convert"; | |
43 import 'dart:math'; | |
44 // TODO(vsm): Remove this when we can do the proper checking in | |
45 // native code for custom elements. | |
46 import 'dart:mirrors'; | |
47 import 'dart:nativewrappers'; | |
48 import 'dart:typed_data'; | |
49 import 'dart:web_gl' as gl; | |
50 import 'dart:web_gl' show web_glBlinkMap; | |
51 import 'dart:web_sql'; | |
52 // Not actually used, but imported since dart:html can generate these objects. | |
53 import 'dart:svg' as svg; | |
54 import 'dart:svg' show svgBlinkMap; | |
55 import 'dart:svg' show Matrix; | |
56 import 'dart:svg' show SvgSvgElement; | |
57 import 'dart:web_audio' as web_audio; | |
58 import 'dart:web_audio' show web_audioBlinkMap; | |
59 import 'dart:_blink' as _blink; | |
60 import 'dart:developer'; | |
61 | |
62 export 'dart:math' show Rectangle, Point; | |
63 | |
64 $!GENERATED_DART_FILES | |
65 | |
66 // Issue 14721, order important for WrappedEvent. | |
67 part '$AUXILIARY_DIR/AttributeMap.dart'; | |
68 part '$AUXILIARY_DIR/CanvasImageSource.dart'; | |
69 part '$AUXILIARY_DIR/CrossFrameTypes.dart'; | |
70 part '$AUXILIARY_DIR/CssClassSet.dart'; | |
71 part '$AUXILIARY_DIR/dartium_CssClassSet.dart'; | |
72 part '$AUXILIARY_DIR/CssRectangle.dart'; | |
73 part '$AUXILIARY_DIR/Dimension.dart'; | |
74 part '$AUXILIARY_DIR/EventListener.dart'; | |
75 part '$AUXILIARY_DIR/EventStreamProvider.dart'; | |
76 part '$AUXILIARY_DIR/Html5NodeValidator.dart'; | |
77 part '$AUXILIARY_DIR/ImmutableListMixin.dart'; | |
78 part '$AUXILIARY_DIR/KeyCode.dart'; | |
79 part '$AUXILIARY_DIR/KeyLocation.dart'; | |
80 part '$AUXILIARY_DIR/KeyName.dart'; | |
81 part '$AUXILIARY_DIR/KeyboardEventStream.dart'; | |
82 part '$AUXILIARY_DIR/NodeValidatorBuilder.dart'; | |
83 part '$AUXILIARY_DIR/ReadyState.dart'; | |
84 part '$AUXILIARY_DIR/Validators.dart'; | |
85 part '$AUXILIARY_DIR/WrappedList.dart'; | |
86 part '$AUXILIARY_DIR/_HttpRequestUtils.dart'; | |
87 part '$AUXILIARY_DIR/_ListIterators.dart'; | |
88 part '$AUXILIARY_DIR/dartium_CustomElementSupport.dart'; | |
89 part '$AUXILIARY_DIR/dartium_KeyEvent.dart'; | |
90 part '$AUXILIARY_DIR/dartium_Platform.dart'; | |
91 part '$AUXILIARY_DIR/dartium_WrappedEvent.dart'; | |
92 part '$AUXILIARY_DIR/shared_html.dart'; | |
93 | |
94 part '$AUXILIARY_DIR/native_DOMImplementation.dart'; | |
95 | |
96 Window _window; | |
97 | |
98 /** | |
99 * Top-level container for a web page, which is usually a browser tab or window. | |
100 * | |
101 * Each web page loaded in the browser has its own [Window], which is a | |
102 * container for the web page. | |
103 * | |
104 * If the web page has any `<iframe>` elements, then each `<iframe>` has its own | |
105 * [Window] object, which is accessible only to that `<iframe>`. | |
106 * | |
107 * See also: | |
108 * | |
109 * * [Window](https://developer.mozilla.org/en-US/docs/Web/API/window) from MD
N. | |
110 */ | |
111 Window get window { | |
112 if (_window != null) { | |
113 return _window; | |
114 } | |
115 $if DARTIUM | |
116 $if JSINTEROP | |
117 _window = js.JsNative.toTypedObject(js.context); | |
118 $else | |
119 _window = _Utils.window(); | |
120 $endif | |
121 $endif | |
122 return _window; | |
123 } | |
124 | |
125 HtmlDocument _document; | |
126 | |
127 /** | |
128 * Root node for all content in a web page. | |
129 */ | |
130 HtmlDocument get document { | |
131 if (_document != null) { | |
132 return _document; | |
133 } | |
134 _document = window.document; | |
135 return _document; | |
136 } | |
137 | |
138 /** | |
139 * Spawn a DOM isolate using the given URI in the same window. | |
140 * This isolate is not concurrent. It runs on the browser thread | |
141 * with full access to the DOM. | |
142 * Note: this API is still evolving and may move to dart:isolate. | |
143 */ | |
144 @Experimental() | |
145 Future<Isolate> spawnDomUri(Uri uri, List<String> args, message) { | |
146 // TODO(17738): Plumb arguments and return value through. | |
147 return _Utils.spawnDomUri(uri.toString()); | |
148 } | |
149 // FIXME: Can we make this private? | |
150 @Deprecated("Internal Use Only") | |
151 final htmlBlinkMap = { | |
152 '_HistoryCrossFrame': () => _HistoryCrossFrame, | |
153 '_LocationCrossFrame': () => _LocationCrossFrame, | |
154 '_DOMWindowCrossFrame': () => _DOMWindowCrossFrame, | |
155 // FIXME: Move these to better locations. | |
156 'DateTime': () => DateTime, | |
157 'JsObject': () => js.JsObject, | |
158 'JsFunction': () => js.JsFunction, | |
159 'JsArray': () => js.JsArray, | |
160 // We have to call .instanceRuntimeType as these classes have a private | |
161 // implementation class defined dynamically at runtime via a patch file. | |
162 'JSObject': () => js.JSObject.instanceRuntimeType, | |
163 'JSFunction': () => js.JSFunction.instanceRuntimeType, | |
164 'JSArray': () => js.JSArray.instanceRuntimeType, | |
165 $!TYPE_MAP | |
166 }; | |
167 | |
168 // TODO(leafp): We may want to move this elsewhere if html becomes | |
169 // a package to avoid dartium depending on pkg:html. | |
170 @Deprecated("Internal Use Only") | |
171 getHtmlCreateType(String key) => _getType(key); | |
172 | |
173 Type _getType(String key) { | |
174 var result; | |
175 | |
176 // TODO(vsm): Add Cross Frame and JS types here as well. | |
177 | |
178 // Check the html library. | |
179 result = _getHtmlType(key); | |
180 if (result != null) { | |
181 return result; | |
182 } | |
183 | |
184 // Check the web gl library. | |
185 result = _getWebGlType(key); | |
186 if (result != null) { | |
187 return result; | |
188 } | |
189 | |
190 // Check the indexed db library. | |
191 result = _getIndexDbType(key); | |
192 if (result != null) { | |
193 return result; | |
194 } | |
195 | |
196 // Check the web audio library. | |
197 result = _getWebAudioType(key); | |
198 if (result != null) { | |
199 return result; | |
200 } | |
201 | |
202 // Check the web sql library. | |
203 result = _getWebSqlType(key); | |
204 if (result != null) { | |
205 return result; | |
206 } | |
207 | |
208 // Check the svg library. | |
209 result = _getSvgType(key); | |
210 if (result != null) { | |
211 return result; | |
212 } | |
213 | |
214 return null; | |
215 } | |
216 | |
217 Type _getHtmlType(String key) { | |
218 if (htmlBlinkMap.containsKey(key)) { | |
219 return htmlBlinkMap[key](); | |
220 } | |
221 return null; | |
222 } | |
223 | |
224 Type _getWebGlType(String key) { | |
225 if (web_glBlinkMap.containsKey(key)) { | |
226 return web_glBlinkMap[key](); | |
227 } | |
228 return null; | |
229 } | |
230 | |
231 Type _getIndexDbType(String key) { | |
232 if (indexed_dbBlinkMap.containsKey(key)) { | |
233 return indexed_dbBlinkMap[key](); | |
234 } | |
235 return null; | |
236 } | |
237 | |
238 Type _getWebAudioType(String key) { | |
239 if (web_audioBlinkMap.containsKey(key)) { | |
240 return web_audioBlinkMap[key](); | |
241 } | |
242 return null; | |
243 } | |
244 | |
245 Type _getWebSqlType(String key) { | |
246 if (web_sqlBlinkMap.containsKey(key)) { | |
247 return web_sqlBlinkMap[key](); | |
248 } | |
249 return null; | |
250 } | |
251 | |
252 Type _getSvgType(String key) { | |
253 if (svgBlinkMap.containsKey(key)) { | |
254 return svgBlinkMap[key](); | |
255 } | |
256 return null; | |
257 } | |
258 | |
259 // TODO(jacobr): it would be nice to place these conversion methods in a consist
ent place for dart2js and dartium. | |
260 | |
261 WindowBase _convertNativeToDart_Window(win) { | |
262 if (win == null) return null; | |
263 return _DOMWindowCrossFrame._createSafe(win); | |
264 } | |
265 | |
266 EventTarget _convertNativeToDart_EventTarget(e) { | |
267 if (e == null) { | |
268 return null; | |
269 } | |
270 // Assume it's a Window if it contains the postMessage property. It may be | |
271 // from a different frame - without a patched prototype - so we cannot | |
272 // rely on Dart type checking. | |
273 try { | |
274 if (js.JsNative.hasProperty(e, "postMessage")) { | |
275 var window = _DOMWindowCrossFrame._createSafe(e); | |
276 // If it's a native window. | |
277 if (window is EventTarget) { | |
278 return window; | |
279 } | |
280 return null; | |
281 } | |
282 } catch (err) { | |
283 print("Error calling _convertNativeToDart_EventTarget... $err"); | |
284 } | |
285 return e; | |
286 } | |
287 | |
288 EventTarget _convertDartToNative_EventTarget(e) { | |
289 // _DOMWindowCrossFrame uses an interceptor so we don't need to do anything un
like Dart2Js. | |
290 return e; | |
291 } | |
292 | |
293 _convertNativeToDart_XHR_Response(o) { | |
294 if (o is Document) { | |
295 return o; | |
296 } | |
297 return convertNativeToDart_SerializedScriptValue(o); | |
298 } | |
299 | |
300 $if JSINTEROP | |
301 | |
302 /****************************************************************************** | |
303 ********** ********** | |
304 ********** JS Interop Support ********** | |
305 ********** ********** | |
306 ******************************************************************************/ | |
307 | |
308 String _getCustomElementExtends(object) { | |
309 var entry = getCustomElementEntry(object); | |
310 if (entry != null) { | |
311 return entry['extends']; | |
312 } | |
313 return null; | |
314 } | |
315 | |
316 // Return the tag name or is attribute of the custom element or data binding. | |
317 String _getCustomElementName(element) { | |
318 var jsObject; | |
319 var tag = ""; | |
320 var runtimeType = element.runtimeType; | |
321 if (runtimeType == TemplateElement) { | |
322 // Data binding with a Dart class. | |
323 tag = element.attributes['is']; | |
324 } else if (element is HtmlElement) { | |
325 tag = element.attributes['is']; | |
326 if (tag == null) { | |
327 // It's a custom element we want the local name. | |
328 tag = element.localName; | |
329 } | |
330 } else { | |
331 throw new UnsupportedError('Element is incorrect type. Got ${runtimeType}, e
xpected HtmlElement/HtmlTemplate/JsObject.'); | |
332 } | |
333 | |
334 return tag; | |
335 } | |
336 | |
337 /// An abstract class for all DOM objects we wrap in dart:html and related | |
338 /// libraries. | |
339 @Deprecated("Internal Use Only") | |
340 class DartHtmlDomObject extends js.JSObject { | |
341 DartHtmlDomObject() : super.internal(); | |
342 } | |
343 | |
344 @Deprecated("Internal Use Only") | |
345 class DebugAssertException implements Exception { | |
346 String message; | |
347 DebugAssertException(this.message); | |
348 } | |
349 | |
350 @Deprecated("Internal Use Only") | |
351 debug_or_assert(message, expression) { | |
352 if (!expression) { | |
353 throw new DebugAssertException("$message"); | |
354 } | |
355 } | |
356 | |
357 @Deprecated("Internal Use Only") | |
358 Map<String, dynamic> convertNativeObjectToDartMap(js.JsObject jsObject) { | |
359 var result = new Map(); | |
360 var keys = js.JsNative.callMethod(js.JsNative.getProperty(js.context, 'Object'
), 'keys', [jsObject]); | |
361 for (var key in keys) { | |
362 result[key] = js.JsNative.getProperty(jsObject, key); | |
363 } | |
364 return result; | |
365 } | |
366 | |
367 /** | |
368 * Upgrade the JS HTMLElement to the Dart class. Used by Dart's Polymer. | |
369 */ | |
370 _createCustomUpgrader(Type customElementClass, $this) { | |
371 return _blink.Blink_Utils.setInstanceInterceptor($this, customElementClass, cu
stomElement: true); | |
372 } | |
373 | |
374 $else | |
375 class DartHtmlDomObject extends NativeFieldWrapperClass2 {} | |
376 | |
377 _createCustomUpgrader(Type customElementClass, $this) => $this; | |
378 | |
379 $endif | |
380 | |
381 /** | |
382 * Emitted for any setlike IDL entry needs a callback signature. | |
383 * Today there is only one. | |
384 */ | |
385 @DomName('FontFaceSetForEachCallback') | |
386 @Experimental() // untriaged | |
387 typedef void FontFaceSetForEachCallback( | |
388 FontFace fontFace, FontFace fontFaceAgain, FontFaceSet set); | |
389 | |
OLD | NEW |