| 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 String typeNameInChrome(obj) { | 5 String typeNameInChrome(obj) { |
| 6 String name = JS('String', "#.constructor.name", obj); | 6 String name = JS('String', "#.constructor.name", obj); |
| 7 if (name == 'Window') return 'DOMWindow'; | 7 if (name == 'Window') return 'DOMWindow'; |
| 8 if (name == 'CanvasPixelArray') return 'Uint8ClampedArray'; | 8 if (name == 'CanvasPixelArray') return 'Uint8ClampedArray'; |
| 9 if (name == 'WebKitMutationObserver') return 'MutationObserver'; | 9 if (name == 'WebKitMutationObserver') return 'MutationObserver'; |
| 10 if (name == 'FormData') return 'DOMFormData'; |
| 10 return name; | 11 return name; |
| 11 } | 12 } |
| 12 | 13 |
| 13 String typeNameInSafari(obj) { | 14 String typeNameInSafari(obj) { |
| 14 String name = JS('String', '#', constructorNameFallback(obj)); | 15 String name = JS('String', '#', constructorNameFallback(obj)); |
| 15 // Safari is very similar to Chrome. | 16 // Safari is very similar to Chrome. |
| 16 if (name == 'Window') return 'DOMWindow'; | 17 if (name == 'Window') return 'DOMWindow'; |
| 17 if (name == 'CanvasPixelArray') return 'Uint8ClampedArray'; | 18 if (name == 'CanvasPixelArray') return 'Uint8ClampedArray'; |
| 18 if (name == 'WebKitMutationObserver') return 'MutationObserver'; | 19 if (name == 'WebKitMutationObserver') return 'MutationObserver'; |
| 20 if (name == 'FormData') return 'DOMFormData'; |
| 19 return name; | 21 return name; |
| 20 } | 22 } |
| 21 | 23 |
| 22 String typeNameInOpera(obj) { | 24 String typeNameInOpera(obj) { |
| 23 String name = JS('String', '#', constructorNameFallback(obj)); | 25 String name = JS('String', '#', constructorNameFallback(obj)); |
| 24 if (name == 'Window') return 'DOMWindow'; | 26 if (name == 'Window') return 'DOMWindow'; |
| 27 if (name == 'FormData') return 'DOMFormData'; |
| 25 return name; | 28 return name; |
| 26 } | 29 } |
| 27 | 30 |
| 28 String typeNameInFirefox(obj) { | 31 String typeNameInFirefox(obj) { |
| 29 String name = JS('String', '#', constructorNameFallback(obj)); | 32 String name = JS('String', '#', constructorNameFallback(obj)); |
| 30 if (name == 'Window') return 'DOMWindow'; | 33 if (name == 'Window') return 'DOMWindow'; |
| 31 if (name == 'Document') return 'HTMLDocument'; | 34 if (name == 'Document') return 'HTMLDocument'; |
| 32 if (name == 'XMLDocument') return 'Document'; | 35 if (name == 'XMLDocument') return 'Document'; |
| 33 if (name == 'WorkerMessageEvent') return 'MessageEvent'; | 36 if (name == 'WorkerMessageEvent') return 'MessageEvent'; |
| 34 if (name == 'DragEvent') return 'MouseEvent'; | 37 if (name == 'DragEvent') return 'MouseEvent'; |
| 35 if (name == 'DataTransfer') return 'Clipboard'; | 38 if (name == 'DataTransfer') return 'Clipboard'; |
| 39 if (name == 'FormData') return 'DOMFormData'; |
| 36 return name; | 40 return name; |
| 37 } | 41 } |
| 38 | 42 |
| 39 String typeNameInIE(obj) { | 43 String typeNameInIE(obj) { |
| 40 String name = JS('String', '#', constructorNameFallback(obj)); | 44 String name = JS('String', '#', constructorNameFallback(obj)); |
| 41 if (name == 'Window') return 'DOMWindow'; | 45 if (name == 'Window') return 'DOMWindow'; |
| 42 if (name == 'Document') { | 46 if (name == 'Document') { |
| 43 // IE calls both HTML and XML documents 'Document', so we check for the | 47 // IE calls both HTML and XML documents 'Document', so we check for the |
| 44 // xmlVersion property, which is the empty string on HTML documents. | 48 // xmlVersion property, which is the empty string on HTML documents. |
| 45 if (JS('bool', '!!#.xmlVersion', obj)) return 'Document'; | 49 if (JS('bool', '!!#.xmlVersion', obj)) return 'Document'; |
| 46 return 'HTMLDocument'; | 50 return 'HTMLDocument'; |
| 47 } | 51 } |
| 48 if (name == 'CanvasPixelArray') return 'Uint8ClampedArray'; | 52 if (name == 'CanvasPixelArray') return 'Uint8ClampedArray'; |
| 49 if (name == 'DataTransfer') return 'Clipboard'; | 53 if (name == 'DataTransfer') return 'Clipboard'; |
| 50 if (name == 'DragEvent') return 'MouseEvent'; | 54 if (name == 'DragEvent') return 'MouseEvent'; |
| 51 if (name == 'HTMLDDElement') return 'HTMLElement'; | 55 if (name == 'HTMLDDElement') return 'HTMLElement'; |
| 52 if (name == 'HTMLDTElement') return 'HTMLElement'; | 56 if (name == 'HTMLDTElement') return 'HTMLElement'; |
| 53 if (name == 'HTMLTableDataCellElement') return 'HTMLTableCellElement'; | 57 if (name == 'HTMLTableDataCellElement') return 'HTMLTableCellElement'; |
| 54 if (name == 'HTMLTableHeaderCellElement') return 'HTMLTableCellElement'; | 58 if (name == 'HTMLTableHeaderCellElement') return 'HTMLTableCellElement'; |
| 55 if (name == 'HTMLPhraseElement') return 'HTMLElement'; | 59 if (name == 'HTMLPhraseElement') return 'HTMLElement'; |
| 56 if (name == 'MSStyleCSSProperties') return 'CSSStyleDeclaration'; | 60 if (name == 'MSStyleCSSProperties') return 'CSSStyleDeclaration'; |
| 57 if (name == 'MouseWheelEvent') return 'WheelEvent'; | 61 if (name == 'MouseWheelEvent') return 'WheelEvent'; |
| 62 if (name == 'FormData') return 'DOMFormData'; |
| 58 return name; | 63 return name; |
| 59 } | 64 } |
| 60 | 65 |
| 61 String constructorNameFallback(obj) { | 66 String constructorNameFallback(obj) { |
| 62 var constructor = JS('var', "#.constructor", obj); | 67 var constructor = JS('var', "#.constructor", obj); |
| 63 if (JS('String', "typeof(#)", constructor) === 'function') { | 68 if (JS('String', "typeof(#)", constructor) === 'function') { |
| 64 // The constructor isn't null or undefined at this point. Try | 69 // The constructor isn't null or undefined at this point. Try |
| 65 // to grab hold of its name. | 70 // to grab hold of its name. |
| 66 var name = JS('var', '#.name', constructor); | 71 var name = JS('var', '#.name', constructor); |
| 67 // If the name is a non-empty string, we use that as the type | 72 // If the name is a non-empty string, we use that as the type |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 } | 331 } |
| 327 return result; | 332 return result; |
| 328 } | 333 } |
| 329 | 334 |
| 330 /** | 335 /** |
| 331 * Called by the compiler to setup [_dynamicMetadata]. | 336 * Called by the compiler to setup [_dynamicMetadata]. |
| 332 */ | 337 */ |
| 333 void dynamicSetMetadata(List<List<String>> inputTable) { | 338 void dynamicSetMetadata(List<List<String>> inputTable) { |
| 334 _dynamicMetadata = buildDynamicMetadata(inputTable); | 339 _dynamicMetadata = buildDynamicMetadata(inputTable); |
| 335 } | 340 } |
| OLD | NEW |