Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions patches/helium/ui/side-panel.patch
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,68 @@
}
}

// Reduce minimum acceptable side panel content width without changing the default size.
--- a/chrome/browser/ui/views/side_panel/side_panel.cc
+++ b/chrome/browser/ui/views/side_panel/side_panel.cc
@@ -419,8 +419,7 @@ void SidePanel::UpdateWidthOnEntryChange
// 1. Use the user's manually resized width
// 2. Use the side panels default width
// NOTE: If not specified, the side panel will default to
- // SidePanelEntry::kSidePanelDefaultContentWidth which evaluates to the same
- // value as GetMinimumSize().
+ // SidePanelEntry::kSidePanelDefaultContentWidth
if (std::optional<int> width_from_pref = dict.FindInt(panel_id)) {
SetPanelWidth(width_from_pref.value());
} else {
@@ -444,6 +443,13 @@ bool SidePanel::IsRightAligned() const {
gfx::Size SidePanel::GetMinimumSize() const {
const int min_height = 0;
return gfx::Size(
+ SidePanelEntry::kSidePanelMinimumContentWidth + GetBorderInsets().width(),
+ min_height);
+}
+
+gfx::Size SidePanel::GetDefaultSize() const {
+ const int min_height = 0;
+ return gfx::Size(
SidePanelEntry::kSidePanelDefaultContentWidth + GetBorderInsets().width(),
min_height);
}
@@ -614,6 +620,13 @@ void SidePanel::OnResize(int resize_amou
proposed_width = minimum_width;
}

+ // Snap to default_width if the proposed_width is close enough.
+ const int default_width = GetDefaultSize().width();
+ const int snap_diff = 20;
+ if (abs(proposed_width - default_width) < snap_diff) {
+ proposed_width = default_width;
+ }
+
if (width() != proposed_width) {
if (SidePanelUI* side_panel_ui =
browser_view_->browser()->GetFeatures().side_panel_ui()) {
--- a/chrome/browser/ui/views/side_panel/side_panel_entry.h
+++ b/chrome/browser/ui/views/side_panel/side_panel_entry.h
@@ -38,8 +38,10 @@ class SidePanelEntry final : public ui::
kToolbar,
};

- // The default and minimum acceptable side panel content width.
+ // The default side panel content width.
static constexpr int kSidePanelDefaultContentWidth = 360;
+ // The minimum acceptable side panel content width
+ static constexpr int kSidePanelMinimumContentWidth = 260;
using CreateContentCallback =
base::RepeatingCallback<std::unique_ptr<views::View>(
SidePanelEntryScope&)>;
--- a/chrome/browser/ui/views/side_panel/side_panel.h
+++ b/chrome/browser/ui/views/side_panel/side_panel.h
@@ -51,6 +51,7 @@ class SidePanel : public views::Accessib
HorizontalAlignment GetHorizontalAlignment() const;
bool IsRightAligned() const;
gfx::Size GetMinimumSize() const override;
+ gfx::Size GetDefaultSize() const;
bool IsClosing();
void DisableAnimationsForTesting() { animations_disabled_ = true; }
void SetKeyboardResized(bool keyboard_resized) {