Changeset 25312 in webkit
- Timestamp:
- Aug 29, 2007 5:45:52 PM (17 years ago)
- Location:
- trunk/WebKit
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit/ChangeLog
r25307 r25312 1 2007-08-29 Darin Adler <darin@apple.com> 2 3 Reviewed by Tim Hatcher. 4 5 - fix <rdar://problem/4582212> WebKit inappropriately adds +initialize to 6 NSPasteboard via a category, prevents AppKit initialize 7 http://bugs.webkit.org/show_bug.cgi?id=9417 8 9 * Misc/WebNSPasteboardExtras.h: Got rid of the global data objects and replaced 10 them with global functions. 11 12 * Misc/WebNSPasteboardExtras.mm: 13 (initializePasteboardTypes): Changed the initialize method to be this function. 14 (WebURLPasteboardType): Added, calls the initialize function and then returns 15 the value of the global. 16 (WebURLNamePasteboardType): Ditto. 17 (+[NSPasteboard _web_writableTypesForURL]): Changed to call the new function instead 18 of getting at the global directly. 19 (+[NSPasteboard _web_dragTypesForURL]): Ditto. 20 (-[NSPasteboard _web_writeURL:andTitle:types:]): Ditto. 21 * WebCoreSupport/WebPasteboardHelper.mm: 22 (WebPasteboardHelper::urlFromPasteboard): Ditto. 23 * WebView/WebHTMLView.mm: 24 (-[WebHTMLView _documentFragmentFromPasteboard:forType:inContext:subresources:]): Ditto. 25 26 * WebView/WebView.mm: 27 (+[WebView initialize]): Added a call to one of the functions to take advantage 28 of the side effect that initializes the globals; this is to help out old versions 29 of Safari. 30 (+[WebView URLTitleFromPasteboard:]): Changed to call the new function instead 31 of getting at the global directly. 32 33 * WebKit.exp: Add exports of the new functions. 34 1 35 2007-08-29 Adele Peterson <adele@apple.com> 2 36 -
trunk/WebKit/Misc/WebNSPasteboardExtras.h
r21533 r25312 1 1 /* 2 * Copyright (C) 2005, 2006 Apple Computer, Inc.All rights reserved.2 * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 33 33 @class WebHTMLView; 34 34 35 extern NSString *WebURLPboardType; 36 extern NSString *WebURLNamePboardType; 35 #ifdef __cplusplus 36 extern "C" { 37 #endif 38 39 NSString *WebURLPasteboardType(void); 40 NSString *WebURLNamePasteboardType(void); 37 41 38 42 @interface NSPasteboard (WebExtras) … … 80 84 81 85 @end 86 87 #ifdef __cplusplus 88 } 89 #endif -
trunk/WebKit/Misc/WebNSPasteboardExtras.mm
r24417 r25312 46 46 #import <WebKitSystemInterface.h> 47 47 48 using namespace WebCore; 49 50 NSString *WebURLPboardType = nil;51 NSString *WebURLNamePboardType = nil;48 // These are needed for compatibility with old versions of Safari. Once we don't need 49 // to support Safari 2 or the first Safari 3 public beta, we can remove them. 50 extern "C" NSString *WebURLPboardType; 51 extern "C" NSString *WebURLNamePboardType; 52 52 53 53 @interface NSFilePromiseDragSource : NSObject … … 56 56 @end 57 57 58 @implementation NSPasteboard (WebExtras) 59 60 + (void)initialize 61 { 62 // FIXME The code below addresses 3446192. It was awaiting a fix for 3446669. Now that bug has been fixed, 63 // but this code still does not work; UTTypeCopyPreferredTagWithClass returns nil, which caused 4145214. Some 64 // day we'll need to investigate why this code is still not working. 58 using namespace WebCore; 59 60 NSString *WebURLPboardType = nil; 61 NSString *WebURLNamePboardType = nil; 62 63 static void initializePasteboardTypes() 64 { 65 if (WebURLPboardType) 66 return; 67 68 // FIXME: We'd like to use UTI_PB_API code, but we can't yet. The reasons are in Radar bug 3446192. 65 69 #ifdef UTI_PB_API 66 70 CFStringRef osTypeString = UTCreateStringForOSType('url '); 67 CFStringRef utiTypeString = UTTypeCreatePreferredIdentifierForTag( kUTTagClassOSType, osTypeString, NULL);68 WebURLPboardType = (NSString *)UTTypeCopyPreferredTagWithClass( kUTTagClassNSPboardType, utiTypeString);69 if (osTypeString != NULL) {71 CFStringRef utiTypeString = UTTypeCreatePreferredIdentifierForTag(kUTTagClassOSType, osTypeString, NULL); 72 WebURLPboardType = (NSString *)UTTypeCopyPreferredTagWithClass(kUTTagClassNSPboardType, utiTypeString); 73 if (osTypeString != NULL) 70 74 CFRelease(osTypeString); 71 } 72 if (utiTypeString != NULL) { 75 if (utiTypeString != NULL) 73 76 CFRelease(utiTypeString); 74 }75 77 76 78 osTypeString = UTCreateStringForOSType('urln'); 77 utiTypeString = UTTypeCreatePreferredIdentifierForTag( kUTTagClassOSType, osTypeString, NULL);78 WebURLNamePboardType = (NSString *)UTTypeCopyPreferredTagWithClass( kUTTagClassNSPboardType, utiTypeString);79 if (osTypeString != NULL) {79 utiTypeString = UTTypeCreatePreferredIdentifierForTag(kUTTagClassOSType, osTypeString, NULL); 80 WebURLNamePboardType = (NSString *)UTTypeCopyPreferredTagWithClass(kUTTagClassNSPboardType, utiTypeString); 81 if (osTypeString != NULL) 80 82 CFRelease(osTypeString); 81 } 82 if (utiTypeString != NULL) { 83 if (utiTypeString != NULL) 83 84 CFRelease(utiTypeString); 84 }85 85 #else 86 86 WebURLPboardType = WKCreateURLPasteboardFlavorTypeName(); … … 88 88 #endif 89 89 } 90 91 NSString *WebURLPasteboardType() 92 { 93 initializePasteboardTypes(); 94 return WebURLPboardType; 95 } 96 97 NSString *WebURLNamePasteboardType() 98 { 99 initializePasteboardTypes(); 100 return WebURLNamePboardType; 101 } 102 103 #define WebURLPboardType DO_NOT_USE_WebURLPboardType_IN_THIS_FILE 104 #define WebURLNamePboardType DO_NOT_USE_WebURLNamePboardType_IN_THIS_FILE 105 106 @implementation NSPasteboard (WebExtras) 90 107 91 108 + (NSArray *)_web_writableTypesForURL … … 96 113 WebURLsWithTitlesPboardType, 97 114 NSURLPboardType, 98 WebURLP boardType,99 WebURLNameP boardType,115 WebURLPasteboardType(), 116 WebURLNamePasteboardType(), 100 117 NSStringPboardType, 101 118 nil]; … … 137 154 WebURLsWithTitlesPboardType, 138 155 NSURLPboardType, 139 WebURLP boardType,140 WebURLNameP boardType,156 WebURLPasteboardType(), 157 WebURLNamePasteboardType(), 141 158 NSStringPboardType, 142 159 NSFilenamesPboardType, … … 183 200 { 184 201 ASSERT(URL); 185 202 186 203 if ([title length] == 0) { 187 204 title = [[URL path] lastPathComponent]; 188 if ([title length] == 0) {205 if ([title length] == 0) 189 206 title = [URL _web_userVisibleString]; 190 } 191 } 192 193 if ([types containsObject:NSURLPboardType]) { 207 } 208 209 if ([types containsObject:NSURLPboardType]) 194 210 [URL writeToPasteboard:self]; 195 } 196 if ([types containsObject:WebURLPboardType]) { 197 [self setString:[URL _web_originalDataAsString] forType:WebURLPboardType]; 198 } 199 if ([types containsObject:WebURLNamePboardType]) { 200 [self setString:title forType:WebURLNamePboardType]; 201 } 202 if ([types containsObject:NSStringPboardType]) { 211 if ([types containsObject:WebURLPasteboardType()]) 212 [self setString:[URL _web_originalDataAsString] forType:WebURLPasteboardType()]; 213 if ([types containsObject:WebURLNamePasteboardType()]) 214 [self setString:title forType:WebURLNamePasteboardType()]; 215 if ([types containsObject:NSStringPboardType]) 203 216 [self setString:[URL _web_userVisibleString] forType:NSStringPboardType]; 204 } 205 if ([types containsObject:WebURLsWithTitlesPboardType]) { 217 if ([types containsObject:WebURLsWithTitlesPboardType]) 206 218 [WebURLsWithTitles writeURLs:[NSArray arrayWithObject:URL] andTitles:[NSArray arrayWithObject:title] toPasteboard:self]; 207 }208 219 } 209 220 -
trunk/WebKit/WebCoreSupport/WebPasteboardHelper.mm
r20863 r25312 1 1 /* 2 * Copyright (C) 2007 Apple Inc. 2 * Copyright (C) 2007 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 40 40 { 41 41 NSURL *URL = [pasteboard _web_bestURL]; 42 if (title) 43 if (NSString *URLTitleString = [pasteboard stringForType:WebURLNameP boardType])42 if (title) { 43 if (NSString *URLTitleString = [pasteboard stringForType:WebURLNamePasteboardType()]) 44 44 *title = URLTitleString; 45 } 45 46 46 47 return [URL _web_originalDataAsString]; -
trunk/WebKit/WebKit.exp
r23682 r25312 94 94 _WebScriptErrorDomain 95 95 _WebScriptErrorLineNumberKey 96 _WebURLNamePasteboardType 96 97 _WebURLNamePboardType 98 _WebURLPasteboardType 97 99 _WebURLPboardType 98 100 _WebViewDidBeginEditingNotification -
trunk/WebKit/WebView/WebHTMLView.mm
r25304 r25312 1926 1926 if ([URLString length] == 0) 1927 1927 return nil; 1928 NSString *URLTitleString = [pasteboard stringForType:WebURLNameP boardType];1928 NSString *URLTitleString = [pasteboard stringForType:WebURLNamePasteboardType()]; 1929 1929 DOMText *text = [document createTextNode:URLTitleString]; 1930 1930 [anchor setHref:URLString]; -
trunk/WebKit/WebView/WebView.mm
r25307 r25312 1651 1651 + (void)initialize 1652 1652 { 1653 static BOOL tooLate = NO; 1654 if (!tooLate) { 1653 static BOOL initialized = NO; 1654 if (initialized) 1655 return; 1656 initialized = YES; 1657 1655 1658 #ifdef REMOVE_SAFARI_DOM_TREE_DEBUG_ITEM 1656 // this prevents open source users from crashing when using the Show DOM Tree menu item in Safari 21657 // FIXME: remove this when we no longer need to support Safari 21658 1659 1659 // This prevents open source users from crashing when using the Show DOM Tree menu item in Safari 2. 1660 // FIXME: remove this when we no longer need to support Safari 2. 1661 if ([[[NSBundle mainBundle] bundleIdentifier] isEqualToString:@"com.apple.Safari"] && [[NSUserDefaults standardUserDefaults] boolForKey:@"IncludeDebugMenu"]) 1662 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_finishedLaunching) name:NSApplicationDidFinishLaunchingNotification object:NSApp]; 1660 1663 #endif 1661 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_applicationWillTerminate) name:NSApplicationWillTerminateNotification object:NSApp]; 1662 tooLate = YES; 1663 } 1664 1665 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_applicationWillTerminate) name:NSApplicationWillTerminateNotification object:NSApp]; 1666 1667 // Older versions of Safari use the pasteboard types without initializing them. 1668 // But they create a WebView beforehand, so if we initialize here that should be fine. 1669 WebURLPasteboardType(); 1664 1670 } 1665 1671 … … 1775 1781 + (NSString *)URLTitleFromPasteboard:(NSPasteboard *)pasteboard 1776 1782 { 1777 return [pasteboard stringForType:WebURLNameP boardType];1783 return [pasteboard stringForType:WebURLNamePasteboardType()]; 1778 1784 } 1779 1785
Note: See TracChangeset
for help on using the changeset viewer.