Compare commits

...

1 Commits

Author SHA1 Message Date
Milan Burda
372523e4f5 refactor: AddBrowserView / RemoveBrowserView / SetTopBrowserView 2023-11-11 02:42:23 +01:00
2 changed files with 21 additions and 33 deletions

View File

@@ -1268,14 +1268,13 @@ bool NativeWindowMac::IsFocusable() {
}
void NativeWindowMac::AddBrowserView(NativeBrowserView* view) {
[CATransaction begin];
[CATransaction setDisableActions:YES];
if (!view) {
[CATransaction commit];
return;
}
[CATransaction begin];
[CATransaction setDisableActions:YES];
add_browser_view(view);
if (auto* native_view = GetNativeNSView(view)) {
[[window_ contentView] addSubview:native_view
@@ -1288,14 +1287,13 @@ void NativeWindowMac::AddBrowserView(NativeBrowserView* view) {
}
void NativeWindowMac::RemoveBrowserView(NativeBrowserView* view) {
[CATransaction begin];
[CATransaction setDisableActions:YES];
if (!view) {
[CATransaction commit];
return;
}
[CATransaction begin];
[CATransaction setDisableActions:YES];
if (auto* native_view = GetNativeNSView(view)) {
[native_view removeFromSuperview];
}
@@ -1305,14 +1303,13 @@ void NativeWindowMac::RemoveBrowserView(NativeBrowserView* view) {
}
void NativeWindowMac::SetTopBrowserView(NativeBrowserView* view) {
[CATransaction begin];
[CATransaction setDisableActions:YES];
if (!view) {
[CATransaction commit];
return;
}
[CATransaction begin];
[CATransaction setDisableActions:YES];
remove_browser_view(view);
add_browser_view(view);
if (auto* native_view = GetNativeNSView(view)) {

View File

@@ -1352,47 +1352,38 @@ void NativeWindowViews::SetMenu(ElectronMenuModel* menu_model) {
}
void NativeWindowViews::AddBrowserView(NativeBrowserView* view) {
if (!content_view())
return;
if (!view) {
if (!content_view() || !view) {
return;
}
add_browser_view(view);
if (view->GetInspectableWebContentsView())
content_view()->AddChildView(
view->GetInspectableWebContentsView()->GetView());
if (auto* iwc_view = view->GetInspectableWebContentsView()) {
content_view()->AddChildView(iwc_view->GetView());
}
}
void NativeWindowViews::RemoveBrowserView(NativeBrowserView* view) {
if (!content_view())
return;
if (!view) {
if (!content_view() || !view) {
return;
}
if (view->GetInspectableWebContentsView())
content_view()->RemoveChildView(
view->GetInspectableWebContentsView()->GetView());
if (auto* iwc_view = view->GetInspectableWebContentsView()) {
content_view()->RemoveChildView(iwc_view->GetView());
}
remove_browser_view(view);
}
void NativeWindowViews::SetTopBrowserView(NativeBrowserView* view) {
if (!content_view())
return;
if (!view) {
if (!content_view() || !view) {
return;
}
remove_browser_view(view);
add_browser_view(view);
if (view->GetInspectableWebContentsView())
content_view()->ReorderChildView(
view->GetInspectableWebContentsView()->GetView(), -1);
if (auto* iwc_view = view->GetInspectableWebContentsView()) {
content_view()->ReorderChildView(iwc_view->GetView(), -1);
}
}
void NativeWindowViews::SetParentWindow(NativeWindow* parent) {