Changeset 260611 in webkit
- Timestamp:
- Apr 23, 2020 5:46:18 PM (4 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r260608 r260611 1 2020-04-23 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`. 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-23 Megan Gardner <megan_gardner@apple.com> 2 54 -
trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm
r260498 r260611 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
r260498 r260611 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
r260581 r260611 35 35 @implementation WKQLThumbnailQueueManager 36 36 37 - (i d)init37 - (instancetype)init 38 38 { 39 39 self = [super init]; 40 40 if (self) 41 _q lThumbnailGenerationQueue = [[NSOperationQueue alloc] init];41 _queue = [[NSOperationQueue alloc] init]; 42 42 return self; 43 } 44 45 - (void)dealloc 46 { 47 [_queue release]; 48 [super dealloc]; 43 49 } 44 50 … … 51 57 @end 52 58 59 @interface WKQLThumbnailLoadOperation () 60 @property (atomic, readwrite, getter=isExecuting) BOOL executing; 61 @property (atomic, readwrite, getter=isFinished) BOOL finished; 62 @end 63 53 64 @implementation WKQLThumbnailLoadOperation { 54 65 RetainPtr<NSURL> _filePath; 55 RetainPtr<NS MutableString> _identifier;66 RetainPtr<NSString> _identifier; 56 67 RetainPtr<NSFileWrapper> _fileWrapper; 57 #if PLATFORM(MAC) 58 RetainPtr<NSImage> _thumbnail; 59 #endif 60 #if PLATFORM(IOS_FAMILY) 61 RetainPtr<UIImage> _thumbnail; 62 #endif 68 RetainPtr<CocoaImage> _thumbnail; 69 BOOL _shouldWrite; 63 70 } 64 71 65 - (i d)initWithAttachment:(NSFileWrapper *)fileWrapper identifier:(NSString *)identifier72 - (instancetype)initWithAttachment:(NSFileWrapper *)fileWrapper identifier:(NSString *)identifier 66 73 { 67 74 if (self = [super init]) { … … 73 80 } 74 81 75 - (i d)initWithURL:(NSString *)fileURL identifier:(NSString *)identifier82 - (instancetype)initWithURL:(NSString *)fileURL identifier:(NSString *)identifier 76 83 { 77 84 if (self = [super init]) { … … 85 92 { 86 93 self.executing = YES; 87 94 88 95 if (_shouldWrite) { 89 96 NSString *temporaryDirectory = FileSystem::createTemporaryDirectory(@"QLTempFileData"); 90 97 91 98 NSString *filePath = [temporaryDirectory stringByAppendingPathComponent:[_fileWrapper preferredFilename]]; 92 99 NSFileWrapperWritingOptions options = 0; … … 101 108 } 102 109 103 auto req = adoptNS([WebKit::allocQLThumbnailGenerationRequestInstance() initWithFileAtURL:_filePath.get() size:CGSizeMake(400, 400) scale:1 representationTypes:QLThumbnailGenerationRequestRepresentationTypeAll]);104 [req setIconMode:YES];110 auto request = adoptNS([WebKit::allocQLThumbnailGenerationRequestInstance() initWithFileAtURL:_filePath.get() size:CGSizeMake(400, 400) scale:1 representationTypes:QLThumbnailGenerationRequestRepresentationTypeAll]); 111 [request setIconMode:YES]; 105 112 106 [[WebKit::getQLThumbnailGeneratorClass() sharedGenerator] generateBestRepresentationForRequest:req .get() completionHandler:^(QLThumbnailRepresentation *thumbnail, NSError *error) {113 [[WebKit::getQLThumbnailGeneratorClass() sharedGenerator] generateBestRepresentationForRequest:request.get() completionHandler:^(QLThumbnailRepresentation *thumbnail, NSError *error) { 107 114 if (error) 108 115 return; 109 116 if (_thumbnail) 110 117 return; 111 #if PLATFORM(MAC)118 #if USE(APPKIT) 112 119 _thumbnail = thumbnail.NSImage; 113 #endif 114 #if PLATFORM(IOS_FAMILY) 120 #else 115 121 _thumbnail = thumbnail.UIImage; 116 122 #endif … … 123 129 } 124 130 125 #if PLATFORM(IOS_FAMILY) 126 - (UIImage *)thumbnail 131 - (CocoaImage *)thumbnail 127 132 { 128 133 return _thumbnail.get(); 129 134 } 130 #endif131 132 #if PLATFORM(MAC)133 - (NSImage *)thumbnail134 {135 return _thumbnail.get();136 }137 #endif138 135 139 136 - (NSString *)identifier … … 189 186 @end 190 187 191 #endif 188 #endif // HAVE(QUICKLOOK_THUMBNAILING)
Note: See TracChangeset
for help on using the changeset viewer.