Store InspectableWebContents instead of InspectableWebContentsView in NativeBrowserView

This commit is contained in:
Birunthan Mohanathas 2018-03-19 09:50:30 +02:00
parent 6b80865bfe
commit 61160ff9e5
7 changed files with 30 additions and 20 deletions

View file

@ -68,8 +68,8 @@ void BrowserView::Init(v8::Isolate* isolate,
web_contents_.Reset(isolate, web_contents.ToV8()); web_contents_.Reset(isolate, web_contents.ToV8());
api_web_contents_ = web_contents.get(); api_web_contents_ = web_contents.get();
view_.reset(NativeBrowserView::Create( view_.reset(
api_web_contents_->managed_web_contents()->GetView())); NativeBrowserView::Create(api_web_contents_->managed_web_contents()));
InitWith(isolate, wrapper); InitWith(isolate, wrapper);
} }

View file

@ -7,14 +7,19 @@
#include "atom/browser/native_browser_view.h" #include "atom/browser/native_browser_view.h"
#include "atom/browser/api/atom_api_web_contents.h" #include "atom/browser/api/atom_api_web_contents.h"
#include "brightray/browser/inspectable_web_contents_view.h" #include "brightray/browser/inspectable_web_contents.h"
namespace atom { namespace atom {
NativeBrowserView::NativeBrowserView( NativeBrowserView::NativeBrowserView(
brightray::InspectableWebContentsView* web_contents_view) brightray::InspectableWebContents* inspectable_web_contents)
: web_contents_view_(web_contents_view) {} : inspectable_web_contents_(inspectable_web_contents) {}
NativeBrowserView::~NativeBrowserView() {} NativeBrowserView::~NativeBrowserView() {}
brightray::InspectableWebContentsView*
NativeBrowserView::GetInspectableWebContentsView() {
return inspectable_web_contents_->GetView();
}
} // namespace atom } // namespace atom

View file

@ -12,6 +12,7 @@
#include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkColor.h"
namespace brightray { namespace brightray {
class InspectableWebContents;
class InspectableWebContentsView; class InspectableWebContentsView;
} }
@ -31,12 +32,14 @@ class NativeBrowserView {
virtual ~NativeBrowserView(); virtual ~NativeBrowserView();
static NativeBrowserView* Create( static NativeBrowserView* Create(
brightray::InspectableWebContentsView* web_contents_view); brightray::InspectableWebContents* inspectable_web_contents);
brightray::InspectableWebContentsView* GetInspectableWebContentsView() { brightray::InspectableWebContents* GetInspectableWebContents() {
return web_contents_view_; return inspectable_web_contents_;
} }
brightray::InspectableWebContentsView* GetInspectableWebContentsView();
virtual void SetAutoResizeFlags(uint8_t flags) = 0; virtual void SetAutoResizeFlags(uint8_t flags) = 0;
virtual void SetBounds(const gfx::Rect& bounds) = 0; virtual void SetBounds(const gfx::Rect& bounds) = 0;
virtual void SetBackgroundColor(SkColor color) = 0; virtual void SetBackgroundColor(SkColor color) = 0;
@ -47,9 +50,9 @@ class NativeBrowserView {
protected: protected:
explicit NativeBrowserView( explicit NativeBrowserView(
brightray::InspectableWebContentsView* web_contents_view); brightray::InspectableWebContents* inspectable_web_contents);
brightray::InspectableWebContentsView* web_contents_view_; brightray::InspectableWebContents* inspectable_web_contents_;
private: private:
DISALLOW_COPY_AND_ASSIGN(NativeBrowserView); DISALLOW_COPY_AND_ASSIGN(NativeBrowserView);

View file

@ -17,12 +17,13 @@ namespace atom {
class NativeBrowserViewMac : public NativeBrowserView { class NativeBrowserViewMac : public NativeBrowserView {
public: public:
explicit NativeBrowserViewMac( explicit NativeBrowserViewMac(
brightray::InspectableWebContentsView* web_contents_view); brightray::InspectableWebContents* inspectable_web_contents);
~NativeBrowserViewMac() override; ~NativeBrowserViewMac() override;
void SetAutoResizeFlags(uint8_t flags) override; void SetAutoResizeFlags(uint8_t flags) override;
void SetBounds(const gfx::Rect& bounds) override; void SetBounds(const gfx::Rect& bounds) override;
void SetBackgroundColor(SkColor color) override; void SetBackgroundColor(SkColor color) override;
void UpdateDraggableRegions( void UpdateDraggableRegions(
const std::vector<gfx::Rect>& system_drag_exclude_areas) override; const std::vector<gfx::Rect>& system_drag_exclude_areas) override;

View file

@ -4,6 +4,7 @@
#include "atom/browser/native_browser_view_mac.h" #include "atom/browser/native_browser_view_mac.h"
#include "brightray/browser/inspectable_web_contents.h"
#include "brightray/browser/inspectable_web_contents_view.h" #include "brightray/browser/inspectable_web_contents_view.h"
#include "skia/ext/skia_utils_mac.h" #include "skia/ext/skia_utils_mac.h"
#include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect.h"
@ -156,8 +157,8 @@ const NSAutoresizingMaskOptions kDefaultAutoResizingMask =
namespace atom { namespace atom {
NativeBrowserViewMac::NativeBrowserViewMac( NativeBrowserViewMac::NativeBrowserViewMac(
brightray::InspectableWebContentsView* web_contents_view) brightray::InspectableWebContents* inspectable_web_contents)
: NativeBrowserView(web_contents_view) { : NativeBrowserView(inspectable_web_contents) {
auto* view = GetInspectableWebContentsView()->GetNativeView(); auto* view = GetInspectableWebContentsView()->GetNativeView();
view.autoresizingMask = kDefaultAutoResizingMask; view.autoresizingMask = kDefaultAutoResizingMask;
} }
@ -247,8 +248,8 @@ void NativeBrowserViewMac::UpdateDraggableRegions(
// static // static
NativeBrowserView* NativeBrowserView::Create( NativeBrowserView* NativeBrowserView::Create(
brightray::InspectableWebContentsView* web_contents_view) { brightray::InspectableWebContents* inspectable_web_contents) {
return new NativeBrowserViewMac(web_contents_view); return new NativeBrowserViewMac(inspectable_web_contents);
} }
} // namespace atom } // namespace atom

View file

@ -12,8 +12,8 @@
namespace atom { namespace atom {
NativeBrowserViewViews::NativeBrowserViewViews( NativeBrowserViewViews::NativeBrowserViewViews(
brightray::InspectableWebContentsView* web_contents_view) brightray::InspectableWebContents* inspectable_web_contents)
: NativeBrowserView(web_contents_view) {} : NativeBrowserView(inspectable_web_contents) {}
NativeBrowserViewViews::~NativeBrowserViewViews() {} NativeBrowserViewViews::~NativeBrowserViewViews() {}
@ -29,8 +29,8 @@ void NativeBrowserViewViews::SetBackgroundColor(SkColor color) {
// static // static
NativeBrowserView* NativeBrowserView::Create( NativeBrowserView* NativeBrowserView::Create(
brightray::InspectableWebContentsView* web_contents_view) { brightray::InspectableWebContents* inspectable_web_contents) {
return new NativeBrowserViewViews(web_contents_view); return new NativeBrowserViewViews(inspectable_web_contents);
} }
} // namespace atom } // namespace atom

View file

@ -12,7 +12,7 @@ namespace atom {
class NativeBrowserViewViews : public NativeBrowserView { class NativeBrowserViewViews : public NativeBrowserView {
public: public:
explicit NativeBrowserViewViews( explicit NativeBrowserViewViews(
brightray::InspectableWebContentsView* web_contents_view); brightray::InspectableWebContents* inspectable_web_contents);
~NativeBrowserViewViews() override; ~NativeBrowserViewViews() override;
uint8_t GetAutoResizeFlags() { return auto_resize_flags_; } uint8_t GetAutoResizeFlags() { return auto_resize_flags_; }