Commit 2f065d26 authored by Avery Musbach's avatar Avery Musbach Committed by Commit Bot

overview: Factor out excessively duplicated code into helper function

Bug: None
Change-Id: Iaf0c5d02293d89dcf8581f6cf3418aff5d6d0c31
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1985338Reviewed-by: default avatarSammie Quon <sammiequon@chromium.org>
Commit-Queue: Avery Musbach <amusbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#728072}
parent d4992c6f
...@@ -248,6 +248,12 @@ gfx::Rect GetWidgetBoundsInRoot(views::Widget* widget) { ...@@ -248,6 +248,12 @@ gfx::Rect GetWidgetBoundsInRoot(views::Widget* widget) {
return window->GetBoundsInRootWindow(); return window->GetBoundsInRootWindow();
} }
bool ShouldExcludeItemFromGridLayout(
OverviewItem* item,
const base::flat_set<OverviewItem*>& ignored_items) {
return item->animating_to_close() || ignored_items.contains(item);
}
} // namespace } // namespace
// The class to observe the overview window that the dragged tabs will merge // The class to observe the overview window that the dragged tabs will merge
...@@ -452,8 +458,7 @@ void OverviewGrid::PositionWindows( ...@@ -452,8 +458,7 @@ void OverviewGrid::PositionWindows(
for (size_t i = 0; i < window_list_.size(); ++i) { for (size_t i = 0; i < window_list_.size(); ++i) {
OverviewItem* window_item = window_list_[i].get(); OverviewItem* window_item = window_list_[i].get();
if (window_item->animating_to_close() || if (ShouldExcludeItemFromGridLayout(window_item, ignored_items)) {
ignored_items.contains(window_item)) {
rects[i].SetRect(0, 0, 0, 0); rects[i].SetRect(0, 0, 0, 0);
continue; continue;
} }
...@@ -1699,7 +1704,7 @@ std::vector<gfx::RectF> OverviewGrid::GetWindowRectsForTabletModeLayout( ...@@ -1699,7 +1704,7 @@ std::vector<gfx::RectF> OverviewGrid::GetWindowRectsForTabletModeLayout(
// that the items are always aligned left or right. // that the items are always aligned left or right.
float rightmost_window_right = 0; float rightmost_window_right = 0;
for (const auto& item : window_list_) { for (const auto& item : window_list_) {
if (item->animating_to_close() || ignored_items.contains(item.get())) if (ShouldExcludeItemFromGridLayout(item.get(), ignored_items))
continue; continue;
rightmost_window_right = rightmost_window_right =
std::max(rightmost_window_right, item->target_bounds().right()); std::max(rightmost_window_right, item->target_bounds().right());
...@@ -1729,7 +1734,7 @@ std::vector<gfx::RectF> OverviewGrid::GetWindowRectsForTabletModeLayout( ...@@ -1729,7 +1734,7 @@ std::vector<gfx::RectF> OverviewGrid::GetWindowRectsForTabletModeLayout(
std::vector<gfx::RectF> rects; std::vector<gfx::RectF> rects;
for (size_t i = 0; i < window_list_.size(); ++i) { for (size_t i = 0; i < window_list_.size(); ++i) {
OverviewItem* item = window_list_[i].get(); OverviewItem* item = window_list_[i].get();
if (item->animating_to_close() || ignored_items.contains(item)) { if (ShouldExcludeItemFromGridLayout(item, ignored_items)) {
rects.push_back(gfx::RectF()); rects.push_back(gfx::RectF());
continue; continue;
} }
...@@ -1782,10 +1787,8 @@ bool OverviewGrid::FitWindowRectsInBounds( ...@@ -1782,10 +1787,8 @@ bool OverviewGrid::FitWindowRectsInBounds(
// All elements are of same height and only the height is necessary to // All elements are of same height and only the height is necessary to
// determine each item's scale. // determine each item's scale.
for (size_t i = 0u; i < window_count; ++i) { for (size_t i = 0u; i < window_count; ++i) {
if (window_list_[i]->animating_to_close() || if (ShouldExcludeItemFromGridLayout(window_list_[i].get(), ignored_items))
ignored_items.contains(window_list_[i].get())) {
continue; continue;
}
int width = int width =
CalculateWidthAndMaybeSetUnclippedBounds(window_list_[i].get(), height); CalculateWidthAndMaybeSetUnclippedBounds(window_list_[i].get(), height);
......
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