diff options
author | varunjain@chromium.org <varunjain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-07 12:23:24 +0000 |
---|---|---|
committer | varunjain@chromium.org <varunjain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-07 12:23:24 +0000 |
commit | 41d8685c5d9bba8921bc99dfb75a0f7a8d05f774 (patch) | |
tree | ad92883824e8ffc874f97400aa50fbf417e6ffdd /content | |
parent | 41561ca31b9de2e4c1c5fe80aeb86bedb7403536 (diff) | |
download | chromium_src-41d8685c5d9bba8921bc99dfb75a0f7a8d05f774.zip chromium_src-41d8685c5d9bba8921bc99dfb75a0f7a8d05f774.tar.gz chromium_src-41d8685c5d9bba8921bc99dfb75a0f7a8d05f774.tar.bz2 |
Plumb drag event info through from the renderer. This CL appends the following
two pieces of information to the StartDragging IPC:
1. Whether the drag was started by a touch event or mouse event
2. The location of drag start. This information is needed for chromeos and was
currently being read from the platform. But that is not possible (also not
correct) for touch based drag/drop. So we pass this information from the
renderer.
BUG=114755
Review URL: https://chromiumcodereview.appspot.com/11369102
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@166401 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
26 files changed, 125 insertions, 32 deletions
diff --git a/content/browser/renderer_host/render_view_host_impl.cc b/content/browser/renderer_host/render_view_host_impl.cc index 30748c0..ad0bac3 100644 --- a/content/browser/renderer_host/render_view_host_impl.cc +++ b/content/browser/renderer_host/render_view_host_impl.cc @@ -1458,7 +1458,8 @@ void RenderViewHostImpl::OnMsgStartDragging( const WebDropData& drop_data, WebDragOperationsMask drag_operations_mask, const SkBitmap& bitmap, - const gfx::Vector2d& bitmap_offset_in_dip) { + const gfx::Vector2d& bitmap_offset_in_dip, + const DragEventSourceInfo& event_info) { RenderViewHostDelegateView* view = delegate_->GetDelegateView(); if (!view) return; @@ -1491,7 +1492,7 @@ void RenderViewHostImpl::OnMsgStartDragging( ui::ScaleFactor scale_factor = GetScaleFactorForView(GetView()); gfx::ImageSkia image(gfx::ImageSkiaRep(bitmap, scale_factor)); view->StartDragging(filtered_data, drag_operations_mask, image, - bitmap_offset_in_dip); + bitmap_offset_in_dip, event_info); } void RenderViewHostImpl::OnUpdateDragCursor(WebDragOperation current_op) { diff --git a/content/browser/renderer_host/render_view_host_impl.h b/content/browser/renderer_host/render_view_host_impl.h index 571512b..ae8cc82 100644 --- a/content/browser/renderer_host/render_view_host_impl.h +++ b/content/browser/renderer_host/render_view_host_impl.h @@ -16,6 +16,7 @@ #include "content/browser/renderer_host/render_widget_host_impl.h" #include "content/browser/site_instance_impl.h" #include "content/common/accessibility_node_data.h" +#include "content/common/drag_event_source_info.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/render_view_host.h" #include "content/public/common/javascript_message_type.h" @@ -541,7 +542,8 @@ class CONTENT_EXPORT RenderViewHostImpl void OnMsgStartDragging(const WebDropData& drop_data, WebKit::WebDragOperationsMask operations_allowed, const SkBitmap& bitmap, - const gfx::Vector2d& bitmap_offset_in_dip); + const gfx::Vector2d& bitmap_offset_in_dip, + const DragEventSourceInfo& event_info); void OnUpdateDragCursor(WebKit::WebDragOperation drag_operation); void OnTargetDropACK(); void OnTakeFocus(bool reverse); diff --git a/content/browser/renderer_host/render_view_host_unittest.cc b/content/browser/renderer_host/render_view_host_unittest.cc index 653c233..b7d5544 100644 --- a/content/browser/renderer_host/render_view_host_unittest.cc +++ b/content/browser/renderer_host/render_view_host_unittest.cc @@ -95,7 +95,8 @@ class MockDraggingRenderViewHostDelegateView virtual void StartDragging(const WebDropData& drop_data, WebKit::WebDragOperationsMask allowed_ops, const gfx::ImageSkia& image, - const gfx::Vector2d& image_offset) OVERRIDE { + const gfx::Vector2d& image_offset, + const DragEventSourceInfo& event_info) OVERRIDE { drag_url_ = drop_data.url; html_base_url_ = drop_data.html_base_url; } diff --git a/content/browser/renderer_host/test_render_view_host.cc b/content/browser/renderer_host/test_render_view_host.cc index c2cb5d1..193b654 100644 --- a/content/browser/renderer_host/test_render_view_host.cc +++ b/content/browser/renderer_host/test_render_view_host.cc @@ -355,7 +355,9 @@ void TestRenderViewHost::SimulateWasShown() { void TestRenderViewHost::TestOnMsgStartDragging( const WebDropData& drop_data) { WebKit::WebDragOperationsMask drag_operation = WebKit::WebDragOperationEvery; - OnMsgStartDragging(drop_data, drag_operation, SkBitmap(), gfx::Vector2d()); + DragEventSourceInfo event_info; + OnMsgStartDragging(drop_data, drag_operation, SkBitmap(), gfx::Vector2d(), + event_info); } void TestRenderViewHost::set_simulate_fetch_via_proxy(bool proxy) { diff --git a/content/browser/web_contents/interstitial_page_impl.cc b/content/browser/web_contents/interstitial_page_impl.cc index 66df56b..32fc906 100644 --- a/content/browser/web_contents/interstitial_page_impl.cc +++ b/content/browser/web_contents/interstitial_page_impl.cc @@ -82,7 +82,8 @@ class InterstitialPageImpl::InterstitialPageRVHDelegateView virtual void StartDragging(const WebDropData& drop_data, WebDragOperationsMask operations_allowed, const gfx::ImageSkia& image, - const gfx::Vector2d& image_offset) OVERRIDE; + const gfx::Vector2d& image_offset, + const DragEventSourceInfo& event_info) OVERRIDE; virtual void UpdateDragCursor(WebDragOperation operation) OVERRIDE; virtual void GotFocus() OVERRIDE; virtual void TakeFocus(bool reverse) OVERRIDE; @@ -739,7 +740,8 @@ void InterstitialPageImpl::InterstitialPageRVHDelegateView::StartDragging( const WebDropData& drop_data, WebDragOperationsMask allowed_operations, const gfx::ImageSkia& image, - const gfx::Vector2d& image_offset) { + const gfx::Vector2d& image_offset, + const DragEventSourceInfo& event_info) { NOTREACHED() << "InterstitialPage does not support dragging yet."; } diff --git a/content/browser/web_contents/web_contents_view_android.cc b/content/browser/web_contents/web_contents_view_android.cc index b4d67fa..a18d053 100644 --- a/content/browser/web_contents/web_contents_view_android.cc +++ b/content/browser/web_contents/web_contents_view_android.cc @@ -183,7 +183,8 @@ void WebContentsViewAndroid::StartDragging( const WebDropData& drop_data, WebKit::WebDragOperationsMask allowed_ops, const gfx::ImageSkia& image, - const gfx::Vector2d& image_offset) { + const gfx::Vector2d& image_offset, + const DragEventSourceInfo& event_info) { NOTIMPLEMENTED(); } diff --git a/content/browser/web_contents/web_contents_view_android.h b/content/browser/web_contents/web_contents_view_android.h index ce7537e..6236fe8 100644 --- a/content/browser/web_contents/web_contents_view_android.h +++ b/content/browser/web_contents/web_contents_view_android.h @@ -64,7 +64,8 @@ class WebContentsViewAndroid : public WebContentsView, virtual void StartDragging(const WebDropData& drop_data, WebKit::WebDragOperationsMask allowed_ops, const gfx::ImageSkia& image, - const gfx::Vector2d& image_offset) OVERRIDE; + const gfx::Vector2d& image_offset, + const DragEventSourceInfo& event_info) OVERRIDE; virtual void UpdateDragCursor(WebKit::WebDragOperation operation) OVERRIDE; virtual void GotFocus() OVERRIDE; virtual void TakeFocus(bool reverse) OVERRIDE; diff --git a/content/browser/web_contents/web_contents_view_aura.cc b/content/browser/web_contents/web_contents_view_aura.cc index fefa352..a18411e 100644 --- a/content/browser/web_contents/web_contents_view_aura.cc +++ b/content/browser/web_contents/web_contents_view_aura.cc @@ -438,7 +438,8 @@ void WebContentsViewAura::StartDragging( const WebDropData& drop_data, WebKit::WebDragOperationsMask operations, const gfx::ImageSkia& image, - const gfx::Vector2d& image_offset) { + const gfx::Vector2d& image_offset, + const DragEventSourceInfo& event_info) { aura::RootWindow* root_window = GetNativeView()->GetRootWindow(); if (!aura::client::GetDragDropClient(root_window)) return; @@ -458,17 +459,11 @@ void WebContentsViewAura::StartDragging( // updates while in the system DoDragDrop loop. int result_op = 0; { - // TODO(sad): Avoid using GetCursorScreenPoint here, since the drag may not - // always start from a mouse-event (e.g. a touch or gesture event could - // initiate the drag). The location information should be carried over from - // webkit. http://crbug.com/114754 - // TODO(varunjain): Properly determine and send DRAG_EVENT_SOURCE below. - gfx::Point location( - gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint()); MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); result_op = aura::client::GetDragDropClient(root_window)->StartDragAndDrop( - data, root_window, GetContentNativeView(), location, - ConvertFromWeb(operations), ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE); + data, root_window, GetContentNativeView(), + event_info.event_location, ConvertFromWeb(operations), + event_info.event_source); } // Bail out immediately if the contents view window is gone. Note that it is diff --git a/content/browser/web_contents/web_contents_view_aura.h b/content/browser/web_contents/web_contents_view_aura.h index cd77127..6fc2ae3 100644 --- a/content/browser/web_contents/web_contents_view_aura.h +++ b/content/browser/web_contents/web_contents_view_aura.h @@ -80,7 +80,8 @@ class CONTENT_EXPORT WebContentsViewAura virtual void StartDragging(const WebDropData& drop_data, WebKit::WebDragOperationsMask operations, const gfx::ImageSkia& image, - const gfx::Vector2d& image_offset) OVERRIDE; + const gfx::Vector2d& image_offset, + const DragEventSourceInfo& event_info) OVERRIDE; virtual void UpdateDragCursor(WebKit::WebDragOperation operation) OVERRIDE; virtual void GotFocus() OVERRIDE; virtual void TakeFocus(bool reverse) OVERRIDE; diff --git a/content/browser/web_contents/web_contents_view_gtk.cc b/content/browser/web_contents/web_contents_view_gtk.cc index f3a35dd..59aa26a 100644 --- a/content/browser/web_contents/web_contents_view_gtk.cc +++ b/content/browser/web_contents/web_contents_view_gtk.cc @@ -342,7 +342,8 @@ void WebContentsViewGtk::ShowPopupMenu(const gfx::Rect& bounds, void WebContentsViewGtk::StartDragging(const WebDropData& drop_data, WebDragOperationsMask ops, const gfx::ImageSkia& image, - const gfx::Vector2d& image_offset) { + const gfx::Vector2d& image_offset, + const DragEventSourceInfo& event_info) { DCHECK(GetContentNativeView()); RenderWidgetHostViewGtk* view_gtk = static_cast<RenderWidgetHostViewGtk*>( diff --git a/content/browser/web_contents/web_contents_view_gtk.h b/content/browser/web_contents/web_contents_view_gtk.h index 0286e81..3e52372 100644 --- a/content/browser/web_contents/web_contents_view_gtk.h +++ b/content/browser/web_contents/web_contents_view_gtk.h @@ -11,6 +11,7 @@ #include "base/memory/scoped_ptr.h" #include "content/common/content_export.h" +#include "content/common/drag_event_source_info.h" #include "content/port/browser/render_view_host_delegate_view.h" #include "content/public/browser/web_contents_view.h" #include "ui/base/gtk/focus_store_gtk.h" @@ -79,7 +80,8 @@ class CONTENT_EXPORT WebContentsViewGtk virtual void StartDragging(const WebDropData& drop_data, WebKit::WebDragOperationsMask allowed_ops, const gfx::ImageSkia& image, - const gfx::Vector2d& image_offset) OVERRIDE; + const gfx::Vector2d& image_offset, + const DragEventSourceInfo& event_info) OVERRIDE; virtual void UpdateDragCursor(WebKit::WebDragOperation operation) OVERRIDE; virtual void GotFocus() OVERRIDE; virtual void TakeFocus(bool reverse) OVERRIDE; diff --git a/content/browser/web_contents/web_contents_view_mac.h b/content/browser/web_contents/web_contents_view_mac.h index af0c4d4..a3193a3 100644 --- a/content/browser/web_contents/web_contents_view_mac.h +++ b/content/browser/web_contents/web_contents_view_mac.h @@ -12,6 +12,7 @@ #include "base/memory/scoped_nsobject.h" #include "base/memory/scoped_ptr.h" +#include "content/common/drag_event_source_info.h" #include "content/port/browser/render_view_host_delegate_view.h" #include "content/public/browser/web_contents_view.h" #include "ui/base/cocoa/base_view.h" @@ -97,7 +98,8 @@ class WebContentsViewMac : public WebContentsView, virtual void StartDragging(const WebDropData& drop_data, WebKit::WebDragOperationsMask allowed_operations, const gfx::ImageSkia& image, - const gfx::Vector2d& image_offset) OVERRIDE; + const gfx::Vector2d& image_offset, + const DragEventSourceInfo& event_info) OVERRIDE; virtual void UpdateDragCursor(WebKit::WebDragOperation operation) OVERRIDE; virtual void GotFocus() OVERRIDE; virtual void TakeFocus(bool reverse) OVERRIDE; diff --git a/content/browser/web_contents/web_contents_view_mac.mm b/content/browser/web_contents/web_contents_view_mac.mm index 342a051..b7b7a28d 100644 --- a/content/browser/web_contents/web_contents_view_mac.mm +++ b/content/browser/web_contents/web_contents_view_mac.mm @@ -174,7 +174,8 @@ void WebContentsViewMac::StartDragging( const WebDropData& drop_data, WebDragOperationsMask allowed_operations, const gfx::ImageSkia& image, - const gfx::Vector2d& image_offset) { + const gfx::Vector2d& image_offset, + const DragEventSourceInfo& event_info) { // By allowing nested tasks, the code below also allows Close(), // which would deallocate |this|. The same problem can occur while // processing -sendEvent:, so Close() is deferred in that case. diff --git a/content/browser/web_contents/web_contents_view_win.cc b/content/browser/web_contents/web_contents_view_win.cc index 64844f1..c936b2b 100644 --- a/content/browser/web_contents/web_contents_view_win.cc +++ b/content/browser/web_contents/web_contents_view_win.cc @@ -263,7 +263,8 @@ void WebContentsViewWin::ShowPopupMenu(const gfx::Rect& bounds, void WebContentsViewWin::StartDragging(const WebDropData& drop_data, WebKit::WebDragOperationsMask operations, const gfx::ImageSkia& image, - const gfx::Vector2d& image_offset) { + const gfx::Vector2d& image_offset, + const DragEventSourceInfo& event_info) { drag_handler_ = new WebContentsDragWin( GetNativeView(), web_contents_, diff --git a/content/browser/web_contents/web_contents_view_win.h b/content/browser/web_contents/web_contents_view_win.h index 9d4d010..f31d46e 100644 --- a/content/browser/web_contents/web_contents_view_win.h +++ b/content/browser/web_contents/web_contents_view_win.h @@ -10,6 +10,7 @@ #include "base/timer.h" #include "base/win/win_util.h" #include "content/common/content_export.h" +#include "content/common/drag_event_source_info.h" #include "content/port/browser/render_view_host_delegate_view.h" #include "content/public/browser/web_contents_view.h" #include "ui/base/win/window_impl.h" @@ -88,7 +89,8 @@ class CONTENT_EXPORT WebContentsViewWin virtual void StartDragging(const WebDropData& drop_data, WebKit::WebDragOperationsMask operations, const gfx::ImageSkia& image, - const gfx::Vector2d& image_offset) OVERRIDE; + const gfx::Vector2d& image_offset, + const DragEventSourceInfo& event_info) OVERRIDE; virtual void UpdateDragCursor(WebKit::WebDragOperation operation) OVERRIDE; virtual void GotFocus() OVERRIDE; virtual void TakeFocus(bool reverse) OVERRIDE; diff --git a/content/common/drag_event_source_info.h b/content/common/drag_event_source_info.h new file mode 100644 index 0000000..59a6f7c --- /dev/null +++ b/content/common/drag_event_source_info.h @@ -0,0 +1,22 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_COMMON_DRAG_EVENT_SOURCE_INFO_H_ +#define CONTENT_COMMON_DRAG_EVENT_SOURCE_INFO_H_ + +#include "content/common/content_export.h" +#include "ui/base/dragdrop/drag_drop_types.h" +#include "ui/gfx/point.h" + +namespace content { + +// Information about the event that started a drag session. +struct CONTENT_EXPORT DragEventSourceInfo { + gfx::Point event_location; + ui::DragDropTypes::DragEventSource event_source; +}; + +}; // namespace content + +#endif // CONTENT_COMMON_DRAG_EVENT_SOURCE_INFO_H_ diff --git a/content/common/drag_messages.h b/content/common/drag_messages.h index 0ad3db8..aafdbcc 100644 --- a/content/common/drag_messages.h +++ b/content/common/drag_messages.h @@ -5,6 +5,7 @@ // IPC messages for drag and drop. // Multiply-included message file, hence no include guard. +#include "content/common/drag_event_source_info.h" #include "content/public/common/common_param_traits.h" #include "ipc/ipc_message_macros.h" #include "third_party/skia/include/core/SkBitmap.h" @@ -54,11 +55,12 @@ IPC_MESSAGE_ROUTED0(DragMsg_SourceSystemDragEnded) // WebDropData struct contains contextual information about the pieces of the // page the user dragged. The parent uses this notification to initiate a // drag session at the OS level. -IPC_MESSAGE_ROUTED4(DragHostMsg_StartDragging, +IPC_MESSAGE_ROUTED5(DragHostMsg_StartDragging, WebDropData /* drop_data */, WebKit::WebDragOperationsMask /* ops_allowed */, SkBitmap /* image */, - gfx::Vector2d /* image_offset */) + gfx::Vector2d /* image_offset */, + content::DragEventSourceInfo /* event_info */) // The page wants to update the mouse cursor during a drag & drop operation. // |is_drop_target| is true if the mouse is over a valid drop target. diff --git a/content/common/drag_traits.h b/content/common/drag_traits.h index ccd841b..6b693d8 100644 --- a/content/common/drag_traits.h +++ b/content/common/drag_traits.h @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "content/common/drag_event_source_info.h" #include "content/public/common/common_param_traits.h" #include "ipc/ipc_message_macros.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragOperation.h" @@ -31,3 +32,10 @@ IPC_STRUCT_TRAITS_BEGIN(WebDropData) IPC_STRUCT_TRAITS_MEMBER(file_contents) IPC_STRUCT_TRAITS_MEMBER(custom_data) IPC_STRUCT_TRAITS_END() + +IPC_ENUM_TRAITS(ui::DragDropTypes::DragEventSource) + +IPC_STRUCT_TRAITS_BEGIN(content::DragEventSourceInfo) + IPC_STRUCT_TRAITS_MEMBER(event_location) + IPC_STRUCT_TRAITS_MEMBER(event_source) +IPC_STRUCT_TRAITS_END() diff --git a/content/content_common.gypi b/content/content_common.gypi index bca8721..c5f5f65 100644 --- a/content/content_common.gypi +++ b/content/content_common.gypi @@ -163,6 +163,7 @@ 'common/device_orientation_messages.h', 'common/devtools_messages.h', 'common/dom_storage_messages.h', + 'common/drag_event_source_info.h', 'common/drag_messages.h', 'common/drag_traits.h', 'common/edit_command.h', diff --git a/content/port/browser/render_view_host_delegate_view.h b/content/port/browser/render_view_host_delegate_view.h index 4b84cb84..85ef3da 100644 --- a/content/port/browser/render_view_host_delegate_view.h +++ b/content/port/browser/render_view_host_delegate_view.h @@ -9,6 +9,7 @@ #include "base/basictypes.h" #include "content/common/content_export.h" +#include "content/common/drag_event_source_info.h" #include "content/public/common/context_menu_source_type.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragOperation.h" @@ -53,7 +54,8 @@ class CONTENT_EXPORT RenderViewHostDelegateView { virtual void StartDragging(const WebDropData& drop_data, WebKit::WebDragOperationsMask allowed_ops, const gfx::ImageSkia& image, - const gfx::Vector2d& image_offset) {} + const gfx::Vector2d& image_offset, + const DragEventSourceInfo& event_info) {} // The page wants to update the mouse cursor during a drag & drop operation. // |operation| describes the current operation (none, move, copy, link.) diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc index 729ad00..2e0569c 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc @@ -2246,7 +2246,8 @@ void RenderViewImpl::startDragging(WebFrame* frame, drop_data, mask, image.getSkBitmap(), - imageOffset)); + imageOffset, + possible_drag_event_info_)); } bool RenderViewImpl::acceptsLoadDrops() { @@ -5653,6 +5654,10 @@ void RenderViewImpl::DidHandleKeyEvent() { } bool RenderViewImpl::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { + possible_drag_event_info_.event_source = + ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE; + possible_drag_event_info_.event_location = + gfx::Point(event.globalX, event.globalY); pepper_delegate_.WillHandleMouseEvent(); // If the mouse is locked, only the current owner of the mouse lock can @@ -5660,6 +5665,15 @@ bool RenderViewImpl::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { return mouse_lock_dispatcher_->WillHandleMouseEvent(event); } +bool RenderViewImpl::WillHandleGestureEvent( + const WebKit::WebGestureEvent& event) { + possible_drag_event_info_.event_source = + ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH; + possible_drag_event_info_.event_location = + gfx::Point(event.globalX, event.globalY); + return false; +} + void RenderViewImpl::DidHandleMouseEvent(const WebMouseEvent& event) { FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidHandleMouseEvent(event)); } diff --git a/content/renderer/render_view_impl.h b/content/renderer/render_view_impl.h index d53073e..a22fb11 100644 --- a/content/renderer/render_view_impl.h +++ b/content/renderer/render_view_impl.h @@ -17,6 +17,7 @@ #include "base/values.h" #include "build/build_config.h" #include "content/common/content_export.h" +#include "content/common/drag_event_source_info.h" #include "content/common/edit_command.h" #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" #include "content/common/navigation_gesture.h" @@ -745,6 +746,8 @@ class RenderViewImpl : public RenderWidget, virtual void DidHandleKeyEvent() OVERRIDE; virtual bool WillHandleMouseEvent( const WebKit::WebMouseEvent& event) OVERRIDE; + virtual bool WillHandleGestureEvent( + const WebKit::WebGestureEvent& event) OVERRIDE; virtual void DidHandleMouseEvent(const WebKit::WebMouseEvent& event) OVERRIDE; virtual void DidHandleTouchEvent(const WebKit::WebTouchEvent& event) OVERRIDE; virtual void OnSetFocus(bool enable) OVERRIDE; @@ -1543,6 +1546,11 @@ class RenderViewImpl : public RenderWidget, // AddObservers method of RenderViewImpl from c-tor. PepperPluginDelegateImpl pepper_delegate_; + // This field stores drag/drop related info for the event that is currently + // being handled. If the current event results in starting a drag/drop + // session, this info is sent to the browser along with other drag/drop info. + DragEventSourceInfo possible_drag_event_info_; + // --------------------------------------------------------------------------- // 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 9e723b5..a974fde1 100644 --- a/content/renderer/render_widget.cc +++ b/content/renderer/render_widget.cc @@ -54,6 +54,7 @@ using WebKit::WebCompositionUnderline; using WebKit::WebCursorInfo; +using WebKit::WebGestureEvent; using WebKit::WebInputEvent; using WebKit::WebMouseEvent; using WebKit::WebNavigationPolicy; @@ -585,6 +586,12 @@ void RenderWidget::OnHandleInputEvent(const IPC::Message& message) { prevent_default = WillHandleMouseEvent(mouse_event); } + if (WebInputEvent::isGestureEventType(input_event->type)) { + const WebGestureEvent& gesture_event = + *static_cast<const WebGestureEvent*>(input_event); + prevent_default = prevent_default || WillHandleGestureEvent(gesture_event); + } + bool processed = prevent_default; if (input_event->type != WebInputEvent::Char || !suppress_next_char_events_) { suppress_next_char_events_ = false; @@ -1923,6 +1930,11 @@ bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { return false; } +bool RenderWidget::WillHandleGestureEvent( + const WebKit::WebGestureEvent& event) { + return false; +} + bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { return false; } diff --git a/content/renderer/render_widget.h b/content/renderer/render_widget.h index eff42ccb..cbc1c62 100644 --- a/content/renderer/render_widget.h +++ b/content/renderer/render_widget.h @@ -40,6 +40,7 @@ class SyncMessage; } namespace WebKit { +class WebGestureEvent; class WebMouseEvent; class WebTouchEvent; } @@ -413,6 +414,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 gesture 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. + virtual bool WillHandleGestureEvent(const WebKit::WebGestureEvent& event); + // Called by OnHandleInputEvent() to notify subclasses that a mouse event was // just handled. virtual void DidHandleMouseEvent(const WebKit::WebMouseEvent& event) {} diff --git a/content/test/test_web_contents_view.cc b/content/test/test_web_contents_view.cc index ce8b6c7..0bfbc92 100644 --- a/content/test/test_web_contents_view.cc +++ b/content/test/test_web_contents_view.cc @@ -29,7 +29,8 @@ void TestWebContentsView::StartDragging( const WebDropData& drop_data, WebKit::WebDragOperationsMask allowed_ops, const gfx::ImageSkia& image, - const gfx::Vector2d& image_offset) { + const gfx::Vector2d& image_offset, + const DragEventSourceInfo& event_info) { } void TestWebContentsView::UpdateDragCursor(WebKit::WebDragOperation operation) { diff --git a/content/test/test_web_contents_view.h b/content/test/test_web_contents_view.h index 092cf18..7a51903 100644 --- a/content/test/test_web_contents_view.h +++ b/content/test/test_web_contents_view.h @@ -30,7 +30,8 @@ class TestWebContentsView : public WebContentsView, virtual void StartDragging(const WebDropData& drop_data, WebKit::WebDragOperationsMask allowed_ops, const gfx::ImageSkia& image, - const gfx::Vector2d& image_offset) OVERRIDE; + const gfx::Vector2d& image_offset, + const DragEventSourceInfo& event_info) OVERRIDE; virtual void UpdateDragCursor(WebKit::WebDragOperation operation) OVERRIDE; virtual void GotFocus() OVERRIDE; virtual void TakeFocus(bool reverse) OVERRIDE; |