Title: [154652] trunk/Tools
Revision
154652
Author
[email protected]
Date
2013-08-26 16:38:49 -0700 (Mon, 26 Aug 2013)

Log Message

        WebKitTestRunner needs to protect the user's pasteboard contents while running
        https://bugs.webkit.org/show_bug.cgi?id=81419
        <rdar://problem/11066794>

        Reviewed by Darin Adler.

        Mostly a copy/paste of DRT code.

        Tested manually by making sure that editing/pasteboard/copy-image-with-alt-text.html
        doesn't interfere with my clipboard while being run in a loop.

        * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:
        * WebKitTestRunner/mac/PoseAsClass.h: Added.
        * WebKitTestRunner/mac/PoseAsClass.mm: Added.
        * WebKitTestRunner/mac/TestControllerMac.mm:
        (WTR::TestController::platformInitialize):
        (WTR::TestController::platformDestroy):
        * WebKitTestRunner/mac/WebKitTestRunnerPasteboard.h: Added.
        * WebKitTestRunner/mac/WebKitTestRunnerPasteboard.mm: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/Tools/ChangeLog (154651 => 154652)


--- trunk/Tools/ChangeLog	2013-08-26 23:37:16 UTC (rev 154651)
+++ trunk/Tools/ChangeLog	2013-08-26 23:38:49 UTC (rev 154652)
@@ -1,3 +1,25 @@
+2013-08-26  Alexey Proskuryakov  <[email protected]>
+
+        WebKitTestRunner needs to protect the user's pasteboard contents while running
+        https://bugs.webkit.org/show_bug.cgi?id=81419
+        <rdar://problem/11066794>
+
+        Reviewed by Darin Adler.
+
+        Mostly a copy/paste of DRT code.
+
+        Tested manually by making sure that editing/pasteboard/copy-image-with-alt-text.html
+        doesn't interfere with my clipboard while being run in a loop.
+
+        * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:
+        * WebKitTestRunner/mac/PoseAsClass.h: Added.
+        * WebKitTestRunner/mac/PoseAsClass.mm: Added.
+        * WebKitTestRunner/mac/TestControllerMac.mm:
+        (WTR::TestController::platformInitialize):
+        (WTR::TestController::platformDestroy):
+        * WebKitTestRunner/mac/WebKitTestRunnerPasteboard.h: Added.
+        * WebKitTestRunner/mac/WebKitTestRunnerPasteboard.mm: Added.
+
 2013-08-26  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r154640.

Modified: trunk/Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj (154651 => 154652)


--- trunk/Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj	2013-08-26 23:37:16 UTC (rev 154651)
+++ trunk/Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj	2013-08-26 23:38:49 UTC (rev 154652)
@@ -86,6 +86,8 @@
 		BCDA2B9A1191051F00C3BC47 /* _javascript_Core.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BCDA2B991191051F00C3BC47 /* _javascript_Core.framework */; };
 		C0CE720B1247C93300BC0EC4 /* TestRunnerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = C0CE720A1247C93300BC0EC4 /* TestRunnerMac.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 */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXContainerItemProxy section */
@@ -220,6 +222,10 @@
 		BCDA2B991191051F00C3BC47 /* _javascript_Core.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = _javascript_Core.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>"; };
 		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>"; };
+		E1C642C417CBCD4C00D66A3C /* WebKitTestRunnerPasteboard.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebKitTestRunnerPasteboard.mm; sourceTree = "<group>"; };
+		E1C642C517CBCD4C00D66A3C /* WebKitTestRunnerPasteboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKitTestRunnerPasteboard.h; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -416,7 +422,11 @@
 				5670B8271386FCA5002EB355 /* EventSenderProxy.mm */,
 				BC7933FF118F7C84005EA8E2 /* main.mm */,
 				BC7934E711906846005EA8E2 /* PlatformWebViewMac.mm */,
+				E1C642C117CBCC7300D66A3C /* PoseAsClass.mm */,
+				E1C642C217CBCC7300D66A3C /* PoseAsClass.h */,
 				BC8C795B11D2785D004535A1 /* TestControllerMac.mm */,
+				E1C642C417CBCD4C00D66A3C /* WebKitTestRunnerPasteboard.mm */,
+				E1C642C517CBCD4C00D66A3C /* WebKitTestRunnerPasteboard.h */,
 			);
 			path = mac;
 			sourceTree = "<group>";
@@ -602,10 +612,12 @@
 			buildActionMask = 2147483647;
 			files = (
 				5322FB4313FDA0CD0041ABCC /* CyclicRedundancyCheck.cpp in Sources */,
+				E1C642C317CBCC7300D66A3C /* PoseAsClass.mm in Sources */,
 				5670B8281386FCA5002EB355 /* EventSenderProxy.mm in Sources */,
 				26D758E7160BECDD00268472 /* GeolocationProviderMock.cpp in Sources */,
 				BC793400118F7C84005EA8E2 /* main.mm in Sources */,
 				5322FB4613FDA0EA0041ABCC /* PixelDumpSupport.cpp in Sources */,
+				E1C642C617CBCD4C00D66A3C /* WebKitTestRunnerPasteboard.mm in Sources */,
 				BC7934E811906846005EA8E2 /* PlatformWebViewMac.mm in Sources */,
 				BC793431118F7F19005EA8E2 /* TestController.cpp in Sources */,
 				BC8C795C11D2785D004535A1 /* TestControllerMac.mm in Sources */,

Added: trunk/Tools/WebKitTestRunner/mac/PoseAsClass.h (0 => 154652)


--- trunk/Tools/WebKitTestRunner/mac/PoseAsClass.h	                        (rev 0)
+++ trunk/Tools/WebKitTestRunner/mac/PoseAsClass.h	2013-08-26 23:38:49 UTC (rev 154652)
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+
+#ifndef PoseAsClass_h
+#define PoseAsClass_h
+
+void poseAsClass(const char* imposter, const char* original);
+
+#endif // PoseAsClass_h
Property changes on: trunk/Tools/WebKitTestRunner/mac/PoseAsClass.h
___________________________________________________________________

Added: svn:eol-style

Added: trunk/Tools/WebKitTestRunner/mac/PoseAsClass.mm (0 => 154652)


--- trunk/Tools/WebKitTestRunner/mac/PoseAsClass.mm	                        (rev 0)
+++ trunk/Tools/WebKitTestRunner/mac/PoseAsClass.mm	2013-08-26 23:38:49 UTC (rev 154652)
@@ -0,0 +1,73 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "PoseAsClass.h"
+
+#import <objc/runtime.h>
+#import <wtf/Assertions.h>
+
+static void swizzleAllMethods(Class imposter, Class original)
+{
+    unsigned int imposterMethodCount;
+    Method* imposterMethods = class_copyMethodList(imposter, &imposterMethodCount);
+
+    unsigned int originalMethodCount;
+    Method* originalMethods = class_copyMethodList(original, &originalMethodCount);
+
+    for (unsigned int i = 0; i < imposterMethodCount; i++) {
+        SEL imposterMethodName = method_getName(imposterMethods[i]);
+
+        // Attempt to add the method to the original class.  If it fails, the method already exists and we should
+        // instead exchange the implementations.
+        if (class_addMethod(original, imposterMethodName, method_getImplementation(imposterMethods[i]), method_getTypeEncoding(imposterMethods[i])))
+            continue;
+
+        unsigned int j = 0;
+        for (; j < originalMethodCount; j++) {
+            SEL originalMethodName = method_getName(originalMethods[j]);
+            if (sel_isEqual(imposterMethodName, originalMethodName))
+                break;
+        }
+
+        // If class_addMethod failed above then the method must exist on the original class.
+        ASSERT(j < originalMethodCount);
+        method_exchangeImplementations(imposterMethods[i], originalMethods[j]);
+    }
+
+    free(imposterMethods);
+    free(originalMethods);
+}
+
+void poseAsClass(const char* imposter, const char* original)
+{
+    Class imposterClass = objc_getClass(imposter);
+    Class originalClass = objc_getClass(original);
+
+    // Swizzle instance methods
+    swizzleAllMethods(imposterClass, originalClass);
+    // and then class methods
+    swizzleAllMethods(object_getClass(imposterClass), object_getClass(originalClass));
+}
Property changes on: trunk/Tools/WebKitTestRunner/mac/PoseAsClass.mm
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/Tools/WebKitTestRunner/mac/TestControllerMac.mm (154651 => 154652)


--- trunk/Tools/WebKitTestRunner/mac/TestControllerMac.mm	2013-08-26 23:37:16 UTC (rev 154651)
+++ trunk/Tools/WebKitTestRunner/mac/TestControllerMac.mm	2013-08-26 23:38:49 UTC (rev 154652)
@@ -27,6 +27,8 @@
 #import "TestController.h"
 
 #import "PlatformWebView.h"
+#import "PoseAsClass.h"
+#import "WebKitTestRunnerPasteboard.h"
 #import <WebKit2/WKStringCF.h>
 #import <mach-o/dyld.h> 
 
@@ -38,10 +40,12 @@
 
 void TestController::platformInitialize()
 {
+    poseAsClass("WebKitTestRunnerPasteboard", "NSPasteboard");
 }
 
 void TestController::platformDestroy()
 {
+    [WebKitTestRunnerPasteboard releaseLocalPasteboards];
 }
 
 void TestController::initializeInjectedBundlePath()

Added: trunk/Tools/WebKitTestRunner/mac/WebKitTestRunnerPasteboard.h (0 => 154652)


--- trunk/Tools/WebKitTestRunner/mac/WebKitTestRunnerPasteboard.h	                        (rev 0)
+++ trunk/Tools/WebKitTestRunner/mac/WebKitTestRunnerPasteboard.h	2013-08-26 23:38:49 UTC (rev 154652)
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2005, 2006, 2007, 2013 Apple, Inc.  All rights reserved.
+ * Copyright (C) 2007 Graham Dennis ([email protected])
+ * Copyright (C) 2007 Eric Seidel <[email protected]>
+ *
+ * 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.
+ */
+
+#ifndef WebKitTestRunnerPasteboard_h
+#define WebKitTestRunnerPasteboard_h
+
+#import <AppKit/AppKit.h>
+
+@interface WebKitTestRunnerPasteboard : NSPasteboard
++ (void)releaseLocalPasteboards;
+@end
+
+#endif // WebKitTestRunnerPasteboard_h
Property changes on: trunk/Tools/WebKitTestRunner/mac/WebKitTestRunnerPasteboard.h
___________________________________________________________________

Added: svn:eol-style

Added: trunk/Tools/WebKitTestRunner/mac/WebKitTestRunnerPasteboard.mm (0 => 154652)


--- trunk/Tools/WebKitTestRunner/mac/WebKitTestRunnerPasteboard.mm	                        (rev 0)
+++ trunk/Tools/WebKitTestRunner/mac/WebKitTestRunnerPasteboard.mm	2013-08-26 23:38:49 UTC (rev 154652)
@@ -0,0 +1,214 @@
+/*
+ * Copyright (C) 2005, 2006, 2007, 2013 Apple, Inc.  All rights reserved.
+ * Copyright (C) 2007 Graham Dennis ([email protected])
+ * Copyright (C) 2007 Eric Seidel <[email protected]>
+ *
+ * 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.
+ */
+
+#include "config.h"
+#include "WebKitTestRunnerPasteboard.h"
+
+@interface LocalPasteboard : NSPasteboard
+{
+    NSMutableArray *typesArray;
+    NSMutableSet *typesSet;
+    NSMutableDictionary *dataByType;
+    NSInteger changeCount;
+    NSString *pasteboardName;
+}
+
+-(id)initWithName:(NSString *)name;
+@end
+
+static NSMutableDictionary *localPasteboards;
+
+@implementation WebKitTestRunnerPasteboard
+
+// Return a local pasteboard so we don't disturb the real pasteboards when running tests.
++ (NSPasteboard *)_pasteboardWithName:(NSString *)name
+{
+    static int number = 0;
+    if (!name)
+        name = [NSString stringWithFormat:@"LocalPasteboard%d", ++number];
+    if (!localPasteboards)
+        localPasteboards = [[NSMutableDictionary alloc] init];
+    LocalPasteboard *pasteboard = [localPasteboards objectForKey:name];
+    if (pasteboard)
+        return pasteboard;
+    pasteboard = [[LocalPasteboard alloc] initWithName:name];
+    [localPasteboards setObject:pasteboard forKey:name];
+    [pasteboard release];
+    return pasteboard;
+}
+
+// This method crashes when called on LocalPasteboard.
+// This happens during dragging, so overriding it may become unnecessary once we use mock dragging, like DumpRenderTree does.
+- (void)_updateTypeCacheIfNeeded
+{
+}
+
++ (void)releaseLocalPasteboards
+{
+    [localPasteboards release];
+    localPasteboards = nil;
+}
+
+// Convenience method for JS so that it doesn't have to try and create a NSArray on the objc side instead
+// of the usual WebScriptObject that is passed around
+- (NSInteger)declareType:(NSString *)type owner:(id)newOwner
+{
+    return [self declareTypes:[NSArray arrayWithObject:type] owner:newOwner];
+}
+
+@end
+
+@implementation LocalPasteboard
+
++ (id)alloc
+{
+    return NSAllocateObject(self, 0, 0);
+}
+
+- (id)initWithName:(NSString *)name
+{
+    self = [super init];
+    if (!self)
+        return nil;
+    typesArray = [[NSMutableArray alloc] init];
+    typesSet = [[NSMutableSet alloc] init];
+    dataByType = [[NSMutableDictionary alloc] init];
+    pasteboardName = [name copy];
+    return self;
+}
+
+- (void)dealloc
+{
+    [typesArray release];
+    [typesSet release];
+    [dataByType release];
+    [pasteboardName release];
+    [super dealloc];
+}
+
+- (NSString *)name
+{
+    return pasteboardName;
+}
+
+- (void)releaseGlobally
+{
+}
+
+- (NSInteger)declareTypes:(NSArray *)newTypes owner:(id)newOwner
+{
+    [typesArray removeAllObjects];
+    [typesSet removeAllObjects];
+    [dataByType removeAllObjects];
+    return [self addTypes:newTypes owner:newOwner];
+}
+
+- (NSInteger)addTypes:(NSArray *)newTypes owner:(id)newOwner
+{
+    unsigned count = [newTypes count];
+    unsigned i;
+    for (i = 0; i < count; ++i) {
+        NSString *type = [newTypes objectAtIndex:i];
+        NSString *setType = [typesSet member:type];
+        if (!setType) {
+            setType = [type copy];
+            [typesArray addObject:setType];
+            [typesSet addObject:setType];
+            [setType release];
+        }
+        if (newOwner && [newOwner respondsToSelector:@selector(pasteboard:provideDataForType:)])
+            [newOwner pasteboard:self provideDataForType:setType];
+    }
+    return ++changeCount;
+}
+
+- (NSInteger)changeCount
+{
+    return changeCount;
+}
+
+- (NSArray *)types
+{
+    return typesArray;
+}
+
+- (NSString *)availableTypeFromArray:(NSArray *)types
+{
+    unsigned count = [types count];
+    unsigned i;
+    for (i = 0; i < count; ++i) {
+        NSString *type = [types objectAtIndex:i];
+        NSString *setType = [typesSet member:type];
+        if (setType)
+            return setType;
+    }
+    return nil;
+}
+
+- (BOOL)setData:(NSData *)data forType:(NSString *)dataType
+{
+    if (data == nil)
+        data = "" data];
+    if (![typesSet containsObject:dataType])
+        return NO;
+    [dataByType setObject:data forKey:dataType];
+    ++changeCount;
+    return YES;
+}
+
+- (NSData *)dataForType:(NSString *)dataType
+{
+    return [dataByType objectForKey:dataType];
+}
+
+- (BOOL)setPropertyList:(id)propertyList forType:(NSString *)dataType
+{
+    CFDataRef data = ""
+    if (propertyList)
+        data = "" propertyList);
+    BOOL result = [self setData:(NSData *)data forType:dataType];
+    if (data)
+        CFRelease(data);
+    return result;
+}
+
+- (BOOL)setString:(NSString *)string forType:(NSString *)dataType
+{
+    CFDataRef data = ""
+    if (string) {
+        if ([string length] == 0)
+            data = "" 0, 0);
+        else
+            data = "" (CFStringRef)string, kCFStringEncodingUTF8, 0);
+    }
+    BOOL result = [self setData:(NSData *)data forType:dataType];
+    if (data)
+        CFRelease(data);
+    return result;
+}
+
+@end
Property changes on: trunk/Tools/WebKitTestRunner/mac/WebKitTestRunnerPasteboard.mm
___________________________________________________________________

Added: svn:eol-style

_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to