| 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..7cd59a54f97355f6c6d7be2f1df94c69472e0e9b 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"
|
| @@ -15,6 +16,7 @@
|
| #include "ui/gfx/image/image.h"
|
| #include "ui/gfx/native_widget_types.h"
|
| #include "ui/gfx/text_utils.h"
|
| +#include "ui/views/background.h"
|
| #include "ui/views/border.h"
|
| #include "ui/views/widget/widget.h"
|
|
|
| @@ -24,19 +26,27 @@ 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) {
|
| + AutofillPopupChildView *child = new AutofillPopupChildView(controller, i);
|
| + AddChildViewAt(child, static_cast<int>(i));
|
| + }
|
| + SetFocusBehavior(FocusBehavior::ALWAYS);
|
| + set_background(views::Background::CreateSolidBackground(
|
| + GetNativeTheme()->GetSystemColor(
|
| + ui::NativeTheme::kColorId_ResultsTableNormalBackground)));
|
| +}
|
|
|
| AutofillPopupViewViews::~AutofillPopupViewViews() {}
|
|
|
| void AutofillPopupViewViews::Show() {
|
| DoShow();
|
| + NotifyAccessibilityEvent(ui::AX_EVENT_MENU_POPUP_START, true);
|
| }
|
|
|
| void AutofillPopupViewViews::Hide() {
|
| - // The controller is no longer valid after it hides us.
|
| - controller_ = NULL;
|
| -
|
| DoHide();
|
| + NotifyAccessibilityEvent(ui::AX_EVENT_MENU_POPUP_END, true);
|
| }
|
|
|
| void AutofillPopupViewViews::UpdateBoundsAndRedrawPopup() {
|
| @@ -44,30 +54,38 @@ void AutofillPopupViewViews::UpdateBoundsAndRedrawPopup() {
|
| }
|
|
|
| void AutofillPopupViewViews::OnPaint(gfx::Canvas* canvas) {
|
| - if (!controller_)
|
| - return;
|
| -
|
| - canvas->DrawColor(GetNativeTheme()->GetSystemColor(
|
| - ui::NativeTheme::kColorId_ResultsTableNormalBackground));
|
| + OnPaintBackground(canvas);
|
| OnPaintBorder(canvas);
|
| -
|
| - 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);
|
| }
|
| }
|
|
|
| void AutofillPopupViewViews::InvalidateRow(size_t row) {
|
| - SchedulePaintInRect(controller_->layout_model().GetRowBounds(row));
|
| + child_at(row)->SchedulePaint();
|
| +}
|
| +
|
| +AutofillPopupChildView::AutofillPopupChildView(
|
| + AutofillPopupController* controller, size_t index)
|
| + : controller_(controller), index_(index) {
|
| + SetFocusBehavior(FocusBehavior::ALWAYS);
|
| +}
|
| +
|
| +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) {
|
| + 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,21 @@ void AutofillPopupViewViews::DrawAutofillEntry(gfx::Canvas* canvas,
|
| }
|
| }
|
|
|
| +void AutofillPopupChildView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
|
| + 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 =
|
|
|