summaryrefslogtreecommitdiffstats
path: root/ui/views/animation
diff options
context:
space:
mode:
authordanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-29 22:52:18 +0000
committerdanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-29 22:52:18 +0000
commitce112fe17067812a9014c6b10e041435aedf9998 (patch)
tree45e32fbd98173f5aae7bc2fd417d67d4461570f4 /ui/views/animation
parentaa1c70d3bc9449db2a3bfd02c15875aafb17caa5 (diff)
downloadchromium_src-ce112fe17067812a9014c6b10e041435aedf9998.zip
chromium_src-ce112fe17067812a9014c6b10e041435aedf9998.tar.gz
chromium_src-ce112fe17067812a9014c6b10e041435aedf9998.tar.bz2
Add non-member non-mutating methods for common gfx::Rect operations.
This adds non-member methods that return a new Rect (or RectF) object as their result instead of mutating an existing rect. We add: Rect gfx::IntersectRects(Rect, Rect) RectF gfx::IntersectRects(RectF, RectF) Rect gfx::UnionRects(Rect, Rect) RectF gfx::UnionRects(RectF, RectF) Rect gfx::SubtractRects(Rect, Rect) RectF gfx::SubtractRects(RectF, RectF) RectF gfx::ScaleRect(RectF, scale) RectF gfx::ScaleRect(RectF, x_scale, y_scale) In CL https://codereview.chromium.org/11110004/ we made all member methods of Rect (and RectF) mutate the existing object, so these methods are added for cases where we want the result to create a new object instead. BUG=147395 R=sky Review URL: https://codereview.chromium.org/11270042 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@164760 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views/animation')
-rw-r--r--ui/views/animation/bounds_animator.cc3
-rw-r--r--ui/views/animation/bounds_animator_unittest.cc4
2 files changed, 3 insertions, 4 deletions
diff --git a/ui/views/animation/bounds_animator.cc b/ui/views/animation/bounds_animator.cc
index 037b9d6..c064cc8 100644
--- a/ui/views/animation/bounds_animator.cc
+++ b/ui/views/animation/bounds_animator.cc
@@ -235,8 +235,7 @@ void BoundsAnimator::AnimationProgressed(const Animation* animation) {
gfx::Rect new_bounds =
animation->CurrentValueBetween(data.start_bounds, data.target_bounds);
if (new_bounds != view->bounds()) {
- gfx::Rect total_bounds = view->bounds();
- total_bounds.Union(new_bounds);
+ gfx::Rect total_bounds = gfx::UnionRects(new_bounds, view->bounds());
// Build up the region to repaint in repaint_bounds_. We'll do the repaint
// when all animations complete (in AnimationContainerProgressed).
diff --git a/ui/views/animation/bounds_animator_unittest.cc b/ui/views/animation/bounds_animator_unittest.cc
index 2dbfc48..c9431f8 100644
--- a/ui/views/animation/bounds_animator_unittest.cc
+++ b/ui/views/animation/bounds_animator_unittest.cc
@@ -129,8 +129,8 @@ TEST_F(BoundsAnimatorTest, AnimateViewTo) {
// The parent should have been told to repaint as the animation progressed.
// The resulting rect is the union of the original and target bounds.
- target_bounds.Union(initial_bounds);
- EXPECT_EQ(target_bounds, parent()->dirty_rect());
+ EXPECT_EQ(gfx::UnionRects(target_bounds, initial_bounds),
+ parent()->dirty_rect());
}
// Make sure an AnimationDelegate is deleted when canceled.