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

Side by Side Diff: sky/engine/core/painting/Size.dart

Issue 1213473003: Add asserts to catch potential misuses of the rendering framework. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « no previous file | sky/examples/rendering/sector_layout.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 part of dart.sky; 5 part of dart.sky;
6 6
7 /// Holds a 2D floating-point size. 7 /// Holds a 2D floating-point size.
8 /// Think of this as a vector from Point(0,0) to Point(size.width, size.height) 8 /// Think of this as a vector from Point(0,0) to Point(size.width, size.height)
9 class Size { 9 class Size {
10 const Size(this.width, this.height); 10 const Size(this.width, this.height);
11 Size.copy(Size source) : width = source.width, height = source.height; 11 Size.copy(Size source) : width = source.width, height = source.height;
12 const Size.fromWidth(this.width) : height = double.INFINITY; 12 const Size.fromWidth(this.width) : height = double.INFINITY;
13 const Size.fromHeight(this.height) : width = double.INFINITY; 13 const Size.fromHeight(this.height) : width = double.INFINITY;
14 14
15 final double width; 15 final double width;
16 final double height; 16 final double height;
17 17
18 static const Size zero = const Size(0.0, 0.0); 18 static const Size zero = const Size(0.0, 0.0);
19 static const Size infinite = const Size(double.INFINITY, double.INFINITY); 19 static const Size infinite = const Size(double.INFINITY, double.INFINITY);
20 20
21 bool operator ==(other) => other is Size && width == other.width && height == other.height; 21 bool operator ==(other) => other is Size && width == other.width && height == other.height;
22 Size operator +(Size other) => new Size(width + other.width, height + other.he ight); 22 Size operator +(Size other) => new Size(width + other.width, height + other.he ight);
23 Size operator -(Size other) => new Size(width - other.width, height - other.he ight); 23 Size operator -(Size other) => new Size(width - other.width, height - other.he ight);
24 24
25 bool get isInfinite => width >= double.INFINITY || height >= double.INFINITY;
26
25 // does the equivalent of "return new Point(0,0) + this" 27 // does the equivalent of "return new Point(0,0) + this"
26 Point toPoint() => new Point(this.width, this.height); 28 Point toPoint() => new Point(this.width, this.height);
27 29
28 int get hashCode { 30 int get hashCode {
29 int result = 373; 31 int result = 373;
30 result = 37 * result + width.hashCode; 32 result = 37 * result + width.hashCode;
31 result = 37 * result + height.hashCode; 33 result = 37 * result + height.hashCode;
32 return result; 34 return result;
33 } 35 }
34 String toString() => "Size($width, $height)"; 36 String toString() => "Size($width, $height)";
35 } 37 }
OLDNEW
« no previous file with comments | « no previous file | sky/examples/rendering/sector_layout.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698