From 506a7e9b3b3be0862f48e0a251716b3a8696d6df Mon Sep 17 00:00:00 2001 From: Ethan Huang <69299174+chingweih@users.noreply.github.com> Date: Sun, 28 Dec 2025 13:29:28 +0800 Subject: [PATCH 1/5] helium/ui: reduce side panel minimum width --- patches/helium/ui/side-panel-minimum-width.patch | 11 +++++++++++ patches/series | 2 ++ 2 files changed, 13 insertions(+) create mode 100644 patches/helium/ui/side-panel-minimum-width.patch diff --git a/patches/helium/ui/side-panel-minimum-width.patch b/patches/helium/ui/side-panel-minimum-width.patch new file mode 100644 index 000000000..6bf39f325 --- /dev/null +++ b/patches/helium/ui/side-panel-minimum-width.patch @@ -0,0 +1,11 @@ +--- a/chrome/browser/ui/views/side_panel/side_panel_entry.h ++++ b/chrome/browser/ui/views/side_panel/side_panel_entry.h +@@ -39,7 +39,7 @@ class SidePanelEntry final : public ui:: + }; + + // The default and minimum acceptable side panel content width. +- static constexpr int kSidePanelDefaultContentWidth = 360; ++ static constexpr int kSidePanelDefaultContentWidth = 260; + using CreateContentCallback = + base::RepeatingCallback( + SidePanelEntryScope&)>; diff --git a/patches/series b/patches/series index 5d8064460..0ff7e9f09 100644 --- a/patches/series +++ b/patches/series @@ -272,3 +272,5 @@ helium/ui/find-bar.patch helium/ui/remove-zoom-action.patch helium/ui/experiments/compact-action-toolbar.patch helium/ui/pdf-viewer.patch +helium/ui/side-panel-minimum-width.patch + From 02857257c8760d73fdb98eb41ddee2dd7dbb5391 Mon Sep 17 00:00:00 2001 From: Ethan Huang <69299174+chingweih@users.noreply.github.com> Date: Thu, 1 Jan 2026 16:47:11 +0800 Subject: [PATCH 2/5] fix: implement minimum width change by introducing a new variable instead of changing the default width --- .../helium/ui/side-panel-minimum-width.patch | 22 +++++++++++++++---- patches/series | 1 - 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/patches/helium/ui/side-panel-minimum-width.patch b/patches/helium/ui/side-panel-minimum-width.patch index 6bf39f325..62f268f19 100644 --- a/patches/helium/ui/side-panel-minimum-width.patch +++ b/patches/helium/ui/side-panel-minimum-width.patch @@ -1,11 +1,25 @@ +--- a/chrome/browser/ui/views/side_panel/side_panel.cc ++++ b/chrome/browser/ui/views/side_panel/side_panel.cc +@@ -444,7 +444,7 @@ bool SidePanel::IsRightAligned() const { + gfx::Size SidePanel::GetMinimumSize() const { + const int min_height = 0; + return gfx::Size( +- SidePanelEntry::kSidePanelDefaultContentWidth + GetBorderInsets().width(), ++ SidePanelEntry::kSidePanelMinimumContentWidth + GetBorderInsets().width(), + min_height); + } + --- a/chrome/browser/ui/views/side_panel/side_panel_entry.h +++ b/chrome/browser/ui/views/side_panel/side_panel_entry.h -@@ -39,7 +39,7 @@ class SidePanelEntry final : public ui:: +@@ -38,8 +38,10 @@ class SidePanelEntry final : public ui:: + kToolbar, }; - // The default and minimum acceptable side panel content width. -- static constexpr int kSidePanelDefaultContentWidth = 360; -+ static constexpr int kSidePanelDefaultContentWidth = 260; +- // 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( SidePanelEntryScope&)>; diff --git a/patches/series b/patches/series index 0ff7e9f09..367a3e4b4 100644 --- a/patches/series +++ b/patches/series @@ -273,4 +273,3 @@ helium/ui/remove-zoom-action.patch helium/ui/experiments/compact-action-toolbar.patch helium/ui/pdf-viewer.patch helium/ui/side-panel-minimum-width.patch - From 0b58449525e092fd51e1660806085100b6619260 Mon Sep 17 00:00:00 2001 From: Ethan Huang <69299174+chingweih@users.noreply.github.com> Date: Thu, 1 Jan 2026 16:52:07 +0800 Subject: [PATCH 3/5] chore: merge side-panel-minimum-width patch to side-panel --- .../helium/ui/side-panel-minimum-width.patch | 25 ------------------ patches/helium/ui/side-panel.patch | 26 +++++++++++++++++++ patches/series | 1 - 3 files changed, 26 insertions(+), 26 deletions(-) delete mode 100644 patches/helium/ui/side-panel-minimum-width.patch diff --git a/patches/helium/ui/side-panel-minimum-width.patch b/patches/helium/ui/side-panel-minimum-width.patch deleted file mode 100644 index 62f268f19..000000000 --- a/patches/helium/ui/side-panel-minimum-width.patch +++ /dev/null @@ -1,25 +0,0 @@ ---- a/chrome/browser/ui/views/side_panel/side_panel.cc -+++ b/chrome/browser/ui/views/side_panel/side_panel.cc -@@ -444,7 +444,7 @@ bool SidePanel::IsRightAligned() const { - gfx::Size SidePanel::GetMinimumSize() const { - const int min_height = 0; - return gfx::Size( -- SidePanelEntry::kSidePanelDefaultContentWidth + GetBorderInsets().width(), -+ SidePanelEntry::kSidePanelMinimumContentWidth + GetBorderInsets().width(), - min_height); - } - ---- 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( - SidePanelEntryScope&)>; diff --git a/patches/helium/ui/side-panel.patch b/patches/helium/ui/side-panel.patch index d830f3c1b..f22b4b333 100644 --- a/patches/helium/ui/side-panel.patch +++ b/patches/helium/ui/side-panel.patch @@ -64,3 +64,29 @@ } } + // 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 + @@ -444,7 +444,7 @@ bool SidePanel::IsRightAligned() const { + gfx::Size SidePanel::GetMinimumSize() const { + const int min_height = 0; + return gfx::Size( + - SidePanelEntry::kSidePanelDefaultContentWidth + GetBorderInsets().width(), + + SidePanelEntry::kSidePanelMinimumContentWidth + GetBorderInsets().width(), + min_height); + } + + --- 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( + SidePanelEntryScope&)>; diff --git a/patches/series b/patches/series index 367a3e4b4..5d8064460 100644 --- a/patches/series +++ b/patches/series @@ -272,4 +272,3 @@ helium/ui/find-bar.patch helium/ui/remove-zoom-action.patch helium/ui/experiments/compact-action-toolbar.patch helium/ui/pdf-viewer.patch -helium/ui/side-panel-minimum-width.patch From 0e626157c7662170c6ea560e2726045ca5dc30ee Mon Sep 17 00:00:00 2001 From: Ethan Huang <69299174+chingweih@users.noreply.github.com> Date: Thu, 1 Jan 2026 17:10:25 +0800 Subject: [PATCH 4/5] feat: implement side panel snap to default width on resizing --- patches/helium/ui/side-panel.patch | 43 ++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/patches/helium/ui/side-panel.patch b/patches/helium/ui/side-panel.patch index f22b4b333..9f3517304 100644 --- a/patches/helium/ui/side-panel.patch +++ b/patches/helium/ui/side-panel.patch @@ -67,15 +67,44 @@ // 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 - @@ -444,7 +444,7 @@ bool SidePanel::IsRightAligned() const { + @@ -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 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::kSidePanelDefaultContentWidth + GetBorderInsets().width(), + 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:: @@ -90,3 +119,13 @@ using CreateContentCallback = base::RepeatingCallback( 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) { From 82766b8f0ec516c516ac9d3c0e959a910806ef84 Mon Sep 17 00:00:00 2001 From: Ethan Huang <69299174+chingweih@users.noreply.github.com> Date: Fri, 2 Jan 2026 00:50:25 +0800 Subject: [PATCH 5/5] fix: update indents --- patches/helium/ui/side-panel.patch | 130 ++++++++++++++--------------- 1 file changed, 65 insertions(+), 65 deletions(-) diff --git a/patches/helium/ui/side-panel.patch b/patches/helium/ui/side-panel.patch index 9f3517304..0244b3ffb 100644 --- a/patches/helium/ui/side-panel.patch +++ b/patches/helium/ui/side-panel.patch @@ -64,68 +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 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( - 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) { +// 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 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( + 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) {