Chromium Code Reviews| 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 123 var dispatchRecordsForInstanceTags; | 123 var dispatchRecordsForInstanceTags; |
| 124 | 124 |
| 125 /** | 125 /** |
| 126 * Cache of interceptors indexed by uncacheable tags, e.g. "~SomeThing". | 126 * Cache of interceptors indexed by uncacheable tags, e.g. "~SomeThing". |
| 127 * This is a JavaScript object used as a map. | 127 * This is a JavaScript object used as a map. |
| 128 */ | 128 */ |
| 129 var interceptorsForUncacheableTags; | 129 var interceptorsForUncacheableTags; |
| 130 | 130 |
| 131 | 131 |
| 132 lookupInterceptor(String tag) { | 132 lookupInterceptor(String tag) { |
| 133 if (JS('bool', '!#', interceptorsByTag)) return JS('', 'null'); | |
|
floitsch
2015/02/26 18:12:12
I'm not sure I like this.
If there are native clas
floitsch
2015/02/26 18:12:12
I don't understand the `return JS('', 'null')` par
zarah
2015/02/27 09:03:48
As mentioned in my previous comment, I just think
| |
| 133 return propertyGet(interceptorsByTag, tag); | 134 return propertyGet(interceptorsByTag, tag); |
| 134 } | 135 } |
| 135 | 136 |
| 136 | 137 |
| 137 // Dispatch tag marks are optional prefixes for a dispatch tag that direct how | 138 // Dispatch tag marks are optional prefixes for a dispatch tag that direct how |
| 138 // the interceptor for the tag may be cached. | 139 // the interceptor for the tag may be cached. |
| 139 | 140 |
| 140 /// No caching permitted. | 141 /// No caching permitted. |
| 141 const UNCACHED_MARK = '~'; | 142 const UNCACHED_MARK = '~'; |
| 142 | 143 |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 295 | 296 |
| 296 dispatchRecordsForInstanceTags = JS('', 'Object.create(null)'); | 297 dispatchRecordsForInstanceTags = JS('', 'Object.create(null)'); |
| 297 interceptorsForUncacheableTags = JS('', 'Object.create(null)'); | 298 interceptorsForUncacheableTags = JS('', 'Object.create(null)'); |
| 298 | 299 |
| 299 initHooks(); | 300 initHooks(); |
| 300 | 301 |
| 301 // Try to pro-actively patch prototypes of DOM objects. For each of our known | 302 // Try to pro-actively patch prototypes of DOM objects. For each of our known |
| 302 // tags `TAG`, if `window.TAG` is a (constructor) function, set the dispatch | 303 // tags `TAG`, if `window.TAG` is a (constructor) function, set the dispatch |
| 303 // property if the function's prototype to a dispatch record. | 304 // property if the function's prototype to a dispatch record. |
| 304 var map = interceptorsByTag; | 305 var map = interceptorsByTag; |
| 306 if (JS('bool', '!map')) return; | |
|
floitsch
2015/02/26 18:12:12
ditto.
also won't work in minified mode.
zarah
2015/02/27 09:03:48
Acknowledged.
| |
| 305 var tags = JS('JSMutableArray', 'Object.getOwnPropertyNames(#)', map); | 307 var tags = JS('JSMutableArray', 'Object.getOwnPropertyNames(#)', map); |
| 306 | 308 |
| 307 if (JS('bool', 'typeof window != "undefined"')) { | 309 if (JS('bool', 'typeof window != "undefined"')) { |
| 308 var context = JS('=Object', 'window'); | 310 var context = JS('=Object', 'window'); |
| 309 var fun = JS('=Object', 'function () {}'); | 311 var fun = JS('=Object', 'function () {}'); |
| 310 for (int i = 0; i < tags.length; i++) { | 312 for (int i = 0; i < tags.length; i++) { |
| 311 var tag = tags[i]; | 313 var tag = tags[i]; |
| 312 var proto = prototypeForTagFunction(tag); | 314 var proto = prototypeForTagFunction(tag); |
| 313 if (proto != null) { | 315 if (proto != null) { |
| 314 var interceptorClass = JS('', '#[#]', map, tag); | 316 var interceptorClass = JS('', '#[#]', map, tag); |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 643 const _safariHooksTransformer = const JS_CONST(r''' | 645 const _safariHooksTransformer = const JS_CONST(r''' |
| 644 function(hooks) { return hooks; } | 646 function(hooks) { return hooks; } |
| 645 '''); | 647 '''); |
| 646 | 648 |
| 647 | 649 |
| 648 const _dartExperimentalFixupGetTagHooksTransformer = const JS_CONST(r''' | 650 const _dartExperimentalFixupGetTagHooksTransformer = const JS_CONST(r''' |
| 649 function(hooks) { | 651 function(hooks) { |
| 650 if (typeof dartExperimentalFixupGetTag != "function") return hooks; | 652 if (typeof dartExperimentalFixupGetTag != "function") return hooks; |
| 651 hooks.getTag = dartExperimentalFixupGetTag(hooks.getTag); | 653 hooks.getTag = dartExperimentalFixupGetTag(hooks.getTag); |
| 652 }'''); | 654 }'''); |
| OLD | NEW |