+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
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;
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);
[editingDelegate release];
[uiDelegate release];
- [localPasteboard release];
- localPasteboard = nil;
+ [localPasteboards release];
+ localPasteboards = nil;
[navigationController release];
navigationController = nil;
@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];
[typesSet addObject:setType];
[setType release];
}
- if (newOwner)
+ if (newOwner && [newOwner respondsToSelector:@selector(pasteboard:provideDataForType:)])
[newOwner pasteboard:self provideDataForType:setType];
}
return ++changeCount;