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 class _AudioContextFactoryProvider { | 5 class _AudioContextFactoryProvider { |
6 | 6 |
7 factory AudioContext() native ''' | 7 factory AudioContext() native ''' |
8 var constructor = window.AudioContext || window.webkitAudioContext; | 8 var constructor = window.AudioContext || window.webkitAudioContext; |
9 return new constructor(); | 9 return new constructor(); |
10 '''; | 10 '''; |
11 } | 11 } |
12 | 12 |
13 class _DOMParserFactoryProvider { | |
14 | |
15 factory DOMParser() native 'return new DOMParser();'; | |
16 } | |
17 | |
18 class _FileReaderFactoryProvider { | |
19 | |
20 factory FileReader() native 'return new FileReader();'; | |
21 } | |
22 | |
23 class _TypedArrayFactoryProvider { | 13 class _TypedArrayFactoryProvider { |
24 | 14 |
25 factory Float32Array(int length) => _F32(length); | 15 factory Float32Array(int length) => _F32(length); |
26 factory Float32Array.fromList(List<num> list) => _F32(ensureNative(list)); | 16 factory Float32Array.fromList(List<num> list) => _F32(ensureNative(list)); |
27 factory Float32Array.fromBuffer(ArrayBuffer buffer) => _F32(buffer); | 17 factory Float32Array.fromBuffer(ArrayBuffer buffer) => _F32(buffer); |
28 | 18 |
29 factory Float64Array(int length) => _F64(length); | 19 factory Float64Array(int length) => _F64(length); |
30 factory Float64Array.fromList(List<num> list) => _F64(ensureNative(list)); | 20 factory Float64Array.fromList(List<num> list) => _F64(ensureNative(list)); |
31 factory Float64Array.fromBuffer(ArrayBuffer buffer) => _F64(buffer); | 21 factory Float64Array.fromBuffer(ArrayBuffer buffer) => _F64(buffer); |
32 | 22 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 static Int16Array _I16(arg) native 'return new Int16Array(arg);'; | 54 static Int16Array _I16(arg) native 'return new Int16Array(arg);'; |
65 static Int32Array _I32(arg) native 'return new Int32Array(arg);'; | 55 static Int32Array _I32(arg) native 'return new Int32Array(arg);'; |
66 static Uint8Array _U8(arg) native 'return new Uint8Array(arg);'; | 56 static Uint8Array _U8(arg) native 'return new Uint8Array(arg);'; |
67 static Uint16Array _U16(arg) native 'return new Uint16Array(arg);'; | 57 static Uint16Array _U16(arg) native 'return new Uint16Array(arg);'; |
68 static Uint32Array _U32(arg) native 'return new Uint32Array(arg);'; | 58 static Uint32Array _U32(arg) native 'return new Uint32Array(arg);'; |
69 static Uint8ClampedArray _U8C(arg) native 'return new Uint8ClampedArray(arg);'
; | 59 static Uint8ClampedArray _U8C(arg) native 'return new Uint8ClampedArray(arg);'
; |
70 | 60 |
71 static ensureNative(List list) => list; // TODO: make sure. | 61 static ensureNative(List list) => list; // TODO: make sure. |
72 } | 62 } |
73 | 63 |
74 class _CSSMatrixFactoryProvider { | |
75 | |
76 factory CSSMatrix([String spec = '']) native | |
77 'return new WebKitCSSMatrix(spec);'; | |
78 } | |
79 | |
80 class _PointFactoryProvider { | 64 class _PointFactoryProvider { |
81 | 65 |
82 factory Point(num x, num y) native 'return new WebKitPoint(x, y);'; | 66 factory Point(num x, num y) native 'return new WebKitPoint(x, y);'; |
83 } | 67 } |
84 | |
85 class _WebSocketFactoryProvider { | |
86 | |
87 factory WebSocket(String url) native 'return new WebSocket(url);'; | |
88 } | |
89 | |
90 class _XMLHttpRequestFactoryProvider { | |
91 factory XMLHttpRequest() native 'return new XMLHttpRequest();'; | |
92 | |
93 factory XMLHttpRequest.getTEMPNAME(String url, | |
94 onSuccess(XMLHttpRequest request)) { | |
95 final request = new XMLHttpRequest(); | |
96 request.open('GET', url, true); | |
97 | |
98 // TODO(terry): Validate after client login added if necessary to forward | |
99 // cookies to server. | |
100 request.withCredentials = true; | |
101 | |
102 // Status 0 is for local XHR request. | |
103 request.on.readyStateChange.add((e) { | |
104 if (request.readyState == XMLHttpRequest.DONE && | |
105 (request.status == 200 || request.status == 0)) { | |
106 onSuccess(request); | |
107 } | |
108 }); | |
109 | |
110 request.send(); | |
111 | |
112 return request; | |
113 } | |
114 } | |
OLD | NEW |