Commit 7781c219 authored by Dana Fried's avatar Dana Fried Committed by Commit Bot

Fade out hover card on touch input.

This CL hides the hover card on any gesture event and also ignores
mouse events on tabs when mouse input is disabled (which happens
between a touch event and the next actual mouse event).

This prevents flashing of hover state and hover cards.

Bug: 1007935
Change-Id: I65255c31f6c624d9062398bb298830090500a49e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1849988
Commit-Queue: Dana Fried <dfried@chromium.org>
Reviewed-by: default avatarCharlene Yan <cyan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#707186}
parent 9f224aff
......@@ -550,9 +550,17 @@ void Tab::OnMouseCaptureLost() {
void Tab::OnMouseMoved(const ui::MouseEvent& event) {
tab_style_->SetHoverLocation(event.location());
controller_->OnMouseEventInTab(this, event);
#if defined(OS_LINUX)
// Linux enter/leave events are sometimes flaky, so we don't want to "miss"
// an enter event and fail to hover the tab.
//
// In Windows, we won't miss the enter event but mouse input is disabled after
// a touch gesture and we could end up ignoring the enter event. If the user
// subsequently moves the mouse, we need to then hover the tab.
//
// Either way, this is effectively a no-op if the tab is already in a hovered
// state.
MaybeUpdateHoverStatus(event);
#endif
}
void Tab::OnMouseEntered(const ui::MouseEvent& event) {
......@@ -560,6 +568,9 @@ void Tab::OnMouseEntered(const ui::MouseEvent& event) {
}
void Tab::MaybeUpdateHoverStatus(const ui::MouseEvent& event) {
if (mouse_hovered_ || !GetWidget()->IsMouseEventsEnabled())
return;
#if defined(OS_LINUX)
// Move the hit test area for hovering up so that it is not overlapped by tab
// hover cards when they are shown.
......@@ -578,6 +589,8 @@ void Tab::MaybeUpdateHoverStatus(const ui::MouseEvent& event) {
}
void Tab::OnMouseExited(const ui::MouseEvent& event) {
if (!mouse_hovered_)
return;
mouse_hovered_ = false;
tab_style_->HideHover(TabStyle::HideHoverStyle::kGradual);
UpdateForegroundColors();
......
......@@ -152,8 +152,6 @@ class Tab : public gfx::AnimationDelegate,
// throbbers in sync.
void StepLoadingAnimation(const base::TimeDelta& elapsed_time);
bool ShowingLoadingAnimation() const;
// Sets the visibility of the indicator shown when the tab needs to indicate
// to the user that it needs their attention.
void SetTabNeedsAttention(bool attention);
......@@ -214,7 +212,8 @@ class Tab : public gfx::AnimationDelegate,
void UpdateForegroundColors();
// Considers switching to hovered mode or [re-]showing the hover card based on
// the mouse moving over the tab.
// the mouse moving over the tab. If the tab is already hovered or mouse
// events are disabled because of touch input, this is a no-op.
void MaybeUpdateHoverStatus(const ui::MouseEvent& event);
// The controller, never nullptr.
......
......@@ -157,6 +157,10 @@ class TabHoverCardEventSniffer : public ui::EventHandler {
hover_card_->FadeOutToHide();
}
void OnGestureEvent(ui::GestureEvent* event) override {
hover_card_->FadeOutToHide();
}
private:
TabHoverCardBubbleView* const hover_card_;
TabStrip* tab_strip_;
......
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