Chromium Code Reviews| Index: chrome/browser/ui/views/dropdown_bar_host.cc |
| =================================================================== |
| --- chrome/browser/ui/views/dropdown_bar_host.cc (revision 84320) |
| +++ chrome/browser/ui/views/dropdown_bar_host.cc (working copy) |
| @@ -7,6 +7,7 @@ |
| #include <algorithm> |
| #include "chrome/browser/ui/view_ids.h" |
| +#include "chrome/browser/ui/views/dropdown_bar_host_delegate.h" |
| #include "chrome/browser/ui/views/dropdown_bar_view.h" |
| #include "chrome/browser/ui/views/frame/browser_view.h" |
| #include "ui/base/animation/slide_animation.h" |
| @@ -44,14 +45,20 @@ |
| DropdownBarHost::DropdownBarHost(BrowserView* browser_view) |
| : browser_view_(browser_view), |
| view_(NULL), |
| + delegate_(NULL), |
| animation_offset_(0), |
| focus_manager_(NULL), |
| esc_accel_target_registered_(false), |
| is_visible_(false) { |
| } |
| -void DropdownBarHost::Init(DropdownBarView* view) { |
| +void DropdownBarHost::Init(views::View* view, |
| + DropdownBarHostDelegate* delegate) { |
| + DCHECK(view); |
| + DCHECK(delegate); |
| + |
| view_ = view; |
| + delegate_ = delegate; |
| // Initialize the host. |
| host_.reset(views::Widget::CreateWidget()); |
| @@ -102,7 +109,7 @@ |
| } |
| void DropdownBarHost::SetFocusAndSelection() { |
| - view_->SetFocusAndSelection(true); |
| + delegate_->SetFocusAndSelection(true); |
| } |
| bool DropdownBarHost::IsAnimating() const { |
| @@ -113,12 +120,24 @@ |
| if (!IsVisible()) |
| return; |
| if (animate && !disable_animations_during_testing_) { |
| - animation_->Reset(1.0); |
| - animation_->Hide(); |
| + if (!animation_->IsClosing()) { |
|
sky
2011/05/09 14:27:22
Do you really need the if?
SteveT
2011/05/09 19:40:04
No - removed.
|
| + animation_->Hide(); |
| + } |
| } else { |
| - StopAnimation(); |
| - is_visible_ = false; |
| - host_->Hide(); |
| + if (animation_->IsClosing()) { |
| + // If we're in the middle of a close animation, skip immediately to the |
| + // end of the animation. |
| + StopAnimation(); |
| + } else { |
| + // Otherwise we need to set both the animation state to ended and the |
| + // DropdownBarHost state to ended/hidden, otherwise the next time we try |
| + // to show the bar, it might refuse to do so. Note that we call |
| + // AnimationEnded ourselves as Reset does not call it if we are not |
| + // animating here. |
| + animation_->Reset(); |
| + animation_->Hide(); |
|
sky
2011/05/09 14:27:22
I don't think you need the hide here.
SteveT
2011/05/09 19:40:04
Yes - The reset will put animation_ back in the co
|
| + AnimationEnded(animation_.get()); |
| + } |
| } |
| } |
| @@ -171,7 +190,7 @@ |
| // Let the view know if we are animating, and at which offset to draw the |
| // edges. |
| - view_->set_animation_offset(animation_offset_); |
| + delegate_->SetAnimationOffset(animation_offset_); |
| view_->SchedulePaint(); |
| } |