| 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 library dom; | 6 library dom; |
| 6 | 7 |
| 7 class JsType { | 8 |
| 8 /// The JavaScript constructor function name. | 9 class JsName { |
| 9 /// Used for construction and instanceof checks. | 10 /// The JavaScript name. |
| 11 /// Used for classes and libraries. |
| 10 /// 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 |
| 11 /// 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. |
| 12 final String name; | 14 final String name; |
| 13 const JsType({this.name}); | 15 const JsName({this.name}); |
| 14 } | |
| 15 class JsGlobal { | |
| 16 const JsGlobal(); | |
| 17 } | 16 } |
| 18 class Overload { | 17 class Overload { |
| 19 const Overload(); | 18 const Overload(); |
| 20 } | 19 } |
| 21 const overload = const Overload(); | 20 const overload = const Overload(); |
| 22 | 21 |
| 23 @JsGlobal() | 22 external Document get document; |
| 24 final Document document = null; | |
| 25 | 23 |
| 26 @JsType(name: 'Document') | 24 @JsName(name: 'Document') |
| 27 abstract class Document { | 25 abstract class Document { |
| 28 Element querySelector(String selector); | 26 Element querySelector(String selector); |
| 29 } | 27 } |
| 30 | 28 |
| 31 @JsType(name: 'Element') | 29 @JsName(name: 'Element') |
| 32 abstract class Element { | 30 abstract class Element { |
| 33 void addEventListener(String type, EventListener callback, [bool capture]); | 31 void addEventListener(String type, EventListener callback, [bool capture]); |
| 34 String textContent; | 32 String textContent; |
| 35 } | 33 } |
| 36 | 34 |
| 37 typedef void EventListener(Event e); | 35 typedef void EventListener(Event e); |
| 38 | 36 |
| 39 abstract class Event {} | 37 abstract class Event {} |
| 40 | 38 |
| 41 @JsType(name: 'HTMLInputElement') | 39 @JsName(name: 'HTMLInputElement') |
| 42 abstract class InputElement extends Element { | 40 abstract class InputElement extends Element { |
| 43 String value; | 41 String value; |
| 44 } | 42 } |
| 45 | 43 |
| 46 @JsType(name: 'HTMLCanvasElement') | 44 @JsName(name: 'HTMLCanvasElement') |
| 47 abstract class CanvasElement extends Element { | 45 abstract class CanvasElement extends Element { |
| 48 RenderingContext getContext(String contextId); | 46 RenderingContext getContext(String contextId); |
| 49 } | 47 } |
| 50 | 48 |
| 51 // TODO(jmesserly): union type of CanvasRenderingContext2D and | 49 // TODO(jmesserly): union type of CanvasRenderingContext2D and |
| 52 // WebGLRenderingContext | 50 // WebGLRenderingContext |
| 53 abstract class RenderingContext {} | 51 abstract class RenderingContext {} |
| 54 | 52 |
| 55 // http://www.w3.org/html/wg/drafts/2dcontext/html5_canvas_CR/ | 53 // http://www.w3.org/html/wg/drafts/2dcontext/html5_canvas_CR/ |
| 56 @JsType() | 54 @JsName() |
| 57 abstract class CanvasRenderingContext2D | 55 abstract class CanvasRenderingContext2D |
| 58 implements CanvasDrawingStyles, CanvasPathMethods, RenderingContext { | 56 implements CanvasDrawingStyles, CanvasPathMethods, RenderingContext { |
| 59 | 57 |
| 60 // back-reference to the canvas | 58 // back-reference to the canvas |
| 61 CanvasElement get canvas; | 59 CanvasElement get canvas; |
| 62 | 60 |
| 63 // state | 61 // state |
| 64 void save(); // push state on state stack | 62 void save(); // push state on state stack |
| 65 void restore(); // pop state stack and restore state | 63 void restore(); // pop state stack and restore state |
| 66 | 64 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 void moveTo(num x, num y); | 160 void moveTo(num x, num y); |
| 163 void lineTo(num x, num y); | 161 void lineTo(num x, num y); |
| 164 void quadraticCurveTo(num cpx, num cpy, num x, num y); | 162 void quadraticCurveTo(num cpx, num cpy, num x, num y); |
| 165 void bezierCurveTo(num cp1x, num cp1y, num cp2x, num cp2y, num x, num y); | 163 void bezierCurveTo(num cp1x, num cp1y, num cp2x, num cp2y, num x, num y); |
| 166 void arcTo(num x1, num y1, num x2, num y2, num radius); | 164 void arcTo(num x1, num y1, num x2, num y2, num radius); |
| 167 void rect(num x, num y, num w, num h); | 165 void rect(num x, num y, num w, num h); |
| 168 void arc(num x, num y, num radius, num startAngle, num endAngle, | 166 void arc(num x, num y, num radius, num startAngle, num endAngle, |
| 169 [bool anticlockwise]); | 167 [bool anticlockwise]); |
| 170 } | 168 } |
| 171 | 169 |
| 172 @JsType() | 170 @JsName() |
| 173 abstract class CanvasGradient { | 171 abstract class CanvasGradient { |
| 174 // opaque object | 172 // opaque object |
| 175 void addColorStop(num offset, String color); | 173 void addColorStop(num offset, String color); |
| 176 } | 174 } |
| 177 | 175 |
| 178 @JsType() | 176 @JsName() |
| 179 abstract class CanvasPattern { | 177 abstract class CanvasPattern { |
| 180 // opaque object | 178 // opaque object |
| 181 } | 179 } |
| 182 | 180 |
| 183 @JsType() | 181 @JsName() |
| 184 abstract class TextMetrics { | 182 abstract class TextMetrics { |
| 185 num get width; | 183 num get width; |
| 186 } | 184 } |
| 187 | 185 |
| 188 @JsType() | 186 @JsName() |
| 189 abstract class ImageData { | 187 abstract class ImageData { |
| 190 int get width; | 188 int get width; |
| 191 int get height; | 189 int get height; |
| 192 // TODO: readonly Uint8ClampedArray data; | 190 // TODO: readonly Uint8ClampedArray data; |
| 193 } | 191 } |
| OLD | NEW |