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 // DO NOT EDIT | 5 // DO NOT EDIT |
6 // Auto-generated dart:html library. | 6 // Auto-generated dart:html library. |
7 | 7 |
8 /** | 8 /** |
9 * HTML elements and other resources for web-based applications that need to | 9 * HTML elements and other resources for web-based applications that need to |
10 * interact with the browser and the DOM (Document Object Model). | 10 * interact with the browser and the DOM (Document Object Model). |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 return _Utils.spawnDomUri(uri.toString()); | 151 return _Utils.spawnDomUri(uri.toString()); |
152 } | 152 } |
153 // FIXME: Can we make this private? | 153 // FIXME: Can we make this private? |
154 @Deprecated("Internal Use Only") | 154 @Deprecated("Internal Use Only") |
155 final htmlBlinkMap = { | 155 final htmlBlinkMap = { |
156 '_HistoryCrossFrame': () => _HistoryCrossFrame, | 156 '_HistoryCrossFrame': () => _HistoryCrossFrame, |
157 '_LocationCrossFrame': () => _LocationCrossFrame, | 157 '_LocationCrossFrame': () => _LocationCrossFrame, |
158 '_DOMWindowCrossFrame': () => _DOMWindowCrossFrame, | 158 '_DOMWindowCrossFrame': () => _DOMWindowCrossFrame, |
159 // FIXME: Move these to better locations. | 159 // FIXME: Move these to better locations. |
160 'DateTime': () => DateTime, | 160 'DateTime': () => DateTime, |
161 'JsObject': () => js.JsObjectImpl, | 161 'JsObject': () => js.JsObject, |
162 'JsFunction': () => js.JsFunctionImpl, | 162 'JsFunction': () => js.JsFunction, |
163 'JsArray': () => js.JsArrayImpl, | 163 'JsArray': () => js.JsArray, |
164 $!TYPE_MAP | 164 $!TYPE_MAP |
165 }; | 165 }; |
166 | 166 |
167 // TODO(leafp): We may want to move this elsewhere if html becomes | 167 // TODO(leafp): We may want to move this elsewhere if html becomes |
168 // a package to avoid dartium depending on pkg:html. | 168 // a package to avoid dartium depending on pkg:html. |
169 Type _getType(String key) { | 169 Type _getType(String key) { |
170 var result; | 170 var result; |
171 | 171 |
172 // TODO(vsm): Add Cross Frame and JS types here as well. | 172 // TODO(vsm): Add Cross Frame and JS types here as well. |
173 | 173 |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 // Return the tag name or is attribute of the custom element or data binding. | 366 // Return the tag name or is attribute of the custom element or data binding. |
367 String _getCustomElementName(element) { | 367 String _getCustomElementName(element) { |
368 var jsObject; | 368 var jsObject; |
369 var tag = ""; | 369 var tag = ""; |
370 var runtimeType = element.runtimeType; | 370 var runtimeType = element.runtimeType; |
371 if (runtimeType == HtmlElement) { | 371 if (runtimeType == HtmlElement) { |
372 tag = element.localName; | 372 tag = element.localName; |
373 } else if (runtimeType == TemplateElement) { | 373 } else if (runtimeType == TemplateElement) { |
374 // Data binding with a Dart class. | 374 // Data binding with a Dart class. |
375 tag = element.attributes['is']; | 375 tag = element.attributes['is']; |
376 } else if (runtimeType == js.JsObjectImpl) { | 376 } else if (runtimeType == js.JsObject) { |
377 // It's a Polymer core element (written in JS). | 377 // It's a Polymer core element (written in JS). |
378 // Make sure it's an element anything else we can ignore. | 378 // Make sure it's an element anything else we can ignore. |
379 if (element.hasProperty('nodeType') && element['nodeType'] == 1) { | 379 if (element.hasProperty('nodeType') && element['nodeType'] == 1) { |
380 if (js.JsNative.callMethod(element, 'hasAttribute', ['is'])) { | 380 if (js.JsNative.callMethod(element, 'hasAttribute', ['is'])) { |
381 // It's data binding use the is attribute. | 381 // It's data binding use the is attribute. |
382 tag = js.JsNative.callMethod(element, 'getAttribute', ['is']); | 382 tag = js.JsNative.callMethod(element, 'getAttribute', ['is']); |
383 } else { | 383 } else { |
384 // It's a custom element we want the local name. | 384 // It's a custom element we want the local name. |
385 tag = element['localName']; | 385 tag = element['localName']; |
386 } | 386 } |
387 } | 387 } |
388 } else { | 388 } else { |
389 throw new UnsupportedError('Element is incorrect type. Got ${runtimeType}, e
xpected HtmlElement/HtmlTemplate/JsObjectImpl.'); | 389 throw new UnsupportedError('Element is incorrect type. Got ${runtimeType}, e
xpected HtmlElement/HtmlTemplate/JsObject.'); |
390 } | 390 } |
391 | 391 |
392 return tag; | 392 return tag; |
393 } | 393 } |
394 | 394 |
395 /// An abstract class for all DOM objects we wrap in dart:html and related | 395 /// An abstract class for all DOM objects we wrap in dart:html and related |
396 /// libraries. | 396 /// libraries. |
397 /// | |
398 /// ** Internal Use Only ** | |
399 @Deprecated("Internal Use Only") | 397 @Deprecated("Internal Use Only") |
400 class DartHtmlDomObject { | 398 class DartHtmlDomObject extends js.JSObject { |
401 | 399 DartHtmlDomObject() : super.internal(); |
402 /// The underlying JS DOM object. | |
403 @Deprecated("Internal Use Only") | |
404 js.JsObject blink_jsObject; | |
405 | |
406 } | 400 } |
407 | 401 |
408 @Deprecated("Internal Use Only") | 402 @Deprecated("Internal Use Only") |
409 class DebugAssertException implements Exception { | 403 class DebugAssertException implements Exception { |
410 String message; | 404 String message; |
411 DebugAssertException(this.message); | 405 DebugAssertException(this.message); |
412 } | 406 } |
413 | 407 |
414 @Deprecated("Internal Use Only") | 408 @Deprecated("Internal Use Only") |
415 debug_or_assert(message, expression) { | 409 debug_or_assert(message, expression) { |
416 if (!expression) { | 410 if (!expression) { |
417 throw new DebugAssertException("$message"); | 411 throw new DebugAssertException("$message"); |
418 } | 412 } |
419 } | 413 } |
420 | 414 |
421 // TODO(terry): Manage JS interop JsFunctions for each listener used for add/ | |
422 // removeEventListener. These JsFunctions will leak look at | |
423 // fixing with weak-refs in C++. The key are the hashcodes of the | |
424 // user's this (this is needed for futures) and listener function. | |
425 Map<int, Map<int, js.JsFunction>> _knownListeners = {}; | |
426 | |
427 @Deprecated("Internal Use Only") | |
428 js.JsFunction wrap_event_listener(theObject, Function listener) { | |
429 var thisHashCode = theObject.hashCode; | |
430 var listenerHashCode = identityHashCode(listener); | |
431 | |
432 _knownListeners.putIfAbsent(thisHashCode, () => new Map<int, js.JsFunction>())
; | |
433 _knownListeners[thisHashCode].putIfAbsent(listenerHashCode, () => | |
434 new js.JsFunction.withThis((theObject, event) => listener(wrap_jso(event))))
; | |
435 | |
436 return _knownListeners[thisHashCode][listenerHashCode]; | |
437 } | |
438 | |
439 @Deprecated("Internal Use Only") | 415 @Deprecated("Internal Use Only") |
440 Map<String, dynamic> convertNativeObjectToDartMap(js.JsObject jsObject) { | 416 Map<String, dynamic> convertNativeObjectToDartMap(js.JsObject jsObject) { |
441 var result = new Map(); | 417 var result = new Map(); |
442 var keys = js.JsNative.callMethod(js.JsNative.getProperty(js.context, 'Object'
), 'keys', [jsObject]); | 418 var keys = js.JsNative.callMethod(js.JsNative.getProperty(js.context, 'Object'
), 'keys', [jsObject]); |
443 for (var key in keys) { | 419 for (var key in keys) { |
444 result[key] = wrap_jso(js.JsNative.getProperty(jsObject, key)); | 420 result[key] = wrap_jso(js.JsNative.getProperty(jsObject, key)); |
445 } | 421 } |
446 return result; | 422 return result; |
447 } | 423 } |
448 | 424 |
(...skipping 21 matching lines...) Expand all Loading... |
470 | 446 |
471 return dartClass; | 447 return dartClass; |
472 } | 448 } |
473 | 449 |
474 $else | 450 $else |
475 class DartHtmlDomObject extends NativeFieldWrapperClass2 {} | 451 class DartHtmlDomObject extends NativeFieldWrapperClass2 {} |
476 | 452 |
477 _createCustomUpgrader(Type customElementClass, $this) => $this; | 453 _createCustomUpgrader(Type customElementClass, $this) => $this; |
478 | 454 |
479 $endif | 455 $endif |
OLD | NEW |