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

Unified Diff: chrome/browser/ui/views/location_bar/zoom_view.cc

Issue 420533002: zoom bubble: Close if anchor is clicked while bubble is showing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: asdf Created 6 years, 5 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
Index: chrome/browser/ui/views/location_bar/zoom_view.cc
diff --git a/chrome/browser/ui/views/location_bar/zoom_view.cc b/chrome/browser/ui/views/location_bar/zoom_view.cc
index 0ab6b72f98a4483e0beb796e085308a4726532af..4e9d6ad97af56f80c808d1d5b6a0c28099178916 100644
--- a/chrome/browser/ui/views/location_bar/zoom_view.cc
+++ b/chrome/browser/ui/views/location_bar/zoom_view.cc
@@ -17,7 +17,8 @@
#include "ui/gfx/size.h"
ZoomView::ZoomView(LocationBarView::Delegate* location_bar_delegate)
- : location_bar_delegate_(location_bar_delegate) {
+ : location_bar_delegate_(location_bar_delegate),
+ was_bubble_showing_(false) {
SetAccessibilityFocusable(true);
Update(NULL);
}
@@ -52,13 +53,23 @@ bool ZoomView::GetTooltipText(const gfx::Point& p,
}
bool ZoomView::OnMousePressed(const ui::MouseEvent& event) {
+ // The Zoom bubble has its own widget. By the time this code is reached, it's
+ // already lost activation and is closing as mouse presses on other widgets
+ // immediately call Close().
+ was_bubble_showing_ = ZoomBubbleView::IsClosing();
+
// Do nothing until mouse is released.
return true;
}
void ZoomView::OnMouseReleased(const ui::MouseEvent& event) {
+ if (was_bubble_showing_) {
+ was_bubble_showing_ = false;
+ return;
+ }
+
if (event.IsOnlyLeftMouseButton() && HitTestPoint(event.location()))
- ActivateBubble();
+ ToggleBubble();
}
bool ZoomView::OnKeyPressed(const ui::KeyEvent& event) {
@@ -67,17 +78,20 @@ bool ZoomView::OnKeyPressed(const ui::KeyEvent& event) {
return false;
}
- ActivateBubble();
+ ToggleBubble();
return true;
}
void ZoomView::OnGestureEvent(ui::GestureEvent* event) {
if (event->type() == ui::ET_GESTURE_TAP) {
- ActivateBubble();
+ ToggleBubble();
event->SetHandled();
}
}
-void ZoomView::ActivateBubble() {
- ZoomBubbleView::ShowBubble(location_bar_delegate_->GetWebContents(), false);
+void ZoomView::ToggleBubble() {
+ if (ZoomBubbleView::IsShowing())
+ ZoomBubbleView::CloseBubble();
+ else
+ ZoomBubbleView::ShowBubble(location_bar_delegate_->GetWebContents(), false);
}

Powered by Google App Engine
This is Rietveld 408576698