2006-03-17 Eric Seidel <eseidel@apple.com>
authoreseidel <eseidel@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Mar 2006 09:13:45 +0000 (09:13 +0000)
committereseidel <eseidel@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Mar 2006 09:13:45 +0000 (09:13 +0000)
        Rubber-stamped by ggaren.

        Break DumpRenderTree.m up into several files to make the code more readable.

        * DumpRenderTree/DumpRenderTree.h: Added.
        * DumpRenderTree/DumpRenderTree.m:
        (doneLoading): new accessor function for "done" global.
        * DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
        * DumpRenderTree/DumpRenderTreeDraggingInfo.h: Added.
        * DumpRenderTree/DumpRenderTreeDraggingInfo.m: Added.
        * DumpRenderTree/EditingDelegate.h: Added.
        * DumpRenderTree/EditingDelegate.m: Added.
        (-[EditingDelegate webViewDidChangeSelection:]):
        * DumpRenderTree/EventSendingController.h: Added.
        * DumpRenderTree/EventSendingController.m: Added.

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

WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/DumpRenderTree.h [new file with mode: 0644]
WebKitTools/DumpRenderTree/DumpRenderTree.m
WebKitTools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj
WebKitTools/DumpRenderTree/DumpRenderTreeDraggingInfo.h [new file with mode: 0644]
WebKitTools/DumpRenderTree/DumpRenderTreeDraggingInfo.m [new file with mode: 0644]
WebKitTools/DumpRenderTree/EditingDelegate.h [new file with mode: 0644]
WebKitTools/DumpRenderTree/EditingDelegate.m [new file with mode: 0644]
WebKitTools/DumpRenderTree/EventSendingController.h [new file with mode: 0644]
WebKitTools/DumpRenderTree/EventSendingController.m [new file with mode: 0644]

index 74056356f6dd8dd29f6c1d9063a010d91c7d80ee..b0e4cabb89d9430b4e2b38b7f47626c23813ba7a 100644 (file)
@@ -1,3 +1,21 @@
+2006-03-17  Eric Seidel  <eseidel@apple.com>
+
+        Rubber-stamped by ggaren.
+
+        Break DumpRenderTree.m up into several files to make the code more readable.
+
+        * DumpRenderTree/DumpRenderTree.h: Added.
+        * DumpRenderTree/DumpRenderTree.m:
+        (doneLoading): new accessor function for "done" global.
+        * DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
+        * DumpRenderTree/DumpRenderTreeDraggingInfo.h: Added.
+        * DumpRenderTree/DumpRenderTreeDraggingInfo.m: Added.
+        * DumpRenderTree/EditingDelegate.h: Added.
+        * DumpRenderTree/EditingDelegate.m: Added.
+        (-[EditingDelegate webViewDidChangeSelection:]):
+        * DumpRenderTree/EventSendingController.h: Added.
+        * DumpRenderTree/EventSendingController.m: Added.
+
 2006-03-16  Eric Seidel  <eseidel@apple.com>
 
         Reviewed by darin.
diff --git a/WebKitTools/DumpRenderTree/DumpRenderTree.h b/WebKitTools/DumpRenderTree/DumpRenderTree.h
new file mode 100644 (file)
index 0000000..cd1f11f
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2006 Apple Computer, 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. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE 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 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 "DumpRenderTreeDraggingInfo.h"
+
+@class WebFrame;
+
+extern WebFrame *frame;
+extern DumpRenderTreeDraggingInfo *draggingInfo;
+
+BOOL doneLoading();
\ No newline at end of file
index 35b387ae140345540a72dacd228befb854d7a6a7..68fb7ae4248df008878de54812d35dfe98506a94 100644 (file)
@@ -25,6 +25,8 @@
  * (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 "DumpRenderTree.h"
 
 #import <WebKit/DOMExtensions.h>
 #import <WebKit/DOMRange.h>
@@ -38,7 +40,6 @@
 #import <WebKit/WebHTMLViewPrivate.h>
 #import <WebKit/WebPluginDatabase.h>
 
-#import <Carbon/Carbon.h>                           // for GetCurrentEventTime()
 #import <ApplicationServices/ApplicationServices.h> // for CMSetDefaultProfileBySpace
 #import <objc/objc-runtime.h>                       // for class_poseAs
 
 #import "TextInputController.h"
 #import "NavigationController.h"
 #import "AppleScriptController.h"
+#import "EventSendingController.h"
+#import "EditingDelegate.h"
 
 @interface DumpRenderTreeWindow : NSWindow
 @end
 
-@interface DumpRenderTreeDraggingInfo : 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
-
 @interface DumpRenderTreePasteboard : NSPasteboard
 @end
 
 @interface WaitUntilDoneDelegate : NSObject
 @end
 
-@interface EditingDelegate : NSObject
-@end
-
 @interface LayoutTestController : NSObject
 @end
 
-@interface EventSendingController : NSObject
-{
-    BOOL down;
-    int clickCount;
-    NSTimeInterval lastClick;
-    int eventNumber;
-    double timeOffset;
-}
-@end
-
 static void dumpRenderTree(const char *pathOrURL);
 static NSString *md5HashStringForBitmap(CGImageRef bitmap);
 
+WebFrame *frame = 0;
+DumpRenderTreeDraggingInfo *draggingInfo = 0;
+
 static volatile BOOL done;
-static WebFrame *frame;
 static NavigationController *navigationController;
 static BOOL readyToDump;
 static BOOL waitToDump;
@@ -114,14 +85,17 @@ static BOOL printSeparators;
 static NSString *currentTest = nil;
 static NSPasteboard *localPasteboard;
 static BOOL windowIsKey = YES;
-static NSPoint lastMousePosition;
-static DumpRenderTreeDraggingInfo *draggingInfo;
 static unsigned char* screenCaptureBuffer;
 static CGColorSpaceRef sharedColorSpace;
 
 const unsigned maxViewHeight = 600;
 const unsigned maxViewWidth = 800;
 
+BOOL doneLoading()
+{
+    return done;
+}
+
 static CMProfileRef currentColorProfile = 0;
 static void restoreColorSpace(int ignored)
 {
@@ -505,134 +479,6 @@ static void dump(void)
 
 @end
 
-@interface DOMNode (dumpPath)
-- (NSString *)dumpPath;
-@end
-
-@implementation DOMNode (dumpPath)
-- (NSString *)dumpPath
-{
-    DOMNode *parent = [self parentNode];
-    NSString *str = [NSString stringWithFormat:@"%@", [self nodeName]];
-    if (parent != nil) {
-        str = [str stringByAppendingString:@" > "];
-        str = [str stringByAppendingString:[parent dumpPath]];
-    }
-    return str;
-}
-@end
-
-@interface DOMRange (dump)
-- (NSString *)dump;
-@end
-
-@implementation DOMRange (dump)
-- (NSString *)dump
-{
-    return [NSString stringWithFormat:@"range from %ld of %@ to %ld of %@", [self startOffset], [[self startContainer] dumpPath], [self endOffset], [[self endContainer] dumpPath]];
-}
-@end
-
-
-@implementation EditingDelegate
-
-- (BOOL)webView:(WebView *)webView shouldBeginEditingInDOMRange:(DOMRange *)range
-{
-    printf("EDITING DELEGATE: shouldBeginEditingInDOMRange:%s\n", [[range dump] UTF8String]);
-    return YES;
-}
-
-- (BOOL)webView:(WebView *)webView shouldEndEditingInDOMRange:(DOMRange *)range
-{
-    printf("EDITING DELEGATE: shouldEndEditingInDOMRange:%s\n", [[range dump] UTF8String]);
-    return YES;
-}
-
-- (BOOL)webView:(WebView *)webView shouldInsertNode:(DOMNode *)node replacingDOMRange:(DOMRange *)range givenAction:(WebViewInsertAction)action
-{
-    static const char *insertactionstring[] = {
-        "WebViewInsertActionTyped",
-        "WebViewInsertActionPasted",
-        "WebViewInsertActionDropped",
-    };
-
-    printf("EDITING DELEGATE: shouldInsertNode:%s replacingDOMRange:%s givenAction:%s\n", [[node dumpPath] UTF8String], [[range dump] UTF8String], insertactionstring[action]);
-    return YES;
-}
-
-- (BOOL)webView:(WebView *)webView shouldInsertText:(NSString *)text replacingDOMRange:(DOMRange *)range givenAction:(WebViewInsertAction)action
-{
-    static const char *insertactionstring[] = {
-        "WebViewInsertActionTyped",
-        "WebViewInsertActionPasted",
-        "WebViewInsertActionDropped",
-    };
-
-    printf("EDITING DELEGATE: shouldInsertText:%s replacingDOMRange:%s givenAction:%s\n", [[text description] UTF8String], [[range dump] UTF8String], insertactionstring[action]);
-    return YES;
-}
-
-- (BOOL)webView:(WebView *)webView shouldDeleteDOMRange:(DOMRange *)range
-{
-    printf("EDITING DELEGATE: shouldDeleteDOMRange:%s\n", [[range dump] UTF8String]);
-    return YES;
-}
-
-- (BOOL)webView:(WebView *)webView shouldChangeSelectedDOMRange:(DOMRange *)currentRange toDOMRange:(DOMRange *)proposedRange affinity:(NSSelectionAffinity)selectionAffinity stillSelecting:(BOOL)flag
-{
-    static const char *affinitystring[] = {
-        "NSSelectionAffinityUpstream",
-        "NSSelectionAffinityDownstream"
-    };
-    static const char *boolstring[] = {
-        "FALSE",
-        "TRUE"
-    };
-
-    printf("EDITING DELEGATE: shouldChangeSelectedDOMRange:%s toDOMRange:%s affinity:%s stillSelecting:%s\n", [[currentRange dump] UTF8String], [[proposedRange dump] UTF8String], affinitystring[selectionAffinity], boolstring[flag]);
-    return YES;
-}
-
-- (BOOL)webView:(WebView *)webView shouldApplyStyle:(DOMCSSStyleDeclaration *)style toElementsInDOMRange:(DOMRange *)range
-{
-    printf("EDITING DELEGATE: shouldApplyStyle:%s toElementsInDOMRange:%s\n", [[style description] UTF8String], [[range dump] UTF8String]);
-    return YES;
-}
-
-- (BOOL)webView:(WebView *)webView shouldChangeTypingStyle:(DOMCSSStyleDeclaration *)currentStyle toStyle:(DOMCSSStyleDeclaration *)proposedStyle
-{
-    printf("EDITING DELEGATE: shouldChangeTypingStyle:%s toStyle:%s\n", [[currentStyle description] UTF8String], [[proposedStyle description] UTF8String]);
-    return YES;
-}
-
-- (void)webViewDidBeginEditing:(NSNotification *)notification
-{
-    printf("EDITING DELEGATE: webViewDidBeginEditing:%s\n", [[notification name] UTF8String]);
-}
-
-- (void)webViewDidChange:(NSNotification *)notification
-{
-    printf("EDITING DELEGATE: webViewDidChange:%s\n", [[notification name] UTF8String]);
-}
-
-- (void)webViewDidEndEditing:(NSNotification *)notification
-{
-    printf("EDITING DELEGATE: webViewDidEndEditing:%s\n", [[notification name] UTF8String]);
-}
-
-- (void)webViewDidChangeTypingStyle:(NSNotification *)notification
-{
-    printf("EDITING DELEGATE: webViewDidChangeTypingStyle:%s\n", [[notification name] UTF8String]);
-}
-
-- (void)webViewDidChangeSelection:(NSNotification *)notification
-{
-    if (!done)
-        printf("EDITING DELEGATE: webViewDidChangeSelection:%s\n", [[notification name] UTF8String]);
-}
-
-@end
-
 @implementation LayoutTestController
 
 + (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector
@@ -704,165 +550,6 @@ static void dump(void)
 
 @end
 
-@implementation EventSendingController
-
-+ (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector
-{
-    if (aSelector == @selector(mouseDown)
-            || aSelector == @selector(mouseUp)
-            || aSelector == @selector(mouseClick)
-            || aSelector == @selector(mouseMoveToX:Y:)
-            || aSelector == @selector(leapForward:))
-        return NO;
-    return YES;
-}
-
-+ (NSString *)webScriptNameForSelector:(SEL)aSelector
-{
-    if (aSelector == @selector(mouseMoveToX:Y:))
-        return @"mouseMoveTo";
-    if (aSelector == @selector(leapForward:))
-        return @"leapForward";
-    return nil;
-}
-
-- (id)init
-{
-    lastMousePosition = NSMakePoint(0, 0);
-    down = NO;
-    clickCount = 0;
-    lastClick = 0;
-    return self;
-}
-
-- (double)currentEventTime
-{
-    return GetCurrentEventTime() + timeOffset;
-}
-
-- (void)leapForward:(int)milliseconds
-{
-    timeOffset += milliseconds / 1000.0;
-}
-
-- (void)mouseDown
-{
-    [[[frame frameView] documentView] layout];
-    if ([self currentEventTime] - lastClick >= 1)
-        clickCount = 1;
-    else
-        clickCount++;
-    NSEvent *event = [NSEvent mouseEventWithType:NSLeftMouseDown 
-                                        location:lastMousePosition 
-                                   modifierFlags:nil 
-                                       timestamp:[self currentEventTime]
-                                    windowNumber:[[[frame webView] window] windowNumber] 
-                                         context:[NSGraphicsContext currentContext] 
-                                     eventNumber:++eventNumber 
-                                      clickCount:clickCount 
-                                        pressure:nil];
-
-    NSView *subView = [[frame webView] hitTest:[event locationInWindow]];
-    if (subView) {
-        [subView mouseDown:event];
-        down = YES;
-    }
-}
-
-- (void)mouseUp
-{
-    [[[frame frameView] documentView] layout];
-    NSEvent *event = [NSEvent mouseEventWithType:NSLeftMouseUp 
-                                        location:lastMousePosition 
-                                   modifierFlags:nil 
-                                       timestamp:[self currentEventTime]
-                                    windowNumber:[[[frame webView] window] windowNumber] 
-                                         context:[NSGraphicsContext currentContext] 
-                                     eventNumber:++eventNumber 
-                                      clickCount:clickCount 
-                                        pressure:nil];
-
-    NSView *subView = [[frame webView] hitTest:[event locationInWindow]];
-    if (subView) {
-        [subView mouseUp:event];
-        down = NO;
-        lastClick = [event timestamp];
-        if (draggingInfo) {
-            WebView *webView = [frame webView];
-            
-            NSDragOperation dragOperation = [webView draggingUpdated:draggingInfo];
-            
-            [[draggingInfo draggingSource] draggedImage:[draggingInfo draggedImage] endedAt:lastMousePosition operation:dragOperation];
-            if (dragOperation != NSDragOperationNone)
-                [webView performDragOperation:draggingInfo];
-            [draggingInfo release];
-            draggingInfo = nil;
-        }
-    }
-}
-
-- (void)mouseMoveToX:(int)x Y:(int)y
-{
-    lastMousePosition = NSMakePoint(x, [[frame webView] frame].size.height - y);
-    NSEvent *event = [NSEvent mouseEventWithType:(down ? NSLeftMouseDragged : NSMouseMoved) 
-                                        location:lastMousePosition 
-                                   modifierFlags:nil 
-                                       timestamp:[self currentEventTime]
-                                    windowNumber:[[[frame webView] window] windowNumber] 
-                                         context:[NSGraphicsContext currentContext] 
-                                     eventNumber:++eventNumber 
-                                      clickCount:(down ? clickCount : 0) 
-                                        pressure:nil];
-
-    NSView *subView = [[frame webView] hitTest:[event locationInWindow]];
-    if (subView) {
-        if (down) {
-            [subView mouseDragged:event];
-            [[draggingInfo draggingSource] draggedImage:[draggingInfo draggedImage] movedTo:lastMousePosition];
-            [[frame webView] draggingUpdated:draggingInfo];
-        }
-        else
-            [subView mouseMoved:event];
-    }
-}
-
-- (void)mouseClick
-{
-    [[[frame frameView] documentView] layout];
-    if ([self currentEventTime] - lastClick >= 1)
-        clickCount = 1;
-    else
-        clickCount++;
-    NSEvent *mouseDownEvent = [NSEvent mouseEventWithType:NSLeftMouseDown 
-                                        location:lastMousePosition 
-                                   modifierFlags:nil 
-                                       timestamp:[self currentEventTime]
-                                    windowNumber:[[[frame webView] window] windowNumber] 
-                                         context:[NSGraphicsContext currentContext] 
-                                     eventNumber:++eventNumber 
-                                      clickCount:clickCount 
-                                        pressure:nil];
-
-    NSView *subView = [[frame webView] hitTest:[mouseDownEvent locationInWindow]];
-    if (subView) {
-        [self leapForward:1];
-        NSEvent *mouseUpEvent = [NSEvent mouseEventWithType:NSLeftMouseUp
-                                                   location:lastMousePosition
-                                              modifierFlags:nil
-                                                  timestamp:[self currentEventTime]
-                                               windowNumber:[[[frame webView] window] windowNumber]
-                                                    context:[NSGraphicsContext currentContext]
-                                                eventNumber:++eventNumber
-                                                 clickCount:clickCount
-                                                   pressure:nil];
-        [NSApp postEvent:mouseUpEvent atStart:NO];
-        [subView mouseDown:mouseDownEvent];
-        lastClick = [mouseUpEvent timestamp];
-    }
-}
-
-@end
-
 static void dumpRenderTree(const char *pathOrURL)
 {
     CFStringRef pathOrURLString = CFStringCreateWithCString(NULL, pathOrURL, kCFStringEncodingUTF8);
@@ -957,78 +644,3 @@ static NSString *md5HashStringForBitmap(CGImageRef bitmap)
 }
 
 @end
-
-@implementation DumpRenderTreeDraggingInfo
-
-- (id)initWithImage:(NSImage *)anImage offset:(NSSize)o pasteboard:(NSPasteboard *)pboard source:(id)source
-{
-    draggedImage = [anImage retain];
-    draggingPasteboard = [pboard retain];
-    draggingSource = [source retain];
-    offset = o;
-    
-    return [super init];
-}
-
-- (void)dealloc
-{
-    [draggedImage release];
-    [draggingPasteboard release];
-    [draggingSource release];
-    [super dealloc];
-}
-
-- (NSWindow *)draggingDestinationWindow 
-{
-    return [[frame webView] window];
-}
-
-- (NSDragOperation)draggingSourceOperationMask 
-{
-    return [draggingSource draggingSourceOperationMaskForLocal:YES];
-}
-
-- (NSPoint)draggingLocation
-{ 
-    return lastMousePosition; 
-}
-
-- (NSPoint)draggedImageLocation 
-{
-    return NSMakePoint(lastMousePosition.x + offset.width, lastMousePosition.y + offset.height);
-}
-
-- (NSImage *)draggedImage
-{
-    return draggedImage;
-}
-
-- (NSPasteboard *)draggingPasteboard
-{
-    return draggingPasteboard;
-}
-
-- (id)draggingSource
-{
-    return draggingSource;
-}
-
-- (int)draggingSequenceNumber
-{
-    NSLog(@"DumpRenderTree doesn't support draggingSequenceNumber");
-    return 0;
-}
-
-- (void)slideDraggedImageTo:(NSPoint)screenPoint
-{
-    NSLog(@"DumpRenderTree doesn't support slideDraggedImageTo:");
-}
-
-- (NSArray *)namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination
-{
-    NSLog(@"DumpRenderTree doesn't support namesOfPromisedFilesDroppedAtDestination:");
-    return nil;
-}
-
-@end
-
index dbc0e843b01069f1408ca111d2846c9c9bb82a0b..b77c2a2cba27dcb89f8df5a39e21ee8521216286 100644 (file)
                9340995108540CAE007F3BC8 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9335435F03D75502008635CE /* WebKit.framework */; };
                93442CF608F8BA4900BFE8CA /* TextInputController.h in Headers */ = {isa = PBXBuildFile; fileRef = 93442CF408F8BA4900BFE8CA /* TextInputController.h */; };
                93442CF708F8BA4900BFE8CA /* TextInputController.m in Sources */ = {isa = PBXBuildFile; fileRef = 93442CF508F8BA4900BFE8CA /* TextInputController.m */; };
+               A803FCC709CAAB8D009B2A37 /* EventSendingController.m in Sources */ = {isa = PBXBuildFile; fileRef = A803FCB809CAAAB1009B2A37 /* EventSendingController.m */; };
+               A803FCC809CAAB90009B2A37 /* EventSendingController.h in Headers */ = {isa = PBXBuildFile; fileRef = A803FCB709CAAAB0009B2A37 /* EventSendingController.h */; };
+               A803FFBD09CAAE99009B2A37 /* DumpRenderTreeDraggingInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = A803FFB309CAAE0B009B2A37 /* DumpRenderTreeDraggingInfo.m */; };
+               A803FFBE09CAAE9C009B2A37 /* DumpRenderTreeDraggingInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = A803FFB209CAAE0B009B2A37 /* DumpRenderTreeDraggingInfo.h */; };
+               A803FFF509CAAFE0009B2A37 /* EditingDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = A803FFF309CAAFE0009B2A37 /* EditingDelegate.h */; };
+               A803FFF609CAAFE0009B2A37 /* EditingDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = A803FFF409CAAFE0009B2A37 /* EditingDelegate.m */; };
                A817090008B163EF00CCB9FB /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A84F608908B136DA00E9745F /* Cocoa.framework */; };
                A817090208B1643800CCB9FB /* WebCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A817090108B1643800CCB9FB /* WebCore.framework */; };
                A817090408B164D300CCB9FB /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A817090308B164D300CCB9FB /* JavaScriptCore.framework */; };
                9340995408540CAF007F3BC8 /* DumpRenderTree */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = DumpRenderTree; sourceTree = BUILT_PRODUCTS_DIR; };
                93442CF408F8BA4900BFE8CA /* TextInputController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextInputController.h; sourceTree = "<group>"; };
                93442CF508F8BA4900BFE8CA /* TextInputController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TextInputController.m; sourceTree = "<group>"; };
+               A803FCB709CAAAB0009B2A37 /* EventSendingController.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = EventSendingController.h; sourceTree = "<group>"; };
+               A803FCB809CAAAB1009B2A37 /* EventSendingController.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = EventSendingController.m; sourceTree = "<group>"; };
+               A803FF7409CAAD08009B2A37 /* DumpRenderTree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DumpRenderTree.h; sourceTree = "<group>"; };
+               A803FFB209CAAE0B009B2A37 /* DumpRenderTreeDraggingInfo.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DumpRenderTreeDraggingInfo.h; sourceTree = "<group>"; };
+               A803FFB309CAAE0B009B2A37 /* DumpRenderTreeDraggingInfo.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = DumpRenderTreeDraggingInfo.m; sourceTree = "<group>"; };
+               A803FFF309CAAFE0009B2A37 /* EditingDelegate.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = EditingDelegate.h; sourceTree = "<group>"; };
+               A803FFF409CAAFE0009B2A37 /* EditingDelegate.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = EditingDelegate.m; sourceTree = "<group>"; };
                A817090108B1643800CCB9FB /* WebCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = WebCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
                A817090308B164D300CCB9FB /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = JavaScriptCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
                A84F608908B136DA00E9745F /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
                        isa = PBXGroup;
                        children = (
                                141BF1F5096A439800E0753C /* TestNetscapePlugIn.subproj */,
+                               A803FFF309CAAFE0009B2A37 /* EditingDelegate.h */,
+                               A803FFF409CAAFE0009B2A37 /* EditingDelegate.m */,
+                               A803FF7409CAAD08009B2A37 /* DumpRenderTree.h */,
                                08FB7796FE84155DC02AAC07 /* DumpRenderTree.m */,
+                               A803FFB209CAAE0B009B2A37 /* DumpRenderTreeDraggingInfo.h */,
+                               A803FFB309CAAE0B009B2A37 /* DumpRenderTreeDraggingInfo.m */,
                                32A70AAB03705E1F00C91783 /* DumpRenderTreePrefix.h */,
+                               A803FCB709CAAAB0009B2A37 /* EventSendingController.h */,
+                               A803FCB809CAAAB1009B2A37 /* EventSendingController.m */,
                                93442CF408F8BA4900BFE8CA /* TextInputController.h */,
                                93442CF508F8BA4900BFE8CA /* TextInputController.m */,
                                E13307FE099624DA00AC0A91 /* AppleScriptController.h */,
                                E13307FF099624DA00AC0A91 /* AppleScriptController.m */,
                                B5A7525808AF4A3600138E45 /* ImageDiff.m */,
-                               9335435F03D75502008635CE /* WebKit.framework */,
-                               A817090308B164D300CCB9FB /* JavaScriptCore.framework */,
-                               A817090108B1643800CCB9FB /* WebCore.framework */,
-                               B5A752A108AF5D1F00138E45 /* QuartzCore.framework */,
-                               A84F608908B136DA00E9745F /* Cocoa.framework */,
-                               AE8257EF08D22389000507AB /* Carbon.framework */,
-                               9340995508540CAF007F3BC8 /* Products */,
                                14A6FB880971CAE5008B014F /* NavigationController.h */,
                                14A6FB890971CAE5008B014F /* NavigationController.m */,
+                               A803FF6409CAACC1009B2A37 /* Frameworks */,
+                               9340995508540CAF007F3BC8 /* Products */,
                        );
                        name = DumpRenderTree;
                        sourceTree = "<group>";
                        name = Products;
                        sourceTree = "<group>";
                };
+               A803FF6409CAACC1009B2A37 /* Frameworks */ = {
+                       isa = PBXGroup;
+                       children = (
+                               9335435F03D75502008635CE /* WebKit.framework */,
+                               A817090308B164D300CCB9FB /* JavaScriptCore.framework */,
+                               A817090108B1643800CCB9FB /* WebCore.framework */,
+                               B5A752A108AF5D1F00138E45 /* QuartzCore.framework */,
+                               A84F608908B136DA00E9745F /* Cocoa.framework */,
+                               AE8257EF08D22389000507AB /* Carbon.framework */,
+                       );
+                       name = Frameworks;
+                       sourceTree = "<group>";
+               };
 /* End PBXGroup section */
 
 /* Begin PBXHeadersBuildPhase section */
                        isa = PBXHeadersBuildPhase;
                        buildActionMask = 2147483647;
                        files = (
+                               A803FFBE09CAAE9C009B2A37 /* DumpRenderTreeDraggingInfo.h in Headers */,
+                               A803FCC809CAAB90009B2A37 /* EventSendingController.h in Headers */,
                                9340994C08540CAE007F3BC8 /* DumpRenderTreePrefix.h in Headers */,
                                93442CF608F8BA4900BFE8CA /* TextInputController.h in Headers */,
                                14A6FB8A0971CAE5008B014F /* NavigationController.h in Headers */,
                                E1330800099624DA00AC0A91 /* AppleScriptController.h in Headers */,
+                               A803FFF509CAAFE0009B2A37 /* EditingDelegate.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                        isa = PBXSourcesBuildPhase;
                        buildActionMask = 2147483647;
                        files = (
+                               A803FFBD09CAAE99009B2A37 /* DumpRenderTreeDraggingInfo.m in Sources */,
+                               A803FCC709CAAB8D009B2A37 /* EventSendingController.m in Sources */,
                                9340994E08540CAE007F3BC8 /* DumpRenderTree.m in Sources */,
                                93442CF708F8BA4900BFE8CA /* TextInputController.m in Sources */,
                                14A6FB8B0971CAE5008B014F /* NavigationController.m in Sources */,
                                E1330801099624DA00AC0A91 /* AppleScriptController.m in Sources */,
+                               A803FFF609CAAFE0009B2A37 /* EditingDelegate.m in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
diff --git a/WebKitTools/DumpRenderTree/DumpRenderTreeDraggingInfo.h b/WebKitTools/DumpRenderTree/DumpRenderTreeDraggingInfo.h
new file mode 100644 (file)
index 0000000..249809c
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2005, 2006 Apple Computer, 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. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE 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 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 <Cocoa/Cocoa.h>
+
+@interface DumpRenderTreeDraggingInfo : 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/WebKitTools/DumpRenderTree/DumpRenderTreeDraggingInfo.m b/WebKitTools/DumpRenderTree/DumpRenderTreeDraggingInfo.m
new file mode 100644 (file)
index 0000000..b0407e1
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2005, 2006 Apple Computer, 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. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE 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 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 "DumpRenderTreeDraggingInfo.h"
+
+#import "DumpRenderTree.h"
+#import "EventSendingController.h"
+#import <WebKit/WebKit.h>
+
+@implementation DumpRenderTreeDraggingInfo
+
+- (id)initWithImage:(NSImage *)anImage offset:(NSSize)o pasteboard:(NSPasteboard *)pboard source:(id)source
+{
+    draggedImage = [anImage retain];
+    draggingPasteboard = [pboard retain];
+    draggingSource = [source retain];
+    offset = o;
+    
+    return [super init];
+}
+
+- (void)dealloc
+{
+    [draggedImage release];
+    [draggingPasteboard release];
+    [draggingSource release];
+    [super dealloc];
+}
+
+- (NSWindow *)draggingDestinationWindow 
+{
+    return [[frame webView] window];
+}
+
+- (NSDragOperation)draggingSourceOperationMask 
+{
+    return [draggingSource draggingSourceOperationMaskForLocal:YES];
+}
+
+- (NSPoint)draggingLocation
+{ 
+    return lastMousePosition; 
+}
+
+- (NSPoint)draggedImageLocation 
+{
+    return NSMakePoint(lastMousePosition.x + offset.width, lastMousePosition.y + offset.height);
+}
+
+- (NSImage *)draggedImage
+{
+    return draggedImage;
+}
+
+- (NSPasteboard *)draggingPasteboard
+{
+    return draggingPasteboard;
+}
+
+- (id)draggingSource
+{
+    return draggingSource;
+}
+
+- (int)draggingSequenceNumber
+{
+    NSLog(@"DumpRenderTree doesn't support draggingSequenceNumber");
+    return 0;
+}
+
+- (void)slideDraggedImageTo:(NSPoint)screenPoint
+{
+    NSLog(@"DumpRenderTree doesn't support slideDraggedImageTo:");
+}
+
+- (NSArray *)namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination
+{
+    NSLog(@"DumpRenderTree doesn't support namesOfPromisedFilesDroppedAtDestination:");
+    return nil;
+}
+
+@end
+
diff --git a/WebKitTools/DumpRenderTree/EditingDelegate.h b/WebKitTools/DumpRenderTree/EditingDelegate.h
new file mode 100644 (file)
index 0000000..709c7f5
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2005, 2006 Apple Computer, 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. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE 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 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 <Cocoa/Cocoa.h>
+
+@interface EditingDelegate : NSObject
+@end
diff --git a/WebKitTools/DumpRenderTree/EditingDelegate.m b/WebKitTools/DumpRenderTree/EditingDelegate.m
new file mode 100644 (file)
index 0000000..3a20fec
--- /dev/null
@@ -0,0 +1,159 @@
+/*
+ * Copyright (C) 2005, 2006 Apple Computer, 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. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE 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 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 "EditingDelegate.h"
+#import "DumpRenderTree.h"
+
+#import <WebKit/WebKit.h>
+
+@interface DOMNode (dumpPath)
+- (NSString *)dumpPath;
+@end
+
+@implementation DOMNode (dumpPath)
+- (NSString *)dumpPath
+{
+    DOMNode *parent = [self parentNode];
+    NSString *str = [NSString stringWithFormat:@"%@", [self nodeName]];
+    if (parent != nil) {
+        str = [str stringByAppendingString:@" > "];
+        str = [str stringByAppendingString:[parent dumpPath]];
+    }
+    return str;
+}
+@end
+
+@interface DOMRange (dump)
+- (NSString *)dump;
+@end
+
+@implementation DOMRange (dump)
+- (NSString *)dump
+{
+    return [NSString stringWithFormat:@"range from %ld of %@ to %ld of %@", [self startOffset], [[self startContainer] dumpPath], [self endOffset], [[self endContainer] dumpPath]];
+}
+@end
+
+@implementation EditingDelegate
+
+- (BOOL)webView:(WebView *)webView shouldBeginEditingInDOMRange:(DOMRange *)range
+{
+    printf("EDITING DELEGATE: shouldBeginEditingInDOMRange:%s\n", [[range dump] UTF8String]);
+    return YES;
+}
+
+- (BOOL)webView:(WebView *)webView shouldEndEditingInDOMRange:(DOMRange *)range
+{
+    printf("EDITING DELEGATE: shouldEndEditingInDOMRange:%s\n", [[range dump] UTF8String]);
+    return YES;
+}
+
+- (BOOL)webView:(WebView *)webView shouldInsertNode:(DOMNode *)node replacingDOMRange:(DOMRange *)range givenAction:(WebViewInsertAction)action
+{
+    static const char *insertactionstring[] = {
+        "WebViewInsertActionTyped",
+        "WebViewInsertActionPasted",
+        "WebViewInsertActionDropped",
+    };
+
+    printf("EDITING DELEGATE: shouldInsertNode:%s replacingDOMRange:%s givenAction:%s\n", [[node dumpPath] UTF8String], [[range dump] UTF8String], insertactionstring[action]);
+    return YES;
+}
+
+- (BOOL)webView:(WebView *)webView shouldInsertText:(NSString *)text replacingDOMRange:(DOMRange *)range givenAction:(WebViewInsertAction)action
+{
+    static const char *insertactionstring[] = {
+        "WebViewInsertActionTyped",
+        "WebViewInsertActionPasted",
+        "WebViewInsertActionDropped",
+    };
+
+    printf("EDITING DELEGATE: shouldInsertText:%s replacingDOMRange:%s givenAction:%s\n", [[text description] UTF8String], [[range dump] UTF8String], insertactionstring[action]);
+    return YES;
+}
+
+- (BOOL)webView:(WebView *)webView shouldDeleteDOMRange:(DOMRange *)range
+{
+    printf("EDITING DELEGATE: shouldDeleteDOMRange:%s\n", [[range dump] UTF8String]);
+    return YES;
+}
+
+- (BOOL)webView:(WebView *)webView shouldChangeSelectedDOMRange:(DOMRange *)currentRange toDOMRange:(DOMRange *)proposedRange affinity:(NSSelectionAffinity)selectionAffinity stillSelecting:(BOOL)flag
+{
+    static const char *affinitystring[] = {
+        "NSSelectionAffinityUpstream",
+        "NSSelectionAffinityDownstream"
+    };
+    static const char *boolstring[] = {
+        "FALSE",
+        "TRUE"
+    };
+
+    printf("EDITING DELEGATE: shouldChangeSelectedDOMRange:%s toDOMRange:%s affinity:%s stillSelecting:%s\n", [[currentRange dump] UTF8String], [[proposedRange dump] UTF8String], affinitystring[selectionAffinity], boolstring[flag]);
+    return YES;
+}
+
+- (BOOL)webView:(WebView *)webView shouldApplyStyle:(DOMCSSStyleDeclaration *)style toElementsInDOMRange:(DOMRange *)range
+{
+    printf("EDITING DELEGATE: shouldApplyStyle:%s toElementsInDOMRange:%s\n", [[style description] UTF8String], [[range dump] UTF8String]);
+    return YES;
+}
+
+- (BOOL)webView:(WebView *)webView shouldChangeTypingStyle:(DOMCSSStyleDeclaration *)currentStyle toStyle:(DOMCSSStyleDeclaration *)proposedStyle
+{
+    printf("EDITING DELEGATE: shouldChangeTypingStyle:%s toStyle:%s\n", [[currentStyle description] UTF8String], [[proposedStyle description] UTF8String]);
+    return YES;
+}
+
+- (void)webViewDidBeginEditing:(NSNotification *)notification
+{
+    printf("EDITING DELEGATE: webViewDidBeginEditing:%s\n", [[notification name] UTF8String]);
+}
+
+- (void)webViewDidChange:(NSNotification *)notification
+{
+    printf("EDITING DELEGATE: webViewDidChange:%s\n", [[notification name] UTF8String]);
+}
+
+- (void)webViewDidEndEditing:(NSNotification *)notification
+{
+    printf("EDITING DELEGATE: webViewDidEndEditing:%s\n", [[notification name] UTF8String]);
+}
+
+- (void)webViewDidChangeTypingStyle:(NSNotification *)notification
+{
+    printf("EDITING DELEGATE: webViewDidChangeTypingStyle:%s\n", [[notification name] UTF8String]);
+}
+
+- (void)webViewDidChangeSelection:(NSNotification *)notification
+{
+    if (!doneLoading())
+        printf("EDITING DELEGATE: webViewDidChangeSelection:%s\n", [[notification name] UTF8String]);
+}
+
+@end
diff --git a/WebKitTools/DumpRenderTree/EventSendingController.h b/WebKitTools/DumpRenderTree/EventSendingController.h
new file mode 100644 (file)
index 0000000..d954eb0
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2005, 2006 Apple Computer, 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. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE 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 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 <Cocoa/Cocoa.h>
+
+@interface EventSendingController : NSObject {
+    BOOL down;
+    int clickCount;
+    NSTimeInterval lastClick;
+    int eventNumber;
+    double timeOffset;
+}
+
+@end
+
+extern NSPoint lastMousePosition;
+
diff --git a/WebKitTools/DumpRenderTree/EventSendingController.m b/WebKitTools/DumpRenderTree/EventSendingController.m
new file mode 100644 (file)
index 0000000..f767062
--- /dev/null
@@ -0,0 +1,194 @@
+/*
+ * Copyright (C) 2005, 2006 Apple Computer, 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. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE 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 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 "EventSendingController.h"
+#import "DumpRenderTree.h"
+
+#import <Carbon/Carbon.h>                           // for GetCurrentEventTime()
+#import <WebKit/WebKit.h>
+
+NSPoint lastMousePosition;
+
+@implementation EventSendingController
+
++ (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector
+{
+    if (aSelector == @selector(mouseDown)
+            || aSelector == @selector(mouseUp)
+            || aSelector == @selector(mouseClick)
+            || aSelector == @selector(mouseMoveToX:Y:)
+            || aSelector == @selector(leapForward:))
+        return NO;
+    return YES;
+}
+
++ (NSString *)webScriptNameForSelector:(SEL)aSelector
+{
+    if (aSelector == @selector(mouseMoveToX:Y:))
+        return @"mouseMoveTo";
+    if (aSelector == @selector(leapForward:))
+        return @"leapForward";
+    return nil;
+}
+
+- (id)init
+{
+    lastMousePosition = NSMakePoint(0, 0);
+    down = NO;
+    clickCount = 0;
+    lastClick = 0;
+    return self;
+}
+
+- (double)currentEventTime
+{
+    return GetCurrentEventTime() + timeOffset;
+}
+
+- (void)leapForward:(int)milliseconds
+{
+    timeOffset += milliseconds / 1000.0;
+}
+
+- (void)mouseDown
+{
+    [[[frame frameView] documentView] layout];
+    if ([self currentEventTime] - lastClick >= 1)
+        clickCount = 1;
+    else
+        clickCount++;
+    NSEvent *event = [NSEvent mouseEventWithType:NSLeftMouseDown 
+                                        location:lastMousePosition 
+                                   modifierFlags:nil 
+                                       timestamp:[self currentEventTime]
+                                    windowNumber:[[[frame webView] window] windowNumber] 
+                                         context:[NSGraphicsContext currentContext] 
+                                     eventNumber:++eventNumber 
+                                      clickCount:clickCount 
+                                        pressure:nil];
+
+    NSView *subView = [[frame webView] hitTest:[event locationInWindow]];
+    if (subView) {
+        [subView mouseDown:event];
+        down = YES;
+    }
+}
+
+- (void)mouseUp
+{
+    [[[frame frameView] documentView] layout];
+    NSEvent *event = [NSEvent mouseEventWithType:NSLeftMouseUp 
+                                        location:lastMousePosition 
+                                   modifierFlags:nil 
+                                       timestamp:[self currentEventTime]
+                                    windowNumber:[[[frame webView] window] windowNumber] 
+                                         context:[NSGraphicsContext currentContext] 
+                                     eventNumber:++eventNumber 
+                                      clickCount:clickCount 
+                                        pressure:nil];
+
+    NSView *subView = [[frame webView] hitTest:[event locationInWindow]];
+    if (subView) {
+        [subView mouseUp:event];
+        down = NO;
+        lastClick = [event timestamp];
+        if (draggingInfo) {
+            WebView *webView = [frame webView];
+            
+            NSDragOperation dragOperation = [webView draggingUpdated:draggingInfo];
+            
+            [[draggingInfo draggingSource] draggedImage:[draggingInfo draggedImage] endedAt:lastMousePosition operation:dragOperation];
+            if (dragOperation != NSDragOperationNone)
+                [webView performDragOperation:draggingInfo];
+            [draggingInfo release];
+            draggingInfo = nil;
+        }
+    }
+}
+
+- (void)mouseMoveToX:(int)x Y:(int)y
+{
+    lastMousePosition = NSMakePoint(x, [[frame webView] frame].size.height - y);
+    NSEvent *event = [NSEvent mouseEventWithType:(down ? NSLeftMouseDragged : NSMouseMoved) 
+                                        location:lastMousePosition 
+                                   modifierFlags:nil 
+                                       timestamp:[self currentEventTime]
+                                    windowNumber:[[[frame webView] window] windowNumber] 
+                                         context:[NSGraphicsContext currentContext] 
+                                     eventNumber:++eventNumber 
+                                      clickCount:(down ? clickCount : 0) 
+                                        pressure:nil];
+
+    NSView *subView = [[frame webView] hitTest:[event locationInWindow]];
+    if (subView) {
+        if (down) {
+            [subView mouseDragged:event];
+            [[draggingInfo draggingSource] draggedImage:[draggingInfo draggedImage] movedTo:lastMousePosition];
+            [[frame webView] draggingUpdated:draggingInfo];
+        }
+        else
+            [subView mouseMoved:event];
+    }
+}
+
+- (void)mouseClick
+{
+    [[[frame frameView] documentView] layout];
+    if ([self currentEventTime] - lastClick >= 1)
+        clickCount = 1;
+    else
+        clickCount++;
+    NSEvent *mouseDownEvent = [NSEvent mouseEventWithType:NSLeftMouseDown 
+                                        location:lastMousePosition 
+                                   modifierFlags:nil 
+                                       timestamp:[self currentEventTime]
+                                    windowNumber:[[[frame webView] window] windowNumber] 
+                                         context:[NSGraphicsContext currentContext] 
+                                     eventNumber:++eventNumber 
+                                      clickCount:clickCount 
+                                        pressure:nil];
+
+    NSView *subView = [[frame webView] hitTest:[mouseDownEvent locationInWindow]];
+    if (subView) {
+        [self leapForward:1];
+        NSEvent *mouseUpEvent = [NSEvent mouseEventWithType:NSLeftMouseUp
+                                                   location:lastMousePosition
+                                              modifierFlags:nil
+                                                  timestamp:[self currentEventTime]
+                                               windowNumber:[[[frame webView] window] windowNumber]
+                                                    context:[NSGraphicsContext currentContext]
+                                                eventNumber:++eventNumber
+                                                 clickCount:clickCount
+                                                   pressure:nil];
+        [NSApp postEvent:mouseUpEvent atStart:NO];
+        [subView mouseDown:mouseDownEvent];
+        lastClick = [mouseUpEvent timestamp];
+    }
+}
+
+@end