Changeset 236822 in webkit
- Timestamp:
- Oct 3, 2018, 7:04:08 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm (modified) (3 diffs)
-
Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h (modified) (1 diff)
-
Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.h (modified) (1 diff)
-
Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.mm (modified) (2 diffs)
-
Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm (modified) (2 diffs)
-
Source/WebKit/UIProcess/PageClient.h (modified) (2 diffs)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r236821 r236822 1 2018-10-03 Dan Bernstein <mitz@apple.com> 2 3 [Cocoa] Let clients specify an NSFileWrapper subclassed to be used for _WKAttachment 4 https://bugs.webkit.org/show_bug.cgi?id=190270 5 6 Reviewed by Wenson Hsieh. 7 8 * UIProcess/API/Cocoa/WKWebViewConfiguration.mm: 9 (-[WKWebViewConfiguration copyWithZone:]): Copy new _attachmentFileWrapperClass ivar. 10 (-[WKWebViewConfiguration _attachmentFileWrapperClass]): Added this getter. 11 (-[WKWebViewConfiguration _setAttachmentFileWrapperClass:]): Added this setter, which raises 12 an exception if the argument is not an NSFileWrapper subclass. 13 14 * UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h: Declared new property. 15 16 * UIProcess/Cocoa/PageClientImplCocoa.h: 17 * UIProcess/Cocoa/PageClientImplCocoa.mm: 18 (WebKit::PageClientImplCocoa::allocFileWrapperInstance): Added. Allocates an instance of 19 the class specified in the configuration, or NSFileWrapper if no custom class is specified. 20 21 * UIProcess/Cocoa/WebPageProxyCocoa.mm: 22 (WebKit::WebPageProxy::platformRegisterAttachment): Use PageClient::allocFileWrapperInstance 23 instead of allocating an NSFileWrapper instance. 24 25 * UIProcess/PageClient.h: 26 (WebKit::PageClient::allocFileWrapperInstance): Defined new function. The default 27 implementation returns nil. 28 1 29 2018-10-03 Youenn Fablet <youenn@apple.com> 2 30 -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm
r235935 r236822 137 137 BOOL _mediaDataLoadsAutomatically; 138 138 BOOL _attachmentElementEnabled; 139 Class _attachmentFileWrapperClass; 139 140 BOOL _mainContentUserGestureOverrideEnabled; 140 141 … … 356 357 configuration->_mediaDataLoadsAutomatically = self->_mediaDataLoadsAutomatically; 357 358 configuration->_attachmentElementEnabled = self->_attachmentElementEnabled; 359 configuration->_attachmentFileWrapperClass = self->_attachmentFileWrapperClass; 358 360 configuration->_mediaTypesRequiringUserActionForPlayback = self->_mediaTypesRequiringUserActionForPlayback; 359 361 configuration->_mainContentUserGestureOverrideEnabled = self->_mainContentUserGestureOverrideEnabled; … … 747 749 } 748 750 751 - (Class)_attachmentFileWrapperClass 752 { 753 return _attachmentFileWrapperClass; 754 } 755 756 - (void)_setAttachmentFileWrapperClass:(Class)attachmentFileWrapperClass 757 { 758 if (attachmentFileWrapperClass && ![attachmentFileWrapperClass isSubclassOfClass:[NSFileWrapper self]]) 759 [NSException raise:NSInvalidArgumentException format:@"Class %@ does not inherit from NSFileWrapper", attachmentFileWrapperClass]; 760 761 _attachmentFileWrapperClass = attachmentFileWrapperClass; 762 } 763 749 764 - (BOOL)_colorFilterEnabled 750 765 { -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h
r235961 r236822 66 66 @property (nonatomic, setter=_setMediaDataLoadsAutomatically:) BOOL _mediaDataLoadsAutomatically WK_API_AVAILABLE(macosx(10.12), ios(10.0)); 67 67 @property (nonatomic, setter=_setAttachmentElementEnabled:) BOOL _attachmentElementEnabled WK_API_AVAILABLE(macosx(10.12), ios(10.0)); 68 @property (nonatomic, setter=_setAttachmentFileWrapperClass:) Class _attachmentFileWrapperClass WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); 68 69 @property (nonatomic, setter=_setInitialCapitalizationEnabled:) BOOL _initialCapitalizationEnabled WK_API_AVAILABLE(macosx(10.12), ios(10.0)); 69 70 @property (nonatomic, setter=_setApplePayEnabled:) BOOL _applePayEnabled WK_API_AVAILABLE(macosx(10.12), ios(10.0)); -
trunk/Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.h
r235156 r236822 46 46 void didInsertAttachment(API::Attachment&, const String& source) final; 47 47 void didRemoveAttachment(API::Attachment&) final; 48 NSFileWrapper *allocFileWrapperInstance() final; 48 49 #endif 49 50 -
trunk/Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.mm
r235156 r236822 27 27 #import "PageClientImplCocoa.h" 28 28 29 #import "WKWebViewConfigurationPrivate.h" 29 30 #import "WKWebViewInternal.h" 30 31 … … 66 67 } 67 68 69 NSFileWrapper *PageClientImplCocoa::allocFileWrapperInstance() 70 { 71 #if WK_API_ENABLED 72 Class cls = m_webView.configuration._attachmentFileWrapperClass ?: [NSFileWrapper self]; 73 return [cls alloc]; 74 #else 75 return nil; 76 #endif 77 } 78 68 79 #endif 69 80 -
trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm
r236634 r236822 169 169 170 170 auto buffer = SharedBuffer::create(dataReference.data(), dataReference.size()); 171 auto fileWrapper = adoptNS([ [NSFileWrapper alloc]initRegularFileWithContents:buffer->createNSData().autorelease()]);171 auto fileWrapper = adoptNS([pageClient().allocFileWrapperInstance() initRegularFileWithContents:buffer->createNSData().autorelease()]); 172 172 [fileWrapper setPreferredFilename:preferredFileName]; 173 173 attachment->setFileWrapper(fileWrapper.get()); … … 179 179 return; 180 180 181 auto fileWrapper = adoptNS([ [NSFileWrapper alloc]initWithURL:[NSURL fileURLWithPath:filePath] options:0 error:nil]);181 auto fileWrapper = adoptNS([pageClient().allocFileWrapperInstance() initWithURL:[NSURL fileURLWithPath:filePath] options:0 error:nil]); 182 182 attachment->setFileWrapper(fileWrapper.get()); 183 183 } -
trunk/Source/WebKit/UIProcess/PageClient.h
r236257 r236822 45 45 46 46 OBJC_CLASS CALayer; 47 OBJC_CLASS NSFileWrapper; 47 48 OBJC_CLASS _WKRemoteObjectRegistry; 48 49 … … 444 445 virtual void didInsertAttachment(API::Attachment&, const String& source) { } 445 446 virtual void didRemoveAttachment(API::Attachment&) { } 447 virtual NSFileWrapper *allocFileWrapperInstance() { return nullptr; } 446 448 #endif 447 449 }; -
trunk/Tools/ChangeLog
r236788 r236822 1 2018-10-03 Dan Bernstein <mitz@apple.com> 2 3 [Cocoa] Let clients specify an NSFileWrapper subclassed to be used for _WKAttachment 4 https://bugs.webkit.org/show_bug.cgi?id=190270 5 6 Reviewed by Wenson Hsieh. 7 8 * TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm: 9 (TestWebKitAPI::TEST): 10 1 11 2018-10-03 Ryosuke Niwa <rniwa@webkit.org> 2 12 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm
r236634 r236822 567 567 } 568 568 569 @interface FileWrapper : NSFileWrapper 570 @end 571 572 @implementation FileWrapper 573 @end 574 569 575 namespace TestWebKitAPI { 570 576 … … 1432 1438 } 1433 1439 1440 TEST(WKAttachmentTests, CustomFileWrapperSubclass) 1441 { 1442 auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); 1443 [configuration _setAttachmentElementEnabled:YES]; 1444 RetainPtr<NSException> exception; 1445 @try { 1446 [configuration _setAttachmentFileWrapperClass:[NSArray self]]; 1447 } @catch(NSException *caught) { 1448 exception = caught; 1449 } 1450 EXPECT_TRUE(exception); 1451 1452 [configuration _setAttachmentFileWrapperClass:[FileWrapper self]]; 1453 1454 auto webView = webViewForTestingAttachments(CGSizeZero, configuration.get()); 1455 1456 ObserveAttachmentUpdatesForScope observer(webView.get()); 1457 platformCopyPNG(); 1458 [webView _synchronouslyExecuteEditCommand:@"Paste" argument:nil]; 1459 NSArray<_WKAttachment *> * insertedAttachments = observer.observer().inserted; 1460 1461 EXPECT_EQ(1U, insertedAttachments.count); 1462 EXPECT_EQ([FileWrapper self], [insertedAttachments.firstObject.info.fileWrapper class]); 1463 } 1464 1434 1465 #pragma mark - Platform-specific tests 1435 1466
Note:
See TracChangeset
for help on using the changeset viewer.