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

Side by Side Diff: ui/views/controls/button/menu_button.cc

Issue 196133012: Fix incorrect use of AXState caused when refactoring two enums into one. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make state_ private Created 6 years, 9 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/views/controls/button/menu_button.h" 5 #include "ui/views/controls/button/menu_button.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "grit/ui_resources.h" 8 #include "grit/ui_resources.h"
9 #include "grit/ui_strings.h" 9 #include "grit/ui_strings.h"
10 #include "ui/accessibility/ax_view_state.h" 10 #include "ui/accessibility/ax_view_state.h"
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 // Override CustomButton's implementation, which presses the button when 241 // Override CustomButton's implementation, which presses the button when
242 // you press space and clicks it when you release space. For a MenuButton 242 // you press space and clicks it when you release space. For a MenuButton
243 // we always activate the menu on key press. 243 // we always activate the menu on key press.
244 return false; 244 return false;
245 } 245 }
246 246
247 void MenuButton::GetAccessibleState(ui::AXViewState* state) { 247 void MenuButton::GetAccessibleState(ui::AXViewState* state) {
248 CustomButton::GetAccessibleState(state); 248 CustomButton::GetAccessibleState(state);
249 state->role = ui::AX_ROLE_POP_UP_BUTTON; 249 state->role = ui::AX_ROLE_POP_UP_BUTTON;
250 state->default_action = l10n_util::GetStringUTF16(IDS_APP_ACCACTION_PRESS); 250 state->default_action = l10n_util::GetStringUTF16(IDS_APP_ACCACTION_PRESS);
251 state->state = ui::AX_STATE_HASPOPUP; 251 state->SetStateFlag(ui::AX_STATE_HASPOPUP);
252 } 252 }
253 253
254 void MenuButton::PaintMenuMarker(gfx::Canvas* canvas) { 254 void MenuButton::PaintMenuMarker(gfx::Canvas* canvas) {
255 gfx::Insets insets = GetInsets(); 255 gfx::Insets insets = GetInsets();
256 256
257 // We can not use the views' mirroring infrastructure for mirroring a 257 // We can not use the views' mirroring infrastructure for mirroring a
258 // MenuButton control (see TextButton::OnPaint() for a detailed explanation 258 // MenuButton control (see TextButton::OnPaint() for a detailed explanation
259 // regarding why we can not flip the canvas). Therefore, we need to 259 // regarding why we can not flip the canvas). Therefore, we need to
260 // manually mirror the position of the down arrow. 260 // manually mirror the position of the down arrow.
261 gfx::Rect arrow_bounds(width() - insets.right() - 261 gfx::Rect arrow_bounds(width() - insets.right() -
262 menu_marker_->width() - kMenuMarkerPaddingRight, 262 menu_marker_->width() - kMenuMarkerPaddingRight,
263 height() / 2 - menu_marker_->height() / 2, 263 height() / 2 - menu_marker_->height() / 2,
264 menu_marker_->width(), 264 menu_marker_->width(),
265 menu_marker_->height()); 265 menu_marker_->height());
266 arrow_bounds.set_x(GetMirroredXForRect(arrow_bounds)); 266 arrow_bounds.set_x(GetMirroredXForRect(arrow_bounds));
267 canvas->DrawImageInt(*menu_marker_, arrow_bounds.x(), arrow_bounds.y()); 267 canvas->DrawImageInt(*menu_marker_, arrow_bounds.x(), arrow_bounds.y());
268 } 268 }
269 269
270 int MenuButton::GetMaximumScreenXCoordinate() { 270 int MenuButton::GetMaximumScreenXCoordinate() {
271 if (!GetWidget()) { 271 if (!GetWidget()) {
272 NOTREACHED(); 272 NOTREACHED();
273 return 0; 273 return 0;
274 } 274 }
275 275
276 gfx::Rect monitor_bounds = GetWidget()->GetWorkAreaBoundsInScreen(); 276 gfx::Rect monitor_bounds = GetWidget()->GetWorkAreaBoundsInScreen();
277 return monitor_bounds.right() - 1; 277 return monitor_bounds.right() - 1;
278 } 278 }
279 279
280 } // namespace views 280 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698