Chromium Code Reviews| Index: sdk/lib/html/dart2js/html_dart2js.dart |
| diff --git a/sdk/lib/html/dart2js/html_dart2js.dart b/sdk/lib/html/dart2js/html_dart2js.dart |
| index 56a83e4184c015293f5427ff846a091017c28b55..f8c6e49422973a318093876ef9636baaa683b956 100644 |
| --- a/sdk/lib/html/dart2js/html_dart2js.dart |
| +++ b/sdk/lib/html/dart2js/html_dart2js.dart |
| @@ -18889,31 +18889,6 @@ class RangeException native "*RangeException" { |
| // for details. All rights reserved. Use of this source code is governed by a |
| // BSD-style license that can be found in the LICENSE file. |
| - |
| -@DocsEditable |
| -@DomName('Rect') |
| -class Rect native "*Rect" { |
|
blois
2013/03/05 02:08:51
Ignore removal of this for now- this is being rena
|
| - |
| - @DomName('Rect.bottom') |
| - @DocsEditable |
| - final CssPrimitiveValue bottom; |
| - |
| - @DomName('Rect.left') |
| - @DocsEditable |
| - final CssPrimitiveValue left; |
| - |
| - @DomName('Rect.right') |
| - @DocsEditable |
| - final CssPrimitiveValue right; |
| - |
| - @DomName('Rect.top') |
| - @DocsEditable |
| - final CssPrimitiveValue top; |
| -} |
| -// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| -// for details. All rights reserved. Use of this source code is governed by a |
| -// BSD-style license that can be found in the LICENSE file. |
| - |
| // WARNING: Do not edit - generated code. |
| @@ -31091,6 +31066,69 @@ abstract class KeyName { |
| */ |
| static const String UNIDENTIFIED = "Unidentified"; |
| } |
| +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| + |
| +/// A utility class for representing two-dimensional positions. |
| +class Point { |
| + final num x; |
| + final num y; |
| + |
| + Point([num x = 0, num y = 0]): x = x, y = y; |
| + |
| + String toString() { |
| + return '($x, $y)'; |
| + } |
| + |
| + bool operator ==(other) { |
| + if (other is !Point) return false; |
| + return x == other.x && y == other.y; |
| + } |
| + |
| + Point operator +(Point other) { |
| + return new Point(x + other.x, y + other.y); |
| + } |
| + |
| + Point operator -(Point other) { |
| + return new Point(x - other.x, y - other.y); |
| + } |
| + |
| + Point operator *(num factor) { |
| + return new Point(x * factor, y * factor); |
| + } |
| + |
| + /** |
| + * Returns the distance between two points. |
| + */ |
| + double distanceTo(Point other) { |
| + var dx = x - other.x; |
| + var dy = y - other.y; |
| + return sqrt(dx * dx + dy * dy); |
| + } |
| + |
| + /** |
| + * Returns the squared distance between two points. |
| + * |
| + * Squared distances can be used for comparisons when the actual value is not |
| + * required. |
| + */ |
| + num squaredDistanceTo(Point other) { |
| + var dx = x - other.x; |
| + var dy = y - other.y; |
| + return dx * dx + dy * dy; |
| + } |
| + |
| + Point ceil() => new Point(x.ceil(), y.ceil()); |
| + Point floor() => new Point(x.floor(), y.floor()); |
| + Point round() => new Point(x.round(), y.round()); |
| + |
| + /** |
| + * Truncates x and y to integers and returns the result as a new point. |
| + */ |
| + Point toInt() => new Point(x.toInt(), y.toInt()); |
| +} |
| // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| // for details. All rights reserved. Use of this source code is governed by a |
| // BSD-style license that can be found in the LICENSE file. |
| @@ -31116,6 +31154,141 @@ abstract class ReadyState { |
| */ |
| static const String COMPLETE = "complete"; |
| } |
| +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| + |
| +/** |
| + * A utility class for representing rectangles. |
| + */ |
| +class Rect { |
| + final num left; |
| + final num top; |
| + final num width; |
| + final num height; |
| + |
| + Rect(this.left, this.top, this.width, this.height) { |
| + if (width < 0) { |
| + throw ArgumentError(width); |
| + } |
| + if (height < 0) { |
| + throw ArgumentError(height); |
| + } |
| + } |
| + |
| + factory Rect.fromCorners(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); |
| + } |
| + |
| + String toString() { |
| + return '($left, $top, $width, $height)'; |
| + } |
| + |
| + bool operator ==(other) { |
| + if (other is !Rect) return false; |
| + return left == other.left && top == other.top && width == other.width && |
| + height == other.height; |
| + } |
| + |
| + /** |
| + * Computes the intersection of this rectangle and the rectangle parameter. |
| + * Returns null if there is no intersection |
| + */ |
| + Rect intersection(Rect rect) { |
| + var x0 = max(left, rect.left); |
| + var x1 = min(left + width, rect.left + rect.width); |
| + |
| + if (x0 <= x1) { |
| + var y0 = max(top, rect.top); |
| + var y1 = min(top + height, rect.top + rect.height); |
| + |
| + if (y0 <= y1) { |
| + return new Rect(x0, y0, x1 - x0, y1 - y0); |
| + } |
| + } |
| + return null; |
| + } |
| + |
| + |
| + /** |
| + * Returns whether a rectangle intersects this rectangle. |
| + */ |
| + bool intersects(Rect other) { |
| + return (left <= other.left + other.width && other.left <= left + width && |
| + top <= other.top + other.height && other.top <= top + height); |
| + } |
| + |
| + /** |
| + * Returns a new rectangle which completely contains this rectangle and the |
| + * input rectangle. |
| + */ |
| + Rect union(Rect rect) { |
| + var right = max(this.left + this.width, rect.left + rect.width); |
| + var bottom = max(this.top + this.height, rect.top + rect.height); |
| + |
| + var left = min(this.left, rect.left); |
| + var top = min(this.top, rect.top); |
| + |
| + return new Rect(left, top, right - left, bottom - top); |
| + } |
| + |
| + /** |
| + * Tests whether this rectangle entirely contains another rectangle. |
| + */ |
| + bool containsRect(Rect another) { |
| + return left <= another.left && |
| + left + width >= another.left + another.width && |
| + top <= another.top && |
| + top + height >= another.top + another.height; |
| + } |
| + |
| + /** |
| + * Tests whether this rectangle entirely contains a point. |
| + */ |
| + bool containsPoint(Point another) { |
| + return another.x >= left && |
| + another.x <= left + width && |
| + another.y >= top && |
| + another.y <= top + height; |
| + } |
| + |
| + Rect ceil() => new Rect(left.ceil(), top.ceil(), width.ceil(), height.ceil()); |
| + Rect floor() => new Rect(left.floor(), top.floor(), width.floor(), |
| + height.floor()); |
| + Rect round() => new Rect(left.round(), top.round(), width.round(), |
| + height.round()); |
| + |
| + /** |
| + * Truncates coordinates to integers and returns the result as a new |
| + * rectangle. |
| + */ |
| + Rect toInt() => new Rect(left.toInt(), top.toInt(), width.toInt(), |
| + height.toInt()); |
| + |
| + Point get topLeft => new Point(this.left, this.top); |
| + Point get bottomRight => new Point(this.left + this.width, |
| + this.top + this.height); |
| +} |
| // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| // for details. All rights reserved. Use of this source code is governed by a |
| // BSD-style license that can be found in the LICENSE file. |