| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 part of _js_helper; | 5 part of _js_helper; |
| 6 | 6 |
| 7 | 7 |
| 8 // TODO(ngeoffray): stop using this method once our optimizers can | 8 // TODO(ngeoffray): stop using this method once our optimizers can |
| 9 // change str1.contains(str2) into str1.indexOf(str2) != -1. | 9 // change str1.contains(str2) into str1.indexOf(str2) != -1. |
| 10 bool contains(String userAgent, String name) { | 10 bool contains(String userAgent, String name) { |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 // | 436 // |
| 437 // This is a temporary place for the JavaScript code. | 437 // This is a temporary place for the JavaScript code. |
| 438 // | 438 // |
| 439 // TODO(sra): These code fragments are not minified. They could be generated by | 439 // TODO(sra): These code fragments are not minified. They could be generated by |
| 440 // the code emitter, or JS_CONST could be improved to parse entire functions and | 440 // the code emitter, or JS_CONST could be improved to parse entire functions and |
| 441 // take care of the minification. | 441 // take care of the minification. |
| 442 | 442 |
| 443 const _baseHooks = const JS_CONST(r''' | 443 const _baseHooks = const JS_CONST(r''' |
| 444 function() { | 444 function() { |
| 445 function typeNameInChrome(o) { | 445 function typeNameInChrome(o) { |
| 446 var name = o.constructor.name; | 446 var constructor = o.constructor; |
| 447 if (name) return name; | 447 if (constructor) { |
| 448 var name = constructor.name; |
| 449 if (name) return name; |
| 450 } |
| 448 var s = Object.prototype.toString.call(o); | 451 var s = Object.prototype.toString.call(o); |
| 449 return s.substring(8, s.length - 1); | 452 return s.substring(8, s.length - 1); |
| 450 } | 453 } |
| 451 function getUnknownTag(object, tag) { | 454 function getUnknownTag(object, tag) { |
| 452 // This code really belongs in [getUnknownTagGenericBrowser] but having it | 455 // This code really belongs in [getUnknownTagGenericBrowser] but having it |
| 453 // here allows [getUnknownTag] to be tested on d8. | 456 // here allows [getUnknownTag] to be tested on d8. |
| 454 if (/^HTML[A-Z].*Element$/.test(tag)) { | 457 if (/^HTML[A-Z].*Element$/.test(tag)) { |
| 455 // Check that it is not a simple JavaScript object. | 458 // Check that it is not a simple JavaScript object. |
| 456 var name = Object.prototype.toString.call(object); | 459 var name = Object.prototype.toString.call(object); |
| 457 if (name == "[object Object]") return null; | 460 if (name == "[object Object]") return null; |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 const _safariHooksTransformer = const JS_CONST(r''' | 642 const _safariHooksTransformer = const JS_CONST(r''' |
| 640 function(hooks) { return hooks; } | 643 function(hooks) { return hooks; } |
| 641 '''); | 644 '''); |
| 642 | 645 |
| 643 | 646 |
| 644 const _dartExperimentalFixupGetTagHooksTransformer = const JS_CONST(r''' | 647 const _dartExperimentalFixupGetTagHooksTransformer = const JS_CONST(r''' |
| 645 function(hooks) { | 648 function(hooks) { |
| 646 if (typeof dartExperimentalFixupGetTag != "function") return hooks; | 649 if (typeof dartExperimentalFixupGetTag != "function") return hooks; |
| 647 hooks.getTag = dartExperimentalFixupGetTag(hooks.getTag); | 650 hooks.getTag = dartExperimentalFixupGetTag(hooks.getTag); |
| 648 }'''); | 651 }'''); |
| OLD | NEW |