refactor: make NativeWindow::transparent_ const (#47172)

* refactor: use in-class member initialization for NativeWindow::widget_

* refactor: make NativeWindow::transparent_ const

refactor: make NativeWindow::enable_larger_than_screen_ const

* chore: make linter happy after rebase
This commit is contained in:
Charles Kerr
2025-05-21 12:42:08 -05:00
committed by GitHub
parent a7a3e10300
commit 4af0c5d762
2 changed files with 16 additions and 12 deletions

View File

@@ -97,10 +97,11 @@ gfx::Size GetExpandedWindowSize(const NativeWindow* window, gfx::Size size) {
NativeWindow::NativeWindow(const gin_helper::Dictionary& options,
NativeWindow* parent)
: widget_(std::make_unique<views::Widget>()), parent_(parent) {
: transparent_{options.ValueOrDefault(options::kTransparent, false)},
enable_larger_than_screen_{
options.ValueOrDefault(options::kEnableLargerThanScreen, false)},
parent_{parent} {
options.Get(options::kFrame, &has_frame_);
options.Get(options::kTransparent, &transparent_);
options.Get(options::kEnableLargerThanScreen, &enable_larger_than_screen_);
options.Get(options::kTitleBarStyle, &title_bar_style_);
#if BUILDFLAG(IS_WIN)
options.Get(options::kBackgroundMaterial, &background_material_);

View File

@@ -399,8 +399,11 @@ class NativeWindow : public base::SupportsUserData,
[[nodiscard]] bool has_client_frame() const { return has_client_frame_; }
bool transparent() const { return transparent_; }
bool enable_larger_than_screen() const { return enable_larger_than_screen_; }
[[nodiscard]] bool transparent() const { return transparent_; }
[[nodiscard]] bool enable_larger_than_screen() const {
return enable_larger_than_screen_;
}
NativeWindow* parent() const { return parent_; }
bool is_modal() const { return is_modal_; }
@@ -482,11 +485,17 @@ class NativeWindow : public base::SupportsUserData,
private:
static bool PlatformHasClientFrame();
std::unique_ptr<views::Widget> widget_;
std::unique_ptr<views::Widget> widget_ = std::make_unique<views::Widget>();
static inline int32_t next_id_ = 0;
const int32_t window_id_ = ++next_id_;
// Whether window is transparent.
const bool transparent_;
// Whether window can be resized larger than screen.
const bool enable_larger_than_screen_;
// The content view, weak ref.
raw_ptr<views::View> content_view_ = nullptr;
@@ -502,12 +511,6 @@ class NativeWindow : public base::SupportsUserData,
// Wayland hosts.
const bool has_client_frame_ = PlatformHasClientFrame();
// Whether window is transparent.
bool transparent_ = false;
// Whether window can be resized larger than screen.
bool enable_larger_than_screen_ = false;
// The windows has been closed.
bool is_closed_ = false;