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

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

Issue 1982073002: Fix accessibility of buttons inside Chrome menu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « no previous file | ui/views/controls/menu/menu_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/app_menu.h" 5 #include "chrome/browser/ui/views/toolbar/app_menu.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 26 matching lines...) Expand all
37 #include "content/public/browser/notification_observer.h" 37 #include "content/public/browser/notification_observer.h"
38 #include "content/public/browser/notification_registrar.h" 38 #include "content/public/browser/notification_registrar.h"
39 #include "content/public/browser/notification_source.h" 39 #include "content/public/browser/notification_source.h"
40 #include "content/public/browser/notification_types.h" 40 #include "content/public/browser/notification_types.h"
41 #include "content/public/browser/user_metrics.h" 41 #include "content/public/browser/user_metrics.h"
42 #include "content/public/browser/web_contents.h" 42 #include "content/public/browser/web_contents.h"
43 #include "extensions/common/feature_switch.h" 43 #include "extensions/common/feature_switch.h"
44 #include "grit/theme_resources.h" 44 #include "grit/theme_resources.h"
45 #include "third_party/skia/include/core/SkCanvas.h" 45 #include "third_party/skia/include/core/SkCanvas.h"
46 #include "third_party/skia/include/core/SkPaint.h" 46 #include "third_party/skia/include/core/SkPaint.h"
47 #include "ui/accessibility/ax_view_state.h"
47 #include "ui/base/l10n/l10n_util.h" 48 #include "ui/base/l10n/l10n_util.h"
48 #include "ui/base/layout.h" 49 #include "ui/base/layout.h"
49 #include "ui/base/material_design/material_design_controller.h" 50 #include "ui/base/material_design/material_design_controller.h"
50 #include "ui/base/resource/resource_bundle.h" 51 #include "ui/base/resource/resource_bundle.h"
51 #include "ui/gfx/canvas.h" 52 #include "ui/gfx/canvas.h"
52 #include "ui/gfx/font_list.h" 53 #include "ui/gfx/font_list.h"
53 #include "ui/gfx/image/image.h" 54 #include "ui/gfx/image/image.h"
54 #include "ui/gfx/image/image_skia_source.h" 55 #include "ui/gfx/image/image_skia_source.h"
55 #include "ui/gfx/skia_util.h" 56 #include "ui/gfx/skia_util.h"
56 #include "ui/gfx/text_utils.h" 57 #include "ui/gfx/text_utils.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 // Overridden from ImageButton. 116 // Overridden from ImageButton.
116 gfx::Size GetPreferredSize() const override { 117 gfx::Size GetPreferredSize() const override {
117 gfx::Size pref = ImageButton::GetPreferredSize(); 118 gfx::Size pref = ImageButton::GetPreferredSize();
118 if (border()) { 119 if (border()) {
119 gfx::Insets insets = border()->GetInsets(); 120 gfx::Insets insets = border()->GetInsets();
120 pref.Enlarge(insets.width(), insets.height()); 121 pref.Enlarge(insets.width(), insets.height());
121 } 122 }
122 return pref; 123 return pref;
123 } 124 }
124 125
126 void GetAccessibleState(ui::AXViewState* state) override {
127 ImageButton::GetAccessibleState(state);
128 state->role = ui::AX_ROLE_MENU_ITEM;
129 }
130
125 private: 131 private:
126 DISALLOW_COPY_AND_ASSIGN(FullscreenButton); 132 DISALLOW_COPY_AND_ASSIGN(FullscreenButton);
127 }; 133 };
128 134
129 // Combination border/background for the buttons contained in the menu. The 135 // Combination border/background for the buttons contained in the menu. The
130 // painting of the border/background is done here as LabelButton does not always 136 // painting of the border/background is done here as LabelButton does not always
131 // paint the border. 137 // paint the border.
132 class InMenuButtonBackground : public views::Background { 138 class InMenuButtonBackground : public views::Background {
133 public: 139 public:
134 enum ButtonType { 140 enum ButtonType {
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 set_background(in_menu_background_); 298 set_background(in_menu_background_);
293 SetBorder(views::Border::CreateEmptyBorder(0, kHorizontalPadding, 0, 299 SetBorder(views::Border::CreateEmptyBorder(0, kHorizontalPadding, 0,
294 kHorizontalPadding)); 300 kHorizontalPadding));
295 SetFontList(MenuConfig::instance().font_list); 301 SetFontList(MenuConfig::instance().font_list);
296 } 302 }
297 303
298 void SetOtherButtons(const InMenuButton* left, const InMenuButton* right) { 304 void SetOtherButtons(const InMenuButton* left, const InMenuButton* right) {
299 in_menu_background_->SetOtherButtons(left, right); 305 in_menu_background_->SetOtherButtons(left, right);
300 } 306 }
301 307
308 void GetAccessibleState(ui::AXViewState* state) override {
309 LabelButton::GetAccessibleState(state);
310 state->role = ui::AX_ROLE_MENU_ITEM;
311 }
312
302 // views::LabelButton 313 // views::LabelButton
303 void OnNativeThemeChanged(const ui::NativeTheme* theme) override { 314 void OnNativeThemeChanged(const ui::NativeTheme* theme) override {
304 if (theme) { 315 if (theme) {
305 SetTextColor( 316 SetTextColor(
306 views::Button::STATE_DISABLED, 317 views::Button::STATE_DISABLED,
307 theme->GetSystemColor( 318 theme->GetSystemColor(
308 ui::NativeTheme::kColorId_DisabledMenuItemForegroundColor)); 319 ui::NativeTheme::kColorId_DisabledMenuItemForegroundColor));
309 SetTextColor( 320 SetTextColor(
310 views::Button::STATE_HOVERED, 321 views::Button::STATE_HOVERED,
311 theme->GetSystemColor( 322 theme->GetSystemColor(
(...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after
1289 0, 1300 0,
1290 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, 1301 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS,
1291 BOOKMARK_LAUNCH_LOCATION_APP_MENU); 1302 BOOKMARK_LAUNCH_LOCATION_APP_MENU);
1292 } 1303 }
1293 1304
1294 int AppMenu::ModelIndexFromCommandId(int command_id) const { 1305 int AppMenu::ModelIndexFromCommandId(int command_id) const {
1295 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); 1306 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id);
1296 DCHECK(ix != command_id_to_entry_.end()); 1307 DCHECK(ix != command_id_to_entry_.end());
1297 return ix->second.second; 1308 return ix->second.second;
1298 } 1309 }
OLDNEW
« no previous file with comments | « no previous file | ui/views/controls/menu/menu_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698