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() | |
vsm
2015/06/24 23:16:15
Do we need both this and the dom.dart under test/b
Jennifer Messerly
2015/06/25 20:11:27
unfortunately, yes. Our server won't follow "../"
| |
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 class CustomEvent { | |
42 external CustomEvent(String type, {detail, bubbles, cancelable}); | |
43 } | |
44 | |
45 @JsName() | |
46 abstract class Element extends Node { | |
47 void addEventListener(String type, EventListener callback, [bool capture]); | |
48 String textContent; | |
49 } | |
50 | |
51 @JsName() | |
52 abstract class HTMLElement extends Element { | |
53 String innerHTML; | |
54 HTMLCollection get children; | |
55 } | |
56 | |
57 @JsName() | |
58 abstract class Node { | |
59 bool hasChildNodes(); | |
60 NodeList get childNodes; | |
61 | |
62 Node insertBefore(Node node, [Node child]); | |
63 Node appendChild(Node node); | |
64 Node replaceChild(Node node, Node child); | |
65 Node removeChild(Node child); | |
66 } | |
67 | |
68 abstract class HTMLCollection { | |
69 int get length; | |
70 external Element operator [](num index); | |
71 } | |
39 | 72 |
40 @JsName() | 73 @JsName() |
41 class NodeList { | 74 class NodeList { |
42 external NodeList(); | 75 external NodeList(); |
43 external num get length; | 76 external num get length; |
44 external set length(num _); | 77 external set length(num _); |
45 external Node item(num index); | 78 external Node item(num index); |
46 | 79 |
47 external Node operator [](num index); | 80 external Node operator [](num index); |
48 external void operator []=(num index, Node); | 81 external void operator []=(num index, Node); |
49 } | 82 } |
50 | 83 |
51 typedef void EventListener(Event e); | 84 typedef void EventListener(Event e); |
52 | 85 |
53 @JsName() | 86 @JsName() |
54 abstract class Event {} | 87 abstract class Event {} |
55 | 88 |
89 // TODO(jmesserly): rename these | |
56 @JsName(name: 'HTMLInputElement') | 90 @JsName(name: 'HTMLInputElement') |
57 abstract class InputElement extends Element { | 91 abstract class InputElement extends HTMLElement { |
58 String value; | 92 String value; |
59 } | 93 } |
60 | 94 |
61 @JsName(name: 'HTMLCanvasElement') | 95 @JsName(name: 'HTMLCanvasElement') |
62 abstract class CanvasElement extends Element { | 96 abstract class CanvasElement extends HTMLElement { |
63 RenderingContext getContext(String contextId); | 97 RenderingContext getContext(String contextId); |
64 } | 98 } |
65 | 99 |
100 @JsName(name: 'HTMLDivElement') | |
101 abstract class DivElement extends HTMLElement { | |
102 RenderingContext getContext(String contextId); | |
103 } | |
104 | |
105 @JsName(name: 'HTMLScriptElement') | |
106 abstract class ScriptElement extends HTMLElement { | |
107 String type; | |
108 } | |
109 | |
110 | |
66 // TODO(jmesserly): union type of CanvasRenderingContext2D and | 111 // TODO(jmesserly): union type of CanvasRenderingContext2D and |
67 // WebGLRenderingContext | 112 // WebGLRenderingContext |
68 abstract class RenderingContext {} | 113 abstract class RenderingContext {} |
69 | 114 |
70 // http://www.w3.org/html/wg/drafts/2dcontext/html5_canvas_CR/ | 115 // http://www.w3.org/html/wg/drafts/2dcontext/html5_canvas_CR/ |
71 @JsName() | 116 @JsName() |
72 abstract class CanvasRenderingContext2D | 117 abstract class CanvasRenderingContext2D |
73 implements CanvasDrawingStyles, CanvasPathMethods, RenderingContext { | 118 implements CanvasDrawingStyles, CanvasPathMethods, RenderingContext { |
74 | 119 |
75 // back-reference to the canvas | 120 // back-reference to the canvas |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
199 abstract class TextMetrics { | 244 abstract class TextMetrics { |
200 num get width; | 245 num get width; |
201 } | 246 } |
202 | 247 |
203 @JsName() | 248 @JsName() |
204 abstract class ImageData { | 249 abstract class ImageData { |
205 int get width; | 250 int get width; |
206 int get height; | 251 int get height; |
207 // TODO: readonly Uint8ClampedArray data; | 252 // TODO: readonly Uint8ClampedArray data; |
208 } | 253 } |
OLD | NEW |