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

Side by Side Diff: chrome/browser/ui/views/autofill/autofill_popup_view_views.cc

Issue 2670003002: Accessibility for Autofill Popup View in native code (Closed)
Patch Set: Removes call to RequestFocus. RequestFocus fails because the widget is not active. Created 3 years, 10 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
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 "chrome/browser/ui/views/autofill/autofill_popup_view_views.h" 5 #include "chrome/browser/ui/views/autofill/autofill_popup_view_views.h"
6 6
7 #include "chrome/browser/ui/autofill/autofill_popup_controller.h" 7 #include "chrome/browser/ui/autofill/autofill_popup_controller.h"
8 #include "chrome/browser/ui/autofill/autofill_popup_layout_model.h" 8 #include "chrome/browser/ui/autofill/autofill_popup_layout_model.h"
9 #include "chrome/grit/generated_resources.h"
9 #include "components/autofill/core/browser/popup_item_ids.h" 10 #include "components/autofill/core/browser/popup_item_ids.h"
10 #include "components/autofill/core/browser/suggestion.h" 11 #include "components/autofill/core/browser/suggestion.h"
12 #include "ui/accessibility/ax_node_data.h"
13 #include "ui/base/l10n/l10n_util.h"
11 #include "ui/events/keycodes/keyboard_codes.h" 14 #include "ui/events/keycodes/keyboard_codes.h"
12 #include "ui/gfx/canvas.h" 15 #include "ui/gfx/canvas.h"
13 #include "ui/gfx/geometry/point.h" 16 #include "ui/gfx/geometry/point.h"
14 #include "ui/gfx/geometry/rect.h" 17 #include "ui/gfx/geometry/rect.h"
15 #include "ui/gfx/image/image.h" 18 #include "ui/gfx/image/image.h"
16 #include "ui/gfx/native_widget_types.h" 19 #include "ui/gfx/native_widget_types.h"
17 #include "ui/gfx/text_utils.h" 20 #include "ui/gfx/text_utils.h"
18 #include "ui/views/border.h" 21 #include "ui/views/border.h"
19 #include "ui/views/widget/widget.h" 22 #include "ui/views/widget/widget.h"
20 23
21 namespace autofill { 24 namespace autofill {
22 25
23 AutofillPopupViewViews::AutofillPopupViewViews( 26 AutofillPopupViewViews::AutofillPopupViewViews(
24 AutofillPopupController* controller, 27 AutofillPopupController* controller, views::Widget* parent_widget)
25 views::Widget* parent_widget)
26 : AutofillPopupBaseView(controller, parent_widget), 28 : AutofillPopupBaseView(controller, parent_widget),
27 controller_(controller) {} 29 controller_(controller) {
30 for (size_t i = 0; i < controller_->GetLineCount(); ++i) {
31 AutofillPopupChildView *child = new AutofillPopupChildView(controller, i);
32 AddChildViewAt(child, static_cast<int>(i));
33 }
34 SetFocusBehavior(FocusBehavior::ALWAYS);
35 }
28 36
29 AutofillPopupViewViews::~AutofillPopupViewViews() {} 37 AutofillPopupViewViews::~AutofillPopupViewViews() {}
30 38
31 void AutofillPopupViewViews::Show() { 39 void AutofillPopupViewViews::Show() {
32 DoShow(); 40 DoShow();
41 NotifyAccessibilityEvent(ui::AX_EVENT_MENU_START, true);
33 } 42 }
34 43
35 void AutofillPopupViewViews::Hide() { 44 void AutofillPopupViewViews::Hide() {
36 // The controller is no longer valid after it hides us. 45 // The controller is no longer valid after it hides us.
37 controller_ = NULL; 46 controller_ = NULL;
38
39 DoHide(); 47 DoHide();
48 NotifyAccessibilityEvent(ui::AX_EVENT_MENU_END, true);
40 } 49 }
41 50
42 void AutofillPopupViewViews::UpdateBoundsAndRedrawPopup() { 51 void AutofillPopupViewViews::UpdateBoundsAndRedrawPopup() {
43 DoUpdateBoundsAndRedrawPopup(); 52 DoUpdateBoundsAndRedrawPopup();
44 } 53 }
45 54
46 void AutofillPopupViewViews::OnPaint(gfx::Canvas* canvas) { 55 void AutofillPopupViewViews::OnPaint(gfx::Canvas* canvas) {
47 if (!controller_) 56 if (!controller_)
48 return; 57 return;
49 58
(...skipping 13 matching lines...) Expand all
63 } else { 72 } else {
64 DrawAutofillEntry(canvas, i, line_rect); 73 DrawAutofillEntry(canvas, i, line_rect);
65 } 74 }
66 } 75 }
67 } 76 }
68 77
69 void AutofillPopupViewViews::InvalidateRow(size_t row) { 78 void AutofillPopupViewViews::InvalidateRow(size_t row) {
70 SchedulePaintInRect(controller_->layout_model().GetRowBounds(row)); 79 SchedulePaintInRect(controller_->layout_model().GetRowBounds(row));
71 } 80 }
72 81
82 void AutofillPopupViewViews::NotifyAccessibilityEventForRow(
83 ui::AXEvent event_type, size_t row) {
84 AutofillPopupChildView *child_view =
85 static_cast<AutofillPopupChildView*>(child_at(row));
86 child_view->NotifyAccessibilityEvent(event_type, true);
87 }
88
73 /** 89 /**
74 * Autofill entries in ltr. 90 * Autofill entries in ltr.
75 * 91 *
76 * ............................................................................ 92 * ............................................................................
77 * . ICON | HTTP WARNING MESSAGE VALUE | LABEL . 93 * . ICON | HTTP WARNING MESSAGE VALUE | LABEL .
78 * ............................................................................ 94 * ............................................................................
79 * . OTHER AUTOFILL ENTRY VALUE | LABEL | ICON . 95 * . OTHER AUTOFILL ENTRY VALUE | LABEL | ICON .
80 * ............................................................................ 96 * ............................................................................
81 * 97 *
82 * Autofill entries in rtl. 98 * Autofill entries in rtl.
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 controller_->GetElidedLabelAt(index), 198 controller_->GetElidedLabelAt(index),
183 controller_->layout_model().GetLabelFontListForRow(index), 199 controller_->layout_model().GetLabelFontListForRow(index),
184 GetNativeTheme()->GetSystemColor( 200 GetNativeTheme()->GetSystemColor(
185 ui::NativeTheme::kColorId_ResultsTableNormalDimmedText), 201 ui::NativeTheme::kColorId_ResultsTableNormalDimmedText),
186 gfx::Rect(label_x_align_left, entry_rect.y(), label_width, 202 gfx::Rect(label_x_align_left, entry_rect.y(), label_width,
187 entry_rect.height()), 203 entry_rect.height()),
188 text_align); 204 text_align);
189 } 205 }
190 } 206 }
191 207
208 void AutofillPopupViewViews::GetAccessibleNodeData(ui::AXNodeData* node_data) {
209 node_data->role = ui::AX_ROLE_MENU_LIST_POPUP;
David Tseng 2017/02/25 02:03:16 This isn't the right role to use for ChromeVox. Us
csashi 2017/02/25 02:09:16 Done.
210 node_data->SetName(l10n_util::GetStringUTF16(
211 IDS_AUTOFILL_POPUP_ACCESSIBLE_NODE_DATA));
212 }
213
192 AutofillPopupView* AutofillPopupView::Create( 214 AutofillPopupView* AutofillPopupView::Create(
193 AutofillPopupController* controller) { 215 AutofillPopupController* controller) {
194 views::Widget* observing_widget = 216 views::Widget* observing_widget =
195 views::Widget::GetTopLevelWidgetForNativeView( 217 views::Widget::GetTopLevelWidgetForNativeView(
196 controller->container_view()); 218 controller->container_view());
197 219
198 // If the top level widget can't be found, cancel the popup since we can't 220 // If the top level widget can't be found, cancel the popup since we can't
199 // fully set it up. 221 // fully set it up.
200 if (!observing_widget) 222 if (!observing_widget)
201 return NULL; 223 return NULL;
202 224
203 return new AutofillPopupViewViews(controller, observing_widget); 225 return new AutofillPopupViewViews(controller, observing_widget);
204 } 226 }
205 227
228 AutofillPopupChildView::AutofillPopupChildView(
229 AutofillPopupController* controller, size_t index)
230 : controller_(controller), index_(index) {
231 SetFocusBehavior(FocusBehavior::ALWAYS);
232 }
233
234 AutofillPopupChildView::~AutofillPopupChildView() {}
235
236 void AutofillPopupChildView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
237 if (!controller_)
238 return;
239 // We do not special case |POPUP_ITEM_ID_SEPARATOR| suggestion because we
240 // skip that suggestion when the user navigates through the popup suggestions.
241 node_data->role = ui::AX_ROLE_MENU_ITEM;
242 node_data->SetName(controller_->GetElidedValueAt(index_));
243 }
244
206 } // namespace autofill 245 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698