mac fullscreen: reparent web dialogs on entering and exiting fullscreen
Web dialogs will be occluded by the toolbar if they are created before entering fullscreen. This is because the dialogs are children of the browser window, which is behind the overlay widget. This CL fixes the issue by: * Add a kWidgetIdentifierKey native widget property to widgets. * Mark constrained windows (e.g. web dialogs) using kWidgetIdentifierKey. * Reparent constrained windows to overlay window when entering fullscreen. kWidgetIdentifierKey would allow identifying a widget more easily. It decouples the code that creates a widget from the code that wants to identify a widget. Bug: 1469898, 1476502 Change-Id: I379fa9da7d11c21dd8d1e00e9e808e9673ab9540 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4823250 Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com> Commit-Queue: Keren Zhu <kerenzhu@chromium.org> Reviewed-by: Avi Drissman <avi@chromium.org> Reviewed-by: Leonard Grey <lgrey@chromium.org> Cr-Commit-Position: refs/heads/main@{#1190204}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
4722858475
commit
8dba40691c
chrome/browser/ui/views/frame
components/constrained_window
ui/views/widget
@ -25,6 +25,7 @@
|
||||
#include "chrome/browser/ui/web_applications/app_browser_controller.h"
|
||||
#include "chrome/common/chrome_features.h"
|
||||
#include "chrome/common/pref_names.h"
|
||||
#include "components/constrained_window/constrained_window_views.h"
|
||||
#include "ui/gfx/geometry/insets.h"
|
||||
#include "ui/gfx/geometry/rect.h"
|
||||
#include "ui/gfx/geometry/size.h"
|
||||
@ -34,6 +35,7 @@
|
||||
#include "ui/views/focus/focus_manager.h"
|
||||
#include "ui/views/focus/focus_search.h"
|
||||
#include "ui/views/view_observer.h"
|
||||
#include "ui/views/widget/native_widget.h"
|
||||
#include "ui/views/widget/widget.h"
|
||||
|
||||
namespace {
|
||||
@ -498,6 +500,11 @@ bool ImmersiveModeControllerMac::ShouldMoveChild(views::Widget* child) {
|
||||
}
|
||||
}
|
||||
|
||||
if (child->GetNativeWindowProperty(views::kWidgetIdentifierKey) ==
|
||||
constrained_window::kConstrainedWindowWidgetIdentifier) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Widgets that have an anchor view contained within top chrome should be
|
||||
// reparented.
|
||||
views::WidgetDelegate* widget_delegate = child->widget_delegate();
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "ui/display/display.h"
|
||||
#include "ui/display/screen.h"
|
||||
#include "ui/views/bubble/bubble_dialog_model_host.h"
|
||||
#include "ui/views/widget/native_widget.h"
|
||||
#include "ui/views/widget/widget.h"
|
||||
#include "ui/views/widget/widget_observer.h"
|
||||
#include "ui/views/window/dialog_delegate.h"
|
||||
@ -32,6 +33,9 @@ using web_modal::ModalDialogHost;
|
||||
using web_modal::ModalDialogHostObserver;
|
||||
|
||||
namespace constrained_window {
|
||||
|
||||
const void* kConstrainedWindowWidgetIdentifier = "ConstrainedWindowWidget";
|
||||
|
||||
namespace {
|
||||
|
||||
// Storage access for the currently active ConstrainedWindowViewsClient.
|
||||
@ -213,9 +217,14 @@ views::Widget* CreateWebModalDialogViews(views::WidgetDelegate* dialog,
|
||||
<< ", scheme=" << url.scheme_piece() << ", host=" << url.host_piece();
|
||||
}
|
||||
|
||||
return views::DialogDelegate::CreateDialogWidget(
|
||||
views::Widget* widget = views::DialogDelegate::CreateDialogWidget(
|
||||
dialog, nullptr,
|
||||
manager->delegate()->GetWebContentsModalDialogHost()->GetHostView());
|
||||
widget->SetNativeWindowProperty(
|
||||
views::kWidgetIdentifierKey,
|
||||
const_cast<void*>(kConstrainedWindowWidgetIdentifier));
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
views::Widget* CreateBrowserModalDialogViews(
|
||||
@ -234,6 +243,9 @@ views::Widget* CreateBrowserModalDialogViews(views::DialogDelegate* dialog,
|
||||
parent ? CurrentClient()->GetDialogHostView(parent) : nullptr;
|
||||
views::Widget* widget =
|
||||
views::DialogDelegate::CreateDialogWidget(dialog, nullptr, parent_view);
|
||||
widget->SetNativeWindowProperty(
|
||||
views::kWidgetIdentifierKey,
|
||||
const_cast<void*>(kConstrainedWindowWidgetIdentifier));
|
||||
|
||||
bool requires_positioning = dialog->use_custom_frame();
|
||||
|
||||
|
@ -31,6 +31,8 @@ class WebContentsModalDialogHost;
|
||||
|
||||
namespace constrained_window {
|
||||
|
||||
extern const void* kConstrainedWindowWidgetIdentifier;
|
||||
|
||||
class ConstrainedWindowViewsClient;
|
||||
|
||||
// Sets the ConstrainedWindowClient impl.
|
||||
|
@ -11,6 +11,9 @@ namespace views {
|
||||
|
||||
class Widget;
|
||||
|
||||
// Used with Widget::GetNativeWindowProperty() to identify a widget.
|
||||
VIEWS_EXPORT extern const char kWidgetIdentifierKey[];
|
||||
|
||||
namespace internal {
|
||||
class NativeWidgetPrivate;
|
||||
}
|
||||
|
@ -8,7 +8,11 @@
|
||||
#include "ui/display/display.h"
|
||||
#include "ui/display/screen.h"
|
||||
|
||||
namespace views::internal {
|
||||
namespace views {
|
||||
|
||||
const char kWidgetIdentifierKey[] = "kWidgetIdentifierKey";
|
||||
|
||||
namespace internal {
|
||||
|
||||
// static
|
||||
gfx::Rect NativeWidgetPrivate::ConstrainBoundsToDisplayWorkArea(
|
||||
@ -31,4 +35,6 @@ bool NativeWidgetPrivate::IsMoveLoopSupported() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace views::internal
|
||||
} // namespace internal
|
||||
|
||||
} // namespace views
|
||||
|
Reference in New Issue
Block a user