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 @JsName() |
| 9 class Window {} |
8 | 10 |
9 class JsName { | 11 class JsName { |
10 /// The JavaScript name. | 12 /// The JavaScript name. |
11 /// Used for classes and libraries. | 13 /// Used for classes and libraries. |
12 /// Note that this could be an expression, e.g. `lib.TypeName` in JS, but it | 14 /// 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. | 15 /// should be kept simple, as it will be generated directly into the code. |
14 final String name; | 16 final String name; |
15 const JsName({this.name}); | 17 const JsName({this.name}); |
16 } | 18 } |
17 class Overload { | 19 class Overload { |
18 const Overload(); | 20 const Overload(); |
19 } | 21 } |
20 const overload = const Overload(); | 22 const overload = const Overload(); |
21 | 23 |
22 external Document get document; | 24 external Document get document; |
| 25 external Window get window; |
23 | 26 |
24 @JsName(name: 'Document') | 27 @JsName() |
25 abstract class Document { | 28 abstract class Document extends Node { |
26 Element createElement(String name); | 29 Element createElement(String name); |
27 Element querySelector(String selector); | 30 Element querySelector(String selector); |
28 } | |
29 | 31 |
30 @JsName(name: 'Element') | 32 HTMLElement head; |
31 abstract class Element { | 33 HTMLElement body; |
32 void addEventListener(String type, EventListener callback, [bool capture]); | |
33 String textContent; | |
34 NodeList get childNodes; | |
35 } | 34 } |
36 | 35 |
37 @JsName() | 36 @JsName() |
38 class Node {} | 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 } |
39 | 74 |
40 @JsName() | 75 @JsName() |
41 class NodeList { | 76 class NodeList { |
42 external NodeList(); | 77 external NodeList(); |
43 external num get length; | 78 external num get length; |
44 external set length(num _); | 79 external set length(num _); |
45 external Node item(num index); | 80 external Node item(num index); |
46 | 81 |
47 external Node operator [](num index); | 82 external Node operator [](num index); |
48 external void operator []=(num index, Node); | 83 external void operator []=(num index, Node); |
49 } | 84 } |
50 | 85 |
51 typedef void EventListener(Event e); | 86 typedef void EventListener(Event e); |
52 | 87 |
53 @JsName() | 88 @JsName() |
54 abstract class Event {} | 89 abstract class Event {} |
55 | 90 |
| 91 // TODO(jmesserly): rename these |
56 @JsName(name: 'HTMLInputElement') | 92 @JsName(name: 'HTMLInputElement') |
57 abstract class InputElement extends Element { | 93 abstract class InputElement extends HTMLElement { |
58 String value; | 94 String value; |
59 } | 95 } |
60 | 96 |
61 @JsName(name: 'HTMLCanvasElement') | 97 @JsName(name: 'HTMLCanvasElement') |
62 abstract class CanvasElement extends Element { | 98 abstract class CanvasElement extends HTMLElement { |
63 RenderingContext getContext(String contextId); | 99 RenderingContext getContext(String contextId); |
64 } | 100 } |
65 | 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 |
66 // TODO(jmesserly): union type of CanvasRenderingContext2D and | 113 // TODO(jmesserly): union type of CanvasRenderingContext2D and |
67 // WebGLRenderingContext | 114 // WebGLRenderingContext |
68 abstract class RenderingContext {} | 115 abstract class RenderingContext {} |
69 | 116 |
70 // http://www.w3.org/html/wg/drafts/2dcontext/html5_canvas_CR/ | 117 // http://www.w3.org/html/wg/drafts/2dcontext/html5_canvas_CR/ |
71 @JsName() | 118 @JsName() |
72 abstract class CanvasRenderingContext2D | 119 abstract class CanvasRenderingContext2D |
73 implements CanvasDrawingStyles, CanvasPathMethods, RenderingContext { | 120 implements CanvasDrawingStyles, CanvasPathMethods, RenderingContext { |
74 | 121 |
75 // back-reference to the canvas | 122 // back-reference to the canvas |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 abstract class TextMetrics { | 246 abstract class TextMetrics { |
200 num get width; | 247 num get width; |
201 } | 248 } |
202 | 249 |
203 @JsName() | 250 @JsName() |
204 abstract class ImageData { | 251 abstract class ImageData { |
205 int get width; | 252 int get width; |
206 int get height; | 253 int get height; |
207 // TODO: readonly Uint8ClampedArray data; | 254 // TODO: readonly Uint8ClampedArray data; |
208 } | 255 } |
OLD | NEW |