From 5525ac36b8bb269c502785d26b01bccb4e771fff Mon Sep 17 00:00:00 2001 From: gellert Date: Sun, 31 Jul 2016 12:19:56 +0200 Subject: [PATCH] does linting --- atom/browser/api/atom_api_web_contents.cc | 8 +- atom/browser/api/atom_api_web_contents.h | 4 +- atom/browser/api/atom_api_window.cc | 2 +- atom/browser/api/frame_subscriber.cc | 9 - atom/browser/api/frame_subscriber.h | 10 -- atom/browser/atom_browser_context.cc | 2 +- atom/browser/osr_output_device.h | 7 +- atom/browser/osr_render_widget_host_view.cc | 48 ++++-- atom/browser/osr_render_widget_host_view.h | 155 +++++++++--------- .../osr_render_widget_host_view_win.cc | 4 +- atom/browser/osr_web_contents_view.h | 5 +- 11 files changed, 126 insertions(+), 128 deletions(-) diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index d9de45f2ab..3a12d49ca9 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -313,7 +313,7 @@ WebContents::WebContents(v8::Isolate* isolate, guest_delegate_.reset(new WebViewGuestDelegate); params.guest_delegate = guest_delegate_.get(); web_contents = content::WebContents::Create(params); - } else if(IsOffScreen()) { + } else if (IsOffScreen()) { content::WebContents::CreateParams params(session->browser_context()); auto view = new OffScreenWebContentsView(); @@ -1322,8 +1322,6 @@ void WebContents::OnCursorChange(const content::WebCursor& cursor) { if (cursor.IsCustom()) { Emit("cursor-changed", CursorTypeToString(info), gfx::Image::CreateFrom1xBitmap(info.custom_image), - gfx::Rect(info.custom_image.width(), info.custom_image.height()), - info.hotspot, info.image_scale_factor); } else { Emit("cursor-changed", CursorTypeToString(info)); @@ -1395,8 +1393,8 @@ void WebContents::OnPaint( int bitmap_width, int bitmap_height, void* bitmap_pixels) { - v8::MaybeLocal buffer = node::Buffer::New(isolate - , (char *)bitmap_pixels, sizeof(bitmap_pixels)); + v8::MaybeLocal buffer = node::Buffer::New(isolate, + reinterpret_cast(bitmap_pixels), sizeof(bitmap_pixels)); const gfx::Size bitmap_size = gfx::Size(bitmap_width, bitmap_height); Emit("paint", damage_rect, buffer.ToLocalChecked(), bitmap_size); diff --git a/atom/browser/api/atom_api_web_contents.h b/atom/browser/api/atom_api_web_contents.h index 1587bec34b..631b8ba050 100644 --- a/atom/browser/api/atom_api_web_contents.h +++ b/atom/browser/api/atom_api_web_contents.h @@ -50,7 +50,7 @@ class WebContents : public mate::TrackableObject, BROWSER_WINDOW, // Used by BrowserWindow. REMOTE, // Thin wrap around an existing WebContents. WEB_VIEW, // Used by . - OFF_SCREEN, // Used for offscreen rendering + OFF_SCREEN, // Used for offscreen rendering }; // For node.js callback function type: function(error, buffer) @@ -163,7 +163,7 @@ class WebContents : public mate::TrackableObject, void StartPainting(); void StopPainting(); bool IsPainting() const; - void SetFrameRate(int); + void SetFrameRate(int frame_rate); int GetFrameRate() const; // Callback triggered on permission response. diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index 5b4addbc4b..92d3404f23 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -73,7 +73,7 @@ Window::Window(v8::Isolate* isolate, const mate::Dictionary& options) { // Use options.webPreferences to create WebContents. mate::Dictionary web_preferences = mate::Dictionary::CreateEmpty(isolate); options.Get(options::kWebPreferences, &web_preferences); - + // Copy the backgroundColor to webContents. v8::Local value; if (options.Get(options::kBackgroundColor, &value)) diff --git a/atom/browser/api/frame_subscriber.cc b/atom/browser/api/frame_subscriber.cc index 017310f67f..d262f5684f 100644 --- a/atom/browser/api/frame_subscriber.cc +++ b/atom/browser/api/frame_subscriber.cc @@ -9,7 +9,6 @@ #include "atom/common/node_includes.h" #include "content/public/browser/render_widget_host.h" -#include #include "content/browser/compositor/image_transport_factory.h" #include "cc/surfaces/surface_manager.h" #include "cc/surfaces/surface.h" @@ -19,14 +18,6 @@ namespace atom { namespace api { -FrameSubscriberRenderWidgetHostView::FrameSubscriberRenderWidgetHostView() { - std::cout << "FrameSubscriberRenderWidgetHostView" << std::endl; -} - -FrameSubscriberRenderWidgetHostView::~FrameSubscriberRenderWidgetHostView() { - std::cout << "~FrameSubscriberRenderWidgetHostView" << std::endl; -} - FrameSubscriber::FrameSubscriber(v8::Isolate* isolate, content::RenderWidgetHostView* view, const FrameCaptureCallback& callback, diff --git a/atom/browser/api/frame_subscriber.h b/atom/browser/api/frame_subscriber.h index 6639f2efe7..09ac712987 100644 --- a/atom/browser/api/frame_subscriber.h +++ b/atom/browser/api/frame_subscriber.h @@ -22,16 +22,6 @@ namespace atom { namespace api { -class FrameSubscriberRenderWidgetHostView - : public content::RenderWidgetHostViewBase { - public: - - FrameSubscriberRenderWidgetHostView(); - ~FrameSubscriberRenderWidgetHostView(); - - cc::SurfaceId SurfaceId(); -}; - class FrameSubscriber : public content::RenderWidgetHostViewFrameSubscriber { public: using FrameCaptureCallback = diff --git a/atom/browser/atom_browser_context.cc b/atom/browser/atom_browser_context.cc index 703ce07fe9..a87b29620e 100644 --- a/atom/browser/atom_browser_context.cc +++ b/atom/browser/atom_browser_context.cc @@ -87,7 +87,7 @@ AtomBrowserContext::AtomBrowserContext( // Read options. use_cache_ = true; options.GetBoolean("cache", &use_cache_); - + InitPrefs(); } diff --git a/atom/browser/osr_output_device.h b/atom/browser/osr_output_device.h index a593f3a382..8730cf2ad1 100644 --- a/atom/browser/osr_output_device.h +++ b/atom/browser/osr_output_device.h @@ -12,11 +12,10 @@ namespace atom { -typedef base::Callback OnPaintCallback; +typedef base::Callback OnPaintCallback; class OffScreenOutputDevice : public cc::SoftwareOutputDevice { -public: - + public: OffScreenOutputDevice(bool transparent, const OnPaintCallback& callback); ~OffScreenOutputDevice(); @@ -30,7 +29,7 @@ public: void OnPaint(const gfx::Rect& damage_rect); -private: + private: const bool transparent_; const OnPaintCallback callback_; diff --git a/atom/browser/osr_render_widget_host_view.cc b/atom/browser/osr_render_widget_host_view.cc index 0c1d6c27da..9f2d152401 100644 --- a/atom/browser/osr_render_widget_host_view.cc +++ b/atom/browser/osr_render_widget_host_view.cc @@ -4,6 +4,8 @@ #include "atom/browser/osr_render_widget_host_view.h" +#include + #include "third_party/WebKit/public/platform/WebScreenInfo.h" #include "components/display_compositor/gl_helper.h" #include "content/browser/renderer_host/render_widget_host_impl.h" @@ -303,7 +305,8 @@ class AtomBeginFrameTimer : public cc::DelayBasedTimeSourceClient { : callback_(callback) { time_source_ = cc::DelayBasedTimeSource::Create( base::TimeDelta::FromMilliseconds(frame_rate_threshold_ms), - content::BrowserThread::GetMessageLoopProxyForThread(content::BrowserThread::UI).get()); + content::BrowserThread::GetMessageLoopProxyForThread( + content::BrowserThread::UI).get()); time_source_->SetClient(this); } @@ -333,7 +336,8 @@ class AtomBeginFrameTimer : public cc::DelayBasedTimeSourceClient { }; OffScreenRenderWidgetHostView::OffScreenRenderWidgetHostView( - content::RenderWidgetHost* host, NativeWindow* native_window): render_widget_host_(content::RenderWidgetHostImpl::From(host)), + content::RenderWidgetHost* host, NativeWindow* native_window): + render_widget_host_(content::RenderWidgetHostImpl::From(host)), native_window_(native_window), software_output_device_(NULL), callback_(nullptr), @@ -610,7 +614,8 @@ void OffScreenRenderWidgetHostView::TextInputStateChanged( void OffScreenRenderWidgetHostView::ImeCancelComposition() { } -void OffScreenRenderWidgetHostView::RenderProcessGone(base::TerminationStatus,int) { +void OffScreenRenderWidgetHostView::RenderProcessGone(base::TerminationStatus, + int) { Destroy(); } @@ -625,18 +630,19 @@ void OffScreenRenderWidgetHostView::SelectionBoundsChanged( const ViewHostMsg_SelectionBounds_Params &) { } -void OffScreenRenderWidgetHostView::CopyFromCompositingSurface(const gfx::Rect& src_subrect, - const gfx::Size& dst_size, - const content::ReadbackRequestCallback& callback, - const SkColorType preferred_color_type) { +void OffScreenRenderWidgetHostView::CopyFromCompositingSurface( + const gfx::Rect& src_subrect, + const gfx::Size& dst_size, + const content::ReadbackRequestCallback& callback, + const SkColorType preferred_color_type) { delegated_frame_host_->CopyFromCompositingSurface( src_subrect, dst_size, callback, preferred_color_type); } void OffScreenRenderWidgetHostView::CopyFromCompositingSurfaceToVideoFrame( - const gfx::Rect& src_subrect, - const scoped_refptr& target, - const base::Callback& callback) { + const gfx::Rect& src_subrect, + const scoped_refptr& target, + const base::Callback& callback) { delegated_frame_host_->CopyFromCompositingSurfaceToVideoFrame( src_subrect, target, callback); } @@ -658,7 +664,8 @@ bool OffScreenRenderWidgetHostView::HasAcceleratedSurface(const gfx::Size &) { return false; } -void OffScreenRenderWidgetHostView::GetScreenInfo(blink::WebScreenInfo* results) { +void OffScreenRenderWidgetHostView::GetScreenInfo( + blink::WebScreenInfo* results) { results->rect = gfx::Rect(size_); results->availableRect = gfx::Rect(size_); results->depth = 24; @@ -668,7 +675,8 @@ void OffScreenRenderWidgetHostView::GetScreenInfo(blink::WebScreenInfo* results) results->orientationType = blink::WebScreenOrientationLandscapePrimary; } -bool OffScreenRenderWidgetHostView::GetScreenColorProfile(blink::WebVector*) { +bool OffScreenRenderWidgetHostView::GetScreenColorProfile( + blink::WebVector*) { return false; } @@ -694,7 +702,9 @@ gfx::Size OffScreenRenderWidgetHostView::GetRequestedRendererSize() const { return size_; } -int OffScreenRenderWidgetHostView::DelegatedFrameHostGetGpuMemoryBufferClientId() const { +int OffScreenRenderWidgetHostView:: + DelegatedFrameHostGetGpuMemoryBufferClientId() + const { return render_widget_host_->GetProcess()->GetID(); } @@ -721,7 +731,8 @@ bool OffScreenRenderWidgetHostView::DelegatedFrameCanCreateResizeLock() const { } std::unique_ptr - OffScreenRenderWidgetHostView::DelegatedFrameHostCreateResizeLock(bool) { + OffScreenRenderWidgetHostView::DelegatedFrameHostCreateResizeLock( + bool defer_compositor_lock) { return nullptr; } @@ -736,14 +747,16 @@ void OffScreenRenderWidgetHostView::DelegatedFrameHostSendCompositorSwapAck( output_surface_id, ack)); } -void OffScreenRenderWidgetHostView::DelegatedFrameHostSendReclaimCompositorResources( +void OffScreenRenderWidgetHostView:: + DelegatedFrameHostSendReclaimCompositorResources( int output_surface_id, const cc::CompositorFrameAck& ack) { render_widget_host_->Send(new ViewMsg_ReclaimCompositorResources( render_widget_host_->GetRoutingID(), output_surface_id, ack)); } -void OffScreenRenderWidgetHostView::DelegatedFrameHostOnLostCompositorResources() { +void OffScreenRenderWidgetHostView:: + DelegatedFrameHostOnLostCompositorResources() { render_widget_host_->ScheduleComposite(); } @@ -753,7 +766,8 @@ void OffScreenRenderWidgetHostView::DelegatedFrameHostUpdateVSyncParameters( } std::unique_ptr - OffScreenRenderWidgetHostView::CreateSoftwareOutputDevice(ui::Compositor* compositor) { + OffScreenRenderWidgetHostView::CreateSoftwareOutputDevice( + ui::Compositor* compositor) { DCHECK_EQ(compositor_.get(), compositor); DCHECK(!copy_frame_generator_); DCHECK(!software_output_device_); diff --git a/atom/browser/osr_render_widget_host_view.h b/atom/browser/osr_render_widget_host_view.h index 3463c2b801..67fc0ef91b 100644 --- a/atom/browser/osr_render_widget_host_view.h +++ b/atom/browser/osr_render_widget_host_view.h @@ -5,6 +5,9 @@ #ifndef ATOM_BROWSER_OSR_RENDER_WIDGET_HOST_VIEW_H_ #define ATOM_BROWSER_OSR_RENDER_WIDGET_HOST_VIEW_H_ +#include +#include + #include "atom/browser/native_window.h" #include "content/browser/renderer_host/render_widget_host_view_base.h" @@ -59,82 +62,85 @@ class OffScreenRenderWidgetHostView: #endif public ui::CompositorDelegate, public content::DelegatedFrameHostClient { -public: + public: OffScreenRenderWidgetHostView(content::RenderWidgetHost*, NativeWindow*); ~OffScreenRenderWidgetHostView(); // content::RenderWidgetHostView bool OnMessageReceived(const IPC::Message&) override; - void InitAsChild(gfx::NativeView) override; - content::RenderWidgetHost* GetRenderWidgetHost(void) const override; - void SetSize(const gfx::Size &) override; - void SetBounds(const gfx::Rect &) override; - gfx::Vector2dF GetLastScrollOffset(void) const override; - gfx::NativeView GetNativeView(void) const override; - gfx::NativeViewAccessible GetNativeViewAccessible(void) override; - ui::TextInputClient* GetTextInputClient() override; - void Focus(void) override; - bool HasFocus(void) const override; - bool IsSurfaceAvailableForCopy(void) const override; - void Show(void) override; - void Hide(void) override; - bool IsShowing(void) override; - gfx::Rect GetViewBounds(void) const override; - gfx::Size GetVisibleViewportSize() const override; - void SetInsets(const gfx::Insets&) override; - bool LockMouse(void) override; - void UnlockMouse(void) override; - bool GetScreenColorProfile(std::vector*) override; - + void InitAsChild(gfx::NativeView) override; + content::RenderWidgetHost* GetRenderWidgetHost(void) const override; + void SetSize(const gfx::Size &) override; + void SetBounds(const gfx::Rect &) override; + gfx::Vector2dF GetLastScrollOffset(void) const override; + gfx::NativeView GetNativeView(void) const override; + gfx::NativeViewAccessible GetNativeViewAccessible(void) override; + ui::TextInputClient* GetTextInputClient() override; + void Focus(void) override; + bool HasFocus(void) const override; + bool IsSurfaceAvailableForCopy(void) const override; + void Show(void) override; + void Hide(void) override; + bool IsShowing(void) override; + gfx::Rect GetViewBounds(void) const override; + gfx::Size GetVisibleViewportSize() const override; + void SetInsets(const gfx::Insets&) override; + bool LockMouse(void) override; + void UnlockMouse(void) override; + bool GetScreenColorProfile(std::vector*) override; + #if defined(OS_MACOSX) - ui::AcceleratedWidgetMac* GetAcceleratedWidgetMac() const override; - void SetActive(bool active) override; - void ShowDefinitionForSelection() override; - bool SupportsSpeech() const override; - void SpeakSelection() override; - bool IsSpeaking() const override; - void StopSpeaking() override; -#endif // defined(OS_MACOSX) - - // content::RenderWidgetHostViewBase - void OnSwapCompositorFrame(uint32_t, std::unique_ptr) override; - void ClearCompositorFrame(void) override; - void InitAsPopup(content::RenderWidgetHostView *, const gfx::Rect &) override; - void InitAsFullscreen(content::RenderWidgetHostView *) override; - void UpdateCursor(const content::WebCursor &) override; - void SetIsLoading(bool) override; - void TextInputStateChanged(const content::TextInputState& params) override; - void ImeCancelComposition(void) override; - void RenderProcessGone(base::TerminationStatus,int) override; - void Destroy(void) override; - void SetTooltipText(const base::string16 &) override; - -#if defined(OS_MACOSX) - void SelectionChanged(const base::string16& text, - size_t offset, - const gfx::Range& range) override; -#endif - - void SelectionBoundsChanged(const ViewHostMsg_SelectionBounds_Params &) override; - void CopyFromCompositingSurface(const gfx::Rect &, - const gfx::Size &, - const content::ReadbackRequestCallback &, - const SkColorType) override; - void CopyFromCompositingSurfaceToVideoFrame( - const gfx::Rect &, - const scoped_refptr &, - const base::Callback &) override; - bool CanCopyToVideoFrame(void) const override; - void BeginFrameSubscription( - std::unique_ptr) override; - void EndFrameSubscription() override; - bool HasAcceleratedSurface(const gfx::Size &) override; - void GetScreenInfo(blink::WebScreenInfo *) override; - bool GetScreenColorProfile(blink::WebVector*); - gfx::Rect GetBoundsInRootWindow(void) override; - void LockCompositingSurface(void) override; - void UnlockCompositingSurface(void) override; + ui::AcceleratedWidgetMac* GetAcceleratedWidgetMac() const override; + void SetActive(bool active) override; + void ShowDefinitionForSelection() override; + bool SupportsSpeech() const override; + void SpeakSelection() override; + bool IsSpeaking() const override; + void StopSpeaking() override; +#endif // defined(OS_MACOSX) + + // content::RenderWidgetHostViewBase + void OnSwapCompositorFrame(uint32_t, std::unique_ptr) + override; + void ClearCompositorFrame(void) override; + void InitAsPopup(content::RenderWidgetHostView *rwhv, const gfx::Rect& rect) + override; + void InitAsFullscreen(content::RenderWidgetHostView *) override; + void UpdateCursor(const content::WebCursor &) override; + void SetIsLoading(bool is_loading) override; + void TextInputStateChanged(const content::TextInputState& params) override; + void ImeCancelComposition(void) override; + void RenderProcessGone(base::TerminationStatus, int) override; + void Destroy(void) override; + void SetTooltipText(const base::string16 &) override; + +#if defined(OS_MACOSX) + void SelectionChanged(const base::string16& text, + size_t offset, + const gfx::Range& range) override; +#endif + + void SelectionBoundsChanged(const ViewHostMsg_SelectionBounds_Params &) + override; + void CopyFromCompositingSurface(const gfx::Rect &, + const gfx::Size &, + const content::ReadbackRequestCallback &, + const SkColorType) override; + void CopyFromCompositingSurfaceToVideoFrame( + const gfx::Rect &, + const scoped_refptr &, + const base::Callback &) override; + bool CanCopyToVideoFrame(void) const override; + void BeginFrameSubscription( + std::unique_ptr) override; + void EndFrameSubscription() override; + bool HasAcceleratedSurface(const gfx::Size &) override; + void GetScreenInfo(blink::WebScreenInfo *) override; + bool GetScreenColorProfile(blink::WebVector*); + gfx::Rect GetBoundsInRootWindow(void) override; + void LockCompositingSurface(void) override; + void UnlockCompositingSurface(void) override; void ImeCompositionRangeChanged( const gfx::Range &, const std::vector&) override; gfx::Size GetPhysicalBackingSize() const override; @@ -147,7 +153,8 @@ public: SkColor DelegatedFrameHostGetGutterColor(SkColor) const override; gfx::Size DelegatedFrameHostDesiredSizeInDIP(void) const override; bool DelegatedFrameCanCreateResizeLock(void) const override; - std::unique_ptr DelegatedFrameHostCreateResizeLock(bool) override; + std::unique_ptr DelegatedFrameHostCreateResizeLock( + bool defer_compositor_lock) override; void DelegatedFrameHostResizeLockWasReleased(void) override; void DelegatedFrameHostSendCompositorSwapAck( int, const cc::CompositorFrameAck &) override; @@ -190,13 +197,13 @@ public: int bitmap_height, void* bitmap_pixels); - void SetPainting(bool); + void SetPainting(bool painting); bool IsPainting() const; - void SetFrameRate(int); + void SetFrameRate(int frame_rate); int GetFrameRate() const; private: - void SetupFrameRate(bool); + void SetupFrameRate(bool force); void ResizeRootLayer(); content::RenderWidgetHostImpl* render_widget_host_; diff --git a/atom/browser/osr_render_widget_host_view_win.cc b/atom/browser/osr_render_widget_host_view_win.cc index 285f4212c8..80e63c9b06 100644 --- a/atom/browser/osr_render_widget_host_view_win.cc +++ b/atom/browser/osr_render_widget_host_view_win.cc @@ -9,7 +9,7 @@ namespace atom { class DummyWindowWin : public gfx::WindowImpl { -public: + public: DummyWindowWin() { // Create a hidden 1x1 borderless window. set_window_style(WS_POPUP | WS_SYSMENU); @@ -20,7 +20,7 @@ public: DestroyWindow(hwnd()); } -private: + private: CR_BEGIN_MSG_MAP_EX(DummyWindowWin) CR_MSG_WM_PAINT(OnPaint) CR_END_MSG_MAP() diff --git a/atom/browser/osr_web_contents_view.h b/atom/browser/osr_web_contents_view.h index efab017fd9..a755248dda 100644 --- a/atom/browser/osr_web_contents_view.h +++ b/atom/browser/osr_web_contents_view.h @@ -13,8 +13,7 @@ namespace atom { class OffScreenWebContentsView : public content::WebContentsView, public content::RenderViewHostDelegateView { -public: - + public: OffScreenWebContentsView(); ~OffScreenWebContentsView(); @@ -60,7 +59,7 @@ public: const content::DragEventSourceInfo& event_info) override; void UpdateDragCursor(blink::WebDragOperation operation) override; -private: + private: content::RenderWidgetHostViewBase* view_; content::WebContents* web_contents_; };