Changeset 260478 in webkit
- Timestamp:
- Apr 21, 2020 5:51:48 PM (4 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r260476 r260478 1 2020-04-21 David Kilzer <ddkilzer@apple.com> 2 3 Clean up QuickLookThumbnailLoader 4 <https://webkit.org/b/210814> 5 6 Reviewed by Darin Adler. 7 8 The following items are cleaned up: 9 - Extract `using PlatformImage` into QuickLookThumbnailLoader.h, 10 rename to `CocoaImage` and use to get rid of duplicate 11 code. 12 - Change `id` to `instancetype` for -init methods. 13 - Add `atomic` keyword to @property definitions that were using 14 it as the default. (Use of atomic properties is rare in 15 WebKit, so being explicit avoids a scenario where it looks 16 like `nonatomic` was left off by accident.) 17 - Change @property definitions to `readonly` that are never 18 written to outside of QuickLookThumbnailLoader.mm. 19 - Delete unused @property definitions. 20 - Change method declarations into read-only @property 21 definitions. 22 - Re-declare atomic read-only @property definitions in 23 QuickLookThumbnailLoader.h as read-write definitions in 24 QuickLookThumbnailLoader.mm if they are written to. 25 26 * UIProcess/Cocoa/WebPageProxyCocoa.mm: 27 (WebKit::convertPlatformImageToBitmap): 28 * UIProcess/QuickLookThumbnailLoader.h: 29 - Rename qlThumbnailGenerationQueue @property to just `queue`. 30 - Remove `contentType` @property. It is not used anywhere. 31 This also fixes a theoretical leak found by the clang static 32 analyzer. 33 - Remove `shouldWrite` @property. It is only used within 34 QuickLookThumbnailLoader.mm. 35 - Change `identifier` and `thumbnail` to @property declarations. 36 * UIProcess/QuickLookThumbnailLoader.mm: 37 - Change WKQLThumbnailLoadOperation._identifier type from 38 NSMutableString to NSString. There was no reason for it to 39 be mutable. 40 (-[WKQLThumbnailQueueManager init]): 41 (-[WKQLThumbnailQueueManager dealloc]): 42 - Release `_queue` to fix theoretical leak found by the clang 43 static analyzer. 44 (-[WKQLThumbnailLoadOperation initWithAttachment:identifier:]): 45 (-[WKQLThumbnailLoadOperation initWithURL:identifier:]): 46 (-[WKQLThumbnailLoadOperation start]): 47 - Rename `req` to `request` and use RetainPtr<>. 48 - Change separate #if macros to #if/#else since only one version 49 of this code can be used at a time. 50 (-[WKQLThumbnailLoadOperation thumbnail]): 51 - Use CocoaImage to use one copy of the method. 52 1 53 2020-04-21 David Kilzer <ddkilzer@apple.com> 2 54 -
trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm
r260407 r260478 390 390 391 391 #if HAVE(QUICKLOOK_THUMBNAILING) 392 #if PLATFORM(MAC) 393 using PlatformImage = NSImage*; 394 #elif PLATFORM(IOS_FAMILY) 395 using PlatformImage = UIImage*; 396 #endif 397 398 static RefPtr<WebKit::ShareableBitmap> convertPlatformImageToBitmap(PlatformImage image, const WebCore::IntSize& size) 392 393 static RefPtr<WebKit::ShareableBitmap> convertPlatformImageToBitmap(CocoaImage *image, const WebCore::IntSize& size) 399 394 { 400 395 WebKit::ShareableBitmap::Configuration bitmapConfiguration; … … 433 428 }]; 434 429 435 [[WKQLThumbnailQueueManager sharedInstance].q lThumbnailGenerationQueue addOperation:operation];430 [[WKQLThumbnailQueueManager sharedInstance].queue addOperation:operation]; 436 431 } 437 432 … … 450 445 } 451 446 452 #endif 447 #endif // HAVE(QUICKLOOK_THUMBNAILING) 448 453 449 } // namespace WebKit 454 450 -
trunk/Source/WebKit/UIProcess/QuickLookThumbnailLoader.h
r260407 r260478 26 26 #if HAVE(QUICKLOOK_THUMBNAILING) 27 27 28 #if PLATFORM(IOS_FAMILY) 28 #if USE(APPKIT) 29 @class NSImage; 30 using CocoaImage = NSImage; 31 #else 29 32 @class UIImage; 33 using CocoaImage = UIImage; 30 34 #endif 31 35 32 36 @interface WKQLThumbnailQueueManager : NSObject 33 37 34 @property (nonatomic, readwrite, retain) NSOperationQueue* qlThumbnailGenerationQueue; 35 - (id)init; 38 @property (nonatomic, readonly, retain) NSOperationQueue *queue; 39 40 - (instancetype)init; 36 41 + (WKQLThumbnailQueueManager *)sharedInstance; 42 37 43 @end 38 44 39 45 @interface WKQLThumbnailLoadOperation : NSOperation 40 46 41 @property ( readonly, getter=isAsynchronous) BOOL asynchronous;42 @property ( readonly, getter=isExecuting) BOOL executing;43 @property ( readonly, getter=isFinished) BOOL finished;47 @property (atomic, readonly, getter=isAsynchronous) BOOL asynchronous; 48 @property (atomic, readonly, getter=isExecuting) BOOL executing; 49 @property (atomic, readonly, getter=isFinished) BOOL finished; 44 50 45 @property (nonatomic, copy) NSString *contentType;46 @property (nonatomic ) BOOL shouldWrite;51 @property (nonatomic, readonly, copy) NSString *identifier; 52 @property (nonatomic, readonly, retain) CocoaImage *thumbnail; 47 53 48 - (id)initWithAttachment:(NSFileWrapper *)fileWrapper identifier:(NSString *)identifier; 49 - (id)initWithURL:(NSString *)fileURL identifier:(NSString *)identifier; 50 - (NSString *)identifier; 51 #if PLATFORM(IOS_FAMILY) 52 -(UIImage *)thumbnail; 53 #endif 54 #if PLATFORM(MAC) 55 -(NSImage *)thumbnail; 56 #endif 54 - (instancetype)initWithAttachment:(NSFileWrapper *)fileWrapper identifier:(NSString *)identifier; 55 - (instancetype)initWithURL:(NSString *)fileURL identifier:(NSString *)identifier; 57 56 58 57 @end 59 58 60 #endif 59 #endif // HAVE(QUICKLOOK_THUMBNAILING) -
trunk/Source/WebKit/UIProcess/QuickLookThumbnailLoader.mm
r260407 r260478 34 34 @implementation WKQLThumbnailQueueManager 35 35 36 - (i d)init36 - (instancetype)init 37 37 { 38 38 self = [super init]; 39 39 if (self) 40 _q lThumbnailGenerationQueue = [[NSOperationQueue alloc] init];40 _queue = [[NSOperationQueue alloc] init]; 41 41 return self; 42 } 43 44 - (void)dealloc 45 { 46 [_queue release]; 47 [super dealloc]; 42 48 } 43 49 … … 50 56 @end 51 57 58 @interface WKQLThumbnailLoadOperation () 59 @property (atomic, readwrite, getter=isExecuting) BOOL executing; 60 @property (atomic, readwrite, getter=isFinished) BOOL finished; 61 @end 62 52 63 @implementation WKQLThumbnailLoadOperation { 53 64 RetainPtr<NSURL> _filePath; 54 RetainPtr<NS MutableString> _identifier;65 RetainPtr<NSString> _identifier; 55 66 RetainPtr<NSFileWrapper> _fileWrapper; 56 #if PLATFORM(MAC) 57 RetainPtr<NSImage> _thumbnail; 58 #endif 59 #if PLATFORM(IOS_FAMILY) 60 RetainPtr<UIImage> _thumbnail; 61 #endif 67 RetainPtr<CocoaImage> _thumbnail; 68 BOOL _shouldWrite; 62 69 } 63 70 64 - (i d)initWithAttachment:(NSFileWrapper *)fileWrapper identifier:(NSString *)identifier71 - (instancetype)initWithAttachment:(NSFileWrapper *)fileWrapper identifier:(NSString *)identifier 65 72 { 66 73 if (self = [super init]) { … … 72 79 } 73 80 74 - (i d)initWithURL:(NSString *)fileURL identifier:(NSString *)identifier81 - (instancetype)initWithURL:(NSString *)fileURL identifier:(NSString *)identifier 75 82 { 76 83 if (self = [super init]) { … … 84 91 { 85 92 self.executing = YES; 86 93 87 94 if (_shouldWrite) { 88 95 NSString *temporaryDirectory = FileSystem::createTemporaryDirectory(@"QLTempFileData"); 89 96 90 97 NSString *filePath = [temporaryDirectory stringByAppendingPathComponent:[_fileWrapper preferredFilename]]; 91 98 NSFileWrapperWritingOptions options = 0; 92 99 NSError *error = nil; 93 100 94 101 auto fileURLPath = adoptNS([NSURL fileURLWithPath:filePath]); 95 102 … … 100 107 } 101 108 102 QLThumbnailGenerationRequest *req = [[QLThumbnailGenerationRequest alloc] initWithFileAtURL:_filePath.get() size:CGSizeMake(400, 400) scale:1 representationTypes:QLThumbnailGenerationRequestRepresentationTypeAll];103 req .iconMode = YES;104 105 [[QLThumbnailGenerator sharedGenerator] generateBestRepresentationForRequest:req completionHandler:^(QLThumbnailRepresentation *thumbnail, NSError *error) {109 RetainPtr<QLThumbnailGenerationRequest> request = adoptNS([[QLThumbnailGenerationRequest alloc] initWithFileAtURL:_filePath.get() size:CGSizeMake(400, 400) scale:1 representationTypes:QLThumbnailGenerationRequestRepresentationTypeAll]); 110 request.get().iconMode = YES; 111 112 [[QLThumbnailGenerator sharedGenerator] generateBestRepresentationForRequest:request.get() completionHandler:^(QLThumbnailRepresentation *thumbnail, NSError *error) { 106 113 if (error) 107 114 return; 108 115 if (_thumbnail) 109 116 return; 110 #if PLATFORM(MAC)117 #if USE(APPKIT) 111 118 _thumbnail = thumbnail.NSImage; 112 #endif 113 #if PLATFORM(IOS_FAMILY) 119 #else 114 120 _thumbnail = thumbnail.UIImage; 115 121 #endif … … 122 128 } 123 129 124 #if PLATFORM(IOS_FAMILY) 125 - (UIImage *)thumbnail 130 - (CocoaImage *)thumbnail 126 131 { 127 132 return _thumbnail.get(); 128 133 } 129 #endif130 131 #if PLATFORM(MAC)132 - (NSImage *)thumbnail133 {134 return _thumbnail.get();135 }136 #endif137 134 138 135 - (NSString *)identifier … … 188 185 @end 189 186 190 #endif 187 #endif // HAVE(QUICKLOOK_THUMBNAILING)
Note: See TracChangeset
for help on using the changeset viewer.