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

Side by Side Diff: tools/dom/src/Rectangle.dart

Issue 18034021: Fixing analyzer warnings on overloading == but not get hashCode. (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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 part of html; 5 part of html;
6 6
7 /** 7 /**
8 * A class for representing two-dimensional rectangles. 8 * A class for representing two-dimensional rectangles.
9 */ 9 */
10 class Rect { 10 class Rect {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 String toString() { 47 String toString() {
48 return '($left, $top, $width, $height)'; 48 return '($left, $top, $width, $height)';
49 } 49 }
50 50
51 bool operator ==(other) { 51 bool operator ==(other) {
52 if (other is !Rect) return false; 52 if (other is !Rect) return false;
53 return left == other.left && top == other.top && width == other.width && 53 return left == other.left && top == other.top && width == other.width &&
54 height == other.height; 54 height == other.height;
55 } 55 }
56 56
57 int get hashCode => JenkinsSmiHash.hash4(left.hashCode, top.hashCode,
58 width.hashCode, height.hashCode);
59
57 /** 60 /**
58 * Computes the intersection of this rectangle and the rectangle parameter. 61 * Computes the intersection of this rectangle and the rectangle parameter.
59 * Returns null if there is no intersection. 62 * Returns null if there is no intersection.
60 */ 63 */
61 Rect intersection(Rect rect) { 64 Rect intersection(Rect rect) {
62 var x0 = max(left, rect.left); 65 var x0 = max(left, rect.left);
63 var x1 = min(left + width, rect.left + rect.width); 66 var x1 = min(left + width, rect.left + rect.width);
64 67
65 if (x0 <= x1) { 68 if (x0 <= x1) {
66 var y0 = max(top, rect.top); 69 var y0 = max(top, rect.top);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 * Truncates coordinates to integers and returns the result as a new 129 * Truncates coordinates to integers and returns the result as a new
127 * rectangle. 130 * rectangle.
128 */ 131 */
129 Rect toInt() => new Rect(left.toInt(), top.toInt(), width.toInt(), 132 Rect toInt() => new Rect(left.toInt(), top.toInt(), width.toInt(),
130 height.toInt()); 133 height.toInt());
131 134
132 Point get topLeft => new Point(this.left, this.top); 135 Point get topLeft => new Point(this.left, this.top);
133 Point get bottomRight => new Point(this.left + this.width, 136 Point get bottomRight => new Point(this.left + this.width,
134 this.top + this.height); 137 this.top + this.height);
135 } 138 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698