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

Unified Diff: chrome/browser/ui/views/autofill/autofill_popup_view_views.cc

Issue 2670003002: Accessibility for Autofill Popup View in native code (Closed)
Patch Set: Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/autofill/autofill_popup_view_views.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/autofill/autofill_popup_view_views.cc
diff --git a/chrome/browser/ui/views/autofill/autofill_popup_view_views.cc b/chrome/browser/ui/views/autofill/autofill_popup_view_views.cc
index 89925cee23efa839e82e4105a6ff2f6b6bc68806..9b865a8bb23bad9a0371933b7e598051f42e84f4 100644
--- a/chrome/browser/ui/views/autofill/autofill_popup_view_views.cc
+++ b/chrome/browser/ui/views/autofill/autofill_popup_view_views.cc
@@ -8,6 +8,7 @@
#include "chrome/browser/ui/autofill/autofill_popup_layout_model.h"
#include "components/autofill/core/browser/popup_item_ids.h"
#include "components/autofill/core/browser/suggestion.h"
+#include "ui/accessibility/ax_node_data.h"
#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/geometry/point.h"
@@ -24,7 +25,12 @@ AutofillPopupViewViews::AutofillPopupViewViews(
AutofillPopupController* controller,
views::Widget* parent_widget)
: AutofillPopupBaseView(controller, parent_widget),
- controller_(controller) {}
+ controller_(controller) {
+ for (size_t i = 0; i < controller_->GetLineCount(); ++i) {
Mathieu 2017/02/02 22:07:44 if it's a separator, let's not create a child view
csashi 2017/02/02 23:27:18 Do we want an accessibility handler for the separa
+ AutofillPopupChildView *child = new AutofillPopupChildView(controller, i);
+ AddChildViewAt(child, static_cast<int>(i));
+ }
+}
AutofillPopupViewViews::~AutofillPopupViewViews() {}
@@ -35,7 +41,9 @@ void AutofillPopupViewViews::Show() {
void AutofillPopupViewViews::Hide() {
// The controller is no longer valid after it hides us.
controller_ = NULL;
Mathieu 2017/02/02 22:07:44 Since DoHide just kills us, I wonder if this is ne
csashi 2017/02/02 23:27:18 Done.
-
+ for (int i = 0; i < child_count(); ++i) {
+ (static_cast<AutofillPopupChildView*>(child_at(i)))->clear_controller();
+ }
DoHide();
}
@@ -50,24 +58,34 @@ void AutofillPopupViewViews::OnPaint(gfx::Canvas* canvas) {
canvas->DrawColor(GetNativeTheme()->GetSystemColor(
Mathieu 2017/02/02 19:30:15 I think we could use set_background in the constru
Mathieu 2017/02/02 22:07:45 In the constructor: set_background(views::Backgr
csashi 2017/02/02 23:27:18 Done.
csashi 2017/02/02 23:27:18 Done.
ui::NativeTheme::kColorId_ResultsTableNormalBackground));
OnPaintBorder(canvas);
Mathieu 2017/02/02 19:30:15 I think we could SetBorder in the constructor
Mathieu 2017/02/02 22:07:45 In the constructor (color to be confirmed): SetBo
-
- for (size_t i = 0; i < controller_->GetLineCount(); ++i) {
- gfx::Rect line_rect = controller_->layout_model().GetRowBounds(i);
-
- if (controller_->GetSuggestionAt(i).frontend_id ==
- POPUP_ITEM_ID_SEPARATOR) {
- canvas->FillRect(
- line_rect,
- GetNativeTheme()->GetSystemColor(
- ui::NativeTheme::kColorId_ResultsTableNormalDimmedText));
- } else {
- DrawAutofillEntry(canvas, i, line_rect);
- }
+ for (int i = 0; i < child_count(); ++i) {
+ (static_cast<AutofillPopupChildView*>(child_at(i)))->OnPaint(canvas);
Mathieu 2017/02/02 19:30:15 Since this is the last thing, we shouldn't need to
csashi 2017/02/02 23:27:18 I thought so too, but that didn't work. Not sure w
}
}
void AutofillPopupViewViews::InvalidateRow(size_t row) {
- SchedulePaintInRect(controller_->layout_model().GetRowBounds(row));
+ child_at(row)->SchedulePaint();
+}
+
+void AutofillPopupViewViews::GetAccessibleNodeData(ui::AXNodeData* node_data) {
+ LOG(VERBOSE) << "AutofillPopupViewViews::GetAccessibleNodeData";
+}
+
+AutofillPopupChildView::~AutofillPopupChildView() {}
+
+void AutofillPopupChildView::OnPaint(gfx::Canvas* canvas) {
+ if (!controller_)
+ return;
+ const gfx::Rect line_rect = controller_->layout_model().GetRowBounds(index_);
+ if (controller_->GetSuggestionAt(index_).frontend_id ==
+ POPUP_ITEM_ID_SEPARATOR) {
Mathieu 2017/02/02 22:07:45 As mentioned above, let's not draw separators but
csashi 2017/02/02 23:27:18 Same comment as above. Doesn't this depend on whet
+ canvas->FillRect(
+ line_rect,
+ GetNativeTheme()->GetSystemColor(
+ ui::NativeTheme::kColorId_ResultsTableNormalDimmedText));
+ } else {
+ DrawAutofillEntry(canvas, index_, line_rect);
+ }
}
/**
@@ -92,7 +110,7 @@ void AutofillPopupViewViews::InvalidateRow(size_t row) {
* #mark-non-secure-as flag as "display form warning", go to goo.gl/CEIjc6 with
* stored autofill info and check for credit card or password forms.
*/
-void AutofillPopupViewViews::DrawAutofillEntry(gfx::Canvas* canvas,
+void AutofillPopupChildView::DrawAutofillEntry(gfx::Canvas* canvas,
int index,
const gfx::Rect& entry_rect) {
canvas->FillRect(
@@ -189,6 +207,22 @@ void AutofillPopupViewViews::DrawAutofillEntry(gfx::Canvas* canvas,
}
}
+void AutofillPopupChildView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
+ LOG(VERBOSE) << "AutofillPopupChildView::GetAccessibleNodeData";
+ if (!controller_)
+ return;
+ if (controller_->GetSuggestionAt(index_).frontend_id ==
+ POPUP_ITEM_ID_SEPARATOR) {
+ node_data->role = ui::AX_ROLE_SPLITTER;
+ node_data->AddStateFlag(ui::AX_STATE_READ_ONLY);
+ return;
+ }
+ node_data->role = ui::AX_ROLE_TEXT_FIELD;
+ node_data->SetName(controller_->GetElidedLabelAt(index_));
+ node_data->SetValue(controller_->GetElidedValueAt(index_));
+ node_data->AddStateFlag(ui::AX_STATE_EDITABLE);
+}
+
AutofillPopupView* AutofillPopupView::Create(
AutofillPopupController* controller) {
views::Widget* observing_widget =
« no previous file with comments | « chrome/browser/ui/views/autofill/autofill_popup_view_views.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698