Index: content/renderer/gpu/compositor_thread.cc |
diff --git a/content/renderer/gpu/compositor_thread.cc b/content/renderer/gpu/compositor_thread.cc |
index d4c790c297ff3a5973b22bd3abf1c52fa328617b..287d35a938cffa9834d2378c8f48a27ebbe30bd7 100644 |
--- a/content/renderer/gpu/compositor_thread.cc |
+++ b/content/renderer/gpu/compositor_thread.cc |
@@ -6,9 +6,12 @@ |
#include "base/bind.h" |
#include "content/renderer/gpu/input_event_filter.h" |
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositor.h" |
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositorClient.h" |
+#include "content/public/renderer/render_view.h" |
+#include "content/public/renderer/render_view_visitor.h" |
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebActiveWheelFlingParameters.h" |
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositorInputHandlerClient.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositorInputHandler.h" |
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
using WebKit::WebCompositorInputHandler; |
using WebKit::WebInputEvent; |
@@ -16,17 +19,29 @@ using WebKit::WebInputEvent; |
//------------------------------------------------------------------------------ |
class CompositorThread::InputHandlerWrapper |
- : public WebKit::WebCompositorClient { |
+ : public WebKit::WebCompositorInputHandlerClient { |
public: |
InputHandlerWrapper(CompositorThread* compositor_thread, |
int routing_id, |
- WebKit::WebCompositorInputHandler* input_handler) |
+ WebKit::WebCompositorInputHandler* input_handler, |
+ scoped_refptr<base::MessageLoopProxy> main_loop) |
: compositor_thread_(compositor_thread), |
routing_id_(routing_id), |
- input_handler_(input_handler) { |
+ input_handler_(input_handler), |
+ main_loop_(main_loop), |
+ render_view_finder_(routing_id) { |
input_handler_->setClient(this); |
} |
+ virtual void transferActiveWheelFlingAnimation( |
+ const WebKit::WebActiveWheelFlingParameters& params) { |
+ main_loop_->PostTask( |
+ FROM_HERE, |
+ base::Bind(&CompositorThread::InputHandlerWrapper |
+ ::TransferActiveWheelFlingAnimation, |
+ base::Unretained(this), params)); |
+ } |
+ |
virtual ~InputHandlerWrapper() { |
input_handler_->setClient(NULL); |
} |
@@ -36,7 +51,7 @@ class CompositorThread::InputHandlerWrapper |
return input_handler_; |
} |
- // WebCompositorClient methods: |
+ // WebCompositorInputHandlerClient methods: |
virtual void willShutdown() { |
compositor_thread_->RemoveInputHandler(routing_id_); |
@@ -51,9 +66,46 @@ class CompositorThread::InputHandlerWrapper |
} |
private: |
+ // TODO(jamesr): There's got to be a better way to do this. Do we have a map |
+ // from routing_id -> RenderView / RenderViewImpl somewhere? |
+ class FindRenderViewByRoutingIDVisitor : public content::RenderViewVisitor { |
+ public: |
+ explicit FindRenderViewByRoutingIDVisitor(int routing_id) |
+ : routing_id_(routing_id) , |
+ render_view_(NULL) { |
+ } |
+ |
+ content::RenderView* FindRenderView() { |
+ if (!render_view_) |
+ content::RenderView::ForEach(this); |
+ return render_view_; |
+ } |
+ |
+ virtual bool Visit(content::RenderView* render_view) OVERRIDE { |
+ if (render_view->GetRoutingID() == routing_id_) |
+ return false; |
+ return true; |
+ } |
+ |
+ private: |
+ int routing_id_; |
+ // We will always destroy the CompositorWrapper through |
jamesr
2012/03/21 14:38:31
note: I haven't fully convinced myself that this i
|
+ // CompositorThread::RemoveCompositor before the view goes away, so it's |
+ // safe to stash a raw pointer here. |
+ content::RenderView* render_view_; |
+ }; |
+ |
+ void TransferActiveWheelFlingAnimation( |
+ WebKit::WebActiveWheelFlingParameters params) { |
+ render_view_finder_.FindRenderView()-> |
+ GetWebView()->transferActiveWheelFlingAnimation(params); |
+ } |
+ |
CompositorThread* compositor_thread_; |
int routing_id_; |
WebKit::WebCompositorInputHandler* input_handler_; |
+ scoped_refptr<base::MessageLoopProxy> main_loop_; |
+ FindRenderViewByRoutingIDVisitor render_view_finder_; |
DISALLOW_COPY_AND_ASSIGN(InputHandlerWrapper); |
}; |
@@ -77,13 +129,22 @@ IPC::ChannelProxy::MessageFilter* CompositorThread::GetMessageFilter() const { |
} |
void CompositorThread::AddInputHandler(int routing_id, int input_handler_id) { |
- if (thread_.message_loop() != MessageLoop::current()) { |
- thread_.message_loop()->PostTask( |
- FROM_HERE, |
- base::Bind(&CompositorThread::AddInputHandler, base::Unretained(this), |
- routing_id, input_handler_id)); |
- return; |
- } |
+ DCHECK_NE(thread_.message_loop(), MessageLoop::current()); |
+ |
+ thread_.message_loop()->PostTask( |
+ FROM_HERE, |
+ base::Bind(&CompositorThread::AddInputHandlerOnCompositorThread, |
+ base::Unretained(this), |
+ routing_id, |
+ input_handler_id, |
+ base::MessageLoopProxy::current())); |
+} |
+ |
+void CompositorThread::AddInputHandlerOnCompositorThread( |
+ int routing_id, int input_handler_id, |
+ scoped_refptr<base::MessageLoopProxy> main_loop) { |
+ |
+ DCHECK_EQ(thread_.message_loop(), MessageLoop::current()); |
WebCompositorInputHandler* input_handler = |
WebCompositorInputHandler::fromIdentifier(input_handler_id); |
@@ -100,11 +161,12 @@ void CompositorThread::AddInputHandler(int routing_id, int input_handler_id) { |
filter_->AddRoute(routing_id); |
input_handlers_[routing_id] = |
- make_linked_ptr(new InputHandlerWrapper(this, routing_id, input_handler)); |
+ make_linked_ptr(new InputHandlerWrapper(this, |
+ routing_id, input_handler, main_loop)); |
} |
void CompositorThread::RemoveInputHandler(int routing_id) { |
- DCHECK(thread_.message_loop() == MessageLoop::current()); |
+ DCHECK_EQ(MessageLoop::current(), thread_.message_loop()); |
filter_->RemoveRoute(routing_id); |
input_handlers_.erase(routing_id); |