Commit 15a799c7 authored by Alex Newcomer's avatar Alex Newcomer Committed by Commit Bot

cros dont allow webview to be focused

In the new app list focus design, whenever the AnswerCard WebView is
focused, keys are filtered and sent straight to the webview.

To fix this, we do not allow webview to be focused.
No functionality is lost in this choice.

Also in this CL, fix the Accessibility experience of answer cards by:
- Make the SearchAnswerWebView's focus behavior Accessible only.
- Make the SearchResultAnswerCardView's focus behavior Accessible only.
- Make SearchAnswerContainerView's AX Role "Generic Container" instead
  of "Button", so chromevox knows to look inside the view for the
  Answer Card's contents.

This focus behavior feels exactly like the old model, and improves
ChromeVox's ability to see the WebView's elements, where before they
could not be discovered by chromeVox.

Bug: 763074
Change-Id: I0543c7fb653c0389eda405679fdfec30795da0df
Reviewed-on: https://chromium-review.googlesource.com/722059
Commit-Queue: Alex Newcomer <newcomer@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#509532}
parent 81ffb00e
......@@ -19,6 +19,7 @@
#include "content/public/common/renderer_preferences.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_status_code.h"
#include "ui/app_list/app_list_features.h"
#include "ui/app_list/views/app_list_view.h"
#include "ui/aura/window.h"
#include "ui/views/controls/native/native_view_host.h"
......@@ -70,6 +71,10 @@ class SearchAnswerWebView : public views::WebView {
AppListView::ExcludeWindowFromEventHandling(window);
OnVisibilityEvent(false);
// Focus Behavior is originally set in WebView::SetWebContents, but
// overriden here because we do not want the webview to get focus.
if (features::IsAppListFocusEnabled())
SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY);
}
void RemovedFromWidget() override {
......
......@@ -4,6 +4,8 @@
#include "ui/app_list/views/search_result_answer_card_view.h"
#include "ui/accessibility/ax_node.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/app_list/app_list_constants.h"
#include "ui/app_list/app_list_features.h"
#include "ui/app_list/app_list_view_delegate.h"
......@@ -89,6 +91,20 @@ class SearchResultAnswerCardView::SearchAnswerContainerView
return "SearchAnswerContainerView";
}
void OnBlur() override {
if (features::IsAppListFocusEnabled())
SetSelected(false);
Button::OnBlur();
}
void OnFocus() override {
if (features::IsAppListFocusEnabled()) {
SetSelected(true);
NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, true);
}
Button::OnFocus();
}
bool OnKeyPressed(const ui::KeyEvent& event) override {
if (event.key_code() == ui::VKEY_SPACE) {
// Shouldn't eat Space; we want Space to go to the search box.
......@@ -98,6 +114,15 @@ class SearchResultAnswerCardView::SearchAnswerContainerView
return Button::OnKeyPressed(event);
}
void GetAccessibleNodeData(ui::AXNodeData* node_data) override {
if (!features::IsAppListFocusEnabled()) {
Button::GetAccessibleNodeData(node_data);
return;
}
node_data->role = ui::AX_ROLE_GENERIC_CONTAINER;
node_data->SetName(accessible_name());
}
// views::ButtonListener overrides:
void ButtonPressed(views::Button* sender, const ui::Event& event) override {
DCHECK(sender == this);
......
......@@ -424,10 +424,12 @@ void SearchResultView::PaintButtonContents(gfx::Canvas* canvas) {
void SearchResultView::OnFocus() {
SetSelected(true);
Button::OnFocus();
}
void SearchResultView::OnBlur() {
SetSelected(false);
Button::OnBlur();
}
void SearchResultView::ButtonPressed(views::Button* sender,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment