Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: ash/wm/workspace/workspace_window_resizer.cc

Issue 1366123002: Cleanup: IWYU for base/gtest_prod_util.h. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gtest_iwyu
Patch Set: more lint Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/wm/workspace/workspace_window_resizer.h" 5 #include "ash/wm/workspace/workspace_window_resizer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 : size_(size), 271 : size_(size),
272 min_(min), 272 min_(min),
273 max_(max) { 273 max_(max) {
274 // Grow the min/max bounds to include the starting size. 274 // Grow the min/max bounds to include the starting size.
275 if (is_underflowing()) 275 if (is_underflowing())
276 min_ = size_; 276 min_ = size_;
277 if (is_overflowing()) 277 if (is_overflowing())
278 max_ = size_; 278 max_ = size_;
279 } 279 }
280 280
281 bool is_at_capacity(bool shrinking) { 281 bool is_at_capacity(bool shrinking) const {
282 return size_ == (shrinking ? min_ : max_); 282 return size_ == (shrinking ? min_ : max_);
283 } 283 }
284 284
285 int size() const { 285 int size() const {
286 return size_; 286 return size_;
287 } 287 }
288 288
289 bool has_min() const { 289 bool has_min() const {
290 return min_ != 0; 290 return min_ != 0;
291 } 291 }
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 if (total_initial_size_ >= available_size) 623 if (total_initial_size_ >= available_size)
624 grow_attached_by = available_size - total_initial_size_; 624 grow_attached_by = available_size - total_initial_size_;
625 } else { 625 } else {
626 // If we're shrinking, we grow the attached so the total size remains 626 // If we're shrinking, we grow the attached so the total size remains
627 // constant. 627 // constant.
628 grow_attached_by = -delta; 628 grow_attached_by = -delta;
629 } 629 }
630 630
631 int leftover_pixels = 0; 631 int leftover_pixels = 0;
632 while (grow_attached_by != 0) { 632 while (grow_attached_by != 0) {
633 int leftovers = GrowFairly(grow_attached_by, window_sizes); 633 int leftovers = GrowFairly(grow_attached_by, &window_sizes);
634 if (leftovers == grow_attached_by) { 634 if (leftovers == grow_attached_by) {
635 leftover_pixels = leftovers; 635 leftover_pixels = leftovers;
636 break; 636 break;
637 } 637 }
638 grow_attached_by = leftovers; 638 grow_attached_by = leftovers;
639 } 639 }
640 640
641 for (size_t i = 0; i < window_sizes.size(); ++i) 641 for (size_t i = 0; i < window_sizes.size(); ++i)
642 sizes->push_back(window_sizes[i].size()); 642 sizes->push_back(window_sizes[i].size());
643 643
644 return leftover_pixels; 644 return leftover_pixels;
645 } 645 }
646 646
647 int WorkspaceWindowResizer::GrowFairly( 647 int WorkspaceWindowResizer::GrowFairly(int pixels,
648 int pixels, 648 std::vector<WindowSize>* sizes) const {
649 std::vector<WindowSize>& sizes) const {
650 bool shrinking = pixels < 0; 649 bool shrinking = pixels < 0;
651 std::vector<WindowSize*> nonfull_windows; 650 std::vector<WindowSize*> nonfull_windows;
652 for (size_t i = 0; i < sizes.size(); ++i) { 651 for (size_t i = 0; i < sizes->size(); ++i) {
653 if (!sizes[i].is_at_capacity(shrinking)) 652 WindowSize& current_window_size = (*sizes)[i];
654 nonfull_windows.push_back(&sizes[i]); 653 if (!current_window_size.is_at_capacity(shrinking))
654 nonfull_windows.push_back(&current_window_size);
655 } 655 }
656 std::vector<float> ratios; 656 std::vector<float> ratios;
657 CalculateGrowthRatios(nonfull_windows, &ratios); 657 CalculateGrowthRatios(nonfull_windows, &ratios);
658 658
659 int remaining_pixels = pixels; 659 int remaining_pixels = pixels;
660 bool add_leftover_pixels_to_last = true; 660 bool add_leftover_pixels_to_last = true;
661 for (size_t i = 0; i < nonfull_windows.size(); ++i) { 661 for (size_t i = 0; i < nonfull_windows.size(); ++i) {
662 int grow_by = pixels * ratios[i]; 662 int grow_by = pixels * ratios[i];
663 // Put any leftover pixels into the last window. 663 // Put any leftover pixels into the last window.
664 if (i == nonfull_windows.size() - 1 && add_leftover_pixels_to_last) 664 if (i == nonfull_windows.size() - 1 && add_leftover_pixels_to_last)
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED); 1055 snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED);
1056 gfx::Rect snapped_bounds = ScreenUtil::GetDisplayWorkAreaBoundsInParent( 1056 gfx::Rect snapped_bounds = ScreenUtil::GetDisplayWorkAreaBoundsInParent(
1057 GetTarget()); 1057 GetTarget());
1058 if (snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED) 1058 if (snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED)
1059 snapped_bounds.set_x(snapped_bounds.right() - bounds_in_parent.width()); 1059 snapped_bounds.set_x(snapped_bounds.right() - bounds_in_parent.width());
1060 snapped_bounds.set_width(bounds_in_parent.width()); 1060 snapped_bounds.set_width(bounds_in_parent.width());
1061 return bounds_in_parent == snapped_bounds; 1061 return bounds_in_parent == snapped_bounds;
1062 } 1062 }
1063 1063
1064 } // namespace ash 1064 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace/workspace_window_resizer.h ('k') | base/memory/memory_pressure_monitor_chromeos.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698