| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011, 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 DOM implementation. | |
| 7 | |
| 8 function DOM$EnsureDartNull(value) { | |
| 9 return value === null ? (void 0) : value; | |
| 10 } | |
| 11 | |
| 12 function DOM$fixStatic(cls, key) { | |
| 13 cls[key + '$getter'] = function() { | |
| 14 return DOM$EnsureDartNull(cls[key]); | |
| 15 }; | |
| 16 } | |
| 17 function DOM$fixGetter(cls, key) { | |
| 18 cls.prototype[key + '$getter'] = function() { | |
| 19 return DOM$EnsureDartNull(this[key]); | |
| 20 }; | |
| 21 } | |
| 22 function DOM$fixSetter(cls, key) { | |
| 23 cls.prototype[key + '$setter'] = function(x) { this[key] = x; }; | |
| 24 } | |
| 25 function DOM$fixMember(cls, key) { | |
| 26 cls.prototype[key + '$member'] = function () { | |
| 27 return DOM$EnsureDartNull(this[key].apply(this, arguments)); | |
| 28 }; | |
| 29 } | |
| 30 function DOM$fixProp(cls, key) { | |
| 31 DOM$fixGetter(cls, key); | |
| 32 DOM$fixSetter(cls, key); | |
| 33 } | |
| 34 function DOM$fixStatics(cls, keys) { | |
| 35 // TODO(vsm): We should eliminate this dynamic check. | |
| 36 if (cls) { | |
| 37 for (var i = 0; i < keys.length; ++i) { | |
| 38 DOM$fixStatic(cls, keys[i]); | |
| 39 } | |
| 40 } | |
| 41 } | |
| 42 function DOM$fixAccessors(cls, keys) { | |
| 43 // TODO(vsm): We should eliminate this dynamic check. | |
| 44 if (cls && cls.prototype) { | |
| 45 for (var i = 0; i < keys.length; ++i) { | |
| 46 DOM$fixProp(cls, keys[i]); | |
| 47 } | |
| 48 } | |
| 49 } | |
| 50 function DOM$fixGetters(cls, keys) { | |
| 51 // TODO(vsm): We should eliminate this dynamic check. | |
| 52 if (cls && cls.prototype) { | |
| 53 for (var i = 0; i < keys.length; ++i) { | |
| 54 DOM$fixGetter(cls, keys[i]); | |
| 55 } | |
| 56 } | |
| 57 } | |
| 58 function DOM$fixMembers(cls, keys) { | |
| 59 // TODO(vsm): We should eliminate this dynamic check. | |
| 60 if (cls && cls.prototype) { | |
| 61 for (var i = 0; i < keys.length; ++i) { | |
| 62 DOM$fixMember(cls, keys[i]); | |
| 63 } | |
| 64 } | |
| 65 } | |
| 66 | |
| 67 $(!GLOBAL) | |
| 68 function DOM$FixBindings(w) { | |
| 69 | |
| 70 // Have we been called to augment the prototypes on this window before? | |
| 71 if (w.HTMLIFrameElement.prototype && | |
| 72 w.HTMLIFrameElement.prototype.contentWindow$getter) { | |
| 73 return; | |
| 74 } | |
| 75 | |
| 76 // TODO(vsm): Clean this up. This is a workaround for Firefox 3.6 where | |
| 77 // the Location prototype cannot be modified. | |
| 78 // TODO(jacobr): unify the hacks for Navigator and Location. | |
| 79 var tmpLocation = w.Location; | |
| 80 if (w.location) { | |
| 81 if (tmpLocation) { | |
| 82 try { | |
| 83 delete tmpLocation.prototype.get$dart$test; | |
| 84 } catch (e) { | |
| 85 w.Location = { prototype: w.location }; | |
| 86 } | |
| 87 } else { | |
| 88 w.Location = { prototype: w.location.__proto__ }; | |
| 89 } | |
| 90 } | |
| 91 // TODO(vsm): Clean this up. This is a workaround for Firefox 3.6 where | |
| 92 // the Navigator prototype cannot be modified. | |
| 93 if (navigator.userAgent.indexOf("Firefox") != -1) { | |
| 94 w.Navigator = { prototype: w.navigator }; | |
| 95 } | |
| 96 $(!INNER) | |
| 97 if (tmpLocation) { | |
| 98 w.Location = tmpLocation; | |
| 99 } | |
| 100 | |
| 101 // Chrome still uses initWebKitWheelEvent. | |
| 102 if (w && w.WheelEvent && w.WheelEvent.prototype && | |
| 103 !w.WheelEvent.prototype.initWheelEvent) { | |
| 104 w.WheelEvent.prototype.initWheelEvent = function() { | |
| 105 return this.initWebKitWheelEvent.apply(this, arguments); | |
| 106 }; | |
| 107 } | |
| 108 | |
| 109 | |
| 110 // Special implementations that fix the prototypes in a new context on the | |
| 111 // fly. | |
| 112 // TODO(sra): HTMLFrameElement, HTMLObjectElement | |
| 113 if (w.HTMLIFrameElement) { | |
| 114 w.HTMLIFrameElement$Dart = w.HTMLIFrameElement; | |
| 115 w.HTMLIFrameElement.prototype.contentDocument$getter = function() { | |
| 116 this.contentWindow$getter(); // Fix bindings in context | |
| 117 return DOM$EnsureDartNull(this.contentDocument); | |
| 118 }; | |
| 119 w.HTMLIFrameElement.prototype.contentWindow$getter = function() { | |
| 120 var window = this.contentWindow; | |
| 121 if (window) { | |
| 122 DOM$FixBindings(window); | |
| 123 } | |
| 124 return DOM$EnsureDartNull(window); | |
| 125 }; | |
| 126 } | |
| 127 } // end of DOM$FixBindings | |
| 128 | |
| 129 if (this.window) { | |
| 130 DOM$FixBindings(this.window); | |
| 131 | |
| 132 this.arguments = window; | |
| 133 } | |
| 134 | |
| 135 // Declared in src/GlobalProperties.dart | |
| 136 function native__NativeDomGlobalProperties_getWindow() { | |
| 137 // TODO: Should the window be obtained from an isolate? | |
| 138 return window; | |
| 139 } | |
| 140 | |
| 141 // Declared in src/GlobalProperties.dart | |
| 142 function native__NativeDomGlobalProperties_getDocument() { | |
| 143 // TODO: Should the window be obtained from an isolate? | |
| 144 return window.document; | |
| 145 } | |
| OLD | NEW |