fix: revert moving IsClosed() and IsClosable() into NativeWindow::Close() (#47482)
Revert "refactor: move `IsClosed()` and `IsClosable()` tests into `NativeWindow::Close()` (#46888)"
This reverts commit 3faddd5ae2
.
This commit is contained in:
parent
2ad762e075
commit
3536d4976a
8 changed files with 35 additions and 35 deletions
|
@ -362,7 +362,8 @@ void BaseWindow::SetContentView(gin::Handle<View> view) {
|
|||
}
|
||||
|
||||
void BaseWindow::CloseImmediately() {
|
||||
window_->CloseImmediately();
|
||||
if (!window_->IsClosed())
|
||||
window_->CloseImmediately();
|
||||
}
|
||||
|
||||
void BaseWindow::Close() {
|
||||
|
|
|
@ -285,6 +285,10 @@ void NativeWindow::SetShape(const std::vector<gfx::Rect>& rects) {
|
|||
widget()->SetShape(std::make_unique<std::vector<gfx::Rect>>(rects));
|
||||
}
|
||||
|
||||
bool NativeWindow::IsClosed() const {
|
||||
return is_closed_;
|
||||
}
|
||||
|
||||
void NativeWindow::SetSize(const gfx::Size& size, bool animate) {
|
||||
SetBounds(gfx::Rect(GetPosition(), size), animate);
|
||||
}
|
||||
|
@ -523,23 +527,8 @@ void NativeWindow::NotifyWindowCloseButtonClicked() {
|
|||
CloseImmediately();
|
||||
}
|
||||
|
||||
void NativeWindow::Close() {
|
||||
if (!IsClosable()) {
|
||||
WindowList::WindowCloseCancelled(this);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!is_closed())
|
||||
CloseImpl();
|
||||
}
|
||||
|
||||
void NativeWindow::CloseImmediately() {
|
||||
if (!is_closed())
|
||||
CloseImmediatelyImpl();
|
||||
}
|
||||
|
||||
void NativeWindow::NotifyWindowClosed() {
|
||||
if (is_closed())
|
||||
if (is_closed_)
|
||||
return;
|
||||
|
||||
is_closed_ = true;
|
||||
|
|
|
@ -81,10 +81,9 @@ class NativeWindow : public base::SupportsUserData,
|
|||
|
||||
virtual void SetContentView(views::View* view) = 0;
|
||||
|
||||
// wrapper around CloseImpl that checks that window_ can be closed
|
||||
void Close();
|
||||
// wrapper around CloseImmediatelyImpl that checks that window_ can be closed
|
||||
void CloseImmediately();
|
||||
virtual void Close() = 0;
|
||||
virtual void CloseImmediately() = 0;
|
||||
virtual bool IsClosed() const;
|
||||
virtual void Focus(bool focus) = 0;
|
||||
virtual bool IsFocused() const = 0;
|
||||
virtual void Show() = 0;
|
||||
|
@ -427,6 +426,8 @@ class NativeWindow : public base::SupportsUserData,
|
|||
void UpdateBackgroundThrottlingState();
|
||||
|
||||
protected:
|
||||
friend class api::BrowserView;
|
||||
|
||||
NativeWindow(const gin_helper::Dictionary& options, NativeWindow* parent);
|
||||
|
||||
void set_titlebar_overlay_height(int height) {
|
||||
|
@ -457,9 +458,6 @@ class NativeWindow : public base::SupportsUserData,
|
|||
|
||||
void set_content_view(views::View* view) { content_view_ = view; }
|
||||
|
||||
virtual void CloseImpl() = 0;
|
||||
virtual void CloseImmediatelyImpl() = 0;
|
||||
|
||||
static inline constexpr base::cstring_view kNativeWindowKey =
|
||||
"__ELECTRON_NATIVE_WINDOW__";
|
||||
|
||||
|
|
|
@ -39,8 +39,8 @@ class NativeWindowMac : public NativeWindow,
|
|||
// NativeWindow:
|
||||
void OnTitleChanged() override;
|
||||
void SetContentView(views::View* view) override;
|
||||
void CloseImpl() override;
|
||||
void CloseImmediatelyImpl() override;
|
||||
void Close() override;
|
||||
void CloseImmediately() override;
|
||||
void Focus(bool focus) override;
|
||||
bool IsFocused() const override;
|
||||
void Show() override;
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "shell/browser/ui/cocoa/root_view_mac.h"
|
||||
#include "shell/browser/ui/cocoa/window_buttons_proxy.h"
|
||||
#include "shell/browser/ui/drag_util.h"
|
||||
#include "shell/browser/window_list.h"
|
||||
#include "shell/common/gin_converters/gfx_converter.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/node_util.h"
|
||||
|
@ -336,7 +337,12 @@ void NativeWindowMac::SetContentView(views::View* view) {
|
|||
root_view->DeprecatedLayoutImmediately();
|
||||
}
|
||||
|
||||
void NativeWindowMac::CloseImpl() {
|
||||
void NativeWindowMac::Close() {
|
||||
if (!IsClosable()) {
|
||||
WindowList::WindowCloseCancelled(this);
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_transitioning_fullscreen()) {
|
||||
SetHasDeferredWindowClose(true);
|
||||
return;
|
||||
|
@ -372,7 +378,7 @@ void NativeWindowMac::CloseImpl() {
|
|||
}
|
||||
}
|
||||
|
||||
void NativeWindowMac::CloseImmediatelyImpl() {
|
||||
void NativeWindowMac::CloseImmediately() {
|
||||
// Ensure we're detached from the parent window before closing.
|
||||
RemoveChildFromParentWindow();
|
||||
|
||||
|
@ -1686,7 +1692,7 @@ bool NativeWindowMac::IsActive() const {
|
|||
}
|
||||
|
||||
void NativeWindowMac::Cleanup() {
|
||||
DCHECK(!is_closed());
|
||||
DCHECK(!IsClosed());
|
||||
ui::NativeTheme::GetInstanceForNativeUi()->RemoveObserver(this);
|
||||
display::Screen::GetScreen()->RemoveObserver(this);
|
||||
[window_ cleanup];
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "shell/browser/ui/views/root_view.h"
|
||||
#include "shell/browser/web_contents_preferences.h"
|
||||
#include "shell/browser/web_view_manager.h"
|
||||
#include "shell/browser/window_list.h"
|
||||
#include "shell/common/electron_constants.h"
|
||||
#include "shell/common/gin_converters/image_converter.h"
|
||||
#include "shell/common/gin_helper/arguments.h"
|
||||
|
@ -532,11 +533,16 @@ void NativeWindowViews::SetContentView(views::View* view) {
|
|||
root_view_.GetMainView()->DeprecatedLayoutImmediately();
|
||||
}
|
||||
|
||||
void NativeWindowViews::CloseImpl() {
|
||||
void NativeWindowViews::Close() {
|
||||
if (!IsClosable()) {
|
||||
WindowList::WindowCloseCancelled(this);
|
||||
return;
|
||||
}
|
||||
|
||||
widget()->Close();
|
||||
}
|
||||
|
||||
void NativeWindowViews::CloseImmediatelyImpl() {
|
||||
void NativeWindowViews::CloseImmediately() {
|
||||
widget()->CloseNow();
|
||||
}
|
||||
|
||||
|
|
|
@ -53,8 +53,8 @@ class NativeWindowViews : public NativeWindow,
|
|||
|
||||
// NativeWindow:
|
||||
void SetContentView(views::View* view) override;
|
||||
void CloseImpl() override;
|
||||
void CloseImmediatelyImpl() override;
|
||||
void Close() override;
|
||||
void CloseImmediately() override;
|
||||
void Focus(bool focus) override;
|
||||
bool IsFocused() const override;
|
||||
void Show() override;
|
||||
|
|
|
@ -84,7 +84,7 @@ void WindowList::CloseAllWindows() {
|
|||
std::ranges::reverse(weak_windows);
|
||||
#endif
|
||||
for (const auto& window : weak_windows) {
|
||||
if (window)
|
||||
if (window && !window->IsClosed())
|
||||
window->Close();
|
||||
}
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ void WindowList::DestroyAllWindows() {
|
|||
ConvertToWeakPtrVector(GetInstance()->windows_);
|
||||
|
||||
for (const auto& window : weak_windows) {
|
||||
if (window)
|
||||
if (window && !window->IsClosed())
|
||||
window->CloseImmediately();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue