diff options
6 files changed, 43 insertions, 1 deletions
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index 5fee2fb..969c6fa 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -1371,6 +1371,26 @@ gfx::Rect RenderViewHost::GetRootWindowResizerRect() const { return delegate_->GetRootWindowResizerRect(); } +void RenderViewHost::ForwardMouseEvent( + const WebKit::WebMouseEvent& mouse_event) { + RenderWidgetHost::ForwardMouseEvent(mouse_event); + + RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); + if (view) { + switch (mouse_event.type) { + case WebInputEvent::MouseMove: + view->HandleMouseEvent(); + break; + case WebInputEvent::MouseLeave: + view->HandleMouseLeave(); + break; + default: + // For now, we don't care about the rest. + break; + } + } +} + void RenderViewHost::OnDebugDisconnect() { if (debugger_attached_) { debugger_attached_ = false; diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h index b23d63b..5c20c12 100644 --- a/chrome/browser/renderer_host/render_view_host.h +++ b/chrome/browser/renderer_host/render_view_host.h @@ -417,6 +417,7 @@ class RenderViewHost : public RenderWidgetHost { virtual bool IsRenderView() { return true; } virtual void OnMessageReceived(const IPC::Message& msg); virtual bool CanBlur() const; + virtual void ForwardMouseEvent(const WebKit::WebMouseEvent& mouse_event); virtual gfx::Rect GetRootWindowResizerRect() const; // Creates a new RenderView with the given route id. diff --git a/chrome/browser/renderer_host/render_view_host_delegate.h b/chrome/browser/renderer_host/render_view_host_delegate.h index 14c1337..39794de 100644 --- a/chrome/browser/renderer_host/render_view_host_delegate.h +++ b/chrome/browser/renderer_host/render_view_host_delegate.h @@ -118,6 +118,11 @@ class RenderViewHostDelegate { // event (used for keyboard shortcuts). virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) = 0; + // Notifications about mouse events in this view. This is useful for + // implementing global 'on hover' features external to the view. + virtual void HandleMouseEvent() {} + virtual void HandleMouseLeave() {} + // The content's intrinsic width (prefWidth) changed. virtual void UpdatePreferredWidth(int pref_width) = 0; }; diff --git a/chrome/browser/renderer_host/render_widget_host.h b/chrome/browser/renderer_host/render_widget_host.h index 27cb467..8e12099 100644 --- a/chrome/browser/renderer_host/render_widget_host.h +++ b/chrome/browser/renderer_host/render_widget_host.h @@ -211,7 +211,7 @@ class RenderWidgetHost : public IPC::Channel::Listener { // Forwards the given message to the renderer. These are called by the view // when it has received a message. - void ForwardMouseEvent(const WebKit::WebMouseEvent& mouse_event); + virtual void ForwardMouseEvent(const WebKit::WebMouseEvent& mouse_event); void ForwardWheelEvent(const WebKit::WebMouseWheelEvent& wheel_event); void ForwardKeyboardEvent(const NativeWebKeyboardEvent& key_event); diff --git a/chrome/browser/tab_contents/interstitial_page.cc b/chrome/browser/tab_contents/interstitial_page.cc index 04afbbc..f697488 100644 --- a/chrome/browser/tab_contents/interstitial_page.cc +++ b/chrome/browser/tab_contents/interstitial_page.cc @@ -85,6 +85,8 @@ class InterstitialPage::InterstitialPageRVHViewDelegate virtual void UpdateDragCursor(bool is_drop_target); virtual void TakeFocus(bool reverse); virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event); + virtual void HandleMouseEvent(); + virtual void HandleMouseLeave(); virtual void OnFindReply(int request_id, int number_of_matches, const gfx::Rect& selection_rect, @@ -533,6 +535,16 @@ void InterstitialPage::InterstitialPageRVHViewDelegate::HandleKeyboardEvent( interstitial_page_->tab()->GetViewDelegate()->HandleKeyboardEvent(event); } +void InterstitialPage::InterstitialPageRVHViewDelegate::HandleMouseEvent() { + if (interstitial_page_->tab() && interstitial_page_->tab()->GetViewDelegate()) + interstitial_page_->tab()->GetViewDelegate()->HandleMouseEvent(); +} + +void InterstitialPage::InterstitialPageRVHViewDelegate::HandleMouseLeave() { + if (interstitial_page_->tab() && interstitial_page_->tab()->GetViewDelegate()) + interstitial_page_->tab()->GetViewDelegate()->HandleMouseLeave(); +} + void InterstitialPage::InterstitialPageRVHViewDelegate::OnFindReply( int request_id, int number_of_matches, const gfx::Rect& selection_rect, int active_match_ordinal, bool final_update) { diff --git a/chrome/browser/tab_contents/tab_contents_view.h b/chrome/browser/tab_contents/tab_contents_view.h index c5868b0..a7299f1 100644 --- a/chrome/browser/tab_contents/tab_contents_view.h +++ b/chrome/browser/tab_contents/tab_contents_view.h @@ -129,6 +129,10 @@ class TabContentsView : public RenderViewHostDelegate::View { // invoked, SetInitialFocus is invoked. virtual void RestoreFocus() = 0; + // Simple mouse event forwarding from the RenderViewHost. + virtual void HandleMouseEvent() {} + virtual void HandleMouseLeave() {} + // Set and return the content's intrinsic width. virtual void UpdatePreferredWidth(int pref_width); int preferred_width() const { |