Changeset 294830 in webkit
- Timestamp:
- May 25, 2022, 3:36:19 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
-
Source/WebCore/rendering/RenderThemeMac.mm (modified) (1 diff)
-
Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm (modified) (4 diffs)
-
Source/WebKit/UIProcess/WebPageProxy.cpp (modified) (1 diff)
-
Source/WebKit/UIProcess/WebPageProxy.h (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/rendering/RenderThemeMac.mm
r294680 r294830 2600 2600 RetainPtr<NSImage> RenderThemeMac::iconForAttachment(const String& fileName, const String& attachmentType, const String& title) 2601 2601 { 2602 if (fileName.isNull() && attachmentType.isNull() && title.isNull()) 2603 return nil; 2604 2602 2605 if (auto icon = WebCore::iconForAttachment(fileName, attachmentType, title)) 2603 2606 return icon->nsImage(); -
trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm
r294790 r294830 119 119 using namespace WebCore; 120 120 121 constexpr IntSize iconSize = IntSize(400, 400); 122 121 123 #if ENABLE(DATA_DETECTION) 122 124 … … 603 605 RunLoop::main().dispatch([this, operation = retainPtr(operation)] { 604 606 auto identifier = [operation identifier]; 605 auto convertedImage = convertPlatformImageToBitmap([operation thumbnail], WebCore::IntSize(400, 400));607 auto convertedImage = convertPlatformImageToBitmap([operation thumbnail], iconSize); 606 608 if (!convertedImage) 607 609 return; … … 613 615 } 614 616 615 616 void WebPageProxy::requestThumbnailWithFileWrapper(NSFileWrapper* fileWrapper, const String& identifier) 617 void WebPageProxy::requestThumbnailWithFileWrapper(NSFileWrapper *fileWrapper, const String& identifier) 617 618 { 618 619 auto operation = adoptNS([[WKQLThumbnailLoadOperation alloc] initWithAttachment:fileWrapper identifier:identifier]); … … 624 625 auto operation = adoptNS([[WKQLThumbnailLoadOperation alloc] initWithURL:filePath identifier:identifier]); 625 626 requestThumbnailWithOperation(operation.get()); 626 627 627 } 628 628 629 629 #endif // HAVE(QUICKLOOK_THUMBNAILING) 630 631 #if PLATFORM(MAC) 632 633 void WebPageProxy::updateIconForDirectory(NSFileWrapper *fileWrapper, const String& identifier) 634 { 635 auto image = [fileWrapper icon]; 636 if (!image) 637 return; 638 639 auto flippedIcon = [NSImage imageWithSize:iconSize flipped:YES drawingHandler:^BOOL(NSRect destinationRect) { 640 [image drawInRect:destinationRect fromRect:NSMakeRect(0, 0, [image size].width, [image size].height) operation:NSCompositingOperationSourceOver fraction:1.0f]; 641 return YES; 642 }]; 643 644 auto convertedImage = convertPlatformImageToBitmap(flippedIcon, iconSize); 645 if (!convertedImage) 646 return; 647 648 ShareableBitmap::Handle handle; 649 convertedImage->createHandle(handle); 650 send(Messages::WebPage::UpdateAttachmentIcon(identifier, handle, iconSize)); 651 } 652 653 #endif 630 654 631 655 void WebPageProxy::scheduleActivityStateUpdate() -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r294790 r294830 10304 10304 FloatSize size = requestedSize; 10305 10305 ShareableBitmap::Handle handle; 10306 #if PLATFORM(MAC) 10307 auto attachment = attachmentForIdentifier(identifier); 10308 if (attachment && attachment->contentType() == "public.directory") { 10309 updateIconForDirectory(attachment->fileWrapper(), attachment->identifier()); 10310 return; 10311 } 10312 #endif 10313 10306 10314 #if PLATFORM(COCOA) 10307 10315 if (auto icon = iconForAttachment(fileName, contentType, title, size)) -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r294790 r294830 2110 2110 #endif 2111 2111 2112 #if PLATFORM(MAC) 2113 void updateIconForDirectory(NSFileWrapper *, const String&); 2114 #endif 2115 2112 2116 private: 2113 2117 WebPageProxy(PageClient&, WebProcessProxy&, Ref<API::PageConfiguration>&&); -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm
r294515 r294830 157 157 } 158 158 159 #if PLATFORM(MAC) 160 161 static NSURL *testDirectoryAttachmentFileURL() 162 { 163 NSString *folderName = [NSString stringWithFormat:@"some.directory-%@", [NSUUID UUID].UUIDString]; 164 auto temporaryFolder = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:folderName] isDirectory:YES]; 165 NSError *error = nil; 166 [[NSFileManager defaultManager] createDirectoryAtURL:temporaryFolder withIntermediateDirectories:NO attributes:nil error:&error]; 167 168 return temporaryFolder; 169 } 170 171 #endif 172 159 173 @interface AttachmentUIDelegate : NSObject<WKUIDelegatePrivate> 160 174 @end … … 2063 2077 } 2064 2078 2079 static bool didLoadIcon; 2080 static NSImage *_icon(id, SEL) 2081 { 2082 didLoadIcon = true; 2083 return nil; 2084 } 2085 2086 TEST(WKAttachmentTestsMac, DragDirectoryAttachment) 2087 { 2088 didLoadIcon = false; 2089 auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); 2090 [configuration _setAttachmentElementEnabled:YES]; 2091 auto simulator = adoptNS([[DragAndDropSimulator alloc] initWithWebViewFrame:NSMakeRect(0, 0, 400, 400) configuration:configuration.get()]); 2092 TestWKWebView *webView = [simulator webView]; 2093 [webView synchronouslyLoadHTMLString:attachmentEditingTestMarkup]; 2094 2095 InstanceMethodSwizzler fileWrapperSwizzler { 2096 [NSFileWrapper class], 2097 @selector(icon), 2098 reinterpret_cast<IMP>(_icon) 2099 }; 2100 2101 auto fileWrapper = adoptNS([[NSFileWrapper alloc] initWithURL:testDirectoryAttachmentFileURL() options:0 error:nil]); 2102 auto attachment = retainPtr([webView synchronouslyInsertAttachmentWithFileWrapper:fileWrapper.get() contentType:nil]); 2103 [simulator runFrom:[webView attachmentElementMidPoint] to:CGPointMake(300, 300)]; 2104 TestWebKitAPI::Util::run(&didLoadIcon); 2105 } 2106 2065 2107 #endif // PLATFORM(MAC) 2066 2108
Note:
See TracChangeset
for help on using the changeset viewer.