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

Unified Diff: chrome/browser/views/tabs/tab.cc

Issue 2863003: Attempt 2 at: (Closed)
Patch Set: Created 10 years, 6 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
« no previous file with comments | « chrome/browser/views/tabs/side_tab.cc ('k') | chrome/browser/views/tabs/tab_strip.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/views/tabs/tab.cc
diff --git a/chrome/browser/views/tabs/tab.cc b/chrome/browser/views/tabs/tab.cc
index ec34e42d1792f9e58d751842e4b1383a71bb843c..75de074ac84214790ec5de892d32f6a184ecbefc 100644
--- a/chrome/browser/views/tabs/tab.cc
+++ b/chrome/browser/views/tabs/tab.cc
@@ -23,6 +23,7 @@
#include "grit/theme_resources.h"
#include "third_party/skia/include/effects/SkGradientShader.h"
#include "views/controls/button/image_button.h"
+#include "views/widget/root_view.h"
#include "views/widget/tooltip_manager.h"
#include "views/widget/widget.h"
#include "views/window/non_client_view.h"
@@ -105,7 +106,7 @@ const char Tab::kViewClassName[] = "browser/tabs/Tab";
// Tab, public:
Tab::Tab(TabController* controller)
- : BaseTab(controller),
+ : BaseTab(controller, true),
showing_icon_(false),
showing_close_button_(false),
close_button_color_(NULL),
@@ -232,13 +233,7 @@ void Tab::Paint(gfx::Canvas* canvas) {
PaintIcon(canvas);
// If the close button color has changed, generate a new one.
- if (!close_button_color_ || title_color != close_button_color_) {
- close_button_color_ = title_color;
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- close_button()->SetBackground(close_button_color_,
- rb.GetBitmapNamed(IDR_TAB_CLOSE),
- rb.GetBitmapNamed(IDR_TAB_CLOSE_MASK));
- }
+ SetCloseButtonColor(title_color);
}
void Tab::Layout() {
@@ -286,6 +281,7 @@ void Tab::Layout() {
// Size the Close button.
showing_close_button_ = ShouldShowCloseBox();
+ gfx::Insets near_insets;
if (showing_close_button_) {
int close_button_top =
kTopPadding + kCloseButtonVertFuzz +
@@ -295,10 +291,24 @@ void Tab::Layout() {
close_button_top, close_button_width(),
close_button_height());
close_button()->SetVisible(true);
+ int avail_width = width() - close_button()->bounds().right();
+ if (avail_width > 0) {
+ View* root = GetRootView();
+ if (root) { // Root is NULL when dragging.
+ // Enable mouse near events for the region from the top of the browser
+ // to the bottom of the tab.
+ gfx::Point loc;
+ ConvertPointToView(close_button(), GetRootView(), &loc);
+ near_insets.Set(loc.y(), close_button()->x(),
+ height() - close_button()->bounds().bottom(),
+ avail_width);
+ }
+ }
} else {
close_button()->SetBounds(0, 0, 0, 0);
close_button()->SetVisible(false);
}
+ close_button()->RegisterForMouseNearEvents(near_insets);
int title_left = favicon_bounds_.right() + kFavIconTitleSpacing;
int title_top = kTopPadding + (content_height - font_height()) / 2;
« no previous file with comments | « chrome/browser/views/tabs/side_tab.cc ('k') | chrome/browser/views/tabs/tab_strip.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698