[WK2][Mac] Drag and drop tests interfere with user's UI
authorap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Sep 2013 06:36:21 +0000 (06:36 +0000)
committerap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Sep 2013 06:36:21 +0000 (06:36 +0000)
        https://bugs.webkit.org/show_bug.cgi?id=120538

        Reviewed by Dan Bernstein.

        This makes running WebKit2 regression tests locally more viable. The patch doesn't
        fix drag and drop tests to work as expected, I posted some thought about that in
        <https://bugs.webkit.org/show_bug.cgi?id=68552>.

        * WebKitTestRunner/EventSenderProxy.h:
        (WTR::EventSenderProxy::position):
        * WebKitTestRunner/TestController.h:
        (WTR::TestController::eventSenderProxy):
        Expose a way to get current mouse position from anywhere in WKTR code.

        * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj: Added new files.

        * WebKitTestRunner/mac/EventSenderProxy.mm: (WTR::EventSenderProxy::mouseUp):
        Copied a FIXME comment from DumpRenderTree.

        * WebKitTestRunner/mac/PlatformWebViewMac.mm:
        (-[TestRunnerWKView dragImage:at:offset:event:pasteboard:source:slideBack:]):
        Override drag initiation, using a custom NSDraggingInfo implementation.

        * WebKitTestRunner/mac/TestControllerMac.mm: (WTR::TestController::platformInitialize):
        Replace NSEvent with a custom class.

        * WebKitTestRunner/mac/WebKitTestRunnerDraggingInfo.h: Added.
        * WebKitTestRunner/mac/WebKitTestRunnerDraggingInfo.mm: Added.
        * WebKitTestRunner/mac/WebKitTestRunnerEvent.h: Added.
        * WebKitTestRunner/mac/WebKitTestRunnerEvent.mm: Added.
        Largely a copy of DumpRenderTree classes, modified to not use global variables.
        We should consider making these variables static in EventSenderProxy though, as
        it's strange that mouse state in WKTR is reset between tests without WebKit ever
        being told about that.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@154949 268f45cc-cd09-0410-ab3c-d52691b4dbfc

13 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/mac/WKView.mm
Tools/ChangeLog
Tools/WebKitTestRunner/EventSenderProxy.h
Tools/WebKitTestRunner/TestController.h
Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj
Tools/WebKitTestRunner/mac/EventSenderProxy.mm
Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm
Tools/WebKitTestRunner/mac/TestControllerMac.mm
Tools/WebKitTestRunner/mac/WebKitTestRunnerDraggingInfo.h [new file with mode: 0644]
Tools/WebKitTestRunner/mac/WebKitTestRunnerDraggingInfo.mm [new file with mode: 0644]
Tools/WebKitTestRunner/mac/WebKitTestRunnerEvent.h [new file with mode: 0644]
Tools/WebKitTestRunner/mac/WebKitTestRunnerEvent.mm [new file with mode: 0644]

index 858ed44..f4104af 100644 (file)
@@ -1,3 +1,16 @@
+2013-09-01  Alexey Proskuryakov  <ap@apple.com>
+
+        [WK2][Mac] Drag and drop tests interfere with user's UI
+        https://bugs.webkit.org/show_bug.cgi?id=120538
+
+        Reviewed by Dan Bernstein.
+
+        * UIProcess/API/mac/WKView.mm: (-[WKView _setDragImage:at:linkDrag:]): Make it possible
+        to override drag initiation in subclasses. It is a bit unfortunate that this exposes
+        a deprecated API that we call, but probably not unfortunate enough to invent a new
+        scary looking name for the same function, and conditionally call that if implemented
+        by subclass.
+
 2013-08-31  Santosh Mahto  <santosh.ma@samsung.com>
 
         warning: unused parameter point and area in EwkView.cpp:1390
index 2913547..0357150 100644 (file)
@@ -2754,16 +2754,16 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I
     size.scale(1.0 / _data->_page->deviceScaleFactor());
     [image setSize:size];
     
-    // The call to super could release this WKView.
+    // The call below could release this WKView.
     RetainPtr<WKView> protector(self);
     
-    [super dragImage:image
-                  at:clientPoint
-              offset:NSZeroSize
-               event:(linkDrag) ? [NSApp currentEvent] :_data->_mouseDownEvent
-          pasteboard:[NSPasteboard pasteboardWithName:NSDragPboard]
-              source:self
-           slideBack:YES];
+    [self dragImage:image
+                 at:clientPoint
+             offset:NSZeroSize
+              event:(linkDrag) ? [NSApp currentEvent] :_data->_mouseDownEvent
+         pasteboard:[NSPasteboard pasteboardWithName:NSDragPboard]
+             source:self
+          slideBack:YES];
 }
 
 static bool matchesExtensionOrEquivalent(NSString *filename, NSString *extension)
index 86c23e6..d6aa478 100644 (file)
@@ -1,3 +1,41 @@
+2013-09-01  Alexey Proskuryakov  <ap@apple.com>
+
+        [WK2][Mac] Drag and drop tests interfere with user's UI
+        https://bugs.webkit.org/show_bug.cgi?id=120538
+
+        Reviewed by Dan Bernstein.
+
+        This makes running WebKit2 regression tests locally more viable. The patch doesn't
+        fix drag and drop tests to work as expected, I posted some thought about that in
+        <https://bugs.webkit.org/show_bug.cgi?id=68552>.
+
+        * WebKitTestRunner/EventSenderProxy.h:
+        (WTR::EventSenderProxy::position):
+        * WebKitTestRunner/TestController.h:
+        (WTR::TestController::eventSenderProxy):
+        Expose a way to get current mouse position from anywhere in WKTR code.
+
+        * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj: Added new files.
+
+        * WebKitTestRunner/mac/EventSenderProxy.mm: (WTR::EventSenderProxy::mouseUp):
+        Copied a FIXME comment from DumpRenderTree.
+
+        * WebKitTestRunner/mac/PlatformWebViewMac.mm:
+        (-[TestRunnerWKView dragImage:at:offset:event:pasteboard:source:slideBack:]):
+        Override drag initiation, using a custom NSDraggingInfo implementation.
+
+        * WebKitTestRunner/mac/TestControllerMac.mm: (WTR::TestController::platformInitialize):
+        Replace NSEvent with a custom class.
+
+        * WebKitTestRunner/mac/WebKitTestRunnerDraggingInfo.h: Added.
+        * WebKitTestRunner/mac/WebKitTestRunnerDraggingInfo.mm: Added.
+        * WebKitTestRunner/mac/WebKitTestRunnerEvent.h: Added.
+        * WebKitTestRunner/mac/WebKitTestRunnerEvent.mm: Added.
+        Largely a copy of DumpRenderTree classes, modified to not use global variables.
+        We should consider making these variables static in EventSenderProxy though, as
+        it's strange that mouse state in WKTR is reset between tests without WebKit ever
+        being told about that.
+
 2013-08-30  Brent Fulgham  <bfulgham@apple.com>
 
         [Windows] Unreviewed build fix.
index bb814a8..e96d42f 100644 (file)
 #ifndef EventSenderProxy_h
 #define EventSenderProxy_h
 
+#include <wtf/Deque.h>
+
 #if PLATFORM(QT)
 #include <QEvent>
 #include <QTouchEvent>
 #elif PLATFORM(GTK)
 #include <gdk/gdk.h>
-#include <wtf/Deque.h>
 #elif PLATFORM(EFL)
 #include <WebKit2/EWebKit2.h>
-#include <wtf/Deque.h>
 #endif
 
 namespace WTR {
@@ -53,6 +53,8 @@ public:
     explicit EventSenderProxy(TestController*);
     ~EventSenderProxy();
 
+    WKPoint position() const { return m_position; }
+
     void mouseDown(unsigned button, WKEventModifiers);
     void mouseUp(unsigned button, WKEventModifiers);
     void mouseMoveTo(double x, double y);
index 686f28e..7010ea2 100644 (file)
@@ -63,6 +63,8 @@ public:
     PlatformWebView* mainWebView() { return m_mainWebView.get(); }
     WKContextRef context() { return m_context.get(); }
 
+    EventSenderProxy* eventSenderProxy() { return m_eventSenderProxy.get(); }
+
     void ensureViewSupportsOptions(WKDictionaryRef options);
     
     // Runs the run loop until `done` is true or the timeout elapses.
index dc532cf..d234a2e 100644 (file)
@@ -85,6 +85,8 @@
                BCD7D2F811921278006DB7EE /* TestInvocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCD7D2F711921278006DB7EE /* TestInvocation.cpp */; };
                BCDA2B9A1191051F00C3BC47 /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BCDA2B991191051F00C3BC47 /* JavaScriptCore.framework */; };
                C0CE720B1247C93300BC0EC4 /* TestRunnerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = C0CE720A1247C93300BC0EC4 /* TestRunnerMac.mm */; };
+               E132AA3A17CD5F1000611DF0 /* WebKitTestRunnerDraggingInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = E132AA3817CD5F1000611DF0 /* WebKitTestRunnerDraggingInfo.mm */; };
+               E132AA3D17CE776F00611DF0 /* WebKitTestRunnerEvent.mm in Sources */ = {isa = PBXBuildFile; fileRef = E132AA3B17CE776F00611DF0 /* WebKitTestRunnerEvent.mm */; };
                E1BA671E1742DA6A00C20251 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E1BA671D1742DA5A00C20251 /* Carbon.framework */; };
                E1C642C317CBCC7300D66A3C /* PoseAsClass.mm in Sources */ = {isa = PBXBuildFile; fileRef = E1C642C117CBCC7300D66A3C /* PoseAsClass.mm */; };
                E1C642C617CBCD4C00D66A3C /* WebKitTestRunnerPasteboard.mm in Sources */ = {isa = PBXBuildFile; fileRef = E1C642C417CBCD4C00D66A3C /* WebKitTestRunnerPasteboard.mm */; };
                BCD7D2F711921278006DB7EE /* TestInvocation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TestInvocation.cpp; sourceTree = "<group>"; };
                BCDA2B991191051F00C3BC47 /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = JavaScriptCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
                C0CE720A1247C93300BC0EC4 /* TestRunnerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = TestRunnerMac.mm; path = mac/TestRunnerMac.mm; sourceTree = "<group>"; };
+               E132AA3817CD5F1000611DF0 /* WebKitTestRunnerDraggingInfo.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebKitTestRunnerDraggingInfo.mm; sourceTree = "<group>"; };
+               E132AA3917CD5F1000611DF0 /* WebKitTestRunnerDraggingInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKitTestRunnerDraggingInfo.h; sourceTree = "<group>"; };
+               E132AA3B17CE776F00611DF0 /* WebKitTestRunnerEvent.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebKitTestRunnerEvent.mm; sourceTree = "<group>"; };
+               E132AA3C17CE776F00611DF0 /* WebKitTestRunnerEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKitTestRunnerEvent.h; sourceTree = "<group>"; };
                E1BA671D1742DA5A00C20251 /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = System/Library/Frameworks/Carbon.framework; sourceTree = SDKROOT; };
                E1C642C117CBCC7300D66A3C /* PoseAsClass.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PoseAsClass.mm; sourceTree = "<group>"; };
                E1C642C217CBCC7300D66A3C /* PoseAsClass.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PoseAsClass.h; sourceTree = "<group>"; };
                                5670B8271386FCA5002EB355 /* EventSenderProxy.mm */,
                                BC7933FF118F7C84005EA8E2 /* main.mm */,
                                BC7934E711906846005EA8E2 /* PlatformWebViewMac.mm */,
-                               E1C642C117CBCC7300D66A3C /* PoseAsClass.mm */,
                                E1C642C217CBCC7300D66A3C /* PoseAsClass.h */,
+                               E1C642C117CBCC7300D66A3C /* PoseAsClass.mm */,
                                BC8C795B11D2785D004535A1 /* TestControllerMac.mm */,
-                               E1C642C417CBCD4C00D66A3C /* WebKitTestRunnerPasteboard.mm */,
+                               E132AA3917CD5F1000611DF0 /* WebKitTestRunnerDraggingInfo.h */,
+                               E132AA3817CD5F1000611DF0 /* WebKitTestRunnerDraggingInfo.mm */,
+                               E132AA3C17CE776F00611DF0 /* WebKitTestRunnerEvent.h */,
+                               E132AA3B17CE776F00611DF0 /* WebKitTestRunnerEvent.mm */,
                                E1C642C517CBCD4C00D66A3C /* WebKitTestRunnerPasteboard.h */,
+                               E1C642C417CBCD4C00D66A3C /* WebKitTestRunnerPasteboard.mm */,
                        );
                        path = mac;
                        sourceTree = "<group>";
 /* Begin PBXProject section */
                08FB7793FE84155DC02AAC07 /* Project object */ = {
                        isa = PBXProject;
-                       attributes = {
-                       };
                        buildConfigurationList = 1DEB927808733DD40010E9CD /* Build configuration list for PBXProject "WebKitTestRunner" */;
                        compatibilityVersion = "Xcode 3.1";
                        developmentRegion = English;
                        files = (
                                5322FB4313FDA0CD0041ABCC /* CyclicRedundancyCheck.cpp in Sources */,
                                E1C642C317CBCC7300D66A3C /* PoseAsClass.mm in Sources */,
+                               E132AA3D17CE776F00611DF0 /* WebKitTestRunnerEvent.mm in Sources */,
                                5670B8281386FCA5002EB355 /* EventSenderProxy.mm in Sources */,
                                26D758E7160BECDD00268472 /* GeolocationProviderMock.cpp in Sources */,
                                BC793400118F7C84005EA8E2 /* main.mm in Sources */,
                                BC8C795C11D2785D004535A1 /* TestControllerMac.mm in Sources */,
                                BCD7D2F811921278006DB7EE /* TestInvocation.cpp in Sources */,
                                BC9192051333E4F8003011DC /* TestInvocationCG.cpp in Sources */,
+                               E132AA3A17CD5F1000611DF0 /* WebKitTestRunnerDraggingInfo.mm in Sources */,
                                3164C8F015D1ADA100EF1FE0 /* WebNotificationProvider.cpp in Sources */,
                                4429FC5F1627089600F66D8B /* WorkQueueManager.cpp in Sources */,
                        );
index f3d848e..233d2f8 100644 (file)
@@ -30,9 +30,9 @@
 #import "PlatformWebView.h"
 #import "StringFunctions.h"
 #import "TestController.h"
-#import <wtf/RetainPtr.h>
 #import <Carbon/Carbon.h>
 #import <WebKit2/WKString.h>
+#import <wtf/RetainPtr.h>
 
 namespace WTR {
 
@@ -179,8 +179,11 @@ void EventSenderProxy::mouseUp(unsigned buttonNumber, WKEventModifiers modifiers
                                         pressure:0.0];
 
     NSView *targetView = [m_testController->mainWebView()->platformView() hitTest:[event locationInWindow]];
+    // FIXME: Silly hack to teach WKTR to respect capturing mouse events outside the WKView.
+    // The right solution is just to use NSApplication's built-in event sending methods, 
+    // instead of rolling our own algorithm for selecting an event target.
     targetView = targetView ? targetView : m_testController->mainWebView()->platformView();
-    assert(targetView);
+    ASSERT(targetView);
     [targetView mouseUp:event];
     if (buttonNumber == LeftMouseButton)
         m_leftMouseButtonDown = false;
index 60b8872..d712200 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2013 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "config.h"
-#include "PlatformWebView.h"
-#include "TestController.h"
+#import "config.h"
+#import "PlatformWebView.h"
 
+#import "TestController.h"
+#import "WebKitTestRunnerDraggingInfo.h"
 #import <WebKit2/WKImageCG.h>
 #import <WebKit2/WKViewPrivate.h>
 #import <wtf/RetainPtr.h>
 
+using namespace WTR;
+
 @interface WebKitTestRunnerWindow : NSWindow {
-    WTR::PlatformWebView* _platformWebView;
+    PlatformWebView* _platformWebView;
     NSPoint _fakeOrigin;
 }
-@property (nonatomic, assign) WTR::PlatformWebView* platformWebView;
+@property (nonatomic, assign) PlatformWebView* platformWebView;
 @end
 
 @interface TestRunnerWKView : WKView {
     return _useTiledDrawing;
 }
 
+- (void)dragImage:(NSImage *)anImage at:(NSPoint)viewLocation offset:(NSSize)initialOffset event:(NSEvent *)event pasteboard:(NSPasteboard *)pboard source:(id)sourceObj slideBack:(BOOL)slideFlag
+{
+    RetainPtr<WebKitTestRunnerDraggingInfo> draggingInfo = adoptNS([[WebKitTestRunnerDraggingInfo alloc] initWithImage:anImage offset:initialOffset pasteboard:pboard source:sourceObj]);
+    [self draggingUpdated:draggingInfo.get()];
+}
+
 @end
 
 @implementation WebKitTestRunnerWindow
index 1b77b65..3ad5d18 100644 (file)
@@ -41,6 +41,7 @@ void TestController::notifyDone()
 void TestController::platformInitialize()
 {
     poseAsClass("WebKitTestRunnerPasteboard", "NSPasteboard");
+    poseAsClass("WebKitTestRunnerEvent", "NSEvent");
 }
 
 void TestController::platformDestroy()
diff --git a/Tools/WebKitTestRunner/mac/WebKitTestRunnerDraggingInfo.h b/Tools/WebKitTestRunner/mac/WebKitTestRunnerDraggingInfo.h
new file mode 100644 (file)
index 0000000..321ab23
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2005, 2006, 2013 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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.
+ */
+
+@interface WebKitTestRunnerDraggingInfo : NSObject <NSDraggingInfo> {
+@private
+    NSSize _offset;
+    NSImage *_draggedImage;
+    NSPasteboard *_draggingPasteboard;
+    id _draggingSource;
+}
+
+- (id)initWithImage:(NSImage *)image offset:(NSSize)offset pasteboard:(NSPasteboard *)pasteboard source:(id)source;
+
+- (NSWindow *)draggingDestinationWindow;
+- (NSDragOperation)draggingSourceOperationMask;
+- (NSPoint)draggingLocation;
+- (NSPoint)draggedImageLocation;
+- (NSImage *)draggedImage;
+- (NSPasteboard *)draggingPasteboard;
+- (id)draggingSource;
+- (int)draggingSequenceNumber;
+
+- (void)slideDraggedImageTo:(NSPoint)screenPoint;
+- (NSArray *)namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination;
+@end
diff --git a/Tools/WebKitTestRunner/mac/WebKitTestRunnerDraggingInfo.mm b/Tools/WebKitTestRunner/mac/WebKitTestRunnerDraggingInfo.mm
new file mode 100644 (file)
index 0000000..af31d33
--- /dev/null
@@ -0,0 +1,149 @@
+/*
+ * Copyright (C) 2005, 2006, 2013 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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.
+ */
+
+#import "config.h"
+#import "WebKitTestRunnerDraggingInfo.h"
+
+#import "EventSenderProxy.h"
+#import "PlatformWebView.h"
+#import "TestController.h"
+
+using namespace WTR;
+
+@implementation WebKitTestRunnerDraggingInfo
+
+- (id)initWithImage:(NSImage *)image offset:(NSSize)offset pasteboard:(NSPasteboard *)pasteboard source:(id)source
+{
+    self = [super init];
+    if (!self)
+        return nil;
+
+    _draggedImage = [image retain];
+    _draggingPasteboard = [pasteboard retain];
+    _draggingSource = [source retain];
+    _offset = offset;
+    
+    return self;
+}
+
+- (void)dealloc
+{
+    [_draggedImage release];
+    [_draggingPasteboard release];
+    [_draggingSource release];
+    [super dealloc];
+}
+
+- (NSWindow *)draggingDestinationWindow 
+{
+    return [TestController::shared().mainWebView()->platformView() window];
+}
+
+- (NSDragOperation)draggingSourceOperationMask 
+{
+    // WKView currently implements neither draggingSourceOperationMaskForLocal: nor draggingSession:sourceOperationMaskForDraggingContext:.
+    return NSDragOperationAll;
+}
+
+- (NSPoint)draggingLocation
+{
+    WKPoint location = TestController::shared().eventSenderProxy()->position();
+    return NSMakePoint(location.x, location.y);
+}
+
+- (NSPoint)draggedImageLocation 
+{
+    WKPoint location = TestController::shared().eventSenderProxy()->position();
+    return NSMakePoint(location.x + _offset.width, location.y + _offset.height);
+}
+
+- (NSImage *)draggedImage
+{
+    return _draggedImage;
+}
+
+- (NSPasteboard *)draggingPasteboard
+{
+    return _draggingPasteboard;
+}
+
+- (id)draggingSource
+{
+    return _draggingSource;
+}
+
+- (int)draggingSequenceNumber
+{
+    NSLog(@"WebKitTestRunner doesn't support draggingSequenceNumber");
+    return 0;
+}
+
+- (void)slideDraggedImageTo:(NSPoint)screenPoint
+{
+    NSLog(@"WebKitTestRunner doesn't support slideDraggedImageTo:");
+}
+
+- (NSArray *)namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination
+{
+    NSLog(@"WebKitTestRunner doesn't support namesOfPromisedFilesDroppedAtDestination:");
+    return nil;
+}
+
+- (NSDraggingFormation)draggingFormation
+{
+    return NSDraggingFormationDefault;
+}
+
+- (void)setDraggingFormation:(NSDraggingFormation)formation
+{
+    // Ignored.
+}
+
+- (BOOL)animatesToDestination
+{
+    return NO;
+}
+
+- (void)setAnimatesToDestination:(BOOL)flag
+{
+    // Ignored.
+}
+
+- (NSInteger)numberOfValidItemsForDrop
+{
+    return 1;
+}
+
+- (void)setNumberOfValidItemsForDrop:(NSInteger)number
+{
+    // Ignored.
+}
+
+- (void)enumerateDraggingItemsWithOptions:(NSEnumerationOptions)enumOpts forView:(NSView *)view classes:(NSArray *)classArray searchOptions:(NSDictionary *)searchOptions usingBlock:(void (^)(NSDraggingItem *draggingItem, NSInteger idx, BOOL *stop))block
+{
+    // Ignored.
+}
+
+@end
diff --git a/Tools/WebKitTestRunner/mac/WebKitTestRunnerEvent.h b/Tools/WebKitTestRunner/mac/WebKitTestRunnerEvent.h
new file mode 100644 (file)
index 0000000..7c7e189
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2013 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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.
+ */
+
+@interface WebKitTestRunnerEvent : NSEvent
+@end
diff --git a/Tools/WebKitTestRunner/mac/WebKitTestRunnerEvent.mm b/Tools/WebKitTestRunner/mac/WebKitTestRunnerEvent.mm
new file mode 100644 (file)
index 0000000..24212c7
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2013 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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.
+ */
+
+#import "config.h"
+#import "WebKitTestRunnerEvent.h"
+
+#import "EventSenderProxy.h"
+#import "TestController.h"
+#import "PlatformWebView.h"
+
+using namespace WTR;
+
+@implementation WebKitTestRunnerEvent
+
++ (NSPoint)mouseLocation
+{
+    WKPoint location = TestController::shared().eventSenderProxy()->position();
+    return [TestController::shared().mainWebView()->platformWindow() convertBaseToScreen:NSMakePoint(location.x, location.y)];
+}
+
+@end