diff options
53 files changed, 105 insertions, 126 deletions
diff --git a/android_webview/native/aw_web_contents_view_delegate.cc b/android_webview/native/aw_web_contents_view_delegate.cc index a579984..daaca0d 100644 --- a/android_webview/native/aw_web_contents_view_delegate.cc +++ b/android_webview/native/aw_web_contents_view_delegate.cc @@ -35,8 +35,7 @@ content::WebDragDestDelegate* AwWebContentsViewDelegate::GetDragDestDelegate() { } void AwWebContentsViewDelegate::ShowContextMenu( - const content::ContextMenuParams& params, - content::ContextMenuSourceType type) { + const content::ContextMenuParams& params) { // TODO(boliu): Large blocks of this function are identical with // ChromeWebContentsViewDelegateAndroid::ShowContextMenu. De-dup this if // possible. diff --git a/android_webview/native/aw_web_contents_view_delegate.h b/android_webview/native/aw_web_contents_view_delegate.h index 1892c83..141b6e45 100644 --- a/android_webview/native/aw_web_contents_view_delegate.h +++ b/android_webview/native/aw_web_contents_view_delegate.h @@ -27,8 +27,7 @@ class AwWebContentsViewDelegate : public content::WebContentsViewDelegate { // content::WebContentsViewDelegate implementation. virtual content::WebDragDestDelegate* GetDragDestDelegate() OVERRIDE; virtual void ShowContextMenu( - const content::ContextMenuParams& params, - content::ContextMenuSourceType type) OVERRIDE; + const content::ContextMenuParams& params) OVERRIDE; private: AwWebContentsViewDelegate(content::WebContents* web_contents); diff --git a/chrome/browser/ui/android/tab_contents/chrome_web_contents_view_delegate_android.cc b/chrome/browser/ui/android/tab_contents/chrome_web_contents_view_delegate_android.cc index c8714ad..b65e26a 100644 --- a/chrome/browser/ui/android/tab_contents/chrome_web_contents_view_delegate_android.cc +++ b/chrome/browser/ui/android/tab_contents/chrome_web_contents_view_delegate_android.cc @@ -29,8 +29,7 @@ ChromeWebContentsViewDelegateAndroid::GetDragDestDelegate() { } void ChromeWebContentsViewDelegateAndroid::ShowContextMenu( - const content::ContextMenuParams& params, - content::ContextMenuSourceType type) { + const content::ContextMenuParams& params) { // Display paste pop-up only when selection is empty and editable. if (params.is_editable && params.selection_text.empty()) { content::ContentViewCore* content_view_core = diff --git a/chrome/browser/ui/android/tab_contents/chrome_web_contents_view_delegate_android.h b/chrome/browser/ui/android/tab_contents/chrome_web_contents_view_delegate_android.h index aff3685..04314cb 100644 --- a/chrome/browser/ui/android/tab_contents/chrome_web_contents_view_delegate_android.h +++ b/chrome/browser/ui/android/tab_contents/chrome_web_contents_view_delegate_android.h @@ -24,8 +24,7 @@ class ChromeWebContentsViewDelegateAndroid // WebContentsViewDelegate: virtual void ShowContextMenu( - const content::ContextMenuParams& params, - content::ContextMenuSourceType type) OVERRIDE; + const content::ContextMenuParams& params) OVERRIDE; // WebContentsViewDelegate: virtual content::WebDragDestDelegate* GetDragDestDelegate() OVERRIDE; diff --git a/chrome/browser/ui/cocoa/tab_contents/chrome_web_contents_view_delegate_mac.h b/chrome/browser/ui/cocoa/tab_contents/chrome_web_contents_view_delegate_mac.h index 78320d9..5d0b842 100644 --- a/chrome/browser/ui/cocoa/tab_contents/chrome_web_contents_view_delegate_mac.h +++ b/chrome/browser/ui/cocoa/tab_contents/chrome_web_contents_view_delegate_mac.h @@ -32,8 +32,7 @@ class ChromeWebContentsViewDelegateMac content::RenderWidgetHost* render_widget_host) OVERRIDE; virtual content::WebDragDestDelegate* GetDragDestDelegate() OVERRIDE; virtual void ShowContextMenu( - const content::ContextMenuParams& params, - content::ContextMenuSourceType type) OVERRIDE; + const content::ContextMenuParams& params) OVERRIDE; private: // The context menu. Callbacks are asynchronous so we need to keep it around. diff --git a/chrome/browser/ui/cocoa/tab_contents/chrome_web_contents_view_delegate_mac.mm b/chrome/browser/ui/cocoa/tab_contents/chrome_web_contents_view_delegate_mac.mm index 858108f..f99fc56 100644 --- a/chrome/browser/ui/cocoa/tab_contents/chrome_web_contents_view_delegate_mac.mm +++ b/chrome/browser/ui/cocoa/tab_contents/chrome_web_contents_view_delegate_mac.mm @@ -34,8 +34,7 @@ content::WebDragDestDelegate* } void ChromeWebContentsViewDelegateMac::ShowContextMenu( - const content::ContextMenuParams& params, - content::ContextMenuSourceType type) { + const content::ContextMenuParams& params) { // The renderer may send the "show context menu" message multiple times, one // for each right click mouse event it receives. Normally, this doesn't happen // because mouse events are not forwarded once the context menu is showing. diff --git a/chrome/browser/ui/gtk/tab_contents/chrome_web_contents_view_delegate_gtk.cc b/chrome/browser/ui/gtk/tab_contents/chrome_web_contents_view_delegate_gtk.cc index 4a8eac8..26d5f50 100644 --- a/chrome/browser/ui/gtk/tab_contents/chrome_web_contents_view_delegate_gtk.cc +++ b/chrome/browser/ui/gtk/tab_contents/chrome_web_contents_view_delegate_gtk.cc @@ -128,8 +128,7 @@ gboolean ChromeWebContentsViewDelegateGtk::OnNativeViewFocusEvent( } void ChromeWebContentsViewDelegateGtk::ShowContextMenu( - const content::ContextMenuParams& params, - content::ContextMenuSourceType type) { + const content::ContextMenuParams& params) { // Find out the RenderWidgetHostView that corresponds to the render widget on // which this context menu is showed, so that we can retrieve the last mouse // down event on the render widget and use it as the timestamp of the diff --git a/chrome/browser/ui/gtk/tab_contents/chrome_web_contents_view_delegate_gtk.h b/chrome/browser/ui/gtk/tab_contents/chrome_web_contents_view_delegate_gtk.h index eac550f..d8fe4ad 100644 --- a/chrome/browser/ui/gtk/tab_contents/chrome_web_contents_view_delegate_gtk.h +++ b/chrome/browser/ui/gtk/tab_contents/chrome_web_contents_view_delegate_gtk.h @@ -39,8 +39,7 @@ class ChromeWebContentsViewDelegateGtk // Overridden from WebContentsViewDelegate: virtual void ShowContextMenu( - const content::ContextMenuParams& params, - content::ContextMenuSourceType type) OVERRIDE; + const content::ContextMenuParams& params) OVERRIDE; virtual content::WebDragDestDelegate* GetDragDestDelegate() OVERRIDE; virtual void Initialize(GtkWidget* expanded_container, ui::FocusStoreGtk* focus_store) OVERRIDE; diff --git a/chrome/browser/ui/views/tab_contents/chrome_web_contents_view_delegate_views.cc b/chrome/browser/ui/views/tab_contents/chrome_web_contents_view_delegate_views.cc index 407c1b7..c5f1eaa 100644 --- a/chrome/browser/ui/views/tab_contents/chrome_web_contents_view_delegate_views.cc +++ b/chrome/browser/ui/views/tab_contents/chrome_web_contents_view_delegate_views.cc @@ -127,8 +127,7 @@ void ChromeWebContentsViewDelegateViews::RestoreFocus() { } void ChromeWebContentsViewDelegateViews::ShowContextMenu( - const content::ContextMenuParams& params, - content::ContextMenuSourceType type) { + const content::ContextMenuParams& params) { // Menus need a Widget to work. If we're not the active tab we won't // necessarily be in a widget. views::Widget* top_level_widget = GetTopLevelWidget(); @@ -166,7 +165,7 @@ void ChromeWebContentsViewDelegateViews::ShowContextMenu( // the context menu is being displayed. base::MessageLoop::ScopedNestableTaskAllower allow( base::MessageLoop::current()); - context_menu_->RunMenuAt(top_level_widget, screen_point, type); + context_menu_->RunMenuAt(top_level_widget, screen_point, params.source_type); } void ChromeWebContentsViewDelegateViews::SizeChanged(const gfx::Size& size) { diff --git a/chrome/browser/ui/views/tab_contents/chrome_web_contents_view_delegate_views.h b/chrome/browser/ui/views/tab_contents/chrome_web_contents_view_delegate_views.h index 463cb08..7fbdd64 100644 --- a/chrome/browser/ui/views/tab_contents/chrome_web_contents_view_delegate_views.h +++ b/chrome/browser/ui/views/tab_contents/chrome_web_contents_view_delegate_views.h @@ -38,8 +38,7 @@ class ChromeWebContentsViewDelegateViews virtual bool Focus() OVERRIDE; virtual void TakeFocus(bool reverse) OVERRIDE; virtual void ShowContextMenu( - const content::ContextMenuParams& params, - content::ContextMenuSourceType type) OVERRIDE; + const content::ContextMenuParams& params) OVERRIDE; virtual void SizeChanged(const gfx::Size& size) OVERRIDE; private: diff --git a/chrome/browser/ui/views/tab_contents/render_view_context_menu_views.cc b/chrome/browser/ui/views/tab_contents/render_view_context_menu_views.cc index 158f2ad..4c58468 100644 --- a/chrome/browser/ui/views/tab_contents/render_view_context_menu_views.cc +++ b/chrome/browser/ui/views/tab_contents/render_view_context_menu_views.cc @@ -45,7 +45,8 @@ void RenderViewContextMenuViews::RunMenuAt( const gfx::Point& point, content::ContextMenuSourceType type) { views::MenuItemView::AnchorPosition anchor_position = - type == content::CONTEXT_MENU_SOURCE_TOUCH ? + (type == content::CONTEXT_MENU_SOURCE_TOUCH || + type == content::CONTEXT_MENU_SOURCE_TOUCH_EDIT_MENU) ? views::MenuItemView::BOTTOMCENTER : views::MenuItemView::TOPLEFT; if (menu_runner_->RunMenuAt(parent, NULL, gfx::Rect(point, gfx::Size()), anchor_position, views::MenuRunner::HAS_MNEMONICS | diff --git a/content/browser/renderer_host/render_view_host_delegate.h b/content/browser/renderer_host/render_view_host_delegate.h index 00ef739..15c3439 100644 --- a/content/browser/renderer_host/render_view_host_delegate.h +++ b/content/browser/renderer_host/render_view_host_delegate.h @@ -404,8 +404,7 @@ class CONTENT_EXPORT RenderViewHostDelegate { // A context menu should be shown, to be built using the context information // provided in the supplied params. - virtual void ShowContextMenu(const ContextMenuParams& params, - ContextMenuSourceType type) {} + virtual void ShowContextMenu(const ContextMenuParams& params) {} // The render view has requested access to media devices listed in // |request|, and the client should grant or deny that permission by diff --git a/content/browser/renderer_host/render_view_host_impl.cc b/content/browser/renderer_host/render_view_host_impl.cc index a94d2a5..90958d6 100644 --- a/content/browser/renderer_host/render_view_host_impl.cc +++ b/content/browser/renderer_host/render_view_host_impl.cc @@ -1349,15 +1349,7 @@ void RenderViewHostImpl::OnContextMenu(const ContextMenuParams& params) { FilterURL(policy, process, false, &validated_params.page_url); FilterURL(policy, process, true, &validated_params.frame_url); - ContextMenuSourceType type = CONTEXT_MENU_SOURCE_MOUSE; - if (!in_process_event_types_.empty()) { - WebKit::WebInputEvent::Type event_type = in_process_event_types_.front(); - if (WebKit::WebInputEvent::isGestureEventType(event_type)) - type = CONTEXT_MENU_SOURCE_TOUCH; - else if (WebKit::WebInputEvent::isKeyboardEventType(event_type)) - type = CONTEXT_MENU_SOURCE_KEYBOARD; - } - delegate_->ShowContextMenu(validated_params, type); + delegate_->ShowContextMenu(validated_params); } void RenderViewHostImpl::OnToggleFullscreen(bool enter_fullscreen) { diff --git a/content/browser/renderer_host/render_view_host_unittest.cc b/content/browser/renderer_host/render_view_host_unittest.cc index 2a1f5ee..2dc5558 100644 --- a/content/browser/renderer_host/render_view_host_unittest.cc +++ b/content/browser/renderer_host/render_view_host_unittest.cc @@ -118,9 +118,6 @@ class MockDraggingRenderViewHostDelegateView : public RenderViewHostDelegateView { public: virtual ~MockDraggingRenderViewHostDelegateView() {} - virtual void ShowContextMenu( - const ContextMenuParams& params, - ContextMenuSourceType type) OVERRIDE {} virtual void ShowPopupMenu(const gfx::Rect& bounds, int item_height, double item_font_size, diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc index a9863ea..8d7b5f3 100644 --- a/content/browser/renderer_host/render_widget_host_impl.cc +++ b/content/browser/renderer_host/render_widget_host_impl.cc @@ -1288,8 +1288,6 @@ void RenderWidgetHostImpl::ForwardInputEvent( return; } - in_process_event_types_.push(input_event.type); - // Transmit any pending wheel events on a non-wheel event. This ensures that // the renderer receives the final PhaseEnded wheel event, which is necessary // to terminate rubber-banding, for example. @@ -1917,10 +1915,6 @@ void RenderWidgetHostImpl::OnInputEventAck( TRACE_EVENT0("input", "RenderWidgetHostImpl::OnInputEventAck"); bool processed = (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED); - if (!in_process_event_types_.empty() && - in_process_event_types_.front() == event_type) - in_process_event_types_.pop(); - // Log the time delta for processing an input event. TimeDelta delta = TimeTicks::Now() - input_event_start_time_; UMA_HISTOGRAM_TIMES("MPArch.RWH_InputEventDelta", delta); diff --git a/content/browser/renderer_host/render_widget_host_impl.h b/content/browser/renderer_host/render_widget_host_impl.h index 2f211ec..57f3232 100644 --- a/content/browser/renderer_host/render_widget_host_impl.h +++ b/content/browser/renderer_host/render_widget_host_impl.h @@ -599,8 +599,6 @@ class CONTENT_EXPORT RenderWidgetHostImpl : virtual public RenderWidgetHost, // This value indicates how long to wait before we consider a renderer hung. int hung_renderer_delay_ms_; - std::queue<WebKit::WebInputEvent::Type> in_process_event_types_; - private: friend class MockRenderWidgetHost; diff --git a/content/browser/web_contents/interstitial_page_impl.cc b/content/browser/web_contents/interstitial_page_impl.cc index bd3e25d..84566e5 100644 --- a/content/browser/web_contents/interstitial_page_impl.cc +++ b/content/browser/web_contents/interstitial_page_impl.cc @@ -703,11 +703,6 @@ void InterstitialPageImpl::ShowCreatedFullscreenWidget(int route_id) { << "InterstitialPage does not support showing full screen popups."; } -void InterstitialPageImpl::ShowContextMenu( - const ContextMenuParams& params, - ContextMenuSourceType type) { -} - void InterstitialPageImpl::Disable() { enabled_ = false; } diff --git a/content/browser/web_contents/interstitial_page_impl.h b/content/browser/web_contents/interstitial_page_impl.h index 8b5526e..bfb1e22 100644 --- a/content/browser/web_contents/interstitial_page_impl.h +++ b/content/browser/web_contents/interstitial_page_impl.h @@ -128,9 +128,6 @@ class CONTENT_EXPORT InterstitialPageImpl virtual void ShowCreatedWidget(int route_id, const gfx::Rect& initial_pos) OVERRIDE; virtual void ShowCreatedFullscreenWidget(int route_id) OVERRIDE; - virtual void ShowContextMenu( - const ContextMenuParams& params, - ContextMenuSourceType type) OVERRIDE; // RenderWidgetHostDelegate implementation: virtual void RenderWidgetDeleted( diff --git a/content/browser/web_contents/touch_editable_impl_aura.cc b/content/browser/web_contents/touch_editable_impl_aura.cc index 769e338..551f4d7 100644 --- a/content/browser/web_contents/touch_editable_impl_aura.cc +++ b/content/browser/web_contents/touch_editable_impl_aura.cc @@ -235,11 +235,13 @@ bool TouchEditableImplAura::DrawsHandles() { return false; } -void TouchEditableImplAura::OpenContextMenu(const gfx::Point anchor) { +void TouchEditableImplAura::OpenContextMenu(const gfx::Point& anchor) { if (!rwhva_) return; + gfx::Point point = anchor; + ConvertPointFromScreen(&point); RenderWidgetHost* host = rwhva_->GetRenderWidgetHost(); - host->Send(new ViewMsg_ShowContextMenu(host->GetRoutingID())); + host->Send(new ViewMsg_ShowContextMenu(host->GetRoutingID(), point)); EndTouchEditing(); } diff --git a/content/browser/web_contents/touch_editable_impl_aura.h b/content/browser/web_contents/touch_editable_impl_aura.h index 868220f..18c4009 100644 --- a/content/browser/web_contents/touch_editable_impl_aura.h +++ b/content/browser/web_contents/touch_editable_impl_aura.h @@ -57,7 +57,7 @@ class CONTENT_EXPORT TouchEditableImplAura virtual void ConvertPointToScreen(gfx::Point* point) OVERRIDE; virtual void ConvertPointFromScreen(gfx::Point* point) OVERRIDE; virtual bool DrawsHandles() OVERRIDE; - virtual void OpenContextMenu(const gfx::Point anchor) OVERRIDE; + virtual void OpenContextMenu(const gfx::Point& anchor) OVERRIDE; virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; virtual bool GetAcceleratorForCommandId( diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc index dfc025b..1998790 100644 --- a/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc @@ -1690,14 +1690,12 @@ RenderWidgetHostView* WebContentsImpl::GetCreatedWidget(int route_id) { return widget_host_view; } -void WebContentsImpl::ShowContextMenu( - const ContextMenuParams& params, - ContextMenuSourceType type) { +void WebContentsImpl::ShowContextMenu(const ContextMenuParams& params) { // Allow WebContentsDelegates to handle the context menu operation first. if (delegate_ && delegate_->HandleContextMenu(params)) return; - render_view_host_delegate_view_->ShowContextMenu(params, type); + render_view_host_delegate_view_->ShowContextMenu(params); } void WebContentsImpl::RequestMediaAccessPermission( diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h index e1db4deb..f18b7c4 100644 --- a/content/browser/web_contents/web_contents_impl.h +++ b/content/browser/web_contents/web_contents_impl.h @@ -438,9 +438,7 @@ class CONTENT_EXPORT WebContentsImpl virtual void ShowCreatedWidget(int route_id, const gfx::Rect& initial_pos) OVERRIDE; virtual void ShowCreatedFullscreenWidget(int route_id) OVERRIDE; - virtual void ShowContextMenu( - const ContextMenuParams& params, - ContextMenuSourceType type) OVERRIDE; + virtual void ShowContextMenu(const ContextMenuParams& params) OVERRIDE; virtual void RequestMediaAccessPermission( const MediaStreamRequest& request, const MediaResponseCallback& callback) OVERRIDE; diff --git a/content/browser/web_contents/web_contents_view_android.cc b/content/browser/web_contents/web_contents_view_android.cc index 6f7baf3..2ae977e 100644 --- a/content/browser/web_contents/web_contents_view_android.cc +++ b/content/browser/web_contents/web_contents_view_android.cc @@ -178,10 +178,9 @@ void WebContentsViewAndroid::SetOverscrollControllerEnabled(bool enabled) { } void WebContentsViewAndroid::ShowContextMenu( - const ContextMenuParams& params, - ContextMenuSourceType type) { + const ContextMenuParams& params) { if (delegate_) - delegate_->ShowContextMenu(params, type); + delegate_->ShowContextMenu(params); } void WebContentsViewAndroid::ShowPopupMenu( diff --git a/content/browser/web_contents/web_contents_view_android.h b/content/browser/web_contents/web_contents_view_android.h index 58eb05a..e6a0f01 100644 --- a/content/browser/web_contents/web_contents_view_android.h +++ b/content/browser/web_contents/web_contents_view_android.h @@ -63,8 +63,7 @@ class WebContentsViewAndroid : public WebContentsViewPort, virtual void SetOverscrollControllerEnabled(bool enabled) OVERRIDE; // Backend implementation of RenderViewHostDelegateView. - virtual void ShowContextMenu(const ContextMenuParams& params, - ContextMenuSourceType type) OVERRIDE; + virtual void ShowContextMenu(const ContextMenuParams& params) OVERRIDE; virtual void ShowPopupMenu(const gfx::Rect& bounds, int item_height, double item_font_size, diff --git a/content/browser/web_contents/web_contents_view_aura.cc b/content/browser/web_contents/web_contents_view_aura.cc index cbf23fc..0c45abe 100644 --- a/content/browser/web_contents/web_contents_view_aura.cc +++ b/content/browser/web_contents/web_contents_view_aura.cc @@ -1054,11 +1054,9 @@ void WebContentsViewAura::SetOverscrollControllerEnabled(bool enabled) { //////////////////////////////////////////////////////////////////////////////// // WebContentsViewAura, RenderViewHostDelegateView implementation: -void WebContentsViewAura::ShowContextMenu( - const ContextMenuParams& params, - ContextMenuSourceType type) { +void WebContentsViewAura::ShowContextMenu(const ContextMenuParams& params) { if (delegate_) - delegate_->ShowContextMenu(params, type); + delegate_->ShowContextMenu(params); if (touch_editable_) touch_editable_->EndTouchEditing(); diff --git a/content/browser/web_contents/web_contents_view_aura.h b/content/browser/web_contents/web_contents_view_aura.h index 54425e2..738e28d 100644 --- a/content/browser/web_contents/web_contents_view_aura.h +++ b/content/browser/web_contents/web_contents_view_aura.h @@ -125,9 +125,7 @@ class CONTENT_EXPORT WebContentsViewAura virtual void SetOverscrollControllerEnabled(bool enabled) OVERRIDE; // Overridden from RenderViewHostDelegateView: - virtual void ShowContextMenu( - const ContextMenuParams& params, - ContextMenuSourceType type) OVERRIDE; + virtual void ShowContextMenu(const ContextMenuParams& params) OVERRIDE; virtual void ShowPopupMenu(const gfx::Rect& bounds, int item_height, double item_font_size, diff --git a/content/browser/web_contents/web_contents_view_gtk.cc b/content/browser/web_contents/web_contents_view_gtk.cc index 942a73d..747e8fa 100644 --- a/content/browser/web_contents/web_contents_view_gtk.cc +++ b/content/browser/web_contents/web_contents_view_gtk.cc @@ -349,11 +349,9 @@ gboolean WebContentsViewGtk::OnFocus(GtkWidget* widget, return TRUE; } -void WebContentsViewGtk::ShowContextMenu( - const ContextMenuParams& params, - ContextMenuSourceType type) { +void WebContentsViewGtk::ShowContextMenu(const ContextMenuParams& params) { if (delegate_) - delegate_->ShowContextMenu(params, type); + delegate_->ShowContextMenu(params); else DLOG(ERROR) << "Cannot show context menus without a delegate."; } diff --git a/content/browser/web_contents/web_contents_view_gtk.h b/content/browser/web_contents/web_contents_view_gtk.h index a5a15a2..52f7d8b 100644 --- a/content/browser/web_contents/web_contents_view_gtk.h +++ b/content/browser/web_contents/web_contents_view_gtk.h @@ -72,9 +72,7 @@ class CONTENT_EXPORT WebContentsViewGtk virtual void SetOverscrollControllerEnabled(bool enabled) OVERRIDE; // Backend implementation of RenderViewHostDelegateView. - virtual void ShowContextMenu( - const ContextMenuParams& params, - ContextMenuSourceType type) OVERRIDE; + virtual void ShowContextMenu(const ContextMenuParams& params) OVERRIDE; virtual void ShowPopupMenu(const gfx::Rect& bounds, int item_height, double item_font_size, diff --git a/content/browser/web_contents/web_contents_view_guest.cc b/content/browser/web_contents/web_contents_view_guest.cc index f467521..cc613e7 100644 --- a/content/browser/web_contents/web_contents_view_guest.cc +++ b/content/browser/web_contents/web_contents_view_guest.cc @@ -182,8 +182,7 @@ void WebContentsViewGuest::TakeFocus(bool reverse) { } void WebContentsViewGuest::ShowContextMenu( - const ContextMenuParams& params, - ContextMenuSourceType type) { + const ContextMenuParams& params) { NOTIMPLEMENTED(); } diff --git a/content/browser/web_contents/web_contents_view_guest.h b/content/browser/web_contents/web_contents_view_guest.h index 29dac1c..baf8ef6 100644 --- a/content/browser/web_contents/web_contents_view_guest.h +++ b/content/browser/web_contents/web_contents_view_guest.h @@ -72,9 +72,7 @@ class CONTENT_EXPORT WebContentsViewGuest #endif // Backend implementation of RenderViewHostDelegateView. - virtual void ShowContextMenu( - const ContextMenuParams& params, - ContextMenuSourceType type) OVERRIDE; + virtual void ShowContextMenu(const ContextMenuParams& params) OVERRIDE; virtual void ShowPopupMenu(const gfx::Rect& bounds, int item_height, double item_font_size, diff --git a/content/browser/web_contents/web_contents_view_mac.h b/content/browser/web_contents/web_contents_view_mac.h index 4071575..58aac4b 100644 --- a/content/browser/web_contents/web_contents_view_mac.h +++ b/content/browser/web_contents/web_contents_view_mac.h @@ -96,8 +96,7 @@ class WebContentsViewMac : public WebContentsViewPort, virtual void CloseTabAfterEventTracking() OVERRIDE; // Backend implementation of RenderViewHostDelegateView. - virtual void ShowContextMenu(const ContextMenuParams& params, - ContextMenuSourceType type) OVERRIDE; + virtual void ShowContextMenu(const ContextMenuParams& params) OVERRIDE; virtual void ShowPopupMenu(const gfx::Rect& bounds, int item_height, double item_font_size, diff --git a/content/browser/web_contents/web_contents_view_mac.mm b/content/browser/web_contents/web_contents_view_mac.mm index 6b314c8..9f66004 100644 --- a/content/browser/web_contents/web_contents_view_mac.mm +++ b/content/browser/web_contents/web_contents_view_mac.mm @@ -227,8 +227,7 @@ void WebContentsViewMac::TakeFocus(bool reverse) { } } -void WebContentsViewMac::ShowContextMenu(const ContextMenuParams& params, - ContextMenuSourceType type) { +void WebContentsViewMac::ShowContextMenu(const ContextMenuParams& params) { // Allow delegates to handle the context menu operation first. if (web_contents_->GetDelegate() && web_contents_->GetDelegate()->HandleContextMenu(params)) { @@ -236,7 +235,7 @@ void WebContentsViewMac::ShowContextMenu(const ContextMenuParams& params, } if (delegate()) - delegate()->ShowContextMenu(params, type); + delegate()->ShowContextMenu(params); else DLOG(ERROR) << "Cannot show context menus without a delegate."; } diff --git a/content/browser/web_contents/web_contents_view_win.cc b/content/browser/web_contents/web_contents_view_win.cc index d75f8d14..684197f 100644 --- a/content/browser/web_contents/web_contents_view_win.cc +++ b/content/browser/web_contents/web_contents_view_win.cc @@ -243,11 +243,9 @@ void WebContentsViewWin::RenderViewSwappedIn(RenderViewHost* host) { void WebContentsViewWin::SetOverscrollControllerEnabled(bool enabled) { } -void WebContentsViewWin::ShowContextMenu( - const ContextMenuParams& params, - ContextMenuSourceType type) { +void WebContentsViewWin::ShowContextMenu(const ContextMenuParams& params) { if (delegate_) - delegate_->ShowContextMenu(params, type); + delegate_->ShowContextMenu(params); } void WebContentsViewWin::ShowPopupMenu(const gfx::Rect& bounds, diff --git a/content/browser/web_contents/web_contents_view_win.h b/content/browser/web_contents/web_contents_view_win.h index 1994ebe..f6a84d8 100644 --- a/content/browser/web_contents/web_contents_view_win.h +++ b/content/browser/web_contents/web_contents_view_win.h @@ -79,9 +79,7 @@ class CONTENT_EXPORT WebContentsViewWin virtual void SetOverscrollControllerEnabled(bool enabled) OVERRIDE; // Implementation of RenderViewHostDelegateView. - virtual void ShowContextMenu( - const ContextMenuParams& params, - ContextMenuSourceType type) OVERRIDE; + virtual void ShowContextMenu(const ContextMenuParams& params) OVERRIDE; virtual void ShowPopupMenu(const gfx::Rect& bounds, int item_height, double item_font_size, diff --git a/content/common/view_messages.h b/content/common/view_messages.h index 304eeb9..5f1f14c 100644 --- a/content/common/view_messages.h +++ b/content/common/view_messages.h @@ -19,6 +19,7 @@ #include "content/port/common/input_event_ack_state.h" #include "content/public/common/common_param_traits.h" #include "content/public/common/context_menu_params.h" +#include "content/public/common/context_menu_source_type.h" #include "content/public/common/favicon_url.h" #include "content/public/common/file_chooser_params.h" #include "content/public/common/frame_navigate_params.h" @@ -76,6 +77,7 @@ IPC_ENUM_TRAITS(WebKit::WebPopupType) IPC_ENUM_TRAITS(WebKit::WebTextDirection) IPC_ENUM_TRAITS(WebMenuItem::Type) IPC_ENUM_TRAITS(WindowContainerType) +IPC_ENUM_TRAITS(content::ContextMenuSourceType) IPC_ENUM_TRAITS(content::FaviconURL::IconType) IPC_ENUM_TRAITS(content::FileChooserParams::Mode) IPC_ENUM_TRAITS(content::JavaScriptMessageType) @@ -184,6 +186,7 @@ IPC_STRUCT_TRAITS_BEGIN(content::ContextMenuParams) IPC_STRUCT_TRAITS_MEMBER(referrer_policy) IPC_STRUCT_TRAITS_MEMBER(custom_context) IPC_STRUCT_TRAITS_MEMBER(custom_items) + IPC_STRUCT_TRAITS_MEMBER(source_type) #if defined(OS_ANDROID) IPC_STRUCT_TRAITS_MEMBER(selection_start) IPC_STRUCT_TRAITS_MEMBER(selection_end) @@ -878,7 +881,9 @@ IPC_MESSAGE_ROUTED1(ViewMsg_ContextMenuClosed, content::CustomContextMenuContext /* custom_context */) // Sent to inform the renderer to invoke a context menu. -IPC_MESSAGE_ROUTED0(ViewMsg_ShowContextMenu) +// The parameter specifies the location in the render view's coordinates. +IPC_MESSAGE_ROUTED1(ViewMsg_ShowContextMenu, + gfx::Point /* location where menu should be shown */) // Tells the renderer to perform the specified navigation, interrupting any // existing navigation. diff --git a/content/port/browser/render_view_host_delegate_view.h b/content/port/browser/render_view_host_delegate_view.h index 9c859c91..4460544 100644 --- a/content/port/browser/render_view_host_delegate_view.h +++ b/content/port/browser/render_view_host_delegate_view.h @@ -34,8 +34,7 @@ class CONTENT_EXPORT RenderViewHostDelegateView { public: // A context menu should be shown, to be built using the context information // provided in the supplied params. - virtual void ShowContextMenu(const ContextMenuParams& params, - ContextMenuSourceType type) {} + virtual void ShowContextMenu(const ContextMenuParams& params) {} // Shows a popup menu with the specified items. // This method should call RenderViewHost::DidSelectPopupMenuItem[s]() or diff --git a/content/public/browser/web_contents_view_delegate.h b/content/public/browser/web_contents_view_delegate.h index 605582b..3975503 100644 --- a/content/public/browser/web_contents_view_delegate.h +++ b/content/public/browser/web_contents_view_delegate.h @@ -43,9 +43,7 @@ class CONTENT_EXPORT WebContentsViewDelegate { virtual WebDragDestDelegate* GetDragDestDelegate() = 0; // Shows a context menu. - virtual void ShowContextMenu( - const content::ContextMenuParams& params, - content::ContextMenuSourceType type) = 0; + virtual void ShowContextMenu(const content::ContextMenuParams& params) = 0; #if defined(OS_WIN) || defined(USE_AURA) // These methods allow the embedder to intercept WebContentsViewWin's diff --git a/content/public/common/context_menu_params.h b/content/public/common/context_menu_params.h index 5704c1a..d43f160 100644 --- a/content/public/common/context_menu_params.h +++ b/content/public/common/context_menu_params.h @@ -10,6 +10,7 @@ #include "base/basictypes.h" #include "base/strings/string16.h" #include "content/common/content_export.h" +#include "content/public/common/context_menu_source_type.h" #include "content/public/common/page_state.h" #include "content/public/common/ssl_status.h" #include "googleurl/src/gurl.h" @@ -145,6 +146,8 @@ struct CONTENT_EXPORT ContextMenuParams { CustomContextMenuContext custom_context; std::vector<WebMenuItem> custom_items; + ContextMenuSourceType source_type; + #if defined(OS_ANDROID) // Points representing the coordinates in the document space of the start and // end of the selection, if there is one. diff --git a/content/public/common/context_menu_source_type.h b/content/public/common/context_menu_source_type.h index e1fc54b..53e6a60 100644 --- a/content/public/common/context_menu_source_type.h +++ b/content/public/common/context_menu_source_type.h @@ -11,6 +11,10 @@ enum ContextMenuSourceType { CONTEXT_MENU_SOURCE_MOUSE, CONTEXT_MENU_SOURCE_KEYBOARD, CONTEXT_MENU_SOURCE_TOUCH, + + // This source type is used when the context menu is summoned by pressing the + // context menu button in the touch editing menu. + CONTEXT_MENU_SOURCE_TOUCH_EDIT_MENU, }; } // namespace content diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc index db348fc..830370b 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc @@ -804,7 +804,8 @@ RenderViewImpl::RenderViewImpl(RenderViewImplParams* params) decrement_shared_popup_at_destruction_(false), handling_select_range_(false), next_snapshot_id_(0), - allow_partial_swap_(params->allow_partial_swap) { + allow_partial_swap_(params->allow_partial_swap), + context_menu_source_type_(content::CONTEXT_MENU_SOURCE_MOUSE) { } void RenderViewImpl::Initialize(RenderViewImplParams* params) { @@ -2450,6 +2451,11 @@ bool RenderViewImpl::runModalBeforeUnloadDialog( void RenderViewImpl::showContextMenu( WebFrame* frame, const WebContextMenuData& data) { ContextMenuParams params = ContextMenuParamsBuilder::Build(data); + params.source_type = context_menu_source_type_; + if (context_menu_source_type_ == CONTEXT_MENU_SOURCE_TOUCH_EDIT_MENU) { + params.x = touch_editing_context_menu_location_.x(); + params.y = touch_editing_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 @@ -5942,6 +5948,7 @@ void RenderViewImpl::DidHandleKeyEvent() { } bool RenderViewImpl::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { + context_menu_source_type_ = CONTEXT_MENU_SOURCE_MOUSE; possible_drag_event_info_.event_source = ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE; possible_drag_event_info_.event_location = @@ -5953,8 +5960,14 @@ bool RenderViewImpl::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { return mouse_lock_dispatcher_->WillHandleMouseEvent(event); } +bool RenderViewImpl::WillHandleKeyEvent(const WebKit::WebKeyboardEvent& event) { + context_menu_source_type_ = CONTEXT_MENU_SOURCE_KEYBOARD; + return false; +} + bool RenderViewImpl::WillHandleGestureEvent( const WebKit::WebGestureEvent& event) { + context_menu_source_type_ = CONTEXT_MENU_SOURCE_TOUCH; possible_drag_event_info_.event_source = ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH; possible_drag_event_info_.event_location = @@ -6580,7 +6593,9 @@ void RenderViewImpl::OnContextMenuClosed( } } -void RenderViewImpl::OnShowContextMenu() { +void RenderViewImpl::OnShowContextMenu(const gfx::Point& location) { + context_menu_source_type_ = CONTEXT_MENU_SOURCE_TOUCH_EDIT_MENU; + touch_editing_context_menu_location_ = location; if (webview()) webview()->showContextMenu(); } diff --git a/content/renderer/render_view_impl.h b/content/renderer/render_view_impl.h index d930943a..0b1d512 100644 --- a/content/renderer/render_view_impl.h +++ b/content/renderer/render_view_impl.h @@ -27,6 +27,7 @@ #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" #include "content/common/navigation_gesture.h" #include "content/common/view_message_enums.h" +#include "content/public/common/context_menu_source_type.h" #include "content/public/common/javascript_message_type.h" #include "content/public/common/page_zoom.h" #include "content/public/common/referrer.h" @@ -796,6 +797,8 @@ class CONTENT_EXPORT RenderViewImpl virtual void DidHandleKeyEvent() OVERRIDE; virtual bool WillHandleMouseEvent( const WebKit::WebMouseEvent& event) OVERRIDE; + virtual bool WillHandleKeyEvent( + const WebKit::WebKeyboardEvent& event) OVERRIDE; virtual bool WillHandleGestureEvent( const WebKit::WebGestureEvent& event) OVERRIDE; virtual void DidHandleMouseEvent(const WebKit::WebMouseEvent& event) OVERRIDE; @@ -962,7 +965,7 @@ class CONTENT_EXPORT RenderViewImpl void OnClearFocusedNode(); void OnClosePage(); void OnContextMenuClosed(const CustomContextMenuContext& custom_context); - void OnShowContextMenu(); + void OnShowContextMenu(const gfx::Point& location); void OnCopyImageAt(int x, int y); void OnCSSInsertRequest(const string16& frame_xpath, const std::string& css); @@ -1554,6 +1557,9 @@ class CONTENT_EXPORT RenderViewImpl scoped_ptr<RenderViewPepperHelper> pepper_helper_; scoped_ptr<StatsCollectionObserver> stats_collection_observer_; + ContextMenuSourceType context_menu_source_type_; + gfx::Point touch_editing_context_menu_location_; + // --------------------------------------------------------------------------- // ADDING NEW DATA? Please see if it fits appropriately in one of the above // sections rather than throwing it randomly at the end. If you're adding a diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc index 9b05ffb..01d2e73 100644 --- a/content/renderer/render_widget.cc +++ b/content/renderer/render_widget.cc @@ -76,6 +76,7 @@ using WebKit::WebCompositionUnderline; using WebKit::WebCursorInfo; using WebKit::WebGestureEvent; using WebKit::WebInputEvent; +using WebKit::WebKeyboardEvent; using WebKit::WebMouseEvent; using WebKit::WebNavigationPolicy; using WebKit::WebPagePopup; @@ -760,6 +761,12 @@ void RenderWidget::OnHandleInputEvent(const WebKit::WebInputEvent* input_event, prevent_default = WillHandleMouseEvent(mouse_event); } + if (WebInputEvent::isKeyboardEventType(input_event->type)) { + const WebKeyboardEvent& key_event = + *static_cast<const WebKeyboardEvent*>(input_event); + prevent_default = WillHandleKeyEvent(key_event); + } + if (WebInputEvent::isGestureEventType(input_event->type)) { const WebGestureEvent& gesture_event = *static_cast<const WebGestureEvent*>(input_event); @@ -2391,6 +2398,10 @@ bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { return false; } +bool RenderWidget::WillHandleKeyEvent(const WebKit::WebKeyboardEvent& event) { + return false; +} + bool RenderWidget::WillHandleGestureEvent( const WebKit::WebGestureEvent& event) { return false; diff --git a/content/renderer/render_widget.h b/content/renderer/render_widget.h index 6bba462..5bcc2d1 100644 --- a/content/renderer/render_widget.h +++ b/content/renderer/render_widget.h @@ -49,6 +49,7 @@ class SyncMessage; namespace WebKit { class WebGestureEvent; class WebInputEvent; +class WebKeyboardEvent; class WebMouseEvent; class WebTouchEvent; struct WebPoint; @@ -470,6 +471,12 @@ class CONTENT_EXPORT RenderWidget // won't be sent to WebKit or trigger DidHandleMouseEvent(). virtual bool WillHandleMouseEvent(const WebKit::WebMouseEvent& event); + // Called by OnHandleInputEvent() to notify subclasses that a key event is + // about to be handled. + // Returns true if no further handling is needed. In that case, the event + // won't be sent to WebKit or trigger DidHandleKeyEvent(). + virtual bool WillHandleKeyEvent(const WebKit::WebKeyboardEvent& event); + // Called by OnHandleInputEvent() to notify subclasses that a gesture event is // about to be handled. // Returns true if no further handling is needed. In that case, the event diff --git a/content/shell/shell_web_contents_view_delegate.h b/content/shell/shell_web_contents_view_delegate.h index 283f37f..715a64d 100644 --- a/content/shell/shell_web_contents_view_delegate.h +++ b/content/shell/shell_web_contents_view_delegate.h @@ -23,8 +23,7 @@ class ShellWebContentsViewDelegate : public WebContentsViewDelegate { virtual ~ShellWebContentsViewDelegate(); // Overridden from WebContentsViewDelegate: - virtual void ShowContextMenu(const ContextMenuParams& params, - ContextMenuSourceType type) OVERRIDE; + virtual void ShowContextMenu(const ContextMenuParams& params) OVERRIDE; virtual WebDragDestDelegate* GetDragDestDelegate() OVERRIDE; #if defined(TOOLKIT_GTK) diff --git a/content/shell/shell_web_contents_view_delegate_android.cc b/content/shell/shell_web_contents_view_delegate_android.cc index 6277a1c..a5b4c82 100644 --- a/content/shell/shell_web_contents_view_delegate_android.cc +++ b/content/shell/shell_web_contents_view_delegate_android.cc @@ -28,8 +28,7 @@ ShellWebContentsViewDelegate::~ShellWebContentsViewDelegate() { } void ShellWebContentsViewDelegate::ShowContextMenu( - const ContextMenuParams& params, - ContextMenuSourceType type) { + const ContextMenuParams& params) { if (params.is_editable && params.selection_text.empty()) { content::ContentViewCore* content_view_core = ContentViewCore::FromWebContents(web_contents_); diff --git a/content/shell/shell_web_contents_view_delegate_gtk.cc b/content/shell/shell_web_contents_view_delegate_gtk.cc index 2cc33e9..9f1318b 100644 --- a/content/shell/shell_web_contents_view_delegate_gtk.cc +++ b/content/shell/shell_web_contents_view_delegate_gtk.cc @@ -42,8 +42,7 @@ ShellWebContentsViewDelegate::~ShellWebContentsViewDelegate() { } void ShellWebContentsViewDelegate::ShowContextMenu( - const ContextMenuParams& params, - ContextMenuSourceType type) { + const ContextMenuParams& params) { if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) return; diff --git a/content/shell/shell_web_contents_view_delegate_mac.mm b/content/shell/shell_web_contents_view_delegate_mac.mm index 2acb9eb..606a826 100644 --- a/content/shell/shell_web_contents_view_delegate_mac.mm +++ b/content/shell/shell_web_contents_view_delegate_mac.mm @@ -93,8 +93,7 @@ ShellWebContentsViewDelegate::~ShellWebContentsViewDelegate() { } void ShellWebContentsViewDelegate::ShowContextMenu( - const ContextMenuParams& params, - ContextMenuSourceType type) { + const ContextMenuParams& params) { if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) return; diff --git a/content/shell/shell_web_contents_view_delegate_win.cc b/content/shell/shell_web_contents_view_delegate_win.cc index 83d191b..a062dea 100644 --- a/content/shell/shell_web_contents_view_delegate_win.cc +++ b/content/shell/shell_web_contents_view_delegate_win.cc @@ -70,8 +70,7 @@ ShellWebContentsViewDelegate::~ShellWebContentsViewDelegate() { } void ShellWebContentsViewDelegate::ShowContextMenu( - const ContextMenuParams& params, - ContextMenuSourceType type) { + const ContextMenuParams& params) { if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) return; diff --git a/content/test/test_web_contents_view.cc b/content/test/test_web_contents_view.cc index 8fc3c92..3578b06 100644 --- a/content/test/test_web_contents_view.cc +++ b/content/test/test_web_contents_view.cc @@ -12,10 +12,6 @@ TestWebContentsView::TestWebContentsView() { TestWebContentsView::~TestWebContentsView() { } -void TestWebContentsView::ShowContextMenu(const ContextMenuParams& params, - ContextMenuSourceType type) { -} - void TestWebContentsView::ShowPopupMenu(const gfx::Rect& bounds, int item_height, double item_font_size, diff --git a/content/test/test_web_contents_view.h b/content/test/test_web_contents_view.h index c9ba9af..e5bc57f 100644 --- a/content/test/test_web_contents_view.h +++ b/content/test/test_web_contents_view.h @@ -18,8 +18,6 @@ class TestWebContentsView : public WebContentsViewPort, virtual ~TestWebContentsView(); // RenderViewHostDelegateView: - virtual void ShowContextMenu(const ContextMenuParams& params, - ContextMenuSourceType type) OVERRIDE; virtual void ShowPopupMenu(const gfx::Rect& bounds, int item_height, double item_font_size, diff --git a/ui/base/touch/touch_editing_controller.h b/ui/base/touch/touch_editing_controller.h index 72376b2..2c94f0a 100644 --- a/ui/base/touch/touch_editing_controller.h +++ b/ui/base/touch/touch_editing_controller.h @@ -49,7 +49,7 @@ class UI_EXPORT TouchEditable : public ui::SimpleMenuModel::Delegate { virtual bool DrawsHandles() = 0; // Tells the editable to open context menu. - virtual void OpenContextMenu(const gfx::Point anchor) = 0; + virtual void OpenContextMenu(const gfx::Point& anchor) = 0; protected: virtual ~TouchEditable() {} diff --git a/ui/views/controls/textfield/native_textfield_views.cc b/ui/views/controls/textfield/native_textfield_views.cc index b6b0d09..a86e5bc 100644 --- a/ui/views/controls/textfield/native_textfield_views.cc +++ b/ui/views/controls/textfield/native_textfield_views.cc @@ -424,7 +424,7 @@ bool NativeTextfieldViews::DrawsHandles() { return false; } -void NativeTextfieldViews::OpenContextMenu(const gfx::Point anchor) { +void NativeTextfieldViews::OpenContextMenu(const gfx::Point& anchor) { touch_selection_controller_.reset(); ShowContextMenu(anchor, false); } diff --git a/ui/views/controls/textfield/native_textfield_views.h b/ui/views/controls/textfield/native_textfield_views.h index 23cd6f2..7e7dd28 100644 --- a/ui/views/controls/textfield/native_textfield_views.h +++ b/ui/views/controls/textfield/native_textfield_views.h @@ -89,7 +89,7 @@ class VIEWS_EXPORT NativeTextfieldViews : public View, virtual void ConvertPointToScreen(gfx::Point* point) OVERRIDE; virtual void ConvertPointFromScreen(gfx::Point* point) OVERRIDE; virtual bool DrawsHandles() OVERRIDE; - virtual void OpenContextMenu(const gfx::Point anchor) OVERRIDE; + virtual void OpenContextMenu(const gfx::Point& anchor) OVERRIDE; // ContextMenuController overrides: virtual void ShowContextMenuForView(View* source, |