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

Side by Side Diff: test/browser/dom.dart

Issue 1243503007: fixes #221, initial sync*, async, async* implementation (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 4 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
« no previous file with comments | « lib/src/js/template.dart ('k') | test/browser/js_test.dart » ('j') | 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) 2015, 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 @JsName(name: 'window')
6 library dom;
7
8 @JsName()
9 class Window {}
10
11 class JsName {
12 /// The JavaScript name.
13 /// Used for classes and libraries.
14 /// Note that this could be an expression, e.g. `lib.TypeName` in JS, but it
15 /// should be kept simple, as it will be generated directly into the code.
16 final String name;
17 const JsName({this.name});
18 }
19 class Overload {
20 const Overload();
21 }
22 const overload = const Overload();
23
24 external Document get document;
25 external Window get window;
26
27 @JsName()
28 abstract class Document extends Node {
29 Element createElement(String name);
30 Element querySelector(String selector);
31
32 HTMLElement head;
33 HTMLElement body;
34 }
35
36 @JsName()
37 class Blob {
38 external Blob(blobParts, {String type});
39 }
40
41 @JsName()
42 class CustomEvent {
43 external CustomEvent(String type, {detail, bubbles, cancelable});
44 }
45
46 @JsName()
47 abstract class Element extends Node {
48 void addEventListener(String type, EventListener callback, [bool capture]);
49 String textContent;
50 }
51
52 @JsName()
53 abstract class HTMLElement extends Element {
54 String innerHTML;
55 HTMLCollection get children;
56 }
57
58 @JsName()
59 abstract class Node {
60 bool hasChildNodes();
61 NodeList get childNodes;
62
63 Node insertBefore(Node node, [Node child]);
64 Node appendChild(Node node);
65 Node replaceChild(Node node, Node child);
66 Node removeChild(Node child);
67 }
68
69 @JsName()
70 abstract class HTMLCollection {
71 int get length;
72 external Element operator [](num index);
73 }
74
75 @JsName()
76 class NodeList {
77 external NodeList();
78 external num get length;
79 external set length(num _);
80 external Node item(num index);
81
82 external Node operator [](num index);
83 external void operator []=(num index, Node);
84 }
85
86 typedef void EventListener(Event e);
87
88 @JsName()
89 abstract class Event {}
90
91 // TODO(jmesserly): rename these
92 @JsName(name: 'HTMLInputElement')
93 abstract class InputElement extends HTMLElement {
94 String value;
95 }
96
97 @JsName(name: 'HTMLCanvasElement')
98 abstract class CanvasElement extends HTMLElement {
99 RenderingContext getContext(String contextId);
100 }
101
102 @JsName(name: 'HTMLDivElement')
103 abstract class DivElement extends HTMLElement {
104 RenderingContext getContext(String contextId);
105 }
106
107 @JsName(name: 'HTMLScriptElement')
108 abstract class ScriptElement extends HTMLElement {
109 String type;
110 }
111
112
113 // TODO(jmesserly): union type of CanvasRenderingContext2D and
114 // WebGLRenderingContext
115 abstract class RenderingContext {}
116
117 // http://www.w3.org/html/wg/drafts/2dcontext/html5_canvas_CR/
118 @JsName()
119 abstract class CanvasRenderingContext2D
120 implements CanvasDrawingStyles, CanvasPathMethods, RenderingContext {
121
122 // back-reference to the canvas
123 CanvasElement get canvas;
124
125 // state
126 void save(); // push state on state stack
127 void restore(); // pop state stack and restore state
128
129 // transformations (default transform is the identity matrix)
130 void scale(num x, num y);
131 void rotate(num angle);
132 void translate(num x, num y);
133 void transform(num a, num b, num c, num d, num e, num f);
134 void setTransform(num a, num b, num c, num d, num e, num f);
135
136 // compositing
137 num globalAlpha; // (default 1.0)
138 String globalCompositeOperation; // (default source-over)
139
140 // colors and styles (see also the CanvasDrawingStyles interface)
141 Object strokeStyle; // (default black)
142 Object fillStyle; // (default black)
143 CanvasGradient createLinearGradient(num x0, num y0, num x1, num y1);
144 CanvasGradient createRadialGradient(
145 num x0, num y0, num r0, num x1, num y1, num r1);
146 CanvasPattern createPattern(Element image, [String repetition]);
147
148 // shadows
149 num shadowOffsetX; // (default 0)
150 num shadowOffsetY; // (default 0)
151 num shadowBlur; // (default 0)
152 String shadowColor; // (default transparent black)
153
154 // rects
155 void clearRect(num x, num y, num w, num h);
156 void fillRect(num x, num y, num w, num h);
157 void strokeRect(num x, num y, num w, num h);
158
159 // path API (see also CanvasPathMethods)
160 void beginPath();
161 void fill();
162 void stroke();
163 void drawFocusIfNeeded(Element element);
164 void clip();
165 bool isPointInPath(num x, num y);
166
167 // text (see also the CanvasDrawingStyles interface)
168 void fillText(String text, num x, num y, [num maxWidth]);
169 void strokeText(String text, num x, num y, [num maxWidth]);
170 TextMetrics measureText(String text);
171
172 // drawing images
173 void drawImage(Element image, num dx_or_sx, num dy_or_sy,
174 [num dw_or_sw, num dh_or_sh, num dx, num dy, num dw, num dh]);
175 @overload void _drawImage_0(Element image, num dx, num dy);
176 @overload void _drawImage_1(Element image, num dx, num dy, num dw, num dh);
177 @overload void _drawImage_2(Element image, num sx, num sy, num sw, num sh,
178 num dx, num dy, num dw, num dh);
179
180 // hit regions
181 void addHitRegion({String id: '', Element control});
182 void removeHitRegion(String id);
183 void clearHitRegions();
184
185 // pixel manipulation
186 ImageData createImageData(Object sw_or_imageData, [num sh]);
187 @overload ImageData _createImageData_0(num sw, num sh);
188 @overload ImageData _createImageData_1(ImageData imagedata);
189
190 ImageData getImageData(num sx, num sy, num sw, num sh);
191 void putImageData(ImageData imagedata, num dx, num dy,
192 [num dirtyX, num dirtyY, num dirtyWidth, num dirtyHeight]);
193 @overload void _putImageData_0(ImageData imagedata, num dx, num dy,
194 num dirtyX, num dirtyY, num dirtyWidth, num dirtyHeight);
195 @overload void _putImageData_1(ImageData imagedata, num dx, num dy);
196 }
197
198 abstract class CanvasDrawingStyles {
199 // line caps/joins
200 num lineWidth; // (default 1)
201 String lineCap; // "butt", "round", "square" (default "butt")
202 String lineJoin; // "round", "bevel", "miter" (default "miter")
203 num miterLimit; // (default 10)
204
205 // dashed lines
206 void setLineDash(List<num> segments); // default empty
207 List<num> getLineDash();
208 num lineDashOffset;
209
210 // text
211 String font; // (default 10px sans-serif)
212
213 // "start", "end", "left", "right", "center" (default: "start")
214 String textAlign;
215
216 // "top", "hanging", "middle", "alphabetic",
217 // "ideographic", "bottom" (default: "alphabetic")
218 String textBaseline;
219 }
220
221 abstract class CanvasPathMethods {
222 // shared path API methods
223 void closePath();
224 void moveTo(num x, num y);
225 void lineTo(num x, num y);
226 void quadraticCurveTo(num cpx, num cpy, num x, num y);
227 void bezierCurveTo(num cp1x, num cp1y, num cp2x, num cp2y, num x, num y);
228 void arcTo(num x1, num y1, num x2, num y2, num radius);
229 void rect(num x, num y, num w, num h);
230 void arc(num x, num y, num radius, num startAngle, num endAngle,
231 [bool anticlockwise]);
232 }
233
234 @JsName()
235 abstract class CanvasGradient {
236 // opaque object
237 void addColorStop(num offset, String color);
238 }
239
240 @JsName()
241 abstract class CanvasPattern {
242 // opaque object
243 }
244
245 @JsName()
246 abstract class TextMetrics {
247 num get width;
248 }
249
250 @JsName()
251 abstract class ImageData {
252 int get width;
253 int get height;
254 // TODO: readonly Uint8ClampedArray data;
255 }
OLDNEW
« no previous file with comments | « lib/src/js/template.dart ('k') | test/browser/js_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698