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

Side by Side Diff: chrome/browser/ui/views/toolbar/toolbar_button.cc

Issue 292153008: linux_aura: Fix the insets on LabelButtons. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add comments about where the smaller insets come from. Created 6 years, 7 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/views/toolbar/toolbar_button.h" 5 #include "chrome/browser/ui/views/toolbar/toolbar_button.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 8 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
9 #include "grit/theme_resources.h" 9 #include "grit/theme_resources.h"
10 #include "grit/ui_strings.h" 10 #include "grit/ui_strings.h"
11 #include "ui/accessibility/ax_view_state.h" 11 #include "ui/accessibility/ax_view_state.h"
12 #include "ui/base/l10n/l10n_util.h" 12 #include "ui/base/l10n/l10n_util.h"
13 #include "ui/base/models/menu_model.h" 13 #include "ui/base/models/menu_model.h"
14 #include "ui/base/theme_provider.h"
14 #include "ui/gfx/display.h" 15 #include "ui/gfx/display.h"
15 #include "ui/gfx/screen.h" 16 #include "ui/gfx/screen.h"
16 #include "ui/views/controls/button/label_button_border.h" 17 #include "ui/views/controls/button/label_button_border.h"
17 #include "ui/views/controls/menu/menu_item_view.h" 18 #include "ui/views/controls/menu/menu_item_view.h"
18 #include "ui/views/controls/menu/menu_model_adapter.h" 19 #include "ui/views/controls/menu/menu_model_adapter.h"
19 #include "ui/views/controls/menu/menu_runner.h" 20 #include "ui/views/controls/menu/menu_runner.h"
20 #include "ui/views/widget/widget.h" 21 #include "ui/views/widget/widget.h"
21 22
22 ToolbarButton::ToolbarButton(views::ButtonListener* listener, 23 ToolbarButton::ToolbarButton(views::ButtonListener* listener,
23 ui::MenuModel* model) 24 ui::MenuModel* model)
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 LabelButton::OnGestureEvent(event); 122 LabelButton::OnGestureEvent(event);
122 } 123 }
123 124
124 void ToolbarButton::GetAccessibleState(ui::AXViewState* state) { 125 void ToolbarButton::GetAccessibleState(ui::AXViewState* state) {
125 CustomButton::GetAccessibleState(state); 126 CustomButton::GetAccessibleState(state);
126 state->role = ui::AX_ROLE_BUTTON_DROP_DOWN; 127 state->role = ui::AX_ROLE_BUTTON_DROP_DOWN;
127 state->default_action = l10n_util::GetStringUTF16(IDS_APP_ACCACTION_PRESS); 128 state->default_action = l10n_util::GetStringUTF16(IDS_APP_ACCACTION_PRESS);
128 state->AddStateFlag(ui::AX_STATE_HASPOPUP); 129 state->AddStateFlag(ui::AX_STATE_HASPOPUP);
129 } 130 }
130 131
132 void ToolbarButton::SetDefaultBorderInsets(views::LabelButtonBorder* border) {
133 ui::ThemeProvider* provider = GetThemeProvider();
134 if (provider && provider->UsingSystemTheme()) {
135 // These values have no real justification. Because of a mistake in how we
msw 2014/05/21 23:22:57 nit: this paragraph doesn't add much, I think the
136 // were using GTK, we were using these values, which we thought were
137 // insets, but were actually the size of the focus border on the default
138 // activatable widget. This just happened to work.
139 //
140 // We set smaller insets here to accommodate the slightly larger GTK+
141 // icons.
142 border->set_insets(gfx::Insets(2, 2, 2, 2));
143 }
144 }
145
131 void ToolbarButton::ShowContextMenuForView(View* source, 146 void ToolbarButton::ShowContextMenuForView(View* source,
132 const gfx::Point& point, 147 const gfx::Point& point,
133 ui::MenuSourceType source_type) { 148 ui::MenuSourceType source_type) {
134 if (!enabled()) 149 if (!enabled())
135 return; 150 return;
136 151
137 show_menu_factory_.InvalidateWeakPtrs(); 152 show_menu_factory_.InvalidateWeakPtrs();
138 ShowDropDownMenu(source_type); 153 ShowDropDownMenu(source_type);
139 } 154 }
140 155
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 241
227 // Need to explicitly clear mouse handler so that events get sent 242 // Need to explicitly clear mouse handler so that events get sent
228 // properly after the menu finishes running. If we don't do this, then 243 // properly after the menu finishes running. If we don't do this, then
229 // the first click to other parts of the UI is eaten. 244 // the first click to other parts of the UI is eaten.
230 SetMouseHandler(NULL); 245 SetMouseHandler(NULL);
231 246
232 // Set the state back to normal after the drop down menu is closed. 247 // Set the state back to normal after the drop down menu is closed.
233 if (state_ != STATE_DISABLED) 248 if (state_ != STATE_DISABLED)
234 SetState(STATE_NORMAL); 249 SetState(STATE_NORMAL);
235 } 250 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/toolbar/toolbar_button.h ('k') | ui/views/controls/button/blue_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698