Commit 507ccc4d authored by Dana Fried's avatar Dana Fried Committed by Commit Bot

Tab fix for Linux/CrOS.

Because Linux/CrOS do not respect hit test transparency, the top shadow
of bubbles fights for mouse events with the window underneath. This
causes unacceptable flicker with tab hover cards on Linux and ChromeOS.

As a temporary fix until the real culprit can be addressed (a much
larger effort; see crbug/978134), on the affected platforms we move
hover cards down slightly and slightly raise the bottom of the hit test
area for tabs up slightly to compensate. This is not ideal from a UX
standpoint but it is the only solution available at the current time for
an issue that is otherwise a release blocker.

Bug: 972582
Change-Id: I91f0583f8c6c4dfb912c4ea75e07a437fc770f02
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1674290
Commit-Queue: Dana Fried <dfried@chromium.org>
Reviewed-by: default avatarCaroline Rising <corising@chromium.org>
Cr-Commit-Position: refs/heads/master@{#671885}
parent 66e2b580
......@@ -233,10 +233,10 @@ void Tab::ButtonPressed(views::Button* sender, const ui::Event& event) {
else
base::RecordAction(UserMetricsAction("CloseTab_RecordingIndicator"));
const CloseTabSource source =
(event.type() == ui::ET_MOUSE_RELEASED &&
!(event.flags() & ui::EF_FROM_TOUCH)) ? CLOSE_TAB_FROM_MOUSE
: CLOSE_TAB_FROM_TOUCH;
const CloseTabSource source = (event.type() == ui::ET_MOUSE_RELEASED &&
!(event.flags() & ui::EF_FROM_TOUCH))
? CLOSE_TAB_FROM_MOUSE
: CLOSE_TAB_FROM_TOUCH;
DCHECK_EQ(close_button_, sender);
controller_->CloseTab(this, source);
if (event.type() == ui::ET_GESTURE_TAP)
......@@ -524,9 +524,28 @@ void Tab::OnMouseCaptureLost() {
void Tab::OnMouseMoved(const ui::MouseEvent& event) {
tab_style_->SetHoverLocation(event.location());
controller_->OnMouseEventInTab(this, event);
#if defined(OS_LINUX)
MaybeUpdateHoverStatus(event);
#endif
}
void Tab::OnMouseEntered(const ui::MouseEvent& event) {
MaybeUpdateHoverStatus(event);
}
void Tab::MaybeUpdateHoverStatus(const ui::MouseEvent& event) {
#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. Also see the adjustment made in
// abHoverCardBubbleView::TabHoverCardBubbleView(); the two adjustments should
// add to a net six pixels.
// TODO(crbug/978134): Once Linux/CrOS widget transparency is solved, remove
// this case.
constexpr int kHoverCardOverlap = 4;
if (event.location().y() >= height() - kHoverCardOverlap)
return;
#endif
mouse_hovered_ = true;
tab_style_->ShowHover(TabStyle::ShowHoverStyle::kSubtle);
UpdateForegroundColors();
......
......@@ -35,7 +35,7 @@ class TabStyleViews;
namespace gfx {
class Animation;
class LinearAnimation;
}
} // namespace gfx
namespace views {
class Label;
}
......@@ -219,6 +219,10 @@ class Tab : public gfx::AnimationDelegate,
// and alert icon.
void UpdateForegroundColors();
// Considers switching to hovered mode or [re-]showing the hover card based on
// the mouse moving over the tab.
void MaybeUpdateHoverStatus(const ui::MouseEvent& event);
// The controller, never nullptr.
TabController* const controller_;
......
......@@ -280,7 +280,13 @@ TabHoverCardBubbleView::TabHoverCardBubbleView(Tab* tab)
set_margins(gfx::Insets());
// Inset the tab hover cards anchor rect to bring the card closer to the tab.
#if defined(OS_LINUX)
// TODO(crbug/978134): Once Linux/CrOS widget transparency is solved, remove
// this case.
constexpr gfx::Insets kTabHoverCardAnchorInsets(0, 0);
#else
constexpr gfx::Insets kTabHoverCardAnchorInsets(2, 0);
#endif
set_anchor_view_insets(kTabHoverCardAnchorInsets);
// Set so that when hovering over a tab in a inactive window that window will
......
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