refactor: use direct aggregation in NativeWindowViews (#38559)

* refactor: in NativeWindowViews, aggregate root_view_ directly

* refactor: in NativeWindowViews, aggregate keyboard_event_handler_ directly

* refactor: make NativeWindowClientView::window_ a raw_ref

Xref: https://chromium.googlesource.com/chromium/src/+/main/styleguide/c++/c++.md\#non_owning-pointers-in-class-fields

Prefer const raw_ref<T> whenever the held pointer will never be null

* chore: make lint happy
This commit is contained in:
Charles Kerr 2023-06-05 00:37:46 -05:00 committed by GitHub
parent 05db963f87
commit 83d023747c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 40 deletions

View file

@ -13,6 +13,8 @@
#include <vector>
#include "base/memory/raw_ptr.h"
#include "shell/browser/ui/views/root_view.h"
#include "ui/views/controls/webview/unhandled_keyboard_event_handler.h"
#include "ui/views/widget/widget_observer.h"
#if defined(USE_OZONE)
@ -28,14 +30,9 @@
#endif
namespace views {
class UnhandledKeyboardEventHandler;
}
namespace electron {
class GlobalMenuBarX11;
class RootView;
class WindowStateWatcher;
#if defined(USE_OZONE_PLATFORM_X11)
@ -251,7 +248,7 @@ class NativeWindowViews : public NativeWindow,
// Maintain window placement.
void MoveBehindTaskBarIfNeeded();
std::unique_ptr<RootView> root_view_;
RootView root_view_{this};
// The view should be focused by default.
raw_ptr<views::View> focused_view_ = nullptr;
@ -322,7 +319,7 @@ class NativeWindowViews : public NativeWindow,
#endif
// Handles unhandled keyboard messages coming back from the renderer process.
std::unique_ptr<views::UnhandledKeyboardEventHandler> keyboard_event_handler_;
views::UnhandledKeyboardEventHandler keyboard_event_handler_;
// Whether the window should be enabled based on user calls to SetEnabled()
bool is_enabled_ = true;