Merge pull request #13673 from electron/fix-frameless-devtools-crash
Fix crash when opening devtools for frameless window
This commit is contained in:
commit
ede6fd91d0
4 changed files with 14 additions and 4 deletions
|
@ -87,7 +87,7 @@ BrowserWindow::BrowserWindow(v8::Isolate* isolate,
|
||||||
|
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
if (!window()->has_frame())
|
if (!window()->has_frame())
|
||||||
OverrideNSWindowContentView();
|
OverrideNSWindowContentView(web_contents->managed_web_contents());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Init window after everything has been setup.
|
// Init window after everything has been setup.
|
||||||
|
|
|
@ -81,7 +81,7 @@ class BrowserWindow : public TopLevelWindow,
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
void OverrideNSWindowContentView();
|
void OverrideNSWindowContentView(brightray::InspectableWebContents* iwc);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Helpers.
|
// Helpers.
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "atom/browser/native_window_mac.h"
|
#include "atom/browser/native_window_mac.h"
|
||||||
#include "atom/common/draggable_region.h"
|
#include "atom/common/draggable_region.h"
|
||||||
#include "base/mac/scoped_nsobject.h"
|
#include "base/mac/scoped_nsobject.h"
|
||||||
|
#include "brightray/browser/inspectable_web_contents_view.h"
|
||||||
|
|
||||||
@interface NSView (WebContentsView)
|
@interface NSView (WebContentsView)
|
||||||
- (void)setMouseDownCanMoveWindow:(BOOL)can_move;
|
- (void)setMouseDownCanMoveWindow:(BOOL)can_move;
|
||||||
|
@ -54,11 +55,12 @@ std::vector<gfx::Rect> CalculateNonDraggableRegions(
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void BrowserWindow::OverrideNSWindowContentView() {
|
void BrowserWindow::OverrideNSWindowContentView(
|
||||||
|
brightray::InspectableWebContents* iwc) {
|
||||||
// Make NativeWindow use a NSView as content view.
|
// Make NativeWindow use a NSView as content view.
|
||||||
static_cast<NativeWindowMac*>(window())->OverrideNSWindowContentView();
|
static_cast<NativeWindowMac*>(window())->OverrideNSWindowContentView();
|
||||||
// Add webview to contentView.
|
// Add webview to contentView.
|
||||||
NSView* webView = web_contents()->GetNativeView();
|
NSView* webView = iwc->GetView()->GetNativeView();
|
||||||
NSView* contentView = [window()->GetNativeWindow() contentView];
|
NSView* contentView = [window()->GetNativeWindow() contentView];
|
||||||
[webView setFrame:[contentView bounds]];
|
[webView setFrame:[contentView bounds]];
|
||||||
[contentView addSubview:webView];
|
[contentView addSubview:webView];
|
||||||
|
|
|
@ -839,6 +839,14 @@ describe('BrowserWindow module', () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('BrowserWindow.openDevTools()', () => {
|
||||||
|
it('does not crash for frameless window', () => {
|
||||||
|
w.destroy()
|
||||||
|
w = new BrowserWindow({ show: false })
|
||||||
|
w.openDevTools()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('BrowserWindow.fromBrowserView(browserView)', () => {
|
describe('BrowserWindow.fromBrowserView(browserView)', () => {
|
||||||
let bv = null
|
let bv = null
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue