Diff
Modified: trunk/Source/WebCore/ChangeLog (285634 => 285635)
--- trunk/Source/WebCore/ChangeLog 2021-11-11 17:18:22 UTC (rev 285634)
+++ trunk/Source/WebCore/ChangeLog 2021-11-11 17:22:28 UTC (rev 285635)
@@ -1,3 +1,21 @@
+2021-11-11 Dean Jackson <[email protected]>
+
+ WKSystemPreviewView should be called WKUSDPreviewView
+ https://bugs.webkit.org/show_bug.cgi?id=232961
+ <rdar://problem/85265415>
+
+ Reviewed by Sam Weinig.
+
+ Rename the WebCore APIs that look for "SystemPreview" MIME-types
+ to be clear they are looking for USD.
+
+ * platform/MIMETypeRegistry.cpp:
+ (WebCore::MIMETypeRegistry::isUSDMIMEType):
+ (WebCore::MIMETypeRegistry::isSystemPreviewMIMEType): Deleted.
+ * platform/MIMETypeRegistry.h:
+ * platform/cocoa/MIMETypeRegistryCocoa.mm:
+ (WebCore::MIMETypeRegistry::preferredExtensionForMIMEType):
+
2021-11-11 Tyler Wilcock <[email protected]>
AX: Implement AXCoreObject::value for AXIsolatedObject
Modified: trunk/Source/WebCore/platform/MIMETypeRegistry.cpp (285634 => 285635)
--- trunk/Source/WebCore/platform/MIMETypeRegistry.cpp 2021-11-11 17:18:22 UTC (rev 285634)
+++ trunk/Source/WebCore/platform/MIMETypeRegistry.cpp 2021-11-11 17:22:28 UTC (rev 285635)
@@ -670,7 +670,7 @@
return defaultMIMEType;
}
-constexpr ComparableLettersLiteral systemPreviewMIMETypeArray[] = {
+constexpr ComparableLettersLiteral usdMIMETypeArray[] = {
"model/usd", // Unofficial, but supported because we documented this.
"model/vnd.pixar.usd", // Unofficial, but supported because we documented this.
"model/vnd.reality",
@@ -677,15 +677,15 @@
"model/vnd.usdz+zip", // The official type: https://www.iana.org/assignments/media-types/model/vnd.usdz+zip
};
-FixedVector<const char*> MIMETypeRegistry::systemPreviewMIMETypes()
+FixedVector<const char*> MIMETypeRegistry::usdMIMETypes()
{
- return makeFixedVector(systemPreviewMIMETypeArray);
+ return makeFixedVector(usdMIMETypeArray);
}
-bool MIMETypeRegistry::isSystemPreviewMIMEType(const String& mimeType)
+bool MIMETypeRegistry::isUSDMIMEType(const String& mimeType)
{
- static constexpr SortedArraySet systemPreviewMIMETypeSet { systemPreviewMIMETypeArray };
- return systemPreviewMIMETypeSet.contains(mimeType);
+ static constexpr SortedArraySet usdMIMETypeSet { usdMIMETypeArray };
+ return usdMIMETypeSet.contains(mimeType);
}
// FIXME: Not great that CURL needs this concept; other platforms do not.
Modified: trunk/Source/WebCore/platform/MIMETypeRegistry.h (285634 => 285635)
--- trunk/Source/WebCore/platform/MIMETypeRegistry.h 2021-11-11 17:18:22 UTC (rev 285634)
+++ trunk/Source/WebCore/platform/MIMETypeRegistry.h 2021-11-11 17:22:28 UTC (rev 285635)
@@ -106,7 +106,7 @@
static bool isPostScriptMIMEType(const String& mimeType);
WEBCORE_EXPORT static bool isPDFOrPostScriptMIMEType(const String& mimeType);
- WEBCORE_EXPORT static bool isSystemPreviewMIMEType(const String& mimeType);
+ WEBCORE_EXPORT static bool isUSDMIMEType(const String& mimeType);
// Check to see if a MIME type is suitable for being shown inside a page.
// Returns true if any of isSupportedImageMIMEType(), isSupportedNonImageMIMEType(),
@@ -133,7 +133,7 @@
WEBCORE_EXPORT static const HashSet<String, ASCIICaseInsensitiveHash>& supportedMediaMIMETypes();
WEBCORE_EXPORT static FixedVector<const char*> pdfMIMETypes();
WEBCORE_EXPORT static FixedVector<const char*> unsupportedTextMIMETypes();
- WEBCORE_EXPORT static FixedVector<const char*> systemPreviewMIMETypes();
+ WEBCORE_EXPORT static FixedVector<const char*> usdMIMETypes();
WEBCORE_EXPORT static String appendFileExtensionIfNecessary(const String& filename, const String& mimeType);
Modified: trunk/Source/WebCore/platform/cocoa/MIMETypeRegistryCocoa.mm (285634 => 285635)
--- trunk/Source/WebCore/platform/cocoa/MIMETypeRegistryCocoa.mm 2021-11-11 17:18:22 UTC (rev 285634)
+++ trunk/Source/WebCore/platform/cocoa/MIMETypeRegistryCocoa.mm 2021-11-11 17:22:28 UTC (rev 285635)
@@ -103,9 +103,9 @@
String MIMETypeRegistry::preferredExtensionForMIMEType(const String& type)
{
- // System Previews accept some non-standard MIMETypes, so we can't rely on
+ // We accept some non-standard USD MIMETypes, so we can't rely on
// the file type mappings.
- if (isSystemPreviewMIMEType(type))
+ if (isUSDMIMEType(type))
return "usdz"_s;
return [[NSURLFileTypeMappings sharedMappings] preferredExtensionForMIMEType:(NSString *)type];
Modified: trunk/Source/WebKit/ChangeLog (285634 => 285635)
--- trunk/Source/WebKit/ChangeLog 2021-11-11 17:18:22 UTC (rev 285634)
+++ trunk/Source/WebKit/ChangeLog 2021-11-11 17:22:28 UTC (rev 285635)
@@ -1,3 +1,39 @@
+2021-11-11 Dean Jackson <[email protected]>
+
+ WKSystemPreviewView should be called WKUSDPreviewView
+ https://bugs.webkit.org/show_bug.cgi?id=232961
+ <rdar://problem/85265415>
+
+ Reviewed by Sam Weinig.
+
+ WKSystemPreviewView is a uninformative name. WKUSDPreviewView is more accurate.
+
+ * SourcesCocoa.txt:
+ * UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm:
+ (-[WKWebViewContentProviderRegistry initWithConfiguration:]):
+ * UIProcess/SystemPreviewController.cpp:
+ (WebKit::SystemPreviewController::canPreview const):
+ * UIProcess/ios/WKUSDPreviewView.h: Renamed from Source/WebKit/UIProcess/ios/WKSystemPreviewView.h.
+ * UIProcess/ios/WKUSDPreviewView.mm: Renamed from Source/WebKit/UIProcess/ios/WKSystemPreviewView.mm.
+ (getUTIForSystemPreviewMIMEType):
+ (-[WKUSDPreviewView web_initWithFrame:webView:mimeType:]):
+ (-[WKUSDPreviewView web_setContentProviderData:suggestedFilename:]):
+ (-[WKUSDPreviewView _layoutThumbnailView]):
+ (-[WKUSDPreviewView thumbnailView:wantsToPresentPreviewController:forItem:]):
+ (-[WKUSDPreviewView web_contentView]):
+ (+[WKUSDPreviewView web_requiresCustomSnapshotting]):
+ (-[WKUSDPreviewView web_setMinimumSize:]):
+ (-[WKUSDPreviewView web_setOverlaidAccessoryViewsInset:]):
+ (-[WKUSDPreviewView web_computedContentInsetDidChange]):
+ (-[WKUSDPreviewView web_setFixedOverlayView:]):
+ (-[WKUSDPreviewView web_didSameDocumentNavigation:]):
+ (-[WKUSDPreviewView web_isBackground]):
+ (-[WKUSDPreviewView web_countStringMatches:options:maxCount:]):
+ (-[WKUSDPreviewView web_findString:options:maxCount:]):
+ (-[WKUSDPreviewView web_hideFindUI]):
+ (-[WKUSDPreviewView provideDataForItem:]):
+ * WebKit.xcodeproj/project.pbxproj:
+
2021-11-11 Chris Dumez <[email protected]>
Turn off various preferences when in captive portal mode
Modified: trunk/Source/WebKit/SourcesCocoa.txt (285634 => 285635)
--- trunk/Source/WebKit/SourcesCocoa.txt 2021-11-11 17:18:22 UTC (rev 285634)
+++ trunk/Source/WebKit/SourcesCocoa.txt 2021-11-11 17:22:28 UTC (rev 285635)
@@ -506,9 +506,9 @@
UIProcess/ios/WKStylusDeviceObserver.mm
UIProcess/ios/WKSyntheticFlagsChangedWebEvent.mm
UIProcess/ios/WKSyntheticTapGestureRecognizer.mm
-UIProcess/ios/WKSystemPreviewView.mm
UIProcess/ios/WKTouchActionGestureRecognizer.mm
UIProcess/ios/WKTextSelectionRect.mm
+UIProcess/ios/WKUSDPreviewView.mm
UIProcess/ios/WKWebEvent.mm
UIProcess/Launcher/mac/ProcessLauncherMac.mm
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm (285634 => 285635)
--- trunk/Source/WebKit/UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm 2021-11-11 17:18:22 UTC (rev 285634)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm 2021-11-11 17:22:28 UTC (rev 285635)
@@ -29,7 +29,7 @@
#if PLATFORM(IOS_FAMILY)
#import "WKPDFView.h"
-#import "WKSystemPreviewView.h"
+#import "WKUSDPreviewView.h"
#import <WebKit/WKWebViewConfigurationPrivate.h>
#import "WKWebViewInternal.h"
#import "WebPageProxy.h"
@@ -56,8 +56,8 @@
#if USE(SYSTEM_PREVIEW) && !HAVE(UIKIT_WEBKIT_INTERNALS)
if (configuration._systemPreviewEnabled) {
- for (auto& type : WebCore::MIMETypeRegistry::systemPreviewMIMETypes())
- [self registerProvider:[WKSystemPreviewView class] forMIMEType:@(type)];
+ for (auto& type : WebCore::MIMETypeRegistry::usdMIMETypes())
+ [self registerProvider:[WKUSDPreviewView class] forMIMEType:@(type)];
}
#endif
Modified: trunk/Source/WebKit/UIProcess/SystemPreviewController.cpp (285634 => 285635)
--- trunk/Source/WebKit/UIProcess/SystemPreviewController.cpp 2021-11-11 17:18:22 UTC (rev 285634)
+++ trunk/Source/WebKit/UIProcess/SystemPreviewController.cpp 2021-11-11 17:22:28 UTC (rev 285635)
@@ -40,7 +40,7 @@
bool SystemPreviewController::canPreview(const String& mimeType) const
{
- return WebCore::MIMETypeRegistry::isSystemPreviewMIMEType(mimeType);
+ return WebCore::MIMETypeRegistry::isUSDMIMEType(mimeType);
}
}
Deleted: trunk/Source/WebKit/UIProcess/ios/WKSystemPreviewView.h (285634 => 285635)
--- trunk/Source/WebKit/UIProcess/ios/WKSystemPreviewView.h 2021-11-11 17:18:22 UTC (rev 285634)
+++ trunk/Source/WebKit/UIProcess/ios/WKSystemPreviewView.h 2021-11-11 17:22:28 UTC (rev 285635)
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2018 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#if USE(SYSTEM_PREVIEW) && !HAVE(UIKIT_WEBKIT_INTERNALS)
-
-#import "WKApplicationStateTrackingView.h"
-#import "WKWebViewContentProvider.h"
-#import <QuickLook/QuickLook.h>
-#import <UIKit/UIKit.h>
-#import <pal/spi/ios/QuickLookSPI.h>
-
-@interface WKSystemPreviewView : WKApplicationStateTrackingView <WKWebViewContentProvider, QLPreviewItemDataProvider>
-
-@end
-
-#endif
Deleted: trunk/Source/WebKit/UIProcess/ios/WKSystemPreviewView.mm (285634 => 285635)
--- trunk/Source/WebKit/UIProcess/ios/WKSystemPreviewView.mm 2021-11-11 17:18:22 UTC (rev 285634)
+++ trunk/Source/WebKit/UIProcess/ios/WKSystemPreviewView.mm 2021-11-11 17:22:28 UTC (rev 285635)
@@ -1,205 +0,0 @@
-/*
- * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "WKSystemPreviewView.h"
-
-#if USE(SYSTEM_PREVIEW) && !HAVE(UIKIT_WEBKIT_INTERNALS)
-
-#import "APIFindClient.h"
-#import "APIUIClient.h"
-#import "WKWebViewIOS.h"
-#import "WebPageProxy.h"
-#import <MobileCoreServices/MobileCoreServices.h>
-#import <WebCore/FloatRect.h>
-#import <WebCore/LocalizedStrings.h>
-#import <WebCore/MIMETypeRegistry.h>
-#import <WebCore/UTIUtilities.h>
-#import <pal/ios/QuickLookSoftLink.h>
-#import <pal/spi/cg/CoreGraphicsSPI.h>
-#import <pal/spi/ios/SystemPreviewSPI.h>
-#import <wtf/RetainPtr.h>
-#import <wtf/Vector.h>
-
-SOFT_LINK_PRIVATE_FRAMEWORK(AssetViewer);
-SOFT_LINK_CLASS(AssetViewer, ASVThumbnailView);
-
-static NSString *getUTIForSystemPreviewMIMEType(const String& mimeType)
-{
- if (!WebCore::MIMETypeRegistry::isSystemPreviewMIMEType(mimeType))
- return nil;
-
- return WebCore::UTIFromMIMEType(mimeType);
-}
-
-@interface WKSystemPreviewView () <ASVThumbnailViewDelegate>
-@end
-
-@implementation WKSystemPreviewView {
- RetainPtr<NSItemProvider> _itemProvider;
- RetainPtr<NSData> _data;
- RetainPtr<NSString> _suggestedFilename;
- RetainPtr<NSString> _mimeType;
- RetainPtr<QLItem> _item;
- RetainPtr<ASVThumbnailView> _thumbnailView;
- WKWebView *_webView;
-}
-
-- (instancetype)web_initWithFrame:(CGRect)frame webView:(WKWebView *)webView mimeType:(NSString *)mimeType
-{
- if (!(self = [super initWithFrame:frame webView:webView]))
- return nil;
-
- UIColor *backgroundColor = [UIColor colorWithRed:(38. / 255) green:(38. / 255) blue:(38. / 255) alpha:1];
- self.backgroundColor = backgroundColor;
-
- _webView = webView;
- _mimeType = mimeType;
-
- UIScrollView *scrollView = webView.scrollView;
- [scrollView setMinimumZoomScale:1];
- [scrollView setMaximumZoomScale:1];
- [scrollView setBackgroundColor:backgroundColor];
-
- return self;
-}
-
-- (void)web_setContentProviderData:(NSData *)data suggestedFilename:(NSString *)filename
-{
- _suggestedFilename = adoptNS([filename copy]);
- _data = adoptNS([data copy]);
-
- NSString *contentType = getUTIForSystemPreviewMIMEType(_mimeType.get());
-
- _item = adoptNS([PAL::allocQLItemInstance() initWithDataProvider:self contentType:contentType previewTitle:_suggestedFilename.get()]);
- [_item setUseLoadingTimeout:NO];
-
- _thumbnailView = adoptNS([allocASVThumbnailViewInstance() init]);
- [_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()];
-}
-
-- (void)_layoutThumbnailView
-{
- if (_thumbnailView) {
- UIEdgeInsets safeAreaInsets = _webView._computedUnobscuredSafeAreaInset;
- UIEdgeInsets obscuredAreaInsets = _webView._computedObscuredInset;
-
- CGRect layoutFrame = UIEdgeInsetsInsetRect(self.frame, safeAreaInsets);
-
- layoutFrame.size.width -= obscuredAreaInsets.left + obscuredAreaInsets.right;
- layoutFrame.size.height -= obscuredAreaInsets.top + obscuredAreaInsets.bottom;
-
- [_thumbnailView setFrame:layoutFrame];
- [_thumbnailView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
- }
-}
-
-#pragma mark ASVThumbnailViewDelegate
-
-- (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];
-}
-
-#pragma mark WKWebViewContentProvider protocol
-
-- (UIView *)web_contentView
-{
- return self;
-}
-
-+ (BOOL)web_requiresCustomSnapshotting
-{
- return false;
-}
-
-- (void)web_setMinimumSize:(CGSize)size
-{
-}
-
-- (void)web_setOverlaidAccessoryViewsInset:(CGSize)inset
-{
-}
-
-- (void)web_computedContentInsetDidChange
-{
- [self _layoutThumbnailView];
-}
-
-- (void)web_setFixedOverlayView:(UIView *)fixedOverlayView
-{
-}
-
-- (void)web_didSameDocumentNavigation:(WKSameDocumentNavigationType)navigationType
-{
-}
-
-- (BOOL)web_isBackground
-{
- return self.isBackground;
-}
-
-#pragma mark Find-in-Page
-
-- (void)web_countStringMatches:(NSString *)string options:(_WKFindOptions)options maxCount:(NSUInteger)maxCount
-{
- RefPtr<WebKit::WebPageProxy> page = _webView->_page;
- page->findClient().didCountStringMatches(page.get(), string, 0);
-}
-
-- (void)web_findString:(NSString *)string options:(_WKFindOptions)options maxCount:(NSUInteger)maxCount
-{
- RefPtr<WebKit::WebPageProxy> page = _webView->_page;
- page->findClient().didFailToFindString(page.get(), string);
-}
-
-- (void)web_hideFindUI
-{
-}
-
-#pragma mark QLPreviewItemDataProvider
-
-- (NSData *)provideDataForItem:(QLItem *)item
-{
- return _data.get();
-}
-
-@end
-
-#endif
Copied: trunk/Source/WebKit/UIProcess/ios/WKUSDPreviewView.h (from rev 285634, trunk/Source/WebKit/UIProcess/ios/WKSystemPreviewView.h) (0 => 285635)
--- trunk/Source/WebKit/UIProcess/ios/WKUSDPreviewView.h (rev 0)
+++ trunk/Source/WebKit/UIProcess/ios/WKUSDPreviewView.h 2021-11-11 17:22:28 UTC (rev 285635)
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if USE(SYSTEM_PREVIEW) && !HAVE(UIKIT_WEBKIT_INTERNALS)
+
+#import "WKApplicationStateTrackingView.h"
+#import "WKWebViewContentProvider.h"
+#import <QuickLook/QuickLook.h>
+#import <UIKit/UIKit.h>
+#import <pal/spi/ios/QuickLookSPI.h>
+
+@interface WKUSDPreviewView : WKApplicationStateTrackingView <WKWebViewContentProvider, QLPreviewItemDataProvider>
+
+@end
+
+#endif
Copied: trunk/Source/WebKit/UIProcess/ios/WKUSDPreviewView.mm (from rev 285634, trunk/Source/WebKit/UIProcess/ios/WKSystemPreviewView.mm) (0 => 285635)
--- trunk/Source/WebKit/UIProcess/ios/WKUSDPreviewView.mm (rev 0)
+++ trunk/Source/WebKit/UIProcess/ios/WKUSDPreviewView.mm 2021-11-11 17:22:28 UTC (rev 285635)
@@ -0,0 +1,206 @@
+/*
+ * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "WKUSDPreviewView.h"
+
+#if USE(SYSTEM_PREVIEW) && !HAVE(UIKIT_WEBKIT_INTERNALS)
+
+#import "APIFindClient.h"
+#import "APIUIClient.h"
+#import "WKWebViewIOS.h"
+#import "WebPageProxy.h"
+#import <MobileCoreServices/MobileCoreServices.h>
+#import <WebCore/FloatRect.h>
+#import <WebCore/LocalizedStrings.h>
+#import <WebCore/MIMETypeRegistry.h>
+#import <WebCore/UTIUtilities.h>
+#import <pal/spi/cg/CoreGraphicsSPI.h>
+#import <pal/spi/ios/SystemPreviewSPI.h>
+#import <wtf/RetainPtr.h>
+#import <wtf/Vector.h>
+
+#import <pal/ios/QuickLookSoftLink.h>
+
+SOFT_LINK_PRIVATE_FRAMEWORK(AssetViewer);
+SOFT_LINK_CLASS(AssetViewer, ASVThumbnailView);
+
+static NSString *getUTIForUSDMIMEType(const String& mimeType)
+{
+ if (!WebCore::MIMETypeRegistry::isUSDMIMEType(mimeType))
+ return nil;
+
+ return WebCore::UTIFromMIMEType(mimeType);
+}
+
+@interface WKUSDPreviewView () <ASVThumbnailViewDelegate>
+@end
+
+@implementation WKUSDPreviewView {
+ RetainPtr<NSItemProvider> _itemProvider;
+ RetainPtr<NSData> _data;
+ RetainPtr<NSString> _suggestedFilename;
+ RetainPtr<NSString> _mimeType;
+ RetainPtr<QLItem> _item;
+ RetainPtr<ASVThumbnailView> _thumbnailView;
+ WKWebView *_webView;
+}
+
+- (instancetype)web_initWithFrame:(CGRect)frame webView:(WKWebView *)webView mimeType:(NSString *)mimeType
+{
+ if (!(self = [super initWithFrame:frame webView:webView]))
+ return nil;
+
+ UIColor *backgroundColor = [UIColor colorWithRed:(38. / 255) green:(38. / 255) blue:(38. / 255) alpha:1];
+ self.backgroundColor = backgroundColor;
+
+ _webView = webView;
+ _mimeType = mimeType;
+
+ UIScrollView *scrollView = webView.scrollView;
+ [scrollView setMinimumZoomScale:1];
+ [scrollView setMaximumZoomScale:1];
+ [scrollView setBackgroundColor:backgroundColor];
+
+ return self;
+}
+
+- (void)web_setContentProviderData:(NSData *)data suggestedFilename:(NSString *)filename
+{
+ _suggestedFilename = adoptNS([filename copy]);
+ _data = adoptNS([data copy]);
+
+ NSString *contentType = getUTIForUSDMIMEType(_mimeType.get());
+
+ _item = adoptNS([PAL::allocQLItemInstance() initWithDataProvider:self contentType:contentType previewTitle:_suggestedFilename.get()]);
+ [_item setUseLoadingTimeout:NO];
+
+ _thumbnailView = adoptNS([allocASVThumbnailViewInstance() init]);
+ [_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()];
+}
+
+- (void)_layoutThumbnailView
+{
+ if (_thumbnailView) {
+ UIEdgeInsets safeAreaInsets = _webView._computedUnobscuredSafeAreaInset;
+ UIEdgeInsets obscuredAreaInsets = _webView._computedObscuredInset;
+
+ CGRect layoutFrame = UIEdgeInsetsInsetRect(self.frame, safeAreaInsets);
+
+ layoutFrame.size.width -= obscuredAreaInsets.left + obscuredAreaInsets.right;
+ layoutFrame.size.height -= obscuredAreaInsets.top + obscuredAreaInsets.bottom;
+
+ [_thumbnailView setFrame:layoutFrame];
+ [_thumbnailView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
+ }
+}
+
+#pragma mark ASVThumbnailViewDelegate
+
+- (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];
+}
+
+#pragma mark WKWebViewContentProvider protocol
+
+- (UIView *)web_contentView
+{
+ return self;
+}
+
++ (BOOL)web_requiresCustomSnapshotting
+{
+ return false;
+}
+
+- (void)web_setMinimumSize:(CGSize)size
+{
+}
+
+- (void)web_setOverlaidAccessoryViewsInset:(CGSize)inset
+{
+}
+
+- (void)web_computedContentInsetDidChange
+{
+ [self _layoutThumbnailView];
+}
+
+- (void)web_setFixedOverlayView:(UIView *)fixedOverlayView
+{
+}
+
+- (void)web_didSameDocumentNavigation:(WKSameDocumentNavigationType)navigationType
+{
+}
+
+- (BOOL)web_isBackground
+{
+ return self.isBackground;
+}
+
+#pragma mark Find-in-Page
+
+- (void)web_countStringMatches:(NSString *)string options:(_WKFindOptions)options maxCount:(NSUInteger)maxCount
+{
+ RefPtr<WebKit::WebPageProxy> page = _webView->_page;
+ page->findClient().didCountStringMatches(page.get(), string, 0);
+}
+
+- (void)web_findString:(NSString *)string options:(_WKFindOptions)options maxCount:(NSUInteger)maxCount
+{
+ RefPtr<WebKit::WebPageProxy> page = _webView->_page;
+ page->findClient().didFailToFindString(page.get(), string);
+}
+
+- (void)web_hideFindUI
+{
+}
+
+#pragma mark QLPreviewItemDataProvider
+
+- (NSData *)provideDataForItem:(QLItem *)item
+{
+ return _data.get();
+}
+
+@end
+
+#endif
Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (285634 => 285635)
--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2021-11-11 17:18:22 UTC (rev 285634)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2021-11-11 17:22:28 UTC (rev 285635)
@@ -748,7 +748,7 @@
31312621148FF82C00BA2A39 /* WebNotificationManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 3131261C148FF82B00BA2A39 /* WebNotificationManager.h */; };
3155EE0D2673F4F00085E59A /* VisionKitSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 3155EE0C2673F4EF0085E59A /* VisionKitSPI.h */; };
3157135F2040A9B20084F9CF /* SystemPreviewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 3157135D2040A9B20084F9CF /* SystemPreviewController.h */; };
- 316B8B642054B55800BD4A62 /* WKSystemPreviewView.h in Headers */ = {isa = PBXBuildFile; fileRef = 316B8B622054B55800BD4A62 /* WKSystemPreviewView.h */; };
+ 316B8B642054B55800BD4A62 /* WKUSDPreviewView.h in Headers */ = {isa = PBXBuildFile; fileRef = 316B8B622054B55800BD4A62 /* WKUSDPreviewView.h */; };
317FE7C51C487A6C00A0CA89 /* APIExperimentalFeature.h in Headers */ = {isa = PBXBuildFile; fileRef = 317FE7C21C487A6600A0CA89 /* APIExperimentalFeature.h */; };
317FE7CD1C487DAE00A0CA89 /* _WKExperimentalFeatureInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 317FE7C91C487D9D00A0CA89 /* _WKExperimentalFeatureInternal.h */; };
317FE7CF1C487DBD00A0CA89 /* _WKExperimentalFeature.h in Headers */ = {isa = PBXBuildFile; fileRef = 317FE7C71C487D9D00A0CA89 /* _WKExperimentalFeature.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -3437,8 +3437,8 @@
3157135C2040A9B20084F9CF /* SystemPreviewControllerCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = SystemPreviewControllerCocoa.mm; sourceTree = "<group>"; };
3157135D2040A9B20084F9CF /* SystemPreviewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SystemPreviewController.h; sourceTree = "<group>"; };
31607F3819627002009B87DA /* LegacySessionStateCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LegacySessionStateCoding.h; sourceTree = "<group>"; };
- 316B8B612054B55800BD4A62 /* WKSystemPreviewView.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = WKSystemPreviewView.mm; path = ios/WKSystemPreviewView.mm; sourceTree = "<group>"; };
- 316B8B622054B55800BD4A62 /* WKSystemPreviewView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WKSystemPreviewView.h; path = ios/WKSystemPreviewView.h; sourceTree = "<group>"; };
+ 316B8B612054B55800BD4A62 /* WKUSDPreviewView.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = WKUSDPreviewView.mm; path = ios/WKUSDPreviewView.mm; sourceTree = "<group>"; };
+ 316B8B622054B55800BD4A62 /* WKUSDPreviewView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WKUSDPreviewView.h; path = ios/WKUSDPreviewView.h; sourceTree = "<group>"; };
3178AF9720E2A7F80074DE94 /* PDFKitSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PDFKitSPI.h; sourceTree = "<group>"; };
317FE7C11C487A6600A0CA89 /* APIExperimentalFeature.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = APIExperimentalFeature.cpp; sourceTree = "<group>"; };
317FE7C21C487A6600A0CA89 /* APIExperimentalFeature.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIExperimentalFeature.h; sourceTree = "<group>"; };
@@ -7673,8 +7673,6 @@
CE5B4C8721B73D870022E64F /* WKSyntheticFlagsChangedWebEvent.mm */,
26F10BE619187E2E001D0E68 /* WKSyntheticTapGestureRecognizer.h */,
26F10BE719187E2E001D0E68 /* WKSyntheticTapGestureRecognizer.mm */,
- 316B8B622054B55800BD4A62 /* WKSystemPreviewView.h */,
- 316B8B612054B55800BD4A62 /* WKSystemPreviewView.mm */,
CE21215D240EE571006ED443 /* WKTextPlaceholder.h */,
CE21215E240EE571006ED443 /* WKTextPlaceholder.mm */,
CE45945A240F85B90078019F /* WKTextSelectionRect.h */,
@@ -7681,6 +7679,8 @@
CE45945B240F85B90078019F /* WKTextSelectionRect.mm */,
71A676A422C62318007D6295 /* WKTouchActionGestureRecognizer.h */,
71A676A522C62318007D6295 /* WKTouchActionGestureRecognizer.mm */,
+ 316B8B622054B55800BD4A62 /* WKUSDPreviewView.h */,
+ 316B8B612054B55800BD4A62 /* WKUSDPreviewView.mm */,
2D1E8221216FFF5000A15265 /* WKWebEvent.h */,
2D1E8222216FFF5100A15265 /* WKWebEvent.mm */,
);
@@ -12965,7 +12965,6 @@
9593675F252E5E3100D3F0A0 /* WKStylusDeviceObserver.h in Headers */,
CE5B4C8821B73D870022E64F /* WKSyntheticFlagsChangedWebEvent.h in Headers */,
26F10BE819187E2E001D0E68 /* WKSyntheticTapGestureRecognizer.h in Headers */,
- 316B8B642054B55800BD4A62 /* WKSystemPreviewView.h in Headers */,
51F886A61F2C228100C193EF /* WKTestingSupport.h in Headers */,
31D755C11D91B81500843BD1 /* WKTextChecker.h in Headers */,
2DD67A351BD861060053B251 /* WKTextFinderClient.h in Headers */,
@@ -12988,6 +12987,7 @@
51D124341E6DF643002B2820 /* WKURLSchemeHandler.h in Headers */,
51D124351E6DF652002B2820 /* WKURLSchemeTask.h in Headers */,
5C62FDF91EFC271C00CE072E /* WKURLSchemeTaskPrivate.h in Headers */,
+ 316B8B642054B55800BD4A62 /* WKUSDPreviewView.h in Headers */,
1AFA3AC918E61C61003CCBAE /* WKUserContentController.h in Headers */,
1AAF08A4192682DA00B6390C /* WKUserContentControllerInternal.h in Headers */,
7C89D2B61A6B0DD9003A5FDE /* WKUserContentControllerPrivate.h in Headers */,