* DumpRenderTree/DumpRenderTree.m: Instead of allocating a single local
authordarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Oct 2006 16:49:59 +0000 (16:49 +0000)
committerdarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Oct 2006 16:49:59 +0000 (16:49 +0000)
        pasteboard, allocate any number of local pasteboards.
        (main): Allocate the dictionary of pasteboards.
        (+[DumpRenderTreePasteboard _pasteboardWithName:]): Allocate a pasteboard,
        given a name.
        (+[LocalPasteboard alloc]): Added, so we don't have to call NSAllocateObject
        explicitly elsewhere.
        (-[LocalPasteboard addTypes:owner:]): Added a check that the owner responds
        to the selector rather than calling unconditionally.

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

WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/DumpRenderTree.m

index 75c75facaf36279fde60eb21b5f0e76149973b36..98be77cb204f23c1e9dd6b52a594dd9c7ceaef3f 100644 (file)
@@ -1,3 +1,15 @@
+2006-10-31  Darin Adler  <darin@apple.com>
+
+        * DumpRenderTree/DumpRenderTree.m: Instead of allocating a single local
+        pasteboard, allocate any number of local pasteboards.
+        (main): Allocate the dictionary of pasteboards.
+        (+[DumpRenderTreePasteboard _pasteboardWithName:]): Allocate a pasteboard,
+        given a name.
+        (+[LocalPasteboard alloc]): Added, so we don't have to call NSAllocateObject
+        explicitly elsewhere.
+        (-[LocalPasteboard addTypes:owner:]): Added a check that the owner responds
+        to the selector rather than calling unconditionally.
+
 2006-10-30  Darin Adler  <darin@apple.com>
 
         - fixed build
index 6491d012daf8fc9fc965ac29b4098ed28483dc72..9c089082fdbfa7dc034299d9e0f0a648b1dbdc79 100644 (file)
@@ -124,7 +124,7 @@ static BOOL repaintSweepHorizontally = NO;
 static int dumpTree = YES;
 static BOOL printSeparators;
 static NSString *currentTest = nil;
-static NSPasteboard *localPasteboard;
+static NSMutableDictionary *localPasteboards;
 static WebHistoryItem *prevTestBFItem = nil;  // current b/f item at the end of the previous test
 static unsigned char* screenCaptureBuffer;
 static CGColorSpaceRef sharedColorSpace;
@@ -290,7 +290,8 @@ int main(int argc, const char *argv[])
         sharedColorSpace = CGColorSpaceCreateDeviceRGB();
     }
     
-    localPasteboard = [(LocalPasteboard *)NSAllocateObject([LocalPasteboard class], 0, 0) init];
+    localPasteboards = [[NSMutableDictionary alloc] init];
+
     navigationController = [[NavigationController alloc] init];
 
     NSRect rect = NSMakeRect(0, 0, maxViewWidth, maxViewHeight);
@@ -387,8 +388,8 @@ int main(int argc, const char *argv[])
     [editingDelegate release];
     [uiDelegate release];
     
-    [localPasteboard release];
-    localPasteboard = nil;
+    [localPasteboards release];
+    localPasteboards = nil;
     
     [navigationController release];
     navigationController = nil;
@@ -1022,16 +1023,30 @@ static NSString *md5HashStringForBitmap(CGImageRef bitmap)
 
 @implementation DumpRenderTreePasteboard
 
-// Return a local pasteboard so we don't disturb the real pasteboard when running tests.
-+ (NSPasteboard *)generalPasteboard
+// Return a local pasteboard so we don't disturb the real pasteboards when running tests.
++ (NSPasteboard *)_pasteboardWithName:(NSString *)name
 {
-    return localPasteboard;
+    static int number = 0;
+    if (!name)
+        name = [NSString stringWithFormat:@"LocalPasteboard%d", ++number];
+    LocalPasteboard *pasteboard = [localPasteboards objectForKey:name];
+    if (pasteboard)
+        return pasteboard;
+    pasteboard = [[LocalPasteboard alloc] init];
+    [localPasteboards setObject:pasteboard forKey:name];
+    [pasteboard release];
+    return pasteboard;
 }
 
 @end
 
 @implementation LocalPasteboard
 
++ (id)alloc
+{
+    return NSAllocateObject(self, 0, 0);
+}
+
 - (id)init
 {
     typesArray = [[NSMutableArray alloc] init];
@@ -1078,7 +1093,7 @@ static NSString *md5HashStringForBitmap(CGImageRef bitmap)
             [typesSet addObject:setType];
             [setType release];
         }
-        if (newOwner)
+        if (newOwner && [newOwner respondsToSelector:@selector(pasteboard:provideDataForType:)])
             [newOwner pasteboard:self provideDataForType:setType];
     }
     return ++changeCount;