Commit 416d2b05 authored by Allen Bauer's avatar Allen Bauer Committed by Commit Bot

Paint the hovered tabs in order of their hover value.

Under Refresh, as tabs are hovered and the animating hover highlight
is active, several highlighted tabs can be visible. This will change
the painting order of those tabs so that the lower corners of the tabs
are painted such that they aren't likely to look like a "speech bubble"
as pbos@ referred to them.

As a consequence, last_hovered_tab_ could be removed since it's not
needed with the new logic.

Bug: None
Change-Id: I52c470d22966241e47b8450161e4ab9f31966e1b
Reviewed-on: https://chromium-review.googlesource.com/1140954
Commit-Queue: Allen Bauer <kylixrd@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#576334}
parent 6ec9b32f
...@@ -1230,6 +1230,7 @@ void TabStrip::PaintChildren(const views::PaintInfo& paint_info) { ...@@ -1230,6 +1230,7 @@ void TabStrip::PaintChildren(const views::PaintInfo& paint_info) {
Tab* hovered_tab = nullptr; Tab* hovered_tab = nullptr;
Tabs tabs_dragging; Tabs tabs_dragging;
Tabs selected_tabs; Tabs selected_tabs;
Tabs hovered_tabs;
{ {
// We pass false for |lcd_text_requires_opaque_layer| so that background // We pass false for |lcd_text_requires_opaque_layer| so that background
...@@ -1251,22 +1252,19 @@ void TabStrip::PaintChildren(const views::PaintInfo& paint_info) { ...@@ -1251,22 +1252,19 @@ void TabStrip::PaintChildren(const views::PaintInfo& paint_info) {
} else { } else {
tabs_dragging.push_back(tab); tabs_dragging.push_back(tab);
} }
} else if (!tab->IsActive()) { } else if (tab->IsActive()) {
if (!tab->IsSelected()) {
if (!stacked_layout_) {
// In Refresh mode, defer the painting of the hovered tab to below.
if (MD::IsRefreshUi() && tab->mouse_hovered()) {
hovered_tab = tab;
} else {
tab->Paint(paint_info);
}
}
} else {
selected_tabs.push_back(tab);
}
} else {
active_tab = tab; active_tab = tab;
active_tab_index = i; active_tab_index = i;
} else if (tab->IsSelected()) {
selected_tabs.push_back(tab);
} else if (stacked_layout_) {
// Do nothing; this will be handled below.
} else if (MD::IsRefreshUi() && tab->mouse_hovered()) {
hovered_tab = tab;
} else if (MD::IsRefreshUi() && tab->hover_controller()->ShouldDraw()) {
hovered_tabs.push_back(tab);
} else {
tab->Paint(paint_info);
} }
PaintClosingTabs(i, paint_info); PaintClosingTabs(i, paint_info);
} }
...@@ -1287,25 +1285,23 @@ void TabStrip::PaintChildren(const views::PaintInfo& paint_info) { ...@@ -1287,25 +1285,23 @@ void TabStrip::PaintChildren(const views::PaintInfo& paint_info) {
// Now selected but not active. We don't want these dimmed if using native // Now selected but not active. We don't want these dimmed if using native
// frame, so they're painted after initial pass. // frame, so they're painted after initial pass.
for (size_t i = 0; i < selected_tabs.size(); ++i) for (Tab* tab : selected_tabs)
selected_tabs[i]->Paint(paint_info); tab->Paint(paint_info);
// If the last hovered tab is still animating and there is no currently
// hovered tab, make sure it still paints in the right order while it's
// animating.
if (!hovered_tab && last_hovered_tab_ &&
last_hovered_tab_->hover_controller()->ShouldDraw())
hovered_tab = last_hovered_tab_;
// The currently hovered tab or the last tab that was hovered should be
// painted right before the active tab to ensure the highlighted tab shape
// looks reasonable.
if (hovered_tab && !is_dragging)
hovered_tab->Paint(paint_info);
// Keep track of the last tab that was hovered so that it continues to be // Next, paint the hover animating tabs in ascending order of the current
// painted right before the active tab while the animation is running. // animation value.
last_hovered_tab_ = hovered_tab; std::sort(hovered_tabs.begin(), hovered_tabs.end(),
[](Tab* tab1, Tab* tab2) -> bool {
return tab1->hover_controller()->GetAnimationValue() <
tab2->hover_controller()->GetAnimationValue();
});
for (Tab* tab : hovered_tabs)
tab->Paint(paint_info);
// The currently hovered tab should be painted right before the active tab
// to ensure the highlighted tab shape looks reasonable.
if (hovered_tab)
hovered_tab->Paint(paint_info);
// Next comes the active tab. // Next comes the active tab.
if (active_tab && !is_dragging) if (active_tab && !is_dragging)
...@@ -1841,8 +1837,6 @@ void TabStrip::RemoveAndDeleteTab(Tab* tab) { ...@@ -1841,8 +1837,6 @@ void TabStrip::RemoveAndDeleteTab(Tab* tab) {
res.first->second.erase(res.second); res.first->second.erase(res.second);
if (res.first->second.empty()) if (res.first->second.empty())
tabs_closing_map_.erase(res.first); tabs_closing_map_.erase(res.first);
if (tab == last_hovered_tab_)
last_hovered_tab_ = nullptr;
} }
void TabStrip::UpdateTabsClosingMap(int index, int delta) { void TabStrip::UpdateTabsClosingMap(int index, int delta) {
......
...@@ -670,10 +670,6 @@ class TabStrip : public views::View, ...@@ -670,10 +670,6 @@ class TabStrip : public views::View,
// tab close comes from a touch device. // tab close comes from a touch device.
base::OneShotTimer resize_layout_timer_; base::OneShotTimer resize_layout_timer_;
// The last tab over which the mouse was hovered which may still have a hover
// animation in progress.
Tab* last_hovered_tab_ = nullptr;
// This represents the Tabs in |tabs_| that have been selected. // This represents the Tabs in |tabs_| that have been selected.
// //
// Each time tab selection should change, this class will receive a // Each time tab selection should change, this class will receive a
......
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