webcontentsview cleanup

This commit is contained in:
gellert 2016-07-30 20:39:17 +02:00
parent 6486d80f87
commit 976277ffbf
2 changed files with 22 additions and 87 deletions

View file

@ -3,9 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "atom/browser/osr_web_contents_view.h" #include "atom/browser/osr_web_contents_view.h"
#include "atom/browser/osr_render_widget_host_view.h" #include "atom/browser/osr_render_widget_host_view.h"
#include <iostream>
namespace atom { namespace atom {
@ -21,138 +19,79 @@ void OffScreenWebContentsView::SetWebContents(
web_contents_ = web_contents; web_contents_ = web_contents;
} }
// Returns the native widget that contains the contents of the tab. gfx::NativeView OffScreenWebContentsView::GetNativeView() const {
gfx::NativeView OffScreenWebContentsView::GetNativeView() const{
// std::cout << "GetNativeView" << std::endl;
return gfx::NativeView(); return gfx::NativeView();
} }
// Returns the native widget with the main content of the tab (i.e. the main gfx::NativeView OffScreenWebContentsView::GetContentNativeView() const {
// render view host, though there may be many popups in the tab as children of
// the container).
gfx::NativeView OffScreenWebContentsView::GetContentNativeView() const{
// std::cout << "GetContentNativeView" << std::endl;
return gfx::NativeView(); return gfx::NativeView();
} }
// Returns the outermost native view. This will be used as the parent for gfx::NativeWindow OffScreenWebContentsView::GetTopLevelNativeWindow() const {
// dialog boxes.
gfx::NativeWindow OffScreenWebContentsView::GetTopLevelNativeWindow() const{
// std::cout << "GetTopLevelNativeWindow" << std::endl;
return gfx::NativeWindow(); return gfx::NativeWindow();
} }
// Computes the rectangle for the native widget that contains the contents of void OffScreenWebContentsView::GetContainerBounds(gfx::Rect* out) const {
// the tab in the screen coordinate system.
void OffScreenWebContentsView::GetContainerBounds(gfx::Rect* out) const{
// std::cout << "GetContainerBounds" << std::endl;
*out = GetViewBounds(); *out = GetViewBounds();
} }
// TODO(brettw) this is a hack. It's used in two places at the time of this void OffScreenWebContentsView::SizeContents(const gfx::Size& size) {
// writing: (1) when render view hosts switch, we need to size the replaced
// one to be correct, since it wouldn't have known about sizes that happened
// while it was hidden; (2) in constrained windows.
//
// (1) will be fixed once interstitials are cleaned up. (2) seems like it
// should be cleaned up or done some other way, since this works for normal
// WebContents without the special code.
void OffScreenWebContentsView::SizeContents(const gfx::Size& size){
// std::cout << "SizeContents" << std::endl;
} }
// Sets focus to the native widget for this tab. void OffScreenWebContentsView::Focus() {
void OffScreenWebContentsView::Focus(){
// std::cout << "OffScreenWebContentsView::Focus" << std::endl;
} }
// Sets focus to the appropriate element when the WebContents is shown the void OffScreenWebContentsView::SetInitialFocus() {
// first time.
void OffScreenWebContentsView::SetInitialFocus(){
// std::cout << "SetInitialFocus" << std::endl;
} }
// Stores the currently focused view. void OffScreenWebContentsView::StoreFocus() {
void OffScreenWebContentsView::StoreFocus(){
// std::cout << "StoreFocus" << std::endl;
} }
// Restores focus to the last focus view. If StoreFocus has not yet been void OffScreenWebContentsView::RestoreFocus() {
// invoked, SetInitialFocus is invoked.
void OffScreenWebContentsView::RestoreFocus(){
// std::cout << "RestoreFocus" << std::endl;
} }
// Returns the current drop data, if any. content::DropData* OffScreenWebContentsView::GetDropData() const {
content::DropData* OffScreenWebContentsView::GetDropData() const{
// std::cout << "GetDropData" << std::endl;
return nullptr; return nullptr;
} }
// Get the bounds of the View, relative to the parent. gfx::Rect OffScreenWebContentsView::GetViewBounds() const {
gfx::Rect OffScreenWebContentsView::GetViewBounds() const{
// std::cout << "OffScreenWebContentsView::GetViewBounds" << std::endl;
return view_ ? view_->GetViewBounds() : gfx::Rect(); return view_ ? view_->GetViewBounds() : gfx::Rect();
} }
void OffScreenWebContentsView::CreateView( void OffScreenWebContentsView::CreateView(const gfx::Size& initial_size,
const gfx::Size& initial_size, gfx::NativeView context){ gfx::NativeView context) {
std::cout << context << std::endl;
// std::cout << "CreateView" << std::endl;
// std::cout << initial_size.width() << "x" << initial_size.height() << std::endl;
} }
// Sets up the View that holds the rendered web page, receives messages for
// it and contains page plugins. The host view should be sized to the current
// size of the WebContents.
//
// |is_guest_view_hack| is temporary hack and will be removed once
// RenderWidgetHostViewGuest is not dependent on platform view.
// TODO(lazyboy): Remove |is_guest_view_hack| once http://crbug.com/330264 is
// fixed.
content::RenderWidgetHostViewBase* content::RenderWidgetHostViewBase*
OffScreenWebContentsView::CreateViewForWidget( OffScreenWebContentsView::CreateViewForWidget(
content::RenderWidgetHost* render_widget_host, bool is_guest_view_hack){ content::RenderWidgetHost* render_widget_host, bool is_guest_view_hack) {
auto relay = NativeWindowRelay::FromWebContents(web_contents_); auto relay = NativeWindowRelay::FromWebContents(web_contents_);
view_ = new OffScreenRenderWidgetHostView(render_widget_host, view_ = new OffScreenRenderWidgetHostView(render_widget_host,
relay->window.get()); relay->window.get());
return view_; return view_;
} }
// Creates a new View that holds a popup and receives messages for it.
content::RenderWidgetHostViewBase* content::RenderWidgetHostViewBase*
OffScreenWebContentsView::CreateViewForPopupWidget( OffScreenWebContentsView::CreateViewForPopupWidget(
content::RenderWidgetHost* render_widget_host){ content::RenderWidgetHost* render_widget_host) {
auto relay = NativeWindowRelay::FromWebContents(web_contents_); auto relay = NativeWindowRelay::FromWebContents(web_contents_);
view_ = new OffScreenRenderWidgetHostView(render_widget_host, view_ = new OffScreenRenderWidgetHostView(render_widget_host,
relay->window.get()); relay->window.get());
return view_; return view_;
} }
// Sets the page title for the native widgets corresponding to the view. This void OffScreenWebContentsView::SetPageTitle(const base::string16& title) {
// is not strictly necessary and isn't expected to be displayed anywhere, but
// can aid certain debugging tools such as Spy++ on Windows where you are
// trying to find a specific window.
void OffScreenWebContentsView::SetPageTitle(const base::string16& title){
// std::cout << "SetPageTitle" << std::endl;
// std::cout << title << std::endl;
} }
// Invoked when the WebContents is notified that the RenderView has been void OffScreenWebContentsView::RenderViewCreated(
// fully created. content::RenderViewHost* host) {
void OffScreenWebContentsView::RenderViewCreated(content::RenderViewHost* host){
// std::cout << "RenderViewCreated" << std::endl;
} }
// Invoked when the WebContents is notified that the RenderView has been void OffScreenWebContentsView::RenderViewSwappedIn(
// swapped in. content::RenderViewHost* host) {
void OffScreenWebContentsView::RenderViewSwappedIn(content::RenderViewHost* host){
// std::cout << "RenderViewSwappedIn" << std::endl;
} }
// Invoked to enable/disable overscroll gesture navigation. void OffScreenWebContentsView::SetOverscrollControllerEnabled(bool enabled) {
void OffScreenWebContentsView::SetOverscrollControllerEnabled(bool enabled){
// std::cout << "SetOverscrollControllerEnabled" << std::endl;
} }
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
@ -183,5 +122,4 @@ void OffScreenWebContentsView::UpdateDragCursor(
blink::WebDragOperation operation) { blink::WebDragOperation operation) {
} }
} // namespace atom } // namespace atom

View file

@ -20,10 +20,10 @@ public:
void SetWebContents(content::WebContents*); void SetWebContents(content::WebContents*);
// content::WebContentsView
gfx::NativeView GetNativeView() const override; gfx::NativeView GetNativeView() const override;
gfx::NativeView GetContentNativeView() const override; gfx::NativeView GetContentNativeView() const override;
gfx::NativeWindow GetTopLevelNativeWindow() const override; gfx::NativeWindow GetTopLevelNativeWindow() const override;
void GetContainerBounds(gfx::Rect* out) const override; void GetContainerBounds(gfx::Rect* out) const override;
void SizeContents(const gfx::Size& size) override; void SizeContents(const gfx::Size& size) override;
void Focus() override; void Focus() override;
@ -32,16 +32,13 @@ public:
void RestoreFocus() override; void RestoreFocus() override;
content::DropData* GetDropData() const override; content::DropData* GetDropData() const override;
gfx::Rect GetViewBounds() const override; gfx::Rect GetViewBounds() const override;
void CreateView( void CreateView(
const gfx::Size& initial_size, gfx::NativeView context) override; const gfx::Size& initial_size, gfx::NativeView context) override;
content::RenderWidgetHostViewBase* CreateViewForWidget( content::RenderWidgetHostViewBase* CreateViewForWidget(
content::RenderWidgetHost* render_widget_host, content::RenderWidgetHost* render_widget_host,
bool is_guest_view_hack) override; bool is_guest_view_hack) override;
content::RenderWidgetHostViewBase* CreateViewForPopupWidget( content::RenderWidgetHostViewBase* CreateViewForPopupWidget(
content::RenderWidgetHost* render_widget_host) override; content::RenderWidgetHost* render_widget_host) override;
void SetPageTitle(const base::string16& title) override; void SetPageTitle(const base::string16& title) override;
void RenderViewCreated(content::RenderViewHost* host) override; void RenderViewCreated(content::RenderViewHost* host) override;
void RenderViewSwappedIn(content::RenderViewHost* host) override; void RenderViewSwappedIn(content::RenderViewHost* host) override;