From 7240a141265dd3d7f65360ac137fb319f002de22 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Tue, 6 May 2025 07:44:48 -0500 Subject: [PATCH] refactor: remove some `NativeWindow` public API (36-x-y) (#46944) 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 Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Charles Kerr --- shell/browser/native_window.cc | 7 ++----- shell/browser/native_window.h | 27 +++++++++++---------------- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/shell/browser/native_window.cc b/shell/browser/native_window.cc index 64ed9083e62d..658c11950b4c 100644 --- a/shell/browser/native_window.cc +++ b/shell/browser/native_window.cc @@ -803,17 +803,14 @@ bool NativeWindow::IsTranslucent() const { #if BUILDFLAG(IS_MAC) // Windows with vibrancy set are translucent - if (!vibrancy().empty()) { + if (!vibrancy_.empty()) return true; - } #endif #if BUILDFLAG(IS_WIN) // Windows with certain background materials may be translucent - const std::string& bg_material = background_material(); - if (!bg_material.empty() && bg_material != "none") { + if (!background_material_.empty() && background_material_ != "none") return true; - } #endif return false; diff --git a/shell/browser/native_window.h b/shell/browser/native_window.h index aecd0a917814..a88d17a6d8dd 100644 --- a/shell/browser/native_window.h +++ b/shell/browser/native_window.h @@ -229,12 +229,8 @@ class NativeWindow : public base::SupportsUserData, virtual void SetAutoHideCursor(bool auto_hide) {} // Vibrancy API - const std::string& vibrancy() const { return vibrancy_; } 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); // Traffic Light API @@ -290,12 +286,6 @@ class NativeWindow : public base::SupportsUserData, 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 GetWeakPtr() { return weak_factory_.GetWeakPtr(); } @@ -406,7 +396,6 @@ class NativeWindow : public base::SupportsUserData, } 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 transparent() const { return transparent_; } @@ -439,10 +428,16 @@ class NativeWindow : public base::SupportsUserData, void UpdateBackgroundThrottlingState(); protected: - friend class api::BrowserView; + constexpr void set_has_frame(const bool val) { has_frame_ = val; } NativeWindow(const gin_helper::Dictionary& options, NativeWindow* parent); + // 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::Widget* GetWidget() override; const views::Widget* GetWidget() const override; @@ -456,10 +451,6 @@ class NativeWindow : public base::SupportsUserData, // The boolean parsing of the "titleBarOverlay" option bool titlebar_overlay_ = false; - // The custom height parsed from the "height" option in a Object - // "titleBarOverlay" - int titlebar_overlay_height_ = 0; - // The "titleBarStyle" option. TitleBarStyle title_bar_style_ = TitleBarStyle::kNormal; @@ -485,6 +476,10 @@ class NativeWindow : public base::SupportsUserData, // The content view, weak ref. raw_ptr 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. bool has_frame_ = true;