refactor: remove some NativeWindow public API (#46919)

* refactor: make NativeWindow::titlebar_overlay_height_ private

* refactor: make NativeWindow::set_has_frame() protected

* refactor: remove NativeWindow::background_material()

It's only used once, in NativeWindow, so use |background_material_| directly.

* refactor: remove NativeWindow::vibrancy()

It's only used once, in a NativeWindow method, so use |vibrancy_| directly.

* refactor: unfriend api::BrowserView

It was added in Oct 2022 by 23d4a25 for access to protected NativeWindow
methods add_inspectable_view() and remove_inspectable_view().

That dependency was removed in Nov 2022 by 184ac2b, so BrowserView
doesn't need access to NativeWindow's private fields & methods anymore.

* refactor: make NativeWindow::ContentBoundsToWindowBounds() protected

refactor: make NativeWindow::WindowBoundsToContentBounds() protected
This commit is contained in:
Charles Kerr 2025-05-05 09:28:49 -05:00 committed by GitHub
commit 3362db0655
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 21 deletions

View file

@ -830,17 +830,14 @@ bool NativeWindow::IsTranslucent() const {
#if BUILDFLAG(IS_MAC) #if BUILDFLAG(IS_MAC)
// Windows with vibrancy set are translucent // Windows with vibrancy set are translucent
if (!vibrancy().empty()) { if (!vibrancy_.empty())
return true; return true;
}
#endif #endif
#if BUILDFLAG(IS_WIN) #if BUILDFLAG(IS_WIN)
// Windows with certain background materials may be translucent // Windows with certain background materials may be translucent
const std::string& bg_material = background_material(); if (!background_material_.empty() && background_material_ != "none")
if (!bg_material.empty() && bg_material != "none") {
return true; return true;
}
#endif #endif
return false; return false;

View file

@ -223,12 +223,8 @@ class NativeWindow : public base::SupportsUserData,
virtual void SetAutoHideCursor(bool auto_hide) {} virtual void SetAutoHideCursor(bool auto_hide) {}
// Vibrancy API // Vibrancy API
const std::string& vibrancy() const { return vibrancy_; }
virtual void SetVibrancy(const std::string& type, int duration); virtual void SetVibrancy(const std::string& type, int duration);
const std::string& background_material() const {
return background_material_;
}
virtual void SetBackgroundMaterial(const std::string& type); virtual void SetBackgroundMaterial(const std::string& type);
// Traffic Light API // Traffic Light API
@ -284,12 +280,6 @@ class NativeWindow : public base::SupportsUserData,
virtual void SetGTKDarkThemeEnabled(bool use_dark_theme) {} virtual void SetGTKDarkThemeEnabled(bool use_dark_theme) {}
// Converts between content bounds and window bounds.
virtual gfx::Rect ContentBoundsToWindowBounds(
const gfx::Rect& bounds) const = 0;
virtual gfx::Rect WindowBoundsToContentBounds(
const gfx::Rect& bounds) const = 0;
base::WeakPtr<NativeWindow> GetWeakPtr() { base::WeakPtr<NativeWindow> GetWeakPtr() {
return weak_factory_.GetWeakPtr(); return weak_factory_.GetWeakPtr();
} }
@ -400,7 +390,6 @@ class NativeWindow : public base::SupportsUserData,
} }
bool has_frame() const { return has_frame_; } bool has_frame() const { return has_frame_; }
void set_has_frame(bool has_frame) { has_frame_ = has_frame; }
bool has_client_frame() const { return has_client_frame_; } bool has_client_frame() const { return has_client_frame_; }
bool transparent() const { return transparent_; } bool transparent() const { return transparent_; }
@ -433,7 +422,7 @@ class NativeWindow : public base::SupportsUserData,
void UpdateBackgroundThrottlingState(); void UpdateBackgroundThrottlingState();
protected: protected:
friend class api::BrowserView; constexpr void set_has_frame(const bool val) { has_frame_ = val; }
[[nodiscard]] constexpr bool is_closed() const { return is_closed_; } [[nodiscard]] constexpr bool is_closed() const { return is_closed_; }
@ -441,6 +430,12 @@ class NativeWindow : public base::SupportsUserData,
virtual void OnTitleChanged() {} virtual void OnTitleChanged() {}
// Converts between content bounds and window bounds.
virtual gfx::Rect ContentBoundsToWindowBounds(
const gfx::Rect& bounds) const = 0;
virtual gfx::Rect WindowBoundsToContentBounds(
const gfx::Rect& bounds) const = 0;
// views::WidgetDelegate: // views::WidgetDelegate:
views::Widget* GetWidget() override; views::Widget* GetWidget() override;
const views::Widget* GetWidget() const override; const views::Widget* GetWidget() const override;
@ -457,10 +452,6 @@ class NativeWindow : public base::SupportsUserData,
// The boolean parsing of the "titleBarOverlay" option // The boolean parsing of the "titleBarOverlay" option
bool titlebar_overlay_ = false; bool titlebar_overlay_ = false;
// The custom height parsed from the "height" option in a Object
// "titleBarOverlay"
int titlebar_overlay_height_ = 0;
// The "titleBarStyle" option. // The "titleBarStyle" option.
TitleBarStyle title_bar_style_ = TitleBarStyle::kNormal; TitleBarStyle title_bar_style_ = TitleBarStyle::kNormal;
@ -486,6 +477,10 @@ class NativeWindow : public base::SupportsUserData,
// The content view, weak ref. // The content view, weak ref.
raw_ptr<views::View> content_view_ = nullptr; raw_ptr<views::View> content_view_ = nullptr;
// The custom height parsed from the "height" option in a Object
// "titleBarOverlay"
int titlebar_overlay_height_ = 0;
// Whether window has standard frame. // Whether window has standard frame.
bool has_frame_ = true; bool has_frame_ = true;