views: use CalculatePreferredSize(SizeBounds) in ['/ash/wm/window_cycle', '/ash/wm'].
In order to ensure implementation consistency and avoid oversights, we should unify CalculatePreferredSize() and GetHeightForWidth(). Replace them with the CalculatePreferredSize(SizeBounds) overload. This CL was uploaded by git cl split. Bug: 40232718 Change-Id: Ia37fe8e7454ae67d4ca527456a3d3c4c5f84d757 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5467277 Reviewed-by: Mike Wasserman <msw@chromium.org> Commit-Queue: Weidong Liu <weidongliu@chromium.org> Reviewed-by: Sammie Quon <sammiequon@chromium.org> Cr-Commit-Position: refs/heads/main@{#1291670}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
fb279b6b67
commit
ae48c948e7
@@ -85,7 +85,7 @@ void WindowPreview::Layout(PassKey) {
|
||||
content_rect.y(), kCloseButtonSize, kCloseButtonSize));
|
||||
|
||||
const gfx::Size container_size = GetPreviewContainerSize();
|
||||
gfx::Size mirror_size = preview_view_->CalculatePreferredSize();
|
||||
gfx::Size mirror_size = preview_view_->CalculatePreferredSize({});
|
||||
float preview_ratio = static_cast<float>(mirror_size.width()) /
|
||||
static_cast<float>(mirror_size.height());
|
||||
|
||||
|
@@ -163,7 +163,8 @@ void WindowCycleItemView::Layout(PassKey) {
|
||||
source_window(), /*include_header_rounding=*/false)));
|
||||
}
|
||||
|
||||
gfx::Size WindowCycleItemView::CalculatePreferredSize() const {
|
||||
gfx::Size WindowCycleItemView::CalculatePreferredSize(
|
||||
const views::SizeBounds& available_size) const {
|
||||
// Previews can range in width from half to double of
|
||||
// |kFixedPreviewHeightDp|. Padding will be added to the
|
||||
// sides to achieve this if the preview is too narrow.
|
||||
|
@@ -50,7 +50,8 @@ class ASH_EXPORT WindowCycleItemView : public WindowMiniView {
|
||||
void Layout(PassKey) override;
|
||||
|
||||
// views::View:
|
||||
gfx::Size CalculatePreferredSize() const override;
|
||||
gfx::Size CalculatePreferredSize(
|
||||
const views::SizeBounds& available_size) const override;
|
||||
bool HandleAccessibleAction(const ui::AXActionData& action_data) override;
|
||||
|
||||
// WindowMiniViewBase:
|
||||
|
@@ -484,7 +484,7 @@ void WindowCycleList::Scroll(int offset) {
|
||||
|
||||
// The windows should not shift position when selecting when there's enough
|
||||
// room to display all windows.
|
||||
if (cycle_view_ && cycle_view_->CalculatePreferredSize().width() ==
|
||||
if (cycle_view_ && cycle_view_->CalculatePreferredSize({}).width() ==
|
||||
cycle_view_->CalculateMaxWidth()) {
|
||||
cycle_view_->ScrollToWindow(windows_[current_index_]);
|
||||
}
|
||||
|
@@ -553,7 +553,8 @@ int WindowCycleView::CalculateMaxWidth() const {
|
||||
2 * kBackgroundHorizontalInsetDp;
|
||||
}
|
||||
|
||||
gfx::Size WindowCycleView::CalculatePreferredSize() const {
|
||||
gfx::Size WindowCycleView::CalculatePreferredSize(
|
||||
const views::SizeBounds& available_size) const {
|
||||
gfx::Size size = GetContentContainerBounds().size();
|
||||
// `mirror_container_` can have window list that overflow out of the
|
||||
// screen, but the window cycle view with a bandshield, cropping the
|
||||
|
@@ -131,7 +131,8 @@ class ASH_EXPORT WindowCycleView : public views::WidgetDelegateView,
|
||||
int CalculateMaxWidth() const;
|
||||
|
||||
// views::WidgetDelegateView:
|
||||
gfx::Size CalculatePreferredSize() const override;
|
||||
gfx::Size CalculatePreferredSize(
|
||||
const views::SizeBounds& available_size) const override;
|
||||
void Layout(PassKey) override;
|
||||
|
||||
// ui::ImplicitAnimationObserver:
|
||||
|
@@ -67,7 +67,8 @@ void WindowMirrorView::OnWindowDestroying(aura::Window* window) {
|
||||
}
|
||||
}
|
||||
|
||||
gfx::Size WindowMirrorView::CalculatePreferredSize() const {
|
||||
gfx::Size WindowMirrorView::CalculatePreferredSize(
|
||||
const views::SizeBounds& available_size) const {
|
||||
return show_non_client_view_ ? source_->bounds().size()
|
||||
: GetClientAreaBounds().size();
|
||||
}
|
||||
|
@@ -50,7 +50,8 @@ class ASH_EXPORT WindowMirrorView : public views::View,
|
||||
void OnWindowDestroying(aura::Window* window) override;
|
||||
|
||||
// views::View:
|
||||
gfx::Size CalculatePreferredSize() const override;
|
||||
gfx::Size CalculatePreferredSize(
|
||||
const views::SizeBounds& available_size) const override;
|
||||
void Layout(PassKey) override;
|
||||
bool GetNeedsNotificationWhenVisibleBoundsChange() const override;
|
||||
void OnVisibleBoundsChanged() override;
|
||||
|
@@ -64,7 +64,8 @@ void WindowPreviewView::RecreatePreviews() {
|
||||
entry.second->RecreateMirrorLayers();
|
||||
}
|
||||
|
||||
gfx::Size WindowPreviewView::CalculatePreferredSize() const {
|
||||
gfx::Size WindowPreviewView::CalculatePreferredSize(
|
||||
const views::SizeBounds& available_size) const {
|
||||
// The preferred size of this view is the union of all the windows it is made
|
||||
// up of with, scaled to match the ratio of the main window to its mirror
|
||||
// view's preferred size.
|
||||
@@ -75,7 +76,7 @@ gfx::Size WindowPreviewView::CalculatePreferredSize() const {
|
||||
gfx::SizeF window_size(1.f, 1.f);
|
||||
auto it = mirror_views_.find(root);
|
||||
if (it != mirror_views_.end()) {
|
||||
window_size = gfx::SizeF(it->second->CalculatePreferredSize());
|
||||
window_size = gfx::SizeF(it->second->CalculatePreferredSize({}));
|
||||
if (window_size.IsEmpty())
|
||||
return gfx::Size(); // Avoids divide by zero below.
|
||||
}
|
||||
|
@@ -39,7 +39,8 @@ class ASH_EXPORT WindowPreviewView
|
||||
void RecreatePreviews();
|
||||
|
||||
// views::View:
|
||||
gfx::Size CalculatePreferredSize() const override;
|
||||
gfx::Size CalculatePreferredSize(
|
||||
const views::SizeBounds& available_size) const override;
|
||||
void Layout(PassKey) override;
|
||||
|
||||
// aura::client::TransientWindowClientObserver:
|
||||
|
@@ -138,7 +138,8 @@ class MultiWindowResizeController::ResizeView : public views::View {
|
||||
~ResizeView() override = default;
|
||||
|
||||
// views::View:
|
||||
gfx::Size CalculatePreferredSize() const override {
|
||||
gfx::Size CalculatePreferredSize(
|
||||
const views::SizeBounds& available_size) const override {
|
||||
const bool vert = direction_ == Direction::kLeftRight;
|
||||
return gfx::Size(vert ? kLongSide : kShortSide,
|
||||
vert ? kShortSide : kLongSide);
|
||||
|
Reference in New Issue
Block a user