electron/atom/browser/api/atom_api_web_contents_osr.cc
Shelley Vohr ba9a55c391 fix: update and enable osr (#15046)
* fix: update and enable osr

* fix: update MacHelper view to call GetNativeView

* style: move stuff around to make more sense

* chore: move OSR related things in SetOwnerWindow to CommonWebContentsDelegate

* fix: avoid crashing when GetOffscreenRenderWidgetHostView is called

* fix: specify default for current_device_scale_factor_
2018-10-11 09:14:01 -04:00

41 lines
1.2 KiB
C++

// 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/api/atom_api_web_contents.h"
#include "atom/browser/osr/osr_render_widget_host_view.h"
#include "atom/browser/osr/osr_web_contents_view.h"
#include "content/browser/web_contents/web_contents_impl.h"
// Including both web_contents_impl.h and node.h would introduce a error, we
// have to isolate the usage of WebContentsImpl into a clean file to fix it:
// error C2371: 'ssize_t': redefinition; different basic types
namespace atom {
namespace api {
OffScreenWebContentsView* WebContents::GetOffScreenWebContentsView() const {
if (IsOffScreen()) {
const auto* impl =
static_cast<const content::WebContentsImpl*>(web_contents());
return static_cast<OffScreenWebContentsView*>(impl->GetView());
} else {
return nullptr;
}
}
OffScreenRenderWidgetHostView* WebContents::GetOffScreenRenderWidgetHostView()
const {
if (IsOffScreen()) {
return static_cast<OffScreenRenderWidgetHostView*>(
web_contents()->GetRenderWidgetHostView());
} else {
return nullptr;
}
}
} // namespace api
} // namespace atom