Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Unified Diff: tools/dom/src/Rectangle.dart

Issue 19520019: Reverting 25196, 25195, 25192. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/dom/src/Dimension.dart ('k') | tools/dom/templates/html/dart2js/html_dart2js.darttemplate » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/dom/src/Rectangle.dart
diff --git a/tools/dom/src/Rectangle.dart b/tools/dom/src/Rectangle.dart
index b2adb806437e6da8a3ec54aecde3ada2788d6580..e6a80b2f0edc67caa2607040ede9ad3f7d5653c8 100644
--- a/tools/dom/src/Rectangle.dart
+++ b/tools/dom/src/Rectangle.dart
@@ -5,20 +5,44 @@
part of html;
/**
- * A base class for representing two-dimensional rectangles. This will hopefully
- * be moved merged with the dart:math Rect.
+ * A class for representing two-dimensional rectangles.
*/
-// TODO(efortuna): Merge with Math rect after finalizing with Florian.
-abstract class RectBase {
- num get left;
- num get top;
- num get width;
- num get height;
+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);
+ }
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)';
@@ -112,43 +136,3 @@ abstract class RectBase {
Point get bottomRight => new Point(this.left + this.width,
this.top + this.height);
}
-
-
-
-/**
- * A class for representing two-dimensional rectangles.
- *
- * This class is distinctive from RectBase in that it enforces that its
- * properties are immutable.
- */
-class Rect extends RectBase {
Jennifer Messerly 2013/07/19 02:22:59 The fix might be to use a mixin: "extends Object w
- 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);
- }
-}
« no previous file with comments | « tools/dom/src/Dimension.dart ('k') | tools/dom/templates/html/dart2js/html_dart2js.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698