fix: use InspectableWebContentsView as content view

This commit is contained in:
Cheng Zhao 2018-07-16 10:20:35 +09:00
parent 5b81fde8a7
commit 4a7c85f43e
3 changed files with 6 additions and 4 deletions

View file

@ -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.

View file

@ -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.

View file

@ -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];