diff options
author | nick@chromium.org <nick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-05 20:12:12 +0000 |
---|---|---|
committer | nick@chromium.org <nick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-05 20:12:12 +0000 |
commit | 5cdd8fd8e343dbaa131256302eb338eeac7eb2aa (patch) | |
tree | c95bcb8907541f56dfeff6739e17af04ab7cd6f0 | |
parent | f05966bbaca4477d86688492cc49afe8333dadde (diff) | |
download | chromium_src-5cdd8fd8e343dbaa131256302eb338eeac7eb2aa.zip chromium_src-5cdd8fd8e343dbaa131256302eb338eeac7eb2aa.tar.gz chromium_src-5cdd8fd8e343dbaa131256302eb338eeac7eb2aa.tar.bz2 |
Under --site-per-process, route input events from parent process to child frames.
The chain of forwarding starts with an event, in blink, that had been not handled by the document node of a swapped-out frame. It comes into the RenderFrameImpl via the forwardInputEvent method of the blink::WebFrameClient interface. A new IPC message FrameHostMsg_ForwardInputEvent is sent from the renderer process of the parent frame to the browser process, where it is handled by the child frame's CrossProcessFrameConnector, which in turn forwards the event to the RWH hosting the child frame, where it's treated as an ordinary input event.
Related blink change: http://codereview.chromium.org/138003011
The code here is modeled after existing code in BrowserPluginGuest.
BUG=305811, 339659
TEST=loading chromium.org in an iframe under --site-per-process; verify hovering and typing into search box works properly
Review URL: https://codereview.chromium.org/130433016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@249097 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | content/browser/frame_host/cross_process_frame_connector.cc | 37 | ||||
-rw-r--r-- | content/browser/frame_host/cross_process_frame_connector.h | 5 | ||||
-rw-r--r-- | content/common/frame_messages.h | 7 | ||||
-rw-r--r-- | content/common/swapped_out_messages.cc | 2 | ||||
-rw-r--r-- | content/renderer/render_frame_impl.cc | 4 | ||||
-rw-r--r-- | content/renderer/render_frame_impl.h | 2 |
6 files changed, 56 insertions, 1 deletions
diff --git a/content/browser/frame_host/cross_process_frame_connector.cc b/content/browser/frame_host/cross_process_frame_connector.cc index 520eeb60..f386df8 100644 --- a/content/browser/frame_host/cross_process_frame_connector.cc +++ b/content/browser/frame_host/cross_process_frame_connector.cc @@ -6,9 +6,11 @@ #include "content/browser/frame_host/render_frame_host_impl.h" #include "content/browser/frame_host/render_widget_host_view_child_frame.h" +#include "content/browser/renderer_host/render_view_host_impl.h" #include "content/browser/renderer_host/render_widget_host_impl.h" #include "content/common/frame_messages.h" #include "content/common/gpu/gpu_messages.h" +#include "third_party/WebKit/public/web/WebInputEvent.h" namespace content { @@ -16,7 +18,7 @@ CrossProcessFrameConnector::CrossProcessFrameConnector( RenderFrameHostImpl* frame_proxy_in_parent_renderer) : frame_proxy_in_parent_renderer_(frame_proxy_in_parent_renderer), view_(NULL) { - frame_proxy_in_parent_renderer->set_cross_process_frame_connector(this); + frame_proxy_in_parent_renderer->set_cross_process_frame_connector(this); } CrossProcessFrameConnector::~CrossProcessFrameConnector() { @@ -34,6 +36,7 @@ bool CrossProcessFrameConnector::OnMessageReceived(const IPC::Message& msg) { OnCompositorFrameSwappedACK) IPC_MESSAGE_HANDLER(FrameHostMsg_ReclaimCompositorResources, OnReclaimCompositorResources) + IPC_MESSAGE_HANDLER(FrameHostMsg_ForwardInputEvent, OnForwardInputEvent) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP_EX() @@ -120,4 +123,36 @@ gfx::Rect CrossProcessFrameConnector::ChildFrameRect() { return child_frame_rect_; } +void CrossProcessFrameConnector::OnForwardInputEvent( + const blink::WebInputEvent* event) { + if (!view_) + return; + + RenderWidgetHostImpl* child_widget = + RenderWidgetHostImpl::From(view_->GetRenderWidgetHost()); + RenderWidgetHostImpl* parent_widget = + frame_proxy_in_parent_renderer_->render_view_host(); + + if (blink::WebInputEvent::isKeyboardEventType(event->type)) { + if (!parent_widget->GetLastKeyboardEvent()) + return; + NativeWebKeyboardEvent keyboard_event( + *parent_widget->GetLastKeyboardEvent()); + child_widget->ForwardKeyboardEvent(keyboard_event); + return; + } + + if (blink::WebInputEvent::isMouseEventType(event->type)) { + child_widget->ForwardMouseEvent( + *static_cast<const blink::WebMouseEvent*>(event)); + return; + } + + if (event->type == blink::WebInputEvent::MouseWheel) { + child_widget->ForwardWheelEvent( + *static_cast<const blink::WebMouseWheelEvent*>(event)); + return; + } +} + } // namespace content diff --git a/content/browser/frame_host/cross_process_frame_connector.h b/content/browser/frame_host/cross_process_frame_connector.h index 4ab8e02..61103f6 100644 --- a/content/browser/frame_host/cross_process_frame_connector.h +++ b/content/browser/frame_host/cross_process_frame_connector.h @@ -8,6 +8,10 @@ #include "cc/output/compositor_frame.h" #include "ui/gfx/rect.h" +namespace blink { +class WebInputEvent; +} + namespace IPC { class Message; } @@ -94,6 +98,7 @@ class CrossProcessFrameConnector { const FrameHostMsg_CompositorFrameSwappedACK_Params& params); void OnReclaimCompositorResources( const FrameHostMsg_ReclaimCompositorResources_Params& params); + void OnForwardInputEvent(const blink::WebInputEvent* event); // The RenderFrameHost that routes messages to the parent frame's renderer // process. diff --git a/content/common/frame_messages.h b/content/common/frame_messages.h index 625b0e0..9ebf35a 100644 --- a/content/common/frame_messages.h +++ b/content/common/frame_messages.h @@ -6,6 +6,7 @@ // Multiply-included message file, hence no include guard. #include "content/common/content_export.h" +#include "content/common/content_param_traits.h" #include "content/common/frame_param.h" #include "content/public/common/common_param_traits.h" #include "content/public/common/context_menu_params.h" @@ -224,6 +225,12 @@ IPC_MESSAGE_ROUTED0(FrameHostMsg_SwapOut_ACK) IPC_MESSAGE_ROUTED1(FrameHostMsg_ReclaimCompositorResources, FrameHostMsg_ReclaimCompositorResources_Params /* params */) +// Forwards an input event to a child. +// TODO(nick): Temporary bridge, revisit once the browser process can route +// input directly to subframes. http://crbug.com/339659 +IPC_MESSAGE_ROUTED1(FrameHostMsg_ForwardInputEvent, + IPC::WebInputEventPointer /* event */) + // Instructs the frame to swap out for a cross-site transition, including // running the unload event handler. Expects a SwapOut_ACK message when // finished. diff --git a/content/common/swapped_out_messages.cc b/content/common/swapped_out_messages.cc index e2e920e..6572ad0 100644 --- a/content/common/swapped_out_messages.cc +++ b/content/common/swapped_out_messages.cc @@ -43,6 +43,8 @@ bool SwappedOutMessages::CanSendWhileSwappedOut(const IPC::Message* msg) { case FrameHostMsg_CompositorFrameSwappedACK::ID: case FrameHostMsg_BuffersSwappedACK::ID: case FrameHostMsg_ReclaimCompositorResources::ID: + // Input events propagate from parent to child. + case FrameHostMsg_ForwardInputEvent::ID: return true; default: break; diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc index 5aa6180..b5c52da 100644 --- a/content/renderer/render_frame_impl.cc +++ b/content/renderer/render_frame_impl.cc @@ -1629,6 +1629,10 @@ void RenderFrameImpl::showContextMenu(const blink::WebContextMenuData& data) { Send(new FrameHostMsg_ContextMenu(routing_id_, params)); } +void RenderFrameImpl::forwardInputEvent(const blink::WebInputEvent* event) { + Send(new FrameHostMsg_ForwardInputEvent(routing_id_, event)); +} + void RenderFrameImpl::AddObserver(RenderFrameObserver* observer) { observers_.AddObserver(observer); } diff --git a/content/renderer/render_frame_impl.h b/content/renderer/render_frame_impl.h index 48e564b..ba75851 100644 --- a/content/renderer/render_frame_impl.h +++ b/content/renderer/render_frame_impl.h @@ -26,6 +26,7 @@ struct FrameMsg_BuffersSwapped_Params; struct FrameMsg_CompositorFrameSwapped_Params; namespace blink { +class WebInputEvent; class WebMouseEvent; struct WebCompositionUnderline; struct WebContextMenuData; @@ -326,6 +327,7 @@ class CONTENT_EXPORT RenderFrameImpl virtual bool allowWebGL(blink::WebFrame* frame, bool default_value); virtual void didLoseWebGLContext(blink::WebFrame* frame, int arb_robustness_status_code); + virtual void forwardInputEvent(const blink::WebInputEvent* event); // TODO(jam): move this to WebFrameClient virtual void showContextMenu(const blink::WebContextMenuData& data); |