Commit 73f2b808 authored by Dana Fried's avatar Dana Fried Committed by Commit Bot

Make all LocationBarBubbleDelegateViews adjust on-screen if possible.

Thanks to corising@chromium.org we have previously made special cases
for a number of bubbles of this type to prefer offsetting rather than
mirroring, as mirroring can't fix certain cases where the anchor is
off-screen (e.g. in immersive mode, or when the browser window is
partially off-screen).

This makes the fix universal for almost all bubbles anchored to the
toolbar and location bar.

Bug: 1065327
Change-Id: I62e7b060ed20fb6bfa49ec38a2f4b2b1803bedd3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2125468
Commit-Queue: Dana Fried <dfried@chromium.org>
Reviewed-by: default avatarCaroline Rising <corising@chromium.org>
Cr-Commit-Position: refs/heads/master@{#755042}
parent f9c714a5
......@@ -64,23 +64,21 @@ LocationBarBubbleDelegateView::~LocationBarBubbleDelegateView() = default;
void LocationBarBubbleDelegateView::ShowForReason(DisplayReason reason,
bool allow_refocus_alert) {
if (web_contents()) {
Browser* browser = chrome::FindBrowserWithWebContents(web_contents());
if (browser && base::FeatureList::IsEnabled(
autofill::features::kAutofillEnableToolbarStatusChip)) {
ToolbarAccountIconContainerView* toolbar_account_icon_container =
BrowserView::GetBrowserViewForBrowser(browser)
->toolbar()
->toolbar_account_icon_container();
if (toolbar_account_icon_container &&
toolbar_account_icon_container->Contains(GetAnchorView())) {
// These must be set after the bubble is created.
set_adjust_if_offscreen(true);
GetBubbleFrameView()->set_preferred_arrow_adjustment(
views::BubbleFrameView::PreferredArrowAdjustment::kOffset);
}
}
}
// These bubbles all anchor to the location bar or toolbar. We selectively
// anchor location bar bubbles to one end or the other of the toolbar based on
// whether their normal anchor point is visible. However, if part or all of
// the toolbar is off-screen, we should ajust the bubbles so that they are
// visible on the screen and not cut off.
//
// Note: These must be set after the bubble is created.
// Note also: |set_adjust_if_offscreen| is disabled by default on some
// platforms for arbitrary dialog bubbles to be consistent with platform
// standards, however in this case there is no good reason not to ensure the
// bubbles are displayed on-screen.
set_adjust_if_offscreen(true);
GetBubbleFrameView()->set_preferred_arrow_adjustment(
views::BubbleFrameView::PreferredArrowAdjustment::kOffset);
if (reason == USER_GESTURE) {
GetWidget()->Show();
} else {
......
......@@ -189,8 +189,6 @@ views::Widget* TranslateBubbleView::ShowBubble(
view->SetHighlightedButton(highlighted_button);
views::Widget* bubble_widget =
views::BubbleDialogDelegateView::CreateBubble(view);
view->GetBubbleFrameView()->set_preferred_arrow_adjustment(
views::BubbleFrameView::PreferredArrowAdjustment::kOffset);
// TAB UI has the same view throughout. Select the right tab based on |step|
// upon initialization.
......
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