Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Unified Diff: pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/runtime.dart

Issue 2980853002: Registration-based approach to cross frame support. (Closed)
Patch Set: Update dart:html Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/runtime.dart
diff --git a/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/runtime.dart b/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/runtime.dart
index 40aa8f264ecfe4b49ccc4c0c281bcd19cf3c4767..8dff67c6617d9bbf947197c69c2aa1fbdf17b33d 100644
--- a/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/runtime.dart
+++ b/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/runtime.dart
@@ -36,69 +36,79 @@ part 'utils.dart';
// TODO(vsm): Move polyfill code to dart:html.
// Note, native extensions are registered onto types in dart.global.
// This polyfill needs to run before the corresponding dart:html code is run.
-@JSExportName('global')
-final global_ = JS(
+final polyfill = JS(
'',
'''
- function () {
- if (typeof NodeList !== "undefined") {
- // TODO(vsm): Do we still need these?
- NodeList.prototype.get = function(i) { return this[i]; };
- NamedNodeMap.prototype.get = function(i) { return this[i]; };
- DOMTokenList.prototype.get = function(i) { return this[i]; };
- HTMLCollection.prototype.get = function(i) { return this[i]; };
+function (window) {
+ if (typeof window.NodeList !== "undefined") {
+ // TODO(vsm): Do we still need these?
+ window.NodeList.prototype.get = function(i) { return this[i]; };
+ window.NamedNodeMap.prototype.get = function(i) { return this[i]; };
+ window.DOMTokenList.prototype.get = function(i) { return this[i]; };
+ window.HTMLCollection.prototype.get = function(i) { return this[i]; };
- // Expose constructors for DOM types dart:html needs to assume are
- // available on window.
- if (typeof PannerNode == "undefined") {
- let audioContext;
- if (typeof AudioContext == "undefined" &&
- (typeof webkitAudioContext != "undefined")) {
- audioContext = new webkitAudioContext();
- } else {
- audioContext = new AudioContext();
- window.StereoPannerNode =
- audioContext.createStereoPanner().constructor;
- }
- window.PannerNode = audioContext.createPanner().constructor;
- }
- if (typeof AudioSourceNode == "undefined") {
- window.AudioSourceNode = MediaElementAudioSourceNode.__proto__;
- }
- if (typeof FontFaceSet == "undefined") {
- // CSS Font Loading is not supported on Edge.
- if (typeof document.fonts != "undefined") {
- window.FontFaceSet = document.fonts.__proto__.constructor;
- }
- }
- if (typeof MemoryInfo == "undefined") {
- if (typeof window.performance.memory != "undefined") {
- window.MemoryInfo = window.performance.memory.constructor;
- }
+ // Expose constructors for DOM types dart:html needs to assume are
+ // available on window.
+ if (typeof window.PannerNode == "undefined") {
+ let audioContext;
+ if (typeof window.AudioContext == "undefined" &&
+ (typeof window.webkitAudioContext != "undefined")) {
+ audioContext = new window.webkitAudioContext();
+ } else {
+ audioContext = new window.AudioContext();
+ window.StereoPannerNode =
+ audioContext.createStereoPanner().constructor;
}
- if (typeof Geolocation == "undefined") {
- navigator.geolocation.constructor;
- }
- if (typeof Animation == "undefined") {
- let d = document.createElement('div');
- if (typeof d.animate != "undefined") {
- window.Animation = d.animate(d).constructor;
- }
+ window.PannerNode = audioContext.createPanner().constructor;
+ }
+ if (typeof window.AudioSourceNode == "undefined") {
+ window.AudioSourceNode = MediaElementAudioSourceNode.__proto__;
+ }
+ if (typeof window.FontFaceSet == "undefined") {
+ // CSS Font Loading is not supported on Edge.
+ if (typeof window.document.fonts != "undefined") {
+ window.FontFaceSet = window.document.fonts.__proto__.constructor;
}
- if (typeof SourceBufferList == "undefined") {
- window.SourceBufferList = new MediaSource().sourceBuffers.constructor;
+ }
+ if (typeof window.MemoryInfo == "undefined") {
+ if (typeof window.performance.memory != "undefined") {
+ window.MemoryInfo = window.performance.memory.constructor;
}
- if (typeof SpeechRecognition == "undefined") {
- window.SpeechRecognition = window.webkitSpeechRecognition;
- window.SpeechRecognitionError = window.webkitSpeechRecognitionError;
- window.SpeechRecognitionEvent = window.webkitSpeechRecognitionEvent;
+ }
+ if (typeof window.Geolocation == "undefined") {
+ window.Geolocation == window.navigator.geolocation.constructor;
+ }
+ if (typeof window.Animation == "undefined") {
+ let d = window.document.createElement('div');
+ if (typeof d.animate != "undefined") {
+ window.Animation = d.animate(d).constructor;
}
}
+ if (typeof window.SourceBufferList == "undefined") {
+ window.SourceBufferList =
+ new window.MediaSource().sourceBuffers.constructor;
+ }
+ if (typeof window.SpeechRecognition == "undefined") {
+ window.SpeechRecognition = window.webkitSpeechRecognition;
+ window.SpeechRecognitionError = window.webkitSpeechRecognitionError;
+ window.SpeechRecognitionEvent = window.webkitSpeechRecognitionEvent;
+ }
+ }
+}
+''');
+@JSExportName('global')
+final global_ = JS(
+ '',
+ '''
+ function () {
+ // Find global object.
var globalState = (typeof window != "undefined") ? window
: (typeof global != "undefined") ? global
: (typeof self != "undefined") ? self : {};
+ $polyfill(globalState);
+
// These settings must be configured before the application starts so that
// user code runs with the correct configuration.
let settings = 'ddcSettings' in globalState ? globalState.ddcSettings : {};

Powered by Google App Engine
This is Rietveld 408576698