Reviewed by Tim Hatcher.
authordarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Sep 2007 22:39:12 +0000 (22:39 +0000)
committerdarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Sep 2007 22:39:12 +0000 (22:39 +0000)
        - <rdar://problem/5471082> Removing WebURLPboardType from headers broke SPI-using applications

        Rolled out my fix for bug 4582212 and fixed it in a much simpler way.

        * Misc/WebNSPasteboardExtras.h:
        * Misc/WebNSPasteboardExtras.mm:
        * WebCoreSupport/WebPasteboardHelper.mm:
        * WebKit.exp:
        * WebView/WebHTMLView.mm:
        * WebView/WebView.mm:
        Rolled out the new PasteboardType functions and changed the PboardType globals to be initialized
        with constant values.

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

WebKit/ChangeLog
WebKit/Misc/WebNSPasteboardExtras.h
WebKit/Misc/WebNSPasteboardExtras.mm
WebKit/WebCoreSupport/WebPasteboardHelper.mm
WebKit/WebKit.exp
WebKit/WebView/WebHTMLView.mm
WebKit/WebView/WebView.mm

index 8d4043f7b796a9dee5f9f40b37412aa611335494..6ae69517a138f317430f47455ebe408e3d406b4f 100644 (file)
@@ -1,3 +1,20 @@
+2007-09-10  Darin Adler  <darin@apple.com>
+
+        Reviewed by Tim Hatcher.
+
+        - <rdar://problem/5471082> Removing WebURLPboardType from headers broke SPI-using applications
+
+        Rolled out my fix for bug 4582212 and fixed it in a much simpler way.
+
+        * Misc/WebNSPasteboardExtras.h:
+        * Misc/WebNSPasteboardExtras.mm:
+        * WebCoreSupport/WebPasteboardHelper.mm:
+        * WebKit.exp:
+        * WebView/WebHTMLView.mm:
+        * WebView/WebView.mm:
+        Rolled out the new PasteboardType functions and changed the PboardType globals to be initialized
+        with constant values.
+
 2007-09-10  Timothy Hatcher  <timothy@apple.com>
 
         Reviewed by Darin.
index cd2c466f650589374cb75ba5c54a9d94bc8dad5d..b9945122998c771d6799085b1096c5eb28660096 100644 (file)
@@ -36,8 +36,8 @@
 extern "C" {
 #endif
 
-NSString *WebURLPasteboardType(void);
-NSString *WebURLNamePasteboardType(void);
+extern NSString *WebURLPboardType;
+extern NSString *WebURLNamePboardType;
 
 @interface NSPasteboard (WebExtras)
 
index 48bd23c36f0aa4496ad683ae36cf50c89ad4c1c2..0e98d20cc136287ec48ff6deb91af23256171741 100644 (file)
 #import <wtf/RetainPtr.h>
 #import <WebKitSystemInterface.h>
 
-// These are needed for compatibility with old versions of Safari. Once we don't need
-// to support Safari 2 or the first Safari 3 public beta, we can remove them.
-extern "C" NSString *WebURLPboardType;
-extern "C" NSString *WebURLNamePboardType;
-
 @interface NSFilePromiseDragSource : NSObject
 - initWithSource:(id)draggingSource;
 - (void)setTypes:(NSArray *)types onPasteboard:(NSPasteboard *)pboard;
@@ -57,51 +52,8 @@ extern "C" NSString *WebURLNamePboardType;
 
 using namespace WebCore;
 
-NSString *WebURLPboardType = nil;
-NSString *WebURLNamePboardType = nil;
-
-static void initializePasteboardTypes()
-{
-    if (WebURLPboardType)
-        return;
-
-    // FIXME: We'd like to use UTI_PB_API code, but we can't yet. The reasons are in Radar bug 3446192.
-#ifdef UTI_PB_API
-    CFStringRef osTypeString = UTCreateStringForOSType('url ');
-    CFStringRef utiTypeString = UTTypeCreatePreferredIdentifierForTag(kUTTagClassOSType, osTypeString, NULL);
-    WebURLPboardType = (NSString *)UTTypeCopyPreferredTagWithClass(kUTTagClassNSPboardType, utiTypeString);
-    if (osTypeString != NULL)
-        CFRelease(osTypeString);
-    if (utiTypeString != NULL)
-        CFRelease(utiTypeString);
-    
-    osTypeString = UTCreateStringForOSType('urln');
-    utiTypeString = UTTypeCreatePreferredIdentifierForTag(kUTTagClassOSType, osTypeString, NULL);
-    WebURLNamePboardType = (NSString *)UTTypeCopyPreferredTagWithClass(kUTTagClassNSPboardType, utiTypeString);
-    if (osTypeString != NULL)
-        CFRelease(osTypeString);
-    if (utiTypeString != NULL)
-        CFRelease(utiTypeString);
-#else
-    WebURLPboardType = WKCreateURLPasteboardFlavorTypeName();
-    WebURLNamePboardType = WKCreateURLNPasteboardFlavorTypeName();
-#endif
-}
-
-NSString *WebURLPasteboardType()
-{
-    initializePasteboardTypes();
-    return WebURLPboardType;
-}
-
-NSString *WebURLNamePasteboardType()
-{
-    initializePasteboardTypes();
-    return WebURLNamePboardType;
-}
-
-#define WebURLPboardType DO_NOT_USE_WebURLPboardType_IN_THIS_FILE
-#define WebURLNamePboardType DO_NOT_USE_WebURLNamePboardType_IN_THIS_FILE
+NSString *WebURLPboardType = @"CorePasteboardFlavorType 0x75726C20";
+NSString *WebURLNamePboardType = @"CorePasteboardFlavorType 0x75726C6E";
 
 @implementation NSPasteboard (WebExtras)
 
@@ -112,8 +64,8 @@ NSString *WebURLNamePasteboardType()
         types = [[NSArray alloc] initWithObjects:
             WebURLsWithTitlesPboardType,
             NSURLPboardType,
-            WebURLPasteboardType(),
-            WebURLNamePasteboardType(),
+            WebURLPboardType,
+            WebURLNamePboardType,
             NSStringPboardType,
             nil];
     }
@@ -153,8 +105,8 @@ static NSArray *_writableTypesForImageWithArchive (void)
     return [NSArray arrayWithObjects:
         WebURLsWithTitlesPboardType,
         NSURLPboardType,
-        WebURLPasteboardType(),
-        WebURLNamePasteboardType(),
+        WebURLPboardType,
+        WebURLNamePboardType,
         NSStringPboardType,
         NSFilenamesPboardType,
         nil];
@@ -208,10 +160,10 @@ static NSArray *_writableTypesForImageWithArchive (void)
     
     if ([types containsObject:NSURLPboardType])
         [URL writeToPasteboard:self];
-    if ([types containsObject:WebURLPasteboardType()])
-        [self setString:[URL _web_originalDataAsString] forType:WebURLPasteboardType()];
-    if ([types containsObject:WebURLNamePasteboardType()])
-        [self setString:title forType:WebURLNamePasteboardType()];
+    if ([types containsObject:WebURLPboardType])
+        [self setString:[URL _web_originalDataAsString] forType:WebURLPboardType];
+    if ([types containsObject:WebURLNamePboardType])
+        [self setString:title forType:WebURLNamePboardType];
     if ([types containsObject:NSStringPboardType])
         [self setString:[URL _web_userVisibleString] forType:NSStringPboardType];
     if ([types containsObject:WebURLsWithTitlesPboardType])
index bb18854317863eb664ec10c089d8e590fbec3cec..2da66543a05382cbed4f6a492825add6498304f2 100644 (file)
@@ -40,7 +40,7 @@ String WebPasteboardHelper::urlFromPasteboard(const NSPasteboard* pasteboard, St
 {
     NSURL *URL = [pasteboard _web_bestURL];
     if (title) {
-        if (NSString *URLTitleString = [pasteboard stringForType:WebURLNamePasteboardType()])
+        if (NSString *URLTitleString = [pasteboard stringForType:WebURLNamePboardType])
             *title = URLTitleString;
     }
 
index d790bd1ee75458d8f1166a64b5380e1c1d9857c1..b0676d055a15ac4abccad95eb24c5efda12a95a7 100644 (file)
@@ -93,9 +93,7 @@ _WebScriptDebugServerWillUnloadNotification
 _WebScriptErrorDescriptionKey
 _WebScriptErrorDomain
 _WebScriptErrorLineNumberKey
-_WebURLNamePasteboardType
 _WebURLNamePboardType
-_WebURLPasteboardType
 _WebURLPboardType
 _WebViewDidBeginEditingNotification
 _WebViewDidChangeNotification
index 535d85e20581d923986ff296bbd5feed6394cbcf..6e021f319c4316c87fb3b51a8a3ff67e25ae9bf3 100644 (file)
@@ -1925,7 +1925,7 @@ static void _updateMouseoverTimerCallback(CFRunLoopTimerRef timer, void *info)
         NSString *URLString = [URL _web_originalDataAsString];
         if ([URLString length] == 0)
             return nil;
-        NSString *URLTitleString = [pasteboard stringForType:WebURLNamePasteboardType()];
+        NSString *URLTitleString = [pasteboard stringForType:WebURLNamePboardType];
         DOMText *text = [document createTextNode:URLTitleString];
         [anchor setHref:URLString];
         [anchor appendChild:text];
index c98669ed360d75937fd6d7d06fef3232e1ca09d3..52878a07bd80baa923b039a9274129c4544c04b2 100644 (file)
@@ -1673,10 +1673,6 @@ WebFrameLoadDelegateImplementationCache WebViewGetFrameLoadDelegateImplementatio
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_applicationWillTerminate) name:NSApplicationWillTerminateNotification object:NSApp];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_preferencesChangedNotification:) name:WebPreferencesChangedNotification object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_preferencesRemovedNotification:) name:WebPreferencesRemovedNotification object:nil];
-
-    // Older versions of Safari use the pasteboard types without initializing them.
-    // But they create a WebView beforehand, so if we initialize here that should be fine.
-    WebURLPasteboardType();
 }
 
 + (void)_applicationWillTerminate
@@ -1790,7 +1786,7 @@ WebFrameLoadDelegateImplementationCache WebViewGetFrameLoadDelegateImplementatio
 
 + (NSString *)URLTitleFromPasteboard:(NSPasteboard *)pasteboard
 {
-    return [pasteboard stringForType:WebURLNamePasteboardType()];
+    return [pasteboard stringForType:WebURLNamePboardType];
 }
 
 + (void)registerURLSchemeAsLocal:(NSString *)protocol