Created
February 1, 2026 22:52
-
-
Save hjanuschka/cd56373cab10de84069777bb5c4edd12 to your computer and use it in GitHub Desktop.
Fix bubble positioning in app windows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Fix bubble positioning in app windows | |
| When the toolbar isn't visible (e.g., --app mode), fall back to anchoring | |
| bubbles to the contents view and reposition them to the top-right corner. | |
| --- | |
| diff --git a/chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view.cc b/chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view.cc | |
| index 01a5846cd6d9d..203c9c56c9b8a 100644 | |
| --- a/chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view.cc | |
| +++ b/chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view.cc | |
| @@ -138,6 +138,21 @@ void LocationBarBubbleDelegateView::ShowForReason(DisplayReason reason, | |
| GetBubbleFrameView()->SetPreferredArrowAdjustment( | |
| views::BubbleFrameView::PreferredArrowAdjustment::kOffset); | |
| + // When the anchor view is the contents web view (fallback when toolbar isn't | |
| + // visible, e.g., in app windows), reposition the bubble to the top-right | |
| + // corner of the window instead of anchoring to the full contents area. | |
| + if (auto* anchor_view = GetAnchorView()) { | |
| + if (auto* widget = anchor_view->GetWidget()) { | |
| + if (auto* browser_view = BrowserView::GetBrowserViewForNativeWindow( | |
| + widget->GetNativeWindow())) { | |
| + if (anchor_view == browser_view->contents_web_view()) { | |
| + SetAnchorView(nullptr); | |
| + AdjustForFullscreen(widget->GetWindowBoundsInScreen()); | |
| + } | |
| + } | |
| + } | |
| + } | |
| + | |
| if (reason == USER_GESTURE) { | |
| GetWidget()->Show(); | |
| } else { | |
| diff --git a/chrome/browser/ui/views/toolbar/toolbar_view.cc b/chrome/browser/ui/views/toolbar/toolbar_view.cc | |
| index 85b5fd39dfb5a..27176a3177451 100644 | |
| --- a/chrome/browser/ui/views/toolbar/toolbar_view.cc | |
| +++ b/chrome/browser/ui/views/toolbar/toolbar_view.cc | |
| @@ -1090,6 +1090,15 @@ views::View* ToolbarView::GetAnchorView( | |
| views::BubbleAnchor ToolbarView::GetBubbleAnchor( | |
| std::optional<actions::ActionId> action_id) { | |
| if (views::View* view = GetAnchorView(action_id)) { | |
| + // In some window modes (notably app windows) the location bar might exist | |
| + // as a View but not be drawn. Anchoring bubbles to a non-drawn view can | |
| + // result in invalid bubble bounds (e.g. on Ozone/Wayland). | |
| + // | |
| + // Fall back to anchoring to the contents view in that case. | |
| + if (!view->IsDrawn() && browser_view_ && | |
| + browser_view_->contents_web_view()) { | |
| + return browser_view_->contents_web_view(); | |
| + } | |
| return view; | |
| } | |
| return nullptr; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment