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

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

Issue 2518183002: Moved action verbs out of Blink. (Closed)
Patch Set: Returns only "click" for the non-localized method that gets the action name on Windows. Created 4 years 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
« no previous file with comments | « ui/views/DEPS ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ui/accessibility/ax_node_data.h" 8 #include "ui/accessibility/ax_node_data.h"
9 #include "ui/base/dragdrop/drag_drop_types.h" 9 #include "ui/base/dragdrop/drag_drop_types.h"
10 #include "ui/base/l10n/l10n_util.h"
11 #include "ui/base/resource/resource_bundle.h" 10 #include "ui/base/resource/resource_bundle.h"
12 #include "ui/display/screen.h" 11 #include "ui/display/screen.h"
13 #include "ui/events/event.h" 12 #include "ui/events/event.h"
14 #include "ui/events/event_constants.h" 13 #include "ui/events/event_constants.h"
15 #include "ui/events/event_utils.h" 14 #include "ui/events/event_utils.h"
16 #include "ui/gfx/canvas.h" 15 #include "ui/gfx/canvas.h"
17 #include "ui/gfx/image/image.h" 16 #include "ui/gfx/image/image.h"
18 #include "ui/gfx/text_constants.h" 17 #include "ui/gfx/text_constants.h"
19 #include "ui/resources/grit/ui_resources.h" 18 #include "ui/resources/grit/ui_resources.h"
20 #include "ui/strings/grit/ui_strings.h"
21 #include "ui/views/controls/button/button.h" 19 #include "ui/views/controls/button/button.h"
22 #include "ui/views/controls/button/menu_button_listener.h" 20 #include "ui/views/controls/button/menu_button_listener.h"
23 #include "ui/views/mouse_constants.h" 21 #include "ui/views/mouse_constants.h"
24 #include "ui/views/resources/grit/views_resources.h" 22 #include "ui/views/resources/grit/views_resources.h"
25 #include "ui/views/widget/root_view.h" 23 #include "ui/views/widget/root_view.h"
26 #include "ui/views/widget/widget.h" 24 #include "ui/views/widget/widget.h"
27 25
28 using base::TimeTicks; 26 using base::TimeTicks;
29 using base::TimeDelta; 27 using base::TimeDelta;
30 28
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 bool MenuButton::OnKeyReleased(const ui::KeyEvent& event) { 291 bool MenuButton::OnKeyReleased(const ui::KeyEvent& event) {
294 // Override CustomButton's implementation, which presses the button when 292 // Override CustomButton's implementation, which presses the button when
295 // you press space and clicks it when you release space. For a MenuButton 293 // you press space and clicks it when you release space. For a MenuButton
296 // we always activate the menu on key press. 294 // we always activate the menu on key press.
297 return false; 295 return false;
298 } 296 }
299 297
300 void MenuButton::GetAccessibleNodeData(ui::AXNodeData* node_data) { 298 void MenuButton::GetAccessibleNodeData(ui::AXNodeData* node_data) {
301 CustomButton::GetAccessibleNodeData(node_data); 299 CustomButton::GetAccessibleNodeData(node_data);
302 node_data->role = ui::AX_ROLE_POP_UP_BUTTON; 300 node_data->role = ui::AX_ROLE_POP_UP_BUTTON;
303 node_data->AddStringAttribute( 301 node_data->AddIntAttribute(ui::AX_ATTR_ACTION, ui::AX_SUPPORTED_ACTION_PRESS);
sky 2016/11/28 18:18:01 Does whether the button is enabled make a differen
304 ui::AX_ATTR_ACTION, l10n_util::GetStringUTF8(IDS_APP_ACCACTION_PRESS));
305 node_data->AddStateFlag(ui::AX_STATE_HASPOPUP); 302 node_data->AddStateFlag(ui::AX_STATE_HASPOPUP);
306 } 303 }
307 304
308 void MenuButton::PaintMenuMarker(gfx::Canvas* canvas) { 305 void MenuButton::PaintMenuMarker(gfx::Canvas* canvas) {
309 gfx::Insets insets = GetInsets(); 306 gfx::Insets insets = GetInsets();
310 307
311 // Using the Views mirroring infrastructure incorrectly flips icon content. 308 // Using the Views mirroring infrastructure incorrectly flips icon content.
312 // Instead, manually mirror the position of the down arrow. 309 // Instead, manually mirror the position of the down arrow.
313 gfx::Rect arrow_bounds(width() - insets.right() - 310 gfx::Rect arrow_bounds(width() - insets.right() -
314 menu_marker_->width() - kMenuMarkerPaddingRight, 311 menu_marker_->width() - kMenuMarkerPaddingRight,
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 if (!GetWidget()) { 403 if (!GetWidget()) {
407 NOTREACHED(); 404 NOTREACHED();
408 return 0; 405 return 0;
409 } 406 }
410 407
411 gfx::Rect monitor_bounds = GetWidget()->GetWorkAreaBoundsInScreen(); 408 gfx::Rect monitor_bounds = GetWidget()->GetWorkAreaBoundsInScreen();
412 return monitor_bounds.right() - 1; 409 return monitor_bounds.right() - 1;
413 } 410 }
414 411
415 } // namespace views 412 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698