summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/tabs/base_tab.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/views/tabs/base_tab.cc')
-rw-r--r--chrome/browser/views/tabs/base_tab.cc18
1 files changed, 16 insertions, 2 deletions
diff --git a/chrome/browser/views/tabs/base_tab.cc b/chrome/browser/views/tabs/base_tab.cc
index 5441379..06c3321 100644
--- a/chrome/browser/views/tabs/base_tab.cc
+++ b/chrome/browser/views/tabs/base_tab.cc
@@ -16,6 +16,7 @@
#include "chrome/browser/browser.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/views/tabs/tab_controller.h"
+#include "chrome/browser/view_ids.h"
#include "chrome/common/chrome_switches.h"
#include "gfx/canvas_skia.h"
#include "gfx/favicon_size.h"
@@ -150,6 +151,8 @@ BaseTab::BaseTab(TabController* controller)
should_display_crashed_favicon_(false) {
BaseTab::InitResources();
+ SetID(VIEW_ID_TAB);
+
// Add the Close Button.
TabCloseButton* close_button = new TabCloseButton(this);
close_button_ = close_button;
@@ -284,8 +287,19 @@ void BaseTab::OnMouseReleased(const views::MouseEvent& event, bool canceled) {
// Close tab on middle click, but only if the button is released over the tab
// (normal windows behavior is to discard presses of a UI element where the
// releases happen off the element).
- if (event.IsMiddleMouseButton() && HitTest(event.location()))
- controller()->CloseTab(this);
+ if (event.IsMiddleMouseButton()) {
+ if (HitTest(event.location())) {
+ controller()->CloseTab(this);
+ } else if (closing_) {
+ // We're animating closed and a middle mouse button was pushed on us but
+ // we don't contain the mouse anymore. We assume the user is clicking
+ // quicker than the animation and we should close the tab that falls under
+ // the mouse.
+ BaseTab* closest_tab = controller()->GetTabAt(this, event.location());
+ if (closest_tab)
+ controller()->CloseTab(closest_tab);
+ }
+ }
}
bool BaseTab::GetTooltipText(const gfx::Point& p, std::wstring* tooltip) {