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

Side by Side Diff: chrome/browser/ui/autofill/autofill_popup_controller_impl.cc

Issue 2670003002: Accessibility for Autofill Popup View in native code (Closed)
Patch Set: Inline implementation of AutofillPopupChildView. Created 3 years, 9 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/autofill/autofill_popup_controller_impl.h" 5 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "chrome/browser/ui/autofill/autofill_popup_view.h" 15 #include "chrome/browser/ui/autofill/autofill_popup_view.h"
16 #include "components/autofill/core/browser/autofill_popup_delegate.h" 16 #include "components/autofill/core/browser/autofill_popup_delegate.h"
17 #include "components/autofill/core/browser/popup_item_ids.h" 17 #include "components/autofill/core/browser/popup_item_ids.h"
18 #include "components/autofill/core/browser/suggestion.h" 18 #include "components/autofill/core/browser/suggestion.h"
19 #include "content/public/browser/native_web_keyboard_event.h" 19 #include "content/public/browser/native_web_keyboard_event.h"
20 #include "ui/accessibility/ax_enums.h"
20 #include "ui/events/event.h" 21 #include "ui/events/event.h"
21 #include "ui/gfx/canvas.h" 22 #include "ui/gfx/canvas.h"
22 #include "ui/gfx/text_elider.h" 23 #include "ui/gfx/text_elider.h"
23 #include "ui/gfx/text_utils.h" 24 #include "ui/gfx/text_utils.h"
24 25
25 using base::WeakPtr; 26 using base::WeakPtr;
26 27
27 namespace autofill { 28 namespace autofill {
28 namespace { 29 namespace {
29 30
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 if (selected_line_ == selected_line) 395 if (selected_line_ == selected_line)
395 return; 396 return;
396 397
397 if (selected_line_ != kNoSelection && 398 if (selected_line_ != kNoSelection &&
398 static_cast<size_t>(selected_line_) < suggestions_.size()) 399 static_cast<size_t>(selected_line_) < suggestions_.size())
399 InvalidateRow(selected_line_); 400 InvalidateRow(selected_line_);
400 401
401 if (selected_line != kNoSelection) { 402 if (selected_line != kNoSelection) {
402 InvalidateRow(selected_line); 403 InvalidateRow(selected_line);
403 404
404 if (!CanAccept(suggestions_[selected_line].frontend_id)) 405 if (CanAccept(suggestions_[selected_line].frontend_id)) {
406 NotifyAccessibilityEventForRow(ui::AX_EVENT_SELECTION, selected_line);
407 } else {
405 selected_line = kNoSelection; 408 selected_line = kNoSelection;
409 }
406 } 410 }
407 411
408 selected_line_ = selected_line; 412 selected_line_ = selected_line;
409 413
410 if (selected_line_ != kNoSelection) { 414 if (selected_line_ != kNoSelection) {
411 delegate_->DidSelectSuggestion(suggestions_[selected_line_].value, 415 delegate_->DidSelectSuggestion(suggestions_[selected_line_].value,
412 suggestions_[selected_line_].frontend_id); 416 suggestions_[selected_line_].frontend_id);
413 } else { 417 } else {
414 delegate_->ClearPreviewedForm(); 418 delegate_->ClearPreviewedForm();
415 } 419 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 void AutofillPopupControllerImpl::ShowView() { 489 void AutofillPopupControllerImpl::ShowView() {
486 view_->Show(); 490 view_->Show();
487 } 491 }
488 492
489 void AutofillPopupControllerImpl::InvalidateRow(size_t row) { 493 void AutofillPopupControllerImpl::InvalidateRow(size_t row) {
490 DCHECK(0 <= row); 494 DCHECK(0 <= row);
491 DCHECK(row < suggestions_.size()); 495 DCHECK(row < suggestions_.size());
492 view_->InvalidateRow(row); 496 view_->InvalidateRow(row);
493 } 497 }
494 498
499 void AutofillPopupControllerImpl::NotifyAccessibilityEventForRow(
500 ui::AXEvent event_type, size_t row) {
501 DCHECK(0 <= row);
502 DCHECK(row < suggestions_.size());
503 view_->NotifyAccessibilityEventForRow(event_type, row);
504 }
505
495 WeakPtr<AutofillPopupControllerImpl> AutofillPopupControllerImpl::GetWeakPtr() { 506 WeakPtr<AutofillPopupControllerImpl> AutofillPopupControllerImpl::GetWeakPtr() {
496 return weak_ptr_factory_.GetWeakPtr(); 507 return weak_ptr_factory_.GetWeakPtr();
497 } 508 }
498 509
499 #if !defined(OS_ANDROID) 510 #if !defined(OS_ANDROID)
500 void AutofillPopupControllerImpl::ElideValueAndLabelForRow( 511 void AutofillPopupControllerImpl::ElideValueAndLabelForRow(
501 size_t row, 512 size_t row,
502 int available_width) { 513 int available_width) {
503 int value_width = gfx::GetStringWidth( 514 int value_width = gfx::GetStringWidth(
504 suggestions_[row].value, layout_model_.GetValueFontListForRow(row)); 515 suggestions_[row].value, layout_model_.GetValueFontListForRow(row));
(...skipping 23 matching lines...) Expand all
528 // Don't clear view_, because otherwise the popup will have to get regenerated 539 // Don't clear view_, because otherwise the popup will have to get regenerated
529 // and this will cause flickering. 540 // and this will cause flickering.
530 suggestions_.clear(); 541 suggestions_.clear();
531 elided_values_.clear(); 542 elided_values_.clear();
532 elided_labels_.clear(); 543 elided_labels_.clear();
533 544
534 selected_line_ = kNoSelection; 545 selected_line_ = kNoSelection;
535 } 546 }
536 547
537 } // namespace autofill 548 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698