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

Unified Diff: sky/engine/core/painting/Offset.dart

Issue 1209413004: Instead of applying a transform for every RenderObject, pass down an Offset for where to paint. (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sky/engine/core/painting/Rect.dart » ('j') | sky/sdk/lib/rendering/box.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/engine/core/painting/Offset.dart
diff --git a/sky/engine/core/painting/Offset.dart b/sky/engine/core/painting/Offset.dart
index 161bd754c5ca2637d09219f4bb6eea5fb4ab1cf9..13e458882e9090e44dc9bf333112a41da45cc599 100644
--- a/sky/engine/core/painting/Offset.dart
+++ b/sky/engine/core/painting/Offset.dart
@@ -20,7 +20,13 @@ class Offset extends OffsetBase {
Offset operator -() => new Offset(-dx, -dy);
Offset operator -(Offset other) => new Offset(dx - other.dx, dy - other.dy);
- Offset operator +(Offset other) => new Offset(dx + other.dx, dy + other.dy);
+ dynamic operator +(dynamic other) {
+ if (other is Offset)
+ return new Offset(dx + other.dx, dy + other.dy);
+ if (other is Size)
+ return new Rect.fromLTWH(dx, dy, other.width, other.height);
abarth-chromium 2015/06/27 00:39:37 Wow, an offset + a size is a rect? Crazy.
+ throw new ArgumentError(other);
+ }
// does the equivalent of "return new Point(0,0) + this"
Point toPoint() => new Point(this.dx, this.dy);
« no previous file with comments | « no previous file | sky/engine/core/painting/Rect.dart » ('j') | sky/sdk/lib/rendering/box.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698