Skip to content

Commit

Permalink
QA Rich Card: filter scrolling events
Browse files Browse the repository at this point in the history
Explicitly stop the propagation of scroll events (including key and
mouse events) that aren't handled by the pretarget handler when the
rich answers view is visible. Specifically update behavior to disallow
scrolling of anything *other* than the rich answers card. Scrolling
behavior of the rich answers card will be updated later.

This is necessary to make event handling consistent with the existing
quick answers view (e.g. not allowing scrolling of other windows while
the card is visible.)

Tests: tested on DUT
Bug: b/274503679
Change-Id: I4c216049c2d1140bd300aebe71a95fadc2b98335
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4363407
Reviewed-by: Xiaohui Chen <xiaohuic@chromium.org>
Commit-Queue: Angela Xiao <angelaxiao@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1122027}
  • Loading branch information
Angela Xiao authored and Chromium LUCI CQ committed Mar 25, 2023
1 parent 9ed5c17 commit 911d7ac
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,24 @@ void RichAnswersPreTargetHandler::OnKeyEvent(ui::KeyEvent* key_event) {
}

auto key_code = key_event->key_code();
if (key_code == ui::VKEY_ESCAPE) {
QuickAnswersController::Get()->DismissQuickAnswers(
quick_answers::QuickAnswersExitPoint::kUnspecified);
switch (key_code) {
case ui::VKEY_ESCAPE: {
QuickAnswersController::Get()->DismissQuickAnswers(
quick_answers::QuickAnswersExitPoint::kUnspecified);
return;
}
case ui::VKEY_SPACE:
case ui::VKEY_UP:
case ui::VKEY_DOWN:
case ui::VKEY_LEFT:
case ui::VKEY_RIGHT: {
// TODO(b/275106457): Handle key navigation of focus on the
// rich answers card view.
key_event->StopPropagation();
return;
}
default:
return;
}
}

Expand All @@ -52,6 +67,23 @@ void RichAnswersPreTargetHandler::OnMouseEvent(ui::MouseEvent* mouse_event) {
QuickAnswersController::Get()->DismissQuickAnswers(
quick_answers::QuickAnswersExitPoint::kUnspecified);
}

// While the rich answers view is visible, do not pass on unhandled
// mouse events up the hierarchy. The rich answers view should be dismissed
// before allowing mouse event handling by other windows and views.
if (mouse_event->cancelable()) {
mouse_event->StopPropagation();
}
}

void RichAnswersPreTargetHandler::OnScrollEvent(ui::ScrollEvent* scroll_event) {
// TODO(b/265255821): handle scrolling of the rich answers view card.
// Limit scroll events to the rich answers card while it is visible.
// This means other windows and views will not be scrollable until the rich
// answers view is dismissed.
if (scroll_event->cancelable()) {
scroll_event->StopPropagation();
}
}

} // namespace quick_answers
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class RichAnswersPreTargetHandler : public ui::EventHandler {
// ui::EventHandler:
void OnKeyEvent(ui::KeyEvent* key_event) override;
void OnMouseEvent(ui::MouseEvent* mouse_event) override;
void OnScrollEvent(ui::ScrollEvent* scroll_event) override;

private:
// Associated view handled by this class.
Expand Down

0 comments on commit 911d7ac

Please sign in to comment.