diff options
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/api/public/WebDragOperation.h | 59 | ||||
-rw-r--r-- | webkit/data/layout_tests/platform/chromium-linux/LayoutTests/fast/events/drag-in-frames-expected.txt | 18 | ||||
-rw-r--r-- | webkit/data/layout_tests/platform/chromium-mac/LayoutTests/fast/events/drag-in-frames-expected.txt | 18 | ||||
-rw-r--r-- | webkit/data/layout_tests/platform/chromium-win/LayoutTests/fast/events/drag-in-frames-expected.txt | 6 | ||||
-rw-r--r-- | webkit/glue/dragclient_impl.cc | 10 | ||||
-rw-r--r-- | webkit/glue/webview.h | 21 | ||||
-rw-r--r-- | webkit/glue/webview_delegate.h | 7 | ||||
-rw-r--r-- | webkit/glue/webview_impl.cc | 96 | ||||
-rw-r--r-- | webkit/glue/webview_impl.h | 30 | ||||
-rw-r--r-- | webkit/tools/layout_tests/test_expectations.txt | 3 | ||||
-rw-r--r-- | webkit/tools/test_shell/drag_delegate.cc | 3 | ||||
-rw-r--r-- | webkit/tools/test_shell/drop_delegate.cc | 20 | ||||
-rw-r--r-- | webkit/tools/test_shell/event_sending_controller.cc | 34 | ||||
-rw-r--r-- | webkit/tools/test_shell/event_sending_controller.h | 6 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_webview_delegate.cc | 9 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_webview_delegate.h | 4 |
16 files changed, 260 insertions, 84 deletions
diff --git a/webkit/api/public/WebDragOperation.h b/webkit/api/public/WebDragOperation.h new file mode 100644 index 0000000..1a9b9ce --- /dev/null +++ b/webkit/api/public/WebDragOperation.h @@ -0,0 +1,59 @@ +/* +* Copyright (C) 2009 Google Inc. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are +* met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above +* copyright notice, this list of conditions and the following disclaimer +* in the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Google Inc. nor the names of its +* contributors may be used to endorse or promote products derived from +* this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef WebDragOperation_h +#define WebDragOperation_h + +#include <limits.h> + +namespace WebKit { + + // "Verb" of a drag-and-drop operation as negotiated between the source and + // destination. + // (These constants match their equivalents in WebCore's DragActions.h and + // should not be renumbered.) + enum WebDragOperation { + WebDragOperationNone = 0, + WebDragOperationCopy = 1, + WebDragOperationLink = 2, + WebDragOperationGeneric = 4, + WebDragOperationPrivate = 8, + WebDragOperationMove = 16, + WebDragOperationDelete = 32, + WebDragOperationEvery = UINT_MAX + }; + + // Alternate typedef to make it clear when this is being used as a mask + // with potentially multiple value bits set. + typedef WebDragOperation WebDragOperationsMask; + +} // namespace WebKit + +#endif diff --git a/webkit/data/layout_tests/platform/chromium-linux/LayoutTests/fast/events/drag-in-frames-expected.txt b/webkit/data/layout_tests/platform/chromium-linux/LayoutTests/fast/events/drag-in-frames-expected.txt new file mode 100644 index 0000000..0a2bc61 --- /dev/null +++ b/webkit/data/layout_tests/platform/chromium-linux/LayoutTests/fast/events/drag-in-frames-expected.txt @@ -0,0 +1,18 @@ +Event log + +ondragstart src +ondragenter left target +ondrag src +ondragover left target +ondrag src +ondragover left target +ondrag src +ondragenter right target +ondragleave left target +ondrag src +ondragover right target +ondrag src +ondragover right target +ondrop right target +ondragend src +These results are just "sensible" at the moment, meaning that all the events fire on the right elements, nothing more. The order in particular can rightfully change. diff --git a/webkit/data/layout_tests/platform/chromium-mac/LayoutTests/fast/events/drag-in-frames-expected.txt b/webkit/data/layout_tests/platform/chromium-mac/LayoutTests/fast/events/drag-in-frames-expected.txt new file mode 100644 index 0000000..0a2bc61 --- /dev/null +++ b/webkit/data/layout_tests/platform/chromium-mac/LayoutTests/fast/events/drag-in-frames-expected.txt @@ -0,0 +1,18 @@ +Event log + +ondragstart src +ondragenter left target +ondrag src +ondragover left target +ondrag src +ondragover left target +ondrag src +ondragenter right target +ondragleave left target +ondrag src +ondragover right target +ondrag src +ondragover right target +ondrop right target +ondragend src +These results are just "sensible" at the moment, meaning that all the events fire on the right elements, nothing more. The order in particular can rightfully change. diff --git a/webkit/data/layout_tests/platform/chromium-win/LayoutTests/fast/events/drag-in-frames-expected.txt b/webkit/data/layout_tests/platform/chromium-win/LayoutTests/fast/events/drag-in-frames-expected.txt index 78eaf8e..0a2bc61 100644 --- a/webkit/data/layout_tests/platform/chromium-win/LayoutTests/fast/events/drag-in-frames-expected.txt +++ b/webkit/data/layout_tests/platform/chromium-win/LayoutTests/fast/events/drag-in-frames-expected.txt @@ -1,16 +1,18 @@ Event log ondragstart src -ondrag src ondragenter left target ondrag src ondragover left target ondrag src +ondragover left target +ondrag src ondragenter right target ondragleave left target ondrag src ondragover right target +ondrag src ondragover right target -ondragend src ondrop right target +ondragend src These results are just "sensible" at the moment, meaning that all the events fire on the right elements, nothing more. The order in particular can rightfully change. diff --git a/webkit/glue/dragclient_impl.cc b/webkit/glue/dragclient_impl.cc index 661a7a0..75a8ba9 100644 --- a/webkit/glue/dragclient_impl.cc +++ b/webkit/glue/dragclient_impl.cc @@ -16,6 +16,7 @@ #include "webkit/glue/webview_impl.h" using WebKit::WebDragData; +using WebKit::WebPoint; void DragClientImpl::willPerformDragDestinationAction( WebCore::DragDestinationAction, @@ -59,7 +60,14 @@ void DragClientImpl::startDrag(WebCore::DragImageRef drag_image, WebDragData drag_data = webkit_glue::ChromiumDataObjectToWebDragData( static_cast<WebCore::ClipboardChromium*>(clipboard)->dataObject()); - webview_->StartDragging(drag_data); + WebCore::DragOperation drag_operation_mask; + if (!clipboard->sourceOperation(drag_operation_mask)) { + drag_operation_mask = WebCore::DragOperationEvery; + } + + webview_->StartDragging(webkit_glue::IntPointToWebPoint(event_pos), + drag_data, + static_cast<WebKit::WebDragOperationsMask>(drag_operation_mask)); } WebCore::DragImageRef DragClientImpl::createDragImageForLink( diff --git a/webkit/glue/webview.h b/webkit/glue/webview.h index 0b55232..0cd33fc 100644 --- a/webkit/glue/webview.h +++ b/webkit/glue/webview.h @@ -9,6 +9,7 @@ #include <vector> #include "base/basictypes.h" +#include "webkit/api/public/WebDragOperation.h" #include "webkit/api/public/WebWidget.h" namespace WebKit { @@ -185,15 +186,11 @@ class WebView : public WebKit::WebWidget { // Show the JavaScript console. virtual void ShowJavaScriptConsole() = 0; - // Notifies the webview that a drag has been cancelled. - virtual void DragSourceCancelledAt( - const WebKit::WebPoint& client_point, - const WebKit::WebPoint& screen_point) = 0; - - // Notifies the webview that a drag has terminated. + // Notifies the webview that a drag has ended (with a drop or a cancel). virtual void DragSourceEndedAt( const WebKit::WebPoint& client_point, - const WebKit::WebPoint& screen_point) = 0; + const WebKit::WebPoint& screen_point, + WebKit::WebDragOperation operation) = 0; // Notifies the webview that a drag and drop operation is in progress, with // dropable items over the view. @@ -206,13 +203,15 @@ class WebView : public WebKit::WebWidget { // Callback methods when a drag and drop operation is trying to drop data // on this webview. - virtual bool DragTargetDragEnter( + virtual WebKit::WebDragOperation DragTargetDragEnter( const WebKit::WebDragData& drag_data, int identity, const WebKit::WebPoint& client_point, - const WebKit::WebPoint& screen_point) = 0; - virtual bool DragTargetDragOver( + const WebKit::WebPoint& screen_point, + WebKit::WebDragOperationsMask operations_allowed) = 0; + virtual WebKit::WebDragOperation DragTargetDragOver( const WebKit::WebPoint& client_point, - const WebKit::WebPoint& screen_point) = 0; + const WebKit::WebPoint& screen_point, + WebKit::WebDragOperationsMask operations_allowed) = 0; virtual void DragTargetDragLeave() = 0; virtual void DragTargetDrop( const WebKit::WebPoint& client_point, diff --git a/webkit/glue/webview_delegate.h b/webkit/glue/webview_delegate.h index 804049d..7a8e313 100644 --- a/webkit/glue/webview_delegate.h +++ b/webkit/glue/webview_delegate.h @@ -28,6 +28,7 @@ #include <vector> +#include "webkit/api/public/WebDragOperation.h" #include "webkit/api/public/WebFrame.h" #include "webkit/api/public/WebNavigationPolicy.h" #include "webkit/api/public/WebNavigationType.h" @@ -639,10 +640,14 @@ class WebViewDelegate : virtual public WebKit::WebWidgetClient { // Starts a drag session with the supplied contextual information. // webview: The WebView sending the delegate method. + // mouseCoords: Current mouse coordinates // drop_data: a WebDropData struct which should contain all the necessary // information for dragging data out of the webview. + // drag_source_operation_mask: indicates what drag operations are allowed virtual void StartDragging(WebView* webview, - const WebKit::WebDragData& drag_data) { + const WebKit::WebPoint &mouseCoords, + const WebKit::WebDragData& drag_data, + WebKit::WebDragOperationsMask operations_mask) { } // Returns the focus to the client. diff --git a/webkit/glue/webview_impl.cc b/webkit/glue/webview_impl.cc index f38c390..cc9ebbd 100644 --- a/webkit/glue/webview_impl.cc +++ b/webkit/glue/webview_impl.cc @@ -96,6 +96,10 @@ using WebKit::WebCompositionCommand; using WebKit::WebCompositionCommandConfirm; using WebKit::WebCompositionCommandDiscard; using WebKit::WebDragData; +using WebKit::WebDragOperation; +using WebKit::WebDragOperationCopy; +using WebKit::WebDragOperationNone; +using WebKit::WebDragOperationsMask; using WebKit::WebEditingClient; using WebKit::WebFrame; using WebKit::WebInputEvent; @@ -129,10 +133,19 @@ static const double kMaxTextSizeMultiplier = 3.0; // one page group. static const char* kPageGroupName = "default"; -// The webcore drag operation type when something is trying to be dropped on -// the webview. These values are taken from Apple's windows port. -static const WebCore::DragOperation kDropTargetOperation = - static_cast<WebCore::DragOperation>(DragOperationCopy | DragOperationLink); +// Ensure that the WebKit::WebDragOperation enum values stay in sync with +// the original WebCore::DragOperation constants. +#define COMPILE_ASSERT_MATCHING_ENUM(webcore_name) \ + COMPILE_ASSERT(int(WebCore::webcore_name) == int(WebKit::Web##webcore_name),\ + dummy##webcore_name) +COMPILE_ASSERT_MATCHING_ENUM(DragOperationNone); +COMPILE_ASSERT_MATCHING_ENUM(DragOperationCopy); +COMPILE_ASSERT_MATCHING_ENUM(DragOperationLink); +COMPILE_ASSERT_MATCHING_ENUM(DragOperationGeneric); +COMPILE_ASSERT_MATCHING_ENUM(DragOperationPrivate); +COMPILE_ASSERT_MATCHING_ENUM(DragOperationMove); +COMPILE_ASSERT_MATCHING_ENUM(DragOperationDelete); +COMPILE_ASSERT_MATCHING_ENUM(DragOperationEvery); // AutocompletePopupMenuClient class AutocompletePopupMenuClient : public WebCore::PopupMenuClient { @@ -380,7 +393,8 @@ WebViewImpl::WebViewImpl(WebViewDelegate* delegate, drag_target_dispatch_(false), drag_identity_(0), drop_effect_(DROP_EFFECT_DEFAULT), - drop_accept_(false), + operations_allowed_(WebKit::WebDragOperationNone), + drag_operation_(WebKit::WebDragOperationNone), autocomplete_popup_showing_(false), is_transparent_(false) { // WebKit/win/WebView.cpp does the same thing, except they call the @@ -1495,24 +1509,16 @@ void WebViewImpl::ShowJavaScriptConsole() { page_->inspectorController()->showPanel(InspectorController::ConsolePanel); } -void WebViewImpl::DragSourceCancelledAt( - const WebPoint& client_point, - const WebPoint& screen_point) { - PlatformMouseEvent pme(webkit_glue::WebPointToIntPoint(client_point), - webkit_glue::WebPointToIntPoint(screen_point), - NoButton, MouseEventMoved, 0, false, false, false, - false, 0); - page_->mainFrame()->eventHandler()->dragSourceEndedAt(pme, DragOperationNone); -} - void WebViewImpl::DragSourceEndedAt( const WebPoint& client_point, - const WebPoint& screen_point) { + const WebPoint& screen_point, + WebDragOperation operation) { PlatformMouseEvent pme(webkit_glue::WebPointToIntPoint(client_point), webkit_glue::WebPointToIntPoint(screen_point), LeftButton, MouseEventMoved, 0, false, false, false, false, 0); - page_->mainFrame()->eventHandler()->dragSourceEndedAt(pme, DragOperationCopy); + page_->mainFrame()->eventHandler()->dragSourceEndedAt(pme, + static_cast<WebCore::DragOperation>(operation)); } void WebViewImpl::DragSourceMovedTo( @@ -1534,52 +1540,70 @@ void WebViewImpl::DragSourceSystemDragEnded() { } } -bool WebViewImpl::DragTargetDragEnter( +WebDragOperation WebViewImpl::DragTargetDragEnter( const WebDragData& web_drag_data, int identity, const WebPoint& client_point, - const WebPoint& screen_point) { + const WebPoint& screen_point, + WebDragOperation operations_allowed) { DCHECK(!current_drag_data_.get()); current_drag_data_ = webkit_glue::WebDragDataToChromiumDataObject(web_drag_data); drag_identity_ = identity; + operations_allowed_ = operations_allowed; DragData drag_data( current_drag_data_.get(), webkit_glue::WebPointToIntPoint(client_point), webkit_glue::WebPointToIntPoint(screen_point), - kDropTargetOperation); + static_cast<WebCore::DragOperation>(operations_allowed)); drop_effect_ = DROP_EFFECT_DEFAULT; drag_target_dispatch_ = true; DragOperation effect = page_->dragController()->dragEntered(&drag_data); + // Mask the operation against the drag source's allowed operations. + if ((effect & drag_data.draggingSourceOperationMask()) != effect) { + effect = DragOperationNone; + } drag_target_dispatch_ = false; if (drop_effect_ != DROP_EFFECT_DEFAULT) - return drop_accept_ = (drop_effect_ != DROP_EFFECT_NONE); - return drop_accept_ = (effect != DragOperationNone); + drag_operation_ = (drop_effect_ != DROP_EFFECT_NONE) ? + WebDragOperationCopy : WebDragOperationNone; + else + drag_operation_ = static_cast<WebDragOperation>(effect); + return drag_operation_; } -bool WebViewImpl::DragTargetDragOver( +WebDragOperation WebViewImpl::DragTargetDragOver( const WebPoint& client_point, - const WebPoint& screen_point) { + const WebPoint& screen_point, + WebDragOperation operations_allowed) { DCHECK(current_drag_data_.get()); + operations_allowed_ = operations_allowed; DragData drag_data( current_drag_data_.get(), webkit_glue::WebPointToIntPoint(client_point), webkit_glue::WebPointToIntPoint(screen_point), - kDropTargetOperation); + static_cast<WebCore::DragOperation>(operations_allowed)); drop_effect_ = DROP_EFFECT_DEFAULT; drag_target_dispatch_ = true; DragOperation effect = page_->dragController()->dragUpdated(&drag_data); + // Mask the operation against the drag source's allowed operations. + if ((effect & drag_data.draggingSourceOperationMask()) != effect) { + effect = DragOperationNone; + } drag_target_dispatch_ = false; if (drop_effect_ != DROP_EFFECT_DEFAULT) - return drop_accept_ = (drop_effect_ != DROP_EFFECT_NONE); - return drop_accept_ = (effect != DragOperationNone); + drag_operation_ = (drop_effect_ != DROP_EFFECT_NONE) ? + WebDragOperationCopy : WebDragOperationNone; + else + drag_operation_ = static_cast<WebDragOperation>(effect); + return drag_operation_; } void WebViewImpl::DragTargetDragLeave() { @@ -1589,7 +1613,7 @@ void WebViewImpl::DragTargetDragLeave() { current_drag_data_.get(), IntPoint(), IntPoint(), - kDropTargetOperation); + static_cast<WebCore::DragOperation>(operations_allowed_)); drag_target_dispatch_ = true; page_->dragController()->dragExited(&drag_data); @@ -1597,7 +1621,7 @@ void WebViewImpl::DragTargetDragLeave() { current_drag_data_ = NULL; drop_effect_ = DROP_EFFECT_DEFAULT; - drop_accept_ = false; + drag_operation_ = WebDragOperationNone; drag_identity_ = 0; } @@ -1611,9 +1635,9 @@ void WebViewImpl::DragTargetDrop( // flight, or else delayed by javascript processing in this webview. If a // drop happens before our IPC reply has reached the browser process, then // the browser forwards the drop to this webview. So only allow a drop to - // proceed if our webview drop_accept_ state is true. + // proceed if our webview drag_operation_ state is not DragOperationNone. - if (!drop_accept_) { // IPC RACE CONDITION: do not allow this drop. + if (drag_operation_ == WebDragOperationNone) { // IPC RACE CONDITION: do not allow this drop. DragTargetDragLeave(); return; } @@ -1622,7 +1646,7 @@ void WebViewImpl::DragTargetDrop( current_drag_data_.get(), webkit_glue::WebPointToIntPoint(client_point), webkit_glue::WebPointToIntPoint(screen_point), - kDropTargetOperation); + static_cast<WebCore::DragOperation>(operations_allowed_)); drag_target_dispatch_ = true; page_->dragController()->performDrag(&drag_data); @@ -1630,7 +1654,7 @@ void WebViewImpl::DragTargetDrop( current_drag_data_ = NULL; drop_effect_ = DROP_EFFECT_DEFAULT; - drop_accept_ = false; + drag_operation_ = WebDragOperationNone; drag_identity_ = 0; } @@ -1795,11 +1819,13 @@ void WebViewImpl::DidCommitLoad(bool* is_new_navigation) { observed_new_navigation_ = false; } -void WebViewImpl::StartDragging(const WebDragData& drag_data) { +void WebViewImpl::StartDragging(WebPoint event_pos, + const WebDragData& drag_data, + WebDragOperationsMask mask) { if (delegate_) { DCHECK(!doing_drag_and_drop_); doing_drag_and_drop_ = true; - delegate_->StartDragging(this, drag_data); + delegate_->StartDragging(this, event_pos, drag_data, mask); } } diff --git a/webkit/glue/webview_impl.h b/webkit/glue/webview_impl.h index 2504c1e..3c753ac 100644 --- a/webkit/glue/webview_impl.h +++ b/webkit/glue/webview_impl.h @@ -111,23 +111,23 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> { virtual void CopyImageAt(int x, int y); virtual void InspectElement(int x, int y); virtual void ShowJavaScriptConsole(); - virtual void DragSourceCancelledAt( - const WebKit::WebPoint& client_point, - const WebKit::WebPoint& screen_point); virtual void DragSourceEndedAt( const WebKit::WebPoint& client_point, - const WebKit::WebPoint& screen_point); + const WebKit::WebPoint& screen_point, + WebKit::WebDragOperation operation); virtual void DragSourceMovedTo( const WebKit::WebPoint& client_point, const WebKit::WebPoint& screen_point); virtual void DragSourceSystemDragEnded(); - virtual bool DragTargetDragEnter( + virtual WebKit::WebDragOperation DragTargetDragEnter( const WebKit::WebDragData& drag_data, int identity, const WebKit::WebPoint& client_point, - const WebKit::WebPoint& screen_point); - virtual bool DragTargetDragOver( + const WebKit::WebPoint& screen_point, + WebKit::WebDragOperationsMask operations_allowed); + virtual WebKit::WebDragOperation DragTargetDragOver( const WebKit::WebPoint& client_point, - const WebKit::WebPoint& screen_point); + const WebKit::WebPoint& screen_point, + WebKit::WebDragOperationsMask operations_allowed); virtual void DragTargetDragLeave(); virtual void DragTargetDrop( const WebKit::WebPoint& client_point, @@ -231,7 +231,9 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> { } // Start a system drag and drop operation. - void StartDragging(const WebKit::WebDragData& drag_data); + void StartDragging(WebKit::WebPoint event_pos, + const WebKit::WebDragData& drag_data, + WebKit::WebDragOperationsMask drag_source_operation_mask); // Hides the autocomplete popup if it is showing. void HideAutoCompletePopup(); @@ -369,9 +371,13 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> { DROP_EFFECT_COPY } drop_effect_; - // When true, the drag data can be dropped onto the current drop target in - // this WebView (the drop target can accept the drop). - bool drop_accept_; + // The available drag operations (copy, move link...) allowed by the source. + WebKit::WebDragOperation operations_allowed_; + + // The current drag operation as negotiated by the source and destination. + // When not equal to DragOperationNone, the drag data can be dropped onto the + // current drop target in this WebView (the drop target can accept the drop). + WebKit::WebDragOperation drag_operation_; // The autocomplete popup. Kept around and reused every-time new suggestions // should be shown. diff --git a/webkit/tools/layout_tests/test_expectations.txt b/webkit/tools/layout_tests/test_expectations.txt index 5694113..495ff44 100644 --- a/webkit/tools/layout_tests/test_expectations.txt +++ b/webkit/tools/layout_tests/test_expectations.txt @@ -2400,9 +2400,6 @@ BUG20376 WIN : LayoutTests/media/video-src-remove.html = TIMEOUT FAIL BUG20987 : LayoutTests/fast/events/pageshow-pagehide-on-back-uncached.html = FAIL BUG20987 : LayoutTests/fast/events/pageshow-pagehide.html = FAIL -// WebKit 47827:47830 -BUG20985 : LayoutTests/editing/pasteboard/files-during-page-drags.html = FAIL - // This newly added test times out on Mac: BUG20438 MAC : chrome/plugins/get-url-with-iframe-target.html = TIMEOUT BUG20438 MAC : chrome/plugins/get-url-with-iframe-target-no-crash.html = TIMEOUT diff --git a/webkit/tools/test_shell/drag_delegate.cc b/webkit/tools/test_shell/drag_delegate.cc index 5f447ef..d9c45cd 100644 --- a/webkit/tools/test_shell/drag_delegate.cc +++ b/webkit/tools/test_shell/drag_delegate.cc @@ -35,7 +35,8 @@ void TestDragDelegate::OnDragSourceDrop() { gfx::Point client; gfx::Point screen; GetCursorPositions(source_hwnd_, &client, &screen); - webview_->DragSourceEndedAt(client, screen); + webview_->DragSourceEndedAt(client, screen, WebKit::WebDragOperationCopy); + // TODO(snej): Pass the real drag operation instead } void TestDragDelegate::OnDragSourceMove() { diff --git a/webkit/tools/test_shell/drop_delegate.cc b/webkit/tools/test_shell/drop_delegate.cc index 41b4767..ce0e0dc6 100644 --- a/webkit/tools/test_shell/drop_delegate.cc +++ b/webkit/tools/test_shell/drop_delegate.cc @@ -9,6 +9,8 @@ #include "webkit/glue/webdropdata.h" #include "webkit/glue/webview.h" +using WebKit::WebDragOperation; +using WebKit::WebDragOperationCopy; using WebKit::WebPoint; // BaseDropTarget methods ---------------------------------------------------- @@ -22,11 +24,14 @@ DWORD TestDropDelegate::OnDragEnter(IDataObject* data_object, POINT client_pt = cursor_position; ScreenToClient(GetHWND(), &client_pt); - bool valid = webview_->DragTargetDragEnter( + WebDragOperation op = webview_->DragTargetDragEnter( drop_data.ToDragData(), drop_data.identity, WebPoint(client_pt.x, client_pt.y), - WebPoint(cursor_position.x, cursor_position.y)); - return valid ? DROPEFFECT_COPY : DROPEFFECT_NONE; + WebPoint(cursor_position.x, cursor_position.y), + WebDragOperationCopy); + // TODO(snej): Pass the real drag operation instead + return op ? DROPEFFECT_COPY : DROPEFFECT_NONE; + // TODO(snej): Return the real drop effect constant matching 'op' } DWORD TestDropDelegate::OnDragOver(IDataObject* data_object, @@ -35,10 +40,13 @@ DWORD TestDropDelegate::OnDragOver(IDataObject* data_object, DWORD effect) { POINT client_pt = cursor_position; ScreenToClient(GetHWND(), &client_pt); - bool valid = webview_->DragTargetDragOver( + WebDragOperation op = webview_->DragTargetDragOver( WebPoint(client_pt.x, client_pt.y), - WebPoint(cursor_position.x, cursor_position.y)); - return valid ? DROPEFFECT_COPY : DROPEFFECT_NONE; + WebPoint(cursor_position.x, cursor_position.y), + WebDragOperationCopy); + // TODO(snej): Pass the real drag operation instead + return op ? DROPEFFECT_COPY : DROPEFFECT_NONE; + // TODO(snej): Return the real drop effect constant matching 'op' } void TestDropDelegate::OnDragLeave(IDataObject* data_object) { diff --git a/webkit/tools/test_shell/event_sending_controller.cc b/webkit/tools/test_shell/event_sending_controller.cc index 42402f0..15d54f6 100644 --- a/webkit/tools/test_shell/event_sending_controller.cc +++ b/webkit/tools/test_shell/event_sending_controller.cc @@ -45,7 +45,8 @@ using WebKit::WebInputEventFactory; using base::Time; using base::TimeTicks; - +using WebKit::WebDragOperation; +using WebKit::WebDragOperationsMask; using WebKit::WebDragData; using WebKit::WebInputEvent; using WebKit::WebKeyboardEvent; @@ -62,6 +63,8 @@ int EventSendingController::last_button_number_ = -1; namespace { static WebDragData current_drag_data; +static WebDragOperation current_drag_effect; +static WebDragOperationsMask current_drag_effects_allowed; static bool replaying_saved_events = false; static std::queue<WebMouseEvent> mouse_event_queue; @@ -188,6 +191,8 @@ void EventSendingController::Reset() { // The test should have finished a drag and the mouse button state. DCHECK(current_drag_data.isNull()); current_drag_data.reset(); + current_drag_effect = WebKit::WebDragOperationNone; + current_drag_effects_allowed = WebKit::WebDragOperationNone; pressed_button_ = WebMouseEvent::ButtonNone; dragMode.Set(true); #if defined(OS_WIN) @@ -211,9 +216,17 @@ WebView* EventSendingController::webview() { } // static -void EventSendingController::DoDragDrop(const WebDragData& drag_data) { +void EventSendingController::DoDragDrop(const WebKit::WebPoint &event_pos, + const WebDragData& drag_data, + WebDragOperationsMask mask) { + WebMouseEvent event; + InitMouseEvent(WebInputEvent::MouseDown, pressed_button_, event_pos, &event); + WebPoint client_point(event.x, event.y); + WebPoint screen_point(event.globalX, event.globalY); current_drag_data = drag_data; - webview()->DragTargetDragEnter(drag_data, 0, WebPoint(), WebPoint()); + current_drag_effects_allowed = mask; + current_drag_effect = webview()->DragTargetDragEnter( + drag_data, 0, client_point, screen_point, current_drag_effects_allowed); // Finish processing events. ReplaySavedEvents(); @@ -313,14 +326,17 @@ void EventSendingController::mouseUp( WebPoint client_point(e.x, e.y); WebPoint screen_point(e.globalX, e.globalY); - bool valid = webview()->DragTargetDragOver(client_point, screen_point); - if (valid) { - webview()->DragSourceEndedAt(client_point, screen_point); + webview()->DragSourceMovedTo(client_point, screen_point); + current_drag_effect = webview()->DragTargetDragOver(client_point, + screen_point, + current_drag_effects_allowed); + if (current_drag_effect) { webview()->DragTargetDrop(client_point, screen_point); } else { - webview()->DragSourceEndedAt(client_point, screen_point); webview()->DragTargetDragLeave(); } + webview()->DragSourceEndedAt(client_point, screen_point, + current_drag_effect); current_drag_data.reset(); } @@ -357,7 +373,9 @@ void EventSendingController::DoMouseMove(const WebMouseEvent& e) { WebPoint screen_point(e.globalX, e.globalY); webview()->DragSourceMovedTo(client_point, screen_point); - webview()->DragTargetDragOver(client_point, screen_point); + current_drag_effect = webview()->DragTargetDragOver( + client_point, screen_point, + current_drag_effects_allowed); } } diff --git a/webkit/tools/test_shell/event_sending_controller.h b/webkit/tools/test_shell/event_sending_controller.h index 353c411..5f26083 100644 --- a/webkit/tools/test_shell/event_sending_controller.h +++ b/webkit/tools/test_shell/event_sending_controller.h @@ -19,6 +19,7 @@ #include "build/build_config.h" #include "base/gfx/point.h" #include "base/task.h" +#include "webkit/api/public/WebDragOperation.h" #include "webkit/api/public/WebInputEvent.h" #include "webkit/glue/cpp_bound_class.h" @@ -28,6 +29,7 @@ class WebView; namespace WebKit { class WebDragData; class WebMouseEvent; +struct WebPoint; } class EventSendingController : public CppBoundClass { @@ -40,7 +42,9 @@ class EventSendingController : public CppBoundClass { void Reset(); // Simulate drag&drop system call. - static void DoDragDrop(const WebKit::WebDragData& drag_data); + static void DoDragDrop(const WebKit::WebPoint &event_pos, + const WebKit::WebDragData& drag_data, + WebKit::WebDragOperationsMask operations_mask); // JS callback methods. void mouseDown(const CppArgumentList& args, CppVariant* result); diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc index b8b2a11..63917e9 100644 --- a/webkit/tools/test_shell/test_webview_delegate.cc +++ b/webkit/tools/test_shell/test_webview_delegate.cc @@ -27,6 +27,7 @@ #include "webkit/api/public/WebFrame.h" #include "webkit/api/public/WebKit.h" #include "webkit/api/public/WebNode.h" +#include "webkit/api/public/WebPoint.h" #include "webkit/api/public/WebRange.h" #include "webkit/api/public/WebScreenInfo.h" #include "webkit/api/public/WebString.h" @@ -61,6 +62,7 @@ using WebKit::WebData; using WebKit::WebDataSource; using WebKit::WebDragData; +using WebKit::WebDragOperationsMask; using WebKit::WebEditingAction; using WebKit::WebFrame; using WebKit::WebHistoryItem; @@ -69,6 +71,7 @@ using WebKit::WebNavigationPolicy; using WebKit::WebNode; using WebKit::WebPlugin; using WebKit::WebPluginParams; +using WebKit::WebPoint; using WebKit::WebRange; using WebKit::WebRect; using WebKit::WebScreenInfo; @@ -675,7 +678,9 @@ void TestWebViewDelegate::SetStatusbarText(WebView* webview, } void TestWebViewDelegate::StartDragging(WebView* webview, - const WebDragData& drag_data) { + const WebPoint &mouse_coords, + const WebDragData& drag_data, + WebDragOperationsMask mask) { if (WebKit::layoutTestMode()) { WebDragData mutable_drag_data = drag_data; if (shell_->layout_test_controller()->ShouldAddFileToPasteboard()) { @@ -685,7 +690,7 @@ void TestWebViewDelegate::StartDragging(WebView* webview, // When running a test, we need to fake a drag drop operation otherwise // Windows waits for real mouse events to know when the drag is over. - EventSendingController::DoDragDrop(mutable_drag_data); + EventSendingController::DoDragDrop(mouse_coords, mutable_drag_data, mask); } else { // TODO(tc): Drag and drop is disabled in the test shell because we need // to be able to convert from WebDragData to an IDataObject. diff --git a/webkit/tools/test_shell/test_webview_delegate.h b/webkit/tools/test_shell/test_webview_delegate.h index d18999e..ad0beee 100644 --- a/webkit/tools/test_shell/test_webview_delegate.h +++ b/webkit/tools/test_shell/test_webview_delegate.h @@ -104,7 +104,9 @@ class TestWebViewDelegate : public WebViewDelegate, unsigned int line_no, const std::wstring& source_id); virtual void StartDragging(WebView* webview, - const WebKit::WebDragData& drag_data); + const WebKit::WebPoint &mouseCoords, + const WebKit::WebDragData& drag_data, + WebKit::WebDragOperationsMask operations_mask); virtual void ShowContextMenu(WebView* webview, ContextNodeType node_type, int x, |