Commit bb7ba195 authored by Dana Fried's avatar Dana Fried Committed by Commit Bot

Fix bug in layout where min size > preferred caused visual issues.

If this size inversion happened in a flex layout with a flex rule that
causes drop-out below minimum size and the view reported a minimum size
larger than its preferred size it would never display.

This CL fixes both the general case and the specific inversion in
ExtensionsToolbarButton.

It was manifesting as the PWA window not having an extensions menu icon
icon in very specific cases.

I just want to say how DEEPLY FRUSTRATING this one was to track down :/

Will follow up by attempting to make code in flex_layout_types.cc a
DCHECK instead of set-to-min after branch (want to be safe now, will
actually try to find inversions later).

Bug: 1059677, 1057901
Change-Id: Icea2fd739260c91f7d390ec15b890257d9715ac3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2097134
Commit-Queue: Dana Fried <dfried@chromium.org>
Reviewed-by: default avatarCaroline Rising <corising@chromium.org>
Cr-Commit-Position: refs/heads/master@{#749227}
parent 0f6b1555
......@@ -47,6 +47,13 @@ gfx::Size ExtensionsToolbarButton::CalculatePreferredSize() const {
return extensions_container_->GetToolbarActionSize();
}
gfx::Size ExtensionsToolbarButton::GetMinimumSize() const {
const int icon_size = GetIconSize();
gfx::Size min_size(icon_size, icon_size);
min_size.SetToMin(GetPreferredSize());
return min_size;
}
void ExtensionsToolbarButton::OnBoundsChanged(
const gfx::Rect& previous_bounds) {
// Because this button is in a container and doesn't necessarily take up the
......
......@@ -27,6 +27,7 @@ class ExtensionsToolbarButton : public ToolbarButton,
private:
// ToolbarButton:
gfx::Size CalculatePreferredSize() const override;
gfx::Size GetMinimumSize() const override;
void OnBoundsChanged(const gfx::Rect& previous_bounds) override;
const char* GetClassName() const override;
......
......@@ -25,6 +25,12 @@ int InterpolateSize(MinimumFlexSizeRule minimum_size_rule,
int minimum_size,
int preferred_size,
int available_size) {
// A view may (mistakenly) report a minimum size larger than its preferred
// size. While in principle this shouldn't happen, by the time we've gotten
// here it's better to simply make sure the minimum and preferred don't
// cross.
minimum_size = std::min(minimum_size, preferred_size);
if (available_size < minimum_size) {
switch (minimum_size_rule) {
case MinimumFlexSizeRule::kScaleToZero:
......
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