| 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:_debugger' show stackTraceMapper; | 10 import 'dart:_debugger' show stackTraceMapper; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 part 'types.dart'; | 29 part 'types.dart'; |
| 30 part 'errors.dart'; | 30 part 'errors.dart'; |
| 31 part 'generators.dart'; | 31 part 'generators.dart'; |
| 32 part 'operations.dart'; | 32 part 'operations.dart'; |
| 33 part 'profile.dart'; | 33 part 'profile.dart'; |
| 34 part 'utils.dart'; | 34 part 'utils.dart'; |
| 35 | 35 |
| 36 // TODO(vsm): Move polyfill code to dart:html. | 36 // TODO(vsm): Move polyfill code to dart:html. |
| 37 // Note, native extensions are registered onto types in dart.global. | 37 // Note, native extensions are registered onto types in dart.global. |
| 38 // This polyfill needs to run before the corresponding dart:html code is run. | 38 // This polyfill needs to run before the corresponding dart:html code is run. |
| 39 final polyfill = JS( | 39 final _polyfilled = JS('', 'Symbol("_polyfilled")'); |
| 40 |
| 41 bool polyfill(window) => JS( |
| 40 '', | 42 '', |
| 41 ''' | 43 '''(() => { |
| 42 function (window) { | 44 if ($window[$_polyfilled]) return false; |
| 43 if (typeof window.NodeList !== "undefined") { | 45 $window[$_polyfilled] = true; |
| 46 |
| 47 if (typeof $window.NodeList !== "undefined") { |
| 44 // TODO(vsm): Do we still need these? | 48 // TODO(vsm): Do we still need these? |
| 45 window.NodeList.prototype.get = function(i) { return this[i]; }; | 49 $window.NodeList.prototype.get = function(i) { return this[i]; }; |
| 46 window.NamedNodeMap.prototype.get = function(i) { return this[i]; }; | 50 $window.NamedNodeMap.prototype.get = function(i) { return this[i]; }; |
| 47 window.DOMTokenList.prototype.get = function(i) { return this[i]; }; | 51 $window.DOMTokenList.prototype.get = function(i) { return this[i]; }; |
| 48 window.HTMLCollection.prototype.get = function(i) { return this[i]; }; | 52 $window.HTMLCollection.prototype.get = function(i) { return this[i]; }; |
| 49 | 53 |
| 50 // Expose constructors for DOM types dart:html needs to assume are | 54 // Expose constructors for DOM types dart:html needs to assume are |
| 51 // available on window. | 55 // available on window. |
| 52 if (typeof window.PannerNode == "undefined") { | 56 if (typeof $window.PannerNode == "undefined") { |
| 53 let audioContext; | 57 let audioContext; |
| 54 if (typeof window.AudioContext == "undefined" && | 58 if (typeof $window.AudioContext == "undefined" && |
| 55 (typeof window.webkitAudioContext != "undefined")) { | 59 (typeof $window.webkitAudioContext != "undefined")) { |
| 56 audioContext = new window.webkitAudioContext(); | 60 audioContext = new $window.webkitAudioContext(); |
| 57 } else { | 61 } else { |
| 58 audioContext = new window.AudioContext(); | 62 audioContext = new $window.AudioContext(); |
| 59 window.StereoPannerNode = | 63 $window.StereoPannerNode = |
| 60 audioContext.createStereoPanner().constructor; | 64 audioContext.createStereoPanner().constructor; |
| 61 } | 65 } |
| 62 window.PannerNode = audioContext.createPanner().constructor; | 66 $window.PannerNode = audioContext.createPanner().constructor; |
| 63 } | 67 } |
| 64 if (typeof window.AudioSourceNode == "undefined") { | 68 if (typeof $window.AudioSourceNode == "undefined") { |
| 65 window.AudioSourceNode = MediaElementAudioSourceNode.__proto__; | 69 $window.AudioSourceNode = MediaElementAudioSourceNode.__proto__; |
| 66 } | 70 } |
| 67 if (typeof window.FontFaceSet == "undefined") { | 71 if (typeof $window.FontFaceSet == "undefined") { |
| 68 // CSS Font Loading is not supported on Edge. | 72 // CSS Font Loading is not supported on Edge. |
| 69 if (typeof window.document.fonts != "undefined") { | 73 if (typeof $window.document.fonts != "undefined") { |
| 70 window.FontFaceSet = window.document.fonts.__proto__.constructor; | 74 $window.FontFaceSet = $window.document.fonts.__proto__.constructor; |
| 71 } | 75 } |
| 72 } | 76 } |
| 73 if (typeof window.MemoryInfo == "undefined") { | 77 if (typeof $window.MemoryInfo == "undefined") { |
| 74 if (typeof window.performance.memory != "undefined") { | 78 if (typeof $window.performance.memory != "undefined") { |
| 75 window.MemoryInfo = window.performance.memory.constructor; | 79 $window.MemoryInfo = $window.performance.memory.constructor; |
| 76 } | 80 } |
| 77 } | 81 } |
| 78 if (typeof window.Geolocation == "undefined") { | 82 if (typeof $window.Geolocation == "undefined") { |
| 79 window.Geolocation == window.navigator.geolocation.constructor; | 83 $window.Geolocation == $window.navigator.geolocation.constructor; |
| 80 } | 84 } |
| 81 if (typeof window.Animation == "undefined") { | 85 if (typeof $window.Animation == "undefined") { |
| 82 let d = window.document.createElement('div'); | 86 let d = $window.document.createElement('div'); |
| 83 if (typeof d.animate != "undefined") { | 87 if (typeof d.animate != "undefined") { |
| 84 window.Animation = d.animate(d).constructor; | 88 $window.Animation = d.animate(d).constructor; |
| 85 } | 89 } |
| 86 } | 90 } |
| 87 if (typeof window.SourceBufferList == "undefined") { | 91 if (typeof $window.SourceBufferList == "undefined") { |
| 88 window.SourceBufferList = | 92 $window.SourceBufferList = |
| 89 new window.MediaSource().sourceBuffers.constructor; | 93 new $window.MediaSource().sourceBuffers.constructor; |
| 90 } | 94 } |
| 91 if (typeof window.SpeechRecognition == "undefined") { | 95 if (typeof $window.SpeechRecognition == "undefined") { |
| 92 window.SpeechRecognition = window.webkitSpeechRecognition; | 96 $window.SpeechRecognition = $window.webkitSpeechRecognition; |
| 93 window.SpeechRecognitionError = window.webkitSpeechRecognitionError; | 97 $window.SpeechRecognitionError = $window.webkitSpeechRecognitionError; |
| 94 window.SpeechRecognitionEvent = window.webkitSpeechRecognitionEvent; | 98 $window.SpeechRecognitionEvent = $window.webkitSpeechRecognitionEvent; |
| 95 } | 99 } |
| 96 } | 100 } |
| 97 } | 101 return true; |
| 98 '''); | 102 })()'''); |
| 99 | 103 |
| 100 @JSExportName('global') | 104 @JSExportName('global') |
| 101 final global_ = JS( | 105 final global_ = JS( |
| 102 '', | 106 '', |
| 103 ''' | 107 ''' |
| 104 function () { | 108 function () { |
| 105 // Find global object. | 109 // Find global object. |
| 106 var globalState = (typeof window != "undefined") ? window | 110 var globalState = (typeof window != "undefined") ? window |
| 107 : (typeof global != "undefined") ? global | 111 : (typeof global != "undefined") ? global |
| 108 : (typeof self != "undefined") ? self : {}; | 112 : (typeof self != "undefined") ? self : {}; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 125 'failForWeakModeIsChecks' in settings ? | 129 'failForWeakModeIsChecks' in settings ? |
| 126 settings.failForWeakModeIsChecks : true); | 130 settings.failForWeakModeIsChecks : true); |
| 127 $trackProfile( | 131 $trackProfile( |
| 128 'trackProfile' in settings ? settings.trackProfile : false); | 132 'trackProfile' in settings ? settings.trackProfile : false); |
| 129 | 133 |
| 130 return globalState; | 134 return globalState; |
| 131 }() | 135 }() |
| 132 '''); | 136 '''); |
| 133 | 137 |
| 134 final JsSymbol = JS('', 'Symbol'); | 138 final JsSymbol = JS('', 'Symbol'); |
| OLD | NEW |