WebKit Bugzilla
Attachment 339778 Details for
Bug 185397
: Use thumbnails in System Previews
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-185397-20180507172536.patch (text/plain), 12.84 KB, created by
Dean Jackson
on 2018-05-07 17:25:37 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Dean Jackson
Created:
2018-05-07 17:25:37 PDT
Size:
12.84 KB
patch
obsolete
>Subversion Revision: 231399 >diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog >index b2bea75c04d9732b15e5a64daf9d3a7cd65c2d11..0c53ce533ab0b6b9a803849cc81d144b47d8cd93 100644 >--- a/Source/WTF/ChangeLog >+++ b/Source/WTF/ChangeLog >@@ -1,3 +1,15 @@ >+2018-05-07 Dean Jackson <dino@apple.com> >+ >+ Use thumbnails in System Previews >+ https://bugs.webkit.org/show_bug.cgi?id=185397 >+ <rdar://problem/40039376> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Restrict SYSTEM_PREVIEW to newer versions of iOS. >+ >+ * wtf/Platform.h: >+ > 2018-05-04 Tim Horton <timothy_horton@apple.com> > > Shift to a lower-level framework for simplifying URLs >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 12f0f573f4ddacdd86cee54c79a3674ecb095aed..23fb3607f0d1b6b20bb8ef534ff5db16beadf2fb 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,34 @@ >+2018-05-07 Dean Jackson <dino@apple.com> >+ >+ Use thumbnails in System Previews >+ https://bugs.webkit.org/show_bug.cgi?id=185397 >+ <rdar://problem/40039376> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ A system preview that goes through the WKWebViewContentProvider will >+ show a static thumbnail/snapshot of the item, rather than jumping >+ directly to QuickLook. >+ >+ This means we have to link to the AssetViewer framework. That provides >+ a ASVThumbnailView that will trigger QuickLook for us. >+ >+ * Configurations/WebKit.xcconfig: Link to AssetViewer. >+ >+ * UIProcess/ios/WKSystemPreviewView.h: Better macro use. Remove some unneeded protocols. >+ * UIProcess/ios/WKSystemPreviewView.mm: >+ (-[WKSystemPreviewView web_setContentProviderData:suggestedFilename:]): Update this >+ to use an ASVThumbnailView, when on the internal SDK (because it is private). >+ (-[WKSystemPreviewView _layoutThumbnailView]): Use the content insets to put >+ the thumbnail in the right place. >+ (-[WKSystemPreviewView thumbnailView:wantsToPresentPreviewController:forItem:]): >+ Delegate method. >+ (-[WKSystemPreviewView web_contentView]): >+ (-[WKSystemPreviewView web_computedContentInsetDidChange]): >+ (-[WKSystemPreviewView numberOfPreviewItemsInPreviewController:]): Deleted. >+ (-[WKSystemPreviewView previewController:previewItemAtIndex:]): Deleted. >+ (-[WKSystemPreviewView previewControllerWillDismiss:]): Deleted. >+ > 2018-05-07 Dean Jackson <dino@apple.com> > > Use a dark gray for system preview bbackground >diff --git a/Source/WTF/wtf/Platform.h b/Source/WTF/wtf/Platform.h >index 52279ffda39563981c3f3167ee2b0c18a0989bfb..1cebefbd383894772f78fa7a303af531311fe896 100644 >--- a/Source/WTF/wtf/Platform.h >+++ b/Source/WTF/wtf/Platform.h >@@ -1037,7 +1037,7 @@ > #endif > #endif > >-#if PLATFORM(IOS) && USE(QUICK_LOOK) >+#if PLATFORM(IOS) && USE(QUICK_LOOK) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 120000 > #define USE_SYSTEM_PREVIEW 1 > #endif > >diff --git a/Source/WebKit/Configurations/WebKit.xcconfig b/Source/WebKit/Configurations/WebKit.xcconfig >index 871f04717136826d496d181f3ecf96c8fb5c1396..bfcb4258bbc6694043890059ee51afb42a74af9e 100644 >--- a/Source/WebKit/Configurations/WebKit.xcconfig >+++ b/Source/WebKit/Configurations/WebKit.xcconfig >@@ -106,13 +106,19 @@ WK_SAFE_BROWSING_LDFLAGS_iphonesimulator[sdk=iphone*10.*] = ; > WK_SAFE_BROWSING_LDFLAGS_macosx = $(WK_SAFE_BROWSING_LDFLAGS$(WK_MACOS_1013)); > WK_SAFE_BROWSING_LDFLAGS_MACOS_SINCE_1013 = -weak_framework SafariSafeBrowsing; > >+WK_SYSTEM_PREVIEW_LDFLAGS = $(WK_SYSTEM_PREVIEW_LDFLAGS_$(WK_PLATFORM_NAME)); >+WK_SYSTEM_PREVIEW_LDFLAGS_iphoneos = -framework AssetViewer; >+WK_SYSTEM_PREVIEW_LDFLAGS_iphonesimulator = -framework AssetViewer; >+WK_SYSTEM_PREVIEW_LDFLAGS_iphoneos[sdk=iphone*11.*] = ; >+WK_SYSTEM_PREVIEW_LDFLAGS_iphonesimulator[sdk=iphone*11.*] = ; >+ > WK_UIKIT_LDFLAGS = $(WK_UIKIT_LDFLAGS_$(WK_COCOA_TOUCH)); > WK_UIKIT_LDFLAGS_cocoatouch = -framework UIKit; > > WK_URL_FORMATTING_LDFLAGS = $(WK_URL_FORMATTING_LDFLAGS_$(WK_HAVE_URL_FORMATTING)); > WK_URL_FORMATTING_LDFLAGS_YES = -framework URLFormatting; > >-FRAMEWORK_AND_LIBRARY_LDFLAGS = -lobjc -framework CFNetwork -framework CoreAudio -framework CoreFoundation -framework CoreGraphics -framework CoreText -framework Foundation -framework ImageIO -framework IOKit -framework WebKitLegacy -lnetwork $(WK_ACCESSIBILITY_LDFLAGS) $(WK_APPKIT_LDFLAGS) $(WK_ASSERTION_SERVICES_LDFLAGS) $(WK_CARBON_LDFLAGS) $(WK_CORE_PDF_LDFLAGS) $(WK_CORE_PREDICTION_LDFLAGS) $(WK_CORE_SERVICES_LDFLAGS) $(WK_GRAPHICS_SERVICES_LDFLAGS) $(WK_IOSURFACE_LDFLAGS) $(WK_LIBWEBRTC_LDFLAGS) $(WK_MOBILE_CORE_SERVICES_LDFLAGS) $(WK_MOBILE_GESTALT_LDFLAGS) $(WK_OPENGL_LDFLAGS) $(WK_PDFKIT_LDFLAGS) $(WK_SAFE_BROWSING_LDFLAGS) $(WK_UIKIT_LDFLAGS) $(WK_URL_FORMATTING_LDFLAGS); >+FRAMEWORK_AND_LIBRARY_LDFLAGS = -lobjc -framework CFNetwork -framework CoreAudio -framework CoreFoundation -framework CoreGraphics -framework CoreText -framework Foundation -framework ImageIO -framework IOKit -framework WebKitLegacy -lnetwork $(WK_ACCESSIBILITY_LDFLAGS) $(WK_APPKIT_LDFLAGS) $(WK_ASSERTION_SERVICES_LDFLAGS) $(WK_CARBON_LDFLAGS) $(WK_CORE_PDF_LDFLAGS) $(WK_CORE_PREDICTION_LDFLAGS) $(WK_CORE_SERVICES_LDFLAGS) $(WK_GRAPHICS_SERVICES_LDFLAGS) $(WK_IOSURFACE_LDFLAGS) $(WK_LIBWEBRTC_LDFLAGS) $(WK_MOBILE_CORE_SERVICES_LDFLAGS) $(WK_MOBILE_GESTALT_LDFLAGS) $(WK_OPENGL_LDFLAGS) $(WK_PDFKIT_LDFLAGS) $(WK_SAFE_BROWSING_LDFLAGS) $(WK_SYSTEM_PREVIEW_LDFLAGS) $(WK_UIKIT_LDFLAGS) $(WK_URL_FORMATTING_LDFLAGS); > > // Prevent C++ standard library operator new, delete and their related exception types from being exported as weak symbols. > UNEXPORTED_SYMBOL_LDFLAGS = -Wl,-unexported_symbol -Wl,__ZTISt9bad_alloc -Wl,-unexported_symbol -Wl,__ZTISt9exception -Wl,-unexported_symbol -Wl,__ZTSSt9bad_alloc -Wl,-unexported_symbol -Wl,__ZTSSt9exception -Wl,-unexported_symbol -Wl,__ZdlPvS_ -Wl,-unexported_symbol -Wl,__ZnwmPv -Wl,-unexported_symbol -Wl,__Znwm -Wl,-unexported_symbol, -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEEC2EOS4_ -Wl,-unexported_symbol, -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEEC1EOS4_ -Wl,-unexported_symbol, -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEEaSEDn -Wl,-unexported_symbol, -Wl,__ZNKSt3__18functionIFvN7WebCore12PolicyActionEEEclES2_ -Wl,-unexported_symbol, -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEE4swapERS4_ -Wl,-unexported_symbol, -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEEC1ERKS4_ -Wl,-unexported_symbol, -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEEC2ERKS4_ -Wl,-unexported_symbol, -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEED1Ev -Wl,-unexported_symbol, -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEED2Ev -Wl,-unexported_symbol, -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEEaSERKS4_ -Wl,-unexported_symbol, -Wl,__ZTVNSt3__117bad_function_callE; >diff --git a/Source/WebKit/UIProcess/ios/WKSystemPreviewView.h b/Source/WebKit/UIProcess/ios/WKSystemPreviewView.h >index f02ce5798100af4b408c5d47cab3896bf28fd5e8..69025287d805ba00a909a6ca8d203334bee2a320 100644 >--- a/Source/WebKit/UIProcess/ios/WKSystemPreviewView.h >+++ b/Source/WebKit/UIProcess/ios/WKSystemPreviewView.h >@@ -23,14 +23,14 @@ > * THE POSSIBILITY OF SUCH DAMAGE. > */ > >-#if PLATFORM(IOS) && USE(QUICK_LOOK) >+#if USE(SYSTEM_PREVIEW) > > #import "WKWebViewContentProvider.h" > #import <QuickLook/QuickLook.h> > #import <UIKit/UIKit.h> > #import <pal/spi/ios/QuickLookSPI.h> > >-@interface WKSystemPreviewView : UIView <WKWebViewContentProvider, QLPreviewControllerDataSource, QLPreviewControllerDelegate, QLPreviewItemDataProvider> >+@interface WKSystemPreviewView : UIView <WKWebViewContentProvider, QLPreviewItemDataProvider> > > @end > >diff --git a/Source/WebKit/UIProcess/ios/WKSystemPreviewView.mm b/Source/WebKit/UIProcess/ios/WKSystemPreviewView.mm >index 34da80cf34e5eaf79a62ab3b92a0a57eb60d8579..e963b56bff6cb481e548b25993c1bf86ccea8ccd 100644 >--- a/Source/WebKit/UIProcess/ios/WKSystemPreviewView.mm >+++ b/Source/WebKit/UIProcess/ios/WKSystemPreviewView.mm >@@ -39,19 +39,31 @@ > #import <wtf/SoftLinking.h> > #import <wtf/Vector.h> > >+#if USE(APPLE_INTERNAL_SDK) >+#import <AssetViewer/ASVThumbnailView.h> >+#import <QuickLook/QuickLookPrivate.h> >+#import <WebKitAdditions/SystemPreviewTypes.cpp> >+#endif >+ > using namespace WebCore; > using namespace WebKit; > > SOFT_LINK_FRAMEWORK(QuickLook) > SOFT_LINK_CLASS(QuickLook, QLItem); >-SOFT_LINK_CLASS(QuickLook, QLPreviewController); >+ >+#if USE(APPLE_INTERNAL_SDK) >+@interface WKSystemPreviewView () <ASVThumbnailViewDelegate> >+@end >+#endif > > @implementation WKSystemPreviewView { >- RetainPtr<QLPreviewController> _qlPreviewController; > RetainPtr<NSItemProvider> _itemProvider; >- RetainPtr<QLItem> _item; > RetainPtr<NSData> _data; > RetainPtr<NSString> _suggestedFilename; >+#if USE(APPLE_INTERNAL_SDK) >+ RetainPtr<QLItem> _item; >+ RetainPtr<ASVThumbnailView> _thumbnailView; >+#endif > > WKWebView *_webView; > } >@@ -76,6 +88,7 @@ SOFT_LINK_CLASS(QuickLook, QLPreviewController); > > - (void)web_setContentProviderData:(NSData *)data suggestedFilename:(NSString *)filename > { >+#if USE(APPLE_INTERNAL_SDK) > RefPtr<WebKit::WebPageProxy> page = _webView->_page; > UIViewController *presentingViewController = page->uiClient().presentingViewController(); > >@@ -89,12 +102,51 @@ SOFT_LINK_CLASS(QuickLook, QLPreviewController); > RetainPtr<CFStringRef> contentType = adoptCF(UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)extension, nil)); > > _item = adoptNS([allocQLItemInstance() initWithDataProvider:self contentType:(NSString *)contentType.get() previewTitle:_suggestedFilename.get()]); >+ [_item setUseLoadingTimeout:NO]; >+ >+ _thumbnailView = adoptNS([ASVThumbnailView new]); >+ [_thumbnailView setDelegate:self]; >+ [self setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight]; >+ >+ [self setAutoresizesSubviews:YES]; >+ [self setClipsToBounds:YES]; >+ [self addSubview:_thumbnailView.get()]; >+ [self _layoutThumbnailView]; >+ >+ auto screenBounds = UIScreen.mainScreen.bounds; >+ CGFloat maxDimension = CGFloatMin(screenBounds.size.width, screenBounds.size.height); >+ [_thumbnailView setMaxThumbnailSize:CGSizeMake(maxDimension, maxDimension)]; >+ >+ [_thumbnailView setThumbnailItem:_item.get()]; >+#endif >+} >+ >+- (void)_layoutThumbnailView >+{ >+ if (_thumbnailView) { >+ UIEdgeInsets safeAreaInsets = _webView._computedUnobscuredSafeAreaInset; >+ CGRect layoutFrame = CGRectMake(0, 0, self.frame.size.width - safeAreaInsets.left - safeAreaInsets.right, self.frame.size.height - safeAreaInsets.top - safeAreaInsets.bottom); >+ [_thumbnailView setFrame:layoutFrame]; >+ [_thumbnailView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight]; >+ } >+} >+ >+#pragma mark ASVThumbnailViewDelegate >+ >+#if USE(APPLE_INTERNAL_SDK) >+- (void)thumbnailView:(ASVThumbnailView *)thumbnailView wantsToPresentPreviewController:(QLPreviewController *)previewController forItem:(QLItem *)item >+{ >+ RefPtr<WebKit::WebPageProxy> page = _webView->_page; >+ UIViewController *presentingViewController = page->uiClient().presentingViewController(); >+ [presentingViewController presentViewController:previewController animated:YES completion:nil]; >+} >+#endif > >- _qlPreviewController = adoptNS([allocQLPreviewControllerInstance() init]); >- [_qlPreviewController setDelegate:self]; >- [_qlPreviewController setDataSource:self]; >+#pragma mark WKWebViewContentProvider protocol > >- [presentingViewController presentViewController:_qlPreviewController.get() animated:YES completion:nullptr]; >+- (UIView *)web_contentView >+{ >+ return self; > } > > - (void)web_setMinimumSize:(CGSize)size >@@ -107,6 +159,7 @@ SOFT_LINK_CLASS(QuickLook, QLPreviewController); > > - (void)web_computedContentInsetDidChange > { >+ [self _layoutThumbnailView]; > } > > - (void)web_setFixedOverlayView:(UIView *)fixedOverlayView >@@ -117,11 +170,6 @@ SOFT_LINK_CLASS(QuickLook, QLPreviewController); > { > } > >-- (UIView *)web_contentView >-{ >- return self; >-} >- > #pragma mark Find-in-Page > > - (void)web_countStringMatches:(NSString *)string options:(_WKFindOptions)options maxCount:(NSUInteger)maxCount >@@ -140,18 +188,6 @@ SOFT_LINK_CLASS(QuickLook, QLPreviewController); > { > } > >-#pragma mark QLPreviewControllerDataSource >- >-- (NSInteger)numberOfPreviewItemsInPreviewController:(QLPreviewController *)controller >-{ >- return 1; >-} >- >-- (id<QLPreviewItem>)previewController:(QLPreviewController *)controller previewItemAtIndex:(NSInteger)index >-{ >- return static_cast<id<QLPreviewItem>>(_item.get()); >-} >- > #pragma mark QLPreviewItemDataProvider > > - (NSData *)provideDataForItem:(QLItem *)item >@@ -159,14 +195,6 @@ SOFT_LINK_CLASS(QuickLook, QLPreviewController); > return _data.get(); > } > >-#pragma mark QLPreviewControllerDelegate >- >-- (void)previewControllerWillDismiss:(QLPreviewController *)controller >-{ >- RefPtr<WebKit::WebPageProxy> page = _webView->_page; >- page->goBack(); >-} >- > @end > > #endif
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 185397
:
339778
|
339837