| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 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 | 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 /** | 5 /** |
| 6 * Generates JS helpers for dart:core. This used to be in a file "core.js". | 6 * Generates JS helpers for dart:core. This used to be in a file "core.js". |
| 7 * Having them in Dart code means we can easily control which are generated. | 7 * Having them in Dart code means we can easily control which are generated. |
| 8 */ | 8 */ |
| 9 // TODO(jmesserly): one idea to make this cleaner: put these as private "native" | 9 // TODO(jmesserly): one idea to make this cleaner: put these as private "native" |
| 10 // methods somewhere in a library that we import. This would be rather elegant | 10 // methods somewhere in a library that we import. This would be rather elegant |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 var name = this.constructor.name; | 427 var name = this.constructor.name; |
| 428 if (name == 'Window') return 'DOMWindow'; | 428 if (name == 'Window') return 'DOMWindow'; |
| 429 return name; | 429 return name; |
| 430 } | 430 } |
| 431 | 431 |
| 432 function firefox$typeNameOf() { | 432 function firefox$typeNameOf() { |
| 433 var name = constructorNameWithFallback(this); | 433 var name = constructorNameWithFallback(this); |
| 434 if (name == 'Window') return 'DOMWindow'; | 434 if (name == 'Window') return 'DOMWindow'; |
| 435 if (name == 'Document') return 'HTMLDocument'; | 435 if (name == 'Document') return 'HTMLDocument'; |
| 436 if (name == 'XMLDocument') return 'Document'; | 436 if (name == 'XMLDocument') return 'Document'; |
| 437 if (name == 'WorkerMessageEvent') return 'MessageEvent'; |
| 437 return name; | 438 return name; |
| 438 } | 439 } |
| 439 | 440 |
| 440 function ie$typeNameOf() { | 441 function ie$typeNameOf() { |
| 441 var name = constructorNameWithFallback(this); | 442 var name = constructorNameWithFallback(this); |
| 442 if (name == 'Window') return 'DOMWindow'; | 443 if (name == 'Window') return 'DOMWindow'; |
| 443 // IE calls both HTML and XML documents 'Document', so we check for the | 444 // IE calls both HTML and XML documents 'Document', so we check for the |
| 444 // xmlVersion property, which is the empty string on HTML documents. | 445 // xmlVersion property, which is the empty string on HTML documents. |
| 445 if (name == 'Document' && this.xmlVersion) return 'Document'; | 446 if (name == 'Document' && this.xmlVersion) return 'Document'; |
| 446 if (name == 'Document') return 'HTMLDocument'; | 447 if (name == 'Document') return 'HTMLDocument'; |
| 448 if (name == 'HTMLTableDataCellElement') return 'HTMLTableCellElement'; |
| 449 if (name == 'HTMLTableHeaderCellElement') return 'HTMLTableCellElement'; |
| 450 if (name == 'MSStyleCSSProperties') return 'CSSStyleDeclaration'; |
| 447 return name; | 451 return name; |
| 448 } | 452 } |
| 449 | 453 |
| 450 // If we're not in the browser, we're almost certainly running on v8. | 454 // If we're not in the browser, we're almost certainly running on v8. |
| 451 if (typeof(navigator) != 'object') return chrome$typeNameOf; | 455 if (typeof(navigator) != 'object') return chrome$typeNameOf; |
| 452 | 456 |
| 453 var userAgent = navigator.userAgent; | 457 var userAgent = navigator.userAgent; |
| 454 if (/Chrome|DumpRenderTree/.test(userAgent)) return chrome$typeNameOf; | 458 if (/Chrome|DumpRenderTree/.test(userAgent)) return chrome$typeNameOf; |
| 455 if (/Firefox/.test(userAgent)) return firefox$typeNameOf; | 459 if (/Firefox/.test(userAgent)) return firefox$typeNameOf; |
| 456 if (/MSIE/.test(userAgent)) return ie$typeNameOf; | 460 if (/MSIE/.test(userAgent)) return ie$typeNameOf; |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 bound.$length = Math.max(0, funcLength - (argsLength - 1)); | 604 bound.$length = Math.max(0, funcLength - (argsLength - 1)); |
| 601 return bound; | 605 return bound; |
| 602 } else { | 606 } else { |
| 603 var bound = function() { | 607 var bound = function() { |
| 604 return func.apply(thisObj, arguments); | 608 return func.apply(thisObj, arguments); |
| 605 }; | 609 }; |
| 606 bound.$length = funcLength; | 610 bound.$length = funcLength; |
| 607 return bound; | 611 return bound; |
| 608 } | 612 } |
| 609 };"""; | 613 };"""; |
| OLD | NEW |