summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormgiuca <mgiuca@chromium.org>2016-01-06 19:18:27 -0800
committerCommit bot <commit-bot@chromium.org>2016-01-07 03:20:04 +0000
commit1c92cab4c88f614b19c4af5fda2cca0f515b6724 (patch)
tree88eb1869d737ced0676558c3a35edc8d6e07486d
parente9533af791d57515fc1d2428321f730de6ae1018 (diff)
downloadchromium_src-1c92cab4c88f614b19c4af5fda2cca0f515b6724.zip
chromium_src-1c92cab4c88f614b19c4af5fda2cca0f515b6724.tar.gz
chromium_src-1c92cab4c88f614b19c4af5fda2cca0f515b6724.tar.bz2
Refactoring WebContentsDelegate::ContentsMouseEvent.
It is now called for all mouse events, not just MOVED and EXITED (matching its name). A new parameter |exited| was added for EXITED events (like the existing |motion| parameter). Rationale: I want to signal the fullscreen bubble on mouse events, and this seemed a good place to do it except it wasn't receiving all mouse events. TBR=wjmaclean@chromium.org Review URL: https://codereview.chromium.org/1566863002 Cr-Commit-Position: refs/heads/master@{#367999}
-rw-r--r--chrome/browser/ui/browser.cc13
-rw-r--r--chrome/browser/ui/browser.h3
-rw-r--r--components/guest_view/browser/guest_view_base.cc5
-rw-r--r--components/guest_view/browser/guest_view_base.h3
-rw-r--r--content/browser/web_contents/web_contents_view_aura.cc20
-rw-r--r--content/browser/web_contents/web_contents_view_mac.mm9
-rw-r--r--content/public/browser/web_contents_delegate.h8
7 files changed, 30 insertions, 31 deletions
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index 1f41d7c..8dd3a53 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -1620,14 +1620,17 @@ void Browser::UpdateTargetURL(WebContents* source, const GURL& url) {
}
}
-void Browser::ContentsMouseEvent(
- WebContents* source, const gfx::Point& location, bool motion) {
- if (!GetStatusBubble())
+void Browser::ContentsMouseEvent(WebContents* source,
+ const gfx::Point& location,
+ bool motion,
+ bool exited) {
+ // Mouse motion events update the status bubble, if it exists.
+ if (!GetStatusBubble() || (!motion && !exited))
return;
if (source == tab_strip_model_->GetActiveWebContents()) {
- GetStatusBubble()->MouseMoved(location, !motion);
- if (!motion)
+ GetStatusBubble()->MouseMoved(location, exited);
+ if (exited)
GetStatusBubble()->SetURL(GURL(), std::string());
}
}
diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h
index e3f6b883..13ec6b4 100644
--- a/chrome/browser/ui/browser.h
+++ b/chrome/browser/ui/browser.h
@@ -575,7 +575,8 @@ class Browser : public TabStripModelObserver,
void UpdateTargetURL(content::WebContents* source, const GURL& url) override;
void ContentsMouseEvent(content::WebContents* source,
const gfx::Point& location,
- bool motion) override;
+ bool motion,
+ bool exited) override;
void ContentsZoomChange(bool zoom_in) override;
bool TakeFocus(content::WebContents* source, bool reverse) override;
gfx::Rect GetRootWindowResizerRect() const override;
diff --git a/components/guest_view/browser/guest_view_base.cc b/components/guest_view/browser/guest_view_base.cc
index ff69424..c2c27c7 100644
--- a/components/guest_view/browser/guest_view_base.cc
+++ b/components/guest_view/browser/guest_view_base.cc
@@ -608,12 +608,13 @@ void GuestViewBase::ActivateContents(WebContents* web_contents) {
void GuestViewBase::ContentsMouseEvent(WebContents* source,
const gfx::Point& location,
- bool motion) {
+ bool motion,
+ bool exited) {
if (!attached() || !embedder_web_contents()->GetDelegate())
return;
embedder_web_contents()->GetDelegate()->ContentsMouseEvent(
- embedder_web_contents(), location, motion);
+ embedder_web_contents(), location, motion, exited);
}
void GuestViewBase::ContentsZoomChange(bool zoom_in) {
diff --git a/components/guest_view/browser/guest_view_base.h b/components/guest_view/browser/guest_view_base.h
index 3dfa4c6..9d5b340 100644
--- a/components/guest_view/browser/guest_view_base.h
+++ b/components/guest_view/browser/guest_view_base.h
@@ -352,7 +352,8 @@ class GuestViewBase : public content::BrowserPluginGuestDelegate,
void ActivateContents(content::WebContents* contents) final;
void ContentsMouseEvent(content::WebContents* source,
const gfx::Point& location,
- bool motion) final;
+ bool motion,
+ bool exited) final;
void ContentsZoomChange(bool zoom_in) final;
void LoadingStateChanged(content::WebContents* source,
bool to_different_document) final;
diff --git a/content/browser/web_contents/web_contents_view_aura.cc b/content/browser/web_contents/web_contents_view_aura.cc
index 41ef84f..a899bf3 100644
--- a/content/browser/web_contents/web_contents_view_aura.cc
+++ b/content/browser/web_contents/web_contents_view_aura.cc
@@ -1192,20 +1192,14 @@ void WebContentsViewAura::OnMouseEvent(ui::MouseEvent* event) {
if (!web_contents_->GetDelegate())
return;
- switch (event->type()) {
- case ui::ET_MOUSE_PRESSED:
+ ui::EventType type = event->type();
+ if (type == ui::ET_MOUSE_PRESSED)
web_contents_->GetDelegate()->ActivateContents(web_contents_);
- break;
- case ui::ET_MOUSE_MOVED:
- case ui::ET_MOUSE_EXITED:
- web_contents_->GetDelegate()->ContentsMouseEvent(
- web_contents_,
- gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(),
- event->type() == ui::ET_MOUSE_MOVED);
- break;
- default:
- break;
- }
+
+ web_contents_->GetDelegate()->ContentsMouseEvent(
+ web_contents_,
+ gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(),
+ type == ui::ET_MOUSE_MOVED, type == ui::ET_MOUSE_EXITED);
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/content/browser/web_contents/web_contents_view_mac.mm b/content/browser/web_contents/web_contents_view_mac.mm
index 33d5ae3..9556dde 100644
--- a/content/browser/web_contents/web_contents_view_mac.mm
+++ b/content/browser/web_contents/web_contents_view_mac.mm
@@ -465,12 +465,9 @@ void WebContentsViewMac::CloseTab() {
WebContentsImpl* webContents = [self webContents];
if (webContents && webContents->GetDelegate()) {
NSPoint location = [NSEvent mouseLocation];
- if ([theEvent type] == NSMouseMoved)
- webContents->GetDelegate()->ContentsMouseEvent(
- webContents, gfx::Point(location.x, location.y), true);
- if ([theEvent type] == NSMouseExited)
- webContents->GetDelegate()->ContentsMouseEvent(
- webContents, gfx::Point(location.x, location.y), false);
+ webContents->GetDelegate()->ContentsMouseEvent(
+ webContents, gfx::Point(location.x, location.y),
+ [theEvent type] == NSMouseMoved, [theEvent type] == NSMouseExited);
}
}
diff --git a/content/public/browser/web_contents_delegate.h b/content/public/browser/web_contents_delegate.h
index 6379fe4..ed46e43 100644
--- a/content/public/browser/web_contents_delegate.h
+++ b/content/public/browser/web_contents_delegate.h
@@ -152,11 +152,13 @@ class CONTENT_EXPORT WebContentsDelegate {
const GURL& url) {}
// Notification that there was a mouse event, along with the absolute
- // coordinates of the mouse pointer and whether it was a normal motion event
- // (otherwise, the pointer left the contents area).
+ // coordinates of the mouse pointer and the type of event. If |motion| is
+ // true, this is a normal motion event. If |exited| is true, the pointer left
+ // the contents area.
virtual void ContentsMouseEvent(WebContents* source,
const gfx::Point& location,
- bool motion) {}
+ bool motion,
+ bool exited) {}
// Request the delegate to change the zoom level of the current tab.
virtual void ContentsZoomChange(bool zoom_in) {}