display WebContents as views::View on macOS
This commit is contained in:
parent
ada884a129
commit
a9709a635c
5 changed files with 106 additions and 17 deletions
33
atom/browser/ui/cocoa/root_view_mac.h
Normal file
33
atom/browser/ui/cocoa/root_view_mac.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
// Copyright (c) 2018 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_BROWSER_UI_COCOA_ROOT_VIEW_MAC_H_
|
||||
#define ATOM_BROWSER_UI_COCOA_ROOT_VIEW_MAC_H_
|
||||
|
||||
#include "ui/views/view.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
class NativeWindow;
|
||||
|
||||
class RootViewMac : public views::View {
|
||||
public:
|
||||
explicit RootViewMac(NativeWindow* window);
|
||||
~RootViewMac() override;
|
||||
|
||||
// views::View:
|
||||
void Layout() override;
|
||||
gfx::Size GetMinimumSize() const override;
|
||||
gfx::Size GetMaximumSize() const override;
|
||||
|
||||
private:
|
||||
// Parent window, weak ref.
|
||||
NativeWindow* window_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(RootViewMac);
|
||||
};
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_BROWSER_UI_COCOA_ROOT_VIEW_MAC_H_
|
34
atom/browser/ui/cocoa/root_view_mac.mm
Normal file
34
atom/browser/ui/cocoa/root_view_mac.mm
Normal file
|
@ -0,0 +1,34 @@
|
|||
// Copyright (c) 2018 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/browser/ui/cocoa/root_view_mac.h"
|
||||
|
||||
#include "atom/browser/native_window_mac.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
RootViewMac::RootViewMac(NativeWindow* window) : window_(window) {
|
||||
set_owned_by_client();
|
||||
}
|
||||
|
||||
RootViewMac::~RootViewMac() {}
|
||||
|
||||
void RootViewMac::Layout() {
|
||||
views::View* content_view =
|
||||
static_cast<NativeWindowMac*>(window_)->content_view();
|
||||
if (!content_view) // Not ready yet.
|
||||
return;
|
||||
|
||||
content_view->SetBoundsRect(gfx::Rect(gfx::Point(), size()));
|
||||
}
|
||||
|
||||
gfx::Size RootViewMac::GetMinimumSize() const {
|
||||
return window_->GetMinimumSize();
|
||||
}
|
||||
|
||||
gfx::Size RootViewMac::GetMaximumSize() const {
|
||||
return window_->GetMaximumSize();
|
||||
}
|
||||
|
||||
} // namespace atom
|
Loading…
Add table
Add a link
Reference in a new issue