summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorerikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-18 16:05:24 +0000
committererikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-18 16:05:24 +0000
commit05f6e3828cddb241813ebf1e538ea7f8b25348cb (patch)
treede90ff1ae2a8c290c41c7c5c7f1fe36f446180dd
parentd0001a5d4727367f7cc59437dd02d667e9943cac (diff)
downloadchromium_src-05f6e3828cddb241813ebf1e538ea7f8b25348cb.zip
chromium_src-05f6e3828cddb241813ebf1e538ea7f8b25348cb.tar.gz
chromium_src-05f6e3828cddb241813ebf1e538ea7f8b25348cb.tar.bz2
Forward simplified mouse events to the RenderViewHostDelegate::View so that it can implementsimple hover / tracking behavior.BUG=crbug.com/12067TEST=none (suggestions welcome)
Review URL: http://codereview.chromium.org/113481 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16279 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc20
-rw-r--r--chrome/browser/renderer_host/render_view_host.h1
-rw-r--r--chrome/browser/renderer_host/render_view_host_delegate.h5
-rw-r--r--chrome/browser/renderer_host/render_widget_host.h2
-rw-r--r--chrome/browser/tab_contents/interstitial_page.cc12
-rw-r--r--chrome/browser/tab_contents/tab_contents_view.h4
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 {