OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library dart._runtime; | 5 library dart._runtime; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 | 9 |
10 import 'dart:_foreign_helper' show JS, JSExportName, rest, spread; | 10 import 'dart:_foreign_helper' show JS, JSExportName, rest, spread; |
(...skipping 12 matching lines...) Expand all Loading... |
23 SyncIterable; | 23 SyncIterable; |
24 | 24 |
25 part 'classes.dart'; | 25 part 'classes.dart'; |
26 part 'rtti.dart'; | 26 part 'rtti.dart'; |
27 part 'types.dart'; | 27 part 'types.dart'; |
28 part 'errors.dart'; | 28 part 'errors.dart'; |
29 part 'generators.dart'; | 29 part 'generators.dart'; |
30 part 'operations.dart'; | 30 part 'operations.dart'; |
31 part 'utils.dart'; | 31 part 'utils.dart'; |
32 | 32 |
| 33 // TODO(vsm): Move polyfill code to dart:html. |
| 34 // Note, native extensions are registered onto types in dart.global. |
| 35 // This polyfill needs to run before the corresponding dart:html code is run. |
33 @JSExportName('global') | 36 @JSExportName('global') |
34 final global_ = JS('', 'typeof window == "undefined" ? global : window'); | 37 final global_ = JS('', ''' |
| 38 function () { |
| 39 if (typeof NodeList !== "undefined") { |
| 40 // TODO(vsm): Do we still need these? |
| 41 NodeList.prototype.get = function(i) { return this[i]; }; |
| 42 NamedNodeMap.prototype.get = function(i) { return this[i]; }; |
| 43 DOMTokenList.prototype.get = function(i) { return this[i]; }; |
| 44 HTMLCollection.prototype.get = function(i) { return this[i]; }; |
| 45 |
| 46 // Expose constructors for DOM types dart:html needs to assume are |
| 47 // available on window. |
| 48 if (typeof PannerNode == "undefined") { |
| 49 let audioContext; |
| 50 if (typeof AudioContext == "undefined" && |
| 51 (typeof webkitAudioContext != "undefined")) { |
| 52 audioContext = new webkitAudioContext(); |
| 53 } else { |
| 54 audioContext = new AudioContext(); |
| 55 window.StereoPannerNode = |
| 56 audioContext.createStereoPanner().constructor; |
| 57 } |
| 58 window.PannerNode = audioContext.createPanner().constructor; |
| 59 } |
| 60 if (typeof AudioSourceNode == "undefined") { |
| 61 window.AudioSourceNode = MediaElementAudioSourceNode.__proto__; |
| 62 } |
| 63 if (typeof FontFaceSet == "undefined") { |
| 64 window.FontFaceSet = document.fonts.__proto__.constructor; |
| 65 } |
| 66 if (typeof MemoryInfo == "undefined") { |
| 67 if (typeof window.performance.memory != "undefined") { |
| 68 window.MemoryInfo = window.performance.memory.constructor; |
| 69 } |
| 70 } |
| 71 if (typeof Geolocation == "undefined") { |
| 72 navigator.geolocation.constructor; |
| 73 } |
| 74 if (typeof Animation == "undefined") { |
| 75 let d = document.createElement('div'); |
| 76 if (typeof d.animate != "undefined") { |
| 77 window.Animation = d.animate(d).constructor; |
| 78 } |
| 79 } |
| 80 if (typeof SourceBufferList == "undefined") { |
| 81 window.SourceBufferList = new MediaSource().sourceBuffers.constructor; |
| 82 } |
| 83 } |
| 84 return typeof window == "undefined" ? global : window; |
| 85 }() |
| 86 '''); |
| 87 |
35 final JsSymbol = JS('', 'Symbol'); | 88 final JsSymbol = JS('', 'Symbol'); |
OLD | NEW |