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

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: Add dependency 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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 // Override CustomButton's implementation, which presses the button when 237 // Override CustomButton's implementation, which presses the button when
238 // you press space and clicks it when you release space. For a MenuButton 238 // you press space and clicks it when you release space. For a MenuButton
239 // we always activate the menu on key press. 239 // we always activate the menu on key press.
240 return false; 240 return false;
241 } 241 }
242 242
243 void MenuButton::GetAccessibleState(ui::AXViewState* state) { 243 void MenuButton::GetAccessibleState(ui::AXViewState* state) {
244 CustomButton::GetAccessibleState(state); 244 CustomButton::GetAccessibleState(state);
245 state->role = ui::AX_ROLE_POP_UP_BUTTON; 245 state->role = ui::AX_ROLE_POP_UP_BUTTON;
246 state->default_action = l10n_util::GetStringUTF16(IDS_APP_ACCACTION_PRESS); 246 state->default_action = l10n_util::GetStringUTF16(IDS_APP_ACCACTION_PRESS);
247 state->state = ui::AX_STATE_HASPOPUP; 247 state->SetStateFlag(ui::AX_STATE_HASPOPUP);
248 } 248 }
249 249
250 void MenuButton::PaintMenuMarker(gfx::Canvas* canvas) { 250 void MenuButton::PaintMenuMarker(gfx::Canvas* canvas) {
251 gfx::Insets insets = GetInsets(); 251 gfx::Insets insets = GetInsets();
252 252
253 // We can not use the views' mirroring infrastructure for mirroring a 253 // We can not use the views' mirroring infrastructure for mirroring a
254 // MenuButton control (see TextButton::OnPaint() for a detailed explanation 254 // MenuButton control (see TextButton::OnPaint() for a detailed explanation
255 // regarding why we can not flip the canvas). Therefore, we need to 255 // regarding why we can not flip the canvas). Therefore, we need to
256 // manually mirror the position of the down arrow. 256 // manually mirror the position of the down arrow.
257 gfx::Rect arrow_bounds(width() - insets.right() - 257 gfx::Rect arrow_bounds(width() - insets.right() -
258 menu_marker_->width() - kMenuMarkerPaddingRight, 258 menu_marker_->width() - kMenuMarkerPaddingRight,
259 height() / 2 - menu_marker_->height() / 2, 259 height() / 2 - menu_marker_->height() / 2,
260 menu_marker_->width(), 260 menu_marker_->width(),
261 menu_marker_->height()); 261 menu_marker_->height());
262 arrow_bounds.set_x(GetMirroredXForRect(arrow_bounds)); 262 arrow_bounds.set_x(GetMirroredXForRect(arrow_bounds));
263 canvas->DrawImageInt(*menu_marker_, arrow_bounds.x(), arrow_bounds.y()); 263 canvas->DrawImageInt(*menu_marker_, arrow_bounds.x(), arrow_bounds.y());
264 } 264 }
265 265
266 int MenuButton::GetMaximumScreenXCoordinate() { 266 int MenuButton::GetMaximumScreenXCoordinate() {
267 if (!GetWidget()) { 267 if (!GetWidget()) {
268 NOTREACHED(); 268 NOTREACHED();
269 return 0; 269 return 0;
270 } 270 }
271 271
272 gfx::Rect monitor_bounds = GetWidget()->GetWorkAreaBoundsInScreen(); 272 gfx::Rect monitor_bounds = GetWidget()->GetWorkAreaBoundsInScreen();
273 return monitor_bounds.right() - 1; 273 return monitor_bounds.right() - 1;
274 } 274 }
275 275
276 } // namespace views 276 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698