summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgozman@chromium.org <dgozman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-06 07:44:53 +0000
committerdgozman@chromium.org <dgozman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-06 07:44:53 +0000
commit8b2ec2f015f2fa6f0b46635f3c0a15be8928b5b3 (patch)
tree8a7ba4c22749028cc8f624d294938db07ff5d224
parent51542972e394d3101e7f607ebed41056d9159a74 (diff)
downloadchromium_src-8b2ec2f015f2fa6f0b46635f3c0a15be8928b5b3.zip
chromium_src-8b2ec2f015f2fa6f0b46635f3c0a15be8928b5b3.tar.gz
chromium_src-8b2ec2f015f2fa6f0b46635f3c0a15be8928b5b3.tar.bz2
Merge 286280 and 286825 "Touch emulation: issue context menu request for ri..."
> Touch emulation: issue context menu request for right-click. > > It is useful to be able to right-click to bring context menu > instead of doing long-press while touch emulation is on. > > Instead of sending mouse events for right-click (which is undesired > for emulation), we issues an explicit context menu request. > > BUG=395352 > > Review URL: https://codereview.chromium.org/420793002 TBR=dgozman@chromium.org Review URL: https://codereview.chromium.org/443063002 git-svn-id: svn://svn.chromium.org/chrome/branches/2062/src@287731 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/browser/renderer_host/input/touch_emulator.cc5
-rw-r--r--content/browser/renderer_host/input/touch_emulator_client.h1
-rw-r--r--content/browser/renderer_host/input/touch_emulator_unittest.cc2
-rw-r--r--content/browser/renderer_host/render_widget_host_impl.cc5
-rw-r--r--content/browser/renderer_host/render_widget_host_impl.h1
-rw-r--r--content/browser/web_contents/touch_editable_impl_aura.cc3
-rw-r--r--content/common/view_messages.h3
-rw-r--r--content/renderer/render_frame_impl.cc8
-rw-r--r--content/renderer/render_view_impl.cc9
-rw-r--r--content/renderer/render_view_impl.h3
-rw-r--r--content/renderer/render_widget.cc3
-rw-r--r--content/renderer/render_widget.h13
12 files changed, 41 insertions, 15 deletions
diff --git a/content/browser/renderer_host/input/touch_emulator.cc b/content/browser/renderer_host/input/touch_emulator.cc
index c7d5cc6..2ee0247 100644
--- a/content/browser/renderer_host/input/touch_emulator.cc
+++ b/content/browser/renderer_host/input/touch_emulator.cc
@@ -130,6 +130,11 @@ bool TouchEmulator::HandleMouseEvent(const WebMouseEvent& mouse_event) {
if (!enabled_)
return false;
+ if (mouse_event.button == WebMouseEvent::ButtonRight &&
+ mouse_event.type == WebInputEvent::MouseDown) {
+ client_->ShowContextMenuAtPoint(gfx::Point(mouse_event.x, mouse_event.y));
+ }
+
if (mouse_event.button != WebMouseEvent::ButtonLeft)
return true;
diff --git a/content/browser/renderer_host/input/touch_emulator_client.h b/content/browser/renderer_host/input/touch_emulator_client.h
index 92f382f..34ad109 100644
--- a/content/browser/renderer_host/input/touch_emulator_client.h
+++ b/content/browser/renderer_host/input/touch_emulator_client.h
@@ -19,6 +19,7 @@ class CONTENT_EXPORT TouchEmulatorClient {
virtual void ForwardGestureEvent(const blink::WebGestureEvent& event) = 0;
virtual void ForwardTouchEvent(const blink::WebTouchEvent& event) = 0;
virtual void SetCursor(const WebCursor& cursor) = 0;
+ virtual void ShowContextMenuAtPoint(const gfx::Point& point) = 0;
};
} // namespace content
diff --git a/content/browser/renderer_host/input/touch_emulator_unittest.cc b/content/browser/renderer_host/input/touch_emulator_unittest.cc
index 8fdfd54..cc6ec91 100644
--- a/content/browser/renderer_host/input/touch_emulator_unittest.cc
+++ b/content/browser/renderer_host/input/touch_emulator_unittest.cc
@@ -84,6 +84,8 @@ class TouchEmulatorTest : public testing::Test,
virtual void SetCursor(const WebCursor& cursor) OVERRIDE {}
+ virtual void ShowContextMenuAtPoint(const gfx::Point& point) OVERRIDE {}
+
protected:
TouchEmulator* emulator() const {
return emulator_.get();
diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc
index eb03476..6311fce 100644
--- a/content/browser/renderer_host/render_widget_host_impl.cc
+++ b/content/browser/renderer_host/render_widget_host_impl.cc
@@ -1072,6 +1072,11 @@ void RenderWidgetHostImpl::SetCursor(const WebCursor& cursor) {
view_->UpdateCursor(cursor);
}
+void RenderWidgetHostImpl::ShowContextMenuAtPoint(const gfx::Point& point) {
+ Send(new ViewMsg_ShowContextMenu(
+ GetRoutingID(), ui::MENU_SOURCE_MOUSE, point));
+}
+
void RenderWidgetHostImpl::SendCursorVisibilityState(bool is_visible) {
Send(new InputMsg_CursorVisibilityChange(GetRoutingID(), is_visible));
}
diff --git a/content/browser/renderer_host/render_widget_host_impl.h b/content/browser/renderer_host/render_widget_host_impl.h
index 65fa860..e883502 100644
--- a/content/browser/renderer_host/render_widget_host_impl.h
+++ b/content/browser/renderer_host/render_widget_host_impl.h
@@ -295,6 +295,7 @@ class CONTENT_EXPORT RenderWidgetHostImpl
virtual void ForwardTouchEvent(
const blink::WebTouchEvent& touch_event) OVERRIDE;
virtual void SetCursor(const WebCursor& cursor) OVERRIDE;
+ virtual void ShowContextMenuAtPoint(const gfx::Point& point) OVERRIDE;
// Queues a synthetic gesture for testing purposes. Invokes the on_complete
// callback when the gesture is finished running.
diff --git a/content/browser/web_contents/touch_editable_impl_aura.cc b/content/browser/web_contents/touch_editable_impl_aura.cc
index d28fa92..efcd1fc 100644
--- a/content/browser/web_contents/touch_editable_impl_aura.cc
+++ b/content/browser/web_contents/touch_editable_impl_aura.cc
@@ -280,7 +280,8 @@ void TouchEditableImplAura::OpenContextMenu(const gfx::Point& anchor) {
gfx::Point point = anchor;
ConvertPointFromScreen(&point);
RenderWidgetHost* host = rwhva_->GetRenderWidgetHost();
- host->Send(new ViewMsg_ShowContextMenu(host->GetRoutingID(), point));
+ host->Send(new ViewMsg_ShowContextMenu(
+ host->GetRoutingID(), ui::MENU_SOURCE_TOUCH_EDIT_MENU, point));
EndTouchEditing(false);
}
diff --git a/content/common/view_messages.h b/content/common/view_messages.h
index 3815910..d12ba35 100644
--- a/content/common/view_messages.h
+++ b/content/common/view_messages.h
@@ -617,7 +617,8 @@ IPC_MESSAGE_ROUTED1(ViewMsg_SetInitialFocus,
// Sent to inform the renderer to invoke a context menu.
// The parameter specifies the location in the render view's coordinates.
-IPC_MESSAGE_ROUTED1(ViewMsg_ShowContextMenu,
+IPC_MESSAGE_ROUTED2(ViewMsg_ShowContextMenu,
+ ui::MenuSourceType,
gfx::Point /* location where menu should be shown */)
IPC_MESSAGE_ROUTED0(ViewMsg_Stop)
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc
index a1445e6..6f3fa70 100644
--- a/content/renderer/render_frame_impl.cc
+++ b/content/renderer/render_frame_impl.cc
@@ -2269,11 +2269,11 @@ bool RenderFrameImpl::runModalBeforeUnloadDialog(
void RenderFrameImpl::showContextMenu(const blink::WebContextMenuData& data) {
ContextMenuParams params = ContextMenuParamsBuilder::Build(data);
params.source_type = GetRenderWidget()->context_menu_source_type();
- if (params.source_type == ui::MENU_SOURCE_TOUCH_EDIT_MENU) {
- params.x = GetRenderWidget()->touch_editing_context_menu_location().x();
- params.y = GetRenderWidget()->touch_editing_context_menu_location().y();
- }
GetRenderWidget()->OnShowHostContextMenu(&params);
+ if (GetRenderWidget()->has_host_context_menu_location()) {
+ params.x = GetRenderWidget()->host_context_menu_location().x();
+ params.y = GetRenderWidget()->host_context_menu_location().y();
+ }
// Plugins, e.g. PDF, don't currently update the render view when their
// selected text changes, but the context menu params do contain the updated
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index f5bd5eb..3a68a86a 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -3779,11 +3779,14 @@ void RenderViewImpl::DidHideExternalPopupMenu() {
}
#endif
-void RenderViewImpl::OnShowContextMenu(const gfx::Point& location) {
- context_menu_source_type_ = ui::MENU_SOURCE_TOUCH_EDIT_MENU;
- touch_editing_context_menu_location_ = location;
+void RenderViewImpl::OnShowContextMenu(
+ ui::MenuSourceType source_type, const gfx::Point& location) {
+ context_menu_source_type_ = source_type;
+ has_host_context_menu_location_ = true;
+ host_context_menu_location_ = location;
if (webview())
webview()->showContextMenu();
+ has_host_context_menu_location_ = false;
}
void RenderViewImpl::OnEnableViewSourceMode() {
diff --git a/content/renderer/render_view_impl.h b/content/renderer/render_view_impl.h
index 324c4c7..4827abb 100644
--- a/content/renderer/render_view_impl.h
+++ b/content/renderer/render_view_impl.h
@@ -685,7 +685,8 @@ class CONTENT_EXPORT RenderViewImpl
void OnCancelDownload(int32 download_id);
void OnClearFocusedElement();
void OnClosePage();
- void OnShowContextMenu(const gfx::Point& location);
+ void OnShowContextMenu(ui::MenuSourceType source_type,
+ const gfx::Point& location);
void OnCopyImageAt(int x, int y);
void OnSaveImageAt(int x, int y);
void OnDeterminePageLanguage();
diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc
index d91647e..8dfd4aa 100644
--- a/content/renderer/render_widget.cc
+++ b/content/renderer/render_widget.cc
@@ -397,7 +397,8 @@ RenderWidget::RenderWidget(blink::WebPopupType popup_type,
#endif
popup_origin_scale_for_emulation_(0.f),
resizing_mode_selector_(new ResizingModeSelector()),
- context_menu_source_type_(ui::MENU_SOURCE_MOUSE) {
+ context_menu_source_type_(ui::MENU_SOURCE_MOUSE),
+ has_host_context_menu_location_(false) {
if (!swapped_out)
RenderProcess::current()->AddRefProcess();
DCHECK(RenderThread::Get());
diff --git a/content/renderer/render_widget.h b/content/renderer/render_widget.h
index cfba42a..7dd43c9 100644
--- a/content/renderer/render_widget.h
+++ b/content/renderer/render_widget.h
@@ -105,9 +105,13 @@ class CONTENT_EXPORT RenderWidget
bool closing() const { return closing_; }
bool is_swapped_out() { return is_swapped_out_; }
ui::MenuSourceType context_menu_source_type() {
- return context_menu_source_type_; }
- gfx::Point touch_editing_context_menu_location() {
- return touch_editing_context_menu_location_;
+ return context_menu_source_type_;
+ }
+ bool has_host_context_menu_location() {
+ return has_host_context_menu_location_;
+ }
+ gfx::Point host_context_menu_location() {
+ return host_context_menu_location_;
}
// Functions to track out-of-process frames for special notifications.
@@ -704,7 +708,8 @@ class CONTENT_EXPORT RenderWidget
ObserverList<RenderFrameImpl> render_frames_;
ui::MenuSourceType context_menu_source_type_;
- gfx::Point touch_editing_context_menu_location_;
+ bool has_host_context_menu_location_;
+ gfx::Point host_context_menu_location_;
DISALLOW_COPY_AND_ASSIGN(RenderWidget);
};