OLD | NEW |
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 @JsName(name: 'window') |
6 library dom; | 6 library dom; |
7 | 7 |
8 | 8 |
9 class JsName { | 9 class JsName { |
10 /// The JavaScript name. | 10 /// The JavaScript name. |
11 /// Used for classes and libraries. | 11 /// Used for classes and libraries. |
12 /// Note that this could be an expression, e.g. `lib.TypeName` in JS, but it | 12 /// Note that this could be an expression, e.g. `lib.TypeName` in JS, but it |
13 /// should be kept simple, as it will be generated directly into the code. | 13 /// should be kept simple, as it will be generated directly into the code. |
14 final String name; | 14 final String name; |
15 const JsName({this.name}); | 15 const JsName({this.name}); |
16 } | 16 } |
17 class Overload { | 17 class Overload { |
18 const Overload(); | 18 const Overload(); |
19 } | 19 } |
20 const overload = const Overload(); | 20 const overload = const Overload(); |
21 | 21 |
22 class JsIndexer { | |
23 const JsIndexer(); | |
24 } | |
25 | |
26 external Document get document; | 22 external Document get document; |
27 | 23 |
28 @JsName(name: 'Document') | 24 @JsName(name: 'Document') |
29 abstract class Document { | 25 abstract class Document { |
30 Element querySelector(String selector); | 26 Element querySelector(String selector); |
31 } | 27 } |
32 | 28 |
33 @JsName(name: 'Element') | 29 @JsName(name: 'Element') |
34 abstract class Element { | 30 abstract class Element { |
35 void addEventListener(String type, EventListener callback, [bool capture]); | 31 void addEventListener(String type, EventListener callback, [bool capture]); |
36 String textContent; | 32 String textContent; |
37 NodeList get childNodes; | |
38 } | |
39 | |
40 @JsName() | |
41 class Node {} | |
42 | |
43 @JsName() | |
44 @JsIndexer() | |
45 class NodeList { | |
46 external NodeList(); | |
47 external num get length; | |
48 external set length(num _); | |
49 external Node item(num index); | |
50 | |
51 external Node operator [](num index); | |
52 external void operator []=(num index, Node); | |
53 } | 33 } |
54 | 34 |
55 typedef void EventListener(Event e); | 35 typedef void EventListener(Event e); |
56 | 36 |
57 @JsName() | |
58 abstract class Event {} | 37 abstract class Event {} |
59 | 38 |
60 @JsName(name: 'HTMLInputElement') | 39 @JsName(name: 'HTMLInputElement') |
61 abstract class InputElement extends Element { | 40 abstract class InputElement extends Element { |
62 String value; | 41 String value; |
63 } | 42 } |
64 | 43 |
65 @JsName(name: 'HTMLCanvasElement') | 44 @JsName(name: 'HTMLCanvasElement') |
66 abstract class CanvasElement extends Element { | 45 abstract class CanvasElement extends Element { |
67 RenderingContext getContext(String contextId); | 46 RenderingContext getContext(String contextId); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 abstract class TextMetrics { | 182 abstract class TextMetrics { |
204 num get width; | 183 num get width; |
205 } | 184 } |
206 | 185 |
207 @JsName() | 186 @JsName() |
208 abstract class ImageData { | 187 abstract class ImageData { |
209 int get width; | 188 int get width; |
210 int get height; | 189 int get height; |
211 // TODO: readonly Uint8ClampedArray data; | 190 // TODO: readonly Uint8ClampedArray data; |
212 } | 191 } |
OLD | NEW |