mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
refactor: AddBrowserView / RemoveBrowserView / SetTopBrowserView
This commit is contained in:
@@ -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)) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user