Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(191)

Side by Side Diff: client/html/src/frog_FactoryProviders.dart

Issue 9403004: Wrapperless dart:html generator (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Final version to check in. changes generator script but doesn't check in an active version of the … Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « client/dom/templates/interface.darttemplate ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 class _AudioContextFactoryProvider {
6
7 factory AudioContext() native '''
8 var constructor = window.AudioContext || window.webkitAudioContext;
9 return new constructor();
10 ''';
11 }
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 {
24
25 factory Float32Array(int length) => _F32(length);
26 factory Float32Array.fromList(List<num> list) => _F32(ensureNative(list));
27 factory Float32Array.fromBuffer(ArrayBuffer buffer) => _F32(buffer);
28
29 factory Float64Array(int length) => _F64(length);
30 factory Float64Array.fromList(List<num> list) => _F64(ensureNative(list));
31 factory Float64Array.fromBuffer(ArrayBuffer buffer) => _F64(buffer);
32
33 factory Int8Array(int length) => _I8(length);
34 factory Int8Array.fromList(List<num> list) => _I8(ensureNative(list));
35 factory Int8Array.fromBuffer(ArrayBuffer buffer) => _I8(buffer);
36
37 factory Int16Array(int length) => _I16(length);
38 factory Int16Array.fromList(List<num> list) => _I16(ensureNative(list));
39 factory Int16Array.fromBuffer(ArrayBuffer buffer) => _I16(buffer);
40
41 factory Int32Array(int length) => _I32(length);
42 factory Int32Array.fromList(List<num> list) => _I32(ensureNative(list));
43 factory Int32Array.fromBuffer(ArrayBuffer buffer) => _I32(buffer);
44
45 factory Uint8Array(int length) => _U8(length);
46 factory Uint8Array.fromList(List<num> list) => _U8(ensureNative(list));
47 factory Uint8Array.fromBuffer(ArrayBuffer buffer) => _U8(buffer);
48
49 factory Uint16Array(int length) => _U16(length);
50 factory Uint16Array.fromList(List<num> list) => _U16(ensureNative(list));
51 factory Uint16Array.fromBuffer(ArrayBuffer buffer) => _U16(buffer);
52
53 factory Uint32Array(int length) => _U32(length);
54 factory Uint32Array.fromList(List<num> list) => _U32(ensureNative(list));
55 factory Uint32Array.fromBuffer(ArrayBuffer buffer) => _U32(buffer);
56
57 factory Uint8ClampedArray(int length) => _U8C(length);
58 factory Uint8ClampedArray.fromList(List<num> list) => _U8C(ensureNative(list)) ;
59 factory Uint8ClampedArray.fromBuffer(ArrayBuffer buffer) => _U8C(buffer);
60
61 static Float32Array _F32(arg) native 'return new Float32Array(arg);';
62 static Float64Array _F64(arg) native 'return new Float64Array(arg);';
63 static Int8Array _I8(arg) native 'return new Int8Array(arg);';
64 static Int16Array _I16(arg) native 'return new Int16Array(arg);';
65 static Int32Array _I32(arg) native 'return new Int32Array(arg);';
66 static Uint8Array _U8(arg) native 'return new Uint8Array(arg);';
67 static Uint16Array _U16(arg) native 'return new Uint16Array(arg);';
68 static Uint32Array _U32(arg) native 'return new Uint32Array(arg);';
69 static Uint8ClampedArray _U8C(arg) native 'return new Uint8ClampedArray(arg);' ;
70
71 static ensureNative(List list) => list; // TODO: make sure.
72 }
73
74 class _CSSMatrixFactoryProvider {
75
76 factory CSSMatrix([String spec = '']) native
77 'return new WebKitCSSMatrix(spec);';
78 }
79
80 // TODO(jacobr): this factory does not require any native code so move to a
81 // separate file so it can be shared between wrapper and wrapperless versions.
82 class _EventFactoryProvider {
83 factory Event(String type, [bool canBubble = true,
84 bool cancelable = true]) {
85 _EventJs e = _document._createEvent("Event");
86 e._initEvent(type, canBubble, cancelable);
87 return e;
88 }
89 }
90
91 class _PointFactoryProvider {
92
93 factory Point(num x, num y) native 'return new WebKitPoint(x, y);';
94 }
95
96 class _WebSocketFactoryProvider {
97
98 factory WebSocket(String url) native 'return new WebSocket(url);';
99 }
100
101 class _XMLHttpRequestFactoryProvider {
102 factory XMLHttpRequest() native 'return new XMLHttpRequest();';
103
104 factory XMLHttpRequest.getTEMPNAME(String url,
105 onSuccess(XMLHttpRequest request)) {
106 final request = new XMLHttpRequest();
107 request.open('GET', url, true);
108
109 // TODO(terry): Validate after client login added if necessary to forward
110 // cookies to server.
111 request.withCredentials = true;
112
113 // Status 0 is for local XHR request.
114 request.on.readyStateChange.add((e) {
115 if (request.readyState == XMLHttpRequest.DONE &&
116 (request.status == 200 || request.status == 0)) {
117 onSuccess(request);
118 }
119 });
120
121 request.send();
122
123 return request;
124 }
125 }
OLDNEW
« no previous file with comments | « client/dom/templates/interface.darttemplate ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698