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