From 8c40854983b1c843068c252b30ae762da93bf5ce Mon Sep 17 00:00:00 2001 From: Aleksei Kuzmin Date: Thu, 31 Aug 2017 19:51:40 +0300 Subject: [PATCH] Move handling of DraggableRegionsChanged notification from "view" to "frame". https://codereview.chromium.org/2929493003 --- atom/renderer/atom_render_frame_observer.cc | 20 ++++++++++++++++++++ atom/renderer/atom_render_frame_observer.h | 1 + atom/renderer/atom_render_view_observer.cc | 15 --------------- atom/renderer/atom_render_view_observer.h | 2 -- 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/atom/renderer/atom_render_frame_observer.cc b/atom/renderer/atom_render_frame_observer.cc index 0874ba5fcfee..d64588a17c80 100644 --- a/atom/renderer/atom_render_frame_observer.cc +++ b/atom/renderer/atom_render_frame_observer.cc @@ -4,8 +4,13 @@ #include "atom/renderer/atom_render_frame_observer.h" +#include + +#include "atom/common/api/api_messages.h" #include "content/public/renderer/render_frame.h" +#include "content/public/renderer/render_view.h" #include "third_party/WebKit/public/web/WebDocument.h" +#include "third_party/WebKit/public/web/WebDraggableRegion.h" #include "third_party/WebKit/public/web/WebLocalFrame.h" #include "third_party/WebKit/public/web/WebScriptSource.h" @@ -35,6 +40,21 @@ void AtomRenderFrameObserver::DidCreateScriptContext( } } +void AtomRenderFrameObserver::DraggableRegionsChanged() { + blink::WebVector webregions = + render_frame_->GetWebFrame()->GetDocument().DraggableRegions(); + std::vector regions; + for (auto& webregion : webregions) { + DraggableRegion region; + render_frame_->GetRenderView()->ConvertViewportToWindowViaWidget( + &webregion.bounds); + region.bounds = webregion.bounds; + region.draggable = webregion.draggable; + regions.push_back(region); + } + Send(new AtomViewHostMsg_UpdateDraggableRegions(routing_id(), regions)); +} + void AtomRenderFrameObserver::WillReleaseScriptContext( v8::Local context, int world_id) { diff --git a/atom/renderer/atom_render_frame_observer.h b/atom/renderer/atom_render_frame_observer.h index 6eeb32aac03f..248d5a68096d 100644 --- a/atom/renderer/atom_render_frame_observer.h +++ b/atom/renderer/atom_render_frame_observer.h @@ -27,6 +27,7 @@ class AtomRenderFrameObserver : public content::RenderFrameObserver { void DidClearWindowObject() override; void DidCreateScriptContext(v8::Handle context, int world_id) override; + void DraggableRegionsChanged() override; void WillReleaseScriptContext(v8::Local context, int world_id) override; void OnDestruct() override; diff --git a/atom/renderer/atom_render_view_observer.cc b/atom/renderer/atom_render_view_observer.cc index 94c655b14833..a74abddfb627 100644 --- a/atom/renderer/atom_render_view_observer.cc +++ b/atom/renderer/atom_render_view_observer.cc @@ -24,7 +24,6 @@ #include "net/base/net_module.h" #include "net/grit/net_resources.h" #include "third_party/WebKit/public/web/WebDocument.h" -#include "third_party/WebKit/public/web/WebDraggableRegion.h" #include "third_party/WebKit/public/web/WebElement.h" #include "third_party/WebKit/public/web/WebFrame.h" #include "third_party/WebKit/public/web/WebKit.h" @@ -113,20 +112,6 @@ void AtomRenderViewObserver::EmitIPCEvent(blink::WebLocalFrame* frame, } } -void AtomRenderViewObserver::DraggableRegionsChanged(blink::WebFrame* frame) { - blink::WebVector webregions = - frame->GetDocument().DraggableRegions(); - std::vector regions; - for (auto& webregion : webregions) { - DraggableRegion region; - render_view()->ConvertViewportToWindowViaWidget(&webregion.bounds); - region.bounds = webregion.bounds; - region.draggable = webregion.draggable; - regions.push_back(region); - } - Send(new AtomViewHostMsg_UpdateDraggableRegions(routing_id(), regions)); -} - bool AtomRenderViewObserver::OnMessageReceived(const IPC::Message& message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(AtomRenderViewObserver, message) diff --git a/atom/renderer/atom_render_view_observer.h b/atom/renderer/atom_render_view_observer.h index e9fdae0e99b5..4d3e7cba7a65 100644 --- a/atom/renderer/atom_render_view_observer.h +++ b/atom/renderer/atom_render_view_observer.h @@ -7,7 +7,6 @@ #include "base/strings/string16.h" #include "content/public/renderer/render_view_observer.h" -#include "third_party/WebKit/public/web/WebFrame.h" #include "third_party/WebKit/public/web/WebLocalFrame.h" namespace base { @@ -32,7 +31,6 @@ class AtomRenderViewObserver : public content::RenderViewObserver { private: // content::RenderViewObserver implementation. - void DraggableRegionsChanged(blink::WebFrame* frame) override; bool OnMessageReceived(const IPC::Message& message) override; void OnDestruct() override;