Chromium Code Reviews| Index: tools/dom/src/Rectangle.dart |
| diff --git a/tools/dom/src/Rectangle.dart b/tools/dom/src/Rectangle.dart |
| index e87da1146b7cc1434b0a1a6569057750537ded52..13e412edbb35d14df4111e292c22c62374ec0225 100644 |
| --- a/tools/dom/src/Rectangle.dart |
| +++ b/tools/dom/src/Rectangle.dart |
| @@ -5,44 +5,20 @@ |
| part of html; |
| /** |
| - * A class for representing two-dimensional rectangles. |
| + * A base class for representing two-dimensional rectangles. This will hopefully |
| + * be moved merged with the dart:math Rect. |
| */ |
| -class Rect { |
| - final num left; |
| - final num top; |
| - final num width; |
| - final num height; |
| - |
| - const Rect(this.left, this.top, this.width, this.height); |
| - |
| - factory Rect.fromPoints(Point a, Point b) { |
| - var left; |
| - var width; |
| - if (a.x < b.x) { |
| - left = a.x; |
| - width = b.x - left; |
| - } else { |
| - left = b.x; |
| - width = a.x - left; |
| - } |
| - var top; |
| - var height; |
| - if (a.y < b.y) { |
| - top = a.y; |
| - height = b.y - top; |
| - } else { |
| - top = b.y; |
| - height = a.y - top; |
| - } |
| - |
| - return new Rect(left, top, width, height); |
| - } |
| +// TODO(efortuna): Merge with Math rect after finalizing with Florian. |
|
Jacob
2013/05/22 02:09:51
Why can't we just get the full class in Math.rect?
Emily Fortuna
2013/07/10 21:40:16
You're right. And that's why the TODO is here. I'm
|
| +abstract class RectBase { |
| + num get left; |
| + num get top; |
| + num get width; |
| + num get height; |
| num get right => left + width; |
| num get bottom => top + height; |
| // NOTE! All code below should be common with Rect. |
| - // TODO: implement with mixins when available. |
| String toString() { |
| return '($left, $top, $width, $height)'; |
| @@ -133,3 +109,40 @@ class Rect { |
| Point get bottomRight => new Point(this.left + this.width, |
| this.top + this.height); |
| } |
| + |
| + |
| + |
| +/** |
| + * A class for representing two-dimensional rectangles. |
| + */ |
| +class Rect extends RectBase { |
| + final num left; |
| + final num top; |
| + final num width; |
| + final num height; |
| + |
| + const Rect(this.left, this.top, this.width, this.height); |
| + |
| + factory Rect.fromPoints(Point a, Point b) { |
| + var left; |
| + var width; |
| + if (a.x < b.x) { |
| + left = a.x; |
| + width = b.x - left; |
| + } else { |
| + left = b.x; |
| + width = a.x - left; |
| + } |
| + var top; |
| + var height; |
| + if (a.y < b.y) { |
| + top = a.y; |
| + height = b.y - top; |
| + } else { |
| + top = b.y; |
| + height = a.y - top; |
| + } |
| + |
| + return new Rect(left, top, width, height); |
| + } |
| +} |