Remove web_contents_impl() helper to clarify code and remove unnecessary guard

This commit is contained in:
Heilig Benedek 2018-01-26 10:30:20 +01:00
parent 406f171c88
commit df3d94b20d
2 changed files with 10 additions and 32 deletions

View file

@ -1652,12 +1652,8 @@ void WebContents::StartPainting() {
return;
#if defined(ENABLE_OSR)
const auto* wc_impl = web_contents_impl();
if (!wc_impl)
return;
auto* osr_wcv = static_cast<OffScreenWebContentsView*>(
wc_impl->GetView());
const auto* wc_impl = static_cast<content::WebContentsImpl*>(web_contents());
auto* osr_wcv = static_cast<OffScreenWebContentsView*>(wc_impl->GetView());
if (osr_wcv)
osr_wcv->SetPainting(true);
#endif
@ -1668,12 +1664,8 @@ void WebContents::StopPainting() {
return;
#if defined(ENABLE_OSR)
const auto* wc_impl = web_contents_impl();
if (!wc_impl)
return;
auto* osr_wcv = static_cast<OffScreenWebContentsView*>(
wc_impl->GetView());
const auto* wc_impl = static_cast<content::WebContentsImpl*>(web_contents());
auto* osr_wcv = static_cast<OffScreenWebContentsView*>(wc_impl->GetView());
if (osr_wcv)
osr_wcv->SetPainting(false);
#endif
@ -1684,12 +1676,9 @@ bool WebContents::IsPainting() const {
return false;
#if defined(ENABLE_OSR)
const auto* wc_impl = web_contents_impl();
if (!wc_impl)
return false;
const auto* wc_impl = static_cast<content::WebContentsImpl*>(web_contents());
auto* osr_wcv = static_cast<OffScreenWebContentsView*>(wc_impl->GetView());
const auto* osr_wcv = static_cast<OffScreenWebContentsView*>(
wc_impl->GetView());
return osr_wcv && osr_wcv->IsPainting();
#else
return false;
@ -1701,12 +1690,9 @@ void WebContents::SetFrameRate(int frame_rate) {
return;
#if defined(ENABLE_OSR)
const auto* wc_impl = web_contents_impl();
if (!wc_impl)
return;
const auto* wc_impl = static_cast<content::WebContentsImpl*>(web_contents());
auto* osr_wcv = static_cast<OffScreenWebContentsView*>(wc_impl->GetView());
auto* osr_wcv = static_cast<OffScreenWebContentsView*>(
wc_impl->GetView());
if (osr_wcv)
osr_wcv->SetFrameRate(frame_rate);
#endif
@ -1717,12 +1703,9 @@ int WebContents::GetFrameRate() const {
return 0;
#if defined(ENABLE_OSR)
const auto* wc_impl = web_contents_impl();
if (!wc_impl)
return 0;
const auto* wc_impl = static_cast<content::WebContentsImpl*>(web_contents());
auto* osr_wcv = static_cast<OffScreenWebContentsView*>(wc_impl->GetView());
const auto* osr_wcv = static_cast<OffScreenWebContentsView*>(
wc_impl->GetView());
return osr_wcv ? osr_wcv->GetFrameRate() : 0;
#else
return 0;

View file

@ -13,7 +13,6 @@
#include "atom/browser/api/trackable_object.h"
#include "atom/browser/common_web_contents_delegate.h"
#include "atom/browser/ui/autofill_popup.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/common/cursors/webcursor.h"
#include "content/public/browser/keyboard_event_processing_result.h"
#include "content/public/browser/web_contents.h"
@ -374,10 +373,6 @@ class WebContents : public mate::TrackableObject<WebContents>,
return ++request_id_;
}
content::WebContentsImpl* web_contents_impl() const {
return static_cast<content::WebContentsImpl*>(web_contents());
}
// Called when we receive a CursorChange message from chromium.
void OnCursorChange(const content::WebCursor& cursor);