Commit e9924c76 authored by Ahmed Mehfooz's avatar Ahmed Mehfooz Committed by Commit Bot

Fix message center focus traversal with Arc Notifications

This CL makes sure the control buttons view in arc notifications
is not set to visible when the message center is collapsed.
Also fixes GetLastFocusableChild to account for arc notifications.

Bug: 1057988
Change-Id: If4e9988e7362783f4e0331b7bf8cb3c2fe2ce447
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2114166Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Ahmed Mehfooz <amehfooz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#752648}
parent 1ff7639f
...@@ -317,6 +317,15 @@ ArcNotificationContentView::GetControlButtonsView() { ...@@ -317,6 +317,15 @@ ArcNotificationContentView::GetControlButtonsView() {
return floating_control_buttons_widget_ ? &control_buttons_view_ : nullptr; return floating_control_buttons_widget_ ? &control_buttons_view_ : nullptr;
} }
void ArcNotificationContentView::VisibilityChanged(View* starting_from,
bool is_visible) {
// Need to explicitly set visibility for control_buttons_view_ to
// make sure they don't capture focus when the notification is not
// visible due to the message center being collapsed.
control_buttons_view_.SetVisible(is_visible);
UpdateControlButtonsVisibility();
}
void ArcNotificationContentView::UpdateControlButtonsVisibility() { void ArcNotificationContentView::UpdateControlButtonsVisibility() {
if (!control_buttons_view_.parent()) if (!control_buttons_view_.parent())
return; return;
...@@ -329,9 +338,10 @@ void ArcNotificationContentView::UpdateControlButtonsVisibility() { ...@@ -329,9 +338,10 @@ void ArcNotificationContentView::UpdateControlButtonsVisibility() {
DCHECK(floating_control_buttons_widget_); DCHECK(floating_control_buttons_widget_);
const bool target_visibility = const bool target_visibility =
control_buttons_view_.IsAnyButtonFocused() || GetVisible() && (control_buttons_view_.IsAnyButtonFocused() ||
(message_view_->GetMode() != message_center::MessageView::Mode::SETTING && (message_view_->GetMode() !=
IsMouseHovered()); message_center::MessageView::Mode::SETTING &&
IsMouseHovered()));
if (target_visibility == floating_control_buttons_widget_->IsVisible()) if (target_visibility == floating_control_buttons_widget_->IsVisible())
return; return;
......
...@@ -108,6 +108,7 @@ class ArcNotificationContentView ...@@ -108,6 +108,7 @@ class ArcNotificationContentView
void OnAccessibilityEvent(ax::mojom::Event event) override; void OnAccessibilityEvent(ax::mojom::Event event) override;
void AddedToWidget() override; void AddedToWidget() override;
void RemovedFromWidget() override; void RemovedFromWidget() override;
void VisibilityChanged(View* starting_from, bool is_visible) override;
// aura::WindowObserver // aura::WindowObserver
void OnWindowBoundsChanged(aura::Window* window, void OnWindowBoundsChanged(aura::Window* window,
......
...@@ -302,7 +302,7 @@ void UnifiedMessageCenterView::OnDidChangeFocus(views::View* before, ...@@ -302,7 +302,7 @@ void UnifiedMessageCenterView::OnDidChangeFocus(views::View* before,
OnMessageCenterScrolled(); OnMessageCenterScrolled();
if (features::IsUnifiedMessageCenterRefactorEnabled()) { if (features::IsUnifiedMessageCenterRefactorEnabled() && !collapsed()) {
views::View* first_view = GetFirstFocusableChild(); views::View* first_view = GetFirstFocusableChild();
views::View* last_view = GetLastFocusableChild(); views::View* last_view = GetLastFocusableChild();
...@@ -519,8 +519,10 @@ void UnifiedMessageCenterView::NotifyRectBelowScroll() { ...@@ -519,8 +519,10 @@ void UnifiedMessageCenterView::NotifyRectBelowScroll() {
} }
void UnifiedMessageCenterView::FocusOut(bool reverse) { void UnifiedMessageCenterView::FocusOut(bool reverse) {
if (message_center_bubble_) if (message_center_bubble_ && message_center_bubble_->FocusOut(reverse)) {
message_center_bubble_->FocusOut(reverse); GetFocusManager()->ClearFocus();
GetFocusManager()->SetStoredFocusView(nullptr);
}
} }
void UnifiedMessageCenterView::FocusEntered(bool reverse) { void UnifiedMessageCenterView::FocusEntered(bool reverse) {
...@@ -542,14 +544,24 @@ views::View* UnifiedMessageCenterView::GetFirstFocusableChild() { ...@@ -542,14 +544,24 @@ views::View* UnifiedMessageCenterView::GetFirstFocusableChild() {
} }
views::View* UnifiedMessageCenterView::GetLastFocusableChild() { views::View* UnifiedMessageCenterView::GetLastFocusableChild() {
views::FocusTraversable* dummy_focus_traversable; views::FocusTraversable* focus_traversable = nullptr;
views::View* dummy_focus_traversable_view; views::View* dummy_focus_traversable_view = nullptr;
return focus_search_->FindNextFocusableView( views::View* last_view = focus_search_->FindNextFocusableView(
nullptr, views::FocusSearch::SearchDirection::kBackwards, nullptr, views::FocusSearch::SearchDirection::kBackwards,
views::FocusSearch::TraversalDirection::kDown, views::FocusSearch::TraversalDirection::kDown,
views::FocusSearch::StartingViewPolicy::kSkipStartingView, views::FocusSearch::StartingViewPolicy::kSkipStartingView,
views::FocusSearch::AnchoredDialogPolicy::kCanGoIntoAnchoredDialog, views::FocusSearch::AnchoredDialogPolicy::kCanGoIntoAnchoredDialog,
&dummy_focus_traversable, &dummy_focus_traversable_view); &focus_traversable, &dummy_focus_traversable_view);
if (last_view || !focus_traversable)
return last_view;
return focus_traversable->GetFocusSearch()->FindNextFocusableView(
nullptr, views::FocusSearch::SearchDirection::kBackwards,
views::FocusSearch::TraversalDirection::kDown,
views::FocusSearch::StartingViewPolicy::kSkipStartingView,
views::FocusSearch::AnchoredDialogPolicy::kCanGoIntoAnchoredDialog,
&focus_traversable, &dummy_focus_traversable_view);
} }
} // namespace ash } // namespace ash
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