Changeset 243758 in webkit
- Timestamp:
- Apr 2, 2019, 2:06:49 PM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
editing/cocoa/HTMLConverter.mm (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r243757 r243758 1 2019-04-02 Timothy Hatcher <timothy@apple.com> 2 3 NSAttributedString crashes when encoding text attachment cell for missing image. 4 https://bugs.webkit.org/show_bug.cgi?id=196504 5 rdar://problem/49161281 6 7 Reviewed by Tim Horton. 8 9 Clean up and fix a couple of errors and crashes in the missing image path of our 10 attributed string converter. 11 12 Fixes include: 13 * Removed manual call to release on a RetainPtr, leading to autorelease pool crash. 14 * No longer try to load an image that is missing on disk and has long been renamed. 15 * No longer use a NSTextAttachmentCell in the Mac code path which can't be encoded 16 for sending to the UIProcess, so it was pretty useless in the web content process. 17 * Stopped using NSFileWrapper for the missing image so the attachment can contain the 18 retina versions of the missing image. 19 * Simplified bundle finding code, since WebCore is assumed to be loaded. 20 * Fix leak of attachment by adding missing adoptNS(). 21 22 * editing/cocoa/HTMLConverter.mm: 23 (HTMLConverter::_addAttachmentForElement): Unify and simplify missing image path. 24 (_NSFirstPathForDirectoriesInDomains): Deleted. 25 (_NSSystemLibraryPath): Deleted. 26 (_webKitBundle): Deleted. 27 1 28 2019-04-02 Chris Dumez <cdumez@apple.com> 2 29 -
trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm
r242831 r243758 99 99 #define PlatformFont UIFont 100 100 #define PlatformFontClass PAL::getUIFontClass() 101 #define PlatformImageClass PAL::getUIImageClass() 101 102 102 103 #else … … 114 115 #define PlatformFont NSFont 115 116 #define PlatformFontClass NSFont 117 #define PlatformImageClass NSImage 116 118 117 119 #endif … … 773 775 } 774 776 775 #if PLATFORM(IOS_FAMILY)776 static NSString *_NSFirstPathForDirectoriesInDomains(NSSearchPathDirectory directory, NSSearchPathDomainMask domainMask, BOOL expandTilde)777 {778 NSArray *array = NSSearchPathForDirectoriesInDomains(directory, domainMask, expandTilde);779 return [array count] >= 1 ? [array objectAtIndex:0] : nil;780 }781 782 static NSString *_NSSystemLibraryPath(void)783 {784 return _NSFirstPathForDirectoriesInDomains(NSLibraryDirectory, NSSystemDomainMask, YES);785 }786 787 static NSBundle *_webKitBundle()788 {789 // FIXME: This should probably use the WebCore bundle to avoid the layering violation.790 NSBundle *bundle = [NSBundle bundleWithIdentifier:@"com.apple.WebKit"];791 if (!bundle)792 bundle = [NSBundle bundleWithPath:[_NSSystemLibraryPath() stringByAppendingPathComponent:@"Frameworks/WebKit.framework"]];793 return bundle;794 }795 #endif796 797 777 static inline NSShadow *_shadowForShadowStyle(NSString *shadowStyle) 798 778 { … … 1360 1340 #endif 1361 1341 } else { 1342 NSBundle *webCoreBundle = [NSBundle bundleWithIdentifier:@"com.apple.WebCore"]; 1362 1343 #if PLATFORM(IOS_FAMILY) 1363 [attachment release]; 1364 NSURL *missingImageURL = [_webKitBundle() URLForResource:@"missing_image" withExtension:@"tiff"]; 1365 ASSERT_WITH_MESSAGE(missingImageURL != nil, "Unable to find missing_image.tiff!"); 1366 NSFileWrapper *missingImageFileWrapper = [[[NSFileWrapper alloc] initWithURL:missingImageURL options:0 error:NULL] autorelease]; 1367 attachment = [[PlatformNSTextAttachment alloc] initWithFileWrapper:missingImageFileWrapper]; 1344 UIImage *missingImage = [PlatformImageClass imageNamed:@"missingImage" inBundle:webCoreBundle compatibleWithTraitCollection:nil]; 1368 1345 #else 1369 static NSImage *missingImage = nil; 1370 NSTextAttachmentCell *cell; 1371 cell = [[NSTextAttachmentCell alloc] initImageCell:missingImage]; 1372 [attachment setAttachmentCell:cell]; 1373 [cell release]; 1346 NSImage *missingImage = [webCoreBundle imageForResource:@"missingImage"]; 1374 1347 #endif 1348 ASSERT_WITH_MESSAGE(missingImage != nil, "Unable to find missingImage."); 1349 attachment = adoptNS([[PlatformNSTextAttachment alloc] initWithData:nil ofType:nil]); 1350 attachment.get().image = missingImage; 1375 1351 } 1376 1352 [_attrStr replaceCharactersInRange:rangeToReplace withString:string.get()];
Note:
See TracChangeset
for help on using the changeset viewer.