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

Side by Side Diff: chrome/browser/ui/panels/panel_bounds_animation.cc

Issue 9117007: Avoid divide by zero when animating panel bounds. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "chrome/browser/ui/panels/panel_bounds_animation.h" 5 #include "chrome/browser/ui/panels/panel_bounds_animation.h"
6 6
7 #include "chrome/browser/ui/panels/panel.h" 7 #include "chrome/browser/ui/panels/panel.h"
8 #include "chrome/browser/ui/panels/panel_manager.h" 8 #include "chrome/browser/ui/panels/panel_manager.h"
9 9
10 namespace { 10 namespace {
(...skipping 11 matching lines...) Expand all
22 const gfx::Rect& final_bounds) 22 const gfx::Rect& final_bounds)
23 : ui::LinearAnimation(kDefaultFramerateHz, target), 23 : ui::LinearAnimation(kDefaultFramerateHz, target),
24 panel_(panel), 24 panel_(panel),
25 for_big_minimize_(false), 25 for_big_minimize_(false),
26 animation_stop_to_show_titlebar_(0) { 26 animation_stop_to_show_titlebar_(0) {
27 // Detect animation that happens when expansion state is set to MINIMIZED 27 // Detect animation that happens when expansion state is set to MINIMIZED
28 // and there is relatively big portion of the panel to hide from view. 28 // and there is relatively big portion of the panel to hide from view.
29 // Initialize animation differently in this case, using fast-pause-slow 29 // Initialize animation differently in this case, using fast-pause-slow
30 // method, see below for more details. 30 // method, see below for more details.
31 int duration = kSetBoundsAnimationMs; 31 int duration = kSetBoundsAnimationMs;
32 if (panel_->expansion_state() == Panel::MINIMIZED) { 32 if (initial_bounds.height() > final_bounds.height() &&
33 panel_->expansion_state() == Panel::MINIMIZED) {
33 double hidden_title_height = 34 double hidden_title_height =
34 panel_->TitleOnlyHeight() - final_bounds.height(); 35 panel_->TitleOnlyHeight() - final_bounds.height();
35 double distance_y = initial_bounds.height() - final_bounds.height(); 36 double distance_y = initial_bounds.height() - final_bounds.height();
36 animation_stop_to_show_titlebar_ = 1.0 - hidden_title_height / distance_y; 37 animation_stop_to_show_titlebar_ = 1.0 - hidden_title_height / distance_y;
37 if (animation_stop_to_show_titlebar_ > 0.7) { // Relatively big movement. 38 if (animation_stop_to_show_titlebar_ > 0.7) { // Relatively big movement.
38 for_big_minimize_ = true; 39 for_big_minimize_ = true;
39 duration = kSetBoundsAnimationBigMinimizeMs; 40 duration = kSetBoundsAnimationBigMinimizeMs;
40 } 41 }
41 } 42 }
42 SetDuration(PanelManager::AdjustTimeInterval(duration)); 43 SetDuration(PanelManager::AdjustTimeInterval(duration));
(...skipping 28 matching lines...) Expand all
71 (progress / kProgressAtFreezeStart); 72 (progress / kProgressAtFreezeStart);
72 } else if (progress <= kProgressAtFreezeEnd) { 73 } else if (progress <= kProgressAtFreezeEnd) {
73 value = animation_stop_to_show_titlebar; 74 value = animation_stop_to_show_titlebar;
74 } else { 75 } else {
75 value = animation_stop_to_show_titlebar + 76 value = animation_stop_to_show_titlebar +
76 (1.0 - animation_stop_to_show_titlebar) * 77 (1.0 - animation_stop_to_show_titlebar) *
77 ((progress - kProgressAtFreezeEnd) / (1.0 - kProgressAtFreezeEnd)); 78 ((progress - kProgressAtFreezeEnd) / (1.0 - kProgressAtFreezeEnd));
78 } 79 }
79 return value; 80 return value;
80 } 81 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698