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

Side by Side Diff: test/codegen/sunflower/dom.dart

Issue 1448993002: Switch ddc to use @JS instead of @JSName (Closed) Base URL: git://github.com/dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 1 month 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 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 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 @JsName(name: 'window') 5 @js.JS('window')
6 library dom; 6 library dom;
7 7
8 @JsName() 8 import 'package:js/js.dart' as js;
9
10 @js.JS()
9 class Window {} 11 class Window {}
10 12
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 { 13 class Overload {
20 const Overload(); 14 const Overload();
21 } 15 }
22 const overload = const Overload(); 16 const overload = const Overload();
23 17
24 external Document get document; 18 external Document get document;
25 external Window get window; 19 external Window get window;
26 20
27 @JsName() 21 @js.JS()
28 abstract class Document extends Node { 22 abstract class Document extends Node {
29 Element createElement(String name); 23 Element createElement(String name);
30 Element querySelector(String selector); 24 Element querySelector(String selector);
31 25
32 HTMLElement head; 26 HTMLElement head;
33 HTMLElement body; 27 HTMLElement body;
34 } 28 }
35 29
36 @JsName() 30 @js.JS()
37 class Blob { 31 class Blob {
38 external Blob(blobParts, {String type}); 32 external Blob(blobParts, {String type});
39 } 33 }
40 34
41 class CustomEvent { 35 class CustomEvent {
42 external CustomEvent(String type, {detail, bubbles, cancelable}); 36 external CustomEvent(String type, {detail, bubbles, cancelable});
43 } 37 }
44 38
45 @JsName() 39 @js.JS()
46 abstract class Element extends Node { 40 abstract class Element extends Node {
47 void addEventListener(String type, EventListener callback, [bool capture]); 41 void addEventListener(String type, EventListener callback, [bool capture]);
48 String textContent; 42 String textContent;
49 } 43 }
50 44
51 @JsName() 45 @js.JS()
52 abstract class HTMLElement extends Element { 46 abstract class HTMLElement extends Element {
53 String innerHTML; 47 String innerHTML;
54 HTMLCollection get children; 48 HTMLCollection get children;
55 } 49 }
56 50
57 @JsName() 51 @js.JS()
58 abstract class Node { 52 abstract class Node {
59 bool hasChildNodes(); 53 bool hasChildNodes();
60 NodeList get childNodes; 54 NodeList get childNodes;
61 55
62 Node insertBefore(Node node, [Node child]); 56 Node insertBefore(Node node, [Node child]);
63 Node appendChild(Node node); 57 Node appendChild(Node node);
64 Node replaceChild(Node node, Node child); 58 Node replaceChild(Node node, Node child);
65 Node removeChild(Node child); 59 Node removeChild(Node child);
66 } 60 }
67 61
68 abstract class HTMLCollection { 62 abstract class HTMLCollection {
69 int get length; 63 int get length;
70 external Element operator [](num index); 64 external Element operator [](num index);
71 } 65 }
72 66
73 @JsName() 67 @js.JS()
74 class NodeList { 68 class NodeList {
75 external NodeList(); 69 external NodeList();
76 external num get length; 70 external num get length;
77 external set length(num _); 71 external set length(num _);
78 external Node item(num index); 72 external Node item(num index);
79 73
80 external Node operator [](num index); 74 external Node operator [](num index);
81 external void operator []=(num index, Node); 75 external void operator []=(num index, Node);
82 } 76 }
83 77
84 typedef void EventListener(Event e); 78 typedef void EventListener(Event e);
85 79
86 @JsName() 80 @js.JS()
87 abstract class Event {} 81 abstract class Event {}
88 82
89 // TODO(jmesserly): rename these 83 // TODO(jmesserly): rename these
90 @JsName(name: 'HTMLInputElement') 84 @js.JS('HTMLInputElement')
91 abstract class InputElement extends HTMLElement { 85 abstract class InputElement extends HTMLElement {
92 String value; 86 String value;
93 } 87 }
94 88
95 @JsName(name: 'HTMLCanvasElement') 89 @js.JS('HTMLCanvasElement')
96 abstract class CanvasElement extends HTMLElement { 90 abstract class CanvasElement extends HTMLElement {
97 RenderingContext getContext(String contextId); 91 RenderingContext getContext(String contextId);
98 } 92 }
99 93
100 @JsName(name: 'HTMLDivElement') 94 @js.JS('HTMLDivElement')
101 abstract class DivElement extends HTMLElement { 95 abstract class DivElement extends HTMLElement {
102 RenderingContext getContext(String contextId); 96 RenderingContext getContext(String contextId);
103 } 97 }
104 98
105 @JsName(name: 'HTMLScriptElement') 99 @js.JS('HTMLScriptElement')
106 abstract class ScriptElement extends HTMLElement { 100 abstract class ScriptElement extends HTMLElement {
107 String type; 101 String type;
108 } 102 }
109 103
110 104
111 // TODO(jmesserly): union type of CanvasRenderingContext2D and 105 // TODO(jmesserly): union type of CanvasRenderingContext2D and
112 // WebGLRenderingContext 106 // WebGLRenderingContext
113 abstract class RenderingContext {} 107 abstract class RenderingContext {}
114 108
115 // http://www.w3.org/html/wg/drafts/2dcontext/html5_canvas_CR/ 109 // http://www.w3.org/html/wg/drafts/2dcontext/html5_canvas_CR/
116 @JsName() 110 @js.JS()
117 abstract class CanvasRenderingContext2D 111 abstract class CanvasRenderingContext2D
118 implements CanvasDrawingStyles, CanvasPathMethods, RenderingContext { 112 implements CanvasDrawingStyles, CanvasPathMethods, RenderingContext {
119 113
120 // back-reference to the canvas 114 // back-reference to the canvas
121 CanvasElement get canvas; 115 CanvasElement get canvas;
122 116
123 // state 117 // state
124 void save(); // push state on state stack 118 void save(); // push state on state stack
125 void restore(); // pop state stack and restore state 119 void restore(); // pop state stack and restore state
126 120
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 void moveTo(num x, num y); 216 void moveTo(num x, num y);
223 void lineTo(num x, num y); 217 void lineTo(num x, num y);
224 void quadraticCurveTo(num cpx, num cpy, num x, num y); 218 void quadraticCurveTo(num cpx, num cpy, num x, num y);
225 void bezierCurveTo(num cp1x, num cp1y, num cp2x, num cp2y, num x, num y); 219 void bezierCurveTo(num cp1x, num cp1y, num cp2x, num cp2y, num x, num y);
226 void arcTo(num x1, num y1, num x2, num y2, num radius); 220 void arcTo(num x1, num y1, num x2, num y2, num radius);
227 void rect(num x, num y, num w, num h); 221 void rect(num x, num y, num w, num h);
228 void arc(num x, num y, num radius, num startAngle, num endAngle, 222 void arc(num x, num y, num radius, num startAngle, num endAngle,
229 [bool anticlockwise]); 223 [bool anticlockwise]);
230 } 224 }
231 225
232 @JsName() 226 @js.JS()
233 abstract class CanvasGradient { 227 abstract class CanvasGradient {
234 // opaque object 228 // opaque object
235 void addColorStop(num offset, String color); 229 void addColorStop(num offset, String color);
236 } 230 }
237 231
238 @JsName() 232 @js.JS()
239 abstract class CanvasPattern { 233 abstract class CanvasPattern {
240 // opaque object 234 // opaque object
241 } 235 }
242 236
243 @JsName() 237 @js.JS()
244 abstract class TextMetrics { 238 abstract class TextMetrics {
245 num get width; 239 num get width;
246 } 240 }
247 241
248 @JsName() 242 @js.JS()
249 abstract class ImageData { 243 abstract class ImageData {
250 int get width; 244 int get width;
251 int get height; 245 int get height;
252 // TODO: readonly Uint8ClampedArray data; 246 // TODO: readonly Uint8ClampedArray data;
253 } 247 }
OLDNEW
« no previous file with comments | « test/codegen/expect/sunflower/sunflower.html ('k') | tool/input_sdk/lib/js/dart2js/js_dart2js.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698